// 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._GetLocalRuntime()["_OnMessageFromDOM"]({"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\/|nwjs)/i.test(navigator.userAgent);let r=0;function n(e){const t=document.createElement("script");return t.async=!1,t.type="module",e.isStringSrc?new Promise((s=>{const n="c3_resolve_"+r;++r,self[n]=s,t.textContent=e.str+`\n\nself["${n}"]();`,document.head.appendChild(t)})):new Promise(((s,r)=>{t.onload=s,t.onerror=r,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}}),r=await new Promise((e=>{s.addEventListener("message",(t=>{s.terminate(),e(t.data)})),s.postMessage("")}));return e&&r}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")};async function l(e){const t=await c(e);return new TextDecoder("utf-8").decode(t)}function c(e){return new Promise(((t,s)=>{const r=new FileReader;r.onload=e=>t(e.target.result),r.onerror=e=>s(e),r.readAsArrayBuffer(e)}))}a=null;const d=[];let h=0;const p=8;window["RealFile"]=window["File"];const m=[],u=new Map,_=new Map;let w=0;const y=[];self.runOnStartup=function(e){if("function"!=typeof e)throw new Error("runOnStartup called without a function");y.push(e)};const f=new Set(["cordova","playable-ad-single-file","playable-ad-zip","instant-games"]);function g(e){return f.has(e)}let v=!1;window.RuntimeInterface=class r{constructor(e){if(this._useWorker=e.useWorker,this._messageChannelPort=null,this._runtimeBaseUrl="",this._scriptFolder=e.scriptFolder,this._worker=null,this._localRuntime=null,this._domHandlers=[],this._runtimeDomHandler=null,this._isFirstSizeUpdate=!0,this._canvasLayers=[],this._pendingRemoveElements=[],this._pendingUpdateHTMLZOrder=!1,this._updateHTMLZOrderRAFCallback=()=>this._DoUpdateHTMLElementsZOrder(),this._isExportingToVideo=!1,this._exportToVideoDuration=0,this._jobScheduler=null,this._rafId=-1,this._rafFunc=()=>this._OnRAFCallback(),this._rafCallbacks=new Set,this._wrapperInitResolve=null,this._wrapperComponentIds=[],this._exportType=e.exportType,this._isFileProtocol="file"===location.protocol.substr(0,4),this._directoryHandles=[],"playable-ad-single-file"!==this._exportType&&"playable-ad-zip"!==this._exportType&&"instant-games"!==this._exportType||(this._useWorker=!1),s&&(this._useWorker=!1),"cordova"===this._exportType&&this._useWorker&&t){const e=/Chrome\/(\d+)/i.exec(navigator.userAgent);e&&parseInt(e[1],10)>=90||(this._useWorker=!1)}this.IsAnyWebView2Wrapper()?self["chrome"]["webview"].addEventListener("message",(e=>this._OnWrapperMessage(e.data,e["additionalObjects"]))):"macos-wkwebview"===this._exportType?self["C3WrapperOnMessage"]=e=>this._OnWrapperMessage(JSON.parse(e)):"linux-cef"===this._exportType&&self["c3_linux_cef_set_message_callback"]((e=>this._OnWrapperMessage(JSON.parse(e)))),this._localFileBlobs=null,this._localFileStrings=null,"html5"!==this._exportType||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._OnUpdateCanvasSize(e))),this.AddRuntimeComponentMessageHandler("canvas","set-html-layer-count",(e=>this["_OnSetHTMLLayerCount"](e))),this.AddRuntimeComponentMessageHandler("canvas","cleanup-html-layers",(()=>this._OnCleanUpHTMLLayers())),this.AddRuntimeComponentMessageHandler("canvas","update-html-layer-dom-state",(e=>this._UpdateHTMLLayerDOMProperties(e["layersDomState"]))),this.AddRuntimeComponentMessageHandler("runtime","cordova-fetch-local-file",(e=>this._OnCordovaFetchLocalFile(e))),this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",(e=>this._OnCreateJobWorker(e))),this.AddRuntimeComponentMessageHandler("runtime","send-wrapper-extension-message",(e=>this._OnSendWrapperExtensionMessage(e))),"cordova"===this._exportType?document.addEventListener("deviceready",(()=>this._Init(e))):this._Init(e),this._skipAndroidVirtualKeyboardDetection=0}Release(){this._CancelAnimationFrame(),this._messageChannelPort&&(this._messageChannelPort.onmessage=null,this._messageChannelPort=null),this._worker&&(this._worker.terminate(),this._worker=null),this._localRuntime&&(this._localRuntime.Release(),this._localRuntime=null);for(const{canvas:e,htmlWrap:t}of this._canvasLayers)e.remove(),t.remove();this._canvasLayers.length=0}GetMainCanvas(){return this._canvasLayers[0].canvas}GetAvailableHTMLIndex(e){return Math.min(e,this._canvasLayers.length-1)}GetHTMLWrapElement(e){if(e<0||e>=this._canvasLayers.length)throw new RangeError("invalid canvas layer");return this._canvasLayers[e].htmlWrap}"_GetHTMLWrapElement"(e){return this.GetHTMLWrapElement(e)}GetRuntimeBaseURL(){return this._runtimeBaseUrl}UsesWorker(){return this._useWorker}GetExportType(){return this._exportType}IsFileProtocol(){return this._isFileProtocol}GetScriptFolder(){return this._scriptFolder}IsiOSCordova(){return e&&"cordova"===this._exportType}IsiOSWebView(){const t=navigator.userAgent;return e&&g(this._exportType)||navigator["standalone"]||/crios\/|fxios\/|edgios\//i.test(t)}IsAndroid(){return t}IsAndroidWebView(){return t&&g(this._exportType)}IsWindowsWebView2(){return"windows-webview2"===this._exportType||!!("preview"===this._exportType&&window["chrome"]&&window["chrome"]["webview"]&&window["chrome"]["webview"]["postMessage"])}IsAnyWebView2Wrapper(){return this.IsWindowsWebView2()||"xbox-uwp-webview2"===this._exportType}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 _Init(e){if(this._useWorker){await i()||(this._useWorker=!1)}if("macos-wkwebview"===this._exportType&&this._SendWrapperMessage({"type":"ready"}),this.IsAnyWebView2Wrapper()||"macos-wkwebview"===this._exportType||"linux-cef"===this._exportType){this._SetupDesktopWrapperPolyfills();const e=await this._InitWrapper();this._wrapperComponentIds=e["registeredComponentIds"]}if("playable-ad-single-file"===this._exportType&&(this._localFileBlobs=self["c3_base64files"],this._localFileStrings={},await this._ConvertDataUrisToBlobs()),"nwjs"===this._exportType&&self["nw"]){if(self["nw"]["Window"]["get"]()["on"]("close",(()=>self["nw"]["App"]["quit"]())),self["nw"]["App"]["manifest"]["c3-steam-mode"]){let e=0;this._AddRAFCallback((()=>{e++,document.documentElement.style.opacity=e%2==0?"1":"0.999"}))}}if(e.runtimeBaseUrl)this._runtimeBaseUrl=e.runtimeBaseUrl;else{const e=location.origin;this._runtimeBaseUrl=("null"===e?"file:///":e)+location.pathname;const t=this._runtimeBaseUrl.lastIndexOf("/");-1!==t&&(this._runtimeBaseUrl=this._runtimeBaseUrl.substr(0,t+1))}const t=new MessageChannel;if(this._messageChannelPort=t.port1,this._messageChannelPort.onmessage=e=>this["_OnMessageFromRuntime"](e.data),window["c3_addPortMessageHandler"]&&window["c3_addPortMessageHandler"]((e=>this._OnMessageFromDebugger(e))),this._jobScheduler=new self.JobSchedulerDOM(this),await this._jobScheduler.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._useWorker?await this._InitWorker(e,t.port2):await this._InitDOM(e,t.port2)}_GetCommonRuntimeOptions(e){return{"runtimeBaseUrl":this._runtimeBaseUrl,"previewUrl":location.href,"windowInnerWidth":this._GetWindowInnerWidth(),"windowInnerHeight":this._GetWindowInnerHeight(),"cssDisplayMode":this.GetCssDisplayMode(),"devicePixelRatio":window.devicePixelRatio,"isFullscreen":r.IsDocumentFullscreen(),"swClientId":window["cr_swClientId"]||"","exportType":e.exportType,"isNWjs":"undefined"!=typeof nw,"fileMap":globalThis.c3_swFileMap??new Map(Object.entries(this._localFileBlobs??{})),"scriptFolder":this._scriptFolder,"isDebug":new URLSearchParams(self.location.search).has("debug"),"ife":!!self.ife,"jobScheduler":this._jobScheduler.GetPortData(),"supportedAudioFormats":o,"isFileProtocol":this._isFileProtocol,"isiOSCordova":this.IsiOSCordova(),"isiOSWebView":this.IsiOSWebView(),"isWindowsWebView2":this.IsWindowsWebView2(),"isAnyWebView2Wrapper":this.IsAnyWebView2Wrapper(),"wrapperComponentIds":this._wrapperComponentIds,"isFBInstantAvailable":void 0!==self["FBInstant"]}}async _InitWorker(e,t){const s=e.workerMainUrl;"preview"===this._exportType?(this._worker=new Worker("previewworker.js",{type:"module",name:"Runtime"}),await new Promise(((e,t)=>{const r=s=>{this._worker.removeEventListener("message",r),s.data&&"ok"===s.data["type"]?e():t()};this._worker.addEventListener("message",r),this._worker.postMessage({"type":"construct-worker-init","import":new URL(s,this._runtimeBaseUrl).toString()})}))):this._worker=await this.CreateWorker(s,{type:"module",name:"Runtime"});const r=document.createElement("canvas");r.style.display="none";const n=r["transferControlToOffscreen"]();document.body.appendChild(r);const i=document.createElement("div");i.className="c3htmlwrap",i.setAttribute("interactive",""),document.body.appendChild(i),this._canvasLayers.push({canvas:r,htmlWrap:i,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=r,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this._worker.postMessage(Object.assign(this._GetCommonRuntimeOptions(e),{"type":"init-runtime","isInWorker":!0,"messagePort":t,"canvas":n,"runtimeScriptList":e.runtimeScriptList,"projectMainScriptPath":e.projectMainScriptPath,"javaScriptInEventsPath":e.javaScriptInEventsPath,"typeScriptInEventsPath":e.typeScriptInEventsPath}),[t,n,...this._jobScheduler.GetPortTransferables()]),this._domHandlers=m.map((e=>new e(this))),this._FindRuntimeDOMHandler(),this._runtimeDomHandler._AddDefaultCanvasEventHandlers(r),this._runtimeDomHandler._AddDefaultHTMLWrapEventHandlers(i),this._runtimeDomHandler._EnableWindowResizeEvent(),self["c3_callFunction"]=(e,t)=>this._runtimeDomHandler._InvokeFunctionFromJS(e,t),"preview"===this._exportType&&(self["goToLastErrorScript"]=()=>this.PostToRuntimeComponent("runtime","go-to-last-error-script"))}async _InitDOM(e,t){const s=document.createElement("canvas");s.style.display="none",document.body.appendChild(s);const r=document.createElement("div");r.className="c3htmlwrap",r.setAttribute("interactive",""),document.body.appendChild(r),this._canvasLayers.push({canvas:s,htmlWrap:r,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=s,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this._domHandlers=m.map((e=>new e(this))),this._FindRuntimeDOMHandler(),this._runtimeDomHandler._AddDefaultCanvasEventHandlers(s),this._runtimeDomHandler._AddDefaultHTMLWrapEventHandlers(r);const i=await Promise.all(e.runtimeScriptList.map((e=>this._MaybeGetPlatformSpecificScriptURL(e))));await Promise.all(i.map((e=>n(e))));const a=e.projectMainScriptPath,o=e.javaScriptInEventsPath,l=e.typeScriptInEventsPath;if(a)try{if(await n(a),"preview"===this._exportType&&!globalThis.C3_ProjectMainScriptOK)throw new Error("main script did not run to completion")}catch(e){this._RemoveLoadingMessage(),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 n(o),"preview"===this._exportType&&!globalThis.C3.JavaScriptInEvents)throw new Error("JavaScript in events did not run to completion")}catch(e){this._RemoveLoadingMessage(),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(l)try{if(await n(l),"preview"===this._exportType&&!globalThis.C3.TypeScriptInEvents)throw new Error("TypeScript in events did not run to completion")}catch(e){this._RemoveLoadingMessage(),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._GetCommonRuntimeOptions(e),{"isInWorker":!1,"messagePort":t,"canvas":s,"runOnStartupFunctions":y});this._runtimeDomHandler._EnableWindowResizeEvent(),this._OnBeforeCreateRuntime(),this._localRuntime=self["C3_CreateRuntime"](c),await self["C3_InitRuntime"](this._localRuntime,c)}async CreateWorker(e,t){if(e.startsWith("blob:"))return new Worker(e,t);if("cordova"===this._exportType&&this._isFileProtocol){const s=await this.CordovaFetchLocalFileAsArrayBuffer(e),r=new Blob([s],{type:"application/javascript"});return new Worker(URL.createObjectURL(r),t)}if("playable-ad-single-file"===this._exportType){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 r=await e.blob();return new Worker(URL.createObjectURL(r),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","nwjs","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"}_OnBeforeCreateRuntime(){this._RemoveLoadingMessage()}_RemoveLoadingMessage(){const e=window["cr_previewLoadingElem"];e&&(e.parentElement.removeChild(e),window["cr_previewLoadingElem"]=null)}async _OnCreateJobWorker(e){const t=await this._jobScheduler._CreateJobWorker();return{"outputPort":t,"transferables":[t]}}_OnUpdateCanvasSize(e){if(this.IsExportingToVideo())return;const t=e["styleWidth"]+"px",s=e["styleHeight"]+"px",r=e["marginLeft"]+"px",n=e["marginTop"]+"px";for(const{canvas:e,htmlWrap:i}of this._canvasLayers)e.style.width=t,e.style.height=s,e.style.marginLeft=r,e.style.marginTop=n,i.style.width=t,i.style.height=s,i.style.marginLeft=r,i.style.marginTop=n,this._isFirstSizeUpdate&&(e.style.display="",i.style.display="");document.documentElement.style.setProperty("--construct-scale",e["displayScale"]),this._isFirstSizeUpdate=!1}"_OnSetHTMLLayerCount"(e){const t=e["count"],s=e["layersDomState"],r=e["immediate"],n=e["styleWidth"]+"px",i=e["styleHeight"]+"px",a=e["marginLeft"]+"px",o=e["marginTop"]+"px",l=[],c=[];if(t<this._canvasLayers.length)for(;this._canvasLayers.length>t;){const{canvas:e,htmlWrap:t}=this._canvasLayers.pop();t.remove(),this._useWorker&&!r?this._pendingRemoveElements.push(e):e.remove()}else if(t>this._canvasLayers.length)for(let e=0,s=t-this._canvasLayers.length;e<s;++e){const e=document.createElement("canvas");if(e.classList.add("c3overlay"),this._useWorker){const t=e["transferControlToOffscreen"]();l.push(t),c.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=n,e.style.height=i,e.style.marginLeft=a,e.style.marginTop=o,t.style.width=n,t.style.height=i,t.style.marginLeft=a,t.style.marginTop=o,this._runtimeDomHandler._AddDefaultCanvasEventHandlers(e),this._runtimeDomHandler._AddDefaultHTMLWrapEventHandlers(t),this._canvasLayers.push({canvas:e,htmlWrap:t,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}})}this._UpdateHTMLLayerDOMProperties(s);for(const e of this._domHandlers)e instanceof window.DOMElementHandler&&e._OnHTMLLayersChanged();return this._UpdateHTMLElementsZOrder(),{"addedCanvases":l,"transferables":c}}_UpdateHTMLLayerDOMProperties(e){for(let t=0,s=Math.min(this._canvasLayers.length,e.length);t<s;++t){const{htmlWrap:s,lastHtmlLayerDomState:r}=this._canvasLayers[t],n=e[t],i=n["isVisible"],a=n["opacity"],o=n["isInteractive"];i!==r.isVisible&&(s.style.display=i?"":"none",r.isVisible=i),a!==r.opacity&&(s.style.opacity=1===a?"":String(a),r.opacity=a),o!==r.isInteractive&&(s.style.pointerEvents=o?"":"none",o?s.setAttribute("interactive",""):s.removeAttribute("interactive"),r.isInteractive=o)}}_OnCleanUpHTMLLayers(){for(const e of this._pendingRemoveElements)e.remove();this._pendingRemoveElements.length=0}_UpdateHTMLElementsZOrder(){this._pendingUpdateHTMLZOrder||(this._pendingUpdateHTMLZOrder=!0,this._AddRAFCallback(this._updateHTMLZOrderRAFCallback))}_DoUpdateHTMLElementsZOrder(){this._RemoveRAFCallback(this._updateHTMLZOrderRAFCallback),this._pendingUpdateHTMLZOrder=!1;let e=[];for(const t of this._domHandlers)if(t instanceof window.DOMElementHandler){const s=t._GetAllElementStatesForZOrderUpdate();s&&e.push(...s)}e.sort(((e,t)=>{const s=e.GetActualHTMLIndex(),r=t.GetActualHTMLIndex();if(s!==r)return s-r;return e.GetHTMLZIndex()-t.GetHTMLZIndex()}));let t=0,s=0,r=0,n=e.length;for(;r<n;++r){const n=e[r];n.GetActualHTMLIndex()!==t&&(this._DoUpdateHTMLElementsZOrderOnHTMLLayer(t,e.slice(s,r)),t=n.GetActualHTMLIndex(),s=r)}s<r&&this._DoUpdateHTMLElementsZOrderOnHTMLLayer(t,e.slice(s,r))}_DoUpdateHTMLElementsZOrderOnHTMLLayer(e,t){if(t.length<=1)return;if(e>=this._canvasLayers.length)return;const s=t.map((e=>e.GetElement())),r=new Set(s),n=this.GetHTMLWrapElement(e),i=Array.from(n.children).filter((e=>r.has(e)));for(let e=0,t=0,r=s.length;e<r;++e){const r=s[e],a=i[t];r===a?++t:n["moveBefore"]?n["moveBefore"](r,a):n.insertBefore(r,a)}}_GetLocalRuntime(){if(this._useWorker)throw new Error("not available in worker mode");return this._localRuntime}PostToRuntimeComponent(e,t,s,r,n){this._messageChannelPort.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":r||null,"data":s,"responseId":null},n)}PostToRuntimeComponentAsync(e,t,s,r,n){const i=w++,a=new Promise(((e,t)=>{_.set(i,{resolve:e,reject:t})}));return this._messageChannelPort.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":r||null,"data":s,"responseId":i},n),a}"_OnMessageFromRuntime"(e){const t=e["type"];if("event"===t)return this._OnEventFromRuntime(e);if("result"===t)this._OnResultFromRuntime(e);else if("runtime-ready"===t)this._OnRuntimeReady();else if("alert-error"===t)this._RemoveLoadingMessage(),alert(e["message"]);else{if("creating-runtime"!==t)throw new Error(`unknown message '${t}'`);this._OnBeforeCreateRuntime()}}_OnEventFromRuntime(e){const t=e["component"],s=e["handler"],r=e["data"],n=e["responseId"],i=u.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(r)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==n&&this._PostResultToRuntime(n,!1,""+e))}if(null===n)return o;o&&o.then?o.then((e=>this._PostResultToRuntime(n,!0,e))).catch((e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this._PostResultToRuntime(n,!1,""+e)})):this._PostResultToRuntime(n,!0,o)}_PostResultToRuntime(e,t,s){let r;s&&s["transferables"]&&(r=s["transferables"]),this._messageChannelPort.postMessage({"type":"result","responseId":e,"isOk":t,"result":s},r)}_OnResultFromRuntime(e){const t=e["responseId"],s=e["isOk"],r=e["result"],n=_.get(t);s?n.resolve(r):n.reject(r),_.delete(t)}AddRuntimeComponentMessageHandler(e,t,s){let r=u.get(e);if(r||(r=new Map,u.set(e,r)),r.has(t))throw new Error(`[DOM] Component '${e}' already has handler '${t}'`);r.set(t,s)}static AddDOMHandlerClass(e){if(m.includes(e))throw new Error("DOM handler already added");m.push(e)}_FindRuntimeDOMHandler(){for(const e of this._domHandlers)if("runtime"===e.GetComponentID())return void(this._runtimeDomHandler=e);throw new Error("cannot find runtime DOM handler")}_OnMessageFromDebugger(e){this.PostToRuntimeComponent("debugger","message",e)}_OnRuntimeReady(){for(const e of this._domHandlers)e.Attach()}static IsDocumentFullscreen(){return!!(document["fullscreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"]||v)}static _SetWrapperIsFullscreenFlag(e){v=!!e}async GetRemotePreviewStatusInfo(){return await this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(e){this._rafCallbacks.add(e),this._RequestAnimationFrame()}_RemoveRAFCallback(e){this._rafCallbacks.delete(e),0===this._rafCallbacks.size&&this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this._rafId&&this._rafCallbacks.size>0&&(this._rafId=requestAnimationFrame(this._rafFunc))}_CancelAnimationFrame(){-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1)}_OnRAFCallback(){this._rafId=-1;for(const e of this._rafCallbacks)e();this._RequestAnimationFrame()}TryPlayMedia(e){this._runtimeDomHandler.TryPlayMedia(e)}RemovePendingPlay(e){this._runtimeDomHandler.RemovePendingPlay(e)}_PlayPendingMedia(){this._runtimeDomHandler._PlayPendingMedia()}SetSilent(e){this._runtimeDomHandler.SetSilent(e)}IsAudioFormatSupported(e){return!!o[e]}SetIsExportingToVideo(e){this._isExportingToVideo=!0,this._exportToVideoDuration=e}IsExportingToVideo(){return this._isExportingToVideo}GetExportToVideoDuration(){return this._exportToVideoDuration}IsAbsoluteURL(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)}IsRelativeURL(e){return!this.IsAbsoluteURL(e)}async _MaybeGetPlatformSpecificScriptURL(e){if("cordova"===this._exportType&&(e.startsWith("file:")||this._isFileProtocol&&this.IsRelativeURL(e))){let t=e;t.startsWith(this._runtimeBaseUrl)&&(t=t.substr(this._runtimeBaseUrl.length));const s=await this.CordovaFetchLocalFileAsArrayBuffer(t),r=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(r)}if("playable-ad-single-file"===this._exportType){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}async _OnCordovaFetchLocalFile(e){const t=e["filename"];switch(e["as"]){case"text":return await this.CordovaFetchLocalFileAsText(t);case"buffer":return await this.CordovaFetchLocalFileAsArrayBuffer(t);default:throw new Error("unsupported type")}}CordovaFetchLocalFile(e){const t=window["cordova"]["file"]["applicationDirectory"]+"www/"+e;return new Promise(((e,s)=>{window["resolveLocalFileSystemURL"](t,(t=>{t["file"](e,s)}),s)}))}async CordovaFetchLocalFileAsText(e){const t=await this.CordovaFetchLocalFile(e);return await l(t)}_CordovaMaybeStartNextArrayBufferRead(){if(!d.length)return;if(h>=p)return;h++;const e=d.shift();this._CordovaDoFetchLocalFileAsAsArrayBuffer(e.filename,e.successCallback,e.errorCallback)}CordovaFetchLocalFileAsArrayBuffer(e){return new Promise(((t,s)=>{d.push({filename:e,successCallback:e=>{h--,this._CordovaMaybeStartNextArrayBufferRead(),t(e)},errorCallback:e=>{h--,this._CordovaMaybeStartNextArrayBufferRead(),s(e)}}),this._CordovaMaybeStartNextArrayBufferRead()}))}async _CordovaDoFetchLocalFileAsAsArrayBuffer(e,t,s){try{const s=await this.CordovaFetchLocalFile(e);t(await c(s))}catch(e){s(e)}}"_PlayableAdFetchBlob"(e){if(this._localFileBlobs.hasOwnProperty(e))return this._localFileBlobs[e];throw new Error("missing file: "+e)}_GetPermissionAPI(){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}_MapPermissionID(e,t){const s=e[t];if("string"!=typeof s)throw new Error("Invalid permission name");return s}_HasPermission(e){const t=this._GetPermissionAPI();return new Promise(((s,r)=>t["checkPermission"](this._MapPermissionID(t,e),(e=>s(!!e["hasPermission"])),r)))}_RequestPermission(e){const t=this._GetPermissionAPI();return new Promise(((s,r)=>t["requestPermission"](this._MapPermissionID(t,e),(e=>s(!!e["hasPermission"])),r)))}async RequestPermissions(e){if("cordova"!==this.GetExportType())return!0;if(this.IsiOSCordova())return!0;for(const t of e){if(await this._HasPermission(t))continue;if(!1===await this._RequestPermission(t))return!1}return!0}async RequirePermissions(...e){if(!1===await this.RequestPermissions(e))throw new Error("Permission not granted")}_OnWrapperMessage(e,t){if("object"!=typeof e||!e)return void console.warn("Unknown wrapper message: ",e);const s=e["type"];if("directory-handles"===s)this._directoryHandles=t;else if("wrapper-init-response"===s)this._wrapperInitResolve(e),this._wrapperInitResolve=null;else if("fullscreen-change"===s)r._SetWrapperIsFullscreenFlag(e["isFullscreen"]),this._runtimeDomHandler._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"extension-message"===s?this.PostToRuntimeComponent("runtime","wrapper-extension-message",e):console.warn("Unknown wrapper message: ",e)}_OnSendWrapperExtensionMessage(e){this._SendWrapperMessage({"type":"extension-message","componentId":e["componentId"],"messageId":e["messageId"],"params":e["params"]||[],"asyncId":e["asyncId"]})}_SendWrapperMessage(e){this.IsAnyWebView2Wrapper()?window["chrome"]["webview"]["postMessage"](JSON.stringify(e)):"macos-wkwebview"===this._exportType?window["webkit"]["messageHandlers"]["C3Wrapper"]["postMessage"](JSON.stringify(e)):"linux-cef"===this._exportType&&window["c3_linux_cef_sendmessage"](JSON.stringify(e))}_SetupDesktopWrapperPolyfills(){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)})}}_InitWrapper(){return new Promise((e=>{this._wrapperInitResolve=e,this._SendWrapperMessage({"type":"wrapper-init"})}))}_GetDirectoryHandles(){return this._directoryHandles}async _ConvertDataUrisToBlobs(){const e=[];for(const[t,s]of Object.entries(this._localFileBlobs))e.push(this._ConvertDataUriToBlobs(t,s));await Promise.all(e)}async _ConvertDataUriToBlobs(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._FetchDataUri(t);s||(s=this._DataURIToBinaryBlobSync(t)),this._localFileBlobs[e]=s}}async _FetchDataUri(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}}_DataURIToBinaryBlobSync(e){const t=this._ParseDataURI(e);return this._BinaryStringToBlob(t.data,t.mime_type)}_ParseDataURI(e){const t=e.indexOf(",");if(t<0)throw new URIError("expected comma in data: uri");const s=e.substring(5,t),r=e.substring(t+1),n=s.split(";"),i=n[0]||"",a=n[1],o=n[2];let l;return l="base64"===a||"base64"===o?atob(r):decodeURIComponent(r),{mime_type:i,data:l}}_BinaryStringToBlob(e,t){let s,r,n=e.length,i=n>>2,a=new Uint8Array(n),o=new Uint32Array(a.buffer,0,i);for(s=0,r=0;s<i;++s)o[s]=e.charCodeAt(r++)|e.charCodeAt(r++)<<8|e.charCodeAt(r++)<<16|e.charCodeAt(r++)<<24;let l=3&n;for(;l--;)a[r]=e.charCodeAt(r),++r;return new Blob([a],{"type":t})}}}

