{"version":3,"file":"ApplifyChat.eEEE5ZzF.mjs","names":[],"sources":["https:/framerusercontent.com/modules/GlDesPKDAfkMWRDhrY7X/Amf1IK1xzEe92fanMb3b/ApplifyChat.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// Several responsive instances may share one launcher. Remove it only after the\n// last instance leaves the page. A deferred cleanup also supports React remounts.\nlet owners=0;let loader;let currentUrl;let fallback;let cleanupTimer;/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 56\n * @framerIntrinsicHeight 56\n */export default function ApplifyChat({chatUrl,style}){const canvas=RenderTarget.current()===RenderTarget.canvas;React.useEffect(()=>{if(canvas||!chatUrl)return;let url;try{url=new URL(chatUrl);if(!/^https?:$/.test(url.protocol))return;}catch{return;}const chatWindow=window;clearTimeout(cleanupTimer);// A URL change replaces the shared widget even if another responsive\n// instance still owns it.\nif(loader&&currentUrl!==url.href){chatWindow.__applifyChat?.destroy();loader.remove();loader=undefined;fallback?.remove();fallback=undefined;}owners+=1;const instanceLoader=loader??document.createElement(\"script\");const onLoad=()=>{if(loader!==instanceLoader)return;if(owners>0)chatWindow.__applifyChat?.mount();else chatWindow.__applifyChat?.destroy();};const onError=()=>{if(loader!==instanceLoader||owners===0||fallback)return;fallback=document.createElement(\"a\");fallback.href=\"https://wa.me/971553110959\";fallback.target=\"_blank\";fallback.rel=\"noopener noreferrer\";fallback.textContent=\"Contact us\";fallback.setAttribute(\"aria-label\",\"Contact Applify Lab on WhatsApp\");fallback.style.cssText=\"position:fixed;bottom:max(20px,env(safe-area-inset-bottom));right:max(20px,env(safe-area-inset-right));z-index:2147483000;padding:16px 20px;border-radius:28px;background:#d5fa45;color:#11140d;font:14px Arial;text-decoration:none\";document.body.append(fallback);};if(!loader){currentUrl=url.href;loader=instanceLoader;loader.src=new URL(\"/chat-widget.js\",url).href;loader.dataset.chatUrl=url.href;loader.dataset.managed=\"true\";loader.addEventListener(\"load\",onLoad,{once:true});loader.addEventListener(\"error\",onError,{once:true});document.body.append(loader);}else{chatWindow.__applifyChat?.mount();loader.addEventListener(\"error\",onError,{once:true});}return()=>{owners-=1;instanceLoader.removeEventListener(\"error\",onError);cleanupTimer=setTimeout(()=>{if(owners>0)return;chatWindow.__applifyChat?.destroy();loader?.remove();fallback?.remove();loader=undefined;currentUrl=undefined;fallback=undefined;},0);};},[canvas,chatUrl]);if(canvas)return /*#__PURE__*/_jsx(\"div\",{style:{...style,display:\"grid\",placeItems:\"center\",background:\"#d5fa45\",borderRadius:\"50%\",color:\"#11140d\",font:\"bold 14px Arial\"},children:\"Chat\"});return /*#__PURE__*/_jsx(\"div\",{style:{...style,pointerEvents:\"none\"},\"aria-hidden\":\"true\"});}addPropertyControls(ApplifyChat,{chatUrl:{type:ControlType.String,title:\"Chat URL\",placeholder:\"https://your-chat-app.vercel.app/embed\",description:\"The deployed chat app's /embed URL. No API key or token.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ApplifyChat\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"56\",\"framerIntrinsicHeight\":\"56\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ApplifyChat.map"],"mappings":"+LAOG,SAAwB,EAAY,CAAC,UAAQ,SAAO,CAAC,IAAM,EAAO,EAAa,QAAQ,IAAI,EAAa,OAEgrD,OAFzqD,MAAoB,CAAC,GAAG,GAAQ,CAAC,EAAQ,OAAO,IAAI,EAAI,GAAG,CAAsB,GAArB,EAAI,IAAI,IAAI,CAAO,EAAK,CAAC,YAAY,KAAK,EAAI,QAAQ,EAAE,MAAO,MAAM,CAAC,MAAO,CAAC,IAAM,EAAW,EAAO,aAAa,CAAY,EAE1S,GAAQ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