import { FooterTheme } from '@/features/bubble/types'; import { Show, onCleanup, onMount } from 'solid-js'; type Props = { footer?: FooterTheme; botContainer: HTMLDivElement | undefined; poweredByTextColor?: string; badgeBackgroundColor?: string; }; const defaultTextColor = '#303235'; export const Badge = (props: Props) => { let liteBadge: HTMLAnchorElement | undefined; let observer: MutationObserver | undefined; const appendBadgeIfNecessary = (mutations: MutationRecord[]) => { mutations.forEach((mutation) => { mutation.removedNodes.forEach((removedNode) => { if ('id' in removedNode && liteBadge && removedNode.id == 'lite-badge') { console.log("Sorry, you can't able to do that 😅"); props.botContainer?.append(liteBadge); } }); }); }; onMount(() => { if (!document || !props.botContainer) return; observer = new MutationObserver(appendBadgeIfNecessary); observer.observe(props.botContainer, { subtree: false, childList: true, }); }); onCleanup(() => { if (observer) observer.disconnect(); }); return ( <> {props.footer?.text ?? 'AI can make mistakes'}  {props.footer?.company ?? 'Consider checking important information'} ); };