// workers/runtimeDomEvents.js
"use strict";{const e=self.RuntimeInterface;function t(e){return e["sourceCapabilities"]&&e["sourceCapabilities"]["firesTouchEvents"]||e["originalEvent"]&&e["originalEvent"]["sourceCapabilities"]&&e["originalEvent"]["sourceCapabilities"]["firesTouchEvents"]}const i=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),n={"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0},s={"dispatchUserScriptEvent":!0},o={"dispatchRuntimeEvent":!0};async function a(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 r(e){do{if(e.parentNode&&e.hasAttribute("contenteditable"))return!0;e=e.parentNode}while(e);return!1}const d=new Set(["input","textarea","datalist","select"]);const l=new Set(["canvas","body","html"]);function c(e){if(!e.target.tagName)return;const t=e.target.tagName.toLowerCase();l.has(t)&&e.preventDefault()}function h(e){e.target.tagName&&e.target.classList.contains("c3htmlwrap")&&e.preventDefault()}function u(e){(e.metaKey||e.ctrlKey)&&e.preventDefault()}self["C3_GetSvgImageSize"]=async function(e){const t=await a(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 a(e),r=document.createElement("canvas");r.width=n,r.height=s;return r.getContext("2d").drawImage(o,0,0,t,i),r};let m=!1;function g(){try{return window.parent&&window.parent.document.hasFocus()}catch(e){return!1}}document.addEventListener("pause",(()=>m=!0)),document.addEventListener("resume",(()=>m=!1));const p="runtime",_=class extends self.DOMHandler{constructor(e){super(e,p),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)||r(i)||e.preventDefault()})),window.addEventListener("selectstart",c),window.addEventListener("gesturehold",c),window.addEventListener("touchstart",c,{"passive":!1}),window.addEventListener("pointerdown",c,{"passive":!1}),this._mousePointerLastButtons=0,window.addEventListener("mousedown",(e=>{1===e.button&&e.preventDefault()})),window.addEventListener("mousewheel",u,{"passive":!1}),window.addEventListener("wheel",u,{"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",c),e.addEventListener("gesturehold",c),e.addEventListener("pointerdown",c)}_AddDefaultHTMLWrapEventHandlers(e){e.addEventListener("selectstart",h),e.addEventListener("gesturehold",h),e.addEventListener("touchstart",h)}_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&&!m),{"isSuspended":this._pageVisibilityIsHidden}}Attach(){window.addEventListener("focus",(()=>this._PostRuntimeEvent("window-focus"))),window.addEventListener("blur",(()=>{this._PostRuntimeEvent("window-blur",{"parentHasFocus":g()}),this._mousePointerLastButtons=0})),window.addEventListener("focusin",(e=>{var t;t=e.target,(d.has(t.tagName.toLowerCase())||r(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,s))),window.addEventListener("mousemove",(e=>this._OnMouseEvent("mousemove",e,s))),window.addEventListener("mouseup",(e=>this._OnMouseEvent("mouseup",e,s))),window.addEventListener("dblclick",(e=>this._OnMouseEvent("dblclick",e,n))),window.addEventListener("wheel",(e=>this._OnMouseWheelEvent("wheel",e,n))),window.addEventListener("pointerdown",(e=>{this._HandlePointerDownFocus(e),this._OnPointerEvent("pointerdown",e)})),this._iRuntime.UsesWorker()&&void 0!==window["onpointerrawupdate"]&&self===self.top?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,o)}_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&&c(t),"nwjs"===this._iRuntime.GetExportType()&&"u"===t.key&&(t.ctrlKey||t.metaKey)&&t.preventDefault(),this._isExportToVideo)return;const s=i.get(t.code)||t.code;this._PostToRuntimeMaybeSync(e,{"code":s,"key":t.key,"which":t.which,"repeat":t.repeat,"altKey":t.altKey,"ctrlKey":t.ctrlKey,"metaKey":t.metaKey,"shiftKey":t.shiftKey,"timeStamp":t.timeStamp},n)}_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,i,n){this._isExportToVideo||t(i)||this._PostToRuntimeMaybeSync(e,{"button":i.button,"buttons":i.buttons,"clientX":i.clientX,"clientY":i.clientY+this._vkTranslateYOffset,"pageX":i.pageX,"pageY":i.pageY+this._vkTranslateYOffset,"movementX":i.movementX||0,"movementY":i.movementY||0,"timeStamp":i.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},n),"mouse"===t.pointerType&&(this._mousePointerLastButtons=t.buttons)}_OnPointerRawUpdate(e){this._OnPointerEvent("pointermove",e)}_OnTouchEvent(e,t){if(!this._isExportToVideo)for(let i=0,s=t.changedTouches.length;i<s;++i){const s=t.changedTouches[i];this._PostToRuntimeMaybeSync(e,{"pointerId":s.identifier,"pointerType":"touch","button":0,"buttons":0,"lastButtons":0,"clientX":s.clientX,"clientY":s.clientY+this._vkTranslateYOffset,"pageX":s.pageX,"pageY":s.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"width":2*(s["radiusX"]||s["webkitRadiusX"]||0),"height":2*(s["radiusY"]||s["webkitRadiusY"]||0),"pressure":s["force"]||s["webkitForce"]||0,"tangentialPressure":0,"tiltX":0,"tiltY":0,"twist":s["rotationAngle"]||0,"timeStamp":t.timeStamp},n)}}_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"]},n)}_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},n)}_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 s=null;const o=e["accelerationIncludingGravity"];o&&(s={"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":s,"rotationRate":a,"interval":e["interval"],"timeStamp":e.timeStamp},n)}_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(_)}

