import { defineComponent as s, createElementBlock as f, openBlock as m, ref as u, onMounted as l, onBeforeUnmount as d } from "vue";
const w = ["src"], y = s({ name: "zv-scene-unity-iframe" }), I = /* @__PURE__ */ s({
  ...y,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {},
    isPreview: { type: Boolean },
    disableDrag: { type: Boolean }
  },
  emits: ["unity-scene-on-message"],
  setup(i, { emit: a }) {
    const t = i, o = a, r = () => {
      const e = u();
      return l(() => {
        window.SHJSceneUnityIframeInstance || (window.SHJSceneUnityIframeInstance = {}), window.SHJSceneUnityIframeInstance.url = t.basicOption.iframeUrl, window.SHJSceneUnityIframeInstance.ref = e.value;
      }), d(() => {
        window.SHJSceneUnityIframeInstance = null;
      }), window.addEventListener("message", (n) => {
        o("unity-scene-on-message", n.data), window.SHJParseEvent(t.useEvents, "unity-scene-on-message", n.data);
      }, !1), { unityIframeRef: e };
    }, { unityIframeRef: c } = r();
    return (e, n) => (m(), f("iframe", {
      ref_key: "unityIframeRef",
      ref: c,
      src: e.basicOption.iframeUrl,
      sandbox: "allow-scripts allow-same-origin",
      style: { width: "100%", height: "100%", border: "0" }
    }, null, 8, w));
  }
});
export {
  I as default
};
