"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),l={class:"iframe-webscoket"},w=["src"],u=o.defineComponent({name:"zv-scene-ue-iframe"}),E=o.defineComponent({...u,props:{basicOption:{},sources:{},useEvents:{},uuid:{},isPreview:{type:Boolean}},emits:["ue-scoket-on-message"],setup(i,{emit:m}){const c=i,S=m;return(t=>{let n=0,r;const a=()=>{window.SHJSceneUEIframeWebscoket&&(window.SHJSceneUEIframeWebscoket.onclose=null,window.SHJSceneUEIframeWebscoket.close()),window.SHJSceneUEIframeWebscoket=new WebSocket(t.webSocketUrl),window.SHJSceneUEIframeWebscoket.onmessage=s=>{try{const e=JSON.parse(s.data);if(e.type==="ping")return;if(!e.data)throw new Error("数据格式异常");S("ue-scoket-on-message",e.data),window.SHJParseEvent(c.useEvents,"ue-scoket-on-message",e.data)}catch{}},window.SHJSceneUEIframeWebscoket.onopen=()=>{n=0,clearTimeout(r)},window.SHJSceneUEIframeWebscoket.onerror=()=>{},window.SHJSceneUEIframeWebscoket.onclose=s=>{const e=3e3*Math.pow(2,n);r=setTimeout(()=>{n<1/0&&(n++,a())},e)}};o.onMounted(()=>{if(t.webSocketUrl)try{a()}catch{}}),o.onBeforeUnmount(()=>{window.SHJSceneUEIframeWebscoket&&window.SHJSceneUEIframeWebscoket.close()})})(c.basicOption),(t,d)=>(o.openBlock(),o.createElementBlock("div",l,[o.createElementVNode("iframe",{src:t.basicOption.iframeUrl,sandbox:"allow-scripts allow-same-origin",style:{width:"100%",height:"100%",border:"0"}},null,8,w)]))}});exports.default=E;