// 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/Mouse/dom/domSide.js
"use strict";{const e="mouse",t=class extends self.DOMHandler{constructor(t){super(t,e),this.AddRuntimeMessageHandlers([["cursor",e=>this._OnChangeCursorStyle(e)],["request-pointer-lock",e=>this._OnRequestPointerLock(e)],["release-pointer-lock",()=>this._OnReleasePointerLock()]]),document.addEventListener("pointerlockchange",(e=>this._OnPointerLockChange())),document.addEventListener("pointerlockerror",(e=>this._OnPointerLockError()))}_OnChangeCursorStyle(e){document.documentElement.style.cursor=e}_OnRequestPointerLock(e){this._iRuntime.GetMainCanvas().requestPointerLock(e)}_OnReleasePointerLock(){document.exitPointerLock()}_OnPointerLockChange(){this.PostToRuntime("pointer-lock-change",{"has-pointer-lock":!!document.pointerLockElement})}_OnPointerLockError(){this.PostToRuntime("pointer-lock-error",{"has-pointer-lock":!!document.pointerLockElement})}};self.RuntimeInterface.AddDOMHandlerClass(t)}

// 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)}

// scripts/plugins/Touch/dom/domSide.js
"use strict";{const e="touch",t=class extends self.DOMHandler{constructor(t){super(t,e),this.AddRuntimeMessageHandler("request-permission",(e=>this._OnRequestPermission(e)))}async _OnRequestPermission(e){const t=e["type"];let s=!0;0===t?s=await this._RequestOrientationPermission():1===t&&(s=await this._RequestMotionPermission()),this.PostToRuntime("permission-result",{"type":t,"result":s})}async _RequestOrientationPermission(){if(!self["DeviceOrientationEvent"]||!self["DeviceOrientationEvent"]["requestPermission"])return!0;try{return"granted"===await self["DeviceOrientationEvent"]["requestPermission"]()}catch(e){return console.warn("[Touch] Failed to request orientation permission: ",e),!1}}async _RequestMotionPermission(){if(!self["DeviceMotionEvent"]||!self["DeviceMotionEvent"]["requestPermission"])return!0;try{return"granted"===await self["DeviceMotionEvent"]["requestPermission"]()}catch(e){return console.warn("[Touch] Failed to request motion permission: ",e),!1}}};self.RuntimeInterface.AddDOMHandlerClass(t)}

