import{t as n}from"./index-b309bf9f-1782729249161v=1.0.0.js";import{r,Y as E,m as I,U as L}from"./vendor-1e24e3ad-1782729249161v=1.0.0.js";const p=i=>{r(i);const l=r(),f=r([]),a=r(!1),o=r(!0);let t;const m=e=>{f.value.length>=5&&f.value.shift(),f.value.push(e)},d=e=>{n().info("onIframeLoad"),!a.value&&(a.value=!1,o.value=!1,t&&clearTimeout(t))},v=e=>{n().error("onIframeError",e)},c=(e=5e3)=>{a.value=!1,o.value=!1,t=setTimeout(()=>{a.value=!1,o.value=!0,console.warn("Iframe \u52A0\u8F7D\u8D85\u65F6")},e)},g=e=>{var s,u;(u=(s=l.value)==null?void 0:s.contentWindow)==null||u.postMessage(JSON.stringify(e),"*")};return E(()=>{a.value=!1,o.value=!1}),I(()=>{c(),window.addEventListener("message",e=>{const s=e.data;s.type==="H5_READY"&&(a.value=!0,t&&clearTimeout(t),o.value=!1,n().info("onMessage H5_READY",s.data))})}),L(()=>{n().info("onUnmounted"),a.value=!1,o.value=!1,window.removeEventListener("message",e=>{n().info("removeEventListener message")})}),{iframeRef:l,iframeReady:a,onIframeLoad:d,onIframeError:v,sendData:g,readySendDataList:f,addReadySendData:m,iframeLoadError:o}},D=p;export{D as u};
