import{u as _}from"../admin/js/admin.js";import{c as s,r as g,o as f,n as u,e as h,w as E,q as d,t as z,v as l,k as c}from"./purify.es-C5Nd4Mfd.js";const b={class:"extension-page-host"},y={key:0,class:"text-center py-12 text-gray-400"},k={key:1,class:"text-center py-12"},T=["id","data-extension","data-page"],B={__name:"ExtensionPageHost",setup(L){const r=_(),t=s(()=>r.params.extension||""),a=s(()=>r.params.page||""),m=s(()=>`zc-ext-mount--${t.value}--${a.value}`),n=g("waiting");let i=null;function v(){return{extension:t.value,page:a.value,mountId:m.value}}function x(){if(!t.value)return;n.value="waiting";const o=v();window.__zenochatbot_ext_pending_mount=o,window.dispatchEvent(new CustomEvent("zenochatbot:ext:mount",{detail:o})),clearTimeout(i),i=setTimeout(()=>{n.value==="waiting"&&(n.value="failed")},8e3)}function w(o){var e;((e=o.detail)==null?void 0:e.extension)===t.value&&(n.value="mounted",window.__zenochatbot_ext_pending_mount=null,clearTimeout(i))}function p(o){var e;((e=o.detail)==null?void 0:e.extension)===t.value&&n.value==="waiting"&&u(()=>{window.dispatchEvent(new CustomEvent("zenochatbot:ext:mount",{detail:v()}))})}return f(()=>{window.addEventListener("zenochatbot:ext:mounted",w),window.addEventListener("zenochatbot:ext:ready",p),u(x)}),h(()=>{window.removeEventListener("zenochatbot:ext:mounted",w),window.removeEventListener("zenochatbot:ext:ready",p),clearTimeout(i),window.__zenochatbot_ext_pending_mount=null,window.dispatchEvent(new CustomEvent("zenochatbot:ext:unmount",{detail:{extension:t.value}}))}),E([t,a],()=>{u(x)}),(o,e)=>(c(),d("div",b,[n.value==="waiting"?(c(),d("div",y,e[0]||(e[0]=[l("div",{class:"animate-pulse"},"Loading extension...",-1)]))):n.value==="failed"?(c(),d("div",k,e[1]||(e[1]=[l("p",{class:"text-gray-500"},"Extension failed to load. Please refresh the page.",-1)]))):z("",!0),l("div",{id:m.value,"data-extension":t.value,"data-page":a.value},null,8,T)]))}};export{B as default};