// scripts/plugins/Audio/dom/domSide.js
"use strict";{const t=180/Math.PI,e="audio";self.AudioDOMHandler=class extends self.DOMHandler{constructor(t){super(t,e),this._audioContext=null,this._destinationNode=null,this._hasAttachedUnblockEvents=!1,this._unblockFunc=()=>this._UnblockAudioContext(),this._audioBuffers=[],this._audioInstances=[],this._lastAudioInstance=null,this._lastPlayedTags=[],this._loadedAudioUrls=new Set,this._lastTickCount=-1,this._pendingTags=new Map,this._masterVolume=1,this._isSilent=!1,this._timeScaleMode=0,this._timeScale=1,this._gameTime=0,this._panningModel="HRTF",this._distanceModel="inverse",this._refDistance=600,this._maxDistance=1e4,this._rolloffFactor=1,this._lastListenerPos=[0,0,0],this._lastListenerOrientation=[0,0,-1,0,1,0],this._playMusicAsSound=!1,this._lastMusicBuffer=null,this._effects=new Map,this._analysers=new Set,this._isPendingPostFxState=!1,this._hasStartedOfflineRender=!1,this._microphoneTag="",this._microphoneSource=null,self["C3Audio_OnMicrophoneStream"]=(t,e)=>this._OnMicrophoneStream(t,e),this._destMediaStreamNode=null,self["C3Audio_GetOutputStream"]=()=>this._OnGetOutputStream(),self["C3Audio_DOMInterface"]=this,this.AddRuntimeMessageHandlers([["create-audio-context",t=>this._CreateAudioContext(t)],["play",t=>this._Play(t)],["stop",t=>this._Stop(t)],["stop-all",()=>this._StopAll()],["set-paused",t=>this._SetPaused(t)],["set-volume",t=>this._SetVolume(t)],["fade-volume",t=>this._FadeVolume(t)],["set-master-volume",t=>this._SetMasterVolume(t)],["set-muted",t=>this._SetMuted(t)],["set-silent",t=>this._SetSilent(t)],["set-looping",t=>this._SetLooping(t)],["set-playback-rate",t=>this._SetPlaybackRate(t)],["set-stereo-pan",t=>this._SetStereoPan(t)],["seek",t=>this._Seek(t)],["preload",t=>this._Preload(t)],["unload",t=>this._Unload(t)],["unload-all",()=>this._UnloadAll()],["set-suspended",t=>this._SetSuspended(t)],["add-effect",t=>this._AddEffect(t)],["set-effect-param",t=>this._SetEffectParam(t)],["remove-effects",t=>this._RemoveEffects(t)],["tick",t=>this._OnTick(t)],["load-state",t=>this._OnLoadState(t)],["offline-render-audio",t=>this._OnOfflineRenderAudio(t)],["offline-render-finish",()=>this._OnOfflineRenderFinish()]])}async _CreateAudioContext(t){if(t["usePlayMusicAsSoundWorkaround"]&&(this._playMusicAsSound=!0),this._timeScaleMode=t["timeScaleMode"],this._panningModel=["equalpower","HRTF","soundfield"][t["panningModel"]],this._distanceModel=["linear","inverse","exponential"][t["distanceModel"]],this._refDistance=t["refDistance"],this._maxDistance=t["maxDistance"],this._rolloffFactor=t["rolloffFactor"],this._iRuntime.IsExportingToVideo()){this._playMusicAsSound=!0;const t=48e3;this._audioContext=new OfflineAudioContext({"numberOfChannels":2,"sampleRate":t,"length":Math.ceil(this._iRuntime.GetExportToVideoDuration()*t)})}else this._audioContext=new AudioContext({"latencyHint":t["latencyHint"]}),"running"!==this._audioContext.state&&this._AttachUnblockEvents(),this._audioContext.onstatechange=()=>{"running"===this._audioContext.state?this._DetachUnblockEvents():this._AttachUnblockEvents(),this.PostToRuntime("audiocontext-state",{"audioContextState":this._audioContext.state})};this._destinationNode=this._audioContext["createGain"](),this._destinationNode["connect"](this._audioContext["destination"]);const e=t["listenerPos"];this._lastListenerPos[0]=e[0],this._lastListenerPos[1]=e[1],this._lastListenerPos[2]=e[2],this._audioContext["listener"]["setPosition"](e[0],e[1],e[2]),this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation),self["C3_GetAudioContextCurrentTime"]=()=>this.GetAudioCurrentTime();try{await Promise.all(t["preloadList"].map((t=>this._GetAudioBuffer(t["originalUrl"],t["url"],t["type"],!1))))}catch(t){console.error("[Construct] Preloading sounds failed: ",t)}return{"sampleRate":this._audioContext["sampleRate"],"audioContextState":this._audioContext.state,"outputLatency":this._audioContext["outputLatency"]||0}}_AttachUnblockEvents(){this._hasAttachedUnblockEvents||(window.addEventListener("pointerup",this._unblockFunc,!0),window.addEventListener("touchend",this._unblockFunc,!0),window.addEventListener("click",this._unblockFunc,!0),window.addEventListener("keydown",this._unblockFunc,!0),document.addEventListener("visibilitychange",this._unblockFunc),this._hasAttachedUnblockEvents=!0)}_DetachUnblockEvents(){this._hasAttachedUnblockEvents&&(window.removeEventListener("pointerup",this._unblockFunc,!0),window.removeEventListener("touchend",this._unblockFunc,!0),window.removeEventListener("click",this._unblockFunc,!0),window.removeEventListener("keydown",this._unblockFunc,!0),document.removeEventListener("visibilitychange",this._unblockFunc),this._hasAttachedUnblockEvents=!1)}_UnblockAudioContext(){"running"!==this._audioContext["state"]&&this._audioContext["resume"]()}_MatchTagLists(t,e){for(const s of e){let e=!1;for(const i of t)if(self.AudioDOMHandler.EqualsNoCase(i,s)){e=!0;break}if(!e)return!1}return!0}GetAudioContext(){return this._audioContext}GetAudioCurrentTime(){return this._audioContext["currentTime"]}GetDestinationNode(){return this._destinationNode}"GetAudioContextExtern"(){return this.GetAudioContext()}"GetDestinationNodeExtern"(){return this.GetDestinationNode()}GetDestinationForTag(t){const e=this._effects.get(t.toLowerCase());return e?e[0].GetInputNode():this.GetDestinationNode()}AddEffectForTag(t,e){t=t.toLowerCase();let s=this._effects.get(t);s||(s=[],this._effects.set(t,s)),e._SetIndex(s.length),e._SetTag(t),s.push(e),this._ReconnectEffects(t)}_ReconnectEffects(t){t=t.toLowerCase();let e=this.GetDestinationNode();const s=this._effects.get(t);if(s&&s.length){e=s[0].GetInputNode();for(let t=0,e=s.length;t<e;++t){const i=s[t];t+1===e?i.ConnectTo(this.GetDestinationNode()):i.ConnectTo(s[t+1].GetInputNode())}}for(const s of this.audioInstancesByEffectTag(t))s.Reconnect(e);this._microphoneSource&&this._microphoneTag===t&&(this._microphoneSource["disconnect"](),this._microphoneSource["connect"](e))}GetMasterVolume(){return this._masterVolume}IsSilent(){return this._isSilent}GetTimeScaleMode(){return this._timeScaleMode}GetTimeScale(){return this._timeScale}GetGameTime(){return this._gameTime}IsPlayMusicAsSound(){return this._playMusicAsSound}GetPanningModel(){return this._panningModel}GetDistanceModel(){return this._distanceModel}GetReferenceDistance(){return this._refDistance}GetMaxDistance(){return this._maxDistance}GetRolloffFactor(){return this._rolloffFactor}TryPlayMedia(t){this._iRuntime.TryPlayMedia(t)}RemovePendingPlay(t){this._iRuntime.RemovePendingPlay(t)}ReleaseInstancesForBuffer(t){let e=0;for(let s=0,i=this._audioInstances.length;s<i;++s){const i=this._audioInstances[s];this._audioInstances[e]=i,i.GetBuffer()===t?i.Release():++e}this._audioInstances.length=e}ReleaseAllMusicBuffersExceptLast(){let t=0;for(let e=0,s=this._audioBuffers.length;e<s;++e){const s=this._audioBuffers[e];this._audioBuffers[t]=s,s.IsMusic()&&s!==this._lastMusicBuffer?s.Release():++t}this._audioBuffers.length=t}*audioInstancesMatchingTags(t){if(t.length>0)for(const e of this._audioInstances)this._MatchTagLists(e.GetTags(),t)&&(yield e);else this._lastAudioInstance&&!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}*audioInstancesByEffectTag(t){if(t)for(const e of this._audioInstances)self.AudioDOMHandler.EqualsNoCase(e.GetEffectTag(),t)&&(yield e);else this._lastAudioInstance&&!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}async _GetAudioBuffer(t,e,s,i,n){for(const t of this._audioBuffers)if(t.GetUrl()===e)return i&&this._playMusicAsSound&&(this._lastMusicBuffer=t),await t.Load(),t;if(n)return null;i&&this._playMusicAsSound&&this.ReleaseAllMusicBuffersExceptLast();const o=self.C3AudioBuffer.Create(this,t,e,s,i);return this._audioBuffers.push(o),i&&this._playMusicAsSound&&(this._lastMusicBuffer=o),await o.Load(),this._loadedAudioUrls.has(t)||(this.PostToRuntime("buffer-metadata",{"originalUrl":t,"duration":o.GetDuration()}),this._loadedAudioUrls.add(t)),o}async _GetAudioInstance(t,e,s,i,n){for(const t of this._audioInstances)if(t.GetUrl()===e&&(t.CanBeRecycled()||n))return n&&this._playMusicAsSound&&(this._lastMusicBuffer=t.GetBuffer()),t.SetTags(i),t;const o=await this._GetAudioBuffer(t,e,s,n);if(o.WasReleased())throw new Error(`buffer '${t}' unloaded while loading`);const a=o.CreateInstance(i);return this._audioInstances.push(a),a}_AddPendingTags(t){const e=t.join(" ");let s=this._pendingTags.get(e);if(!s){let t=null;s={pendingCount:0,promise:new Promise((e=>t=e)),resolve:t},this._pendingTags.set(e,s)}s.pendingCount++}_RemovePendingTags(t){const e=t.join(" "),s=this._pendingTags.get(e);if(!s)throw new Error("expected pending tag");s.pendingCount--,0===s.pendingCount&&(s.resolve(),this._pendingTags.delete(e))}TagsReady(t){const e=(0===t.length?this._lastPlayedTags:t).join(" "),s=this._pendingTags.get(e);return s?s.promise:Promise.resolve()}_MaybeStartTicking(){if(this._analysers.size>0)this._StartTicking();else for(const t of this._audioInstances)if(t.IsActive())return void this._StartTicking()}Tick(){for(const t of this._analysers)t.Tick();const t=this.GetAudioCurrentTime();for(const e of this._audioInstances)e.Tick(t);const e=this._audioInstances.filter((t=>t.IsActive())).map((t=>t.GetState()));this.PostToRuntime("state",{"tickCount":this._lastTickCount,"outputLatency":this._audioContext["outputLatency"]||0,"audioInstances":e,"analysers":[...this._analysers].map((t=>t.GetData()))}),0===e.length&&0===this._analysers.size&&this._StopTicking()}PostTrigger(t,e,s){this.PostToRuntime("trigger",{"type":t,"tags":e,"aiid":s})}async _Play(t){const e=t["originalUrl"],s=t["url"],i=t["type"],n=t["isMusic"],o=t["tags"],a=t["isLooping"],r=t["vol"],l=t["pos"],u=t["panning"],d=t["stereoPan"];let h=t["off"];h>0&&!t["trueClock"]&&(h+=this.GetAudioCurrentTime()),this._lastPlayedTags=o.slice(0),this._AddPendingTags(o);try{this._lastAudioInstance=await this._GetAudioInstance(e,s,i,o,n),u?(this._lastAudioInstance.SetPannerEnabled(!0),this._lastAudioInstance.SetPan(u["x"],u["y"],u["z"],u["angle"],u["innerAngle"],u["outerAngle"],u["outerGain"]),u.hasOwnProperty("uid")&&this._lastAudioInstance.SetUID(u["uid"])):"number"==typeof d&&0!==d?(this._lastAudioInstance.SetStereoPannerEnabled(!0),this._lastAudioInstance.SetStereoPan(d)):(this._lastAudioInstance.SetPannerEnabled(!1),this._lastAudioInstance.SetStereoPannerEnabled(!1)),this._lastAudioInstance.Play(a,r,l,h)}catch(t){return void console.error("[Construct] Audio: error starting playback: ",t)}finally{this._RemovePendingTags(o)}this._StartTicking()}_Stop(t){const e=t["tags"];for(const t of this.audioInstancesMatchingTags(e))t.Stop()}_StopAll(){for(const t of this._audioInstances)t.Stop()}_SetPaused(t){const e=t["tags"],s=t["paused"];for(const t of this.audioInstancesMatchingTags(e))s?t.Pause():t.Resume();this._MaybeStartTicking()}_SetVolume(t){const e=t["tags"],s=t["vol"];for(const t of this.audioInstancesMatchingTags(e))t.SetVolume(s)}_SetStereoPan(t){const e=t["tags"],s=t["p"];for(const t of this.audioInstancesMatchingTags(e))t.SetStereoPannerEnabled(!0),t.SetStereoPan(s)}async _FadeVolume(t){const e=t["tags"],s=t["vol"],i=t["duration"],n=t["stopOnEnd"];await this.TagsReady(e);for(const t of this.audioInstancesMatchingTags(e))t.FadeVolume(s,i,n);this._MaybeStartTicking()}_SetMasterVolume(t){this._masterVolume=t["vol"],this._destinationNode["gain"]["value"]=this._masterVolume}_SetMuted(t){const e=t["tags"],s=t["isMuted"];for(const t of this.audioInstancesMatchingTags(e))t.SetMuted(s)}_SetSilent(t){this._isSilent=t["isSilent"],this._iRuntime.SetSilent(this._isSilent);for(const t of this._audioInstances)t._UpdateMuted()}_SetLooping(t){const e=t["tags"],s=t["isLooping"];for(const t of this.audioInstancesMatchingTags(e))t.SetLooping(s)}async _SetPlaybackRate(t){const e=t["tags"],s=t["rate"];await this.TagsReady(e);for(const t of this.audioInstancesMatchingTags(e))t.SetPlaybackRate(s)}async _Seek(t){const e=t["tags"],s=t["pos"];await this.TagsReady(e);for(const t of this.audioInstancesMatchingTags(e))t.Seek(s)}async _Preload(t){const e=t["originalUrl"],s=t["url"],i=t["type"],n=t["isMusic"];try{await this._GetAudioInstance(e,s,i,"",n)}catch(t){console.error("[Construct] Audio: error preloading: ",t)}}async _Unload(t){const e=t["url"],s=t["type"],i=t["isMusic"],n=await this._GetAudioBuffer("",e,s,i,!0);if(!n)return;n.Release(),this._lastMusicBuffer===n&&(this._lastMusicBuffer=null);const o=this._audioBuffers.indexOf(n);-1!==o&&this._audioBuffers.splice(o,1)}_UnloadAll(){for(const t of this._audioBuffers)t.Release(),this._lastMusicBuffer===t&&(this._lastMusicBuffer=null);this._audioBuffers.length=0}_SetSuspended(t){const e=t["isSuspended"];!e&&this._audioContext["resume"]&&this._audioContext["resume"]();for(const t of this._audioInstances)t.SetSuspended(e);e&&this._audioContext["suspend"]&&this._audioContext["suspend"]()}_OnTick(t){if(this._timeScale=t["timeScale"],this._gameTime=t["gameTime"],this._lastTickCount=t["tickCount"],0!==this._timeScaleMode)for(const t of this._audioInstances)t._UpdatePlaybackRate();const e=t["listenerPos"];!e||this._lastListenerPos[0]===e[0]&&this._lastListenerPos[1]===e[1]&&this._lastListenerPos[2]===e[2]||(this._lastListenerPos[0]=e[0],this._lastListenerPos[1]=e[1],this._lastListenerPos[2]=e[2],this._audioContext["listener"]["setPosition"](e[0],e[1],e[2]));const s=t["listenerOrientation"];if(s&&(this._lastListenerOrientation[0]!==s[0]||this._lastListenerOrientation[1]!==s[1]||this._lastListenerOrientation[2]!==s[2]||this._lastListenerOrientation[3]!==s[3]||this._lastListenerOrientation[4]!==s[4]||this._lastListenerOrientation[5]!==s[5])){for(let t=0;t<6;++t)this._lastListenerOrientation[t]=s[t];this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation)}for(const e of t["instPans"]){const t=e["uid"];for(const s of this._audioInstances)s.GetUID()===t&&s.SetPanXYZA(e["x"],e["y"],e["z"],e["angle"])}}async _AddEffect(t){const e=t["type"],s=t.hasOwnProperty("tags")?t["tags"]:[t["tag"]],i=t["params"];let n,o;if("convolution"===e)try{o=await this._GetAudioBuffer(t["bufferOriginalUrl"],t["bufferUrl"],t["bufferType"],!1)}catch(t){return void console.log("[Construct] Audio: error loading convolution: ",t)}for(const a of s){if("filter"===e)n=new self.C3AudioFilterFX(this,...i);else if("delay"===e)n=new self.C3AudioDelayFX(this,...i);else if("convolution"===e)n=new self.C3AudioConvolveFX(this,o.GetAudioBuffer(),...i),n._SetBufferInfo(t["bufferOriginalUrl"],t["bufferUrl"],t["bufferType"]);else if("flanger"===e)n=new self.C3AudioFlangerFX(this,...i);else if("phaser"===e)n=new self.C3AudioPhaserFX(this,...i);else if("gain"===e)n=new self.C3AudioGainFX(this,...i);else if("stereopan"===e)n=new self.C3AudioStereoPanFX(this,...i);else if("tremolo"===e)n=new self.C3AudioTremoloFX(this,...i);else if("ringmod"===e)n=new self.C3AudioRingModFX(this,...i);else if("distortion"===e)n=new self.C3AudioDistortionFX(this,...i);else if("compressor"===e)n=new self.C3AudioCompressorFX(this,...i);else{if("analyser"!==e)throw new Error("invalid effect type");n=new self.C3AudioAnalyserFX(this,...i)}this.AddEffectForTag(a,n)}this._PostUpdatedFxState()}_SetEffectParam(t){const e=t["tags"],s=t["index"],i=t["param"],n=t["value"],o=t["ramp"],a=t["time"];for(const t of e){const e=this._effects.get(t.toLowerCase());!e||s<0||s>=e.length||e[s].SetParam(i,n,o,a)}this._PostUpdatedFxState()}_RemoveEffects(t){const e=t["tags"];for(const t of e){const e=t.toLowerCase(),s=this._effects.get(e);if(!s||!s.length)return;for(const t of s)t.Release();this._effects.delete(e),this._ReconnectEffects(e)}}_AddAnalyser(t){this._analysers.add(t),this._MaybeStartTicking()}_RemoveAnalyser(t){this._analysers.delete(t)}_PostUpdatedFxState(){this._isPendingPostFxState||(this._isPendingPostFxState=!0,Promise.resolve().then((()=>this._DoPostUpdatedFxState())))}_DoPostUpdatedFxState(){const t={};for(const[e,s]of this._effects)t[e]=s.map((t=>t.GetState()));this.PostToRuntime("fxstate",{"fxstate":t}),this._isPendingPostFxState=!1}async _OnLoadState(t){const e=t["saveLoadMode"];if(3!==e){const t=[];for(const s of this._audioInstances)s.IsMusic()&&1===e||!s.IsMusic()&&2===e?t.push(s):s.Release();this._audioInstances=t}for(const t of this._effects.values())for(const e of t)e.Release();this._effects.clear(),this._timeScale=t["timeScale"],this._gameTime=t["gameTime"];const s=t["listenerPos"];this._lastListenerPos[0]=s[0],this._lastListenerPos[1]=s[1],this._lastListenerPos[2]=s[2],this._audioContext["listener"]["setPosition"](s[0],s[1],s[2]);const i=t["listenerOrientation"];if(Array.isArray(i)){for(let t=0;t<6;++t)this._lastListenerOrientation[t]=i[t];this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation)}this._isSilent=t["isSilent"],this._iRuntime.SetSilent(this._isSilent),this._masterVolume=t["masterVolume"],this._destinationNode["gain"]["value"]=this._masterVolume;const n=[];for(const e of Object.values(t["effects"]))n.push(Promise.all(e.map((t=>this._AddEffect(t)))));await Promise.all(n),await Promise.all(t["playing"].map((t=>this._LoadAudioInstance(t,e)))),this._MaybeStartTicking()}async _LoadAudioInstance(t,e){if(3===e)return;const s=t["bufferOriginalUrl"],i=t["bufferUrl"],n=t["bufferType"],o=t["isMusic"],a=t["tags"],r=t["isLooping"],l=t["volume"],u=t["playbackTime"];if(o&&1===e)return;if(!o&&2===e)return;let d=null;try{d=await this._GetAudioInstance(s,i,n,a,o)}catch(t){return void console.error("[Construct] Audio: error loading audio state: ",t)}d.LoadPanState(t["pan"]),d.LoadStereoPanState(t["stereoPan"]),d.Play(r,l,u,0),t["isPlaying"]||d.Pause(),d._LoadAdditionalState(t)}_OnMicrophoneStream(t,e){this._microphoneSource&&this._microphoneSource["disconnect"](),this._microphoneTag=e.toLowerCase(),this._microphoneSource=this._audioContext["createMediaStreamSource"](t),this._microphoneSource["connect"](this.GetDestinationForTag(this._microphoneTag))}_OnGetOutputStream(){return this._destMediaStreamNode||(this._destMediaStreamNode=this._audioContext["createMediaStreamDestination"](),this._destinationNode["connect"](this._destMediaStreamNode)),this._destMediaStreamNode["stream"]}async _OnOfflineRenderAudio(t){try{const e=t["time"],s=this._audioContext["suspend"](e);this._hasStartedOfflineRender?this._audioContext["resume"]():(this._audioContext["startRendering"]().then((t=>this._OnOfflineRenderCompleted(t))).catch((t=>this._OnOfflineRenderError(t))),this._hasStartedOfflineRender=!0),await s}catch(t){this._OnOfflineRenderError(t)}}_OnOfflineRenderFinish(){this._audioContext["resume"]()}_OnOfflineRenderCompleted(t){const e=[];for(let s=0,i=t["numberOfChannels"];s<i;++s){const i=t["getChannelData"](s);e.push(i.buffer)}this._iRuntime.PostToRuntimeComponent("runtime","offline-audio-render-completed",{"duration":t["duration"],"length":t["length"],"numberOfChannels":t["numberOfChannels"],"sampleRate":t["sampleRate"],"channelData":e},null,e)}_OnOfflineRenderError(t){console.error("[Audio] Offline rendering error: ",t)}static EqualsNoCase(t,e){return t===e||t.normalize().toLowerCase()===e.normalize().toLowerCase()}static ToDegrees(e){return e*t}static DbToLinearNoCap(t){return Math.pow(10,t/20)}static DbToLinear(t){return Math.max(Math.min(self.AudioDOMHandler.DbToLinearNoCap(t),1),0)}static LinearToDbNoCap(t){return Math.log(t)/Math.log(10)*20}static LinearToDb(t){return self.AudioDOMHandler.LinearToDbNoCap(Math.max(Math.min(t,1),0))}static e4(t,e){return 1-Math.exp(-e*t)}},self.RuntimeInterface.AddDOMHandlerClass(self.AudioDOMHandler)}

