import{o as k,u as E,e as b,a0 as B,a1 as S}from"./index-d64a7cc4.js";import{d as I,r as C,e as r,w as L,f as D,o as F,U as f,a8 as h,a3 as c,a5 as M,S as g,ah as U}from"./vue-10b4afc0.js";import"./naive-ui-fedd20b1.js";import"./vueuse-motion-d4cdaf7b.js";const W={class:"w-full h-full relative"},A={class:"loading"},N=U('',7),T=[N],V=["src"],q=I({__name:"index",setup(G){const _=k(),l=E(),n=C(!1),i=r(()=>l.iframeUrl),o=b(),u=r(()=>o.theme==="dark");function v(){const e=document.getElementById("iframe");e!=null&&e.addEventListener||e==null||e.attachEvent("onload",d),e==null||e.addEventListener("load",d,!0)}const m=r(()=>o.theme);L(m,e=>{s({type:"theme",data:e})}),D(()=>{if(!i.value)return _.push("/");n.value=!0,v(),window.addEventListener("message",p)});async function p(e){const{type:t,data:a}=e.data;t==="theme"&&o.setTheme(a==="dark"?"dark":"light"),t==="chat"&&w(a)}function w(e){B({prompt:e}).then(t=>{const{code:a,data:y}=t;a===200&&s({type:"chat",data:x(y)})})}function x(e){const t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e.replace(t,"")}function s(e){document.getElementById("iframe").contentWindow.postMessage(e,"*")}function d(){s({type:"theme",data:m.value});const e=S();e&&s({type:"token",data:e}),n.value=!1}return F(()=>{l.updateIframeUrl("");const e=document.getElementById("iframe");e==null||e.removeEventListener("load",d),window.removeEventListener("message",p)}),(e,t)=>(g(),f("div",W,[n.value?(g(),f("div",{key:0,class:h(["main-container absolute left-0 right-0 bottom-0 top-0 backdrop-blur",[u.value?"dark:bg-black/20":"bg-white/80"]])},[c("div",A,[c("div",{class:h(["loading-text ",u.value?"text-[#fff]":"text-[#000]"]),id:"loading-text"},T,2)])],2)):M("",!0),c("iframe",{id:"iframe",src:i.value,style:{width:"100%",height:"100%",border:"none"},allow:"fullscreen"},null,8,V)]))}});export{q as default};