// Generated by Construct, the game and animation creation tool
// Visit: https://www.construct.net

// workers/domHandler.js
"use strict";window.DOMHandler=class{constructor(t,i){this._iRuntime=t,this._componentId=i,this._hasTickCallback=!1,this._tickCallback=()=>this.Tick()}Attach(){}PostToRuntime(t,i,e,s){this._iRuntime.PostToRuntimeComponent(this._componentId,t,i,e,s)}PostToRuntimeAsync(t,i,e,s){return this._iRuntime.PostToRuntimeComponentAsync(this._componentId,t,i,e,s)}_PostToRuntimeMaybeSync(t,i,e){this._iRuntime.UsesWorker()?this.PostToRuntime(t,i,e):this._iRuntime._OnLocalRuntimeMessageFromDOM({"type":"event","component":this._componentId,"handler":t,"dispatchOpts":e||null,"data":i,"responseId":null})}AddRuntimeMessageHandler(t,i){this._iRuntime.AddRuntimeComponentMessageHandler(this._componentId,t,i)}AddRuntimeMessageHandlers(t){for(const[i,e]of t)this.AddRuntimeMessageHandler(i,e)}GetRuntimeInterface(){return this._iRuntime}GetComponentID(){return this._componentId}_StartTicking(){this._hasTickCallback||(this._iRuntime._AddRAFCallback(this._tickCallback),this._hasTickCallback=!0)}_StopTicking(){this._hasTickCallback&&(this._iRuntime._RemoveRAFCallback(this._tickCallback),this._hasTickCallback=!1)}Tick(){}},window.RateLimiter=class{constructor(t,i){this._callback=t,this._interval=i,this._timerId=-1,this._lastCallTime=-1/0,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1}SetCanRunImmediate(t){this._canRunImmediate=!!t}Call(){if(-1!==this._timerId)return;const t=Date.now(),i=t-this._lastCallTime,e=this._interval;i>=e&&this._canRunImmediate?(this._lastCallTime=t,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(e-i,4))}_RunCallback(){this._ignoreReset=!0,this._callback(),this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._lastCallTime=Date.now())}_OnTimer(){this._timerId=-1,this._lastCallTime=Date.now(),this._RunCallback()}_CancelTimer(){-1!==this._timerId&&(self.clearTimeout(this._timerId),this._timerId=-1)}Release(){this._CancelTimer(),this._callback=null,this._timerCallFunc=null}};

// workers/domElementHandler.js
"use strict";{class e{constructor(e){this._elem=e,this._hadFirstUpdate=!1,this._isVisibleFlag=!0,this._wantHtmlIndex=-1,this._actualHtmlIndex=-1,this._htmlZIndex=-1}SetVisibleFlag(e){this._isVisibleFlag=!!e}GetVisibleFlag(){return this._isVisibleFlag}HadFirstUpdate(){return this._hadFirstUpdate}SetHadFirstUpdate(){this._hadFirstUpdate=!0}GetWantHTMLIndex(){return this._wantHtmlIndex}SetWantHTMLIndex(e){this._wantHtmlIndex=e}GetActualHTMLIndex(){return this._actualHtmlIndex}SetActualHTMLIndex(e){this._actualHtmlIndex=e}SetHTMLZIndex(e){this._htmlZIndex=e}GetHTMLZIndex(){return this._htmlZIndex}GetElement(){return this._elem}}window.DOMElementHandler=class extends self.DOMHandler{constructor(e,t){super(e,t),this._elementMap=new Map,this._autoAttach=!0,this.AddRuntimeMessageHandlers([["create",e=>this._OnCreate(e)],["destroy",e=>this._OnDestroy(e)],["set-visible",e=>this._OnSetVisible(e)],["update-position",e=>this._OnUpdatePosition(e)],["update-state",e=>this._OnUpdateState(e)],["focus",e=>this._OnSetFocus(e)],["set-css-style",e=>this._OnSetCssStyle(e)],["set-attribute",e=>this._OnSetAttribute(e)],["remove-attribute",e=>this._OnRemoveAttribute(e)]]),this.AddDOMElementMessageHandler("get-element",e=>e)}SetAutoAttach(e){this._autoAttach=!!e}AddDOMElementMessageHandler(e,t){this.AddRuntimeMessageHandler(e,e=>{const n=e["elementId"],s=this.GetElementById(n);return t(s,e)})}AddDOMElementMessageHandlers(e){for(const[t,n]of e)this.AddDOMElementMessageHandler(t,n)}_OnCreate(t){const n=t["elementId"],s=this.CreateElement(n,t),i=new e(s);this._elementMap.set(n,i),s.style.boxSizing="border-box",s.style.display="none",i.SetVisibleFlag(t["isVisible"]);const l=this._GetFocusElement(s);l.addEventListener("focus",e=>this._OnFocus(n)),l.addEventListener("blur",e=>this._OnBlur(n));const a=t["htmlIndex"];if(i.SetWantHTMLIndex(a),i.SetHTMLZIndex(t["htmlZIndex"]),this._autoAttach){const e=this.GetRuntimeInterface().GetAvailableHTMLIndex(a);i.SetActualHTMLIndex(e);this.GetRuntimeInterface().GetHTMLWrapElement(e).appendChild(s)}}CreateElement(e,t){throw new Error("required override")}DestroyElement(e){}_OnDestroy(e){const t=e["elementId"],n=this.GetElementById(t);this.DestroyElement(n),this._autoAttach&&n.parentElement.removeChild(n),this._elementMap.delete(t)}PostToRuntimeElement(e,t,n){n||(n={}),n["elementId"]=t,this.PostToRuntime(e,n)}_PostToRuntimeElementMaybeSync(e,t,n){n||(n={}),n["elementId"]=t,this._PostToRuntimeMaybeSync(e,n)}_OnSetVisible(e){if(!this._autoAttach)return;const t=this._elementMap.get(e["elementId"]),n=t.GetElement();t.HadFirstUpdate()?n.style.display=e["isVisible"]?"":"none":t.SetVisibleFlag(e["isVisible"])}_OnUpdatePosition(e){if(!this._autoAttach)return;const t=this._elementMap.get(e["elementId"]),n=t.GetElement(),s=this.GetRuntimeInterface();n.style.left=e["left"]+"px",n.style.top=e["top"]+"px",n.style.width=e["width"]+"px",n.style.height=e["height"]+"px";const i=e["fontSize"];null!==i&&(n.style.fontSize=i+"em");const l=e["htmlIndex"];t.SetWantHTMLIndex(l);const a=s.GetAvailableHTMLIndex(l);if(a!==t.GetActualHTMLIndex()){n.remove();s.GetHTMLWrapElement(a).appendChild(n),t.SetActualHTMLIndex(a),s._UpdateHTMLElementsZOrder()}const d=e["htmlZIndex"];d!==t.GetHTMLZIndex()&&(t.SetHTMLZIndex(d),s._UpdateHTMLElementsZOrder()),t.HadFirstUpdate()||(t.SetHadFirstUpdate(),t.GetVisibleFlag()&&(n.style.display=""))}_OnHTMLLayersChanged(){if(this._autoAttach)for(const e of this._elementMap.values()){const t=this.GetRuntimeInterface().GetAvailableHTMLIndex(e.GetWantHTMLIndex()),n=e.GetActualHTMLIndex();if(-1!==t&&-1!==n&&t!==n){const n=e.GetElement();n.remove();this.GetRuntimeInterface().GetHTMLWrapElement(t).appendChild(n),e.SetActualHTMLIndex(t)}}}_GetAllElementStatesForZOrderUpdate(){return this._autoAttach?[...this._elementMap.values()]:null}_OnUpdateState(e){const t=this.GetElementById(e["elementId"]);this.UpdateState(t,e)}UpdateState(e,t){throw new Error("required override")}_GetFocusElement(e){return e}_OnFocus(e){this.PostToRuntimeElement("elem-focused",e)}_OnBlur(e){this.PostToRuntimeElement("elem-blurred",e)}_OnSetFocus(e){const t=this._GetFocusElement(this.GetElementById(e["elementId"]));e["focus"]?t.focus():t.blur()}_OnSetCssStyle(e){const t=this.GetElementById(e["elementId"]),n=e["prop"],s=e["val"];n.startsWith("--")?t.style.setProperty(n,s):t.style[n]=s}_OnSetAttribute(e){this.GetElementById(e["elementId"]).setAttribute(e["name"],e["val"])}_OnRemoveAttribute(e){this.GetElementById(e["elementId"]).removeAttribute(e["name"])}GetElementById(e){const t=this._elementMap.get(e);if(!t)throw new Error(`no element with id ${e}`);return t.GetElement()}}}