// scripts/plugins/Audio/dom/audioBuffer.js
"use strict";self.C3AudioBuffer=class{constructor(t,e,i,s,o){this._audioDomHandler=t,this._originalUrl=e,this._url=i,this._type=s,this._isMusic=o,this._api="",this._loadState="not-loaded",this._loadPromise=null}Release(){this._loadState="not-loaded",this._audioDomHandler=null,this._loadPromise=null}WasReleased(){return!this._audioDomHandler}static Create(t,e,i,s,o){return!o||t.IsPlayMusicAsSound()?new self.C3WebAudioBuffer(t,e,i,s,o):new self.C3Html5AudioBuffer(t,e,i,s,o)}CreateInstance(t){return"html5"===this._api?new self.C3Html5AudioInstance(this._audioDomHandler,this,t):new self.C3WebAudioInstance(this._audioDomHandler,this,t)}_Load(){}Load(){return this._loadPromise||(this._loadPromise=this._Load()),this._loadPromise}IsLoaded(){}IsLoadedAndDecoded(){}HasFailedToLoad(){return"failed"===this._loadState}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}GetApi(){return this._api}GetOriginalUrl(){return this._originalUrl}GetUrl(){return this._url}GetContentType(){return this._type}IsMusic(){return this._isMusic}GetDuration(){}};

// scripts/plugins/Audio/dom/html5AudioBuffer.js
"use strict";self.C3Html5AudioBuffer=class extends self.C3AudioBuffer{constructor(e,t,o,i,d){super(e,t,o,i,d),this._api="html5",this._audioElem=new Audio,this._audioElem.crossOrigin="anonymous",this._audioElem.autoplay=!1,this._audioElem.preload="auto",this._loadResolve=null,this._loadReject=null,this._reachedCanPlayThrough=!1,this._audioElem.addEventListener("canplaythrough",(()=>this._reachedCanPlayThrough=!0)),this._outNode=this.GetAudioContext()["createGain"](),this._mediaSourceNode=null,this._audioElem.addEventListener("canplay",(()=>{this._loadResolve&&(this._loadState="loaded",this._loadResolve(),this._loadResolve=null,this._loadReject=null),!this._mediaSourceNode&&this._audioElem&&(this._mediaSourceNode=this.GetAudioContext()["createMediaElementSource"](this._audioElem),this._mediaSourceNode["connect"](this._outNode))})),this.onended=null,this._audioElem.addEventListener("ended",(()=>{this.onended&&this.onended()})),this._audioElem.addEventListener("error",(e=>this._OnError(e)))}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this),this._outNode["disconnect"](),this._outNode=null,this._mediaSourceNode["disconnect"](),this._mediaSourceNode=null,this._audioElem&&!this._audioElem.paused&&this._audioElem.pause(),this.onended=null,this._audioElem=null,super.Release()}_Load(){return this._loadState="loading",new Promise(((e,t)=>{this._loadResolve=e,this._loadReject=t,this._audioElem.src=this._url}))}_OnError(e){console.error(`[Construct] Audio '${this._url}' error: `,e),this._loadReject&&(this._loadState="failed",this._loadReject(e),this._loadResolve=null,this._loadReject=null)}IsLoaded(){const e=this._audioElem["readyState"]>=4;return e&&(this._reachedCanPlayThrough=!0),e||this._reachedCanPlayThrough}IsLoadedAndDecoded(){return this.IsLoaded()}GetAudioElement(){return this._audioElem}GetOutputNode(){return this._outNode}GetDuration(){return this._audioElem["duration"]}};

// scripts/plugins/Audio/dom/webAudioBuffer.js
"use strict";self.C3WebAudioBuffer=class extends self.C3AudioBuffer{constructor(a,t,e,i,o){super(a,t,e,i,o),this._api="webaudio",this._audioData=null,this._audioBuffer=null}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this),this._audioData=null,this._audioBuffer=null,super.Release()}async _Fetch(){if(this._audioData)return this._audioData;const a=this._audioDomHandler.GetRuntimeInterface();if("cordova"===a.GetExportType()&&a.IsRelativeURL(this._url)&&a.IsFileProtocol())this._audioData=await a.CordovaFetchLocalFileAsArrayBuffer(this._url);else if("playable-ad-single-file"===a.GetExportType()&&a.IsRelativeURL(this._url)){const t=a["_PlayableAdFetchBlob"](this._url);this._audioData=await t.arrayBuffer()}else{const a=await fetch(this._url);if(!a.ok)throw new Error(`error fetching audio data: ${a.status} ${a.statusText}`);this._audioData=await a.arrayBuffer()}}async _Decode(){if(this._audioBuffer)return this._audioBuffer;const a=this._audioDomHandler.GetAudioContext();this._audioBuffer=await a["decodeAudioData"](this._audioData),this._audioData=null}async _Load(){try{if(this._loadState="loading",await this._Fetch(),this.WasReleased())return;await this._Decode(),this._loadState="loaded"}catch(a){this._loadState="failed",console.error(`[Construct] Failed to load audio '${this._url}': `,a)}}IsLoaded(){return!(!this._audioData&&!this._audioBuffer)}IsLoadedAndDecoded(){return!!this._audioBuffer}GetAudioBuffer(){return this._audioBuffer}GetDuration(){return this._audioBuffer?this._audioBuffer["duration"]:0}};

// scripts/plugins/Audio/dom/audioInstance.js
"use strict";{let e=0;self.C3AudioInstance=class{constructor(t,n,i){this._audioDomHandler=t,this._buffer=n,this._tags=i,this._lastEffectTag=this.GetEffectTag(),this._aiId=e++,this._gainNode=this.GetAudioContext()["createGain"](),this._gainNode["connect"](this.GetDestinationNode()),this._pannerNode=null,this._isPannerEnabled=!1,this._pannerPosition=[0,0,0],this._pannerOrientation=[0,0,0],this._pannerConeParams=[0,0,0],this._stereoPannerNode=null,this._isStereoPannerEnabled=!1,this._stereoPan=0,this._isStopped=!0,this._isPaused=!1,this._resumeMe=!1,this._isLooping=!1,this._volume=1,this._isMuted=!1,this._playbackRate=1;const s=this._audioDomHandler.GetTimeScaleMode();this._isTimescaled=1===s&&!this.IsMusic()||2===s,this._instUid=-1,this._fadeEndTime=-1,this._stopOnFadeEnd=!1}Release(){this._audioDomHandler=null,this._buffer=null,this._pannerNode&&(this._pannerNode["disconnect"](),this._pannerNode=null),this._stereoPannerNode&&(this._stereoPannerNode["disconnect"](),this._stereoPannerNode=null),this._gainNode["disconnect"](),this._gainNode=null}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}SetTags(e){this._tags=e;const t=this.GetEffectTag();this._lastEffectTag!==t&&(this._lastEffectTag=t,this.Reconnect(this.GetDestinationNode()))}GetTags(){return this._tags}GetEffectTag(){return this._tags.length>0?this._tags[0]:""}GetDestinationNode(){return this._audioDomHandler.GetDestinationForTag(this.GetEffectTag())}GetCurrentTime(){return this._isTimescaled?this._audioDomHandler.GetGameTime():performance.now()/1e3}GetOriginalUrl(){return this._buffer.GetOriginalUrl()}GetUrl(){return this._buffer.GetUrl()}GetContentType(){return this._buffer.GetContentType()}GetBuffer(){return this._buffer}IsMusic(){return this._buffer.IsMusic()}GetAiId(){return this._aiId}HasEnded(){}CanBeRecycled(){}IsPlaying(){return!this._isStopped&&!this._isPaused&&!this.HasEnded()}IsActive(){return!this._isStopped&&!this.HasEnded()}GetPlaybackTime(){}GetDuration(e){let t=this._buffer.GetDuration();return e&&(t/=this._playbackRate||.001),t}Play(e,t,n,i){}Stop(){}Pause(){}IsPaused(){return this._isPaused}Resume(){}SetVolume(e){this._volume=e,this._gainNode["gain"]["cancelScheduledValues"](0),this._fadeEndTime=-1,this._gainNode["gain"]["value"]=this.GetOutputVolume()}FadeVolume(e,t,n){if(this.IsMuted())return;const i=this._gainNode["gain"];i["cancelScheduledValues"](0);const s=this._audioDomHandler.GetAudioCurrentTime(),a=s+t;i["setValueAtTime"](i["value"],s),i["linearRampToValueAtTime"](e,a),this._volume=e,this._fadeEndTime=a,this._stopOnFadeEnd=n}_UpdateVolume(){this.SetVolume(this._volume)}Tick(e){-1!==this._fadeEndTime&&e>=this._fadeEndTime&&(this._fadeEndTime=-1,this._stopOnFadeEnd&&this.Stop(),this._audioDomHandler.PostTrigger("fade-ended",this._tags,this._aiId))}GetOutputVolume(){const e=this._volume;return isFinite(e)?e:0}SetMuted(e){e=!!e,this._isMuted!==e&&(this._isMuted=e,this._UpdateMuted())}IsMuted(){return this._isMuted}IsSilent(){return this._audioDomHandler.IsSilent()}_UpdateMuted(){}SetLooping(e){}IsLooping(){return this._isLooping}SetPlaybackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this._UpdatePlaybackRate())}_UpdatePlaybackRate(){}GetPlaybackRate(){return this._playbackRate}Seek(e){}SetSuspended(e){}SetPannerEnabled(e){e=!!e,this._isPannerEnabled!==e&&(this._isPannerEnabled=e,this._isPannerEnabled?(this.SetStereoPannerEnabled(!1),this._pannerNode||(this._pannerNode=this.GetAudioContext()["createPanner"](),this._pannerNode["panningModel"]=this._audioDomHandler.GetPanningModel(),this._pannerNode["distanceModel"]=this._audioDomHandler.GetDistanceModel(),this._pannerNode["refDistance"]=this._audioDomHandler.GetReferenceDistance(),this._pannerNode["maxDistance"]=this._audioDomHandler.GetMaxDistance(),this._pannerNode["rolloffFactor"]=this._audioDomHandler.GetRolloffFactor()),this._gainNode["disconnect"](),this._gainNode["connect"](this._pannerNode),this._pannerNode["connect"](this.GetDestinationNode())):(this._pannerNode["disconnect"](),this._gainNode["disconnect"](),this._gainNode["connect"](this.GetDestinationNode())))}SetPan(e,t,n,i,s,a,o){if(!this._isPannerEnabled)return;this.SetPanXYZA(e,t,n,i);const r=self.AudioDOMHandler.ToDegrees;this._pannerConeParams[0]!==r(s)&&(this._pannerConeParams[0]=r(s),this._pannerNode["coneInnerAngle"]=r(s)),this._pannerConeParams[1]!==r(a)&&(this._pannerConeParams[1]=r(a),this._pannerNode["coneOuterAngle"]=r(a)),this._pannerConeParams[2]!==o&&(this._pannerConeParams[2]=o,this._pannerNode["coneOuterGain"]=o)}SetPanXYZA(e,t,n,i){if(!this._isPannerEnabled)return;const s=this._pannerPosition,a=this._pannerOrientation,o=Math.cos(i),r=Math.sin(i);s[0]===e&&s[1]===t&&s[2]===n||(s[0]=e,s[1]=t,s[2]=n,this._pannerNode["setPosition"](...s)),a[0]===o&&a[1]===r&&0===a[2]||(a[0]=o,a[1]=r,a[2]=0,this._pannerNode["setOrientation"](...a))}SetStereoPannerEnabled(e){e=!!e,this._isStereoPannerEnabled!==e&&(this._isStereoPannerEnabled=e,this._isStereoPannerEnabled?(this.SetPannerEnabled(!1),this._stereoPannerNode=this.GetAudioContext()["createStereoPanner"](),this._gainNode["disconnect"](),this._gainNode["connect"](this._stereoPannerNode),this._stereoPannerNode["connect"](this.GetDestinationNode())):(this._stereoPannerNode["disconnect"](),this._stereoPannerNode=null,this._gainNode["disconnect"](),this._gainNode["connect"](this.GetDestinationNode())))}SetStereoPan(e){this._isStereoPannerEnabled&&this._stereoPan!==e&&(this._stereoPannerNode["pan"]["value"]=e,this._stereoPan=e)}SetUID(e){this._instUid=e}GetUID(){return this._instUid}GetResumePosition(){}Reconnect(e){const t=this._stereoPannerNode||this._pannerNode||this._gainNode;t["disconnect"](),t["connect"](e)}GetState(){return{"aiid":this.GetAiId(),"tags":this._tags,"duration":this.GetDuration(),"volume":-1===this._fadeEndTime?this._volume:this._gainNode["gain"]["value"],"isPlaying":this.IsPlaying(),"playbackTime":this.GetPlaybackTime(),"playbackRate":this.GetPlaybackRate(),"uid":this._instUid,"bufferOriginalUrl":this.GetOriginalUrl(),"bufferUrl":"","bufferType":this.GetContentType(),"isMusic":this.IsMusic(),"isLooping":this.IsLooping(),"isMuted":this.IsMuted(),"resumePosition":this.GetResumePosition(),"pan":this.GetPanState(),"stereoPan":this.GetStereoPanState()}}_LoadAdditionalState(e){this.SetPlaybackRate(e["playbackRate"]),this.SetMuted(e["isMuted"])}GetPanState(){if(!this._pannerNode)return null;const e=this._pannerNode;return{"pos":this._pannerPosition,"orient":this._pannerOrientation,"cia":e["coneInnerAngle"],"coa":e["coneOuterAngle"],"cog":e["coneOuterGain"],"uid":this._instUid}}LoadPanState(e){if(!e)return void this.SetPannerEnabled(!1);this.SetPannerEnabled(!0);const t=this._pannerNode,n=e["pos"];this._pannerPosition[0]=n[0],this._pannerPosition[1]=n[1],this._pannerPosition[2]=n[2];const i=e["orient"];this._pannerOrientation[0]=i[0],this._pannerOrientation[1]=i[1],this._pannerOrientation[2]=i[2],t["setPosition"](...this._pannerPosition),t["setOrientation"](...this._pannerOrientation),this._pannerConeParams[0]=e["cia"],this._pannerConeParams[1]=e["coa"],this._pannerConeParams[2]=e["cog"],t["coneInnerAngle"]=e["cia"],t["coneOuterAngle"]=e["coa"],t["coneOuterGain"]=e["cog"],this._instUid=e["uid"]}GetStereoPanState(){return this._stereoPannerNode?this._stereoPan:null}LoadStereoPanState(e){"number"==typeof e?(this.SetStereoPannerEnabled(!0),this.SetStereoPan(e)):this.SetStereoPannerEnabled(!1)}}}