// workers/domSide.js
"use strict";{const e=/(iphone|ipod|ipad|macos|macintosh|mac os x)/i.test(navigator.userAgent),t=/android/i.test(navigator.userAgent),s=/safari/i.test(navigator.userAgent)&&!/(chrome|chromium|edg\/|OPR\/)/i.test(navigator.userAgent);let n=0;function r(e){const t=document.createElement("script");return t.async=!1,t.type="module",e.isStringSrc?new Promise(s=>{const r="c3_resolve_"+n;++n,self[r]=s,t.textContent=e.str+`\n\nself["${r}"]();`,document.head.appendChild(t)}):new Promise((s,n)=>{t.onload=s,t.onerror=n,t.src=e,document.head.appendChild(t)})}async function i(){if(!navigator["userActivation"]||"undefined"==typeof OffscreenCanvas)return!1;try{let e=!1;const t=new Blob(['\n\tself.addEventListener("message", () =>\n\t{\n\t\ttry {\n\t\t\tconst offscreenCanvas = new OffscreenCanvas(32, 32);\n\t\t\tconst gl = offscreenCanvas.getContext("webgl");\n\t\t\tself.postMessage(!!gl);\n\t\t}\n\t\tcatch (err)\n\t\t{\n\t\t\tconsole.warn("Feature detection worker error:", err);\n\t\t\tself.postMessage(false);\n\t\t}\n\t});'],{"type":"text/javascript"}),s=new Worker(URL.createObjectURL(t),{get type(){e=!0}}),n=await new Promise(e=>{s.addEventListener("message",t=>{s.terminate(),e(t.data)}),s.postMessage("")});return e&&n}catch(e){return console.warn("Error feature detecting worker mode: ",e),!1}}let a=new Audio;const o={"audio/webm; codecs=opus":!!a.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!a.canPlayType("audio/ogg; codecs=opus"),"audio/webm; codecs=vorbis":!!a.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!a.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!a.canPlayType("audio/mp4"),"audio/mpeg":!!a.canPlayType("audio/mpeg")};a=null;window["RealFile"]=window["File"];const l=[],d=new Map,c=new Map;let p=0;const h=[];self.runOnStartup=function(e){if("function"!=typeof e)throw new Error("runOnStartup called without a function");h.push(e)};const m=new Set(["cordova","playable-ad-single-file","playable-ad-zip","instant-games"]);function u(e){return m.has(e)}let w=!1;window.RuntimeInterface=class n{#e=!0;#t=null;#s="";#n="";#r=null;#i=null;#a=[];#o=null;#l=!0;#d=[];#c=[];#p=!1;#h=()=>this.#m();#u=!1;#w=0;#y=null;#g=-1;#f=()=>this.#v();#b=new Set;#M=null;#T=[];#R=[];#C="";constructor(e){if(this.#e=e.useWorker,this.#n=e.scriptFolder,this.#C=e.exportType,"playable-ad-single-file"!==this.#C&&"playable-ad-zip"!==this.#C&&"instant-games"!==this.#C||(this.#e=!1),(s||"macos-wkwebview"===this.#C)&&(this.#e=!1),"cordova"===this.#C&&this.#e&&t){const e=/Chrome\/(\d+)/i.exec(navigator.userAgent);e&&parseInt(e[1],10)>=90||(this.#e=!1)}this.IsAnyWebView2Wrapper()?self["chrome"]["webview"].addEventListener("message",e=>this.#I(e.data,e["additionalObjects"])):"macos-wkwebview"===this.#C?self["C3WrapperOnMessage"]=e=>this.#I(JSON.parse(e)):"linux-cef"===this.#C&&self["c3_linux_cef_set_message_callback"](e=>this.#I(JSON.parse(e))),this._localFileBlobs=null,this._localFileStrings=null,"html5"!==this.#C||window.isSecureContext||console.warn("[Construct] Warning: the browser indicates this is not a secure context. Some features may be unavailable. Use secure (HTTPS) hosting to ensure all features are available."),this.AddRuntimeComponentMessageHandler("canvas","update-size",e=>this.#S(e)),this.AddRuntimeComponentMessageHandler("canvas","set-html-layer-count",e=>this["_OnSetHTMLLayerCount"](e)),this.AddRuntimeComponentMessageHandler("canvas","cleanup-html-layers",()=>this.#L()),this.AddRuntimeComponentMessageHandler("canvas","update-html-layer-dom-state",e=>this.#P(e["layersDomState"])),this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",e=>this.#O(e)),this.AddRuntimeComponentMessageHandler("runtime","send-wrapper-extension-message",e=>this.#W(e)),this.AddRuntimeComponentMessageHandler("runtime","send-raw-wrapper-extension-message",e=>this.#H(e)),"cordova"===this.#C?document.addEventListener("deviceready",()=>this.#x(e)):this.#x(e),this._skipAndroidVirtualKeyboardDetection=0}Release(){this._CancelAnimationFrame(),this.#t&&(this.#t.onmessage=null,this.#t=null),this.#r&&(this.#r.terminate(),this.#r=null),this.#i&&(this.#i.Release(),this.#i=null);for(const{canvas:e,htmlWrap:t}of this.#d)e.remove(),t.remove();this.#d.length=0}GetMainCanvas(){return this.#d[0].canvas}GetAvailableHTMLIndex(e){return Math.min(e,this.#d.length-1)}GetHTMLWrapElement(e){if(e<0||e>=this.#d.length)throw new RangeError("invalid canvas layer");return this.#d[e].htmlWrap}"_GetHTMLWrapElement"(e){return this.GetHTMLWrapElement(e)}GetRuntimeBaseURL(){return this.#s}UsesWorker(){return this.#e}GetExportType(){return this.#C}GetScriptFolder(){return this.#n}IsiOSCordova(){return e&&"cordova"===this.#C}IsiOSWebView(){const t=navigator.userAgent;return e&&u(this.#C)||navigator["standalone"]||/crios\/|fxios\/|edgios\//i.test(t)}IsAndroid(){return t}IsAndroidWebView(){return t&&u(this.#C)}IsWindowsWebView2(){return"windows-webview2"===this.#C||!!("preview"===this.#C&&window["chrome"]&&window["chrome"]["webview"]&&window["chrome"]["webview"]["postMessage"])}IsAnyWebView2Wrapper(){return this.IsWindowsWebView2()||"xbox-uwp-webview2"===this.#C}SkipNextAndroidVirtualKeyboardDetection(){this.IsAndroidWebView()&&this._skipAndroidVirtualKeyboardDetection++}CanDoAndroidVirtualKeyboardDetection(){return this._CanDoAndroidVirtualKeyboardDetection().next().value}*_CanDoAndroidVirtualKeyboardDetection(){if(!this.IsAndroidWebView())return!0;yield 0===this._skipAndroidVirtualKeyboardDetection,this._skipAndroidVirtualKeyboardDetection>0&&this._skipAndroidVirtualKeyboardDetection--}async#x(e){if(this.#e){await i()||(this.#e=!1)}if("macos-wkwebview"===this.#C&&this._SendWrapperMessage({"type":"ready"}),this.IsAnyWebView2Wrapper()||"macos-wkwebview"===this.#C||"linux-cef"===this.#C){this.#k();const e=await this.#E();this.#T=e["registeredComponentIds"]}if("playable-ad-single-file"===this.#C&&(this._localFileBlobs=self["c3_base64files"],this._localFileStrings={},await this.#_()),e.runtimeBaseUrl)this.#s=e.runtimeBaseUrl;else{const e=location.origin;this.#s=("null"===e?"file:///":e)+location.pathname;const t=this.#s.lastIndexOf("/");-1!==t&&(this.#s=this.#s.substr(0,t+1))}const t=new MessageChannel;if(this.#t=t.port1,this.#t.onmessage=e=>this["_OnMessageFromRuntime"](e.data),window["c3_addPortMessageHandler"]&&window["c3_addPortMessageHandler"](e=>this.#A(e)),this.#y=new self.JobSchedulerDOM(this),await this.#y.Init(),"object"==typeof window["StatusBar"]&&window["StatusBar"]["hide"](),"object"==typeof window["AndroidFullScreen"])try{await new Promise((e,t)=>{window["AndroidFullScreen"]["immersiveMode"](e,t)})}catch(e){console.error("Failed to enter Android immersive mode: ",e)}this.#e?await this.#F(e,t.port2):await this.#D(e,t.port2)}#U(e){return{"runtimeBaseUrl":this.#s,"previewUrl":location.href,"windowInnerWidth":this._GetWindowInnerWidth(),"windowInnerHeight":this._GetWindowInnerHeight(),"cssDisplayMode":this.GetCssDisplayMode(),"devicePixelRatio":window.devicePixelRatio,"isFullscreen":n.IsDocumentFullscreen(),"swClientId":window["cr_swClientId"]||"","exportType":e.exportType,"fileMap":globalThis.c3_swFileMap??new Map(Object.entries(this._localFileBlobs??{})),"scriptFolder":this.#n,"isDebug":new URLSearchParams(self.location.search).has("debug"),"ife":!!self.ife,"jobScheduler":this.#y.GetPortData(),"supportedAudioFormats":o,"isiOSCordova":this.IsiOSCordova(),"isiOSWebView":this.IsiOSWebView(),"isWindowsWebView2":this.IsWindowsWebView2(),"isAnyWebView2Wrapper":this.IsAnyWebView2Wrapper(),"wrapperComponentIds":this.#T,"isFBInstantAvailable":void 0!==self["FBInstant"]}}async#F(e,t){const s=e.workerMainUrl;"preview"===this.#C?(this.#r=new Worker("previewworker.js",{type:"module",name:"Runtime"}),await new Promise((e,t)=>{const n=s=>{this.#r.removeEventListener("message",n),s.data&&"ok"===s.data["type"]?e():t()};this.#r.addEventListener("message",n),this.#r.postMessage({"type":"construct-worker-init","import":new URL(s,this.#s).toString()})})):this.#r=await this.CreateWorker(s,{type:"module",name:"Runtime"});const n=document.createElement("canvas");n.style.display="none";const r=n["transferControlToOffscreen"]();document.body.appendChild(n);const i=document.createElement("div");i.className="c3htmlwrap",i.setAttribute("interactive",""),document.body.appendChild(i),this.#d.push({canvas:n,htmlWrap:i,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=n,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this.#r.postMessage(Object.assign(this.#U(e),{"type":"init-runtime","isInWorker":!0,"messagePort":t,"canvas":r,"runtimeScriptList":e.runtimeScriptList,"projectMainScriptPath":e.projectMainScriptPath,"javaScriptInEventsPath":e.javaScriptInEventsPath,"typeScriptInEventsPath":e.typeScriptInEventsPath}),[t,r,...this.#y.GetPortTransferables()]),this.#a=l.map(e=>new e(this)),this.#B(),this.#o._AddDefaultCanvasEventHandlers(n),this.#o._AddDefaultHTMLWrapEventHandlers(i),this.#o._EnableWindowResizeEvent(),self["c3_callFunction"]=(e,t)=>this.#o._InvokeFunctionFromJS(e,t),"preview"===this.#C&&(self["goToLastErrorScript"]=()=>this.PostToRuntimeComponent("runtime","go-to-last-error-script"))}async#D(e,t){const s=document.createElement("canvas");s.style.display="none",document.body.appendChild(s);const n=document.createElement("div");n.className="c3htmlwrap",n.setAttribute("interactive",""),document.body.appendChild(n),this.#d.push({canvas:s,htmlWrap:n,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=s,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this.#a=l.map(e=>new e(this)),this.#B(),this.#o._AddDefaultCanvasEventHandlers(s),this.#o._AddDefaultHTMLWrapEventHandlers(n);const i=await Promise.all(e.runtimeScriptList.map(e=>this.#V(e)));await Promise.all(i.map(e=>r(e)));const a=e.projectMainScriptPath,o=e.javaScriptInEventsPath,d=e.typeScriptInEventsPath;if(a)try{if(await r(a),"preview"===this.#C&&!globalThis.C3_ProjectMainScriptOK)throw new Error("main script did not run to completion")}catch(e){this.#G(),console.error("Error loading project main script: ",e),alert(`Failed to load the project main script (${a}). Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the script. Press F12 and check the console for error details.`)}if(o)try{if(await r(o),"preview"===this.#C&&!globalThis.C3.JavaScriptInEvents)throw new Error("JavaScript in events did not run to completion")}catch(e){this.#G(),console.error("Error loading JavaScript in events: ",e),alert("Failed to load JavaScript in events. Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the 'Imports for events' script. Press F12 and check the console for error details.")}if(d)try{if(await r(d),"preview"===this.#C&&!globalThis.C3.TypeScriptInEvents)throw new Error("TypeScript in events did not run to completion")}catch(e){this.#G(),console.error("Error loading TypeScript in events: ",e),alert("Failed to load TypeScript in events. Check all your TypeScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the 'Imports for events' script. Press F12 and check the console for error details.")}const c=Object.assign(this.#U(e),{"isInWorker":!1,"messagePort":t,"canvas":s,"runOnStartupFunctions":h});this.#o._EnableWindowResizeEvent(),this.#j(),this.#i=self["C3_CreateRuntime"](c),await self["C3_InitRuntime"](this.#i,c)}async CreateWorker(e,t){if(e.startsWith("blob:"))return new Worker(e,t);if("playable-ad-single-file"===this.#C){const s=this._localFileBlobs[e];if(!s)throw new Error("missing script: "+e);return new Worker(URL.createObjectURL(s),t)}const s=new URL(e,location.href);if(location.origin!==s.origin){const e=await fetch(s);if(!e.ok)throw new Error("failed to fetch worker script");const n=await e.blob();return new Worker(URL.createObjectURL(n),t)}return new Worker(s,t)}_GetWindowInnerWidth(){return Math.max(window.innerWidth,1)}_GetWindowInnerHeight(){return Math.max(window.innerHeight,1)}GetCssDisplayMode(){if(this.IsAnyWebView2Wrapper())return"standalone";const e=this.GetExportType();return new Set(["cordova","macos-wkwebview","linux-cef"]).has(e)?"standalone":window.matchMedia("(display-mode: fullscreen)").matches?"fullscreen":window.matchMedia("(display-mode: standalone)").matches?"standalone":window.matchMedia("(display-mode: minimal-ui)").matches?"minimal-ui":navigator["standalone"]?"standalone":"browser"}#j(){this.#G()}#G(){const e=window["cr_previewLoadingElem"];e&&(e.parentElement.removeChild(e),window["cr_previewLoadingElem"]=null)}async#O(e){const t=await this.#y._CreateJobWorker();return{"outputPort":t,"transferables":[t]}}#S(e){if(this.IsExportingToVideo())return;const t=e["styleWidth"]+"px",s=e["styleHeight"]+"px",n=e["marginLeft"]+"px",r=e["marginTop"]+"px";for(const{canvas:e,htmlWrap:i}of this.#d)e.style.width=t,e.style.height=s,e.style.marginLeft=n,e.style.marginTop=r,i.style.width=t,i.style.height=s,i.style.marginLeft=n,i.style.marginTop=r,this.#l&&(e.style.display="",i.style.display="");document.documentElement.style.setProperty("--construct-scale",e["displayScale"]),this.#l=!1}"_OnSetHTMLLayerCount"(e){const t=e["count"],s=e["layersDomState"],n=e["immediate"],r=e["styleWidth"]+"px",i=e["styleHeight"]+"px",a=e["marginLeft"]+"px",o=e["marginTop"]+"px",l=[],d=[];if(t<this.#d.length)for(;this.#d.length>t;){const{canvas:e,htmlWrap:t}=this.#d.pop();t.remove(),this.#e&&!n?this.#c.push(e):e.remove()}else if(t>this.#d.length)for(let e=0,s=t-this.#d.length;e<s;++e){const e=document.createElement("canvas");if(e.classList.add("c3overlay"),this.#e){const t=e["transferControlToOffscreen"]();l.push(t),d.push(t)}else l.push(e);document.body.appendChild(e);const t=document.createElement("div");t.classList.add("c3htmlwrap","c3overlay"),t.setAttribute("interactive",""),document.body.appendChild(t),e.style.width=r,e.style.height=i,e.style.marginLeft=a,e.style.marginTop=o,t.style.width=r,t.style.height=i,t.style.marginLeft=a,t.style.marginTop=o,this.#o._AddDefaultCanvasEventHandlers(e),this.#o._AddDefaultHTMLWrapEventHandlers(t),this.#d.push({canvas:e,htmlWrap:t,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}})}this.#P(s);for(const e of this.#a)e instanceof window.DOMElementHandler&&e._OnHTMLLayersChanged();return this._UpdateHTMLElementsZOrder(),{"addedCanvases":l,"transferables":d}}#P(e){for(let t=0,s=Math.min(this.#d.length,e.length);t<s;++t){const{htmlWrap:s,lastHtmlLayerDomState:n}=this.#d[t],r=e[t],i=r["isVisible"],a=r["opacity"],o=r["isInteractive"];i!==n.isVisible&&(s.style.display=i?"":"none",n.isVisible=i),a!==n.opacity&&(s.style.opacity=1===a?"":String(a),n.opacity=a),o!==n.isInteractive&&(s.style.pointerEvents=o?"":"none",o?s.setAttribute("interactive",""):s.removeAttribute("interactive"),n.isInteractive=o)}}#L(){for(const e of this.#c)e.remove();this.#c.length=0}_UpdateHTMLElementsZOrder(){this.#p||(this.#p=!0,this._AddRAFCallback(this.#h))}#m(){this._RemoveRAFCallback(this.#h),this.#p=!1;let e=[];for(const t of this.#a)if(t instanceof window.DOMElementHandler){const s=t._GetAllElementStatesForZOrderUpdate();s&&e.push(...s)}e.sort((e,t)=>{const s=e.GetActualHTMLIndex(),n=t.GetActualHTMLIndex();if(s!==n)return s-n;return e.GetHTMLZIndex()-t.GetHTMLZIndex()});let t=0,s=0,n=0,r=e.length;for(;n<r;++n){const r=e[n];r.GetActualHTMLIndex()!==t&&(this.#z(t,e.slice(s,n)),t=r.GetActualHTMLIndex(),s=n)}s<n&&this.#z(t,e.slice(s,n))}#z(e,t){if(t.length<=1)return;if(e>=this.#d.length)return;const s=t.map(e=>e.GetElement()),n=new Set(s),r=this.GetHTMLWrapElement(e),i=Array.from(r.children).filter(e=>n.has(e));for(let e=0,t=0,n=s.length;e<n;++e){const n=s[e],a=i[t];n===a?++t:r["moveBefore"]?r["moveBefore"](n,a):r.insertBefore(n,a)}}_OnLocalRuntimeMessageFromDOM(e){if(this.#e)throw new Error("not available in worker mode");this.#i["_OnMessageFromDOM"](e)}PostToRuntimeComponent(e,t,s,n,r){this.#t.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":n||null,"data":s,"responseId":null},r)}PostToRuntimeComponentAsync(e,t,s,n,r){const i=p++,a=new Promise((e,t)=>{c.set(i,{resolve:e,reject:t})});return this.#t.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":n||null,"data":s,"responseId":i},r),a}"_OnMessageFromRuntime"(e){const t=e["type"];if("event"===t)return this.#Z(e);if("result"===t)this.#J(e);else if("runtime-ready"===t)this.#$();else if("alert-error"===t)this.#G(),alert(e["message"]);else{if("creating-runtime"!==t)throw new Error(`unknown message '${t}'`);this.#j()}}#Z(e){const t=e["component"],s=e["handler"],n=e["data"],r=e["responseId"],i=d.get(t);if(!i)return void console.warn(`[DOM] No event handlers for component '${t}'`);const a=i.get(s);if(!a)return void console.warn(`[DOM] No handler '${s}' for component '${t}'`);let o=null;try{o=a(n)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==r&&this.#q(r,!1,""+e))}if(null===r)return o;o&&o.then?o.then(e=>this.#q(r,!0,e)).catch(e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this.#q(r,!1,""+e)}):this.#q(r,!0,o)}#q(e,t,s){let n;s&&s["transferables"]&&(n=s["transferables"]),this.#t.postMessage({"type":"result","responseId":e,"isOk":t,"result":s},n)}#J(e){const t=e["responseId"],s=e["isOk"],n=e["result"],r=c.get(t);s?r.resolve(n):r.reject(n),c.delete(t)}AddRuntimeComponentMessageHandler(e,t,s){let n=d.get(e);if(n||(n=new Map,d.set(e,n)),n.has(t))throw new Error(`[DOM] Component '${e}' already has handler '${t}'`);n.set(t,s)}static AddDOMHandlerClass(e){if(l.includes(e))throw new Error("DOM handler already added");l.push(e)}#B(){for(const e of this.#a)if("runtime"===e.GetComponentID())return void(this.#o=e);throw new Error("cannot find runtime DOM handler")}#A(e){this.PostToRuntimeComponent("debugger","message",e)}#$(){for(const e of this.#a)e.Attach()}static IsDocumentFullscreen(){return!!(document["fullscreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"]||w)}static _SetWrapperIsFullscreenFlag(e){w=!!e}async GetRemotePreviewStatusInfo(){return await this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(e){this.#b.add(e),this._RequestAnimationFrame()}_RemoveRAFCallback(e){this.#b.delete(e),0===this.#b.size&&this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this.#g&&this.#b.size>0&&(this.#g=requestAnimationFrame(this.#f))}_CancelAnimationFrame(){-1!==this.#g&&(cancelAnimationFrame(this.#g),this.#g=-1)}#v(){this.#g=-1;for(const e of this.#b)e();this._RequestAnimationFrame()}TryPlayMedia(e){this.#o.TryPlayMedia(e)}RemovePendingPlay(e){this.#o.RemovePendingPlay(e)}_PlayPendingMedia(){this.#o._PlayPendingMedia()}SetSilent(e){this.#o.SetSilent(e)}IsAudioFormatSupported(e){return!!o[e]}SetIsExportingToVideo(e){this.#u=!0,this.#w=e}IsExportingToVideo(){return this.#u}GetExportToVideoDuration(){return this.#w}IsAbsoluteURL(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)}IsRelativeURL(e){return!this.IsAbsoluteURL(e)}async#V(e){if("playable-ad-single-file"===this.#C){if(this._localFileStrings.hasOwnProperty(e))return{isStringSrc:!0,str:this._localFileStrings[e]};if(this._localFileBlobs.hasOwnProperty(e))return URL.createObjectURL(this._localFileBlobs[e]);throw new Error("missing script: "+e)}return e}"_PlayableAdFetchBlob"(e){if(this._localFileBlobs.hasOwnProperty(e))return this._localFileBlobs[e];throw new Error("missing file: "+e)}#K(){const e=window["cordova"]&&window["cordova"]["plugins"]&&window["cordova"]["plugins"]["permissions"];if("object"!=typeof e)throw new Error("Permission API is not loaded");return e}#N(e,t){const s=e[t];if("string"!=typeof s)throw new Error("Invalid permission name");return s}#X(e){const t=this.#K();return new Promise((s,n)=>t["checkPermission"](this.#N(t,e),e=>s(!!e["hasPermission"]),n))}#Y(e){const t=this.#K();return new Promise((s,n)=>t["requestPermission"](this.#N(t,e),e=>s(!!e["hasPermission"]),n))}async RequestPermissions(e){if("cordova"!==this.GetExportType())return!0;if(this.IsiOSCordova())return!0;for(const t of e){if(await this.#X(t))continue;if(!1===await this.#Y(t))return!1}return!0}async RequirePermissions(...e){if(!1===await this.RequestPermissions(e))throw new Error("Permission not granted")}#I(e,t){if("object"!=typeof e||!e)return void console.warn("Unknown wrapper message: ",e);const s=e["type"];if("directory-handles"===s)this.#R=t;else if("wrapper-init-response"===s)this.#M(e),this.#M=null;else if("fullscreen-change"===s)n._SetWrapperIsFullscreenFlag(e["isFullscreen"]),this.#o._OnFullscreenChange();else if("log-to-console"===s)switch(e["logType"]){case"error":console.error(e["message"]);break;case"warning":console.warn(e["message"]);break;default:console.log(e["message"])}else if("window-maximized"==s||"window-minimized"==s){const e={"window-maximized":"windowmaximize","window-minimized":"windowminimize"};this.PostToRuntimeComponent("runtime",e[s],null,{"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0})}else"extension-message"===s?this.PostToRuntimeComponent("runtime","wrapper-extension-message",e):console.warn("Unknown wrapper message: ",e)}#W(e){this._SendWrapperMessage({"type":"extension-message","componentId":e["componentId"],"messageId":e["messageId"],"params":e["params"]||[],"asyncId":e["asyncId"]})}#H(e){this._SendWrapperMessage(e)}_SendWrapperMessage(e){this.IsAnyWebView2Wrapper()?window["chrome"]["webview"]["postMessage"](JSON.stringify(e)):"macos-wkwebview"===this.#C?window["webkit"]["messageHandlers"]["C3Wrapper"]["postMessage"](JSON.stringify(e)):"linux-cef"===this.#C&&window["c3_linux_cef_sendmessage"](JSON.stringify(e))}#k(){window.moveTo=(e,t)=>{this._SendWrapperMessage({"type":"set-window-position","windowX":Math.ceil(e),"windowY":Math.ceil(t)})},window.resizeTo=(e,t)=>{this._SendWrapperMessage({"type":"set-window-size","windowWidth":Math.ceil(e),"windowHeight":Math.ceil(t)})},window.focus=()=>{this._SendWrapperMessage({"type":"focus-window"})}}#E(){return new Promise(e=>{this.#M=e,this._SendWrapperMessage({"type":"wrapper-init"})})}_GetDirectoryHandles(){return this.#R}async#_(){const e=[];for(const[t,s]of Object.entries(this._localFileBlobs))e.push(this.#Q(t,s));await Promise.all(e)}async#Q(e,t){if("object"==typeof t)this._localFileBlobs[e]=new Blob([t["str"]],{"type":t["type"]}),this._localFileStrings[e]=t["str"];else{let s=await this.#ee(t);s||(s=this.#te(t)),this._localFileBlobs[e]=s}}async#ee(e){try{const t=await fetch(e);return await t.blob()}catch(e){return console.warn("Failed to fetch a data: URI. Falling back to a slower workaround. This is probably because the Content Security Policy unnecessarily blocked it. Allow data: URIs in your CSP to avoid this.",e),null}}#te(e){const t=this.#se(e);return this.#ne(t.data,t.mime_type)}#se(e){const t=e.indexOf(",");if(t<0)throw new URIError("expected comma in data: uri");const s=e.substring(5,t),n=e.substring(t+1),r=s.split(";"),i=r[0]||"",a=r[1],o=r[2];let l;return l="base64"===a||"base64"===o?atob(n):decodeURIComponent(n),{mime_type:i,data:l}}#ne(e,t){let s,n,r=e.length,i=r>>2,a=new Uint8Array(r),o=new Uint32Array(a.buffer,0,i);for(s=0,n=0;s<i;++s)o[s]=e.charCodeAt(n++)|e.charCodeAt(n++)<<8|e.charCodeAt(n++)<<16|e.charCodeAt(n++)<<24;let l=3&r;for(;l--;)a[n]=e.charCodeAt(n),++n;return new Blob([a],{"type":t})}}}

// workers/runtimeDomEvents.js
"use strict";{const e=self.RuntimeInterface,t=/firefox/i.test(navigator.userAgent);function i(e){return e["sourceCapabilities"]&&e["sourceCapabilities"]["firesTouchEvents"]||e["originalEvent"]&&e["originalEvent"]["sourceCapabilities"]&&e["originalEvent"]["sourceCapabilities"]["firesTouchEvents"]}const n=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),s={"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0},o={"dispatchUserScriptEvent":!0},a={"dispatchRuntimeEvent":!0};async function r(e){const t=URL.createObjectURL(e);try{return await(i=t,new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=i}))}finally{URL.revokeObjectURL(t)}var i}function d(e){do{if(e.parentNode&&e.hasAttribute("contenteditable"))return!0;e=e.parentNode}while(e);return!1}const l=new Set(["input","textarea","datalist","select"]);const c=new Set(["canvas","body","html"]);function h(e){if(!e.target.tagName)return;const t=e.target.tagName.toLowerCase();c.has(t)&&e.preventDefault()}function u(e){e.target.tagName&&e.target.classList.contains("c3htmlwrap")&&e.preventDefault()}function m(e){(e.metaKey||e.ctrlKey)&&e.preventDefault()}self["C3_GetSvgImageSize"]=async function(e){const t=await r(e);if(t.width>0&&t.height>0)return[t.width,t.height];{t.style.position="absolute",t.style.left="0px",t.style.top="0px",t.style.visibility="hidden",document.body.appendChild(t);const e=t.getBoundingClientRect();return document.body.removeChild(t),[e.width,e.height]}},self["C3_RasterSvgImageBlob"]=async function(e,t,i,n,s){const o=await r(e),a=document.createElement("canvas");a.width=n,a.height=s;return a.getContext("2d").drawImage(o,0,0,t,i),a};let g=!1;function p(){try{return window.parent&&window.parent.document.hasFocus()}catch(e){return!1}}document.addEventListener("pause",()=>g=!0),document.addEventListener("resume",()=>g=!1);const _="runtime",w=class extends self.DOMHandler{constructor(e){super(e,_),this._enableWindowResizeEvent=!1,this._simulatedResizeTimerId=-1,this._targetOrientation="any",this._attachedDeviceOrientationEvent=!1,this._attachedDeviceMotionEvent=!1,this._pageVisibilityIsHidden=!1,this._screenReaderTextWrap=document.createElement("div"),this._screenReaderTextWrap.className="c3-screen-reader-text",this._screenReaderTextWrap.setAttribute("aria-live","polite"),document.body.appendChild(this._screenReaderTextWrap),this._debugHighlightElem=null,this._isExportToVideo=!1,this._exportVideoProgressMessage="",this._exportVideoUpdateTimerId=-1,this._enableAndroidVKDetection=!1,this._lastWindowWidth=e._GetWindowInnerWidth(),this._lastWindowHeight=e._GetWindowInnerHeight(),this._virtualKeyboardHeight=0,this._vkTranslateYOffset=0,e.AddRuntimeComponentMessageHandler("runtime","invoke-download",e=>this._OnInvokeDownload(e)),e.AddRuntimeComponentMessageHandler("runtime","load-webfonts",e=>this._OnLoadWebFonts(e)),e.AddRuntimeComponentMessageHandler("runtime","raster-svg-image",e=>this._OnRasterSvgImage(e)),e.AddRuntimeComponentMessageHandler("runtime","get-svg-image-size",e=>this._OnGetSvgImageSize(e)),e.AddRuntimeComponentMessageHandler("runtime","set-target-orientation",e=>this._OnSetTargetOrientation(e)),e.AddRuntimeComponentMessageHandler("runtime","register-sw",()=>this._OnRegisterSW()),e.AddRuntimeComponentMessageHandler("runtime","post-to-debugger",e=>this._OnPostToDebugger(e)),e.AddRuntimeComponentMessageHandler("runtime","go-to-script",e=>this._OnPostToDebugger(e)),e.AddRuntimeComponentMessageHandler("runtime","before-start-ticking",()=>this._OnBeforeStartTicking()),e.AddRuntimeComponentMessageHandler("runtime","debug-highlight",e=>this._OnDebugHighlight(e)),e.AddRuntimeComponentMessageHandler("runtime","enable-device-orientation",()=>this._AttachDeviceOrientationEvent()),e.AddRuntimeComponentMessageHandler("runtime","enable-device-motion",()=>this._AttachDeviceMotionEvent()),e.AddRuntimeComponentMessageHandler("runtime","add-stylesheet",e=>this._OnAddStylesheet(e)),e.AddRuntimeComponentMessageHandler("runtime","script-create-worker",e=>this._OnScriptCreateWorker(e)),e.AddRuntimeComponentMessageHandler("runtime","alert",e=>this._OnAlert(e)),e.AddRuntimeComponentMessageHandler("runtime","screen-reader-text",e=>this._OnScreenReaderTextEvent(e)),e.AddRuntimeComponentMessageHandler("runtime","hide-cordova-splash",()=>this._OnHideCordovaSplash()),e.AddRuntimeComponentMessageHandler("runtime","set-exporting-to-video",e=>this._SetExportingToVideo(e)),e.AddRuntimeComponentMessageHandler("runtime","export-to-video-progress",e=>this._OnExportVideoProgress(e)),e.AddRuntimeComponentMessageHandler("runtime","exported-to-video",e=>this._OnExportedToVideo(e)),e.AddRuntimeComponentMessageHandler("runtime","exported-to-image-sequence",e=>this._OnExportedToImageSequence(e));const t=new Set(["input","textarea","datalist"]);if(window.addEventListener("contextmenu",e=>{const i=e.target,n=i.tagName.toLowerCase();t.has(n)||d(i)||e.preventDefault()}),window.addEventListener("selectstart",h),window.addEventListener("gesturehold",h),window.addEventListener("touchstart",h,{"passive":!1}),window.addEventListener("pointerdown",h,{"passive":!1}),this._mousePointerLastButtons=0,window.addEventListener("mousedown",e=>{1===e.button&&e.preventDefault()}),window.addEventListener("mousewheel",m,{"passive":!1}),window.addEventListener("wheel",m,{"passive":!1}),window.addEventListener("resize",()=>this._OnWindowResize()),window.addEventListener("fullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("webkitfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("mozfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("fullscreenerror",e=>this._OnFullscreenError(e)),window.addEventListener("webkitfullscreenerror",e=>this._OnFullscreenError(e)),window.addEventListener("mozfullscreenerror",e=>this._OnFullscreenError(e)),e.IsiOSWebView()){let e=1/0;window["visualViewport"].addEventListener("resize",()=>{const t=window["visualViewport"].height;t>e&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0),e=t}),document.documentElement.setAttribute("ioswebview","")}this._mediaPendingPlay=new Set,this._mediaRemovedPendingPlay=new WeakSet,this._isSilent=!1}_AddDefaultCanvasEventHandlers(e){e.addEventListener("selectstart",h),e.addEventListener("gesturehold",h),e.addEventListener("pointerdown",h)}_AddDefaultHTMLWrapEventHandlers(e){e.addEventListener("selectstart",u),e.addEventListener("gesturehold",u),e.addEventListener("touchstart",u),e.addEventListener("dragstart",u)}_OnBeforeStartTicking(){return self.setTimeout(()=>{this._enableAndroidVKDetection=!0},1e3),"cordova"===this._iRuntime.GetExportType()?(document.addEventListener("pause",()=>this._OnVisibilityChange(!0)),document.addEventListener("resume",()=>this._OnVisibilityChange(!1))):document.addEventListener("visibilitychange",()=>this._OnVisibilityChange("hidden"===document.visibilityState)),this._pageVisibilityIsHidden=!("hidden"!==document.visibilityState&&!g),{"isSuspended":this._pageVisibilityIsHidden}}Attach(){window.addEventListener("focus",()=>this._PostRuntimeEvent("window-focus")),window.addEventListener("blur",()=>{this._PostRuntimeEvent("window-blur",{"parentHasFocus":p()}),this._mousePointerLastButtons=0}),window.addEventListener("focusin",e=>{var t;t=e.target,(l.has(t.tagName.toLowerCase())||d(t))&&this._PostRuntimeEvent("keyboard-blur")}),window.addEventListener("keydown",e=>this._OnKeyEvent("keydown",e)),window.addEventListener("keyup",e=>this._OnKeyEvent("keyup",e)),window.addEventListener("mousedown",e=>this._OnMouseEvent("mousedown",e,o)),window.addEventListener("mousemove",e=>this._OnMouseEvent("mousemove",e,o)),window.addEventListener("mouseup",e=>this._OnMouseEvent("mouseup",e,o)),window.addEventListener("dblclick",e=>this._OnMouseEvent("dblclick",e,s)),window.addEventListener("wheel",e=>this._OnMouseWheelEvent("wheel",e,s)),window.addEventListener("pointerdown",e=>{this._HandlePointerDownFocus(e),this._OnPointerEvent("pointerdown",e)}),this._iRuntime.UsesWorker()&&void 0!==window["onpointerrawupdate"]&&self===self.top&&!t?window.addEventListener("pointerrawupdate",e=>this._OnPointerRawUpdate(e)):window.addEventListener("pointermove",e=>this._OnPointerEvent("pointermove",e)),window.addEventListener("pointerup",e=>this._OnPointerEvent("pointerup",e)),window.addEventListener("pointercancel",e=>this._OnPointerEvent("pointercancel",e));const e=()=>this._PlayPendingMedia();window.addEventListener("pointerup",e,!0),window.addEventListener("touchend",e,!0),window.addEventListener("click",e,!0),window.addEventListener("keydown",e,!0),window.addEventListener("gamepadconnected",e,!0),this._iRuntime.IsAndroid()&&!this._iRuntime.IsAndroidWebView()&&navigator["virtualKeyboard"]&&(navigator["virtualKeyboard"]["overlaysContent"]=!0,navigator["virtualKeyboard"].addEventListener("geometrychange",()=>{this._OnAndroidVirtualKeyboardChange(this._GetWindowInnerHeight(),navigator["virtualKeyboard"]["boundingRect"]["height"])})),this._iRuntime.IsiOSWebView()&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0)}_OnAndroidVirtualKeyboardChange(e,t){if(document.body.style.position="",document.body.style.overflow="",document.body.style.transform="",this._vkTranslateYOffset=0,t>0){const i=document.activeElement;if(i){const n=i.getBoundingClientRect();let s=(n.top+n.bottom)/2-(e-t)/2;s>t&&(s=t),s<0&&(s=0),s>0&&(document.body.style.position="absolute",document.body.style.overflow="visible",document.body.style.transform=`translateY(${-s}px)`,this._vkTranslateYOffset=s)}}}_PostRuntimeEvent(e,t){this.PostToRuntime(e,t||null,a)}_GetWindowInnerWidth(){return this._iRuntime._GetWindowInnerWidth()}_GetWindowInnerHeight(){return this._iRuntime._GetWindowInnerHeight()}_EnableWindowResizeEvent(){this._enableWindowResizeEvent=!0,this._lastWindowWidth=this._iRuntime._GetWindowInnerWidth(),this._lastWindowHeight=this._iRuntime._GetWindowInnerHeight()}_OnWindowResize(){if(this._isExportToVideo)return;if(!this._enableWindowResizeEvent)return;const t=this._GetWindowInnerWidth(),i=this._GetWindowInnerHeight();if(this._iRuntime.IsAndroidWebView())if(this._enableAndroidVKDetection){if(this._iRuntime.CanDoAndroidVirtualKeyboardDetection()&&this._lastWindowWidth===t&&i<this._lastWindowHeight)return this._virtualKeyboardHeight=this._lastWindowHeight-i,void this._OnAndroidVirtualKeyboardChange(this._lastWindowHeight,this._virtualKeyboardHeight);this._virtualKeyboardHeight>0&&(this._virtualKeyboardHeight=0,this._OnAndroidVirtualKeyboardChange(i,this._virtualKeyboardHeight)),this._lastWindowWidth=t,this._lastWindowHeight=i}else this._lastWindowWidth=t,this._lastWindowHeight=i;this.PostToRuntime("window-resize",{"innerWidth":t,"innerHeight":i,"devicePixelRatio":window.devicePixelRatio,"isFullscreen":e.IsDocumentFullscreen(),"cssDisplayMode":this._iRuntime.GetCssDisplayMode()}),this._iRuntime.IsiOSWebView()&&(-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._OnSimulatedResize(t,i,0))}_ScheduleSimulatedResize(e,t,i){-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._simulatedResizeTimerId=setTimeout(()=>this._OnSimulatedResize(e,t,i),48)}_OnSimulatedResize(t,i,n){const s=this._GetWindowInnerWidth(),o=this._GetWindowInnerHeight();this._simulatedResizeTimerId=-1,s!=t||o!=i?this.PostToRuntime("window-resize",{"innerWidth":s,"innerHeight":o,"devicePixelRatio":window.devicePixelRatio,"isFullscreen":e.IsDocumentFullscreen(),"cssDisplayMode":this._iRuntime.GetCssDisplayMode()}):n<10&&this._ScheduleSimulatedResize(s,o,n+1)}_OnSetTargetOrientation(e){this._targetOrientation=e["targetOrientation"]}_TrySetTargetOrientation(){const e=this._targetOrientation;if(screen["orientation"]&&screen["orientation"]["lock"])screen["orientation"]["lock"](e).catch(e=>console.warn("[Construct] Failed to lock orientation: ",e));else try{let t=!1;screen["lockOrientation"]?t=screen["lockOrientation"](e):screen["webkitLockOrientation"]?t=screen["webkitLockOrientation"](e):screen["mozLockOrientation"]?t=screen["mozLockOrientation"](e):screen["msLockOrientation"]&&(t=screen["msLockOrientation"](e)),t||console.warn("[Construct] Failed to lock orientation")}catch(e){console.warn("[Construct] Failed to lock orientation: ",e)}}_OnFullscreenChange(){if(this._isExportToVideo)return;const t=e.IsDocumentFullscreen();t&&"any"!==this._targetOrientation&&this._TrySetTargetOrientation(),this.PostToRuntime("fullscreenchange",{"isFullscreen":t,"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnFullscreenError(t){console.warn("[Construct] Fullscreen request failed: ",t),this.PostToRuntime("fullscreenerror",{"isFullscreen":e.IsDocumentFullscreen(),"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnVisibilityChange(e){if(this._pageVisibilityIsHidden!==e&&(this._pageVisibilityIsHidden=e,e?this._iRuntime._CancelAnimationFrame():this._iRuntime._RequestAnimationFrame(),this.PostToRuntime("visibilitychange",{"hidden":e}),!e&&this._iRuntime.IsiOSWebView())){const e=()=>{document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0};setTimeout(e,50),setTimeout(e,100),setTimeout(e,250),setTimeout(e,500)}}_OnKeyEvent(e,t){if(void 0===t.key)return;if("Backspace"===t.key&&h(t),this._isExportToVideo)return;const i=n.get(t.code)||t.code;this._PostToRuntimeMaybeSync(e,{"code":i,"key":t.key,"which":t.which,"repeat":t.repeat,"altKey":t.altKey,"ctrlKey":t.ctrlKey,"metaKey":t.metaKey,"shiftKey":t.shiftKey,"timeStamp":t.timeStamp},s)}_OnMouseWheelEvent(e,t,i){this._isExportToVideo||this.PostToRuntime(e,{"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"deltaX":t.deltaX,"deltaY":t.deltaY,"deltaZ":t.deltaZ,"deltaMode":t.deltaMode,"timeStamp":t.timeStamp},i)}_OnMouseEvent(e,t,n){this._isExportToVideo||i(t)||this._PostToRuntimeMaybeSync(e,{"button":t.button,"buttons":t.buttons,"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"timeStamp":t.timeStamp},n)}_OnPointerEvent(e,t){if(this._isExportToVideo)return;let i=0;"mouse"===t.pointerType&&(i=this._mousePointerLastButtons),this._PostToRuntimeMaybeSync(e,{"pointerId":t.pointerId,"pointerType":t.pointerType,"button":t.button,"buttons":t.buttons,"lastButtons":i,"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"width":t.width||0,"height":t.height||0,"pressure":t.pressure||0,"tangentialPressure":t["tangentialPressure"]||0,"tiltX":t.tiltX||0,"tiltY":t.tiltY||0,"twist":t["twist"]||0,"timeStamp":t.timeStamp},s),"mouse"===t.pointerType&&(this._mousePointerLastButtons=t.buttons)}_OnPointerRawUpdate(e){this._OnPointerEvent("pointermove",e)}_OnTouchEvent(e,t){if(!this._isExportToVideo)for(let i=0,n=t.changedTouches.length;i<n;++i){const n=t.changedTouches[i];this._PostToRuntimeMaybeSync(e,{"pointerId":n.identifier,"pointerType":"touch","button":0,"buttons":0,"lastButtons":0,"clientX":n.clientX,"clientY":n.clientY+this._vkTranslateYOffset,"pageX":n.pageX,"pageY":n.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"width":2*(n["radiusX"]||n["webkitRadiusX"]||0),"height":2*(n["radiusY"]||n["webkitRadiusY"]||0),"pressure":n["force"]||n["webkitForce"]||0,"tangentialPressure":0,"tiltX":0,"tiltY":0,"twist":n["rotationAngle"]||0,"timeStamp":t.timeStamp},s)}}_HandlePointerDownFocus(e){window!==window.top&&window.focus(),this._IsElementCanvasOrDocument(e.target)&&document.activeElement&&!this._IsElementCanvasOrDocument(document.activeElement)&&document.activeElement.blur()}_IsElementCanvasOrDocument(e){return!e||e===document||e===window||e===document.body||"canvas"===e.tagName.toLowerCase()}_AttachDeviceOrientationEvent(){this._attachedDeviceOrientationEvent||(this._attachedDeviceOrientationEvent=!0,window.addEventListener("deviceorientation",e=>this._OnDeviceOrientation(e)),window.addEventListener("deviceorientationabsolute",e=>this._OnDeviceOrientationAbsolute(e)))}_AttachDeviceMotionEvent(){this._attachedDeviceMotionEvent||(this._attachedDeviceMotionEvent=!0,window.addEventListener("devicemotion",e=>this._OnDeviceMotion(e)))}_OnDeviceOrientation(e){this._isExportToVideo||this.PostToRuntime("deviceorientation",{"absolute":!!e["absolute"],"alpha":e["alpha"]||0,"beta":e["beta"]||0,"gamma":e["gamma"]||0,"timeStamp":e.timeStamp,"webkitCompassHeading":e["webkitCompassHeading"],"webkitCompassAccuracy":e["webkitCompassAccuracy"]},s)}_OnDeviceOrientationAbsolute(e){this._isExportToVideo||this.PostToRuntime("deviceorientationabsolute",{"absolute":!!e["absolute"],"alpha":e["alpha"]||0,"beta":e["beta"]||0,"gamma":e["gamma"]||0,"timeStamp":e.timeStamp},s)}_OnDeviceMotion(e){if(this._isExportToVideo)return;let t=null;const i=e["acceleration"];i&&(t={"x":i["x"]||0,"y":i["y"]||0,"z":i["z"]||0});let n=null;const o=e["accelerationIncludingGravity"];o&&(n={"x":o["x"]||0,"y":o["y"]||0,"z":o["z"]||0});let a=null;const r=e["rotationRate"];r&&(a={"alpha":r["alpha"]||0,"beta":r["beta"]||0,"gamma":r["gamma"]||0}),this.PostToRuntime("devicemotion",{"acceleration":t,"accelerationIncludingGravity":n,"rotationRate":a,"interval":e["interval"],"timeStamp":e.timeStamp},s)}_OnInvokeDownload(e){const t=e["url"],i=e["filename"],n=document.createElement("a"),s=document.body;n.textContent=i,n.href=t,n.download=i,s.appendChild(n),n.click(),s.removeChild(n)}async _OnLoadWebFonts(e){const t=e["webfonts"];await Promise.all(t.map(async e=>{const t=new FontFace(e.name,`url('${e.url}')`);document.fonts.add(t),await t.load()}))}async _OnRasterSvgImage(e){const t=e["blob"],i=e["imageWidth"],n=e["imageHeight"],s=e["surfaceWidth"],o=e["surfaceHeight"],a=e["imageBitmapOpts"],r=await self["C3_RasterSvgImageBlob"](t,i,n,s,o);let d;return d=a?await createImageBitmap(r,a):await createImageBitmap(r),{"imageBitmap":d,"transferables":[d]}}async _OnGetSvgImageSize(e){return await self["C3_GetSvgImageSize"](e["blob"])}async _OnAddStylesheet(e){var t;await(t=e["url"],new Promise((e,i)=>{const n=document.createElement("link");n.onload=()=>e(n),n.onerror=e=>i(e),n.rel="stylesheet",n.href=t,document.head.appendChild(n)}))}_PlayPendingMedia(){const e=[...this._mediaPendingPlay];if(this._mediaPendingPlay.clear(),!this._isSilent)for(const t of e){const e=t.play();e&&e.catch(e=>{this._mediaRemovedPendingPlay.has(t)||this._mediaPendingPlay.add(t)})}}TryPlayMedia(e){if("function"!=typeof e.play)throw new Error("missing play function");let t;this._mediaRemovedPendingPlay.delete(e);try{t=e.play()}catch(t){return void this._mediaPendingPlay.add(e)}t&&t.catch(t=>{this._mediaRemovedPendingPlay.has(e)||this._mediaPendingPlay.add(e)})}RemovePendingPlay(e){this._mediaPendingPlay.delete(e),this._mediaRemovedPendingPlay.add(e)}SetSilent(e){this._isSilent=!!e}_OnHideCordovaSplash(){navigator["splashscreen"]&&navigator["splashscreen"]["hide"]&&navigator["splashscreen"]["hide"]()}_OnDebugHighlight(e){if(!e["show"])return void(this._debugHighlightElem&&(this._debugHighlightElem.style.display="none"));this._debugHighlightElem||(this._debugHighlightElem=document.createElement("div"),this._debugHighlightElem.id="inspectOutline",document.body.appendChild(this._debugHighlightElem));const t=this._debugHighlightElem;t.style.display="",t.style.left=e["left"]-1+"px",t.style.top=e["top"]-1+"px",t.style.width=e["width"]+2+"px",t.style.height=e["height"]+2+"px",t.textContent=e["name"]}_OnRegisterSW(){window["C3_RegisterSW"]&&window["C3_RegisterSW"]()}_OnPostToDebugger(e){window["c3_postToMessagePort"]&&(e["from"]="runtime",window["c3_postToMessagePort"](e))}_InvokeFunctionFromJS(e,t){return this.PostToRuntimeAsync("js-invoke-function",{"name":e,"params":t})}_OnScriptCreateWorker(e){const t=e["url"],i=e["opts"],n=e["port2"];new Worker(t,i).postMessage({"type":"construct-worker-init","port2":n},[n])}_OnAlert(e){alert(e["message"])}_OnScreenReaderTextEvent(e){const t=e["type"];if("create"===t){const t=document.createElement("p");t.id="c3-sr-"+e["id"],t.textContent=e["text"],this._screenReaderTextWrap.appendChild(t)}else if("update"===t){const t=document.getElementById("c3-sr-"+e["id"]);t?t.textContent=e["text"]:console.warn(`[Construct] Missing screen reader text with id ${e["id"]}`)}else if("release"===t){const t=document.getElementById("c3-sr-"+e["id"]);t?t.remove():console.warn(`[Construct] Missing screen reader text with id ${e["id"]}`)}else console.warn(`[Construct] Unknown screen reader text update '${t}'`)}_SetExportingToVideo(e){this._isExportToVideo=!0;const t=document.createElement("h1");t.id="exportToVideoMessage",t.textContent=e["message"],document.body.prepend(t),document.body.classList.add("exportingToVideo"),this.GetRuntimeInterface().GetMainCanvas().style.display="",this._iRuntime.SetIsExportingToVideo(e["duration"])}_OnExportVideoProgress(e){this._exportVideoProgressMessage=e["message"],-1===this._exportVideoUpdateTimerId&&(this._exportVideoUpdateTimerId=setTimeout(()=>this._DoUpdateExportVideoProgressMessage(),250))}_DoUpdateExportVideoProgressMessage(){this._exportVideoUpdateTimerId=-1;const e=document.getElementById("exportToVideoMessage");e&&(e.textContent=this._exportVideoProgressMessage)}_OnExportedToVideo(e){window.c3_postToMessagePort({"type":"exported-video","arrayBuffer":e["arrayBuffer"],"contentType":e["contentType"],"time":e["time"]})}_OnExportedToImageSequence(e){window.c3_postToMessagePort({"type":"exported-image-sequence","blobArr":e["blobArr"],"time":e["time"],"gif":e["gif"]})}};e.AddDOMHandlerClass(w)}

// workers/jobSchedulerDom.js
"use strict";{const t="dispatchworker.js",r="jobworker.js";self.JobSchedulerDOM=class{constructor(t){this._runtimeInterface=t,this._maxNumWorkers=Math.min(navigator.hardwareConcurrency||2,16),this._dispatchWorker=null,this._jobWorkers=[],this._inputPort=null,this._outputPort=null}async Init(){if(this._hasInitialised)throw new Error("already initialised");this._hasInitialised=!0;const r=this._runtimeInterface.GetScriptFolder()+t;this._dispatchWorker=await this._runtimeInterface.CreateWorker(r,{name:"DispatchWorker"});const e=new MessageChannel;this._inputPort=e.port1,this._dispatchWorker.postMessage({"type":"_init","in-port":e.port2},[e.port2]),this._outputPort=await this._CreateJobWorker()}async _CreateJobWorker(){const t=this._jobWorkers.length,e=this._runtimeInterface.GetScriptFolder()+r,o=await this._runtimeInterface.CreateWorker(e,{name:"JobWorker"+t}),s=new MessageChannel,i=new MessageChannel;return this._dispatchWorker.postMessage({"type":"_addJobWorker","port":s.port1},[s.port1]),o.postMessage({"type":"init","number":t,"dispatch-port":s.port2,"output-port":i.port2},[s.port2,i.port2]),this._jobWorkers.push(o),i.port1}GetPortData(){return{"inputPort":this._inputPort,"outputPort":this._outputPort,"maxNumWorkers":this._maxNumWorkers}}GetPortTransferables(){return[this._inputPort,this._outputPort]}}}

// scripts/plugins/Keyboard/dom/domSide.js
"use strict";{const r="keyboard",o=class extends self.DOMHandler{constructor(o){super(o,r),this._isKeyboardLockSupported=!(!navigator["keyboard"]||!navigator["keyboard"]["lock"]),this.AddRuntimeMessageHandlers([["init",()=>this._OnInit()],["lock-keyboard",r=>this._OnLockKeyboard(r)],["unlock-keyboard",()=>this._OnUnlockKeyboard()]])}_OnInit(){return{"isKeyboardLockSupported":this._isKeyboardLockSupported}}async _OnLockKeyboard(r){const o=r["keysArr"];try{return 0===o.length?await navigator["keyboard"]["lock"]():await navigator["keyboard"]["lock"](o),{"isOk":!0}}catch(r){return console.error("Error locking keyboard:",r),{"isOk":!1}}}_OnUnlockKeyboard(){try{navigator["keyboard"]["unlock"]()}catch(r){console.error("Error unlocking keyboard:",r)}}};self.RuntimeInterface.AddDOMHandlerClass(o)}

// start-export.js
"use strict";if(window["C3_IsSupported"]){const e=true;window["c3_runtimeInterface"]=new self.RuntimeInterface({useWorker:e,workerMainUrl:"workermain.js",runtimeScriptList:["scripts/c3main.js"],scriptFolder:"scripts/",exportType:"html5"})}