// scripts/plugins/Audio/dom/html5AudioInstance.js
"use strict";self.C3Html5AudioInstance=class extends self.C3AudioInstance{constructor(e,t,i){super(e,t,i),this._buffer.GetOutputNode()["connect"](this._gainNode),this._buffer.onended=()=>this._OnEnded()}Release(){this.Stop(),this._buffer.GetOutputNode()["disconnect"](),super.Release()}GetAudioElement(){return this._buffer.GetAudioElement()}_OnEnded(){this._isStopped=!0,this._instUid=-1,this._audioDomHandler.PostTrigger("ended",this._tags,this._aiId)}HasEnded(){return this.GetAudioElement()["ended"]}CanBeRecycled(){return!!this._isStopped||this.HasEnded()}GetPlaybackTime(){let e=this.GetAudioElement()["currentTime"];return this._isLooping||(e=Math.min(e,this.GetDuration())),e}Play(e,t,i,s){const d=this.GetAudioElement();if(1!==d.playbackRate&&(d.playbackRate=1),d.loop!==e&&(d.loop=e),this.SetVolume(t),this._isMuted=!1,d.muted&&(d.muted=!1),d.currentTime!==i)try{d.currentTime=i}catch(e){console.warn(`[Construct] Exception seeking audio '${this._buffer.GetUrl()}' to position '${i}': `,e)}this._audioDomHandler.TryPlayMedia(d),this._isStopped=!1,this._isPaused=!1,this._isLooping=e,this._playbackRate=1}Stop(){const e=this.GetAudioElement();e.paused||e.pause(),this._audioDomHandler.RemovePendingPlay(e),this._isStopped=!0,this._isPaused=!1,this._instUid=-1}Pause(){if(this._isPaused||this._isStopped||this.HasEnded())return;const e=this.GetAudioElement();e.paused||e.pause(),this._audioDomHandler.RemovePendingPlay(e),this._isPaused=!0}Resume(){!this._isPaused||this._isStopped||this.HasEnded()||(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),this._isPaused=!1)}_UpdateMuted(){this.GetAudioElement().muted=this._isMuted||this.IsSilent()}SetLooping(e){e=!!e,this._isLooping!==e&&(this._isLooping=e,this.GetAudioElement().loop=e)}_UpdatePlaybackRate(){let e=this._playbackRate;this._isTimescaled&&(e*=this._audioDomHandler.GetTimeScale());try{this.GetAudioElement()["playbackRate"]=e}catch(t){console.warn(`[Construct] Unable to set playback rate '${e}':`,t)}}Seek(e){if(!this._isStopped&&!this.HasEnded())try{this.GetAudioElement()["currentTime"]=e}catch(t){console.warn(`[Construct] Error seeking audio to '${e}': `,t)}}GetResumePosition(){return this.GetPlaybackTime()}SetSuspended(e){e?this.IsPlaying()?(this.GetAudioElement()["pause"](),this._resumeMe=!0):this._resumeMe=!1:this._resumeMe&&(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),this._resumeMe=!1)}};

// scripts/plugins/Audio/dom/webAudioInstance.js
"use strict";self.C3WebAudioInstance=class extends self.C3AudioInstance{constructor(e,t,s){super(e,t,s),this._bufferSource=null,this._onended_handler=e=>this._OnEnded(e),this._hasPlaybackEnded=!0,this._activeSource=null,this._playStartTime=0,this._playFromSeekPos=0,this._resumePosition=0,this._muteVol=1}Release(){this.Stop(),this._ReleaseBufferSource(),this._onended_handler=null,super.Release()}_ReleaseBufferSource(){this._bufferSource&&(this._bufferSource["onended"]=null,this._bufferSource["disconnect"](),this._bufferSource["buffer"]=null),this._bufferSource=null,this._activeSource=null}_OnEnded(e){this._isPaused||this._resumeMe||e.target===this._activeSource&&(this._hasPlaybackEnded=!0,this._isStopped=!0,this._instUid=-1,this._ReleaseBufferSource(),this._audioDomHandler.PostTrigger("ended",this._tags,this._aiId))}HasEnded(){return!(!this._isStopped&&this._bufferSource&&this._bufferSource["loop"])&&(!this._isPaused&&this._hasPlaybackEnded)}CanBeRecycled(){return!(this._bufferSource&&!this._isStopped)||this.HasEnded()}GetPlaybackTime(){let e=0;return e=this._isPaused?this._resumePosition:this._playFromSeekPos+(this.GetCurrentTime()-this._playStartTime)*this._playbackRate,this._isLooping||(e=Math.min(e,this.GetDuration())),e}Play(e,t,s,i){this._isMuted=!1,this._muteVol=1,this.SetVolume(t),this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext()["createBufferSource"](),this._bufferSource["buffer"]=this._buffer.GetAudioBuffer(),this._bufferSource["connect"](this._gainNode),this._activeSource=this._bufferSource,this._bufferSource["onended"]=this._onended_handler,this._bufferSource["loop"]=e,this._bufferSource["start"](i,s),this._hasPlaybackEnded=!1,this._isStopped=!1,this._isPaused=!1,this._isLooping=e,this._playbackRate=1,this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=s}Stop(){if(this._bufferSource)try{this._bufferSource["stop"](0)}catch(e){}this._isStopped=!0,this._isPaused=!1,this._instUid=-1}Pause(){this._isPaused||this._isStopped||this.HasEnded()||(this._resumePosition=this.GetPlaybackTime(),this._isLooping&&(this._resumePosition%=this.GetDuration()),this._isPaused=!0,this._bufferSource["stop"](0))}Resume(){!this._isPaused||this._isStopped||this.HasEnded()||(this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext()["createBufferSource"](),this._bufferSource["buffer"]=this._buffer.GetAudioBuffer(),this._bufferSource["connect"](this._gainNode),this._activeSource=this._bufferSource,this._bufferSource["onended"]=this._onended_handler,this._bufferSource["loop"]=this._isLooping,this._UpdateVolume(),this._UpdatePlaybackRate(),this._bufferSource["start"](0,this._resumePosition),this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=this._resumePosition,this._isPaused=!1)}GetOutputVolume(){return super.GetOutputVolume()*this._muteVol}_UpdateMuted(){this._muteVol=this._isMuted||this.IsSilent()?0:1,this._UpdateVolume()}SetLooping(e){e=!!e,this._isLooping!==e&&(this._isLooping=e,this._bufferSource&&(this._bufferSource["loop"]=e))}_UpdatePlaybackRate(){let e=this._playbackRate;this._isTimescaled&&(e*=this._audioDomHandler.GetTimeScale()),this._bufferSource&&(this._bufferSource["playbackRate"]["value"]=e)}Seek(e){this._isStopped||this.HasEnded()||(this._isPaused?this._resumePosition=e:(this.Pause(),this._resumePosition=e,this.Resume()))}GetResumePosition(){return this._resumePosition}SetSuspended(e){e?this.IsPlaying()?(this._resumeMe=!0,this._resumePosition=this.GetPlaybackTime(),this._isLooping&&(this._resumePosition%=this.GetDuration()),this._bufferSource["stop"](0)):this._resumeMe=!1:this._resumeMe&&(this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext()["createBufferSource"](),this._bufferSource["buffer"]=this._buffer.GetAudioBuffer(),this._bufferSource["connect"](this._gainNode),this._activeSource=this._bufferSource,this._bufferSource["onended"]=this._onended_handler,this._bufferSource["loop"]=this._isLooping,this._UpdateVolume(),this._UpdatePlaybackRate(),this._bufferSource["start"](0,this._resumePosition),this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=this._resumePosition,this._resumeMe=!1)}_LoadAdditionalState(e){super._LoadAdditionalState(e),this._resumePosition=e["resumePosition"]}};

// scripts/plugins/Audio/dom/effects.js
"use strict";{class e{constructor(e){this._audioDomHandler=e,this._audioContext=e.GetAudioContext(),this._index=-1,this._tag="",this._type="",this._params=null}Release(){this._audioContext=null}_SetIndex(e){this._index=e}GetIndex(){return this._index}_SetTag(e){this._tag=e}GetTag(){return this._tag}CreateGain(){return this._audioContext["createGain"]()}GetInputNode(){}ConnectTo(e){}SetAudioParam(e,t,i,s){if(e["cancelScheduledValues"](0),0===s)return void(e["value"]=t);const o=this._audioContext["currentTime"];switch(s+=o,i){case 0:e["setValueAtTime"](t,s);break;case 1:e["setValueAtTime"](e["value"],o),e["linearRampToValueAtTime"](t,s);break;case 2:e["setValueAtTime"](e["value"],o),e["exponentialRampToValueAtTime"](t,s)}}GetState(){return{"type":this._type,"tag":this._tag,"params":this._params}}}self.C3AudioFilterFX=class extends e{constructor(e,t,i,s,o,a,n){super(e),this._type="filter",this._params=[t,i,s,o,a,n],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=n,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-n,this._filterNode=this._audioContext["createBiquadFilter"](),this._filterNode["type"]=t,this._filterNode["frequency"]["value"]=i,this._filterNode["detune"]["value"]=s,this._filterNode["Q"]["value"]=o,this._filterNode["gain"]["vlaue"]=a,this._inputNode["connect"](this._filterNode),this._inputNode["connect"](this._dryNode),this._filterNode["connect"](this._wetNode)}Release(){this._inputNode["disconnect"](),this._filterNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[5]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 1:this._params[1]=t,this.SetAudioParam(this._filterNode["frequency"],t,i,s);break;case 2:this._params[2]=t,this.SetAudioParam(this._filterNode["detune"],t,i,s);break;case 3:this._params[3]=t,this.SetAudioParam(this._filterNode["Q"],t,i,s);break;case 4:this._params[4]=t,this.SetAudioParam(this._filterNode["gain"],t,i,s)}}},self.C3AudioDelayFX=class extends e{constructor(e,t,i,s){super(e),this._type="delay",this._params=[t,i,s],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=s,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-s,this._mainNode=this.CreateGain(),this._delayNode=this._audioContext["createDelay"](t),this._delayNode["delayTime"]["value"]=t,this._delayGainNode=this.CreateGain(),this._delayGainNode["gain"]["value"]=i,this._inputNode["connect"](this._mainNode),this._inputNode["connect"](this._dryNode),this._mainNode["connect"](this._wetNode),this._mainNode["connect"](this._delayNode),this._delayNode["connect"](this._delayGainNode),this._delayGainNode["connect"](this._mainNode)}Release(){this._inputNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),this._mainNode["disconnect"](),this._delayNode["disconnect"](),this._delayGainNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){const o=self.AudioDOMHandler.DbToLinear;switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[2]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 4:this._params[1]=o(t),this.SetAudioParam(this._delayGainNode["gain"],o(t),i,s);break;case 5:this._params[0]=t,this.SetAudioParam(this._delayNode["delayTime"],t,i,s)}}},self.C3AudioConvolveFX=class extends e{constructor(e,t,i,s){super(e),this._type="convolution",this._params=[i,s],this._bufferOriginalUrl="",this._bufferUrl="",this._bufferType="",this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=s,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-s,this._convolveNode=this._audioContext["createConvolver"](),this._convolveNode["normalize"]=i,this._convolveNode["buffer"]=t,this._inputNode["connect"](this._convolveNode),this._inputNode["connect"](this._dryNode),this._convolveNode["connect"](this._wetNode)}Release(){this._inputNode["disconnect"](),this._convolveNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){if(0===e)t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s)}_SetBufferInfo(e,t,i){this._bufferOriginalUrl=e,this._bufferUrl=t,this._bufferType=i}GetState(){const e=super.GetState();return e["bufferOriginalUrl"]=this._bufferOriginalUrl,e["bufferUrl"]="",e["bufferType"]=this._bufferType,e}},self.C3AudioFlangerFX=class extends e{constructor(e,t,i,s,o,a){super(e),this._type="flanger",this._params=[t,i,s,o,a],this._inputNode=this.CreateGain(),this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-a/2,this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=a/2,this._feedbackNode=this.CreateGain(),this._feedbackNode["gain"]["value"]=o,this._delayNode=this._audioContext["createDelay"](t+i),this._delayNode["delayTime"]["value"]=t,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=s,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=i,this._inputNode["connect"](this._delayNode),this._inputNode["connect"](this._dryNode),this._delayNode["connect"](this._wetNode),this._delayNode["connect"](this._feedbackNode),this._feedbackNode["connect"](this._delayNode),this._oscNode["connect"](this._oscGainNode),this._oscGainNode["connect"](this._delayNode["delayTime"]),this._oscNode["start"](0)}Release(){this._oscNode["stop"](0),this._inputNode["disconnect"](),this._delayNode["disconnect"](),this._oscNode["disconnect"](),this._oscGainNode["disconnect"](),this._dryNode["disconnect"](),this._wetNode["disconnect"](),this._feedbackNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[4]=t,this.SetAudioParam(this._wetNode["gain"],t/2,i,s),this.SetAudioParam(this._dryNode["gain"],1-t/2,i,s);break;case 6:this._params[1]=t/1e3,this.SetAudioParam(this._oscGainNode["gain"],t/1e3,i,s);break;case 7:this._params[2]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s);break;case 8:this._params[3]=t/100,this.SetAudioParam(this._feedbackNode["gain"],t/100,i,s)}}},self.C3AudioPhaserFX=class extends e{constructor(e,t,i,s,o,a,n){super(e),this._type="phaser",this._params=[t,i,s,o,a,n],this._inputNode=this.CreateGain(),this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-n/2,this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=n/2,this._filterNode=this._audioContext["createBiquadFilter"](),this._filterNode["type"]="allpass",this._filterNode["frequency"]["value"]=t,this._filterNode["detune"]["value"]=i,this._filterNode["Q"]["value"]=s,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=a,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=o,this._inputNode["connect"](this._filterNode),this._inputNode["connect"](this._dryNode),this._filterNode["connect"](this._wetNode),this._oscNode["connect"](this._oscGainNode),this._oscGainNode["connect"](this._filterNode["frequency"]),this._oscNode["start"](0)}Release(){this._oscNode["stop"](0),this._inputNode["disconnect"](),this._filterNode["disconnect"](),this._oscNode["disconnect"](),this._oscGainNode["disconnect"](),this._dryNode["disconnect"](),this._wetNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[5]=t,this.SetAudioParam(this._wetNode["gain"],t/2,i,s),this.SetAudioParam(this._dryNode["gain"],1-t/2,i,s);break;case 1:this._params[0]=t,this.SetAudioParam(this._filterNode["frequency"],t,i,s);break;case 2:this._params[1]=t,this.SetAudioParam(this._filterNode["detune"],t,i,s);break;case 3:this._params[2]=t,this.SetAudioParam(this._filterNode["Q"],t,i,s);break;case 6:this._params[3]=t,this.SetAudioParam(this._oscGainNode["gain"],t,i,s);break;case 7:this._params[4]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioGainFX=class extends e{constructor(e,t){super(e),this._type="gain",this._params=[t],this._node=this.CreateGain(),this._node["gain"]["value"]=t}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){const o=self.AudioDOMHandler.DbToLinear;if(4===e)this._params[0]=o(t),this.SetAudioParam(this._node["gain"],o(t),i,s)}},self.C3AudioStereoPanFX=class extends e{constructor(e,t){super(e),this._type="stereopan",this._params=[t],this._node=this._audioContext["createStereoPanner"](),this._node["pan"]["value"]=t}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){if(t=Math.min(Math.max(t/100,-1),1),9===e)this._params[0]=t,this.SetAudioParam(this._node["pan"],t,i,s)}},self.C3AudioTremoloFX=class extends e{constructor(e,t,i){super(e),this._type="tremolo",this._params=[t,i],this._node=this.CreateGain(),this._node["gain"]["value"]=1-i/2,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=t,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=i/2,this._oscNode["connect"](this._oscGainNode),this._oscGainNode["connect"](this._node["gain"]),this._oscNode["start"](0)}Release(){this._oscNode["stop"](0),this._oscNode["disconnect"](),this._oscGainNode["disconnect"](),this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._node["gain"],1-t/2,i,s),this.SetAudioParam(this._oscGainNode["gain"],t/2,i,s);break;case 7:this._params[0]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioRingModFX=class extends e{constructor(e,t,i){super(e),this._type="ringmod",this._params=[t,i],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=i,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-i,this._ringNode=this.CreateGain(),this._ringNode["gain"]["value"]=0,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=t,this._oscNode["connect"](this._ringNode["gain"]),this._oscNode["start"](0),this._inputNode["connect"](this._ringNode),this._inputNode["connect"](this._dryNode),this._ringNode["connect"](this._wetNode)}Release(){this._oscNode["stop"](0),this._oscNode["disconnect"](),this._ringNode["disconnect"](),this._inputNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 7:this._params[0]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioDistortionFX=class extends e{constructor(e,t,i,s,o,a){super(e),this._type="distortion",this._params=[t,i,s,o,a],this._inputNode=this.CreateGain(),this._preGain=this.CreateGain(),this._postGain=this.CreateGain(),this._SetDrive(s,o),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=a,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-a,this._waveShaper=this._audioContext["createWaveShaper"](),this._curve=new Float32Array(65536),this._GenerateColortouchCurve(t,i),this._waveShaper.curve=this._curve,this._inputNode["connect"](this._preGain),this._inputNode["connect"](this._dryNode),this._preGain["connect"](this._waveShaper),this._waveShaper["connect"](this._postGain),this._postGain["connect"](this._wetNode)}Release(){this._inputNode["disconnect"](),this._preGain["disconnect"](),this._waveShaper["disconnect"](),this._postGain["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}_SetDrive(e,t){e<.01&&(e=.01),this._preGain["gain"]["value"]=e,this._postGain["gain"]["value"]=Math.pow(1/e,.6)*t}_GenerateColortouchCurve(e,t){const i=32768;for(let s=0;s<i;++s){let o=s/i;o=this._Shape(o,e,t),this._curve[i+s]=o,this._curve[i-s-1]=-o}}_Shape(e,t,i){const s=1.05*i*t-t,o=e<0?-1:1,a=e<0?-e:e;let n=a<t?a:t+s*self.AudioDOMHandler.e4(a-t,1/s);return n*=o,n}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){if(0===e)t=Math.max(Math.min(t/100,1),0),this._params[4]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s)}},self.C3AudioCompressorFX=class extends e{constructor(e,t,i,s,o,a){super(e),this._type="compressor",this._params=[t,i,s,o,a],this._node=this._audioContext["createDynamicsCompressor"](),this._node["threshold"]["value"]=t,this._node["knee"]["value"]=i,this._node["ratio"]["value"]=s,this._node["attack"]["value"]=o,this._node["release"]["value"]=a}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){}},self.C3AudioAnalyserFX=class extends e{constructor(e,t,i){super(e),this._type="analyser",this._params=[t,i],this._node=this._audioContext["createAnalyser"](),this._node["fftSize"]=t,this._node["smoothingTimeConstant"]=i,this._freqBins=new Float32Array(this._node["frequencyBinCount"]),this._signal=new Uint8Array(t),this._peak=0,this._rms=0,this._audioDomHandler._AddAnalyser(this)}Release(){this._audioDomHandler._RemoveAnalyser(this),this._node["disconnect"](),super.Release()}Tick(){this._node["getFloatFrequencyData"](this._freqBins),this._node["getByteTimeDomainData"](this._signal);const e=this._node["fftSize"];this._peak=0;let t=0;for(let i=0;i<e;++i){let e=(this._signal[i]-128)/128;e<0&&(e=-e),this._peak<e&&(this._peak=e),t+=e*e}const i=self.AudioDOMHandler.LinearToDb;this._peak=i(this._peak),this._rms=i(Math.sqrt(t/e))}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){}GetData(){return{"tag":this.GetTag(),"index":this.GetIndex(),"peak":this._peak,"rms":this._rms,"binCount":this._node["frequencyBinCount"],"freqBins":this._freqBins}}}}

// 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"})}
