diff --git a/dist/webai.min.js b/dist/webai.min.mjs similarity index 99% rename from dist/webai.min.js rename to dist/webai.min.mjs index 8241492..5e00c35 100644 --- a/dist/webai.min.js +++ b/dist/webai.min.mjs @@ -1,4 +1,5 @@ import Be from "https://cdn.jsdelivr.net/npm/onnxruntime-web@dev/dist/ort.all.bundle.min.mjs"; +import { default as oa } from "https://cdn.jsdelivr.net/npm/onnxruntime-web@dev/dist/ort.all.bundle.min.mjs"; var x = function() { var b = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0; return function(y) { @@ -238,7 +239,7 @@ var x = function() { function Tn(e) { return String.prototype.startsWith ? e.startsWith(Fn) : e.indexOf(Fn) === 0; } - var me = "./opencv.wasm"; + var me = "opencv.wasm"; Tn(me) || (me = le(me)); function ir() { try { @@ -6743,3 +6744,9 @@ const te = { window.WebAI = te; window.cv = x; window.ort = Be; +export { + te as WebAI, + x as cv, + te as default, + oa as ort +}; diff --git a/docs/index.js b/docs/index.js index 72021fb..0156fe2 100644 --- a/docs/index.js +++ b/docs/index.js @@ -1,4 +1,4 @@ -import Fn from"https://cdn.jsdelivr.net/npm/onnxruntime-web@dev/dist/ort.all.bundle.min.mjs";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))f(p);new MutationObserver(p=>{for(const h of p)if(h.type==="childList")for(const _ of h.addedNodes)_.tagName==="LINK"&&_.rel==="modulepreload"&&f(_)}).observe(document,{childList:!0,subtree:!0});function t(p){const h={};return p.integrity&&(h.integrity=p.integrity),p.referrerPolicy&&(h.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?h.credentials="include":p.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function f(p){if(p.ep)return;p.ep=!0;const h=t(p);fetch(p.href,h)}})();var x=function(){var d=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a){a=a||{};var t=typeof a<"u"?a:{},f={},p;for(p in t)t.hasOwnProperty(p)&&(f[p]=t[p]);var h="./this.program",_=!1,C=!1,S=!1,w=!1,T=!1;_=typeof window=="object",C=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",S=w&&!_&&!C,T=!_&&!S&&!C;var D="";function F(e){return t.locateFile?t.locateFile(e,D):D+e}var N,X,K;if(S){D=__dirname+"/";var Ne,V;N=function(n,r){var i;return i=en(n),i||(Ne||(Ne=require("fs")),V||(V=require("path")),n=V.normalize(n),i=Ne.readFileSync(n)),r?i:i.toString()},K=function(n){var r=N(n,!0);return r.buffer||(r=new Uint8Array(r)),re(r.buffer),r},process.argv.length>1&&(h=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof Nr))throw e}),process.on("unhandledRejection",ae),t.inspect=function(){return"[Emscripten Module object]"}}else T?(typeof read<"u"&&(N=function(n){var r=en(n);return r?Lr(r):read(n)}),K=function(n){var r;return r=en(n),r||(typeof readbuffer=="function"?new Uint8Array(readbuffer(n)):(r=read(n,"binary"),re(typeof r=="object"),r))},typeof scriptArgs<"u"&&scriptArgs,typeof print<"u"&&(typeof console>"u"&&(console={}),console.log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)):(_||C)&&(C?D=self.location.href:document.currentScript&&(D=document.currentScript.src),d&&(D=d),D.indexOf("blob:")!==0?D=D.substr(0,D.lastIndexOf("/")+1):D="",N=function(n){try{var r=new XMLHttpRequest;return r.open("GET",n,!1),r.send(null),r.responseText}catch(o){var i=en(n);if(i)return Lr(i);throw o}},C&&(K=function(n){try{var r=new XMLHttpRequest;return r.open("GET",n,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}catch(o){var i=en(n);if(i)return i;throw o}}),X=function(n,r,i){var o=new XMLHttpRequest;o.open("GET",n,!0),o.responseType="arraybuffer",o.onload=function(){if(o.status==200||o.status==0&&o.response){r(o.response);return}var u=en(n);if(u){r(u.buffer);return}i()},o.onerror=i,o.send(null)});var Ae=t.print||console.log.bind(console),ie=t.printErr||console.warn.bind(console);for(p in f)f.hasOwnProperty(p)&&(t[p]=f[p]);f=null,t.arguments&&t.arguments,t.thisProgram&&(h=t.thisProgram),t.quit&&t.quit;function On(e){var n=k[Et>>2],r=n+e+15&-16;return r>Pr()&&ae(),k[Et>>2]=r,n}function ze(e){ze.shown||(ze.shown={}),ze.shown[e]||(ze.shown[e]=1,ie(e))}var Ue;t.wasmBinary&&(Ue=t.wasmBinary),t.noExitRuntime&&t.noExitRuntime,typeof WebAssembly!="object"&&ie("no native wasm support detected");var Re,yn=new WebAssembly.Table({initial:12498,maximum:12498,element:"anyfunc"}),ve=!1;function re(e,n){e||ae("Assertion failed: "+n)}function hn(e){return ur?nn(e):On(e)}var He=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Fe(e,n,r){for(var i=n+r,o=n;e[o]&&!(o>=i);)++o;if(o-n>16&&e.subarray&&He)return He.decode(e.subarray(n,o));for(var l="";n>10,56320|y&1023)}}return l}function _e(e,n){return e?Fe(de,e,n):""}function we(e,n,r,i){if(!(i>0))return 0;for(var o=r,l=r+i-1,u=0;u=55296&&c<=57343){var m=e.charCodeAt(++u);c=65536+((c&1023)<<10)|m&1023}if(c<=127){if(r>=l)break;n[r++]=c}else if(c<=2047){if(r+1>=l)break;n[r++]=192|c>>6,n[r++]=128|c&63}else if(c<=65535){if(r+2>=l)break;n[r++]=224|c>>12,n[r++]=128|c>>6&63,n[r++]=128|c&63}else{if(r+3>=l)break;n[r++]=240|c>>18,n[r++]=128|c>>12&63,n[r++]=128|c>>6&63,n[r++]=128|c&63}}return n[r]=0,r-o}function ce(e,n,r){return we(e,de,n,r)}function je(e){for(var n=0,r=0;r=55296&&i<=57343&&(i=65536+((i&1023)<<10)|e.charCodeAt(++r)&1023),i<=127?++n:i<=2047?n+=2:i<=65535?n+=3:n+=4}return n}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function In(e,n){ee.set(e,n)}function Bn(e,n,r){for(var i=0;i>0]=e.charCodeAt(i);ee[n>>0]=0}var Ge=16384,Le=65536;function We(e,n){return e%n>0&&(e+=n-e%n),e}var W,ee,de,zn,Ct,k,be,tr,rr;function ir(e){W=e,t.HEAP8=ee=new Int8Array(e),t.HEAP16=zn=new Int16Array(e),t.HEAP32=k=new Int32Array(e),t.HEAPU8=de=new Uint8Array(e),t.HEAPU16=Ct=new Uint16Array(e),t.HEAPU32=be=new Uint32Array(e),t.HEAPF32=tr=new Float32Array(e),t.HEAPF64=rr=new Float64Array(e)}var ti=7022992,Et=1779952,ar=t.TOTAL_MEMORY||134217728;t.wasmMemory?Re=t.wasmMemory:Re=new WebAssembly.Memory({initial:ar/Le,maximum:1073741824/Le}),Re&&(W=Re.buffer),ar=W.byteLength,ir(W),k[Et>>2]=ti;function Un(e){for(;e.length>0;){var n=e.shift();if(typeof n=="function"){n();continue}var r=n.func;typeof r=="number"?n.arg===void 0?t.dynCall_v(r):t.dynCall_vi(r,n.arg):r(n.arg===void 0?null:n.arg)}}var or=[],sr=[],ri=[],lr=[],ur=!1;function ii(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)li(t.preRun.shift());Un(or)}function ai(){ur=!0,!t.noFSInit&&!s.init.initialized&&s.init(),Un(sr)}function oi(){s.ignorePermissions=!1,Un(ri)}function si(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)ui(t.postRun.shift());Un(lr)}function li(e){or.unshift(e)}function ui(e){lr.unshift(e)}var bt=Math.abs,_n=Math.ceil,gn=Math.floor,Tt=Math.min,Ve=0,vn=null;function Zo(e){return e}function jn(e){Ve++,t.monitorRunDependencies&&t.monitorRunDependencies(Ve)}function wn(e){if(Ve--,t.monitorRunDependencies&&t.monitorRunDependencies(Ve),Ve==0&&vn){var n=vn;vn=null,n()}}t.preloadedImages={},t.preloadedAudios={};function ae(e){throw t.onAbort&&t.onAbort(e),e+="",Ae(e),ie(e),ve=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}var St="data:application/octet-stream;base64,";function Pt(e){return String.prototype.startsWith?e.startsWith(St):e.indexOf(St)===0}var Me="./opencv.wasm";Pt(Me)||(Me=F(Me));function fr(){try{if(Ue)return new Uint8Array(Ue);var e=en(Me);if(e)return e;if(K)return K(Me);throw"both async and sync fetching of the wasm failed"}catch(n){ae(n)}}function fi(){return!Ue&&(_||C)&&typeof fetch=="function"?fetch(Me,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Me+"'";return e.arrayBuffer()}).catch(function(){return fr()}):new Promise(function(e,n){e(fr())})}function ci(){var e={env:Dr,wasi_unstable:Dr};function n(u,c){var m=u.exports;t.asm=m,wn()}jn();function r(u){n(u.instance)}function i(u){return fi().then(function(c){return WebAssembly.instantiate(c,e)}).then(u,function(c){ie("failed to asynchronously prepare wasm: "+c),ae(c)})}function o(){if(!Ue&&typeof WebAssembly.instantiateStreaming=="function"&&!Pt(Me)&&typeof fetch=="function")fetch(Me,{credentials:"same-origin"}).then(function(u){var c=WebAssembly.instantiateStreaming(u,e);return c.then(r,function(m){ie("wasm streaming compile failed: "+m),ie("falling back to ArrayBuffer instantiation"),i(r)})});else return i(r)}if(t.instantiateWasm)try{var l=t.instantiateWasm(e,n);return l}catch(u){return ie("Module.instantiateWasm callback failed with error: "+u),!1}return o(),{}}var ue,xe;sr.push({func:function(){yo()}});function di(e,n){if(g.mainLoop.timingMode=e,g.mainLoop.timingValue=n,!g.mainLoop.func)return 1;if(e==0)g.mainLoop.scheduler=function(){var u=Math.max(0,g.mainLoop.tickStartTime+n-Ye())|0;setTimeout(g.mainLoop.runner,u)},g.mainLoop.method="timeout";else if(e==1)g.mainLoop.scheduler=function(){g.requestAnimationFrame(g.mainLoop.runner)},g.mainLoop.method="rAF";else if(e==2){if(typeof setImmediate>"u"){var r=[],i="setimmediate",o=function(l){(l.data===i||l.data.target===i)&&(l.stopPropagation(),r.shift()())};addEventListener("message",o,!0),setImmediate=function(u){r.push(u),C?(t.setImmediates===void 0&&(t.setImmediates=[]),t.setImmediates.push(u),postMessage({target:i})):postMessage(i,"*")}}g.mainLoop.scheduler=function(){setImmediate(g.mainLoop.runner)},g.mainLoop.method="immediate"}return 0}function Ye(){ae()}function mi(e,n,r,i,o){re(!g.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),g.mainLoop.func=e,g.mainLoop.arg=i;var l;typeof i<"u"?l=function(){t.dynCall_vi(e,i)}:l=function(){t.dynCall_v(e)};var u=g.mainLoop.currentlyRunningMainloop;g.mainLoop.runner=function(){if(!ve){if(g.mainLoop.queue.length>0){var m=Date.now(),y=g.mainLoop.queue.shift();if(y.func(y.arg),g.mainLoop.remainingBlockers){var v=g.mainLoop.remainingBlockers,E=v%1==0?v-1:Math.floor(v);y.counted?g.mainLoop.remainingBlockers=E:(E=E+.5,g.mainLoop.remainingBlockers=(8*v+E)/9)}if(console.log('main loop blocker "'+y.name+'" took '+(Date.now()-m)+" ms"),g.mainLoop.updateStatus(),u1&&g.mainLoop.currentFrameNumber%g.mainLoop.timingValue!=0){g.mainLoop.scheduler();return}else g.mainLoop.timingMode==0&&(g.mainLoop.tickStartTime=Ye());g.mainLoop.method==="timeout"&&t.ctx&&(ie("Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!"),g.mainLoop.method=""),g.mainLoop.runIter(l),!(u"u"&&(console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),t.noImageDecoding=!0);var e={};e.canHandle=function(l){return!t.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(l)},e.handle=function(l,u,c,m){var y=null;if(g.hasBlobConstructor)try{y=new Blob([l],{type:g.getMimetype(u)}),y.size!==l.length&&(y=new Blob([new Uint8Array(l).buffer],{type:g.getMimetype(u)}))}catch(A){ze("Blob constructor present but fails: "+A+"; falling back to blob builder")}if(!y){var v=new g.BlobBuilder;v.append(new Uint8Array(l).buffer),y=v.getBlob()}var E=g.URLObject.createObjectURL(y),b=new Image;b.onload=function(){re(b.complete,"Image "+u+" could not be decoded");var L=document.createElement("canvas");L.width=b.width,L.height=b.height;var U=L.getContext("2d");U.drawImage(b,0,0),t.preloadedImages[u]=L,g.URLObject.revokeObjectURL(E),c&&c(l)},b.onerror=function(L){console.log("Image "+E+" could not be decoded"),m&&m()},b.src=E},t.preloadPlugins.push(e);var n={};n.canHandle=function(l){return!t.noAudioDecoding&&l.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},n.handle=function(l,u,c,m){var y=!1;function v(U){y||(y=!0,t.preloadedAudios[u]=U,c&&c(l))}function E(){y||(y=!0,t.preloadedAudios[u]=new Audio,m&&m())}if(g.hasBlobConstructor){try{var b=new Blob([l],{type:g.getMimetype(u)})}catch{return E()}var A=g.URLObject.createObjectURL(b),L=new Audio;L.addEventListener("canplaythrough",function(){v(L)},!1),L.onerror=function(Y){if(y)return;console.log("warning: browser could not fully decode audio "+u+", trying slower base64 approach");function H(P){for(var R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G="=",I="",$=0,fe=0,Te=0;Te=6;){var bo=$>>fe-6&63;fe-=6,I+=R[bo]}return fe==2?(I+=R[($&3)<<4],I+=G+G):fe==4&&(I+=R[($&15)<<2],I+=G),I}L.src="data:audio/x-"+u.substr(-3)+";base64,"+H(l),v(L)},L.src=A,g.safeSetTimeout(function(){v(L)},1e4)}else return E()},t.preloadPlugins.push(n);function r(){g.pointerLock=document.pointerLockElement===t.canvas||document.mozPointerLockElement===t.canvas||document.webkitPointerLockElement===t.canvas||document.msPointerLockElement===t.canvas}var i=t.canvas;i&&(i.requestPointerLock=i.requestPointerLock||i.mozRequestPointerLock||i.webkitRequestPointerLock||i.msRequestPointerLock||function(){},i.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},i.exitPointerLock=i.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",r,!1),document.addEventListener("mozpointerlockchange",r,!1),document.addEventListener("webkitpointerlockchange",r,!1),document.addEventListener("mspointerlockchange",r,!1),t.elementPointerLock&&i.addEventListener("click",function(o){!g.pointerLock&&t.canvas.requestPointerLock&&(t.canvas.requestPointerLock(),o.preventDefault())},!1))},createContext:function(e,n,r,i){if(n&&t.ctx&&e==t.canvas)return t.ctx;var o,l;if(n){var u={antialias:!1,alpha:!1,majorVersion:1};if(i)for(var c in i)u[c]=i[c];typeof GL<"u"&&(l=GL.createContext(e,u),l&&(o=GL.getContext(l).GLctx))}else o=e.getContext("2d");return o?(r&&(n||re(typeof GLctx>"u","cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),t.ctx=o,n&&GL.makeContextCurrent(l),t.useWebGL=n,g.moduleContextCreatedCallbacks.forEach(function(m){m()}),g.init()),o):null},destroyContext:function(e,n,r){},fullscreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullscreen:function(e,n,r){g.lockPointer=e,g.resizeCanvas=n,g.vrDevice=r,typeof g.lockPointer>"u"&&(g.lockPointer=!0),typeof g.resizeCanvas>"u"&&(g.resizeCanvas=!1),typeof g.vrDevice>"u"&&(g.vrDevice=null);var i=t.canvas;function o(){g.isFullscreen=!1;var u=i.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===u?(i.exitFullscreen=g.exitFullscreen,g.lockPointer&&i.requestPointerLock(),g.isFullscreen=!0,g.resizeCanvas?g.setFullscreenCanvasSize():g.updateCanvasDimensions(i)):(u.parentNode.insertBefore(i,u),u.parentNode.removeChild(u),g.resizeCanvas?g.setWindowedCanvasSize():g.updateCanvasDimensions(i)),t.onFullScreen&&t.onFullScreen(g.isFullscreen),t.onFullscreen&&t.onFullscreen(g.isFullscreen)}g.fullscreenHandlersInstalled||(g.fullscreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",o,!1),document.addEventListener("mozfullscreenchange",o,!1),document.addEventListener("webkitfullscreenchange",o,!1),document.addEventListener("MSFullscreenChange",o,!1));var l=document.createElement("div");i.parentNode.insertBefore(l,i),l.appendChild(i),l.requestFullscreen=l.requestFullscreen||l.mozRequestFullScreen||l.msRequestFullscreen||(l.webkitRequestFullscreen?function(){l.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}:null)||(l.webkitRequestFullScreen?function(){l.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),r?l.requestFullscreen({vrDisplay:r}):l.requestFullscreen()},requestFullScreen:function(e,n,r){return ie("Browser.requestFullScreen() is deprecated. Please call Browser.requestFullscreen instead."),g.requestFullScreen=function(i,o,l){return g.requestFullscreen(i,o,l)},g.requestFullscreen(e,n,r)},exitFullscreen:function(){if(!g.isFullscreen)return!1;var e=document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){};return e.apply(document,[]),!0},nextRAF:0,fakeRequestAnimationFrame:function(e){var n=Date.now();if(g.nextRAF===0)g.nextRAF=n+1e3/60;else for(;n+2>=g.nextRAF;)g.nextRAF+=1e3/60;var r=Math.max(g.nextRAF-n,0);setTimeout(e,r)},requestAnimationFrame:function(e){if(typeof requestAnimationFrame=="function"){requestAnimationFrame(e);return}var n=g.fakeRequestAnimationFrame;n(e)},safeCallback:function(e){return function(){if(!ve)return e.apply(null,arguments)}},allowAsyncCallbacks:!0,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function(){g.allowAsyncCallbacks=!1},resumeAsyncCallbacks:function(){if(g.allowAsyncCallbacks=!0,g.queuedAsyncCallbacks.length>0){var e=g.queuedAsyncCallbacks;g.queuedAsyncCallbacks=[],e.forEach(function(n){n()})}},safeRequestAnimationFrame:function(e){return g.requestAnimationFrame(function(){ve||(g.allowAsyncCallbacks?e():g.queuedAsyncCallbacks.push(e))})},safeSetTimeout:function(e,n){return setTimeout(function(){ve||(g.allowAsyncCallbacks?e():g.queuedAsyncCallbacks.push(e))},n)},safeSetInterval:function(e,n){return setInterval(function(){ve||g.allowAsyncCallbacks&&e()},n)},getMimetype:function(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]},getUserMedia:function(e){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(e)},getMovementX:function(e){return e.movementX||e.mozMovementX||e.webkitMovementX||0},getMovementY:function(e){return e.movementY||e.mozMovementY||e.webkitMovementY||0},getMouseWheelDelta:function(e){var n=0;switch(e.type){case"DOMMouseScroll":n=e.detail/3;break;case"mousewheel":n=e.wheelDelta/120;break;case"wheel":switch(n=e.deltaY,e.deltaMode){case 0:n/=100;break;case 1:n/=3;break;case 2:n*=80;break;default:throw"unrecognized mouse wheel delta mode: "+e.deltaMode}break;default:throw"unrecognized mouse wheel event: "+e.type}return n},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function(e){if(g.pointerLock)e.type!="mousemove"&&"mozMovementX"in e?g.mouseMovementX=g.mouseMovementY=0:(g.mouseMovementX=g.getMovementX(e),g.mouseMovementY=g.getMovementY(e)),typeof SDL<"u"?(g.mouseX=SDL.mouseX+g.mouseMovementX,g.mouseY=SDL.mouseY+g.mouseMovementY):(g.mouseX+=g.mouseMovementX,g.mouseY+=g.mouseMovementY);else{var n=t.canvas.getBoundingClientRect(),r=t.canvas.width,i=t.canvas.height,o=typeof window.scrollX<"u"?window.scrollX:window.pageXOffset,l=typeof window.scrollY<"u"?window.scrollY:window.pageYOffset;if(e.type==="touchstart"||e.type==="touchend"||e.type==="touchmove"){var u=e.touch;if(u===void 0)return;var c=u.pageX-(o+n.left),m=u.pageY-(l+n.top);c=c*(r/n.width),m=m*(i/n.height);var y={x:c,y:m};if(e.type==="touchstart")g.lastTouches[u.identifier]=y,g.touches[u.identifier]=y;else if(e.type==="touchend"||e.type==="touchmove"){var v=g.touches[u.identifier];v||(v=y),g.lastTouches[u.identifier]=v,g.touches[u.identifier]=y}return}var E=e.pageX-(o+n.left),b=e.pageY-(l+n.top);E=E*(r/n.width),b=b*(i/n.height),g.mouseMovementX=E-g.mouseX,g.mouseMovementY=b-g.mouseY,g.mouseX=E,g.mouseY=b}},asyncLoad:function(e,n,r,i){var o=i?"":"al "+e;X(e,function(l){re(l,'Loading data file "'+e+'" failed (no arrayBuffer).'),n(new Uint8Array(l)),o&&wn()},function(l){if(r)r();else throw'Loading data file "'+e+'" failed.'}),o&&jn()},resizeListeners:[],updateResizeListeners:function(){var e=t.canvas;g.resizeListeners.forEach(function(n){n(e.width,e.height)})},setCanvasSize:function(e,n,r){var i=t.canvas;g.updateCanvasDimensions(i,e,n),r||g.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullscreenCanvasSize:function(){if(typeof SDL<"u"){var e=be[SDL.screen>>2];e=e|8388608,k[SDL.screen>>2]=e}g.updateCanvasDimensions(t.canvas),g.updateResizeListeners()},setWindowedCanvasSize:function(){if(typeof SDL<"u"){var e=be[SDL.screen>>2];e=e&-8388609,k[SDL.screen>>2]=e}g.updateCanvasDimensions(t.canvas),g.updateResizeListeners()},updateCanvasDimensions:function(e,n,r){n&&r?(e.widthNative=n,e.heightNative=r):(n=e.widthNative,r=e.heightNative);var i=n,o=r;if(t.forcedAspectRatio&&t.forcedAspectRatio>0&&(i/o>2]===0&&u)return _e(u)}catch{}finally{o&&Ce(o),l&&Ce(l),u&&Ce(u)}return e}function yi(e){var n=/\b_Z[\w\d_]+/g;return e.replace(n,function(r){var i=pi(r);return r===i?r:i+" ["+r+"]"})}function hi(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(n){e=n}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function _i(){var e=hi();return t.extraStackTrace&&(e+=` +import Fn from"https://cdn.jsdelivr.net/npm/onnxruntime-web@dev/dist/ort.all.bundle.min.mjs";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))f(p);new MutationObserver(p=>{for(const h of p)if(h.type==="childList")for(const _ of h.addedNodes)_.tagName==="LINK"&&_.rel==="modulepreload"&&f(_)}).observe(document,{childList:!0,subtree:!0});function t(p){const h={};return p.integrity&&(h.integrity=p.integrity),p.referrerPolicy&&(h.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?h.credentials="include":p.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function f(p){if(p.ep)return;p.ep=!0;const h=t(p);fetch(p.href,h)}})();var x=function(){var d=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a){a=a||{};var t=typeof a<"u"?a:{},f={},p;for(p in t)t.hasOwnProperty(p)&&(f[p]=t[p]);var h="./this.program",_=!1,C=!1,S=!1,w=!1,T=!1;_=typeof window=="object",C=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",S=w&&!_&&!C,T=!_&&!S&&!C;var D="";function F(e){return t.locateFile?t.locateFile(e,D):D+e}var N,X,K;if(S){D=__dirname+"/";var Ne,V;N=function(n,r){var i;return i=en(n),i||(Ne||(Ne=require("fs")),V||(V=require("path")),n=V.normalize(n),i=Ne.readFileSync(n)),r?i:i.toString()},K=function(n){var r=N(n,!0);return r.buffer||(r=new Uint8Array(r)),re(r.buffer),r},process.argv.length>1&&(h=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof Nr))throw e}),process.on("unhandledRejection",ae),t.inspect=function(){return"[Emscripten Module object]"}}else T?(typeof read<"u"&&(N=function(n){var r=en(n);return r?Lr(r):read(n)}),K=function(n){var r;return r=en(n),r||(typeof readbuffer=="function"?new Uint8Array(readbuffer(n)):(r=read(n,"binary"),re(typeof r=="object"),r))},typeof scriptArgs<"u"&&scriptArgs,typeof print<"u"&&(typeof console>"u"&&(console={}),console.log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)):(_||C)&&(C?D=self.location.href:document.currentScript&&(D=document.currentScript.src),d&&(D=d),D.indexOf("blob:")!==0?D=D.substr(0,D.lastIndexOf("/")+1):D="",N=function(n){try{var r=new XMLHttpRequest;return r.open("GET",n,!1),r.send(null),r.responseText}catch(o){var i=en(n);if(i)return Lr(i);throw o}},C&&(K=function(n){try{var r=new XMLHttpRequest;return r.open("GET",n,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}catch(o){var i=en(n);if(i)return i;throw o}}),X=function(n,r,i){var o=new XMLHttpRequest;o.open("GET",n,!0),o.responseType="arraybuffer",o.onload=function(){if(o.status==200||o.status==0&&o.response){r(o.response);return}var u=en(n);if(u){r(u.buffer);return}i()},o.onerror=i,o.send(null)});var Ae=t.print||console.log.bind(console),ie=t.printErr||console.warn.bind(console);for(p in f)f.hasOwnProperty(p)&&(t[p]=f[p]);f=null,t.arguments&&t.arguments,t.thisProgram&&(h=t.thisProgram),t.quit&&t.quit;function On(e){var n=k[Et>>2],r=n+e+15&-16;return r>Pr()&&ae(),k[Et>>2]=r,n}function ze(e){ze.shown||(ze.shown={}),ze.shown[e]||(ze.shown[e]=1,ie(e))}var Ue;t.wasmBinary&&(Ue=t.wasmBinary),t.noExitRuntime&&t.noExitRuntime,typeof WebAssembly!="object"&&ie("no native wasm support detected");var Re,yn=new WebAssembly.Table({initial:12498,maximum:12498,element:"anyfunc"}),ve=!1;function re(e,n){e||ae("Assertion failed: "+n)}function hn(e){return ur?nn(e):On(e)}var He=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Fe(e,n,r){for(var i=n+r,o=n;e[o]&&!(o>=i);)++o;if(o-n>16&&e.subarray&&He)return He.decode(e.subarray(n,o));for(var l="";n>10,56320|y&1023)}}return l}function _e(e,n){return e?Fe(de,e,n):""}function we(e,n,r,i){if(!(i>0))return 0;for(var o=r,l=r+i-1,u=0;u=55296&&c<=57343){var m=e.charCodeAt(++u);c=65536+((c&1023)<<10)|m&1023}if(c<=127){if(r>=l)break;n[r++]=c}else if(c<=2047){if(r+1>=l)break;n[r++]=192|c>>6,n[r++]=128|c&63}else if(c<=65535){if(r+2>=l)break;n[r++]=224|c>>12,n[r++]=128|c>>6&63,n[r++]=128|c&63}else{if(r+3>=l)break;n[r++]=240|c>>18,n[r++]=128|c>>12&63,n[r++]=128|c>>6&63,n[r++]=128|c&63}}return n[r]=0,r-o}function ce(e,n,r){return we(e,de,n,r)}function je(e){for(var n=0,r=0;r=55296&&i<=57343&&(i=65536+((i&1023)<<10)|e.charCodeAt(++r)&1023),i<=127?++n:i<=2047?n+=2:i<=65535?n+=3:n+=4}return n}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function In(e,n){ee.set(e,n)}function Bn(e,n,r){for(var i=0;i>0]=e.charCodeAt(i);ee[n>>0]=0}var Ge=16384,Le=65536;function We(e,n){return e%n>0&&(e+=n-e%n),e}var W,ee,de,zn,Ct,k,be,tr,rr;function ir(e){W=e,t.HEAP8=ee=new Int8Array(e),t.HEAP16=zn=new Int16Array(e),t.HEAP32=k=new Int32Array(e),t.HEAPU8=de=new Uint8Array(e),t.HEAPU16=Ct=new Uint16Array(e),t.HEAPU32=be=new Uint32Array(e),t.HEAPF32=tr=new Float32Array(e),t.HEAPF64=rr=new Float64Array(e)}var ti=7022992,Et=1779952,ar=t.TOTAL_MEMORY||134217728;t.wasmMemory?Re=t.wasmMemory:Re=new WebAssembly.Memory({initial:ar/Le,maximum:1073741824/Le}),Re&&(W=Re.buffer),ar=W.byteLength,ir(W),k[Et>>2]=ti;function Un(e){for(;e.length>0;){var n=e.shift();if(typeof n=="function"){n();continue}var r=n.func;typeof r=="number"?n.arg===void 0?t.dynCall_v(r):t.dynCall_vi(r,n.arg):r(n.arg===void 0?null:n.arg)}}var or=[],sr=[],ri=[],lr=[],ur=!1;function ii(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)li(t.preRun.shift());Un(or)}function ai(){ur=!0,!t.noFSInit&&!s.init.initialized&&s.init(),Un(sr)}function oi(){s.ignorePermissions=!1,Un(ri)}function si(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)ui(t.postRun.shift());Un(lr)}function li(e){or.unshift(e)}function ui(e){lr.unshift(e)}var bt=Math.abs,_n=Math.ceil,gn=Math.floor,Tt=Math.min,Ve=0,vn=null;function Zo(e){return e}function jn(e){Ve++,t.monitorRunDependencies&&t.monitorRunDependencies(Ve)}function wn(e){if(Ve--,t.monitorRunDependencies&&t.monitorRunDependencies(Ve),Ve==0&&vn){var n=vn;vn=null,n()}}t.preloadedImages={},t.preloadedAudios={};function ae(e){throw t.onAbort&&t.onAbort(e),e+="",Ae(e),ie(e),ve=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}var St="data:application/octet-stream;base64,";function Pt(e){return String.prototype.startsWith?e.startsWith(St):e.indexOf(St)===0}var Me="opencv.wasm";Pt(Me)||(Me=F(Me));function fr(){try{if(Ue)return new Uint8Array(Ue);var e=en(Me);if(e)return e;if(K)return K(Me);throw"both async and sync fetching of the wasm failed"}catch(n){ae(n)}}function fi(){return!Ue&&(_||C)&&typeof fetch=="function"?fetch(Me,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Me+"'";return e.arrayBuffer()}).catch(function(){return fr()}):new Promise(function(e,n){e(fr())})}function ci(){var e={env:Dr,wasi_unstable:Dr};function n(u,c){var m=u.exports;t.asm=m,wn()}jn();function r(u){n(u.instance)}function i(u){return fi().then(function(c){return WebAssembly.instantiate(c,e)}).then(u,function(c){ie("failed to asynchronously prepare wasm: "+c),ae(c)})}function o(){if(!Ue&&typeof WebAssembly.instantiateStreaming=="function"&&!Pt(Me)&&typeof fetch=="function")fetch(Me,{credentials:"same-origin"}).then(function(u){var c=WebAssembly.instantiateStreaming(u,e);return c.then(r,function(m){ie("wasm streaming compile failed: "+m),ie("falling back to ArrayBuffer instantiation"),i(r)})});else return i(r)}if(t.instantiateWasm)try{var l=t.instantiateWasm(e,n);return l}catch(u){return ie("Module.instantiateWasm callback failed with error: "+u),!1}return o(),{}}var ue,xe;sr.push({func:function(){yo()}});function di(e,n){if(g.mainLoop.timingMode=e,g.mainLoop.timingValue=n,!g.mainLoop.func)return 1;if(e==0)g.mainLoop.scheduler=function(){var u=Math.max(0,g.mainLoop.tickStartTime+n-Ye())|0;setTimeout(g.mainLoop.runner,u)},g.mainLoop.method="timeout";else if(e==1)g.mainLoop.scheduler=function(){g.requestAnimationFrame(g.mainLoop.runner)},g.mainLoop.method="rAF";else if(e==2){if(typeof setImmediate>"u"){var r=[],i="setimmediate",o=function(l){(l.data===i||l.data.target===i)&&(l.stopPropagation(),r.shift()())};addEventListener("message",o,!0),setImmediate=function(u){r.push(u),C?(t.setImmediates===void 0&&(t.setImmediates=[]),t.setImmediates.push(u),postMessage({target:i})):postMessage(i,"*")}}g.mainLoop.scheduler=function(){setImmediate(g.mainLoop.runner)},g.mainLoop.method="immediate"}return 0}function Ye(){ae()}function mi(e,n,r,i,o){re(!g.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),g.mainLoop.func=e,g.mainLoop.arg=i;var l;typeof i<"u"?l=function(){t.dynCall_vi(e,i)}:l=function(){t.dynCall_v(e)};var u=g.mainLoop.currentlyRunningMainloop;g.mainLoop.runner=function(){if(!ve){if(g.mainLoop.queue.length>0){var m=Date.now(),y=g.mainLoop.queue.shift();if(y.func(y.arg),g.mainLoop.remainingBlockers){var v=g.mainLoop.remainingBlockers,E=v%1==0?v-1:Math.floor(v);y.counted?g.mainLoop.remainingBlockers=E:(E=E+.5,g.mainLoop.remainingBlockers=(8*v+E)/9)}if(console.log('main loop blocker "'+y.name+'" took '+(Date.now()-m)+" ms"),g.mainLoop.updateStatus(),u1&&g.mainLoop.currentFrameNumber%g.mainLoop.timingValue!=0){g.mainLoop.scheduler();return}else g.mainLoop.timingMode==0&&(g.mainLoop.tickStartTime=Ye());g.mainLoop.method==="timeout"&&t.ctx&&(ie("Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!"),g.mainLoop.method=""),g.mainLoop.runIter(l),!(u"u"&&(console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),t.noImageDecoding=!0);var e={};e.canHandle=function(l){return!t.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(l)},e.handle=function(l,u,c,m){var y=null;if(g.hasBlobConstructor)try{y=new Blob([l],{type:g.getMimetype(u)}),y.size!==l.length&&(y=new Blob([new Uint8Array(l).buffer],{type:g.getMimetype(u)}))}catch(A){ze("Blob constructor present but fails: "+A+"; falling back to blob builder")}if(!y){var v=new g.BlobBuilder;v.append(new Uint8Array(l).buffer),y=v.getBlob()}var E=g.URLObject.createObjectURL(y),b=new Image;b.onload=function(){re(b.complete,"Image "+u+" could not be decoded");var L=document.createElement("canvas");L.width=b.width,L.height=b.height;var U=L.getContext("2d");U.drawImage(b,0,0),t.preloadedImages[u]=L,g.URLObject.revokeObjectURL(E),c&&c(l)},b.onerror=function(L){console.log("Image "+E+" could not be decoded"),m&&m()},b.src=E},t.preloadPlugins.push(e);var n={};n.canHandle=function(l){return!t.noAudioDecoding&&l.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},n.handle=function(l,u,c,m){var y=!1;function v(U){y||(y=!0,t.preloadedAudios[u]=U,c&&c(l))}function E(){y||(y=!0,t.preloadedAudios[u]=new Audio,m&&m())}if(g.hasBlobConstructor){try{var b=new Blob([l],{type:g.getMimetype(u)})}catch{return E()}var A=g.URLObject.createObjectURL(b),L=new Audio;L.addEventListener("canplaythrough",function(){v(L)},!1),L.onerror=function(Y){if(y)return;console.log("warning: browser could not fully decode audio "+u+", trying slower base64 approach");function H(P){for(var R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G="=",I="",$=0,fe=0,Te=0;Te=6;){var bo=$>>fe-6&63;fe-=6,I+=R[bo]}return fe==2?(I+=R[($&3)<<4],I+=G+G):fe==4&&(I+=R[($&15)<<2],I+=G),I}L.src="data:audio/x-"+u.substr(-3)+";base64,"+H(l),v(L)},L.src=A,g.safeSetTimeout(function(){v(L)},1e4)}else return E()},t.preloadPlugins.push(n);function r(){g.pointerLock=document.pointerLockElement===t.canvas||document.mozPointerLockElement===t.canvas||document.webkitPointerLockElement===t.canvas||document.msPointerLockElement===t.canvas}var i=t.canvas;i&&(i.requestPointerLock=i.requestPointerLock||i.mozRequestPointerLock||i.webkitRequestPointerLock||i.msRequestPointerLock||function(){},i.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},i.exitPointerLock=i.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",r,!1),document.addEventListener("mozpointerlockchange",r,!1),document.addEventListener("webkitpointerlockchange",r,!1),document.addEventListener("mspointerlockchange",r,!1),t.elementPointerLock&&i.addEventListener("click",function(o){!g.pointerLock&&t.canvas.requestPointerLock&&(t.canvas.requestPointerLock(),o.preventDefault())},!1))},createContext:function(e,n,r,i){if(n&&t.ctx&&e==t.canvas)return t.ctx;var o,l;if(n){var u={antialias:!1,alpha:!1,majorVersion:1};if(i)for(var c in i)u[c]=i[c];typeof GL<"u"&&(l=GL.createContext(e,u),l&&(o=GL.getContext(l).GLctx))}else o=e.getContext("2d");return o?(r&&(n||re(typeof GLctx>"u","cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),t.ctx=o,n&&GL.makeContextCurrent(l),t.useWebGL=n,g.moduleContextCreatedCallbacks.forEach(function(m){m()}),g.init()),o):null},destroyContext:function(e,n,r){},fullscreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullscreen:function(e,n,r){g.lockPointer=e,g.resizeCanvas=n,g.vrDevice=r,typeof g.lockPointer>"u"&&(g.lockPointer=!0),typeof g.resizeCanvas>"u"&&(g.resizeCanvas=!1),typeof g.vrDevice>"u"&&(g.vrDevice=null);var i=t.canvas;function o(){g.isFullscreen=!1;var u=i.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===u?(i.exitFullscreen=g.exitFullscreen,g.lockPointer&&i.requestPointerLock(),g.isFullscreen=!0,g.resizeCanvas?g.setFullscreenCanvasSize():g.updateCanvasDimensions(i)):(u.parentNode.insertBefore(i,u),u.parentNode.removeChild(u),g.resizeCanvas?g.setWindowedCanvasSize():g.updateCanvasDimensions(i)),t.onFullScreen&&t.onFullScreen(g.isFullscreen),t.onFullscreen&&t.onFullscreen(g.isFullscreen)}g.fullscreenHandlersInstalled||(g.fullscreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",o,!1),document.addEventListener("mozfullscreenchange",o,!1),document.addEventListener("webkitfullscreenchange",o,!1),document.addEventListener("MSFullscreenChange",o,!1));var l=document.createElement("div");i.parentNode.insertBefore(l,i),l.appendChild(i),l.requestFullscreen=l.requestFullscreen||l.mozRequestFullScreen||l.msRequestFullscreen||(l.webkitRequestFullscreen?function(){l.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}:null)||(l.webkitRequestFullScreen?function(){l.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),r?l.requestFullscreen({vrDisplay:r}):l.requestFullscreen()},requestFullScreen:function(e,n,r){return ie("Browser.requestFullScreen() is deprecated. Please call Browser.requestFullscreen instead."),g.requestFullScreen=function(i,o,l){return g.requestFullscreen(i,o,l)},g.requestFullscreen(e,n,r)},exitFullscreen:function(){if(!g.isFullscreen)return!1;var e=document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){};return e.apply(document,[]),!0},nextRAF:0,fakeRequestAnimationFrame:function(e){var n=Date.now();if(g.nextRAF===0)g.nextRAF=n+1e3/60;else for(;n+2>=g.nextRAF;)g.nextRAF+=1e3/60;var r=Math.max(g.nextRAF-n,0);setTimeout(e,r)},requestAnimationFrame:function(e){if(typeof requestAnimationFrame=="function"){requestAnimationFrame(e);return}var n=g.fakeRequestAnimationFrame;n(e)},safeCallback:function(e){return function(){if(!ve)return e.apply(null,arguments)}},allowAsyncCallbacks:!0,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function(){g.allowAsyncCallbacks=!1},resumeAsyncCallbacks:function(){if(g.allowAsyncCallbacks=!0,g.queuedAsyncCallbacks.length>0){var e=g.queuedAsyncCallbacks;g.queuedAsyncCallbacks=[],e.forEach(function(n){n()})}},safeRequestAnimationFrame:function(e){return g.requestAnimationFrame(function(){ve||(g.allowAsyncCallbacks?e():g.queuedAsyncCallbacks.push(e))})},safeSetTimeout:function(e,n){return setTimeout(function(){ve||(g.allowAsyncCallbacks?e():g.queuedAsyncCallbacks.push(e))},n)},safeSetInterval:function(e,n){return setInterval(function(){ve||g.allowAsyncCallbacks&&e()},n)},getMimetype:function(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]},getUserMedia:function(e){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(e)},getMovementX:function(e){return e.movementX||e.mozMovementX||e.webkitMovementX||0},getMovementY:function(e){return e.movementY||e.mozMovementY||e.webkitMovementY||0},getMouseWheelDelta:function(e){var n=0;switch(e.type){case"DOMMouseScroll":n=e.detail/3;break;case"mousewheel":n=e.wheelDelta/120;break;case"wheel":switch(n=e.deltaY,e.deltaMode){case 0:n/=100;break;case 1:n/=3;break;case 2:n*=80;break;default:throw"unrecognized mouse wheel delta mode: "+e.deltaMode}break;default:throw"unrecognized mouse wheel event: "+e.type}return n},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function(e){if(g.pointerLock)e.type!="mousemove"&&"mozMovementX"in e?g.mouseMovementX=g.mouseMovementY=0:(g.mouseMovementX=g.getMovementX(e),g.mouseMovementY=g.getMovementY(e)),typeof SDL<"u"?(g.mouseX=SDL.mouseX+g.mouseMovementX,g.mouseY=SDL.mouseY+g.mouseMovementY):(g.mouseX+=g.mouseMovementX,g.mouseY+=g.mouseMovementY);else{var n=t.canvas.getBoundingClientRect(),r=t.canvas.width,i=t.canvas.height,o=typeof window.scrollX<"u"?window.scrollX:window.pageXOffset,l=typeof window.scrollY<"u"?window.scrollY:window.pageYOffset;if(e.type==="touchstart"||e.type==="touchend"||e.type==="touchmove"){var u=e.touch;if(u===void 0)return;var c=u.pageX-(o+n.left),m=u.pageY-(l+n.top);c=c*(r/n.width),m=m*(i/n.height);var y={x:c,y:m};if(e.type==="touchstart")g.lastTouches[u.identifier]=y,g.touches[u.identifier]=y;else if(e.type==="touchend"||e.type==="touchmove"){var v=g.touches[u.identifier];v||(v=y),g.lastTouches[u.identifier]=v,g.touches[u.identifier]=y}return}var E=e.pageX-(o+n.left),b=e.pageY-(l+n.top);E=E*(r/n.width),b=b*(i/n.height),g.mouseMovementX=E-g.mouseX,g.mouseMovementY=b-g.mouseY,g.mouseX=E,g.mouseY=b}},asyncLoad:function(e,n,r,i){var o=i?"":"al "+e;X(e,function(l){re(l,'Loading data file "'+e+'" failed (no arrayBuffer).'),n(new Uint8Array(l)),o&&wn()},function(l){if(r)r();else throw'Loading data file "'+e+'" failed.'}),o&&jn()},resizeListeners:[],updateResizeListeners:function(){var e=t.canvas;g.resizeListeners.forEach(function(n){n(e.width,e.height)})},setCanvasSize:function(e,n,r){var i=t.canvas;g.updateCanvasDimensions(i,e,n),r||g.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullscreenCanvasSize:function(){if(typeof SDL<"u"){var e=be[SDL.screen>>2];e=e|8388608,k[SDL.screen>>2]=e}g.updateCanvasDimensions(t.canvas),g.updateResizeListeners()},setWindowedCanvasSize:function(){if(typeof SDL<"u"){var e=be[SDL.screen>>2];e=e&-8388609,k[SDL.screen>>2]=e}g.updateCanvasDimensions(t.canvas),g.updateResizeListeners()},updateCanvasDimensions:function(e,n,r){n&&r?(e.widthNative=n,e.heightNative=r):(n=e.widthNative,r=e.heightNative);var i=n,o=r;if(t.forcedAspectRatio&&t.forcedAspectRatio>0&&(i/o>2]===0&&u)return _e(u)}catch{}finally{o&&Ce(o),l&&Ce(l),u&&Ce(u)}return e}function yi(e){var n=/\b_Z[\w\d_]+/g;return e.replace(n,function(r){var i=pi(r);return r===i?r:i+" ["+r+"]"})}function hi(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(n){e=n}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function _i(){var e=hi();return t.extraStackTrace&&(e+=` `+t.extraStackTrace()),yi(e)}function gi(e){return nn(e)}function cr(e,n){}function vi(){return cr.apply(null,arguments)}function wi(){return cr.apply(null,arguments)}function Ci(e,n,r){throw"uncaught_exception"in Ut?Ut.uncaught_exceptions++:Ut.uncaught_exceptions=1,e}function Ei(){}function qe(e){return t.___errno_location&&(k[t.___errno_location()>>2]=e),e}function bi(e,n){return qe(63),-1}var z={splitPath:function(e){var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return n.exec(e).slice(1)},normalizeArray:function(e,n){for(var r=0,i=e.length-1;i>=0;i--){var o=e[i];o==="."?e.splice(i,1):o===".."?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(n)for(;r;r--)e.unshift("..");return e},normalize:function(e){var n=e.charAt(0)==="/",r=e.substr(-1)==="/";return e=z.normalizeArray(e.split("/").filter(function(i){return!!i}),!n).join("/"),!e&&!n&&(e="."),e&&r&&(e+="/"),(n?"/":"")+e},dirname:function(e){var n=z.splitPath(e),r=n[0],i=n[1];return!r&&!i?".":(i&&(i=i.substr(0,i.length-1)),r+i)},basename:function(e){if(e==="/")return"/";var n=e.lastIndexOf("/");return n===-1?e:e.substr(n+1)},extname:function(e){return z.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return z.normalize(e.join("/"))},join2:function(e,n){return z.normalize(e+"/"+n)}},De={resolve:function(){for(var e="",n=!1,r=arguments.length-1;r>=-1&&!n;r--){var i=r>=0?arguments[r]:s.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,n=i.charAt(0)==="/"}return e=z.normalizeArray(e.split("/").filter(function(o){return!!o}),!n).join("/"),(n?"/":"")+e||"."},relative:function(e,n){e=De.resolve(e).substr(1),n=De.resolve(n).substr(1);function r(y){for(var v=0;v=0&&y[E]==="";E--);return v>E?[]:y.slice(v,E-v+1)}for(var i=r(e.split("/")),o=r(n.split("/")),l=Math.min(i.length,o.length),u=l,c=0;c0?n=i.slice(0,o).toString("utf-8"):n=null}else typeof window<"u"&&typeof window.prompt=="function"?(n=window.prompt("Input: "),n!==null&&(n+=` `)):typeof readline=="function"&&(n=readline(),n!==null&&(n+=` `));if(!n)return null;e.input=et(n,!0)}return e.input.shift()},put_char:function(e,n){n===null||n===10?(Ae(Fe(e.output,0)),e.output=[]):n!=0&&e.output.push(n)},flush:function(e){e.output&&e.output.length>0&&(Ae(Fe(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,n){n===null||n===10?(ie(Fe(e.output,0)),e.output=[]):n!=0&&e.output.push(n)},flush:function(e){e.output&&e.output.length>0&&(ie(Fe(e.output,0)),e.output=[])}}},O={ops_table:null,mount:function(e){return O.createNode(null,"/",16895,0)},createNode:function(e,n,r,i){if(s.isBlkdev(r)||s.isFIFO(r))throw new s.ErrnoError(63);O.ops_table||(O.ops_table={dir:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr,lookup:O.node_ops.lookup,mknod:O.node_ops.mknod,rename:O.node_ops.rename,unlink:O.node_ops.unlink,rmdir:O.node_ops.rmdir,readdir:O.node_ops.readdir,symlink:O.node_ops.symlink},stream:{llseek:O.stream_ops.llseek}},file:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr},stream:{llseek:O.stream_ops.llseek,read:O.stream_ops.read,write:O.stream_ops.write,allocate:O.stream_ops.allocate,mmap:O.stream_ops.mmap,msync:O.stream_ops.msync}},link:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr,readlink:O.node_ops.readlink},stream:{}},chrdev:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr},stream:s.chrdev_stream_ops}});var o=s.createNode(e,n,r,i);return s.isDir(o.mode)?(o.node_ops=O.ops_table.dir.node,o.stream_ops=O.ops_table.dir.stream,o.contents={}):s.isFile(o.mode)?(o.node_ops=O.ops_table.file.node,o.stream_ops=O.ops_table.file.stream,o.usedBytes=0,o.contents=null):s.isLink(o.mode)?(o.node_ops=O.ops_table.link.node,o.stream_ops=O.ops_table.link.stream):s.isChrdev(o.mode)&&(o.node_ops=O.ops_table.chrdev.node,o.stream_ops=O.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[n]=o),o},getFileDataAsRegularArray:function(e){if(e.contents&&e.contents.subarray){for(var n=[],r=0;r=n)){var i=1024*1024;n=Math.max(n,r*(r0&&e.contents.set(o.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,n){if(e.usedBytes!=n){if(n==0){e.contents=null,e.usedBytes=0;return}if(!e.contents||e.contents.subarray){var r=e.contents;e.contents=new Uint8Array(new ArrayBuffer(n)),r&&e.contents.set(r.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n;return}if(e.contents||(e.contents=[]),e.contents.length>n)e.contents.length=n;else for(;e.contents.length=e.node.usedBytes)return 0;var u=Math.min(e.node.usedBytes-o,i);if(u>8&&l.subarray)n.set(l.subarray(o,o+u),r);else for(var c=0;c0||o+iA.timestamp)&&(o.push(E),i++)});var l=[];if(Object.keys(n.entries).forEach(function(E){n.entries[E];var b=e.entries[E];b||(l.push(E),i++)}),!i)return r(null);var u=!1,c=e.type==="remote"?e.db:n.db,m=c.transaction([Q.DB_STORE_NAME],"readwrite"),y=m.objectStore(Q.DB_STORE_NAME);function v(E){if(E&&!u)return u=!0,r(E)}m.onerror=function(E){v(this.error),E.preventDefault()},m.oncomplete=function(E){u||r(null)},o.sort().forEach(function(E){n.type==="local"?Q.loadRemoteEntry(y,E,function(b,A){if(b)return v(b);Q.storeLocalEntry(E,A,v)}):Q.loadLocalEntry(E,function(b,A){if(b)return v(b);Q.storeRemoteEntry(y,E,A,v)})}),l.sort().reverse().forEach(function(E){n.type==="local"?Q.removeLocalEntry(E,v):Q.removeRemoteEntry(y,E,v)})}},dr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},M={isWindows:!1,staticInit:function(){M.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants");e.fs&&(e=e.fs),M.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY}},bufferFrom:function(e){return Buffer.alloc?Buffer.from(e):new Buffer(e)},convertNodeCode:function(e){var n=e.code;return re(n in dr),dr[n]},mount:function(e){return re(w),M.createNode(null,"/",M.getMode(e.opts.root),0)},createNode:function(e,n,r,i){if(!s.isDir(r)&&!s.isFile(r)&&!s.isLink(r))throw new s.ErrnoError(28);var o=s.createNode(e,n,r);return o.node_ops=M.node_ops,o.stream_ops=M.stream_ops,o},getMode:function(e){var n;try{n=se.lstatSync(e),M.isWindows&&(n.mode=n.mode|(n.mode&292)>>2)}catch(r){throw r.code?new s.ErrnoError(M.convertNodeCode(r)):r}return n.mode},realPath:function(e){for(var n=[];e.parent!==e;)n.push(e.name),e=e.parent;return n.push(e.mount.opts.root),n.reverse(),z.join.apply(null,n)},flagsForNode:function(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289;var n=0;for(var r in M.flagsForNodeMap)e&r&&(n|=M.flagsForNodeMap[r],e^=r);if(e)throw new s.ErrnoError(28);return n},node_ops:{getattr:function(e){var n=M.realPath(e),r;try{r=se.lstatSync(n)}catch(i){throw i.code?new s.ErrnoError(M.convertNodeCode(i)):i}return M.isWindows&&!r.blksize&&(r.blksize=4096),M.isWindows&&!r.blocks&&(r.blocks=(r.size+r.blksize-1)/r.blksize|0),{dev:r.dev,ino:r.ino,mode:r.mode,nlink:r.nlink,uid:r.uid,gid:r.gid,rdev:r.rdev,size:r.size,atime:r.atime,mtime:r.mtime,ctime:r.ctime,blksize:r.blksize,blocks:r.blocks}},setattr:function(e,n){var r=M.realPath(e);try{if(n.mode!==void 0&&(se.chmodSync(r,n.mode),e.mode=n.mode),n.timestamp!==void 0){var i=new Date(n.timestamp);se.utimesSync(r,i,i)}n.size!==void 0&&se.truncateSync(r,n.size)}catch(o){throw o.code?new s.ErrnoError(M.convertNodeCode(o)):o}},lookup:function(e,n){var r=z.join2(M.realPath(e),n),i=M.getMode(r);return M.createNode(e,n,i)},mknod:function(e,n,r,i){var o=M.createNode(e,n,r,i),l=M.realPath(o);try{s.isDir(o.mode)?se.mkdirSync(l,o.mode):se.writeFileSync(l,"",{mode:o.mode})}catch(u){throw u.code?new s.ErrnoError(M.convertNodeCode(u)):u}return o},rename:function(e,n,r){var i=M.realPath(e),o=z.join2(M.realPath(n),r);try{se.renameSync(i,o)}catch(l){throw l.code?new s.ErrnoError(M.convertNodeCode(l)):l}},unlink:function(e,n){var r=z.join2(M.realPath(e),n);try{se.unlinkSync(r)}catch(i){throw i.code?new s.ErrnoError(M.convertNodeCode(i)):i}},rmdir:function(e,n){var r=z.join2(M.realPath(e),n);try{se.rmdirSync(r)}catch(i){throw i.code?new s.ErrnoError(M.convertNodeCode(i)):i}},readdir:function(e){var n=M.realPath(e);try{return se.readdirSync(n)}catch(r){throw r.code?new s.ErrnoError(M.convertNodeCode(r)):r}},symlink:function(e,n,r){var i=z.join2(M.realPath(e),n);try{se.symlinkSync(r,i)}catch(o){throw o.code?new s.ErrnoError(M.convertNodeCode(o)):o}},readlink:function(e){var n=M.realPath(e);try{return n=se.readlinkSync(n),n=Rr.relative(Rr.resolve(e.mount.opts.root),n),n}catch(r){throw r.code?new s.ErrnoError(M.convertNodeCode(r)):r}}},stream_ops:{open:function(e){var n=M.realPath(e.node);try{s.isFile(e.node.mode)&&(e.nfd=se.openSync(n,M.flagsForNode(e.flags)))}catch(r){throw r.code?new s.ErrnoError(M.convertNodeCode(r)):r}},close:function(e){try{s.isFile(e.node.mode)&&e.nfd&&se.closeSync(e.nfd)}catch(n){throw n.code?new s.ErrnoError(M.convertNodeCode(n)):n}},read:function(e,n,r,i,o){if(i===0)return 0;try{return se.readSync(e.nfd,M.bufferFrom(n.buffer),r,i,o)}catch(l){throw new s.ErrnoError(M.convertNodeCode(l))}},write:function(e,n,r,i,o){try{return se.writeSync(e.nfd,M.bufferFrom(n.buffer),r,i,o)}catch(l){throw new s.ErrnoError(M.convertNodeCode(l))}},llseek:function(e,n,r){var i=n;if(r===1)i+=e.position;else if(r===2&&s.isFile(e.node.mode))try{var o=se.fstatSync(e.nfd);i+=o.size}catch(l){throw new s.ErrnoError(M.convertNodeCode(l))}if(i<0)throw new s.ErrnoError(28);return i}}},oe={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function(e){re(C),oe.reader||(oe.reader=new FileReaderSync);var n=oe.createNode(null,"/",oe.DIR_MODE,0),r={};function i(l){for(var u=l.split("/"),c=n,m=0;m=e.node.size)return 0;var l=e.node.contents.slice(o,o+i),u=oe.reader.readAsArrayBuffer(l);return n.set(new Uint8Array(u),r),l.size},write:function(e,n,r,i,o){throw new s.ErrnoError(29)},llseek:function(e,n,r){var i=n;if(r===1?i+=e.position:r===2&&s.isFile(e.node.mode)&&(i+=e.node.size),i<0)throw new s.ErrnoError(28);return i}}},s={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(e){if(!(e instanceof s.ErrnoError))throw e+" : "+_i();return qe(e.errno)},lookupPath:function(e,n){if(e=De.resolve(s.cwd(),e),n=n||{},!e)return{path:"",node:null};var r={follow_mount:!0,recurse_count:0};for(var i in r)n[i]===void 0&&(n[i]=r[i]);if(n.recurse_count>8)throw new s.ErrnoError(32);for(var o=z.normalizeArray(e.split("/").filter(function(b){return!!b}),!1),l=s.root,u="/",c=0;c40)throw new s.ErrnoError(32)}}return{path:u,node:l}},getPath:function(e){for(var n;;){if(s.isRoot(e)){var r=e.mount.mountpoint;return n?r[r.length-1]!=="/"?r+"/"+n:r+n:r}n=n?e.name+"/"+n:e.name,e=e.parent}},hashName:function(e,n){for(var r=0,i=0;i>>0)%s.nameTable.length},hashAddNode:function(e){var n=s.hashName(e.parent.id,e.name);e.name_next=s.nameTable[n],s.nameTable[n]=e},hashRemoveNode:function(e){var n=s.hashName(e.parent.id,e.name);if(s.nameTable[n]===e)s.nameTable[n]=e.name_next;else for(var r=s.nameTable[n];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:function(e,n){var r=s.mayLookup(e);if(r)throw new s.ErrnoError(r,e);for(var i=s.hashName(e.id,n),o=s.nameTable[i];o;o=o.name_next){var l=o.name;if(o.parent.id===e.id&&l===n)return o}return s.lookup(e,n)},createNode:function(e,n,r,i){if(!s.FSNode){s.FSNode=function(c,m,y,v){c||(c=this),this.parent=c,this.mount=c.mount,this.mounted=null,this.id=s.nextInode++,this.name=m,this.mode=y,this.node_ops={},this.stream_ops={},this.rdev=v},s.FSNode.prototype={};var o=365,l=146;Object.defineProperties(s.FSNode.prototype,{read:{get:function(){return(this.mode&o)===o},set:function(c){c?this.mode|=o:this.mode&=~o}},write:{get:function(){return(this.mode&l)===l},set:function(c){c?this.mode|=l:this.mode&=~l}},isFolder:{get:function(){return s.isDir(this.mode)}},isDevice:{get:function(){return s.isChrdev(this.mode)}}})}var u=new s.FSNode(e,n,r,i);return s.hashAddNode(u),u},destroyNode:function(e){s.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return(e&61440)===32768},isDir:function(e){return(e&61440)===16384},isLink:function(e){return(e&61440)===40960},isChrdev:function(e){return(e&61440)===8192},isBlkdev:function(e){return(e&61440)===24576},isFIFO:function(e){return(e&61440)===4096},isSocket:function(e){return(e&49152)===49152},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(e){var n=s.flagModes[e];if(typeof n>"u")throw new Error("Unknown file open mode: "+e);return n},flagsToPermissionString:function(e){var n=["r","w","rw"][e&3];return e&512&&(n+="w"),n},nodePermissions:function(e,n){return s.ignorePermissions?0:n.indexOf("r")!==-1&&!(e.mode&292)||n.indexOf("w")!==-1&&!(e.mode&146)||n.indexOf("x")!==-1&&!(e.mode&73)?2:0},mayLookup:function(e){var n=s.nodePermissions(e,"x");return n||(e.node_ops.lookup?0:2)},mayCreate:function(e,n){try{var r=s.lookupNode(e,n);return 20}catch{}return s.nodePermissions(e,"wx")},mayDelete:function(e,n,r){var i;try{i=s.lookupNode(e,n)}catch(l){return l.errno}var o=s.nodePermissions(e,"wx");if(o)return o;if(r){if(!s.isDir(i.mode))return 54;if(s.isRoot(i)||s.getPath(i)===s.cwd())return 10}else if(s.isDir(i.mode))return 31;return 0},mayOpen:function(e,n){return e?s.isLink(e.mode)?32:s.isDir(e.mode)&&(s.flagsToPermissionString(n)!=="r"||n&512)?31:s.nodePermissions(e,s.flagsToPermissionString(n)):44},MAX_OPEN_FDS:4096,nextfd:function(e,n){e=e||0,n=n||s.MAX_OPEN_FDS;for(var r=e;r<=n;r++)if(!s.streams[r])return r;throw new s.ErrnoError(33)},getStream:function(e){return s.streams[e]},createStream:function(e,n,r){s.FSStream||(s.FSStream=function(){},s.FSStream.prototype={},Object.defineProperties(s.FSStream.prototype,{object:{get:function(){return this.node},set:function(u){this.node=u}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}}));var i=new s.FSStream;for(var o in e)i[o]=e[o];e=i;var l=s.nextfd(n,r);return e.fd=l,s.streams[l]=e,e},closeStream:function(e){s.streams[e]=null},chrdev_stream_ops:{open:function(e){var n=s.getDevice(e.node.rdev);e.stream_ops=n.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new s.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return e&255},makedev:function(e,n){return e<<8|n},registerDevice:function(e,n){s.devices[e]={stream_ops:n}},getDevice:function(e){return s.devices[e]},getMounts:function(e){for(var n=[],r=[e];r.length;){var i=r.pop();n.push(i),r.push.apply(r,i.mounts)}return n},syncfs:function(e,n){typeof e=="function"&&(n=e,e=!1),s.syncFSRequests++,s.syncFSRequests>1&&console.log("warning: "+s.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var r=s.getMounts(s.root.mount),i=0;function o(u){return s.syncFSRequests--,n(u)}function l(u){if(u)return l.errored?void 0:(l.errored=!0,o(u));++i>=r.length&&o(null)}r.forEach(function(u){if(!u.type.syncfs)return l(null);u.type.syncfs(u,e,l)})},mount:function(e,n,r){var i=r==="/",o=!r,l;if(i&&s.root)throw new s.ErrnoError(10);if(!i&&!o){var u=s.lookupPath(r,{follow_mount:!1});if(r=u.path,l=u.node,s.isMountpoint(l))throw new s.ErrnoError(10);if(!s.isDir(l.mode))throw new s.ErrnoError(54)}var c={type:e,opts:n,mountpoint:r,mounts:[]},m=e.mount(c);return m.mount=c,c.root=m,i?s.root=m:l&&(l.mounted=c,l.mount&&l.mount.mounts.push(c)),m},unmount:function(e){var n=s.lookupPath(e,{follow_mount:!1});if(!s.isMountpoint(n.node))throw new s.ErrnoError(28);var r=n.node,i=r.mounted,o=s.getMounts(i);Object.keys(s.nameTable).forEach(function(u){for(var c=s.nameTable[u];c;){var m=c.name_next;o.indexOf(c.mount)!==-1&&s.destroyNode(c),c=m}}),r.mounted=null;var l=r.mount.mounts.indexOf(i);r.mount.mounts.splice(l,1)},lookup:function(e,n){return e.node_ops.lookup(e,n)},mknod:function(e,n,r){var i=s.lookupPath(e,{parent:!0}),o=i.node,l=z.basename(e);if(!l||l==="."||l==="..")throw new s.ErrnoError(28);var u=s.mayCreate(o,l);if(u)throw new s.ErrnoError(u);if(!o.node_ops.mknod)throw new s.ErrnoError(63);return o.node_ops.mknod(o,l,n,r)},create:function(e,n){return n=n!==void 0?n:438,n&=4095,n|=32768,s.mknod(e,n,0)},mkdir:function(e,n){return n=n!==void 0?n:511,n&=1023,n|=16384,s.mknod(e,n,0)},mkdirTree:function(e,n){for(var r=e.split("/"),i="",o=0;o"u"&&(r=n,n=438),n|=8192,s.mknod(e,n,r)},symlink:function(e,n){if(!De.resolve(e))throw new s.ErrnoError(44);var r=s.lookupPath(n,{parent:!0}),i=r.node;if(!i)throw new s.ErrnoError(44);var o=z.basename(n),l=s.mayCreate(i,o);if(l)throw new s.ErrnoError(l);if(!i.node_ops.symlink)throw new s.ErrnoError(63);return i.node_ops.symlink(i,o,e)},rename:function(e,n){var r=z.dirname(e),i=z.dirname(n),o=z.basename(e),l=z.basename(n),u,c,m;try{u=s.lookupPath(e,{parent:!0}),c=u.node,u=s.lookupPath(n,{parent:!0}),m=u.node}catch{throw new s.ErrnoError(10)}if(!c||!m)throw new s.ErrnoError(44);if(c.mount!==m.mount)throw new s.ErrnoError(75);var y=s.lookupNode(c,o),v=De.relative(e,i);if(v.charAt(0)!==".")throw new s.ErrnoError(28);if(v=De.relative(n,r),v.charAt(0)!==".")throw new s.ErrnoError(55);var E;try{E=s.lookupNode(m,l)}catch{}if(y!==E){var b=s.isDir(y.mode),A=s.mayDelete(c,o,b);if(A)throw new s.ErrnoError(A);if(A=E?s.mayDelete(m,l,b):s.mayCreate(m,l),A)throw new s.ErrnoError(A);if(!c.node_ops.rename)throw new s.ErrnoError(63);if(s.isMountpoint(y)||E&&s.isMountpoint(E))throw new s.ErrnoError(10);if(m!==c&&(A=s.nodePermissions(c,"w"),A))throw new s.ErrnoError(A);try{s.trackingDelegate.willMovePath&&s.trackingDelegate.willMovePath(e,n)}catch(L){console.log("FS.trackingDelegate['willMovePath']('"+e+"', '"+n+"') threw an exception: "+L.message)}s.hashRemoveNode(y);try{c.node_ops.rename(y,m,l)}catch(L){throw L}finally{s.hashAddNode(y)}try{s.trackingDelegate.onMovePath&&s.trackingDelegate.onMovePath(e,n)}catch(L){console.log("FS.trackingDelegate['onMovePath']('"+e+"', '"+n+"') threw an exception: "+L.message)}}},rmdir:function(e){var n=s.lookupPath(e,{parent:!0}),r=n.node,i=z.basename(e),o=s.lookupNode(r,i),l=s.mayDelete(r,i,!0);if(l)throw new s.ErrnoError(l);if(!r.node_ops.rmdir)throw new s.ErrnoError(63);if(s.isMountpoint(o))throw new s.ErrnoError(10);try{s.trackingDelegate.willDeletePath&&s.trackingDelegate.willDeletePath(e)}catch(u){console.log("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+u.message)}r.node_ops.rmdir(r,i),s.destroyNode(o);try{s.trackingDelegate.onDeletePath&&s.trackingDelegate.onDeletePath(e)}catch(u){console.log("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+u.message)}},readdir:function(e){var n=s.lookupPath(e,{follow:!0}),r=n.node;if(!r.node_ops.readdir)throw new s.ErrnoError(54);return r.node_ops.readdir(r)},unlink:function(e){var n=s.lookupPath(e,{parent:!0}),r=n.node,i=z.basename(e),o=s.lookupNode(r,i),l=s.mayDelete(r,i,!1);if(l)throw new s.ErrnoError(l);if(!r.node_ops.unlink)throw new s.ErrnoError(63);if(s.isMountpoint(o))throw new s.ErrnoError(10);try{s.trackingDelegate.willDeletePath&&s.trackingDelegate.willDeletePath(e)}catch(u){console.log("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+u.message)}r.node_ops.unlink(r,i),s.destroyNode(o);try{s.trackingDelegate.onDeletePath&&s.trackingDelegate.onDeletePath(e)}catch(u){console.log("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+u.message)}},readlink:function(e){var n=s.lookupPath(e),r=n.node;if(!r)throw new s.ErrnoError(44);if(!r.node_ops.readlink)throw new s.ErrnoError(28);return De.resolve(s.getPath(r.parent),r.node_ops.readlink(r))},stat:function(e,n){var r=s.lookupPath(e,{follow:!n}),i=r.node;if(!i)throw new s.ErrnoError(44);if(!i.node_ops.getattr)throw new s.ErrnoError(63);return i.node_ops.getattr(i)},lstat:function(e){return s.stat(e,!0)},chmod:function(e,n,r){var i;if(typeof e=="string"){var o=s.lookupPath(e,{follow:!r});i=o.node}else i=e;if(!i.node_ops.setattr)throw new s.ErrnoError(63);i.node_ops.setattr(i,{mode:n&4095|i.mode&-4096,timestamp:Date.now()})},lchmod:function(e,n){s.chmod(e,n,!0)},fchmod:function(e,n){var r=s.getStream(e);if(!r)throw new s.ErrnoError(8);s.chmod(r.node,n)},chown:function(e,n,r,i){var o;if(typeof e=="string"){var l=s.lookupPath(e,{follow:!i});o=l.node}else o=e;if(!o.node_ops.setattr)throw new s.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(e,n,r){s.chown(e,n,r,!0)},fchown:function(e,n,r){var i=s.getStream(e);if(!i)throw new s.ErrnoError(8);s.chown(i.node,n,r)},truncate:function(e,n){if(n<0)throw new s.ErrnoError(28);var r;if(typeof e=="string"){var i=s.lookupPath(e,{follow:!0});r=i.node}else r=e;if(!r.node_ops.setattr)throw new s.ErrnoError(63);if(s.isDir(r.mode))throw new s.ErrnoError(31);if(!s.isFile(r.mode))throw new s.ErrnoError(28);var o=s.nodePermissions(r,"w");if(o)throw new s.ErrnoError(o);r.node_ops.setattr(r,{size:n,timestamp:Date.now()})},ftruncate:function(e,n){var r=s.getStream(e);if(!r)throw new s.ErrnoError(8);if(!(r.flags&2097155))throw new s.ErrnoError(28);s.truncate(r.node,n)},utime:function(e,n,r){var i=s.lookupPath(e,{follow:!0}),o=i.node;o.node_ops.setattr(o,{timestamp:Math.max(n,r)})},open:function(e,n,r,i,o){if(e==="")throw new s.ErrnoError(44);n=typeof n=="string"?s.modeStringToFlags(n):n,r=typeof r>"u"?438:r,n&64?r=r&4095|32768:r=0;var l;if(typeof e=="object")l=e;else{e=z.normalize(e);try{var u=s.lookupPath(e,{follow:!(n&131072)});l=u.node}catch{}}var c=!1;if(n&64)if(l){if(n&128)throw new s.ErrnoError(20)}else l=s.mknod(e,r,0),c=!0;if(!l)throw new s.ErrnoError(44);if(s.isChrdev(l.mode)&&(n&=-513),n&65536&&!s.isDir(l.mode))throw new s.ErrnoError(54);if(!c){var m=s.mayOpen(l,n);if(m)throw new s.ErrnoError(m)}n&512&&s.truncate(l,0),n&=-641;var y=s.createStream({node:l,path:s.getPath(l),flags:n,seekable:!0,position:0,stream_ops:l.stream_ops,ungotten:[],error:!1},i,o);y.stream_ops.open&&y.stream_ops.open(y),t.logReadFiles&&!(n&1)&&(s.readFiles||(s.readFiles={}),e in s.readFiles||(s.readFiles[e]=1,console.log("FS.trackingDelegate error on read file: "+e)));try{if(s.trackingDelegate.onOpenFile){var v=0;(n&2097155)!==1&&(v|=s.tracking.openFlags.READ),n&2097155&&(v|=s.tracking.openFlags.WRITE),s.trackingDelegate.onOpenFile(e,v)}}catch(E){console.log("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+E.message)}return y},close:function(e){if(s.isClosed(e))throw new s.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(n){throw n}finally{s.closeStream(e.fd)}e.fd=null},isClosed:function(e){return e.fd===null},llseek:function(e,n,r){if(s.isClosed(e))throw new s.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new s.ErrnoError(70);if(r!=0&&r!=1&&r!=2)throw new s.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,r),e.ungotten=[],e.position},read:function(e,n,r,i,o){if(i<0||o<0)throw new s.ErrnoError(28);if(s.isClosed(e))throw new s.ErrnoError(8);if((e.flags&2097155)===1)throw new s.ErrnoError(8);if(s.isDir(e.node.mode))throw new s.ErrnoError(31);if(!e.stream_ops.read)throw new s.ErrnoError(28);var l=typeof o<"u";if(!l)o=e.position;else if(!e.seekable)throw new s.ErrnoError(70);var u=e.stream_ops.read(e,n,r,i,o);return l||(e.position+=u),u},write:function(e,n,r,i,o,l){if(i<0||o<0)throw new s.ErrnoError(28);if(s.isClosed(e))throw new s.ErrnoError(8);if(!(e.flags&2097155))throw new s.ErrnoError(8);if(s.isDir(e.node.mode))throw new s.ErrnoError(31);if(!e.stream_ops.write)throw new s.ErrnoError(28);e.flags&1024&&s.llseek(e,0,2);var u=typeof o<"u";if(!u)o=e.position;else if(!e.seekable)throw new s.ErrnoError(70);var c=e.stream_ops.write(e,n,r,i,o,l);u||(e.position+=c);try{e.path&&s.trackingDelegate.onWriteToFile&&s.trackingDelegate.onWriteToFile(e.path)}catch(m){console.log("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+m.message)}return c},allocate:function(e,n,r){if(s.isClosed(e))throw new s.ErrnoError(8);if(n<0||r<=0)throw new s.ErrnoError(28);if(!(e.flags&2097155))throw new s.ErrnoError(8);if(!s.isFile(e.node.mode)&&!s.isDir(e.node.mode))throw new s.ErrnoError(43);if(!e.stream_ops.allocate)throw new s.ErrnoError(138);e.stream_ops.allocate(e,n,r)},mmap:function(e,n,r,i,o,l,u){if(l&2&&!(u&2)&&(e.flags&2097155)!==2)throw new s.ErrnoError(2);if((e.flags&2097155)===1)throw new s.ErrnoError(2);if(!e.stream_ops.mmap)throw new s.ErrnoError(43);return e.stream_ops.mmap(e,n,r,i,o,l,u)},msync:function(e,n,r,i,o){return!e||!e.stream_ops.msync?0:e.stream_ops.msync(e,n,r,i,o)},munmap:function(e){return 0},ioctl:function(e,n,r){if(!e.stream_ops.ioctl)throw new s.ErrnoError(59);return e.stream_ops.ioctl(e,n,r)},readFile:function(e,n){if(n=n||{},n.flags=n.flags||"r",n.encoding=n.encoding||"binary",n.encoding!=="utf8"&&n.encoding!=="binary")throw new Error('Invalid encoding type "'+n.encoding+'"');var r,i=s.open(e,n.flags),o=s.stat(e),l=o.size,u=new Uint8Array(l);return s.read(i,u,0,l,0),n.encoding==="utf8"?r=Fe(u,0):n.encoding==="binary"&&(r=u),s.close(i),r},writeFile:function(e,n,r){r=r||{},r.flags=r.flags||"w";var i=s.open(e,r.flags,r.mode);if(typeof n=="string"){var o=new Uint8Array(je(n)+1),l=we(n,o,0,o.length);s.write(i,o,0,l,void 0,r.canOwn)}else if(ArrayBuffer.isView(n))s.write(i,n,0,n.byteLength,void 0,r.canOwn);else throw new Error("Unsupported data type");s.close(i)},cwd:function(){return s.currentPath},chdir:function(e){var n=s.lookupPath(e,{follow:!0});if(n.node===null)throw new s.ErrnoError(44);if(!s.isDir(n.node.mode))throw new s.ErrnoError(54);var r=s.nodePermissions(n.node,"x");if(r)throw new s.ErrnoError(r);s.currentPath=n.path},createDefaultDirectories:function(){s.mkdir("/tmp"),s.mkdir("/home"),s.mkdir("/home/web_user")},createDefaultDevices:function(){s.mkdir("/dev"),s.registerDevice(s.makedev(1,3),{read:function(){return 0},write:function(i,o,l,u,c){return u}}),s.mkdev("/dev/null",s.makedev(1,3)),Xe.register(s.makedev(5,0),Xe.default_tty_ops),Xe.register(s.makedev(6,0),Xe.default_tty1_ops),s.mkdev("/dev/tty",s.makedev(5,0)),s.mkdev("/dev/tty1",s.makedev(6,0));var e;if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var n=new Uint8Array(1);e=function(){return crypto.getRandomValues(n),n[0]}}else if(S)try{var r=require("crypto");e=function(){return r.randomBytes(1)[0]}}catch{}e||(e=function(){ae("random_device")}),s.createDevice("/dev","random",e),s.createDevice("/dev","urandom",e),s.mkdir("/dev/shm"),s.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){s.mkdir("/proc"),s.mkdir("/proc/self"),s.mkdir("/proc/self/fd"),s.mount({mount:function(){var e=s.createNode("/proc/self","fd",16895,73);return e.node_ops={lookup:function(n,r){var i=+r,o=s.getStream(i);if(!o)throw new s.ErrnoError(8);var l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return o.path}}};return l.parent=l,l}},e}},{},"/proc/self/fd")},createStandardStreams:function(){t.stdin?s.createDevice("/dev","stdin",t.stdin):s.symlink("/dev/tty","/dev/stdin"),t.stdout?s.createDevice("/dev","stdout",null,t.stdout):s.symlink("/dev/tty","/dev/stdout"),t.stderr?s.createDevice("/dev","stderr",null,t.stderr):s.symlink("/dev/tty1","/dev/stderr"),s.open("/dev/stdin","r"),s.open("/dev/stdout","w"),s.open("/dev/stderr","w")},ensureErrnoError:function(){s.ErrnoError||(s.ErrnoError=function(n,r){this.node=r,this.setErrno=function(i){this.errno=i},this.setErrno(n),this.message="FS error"},s.ErrnoError.prototype=new Error,s.ErrnoError.prototype.constructor=s.ErrnoError,[44].forEach(function(e){s.genericErrors[e]=new s.ErrnoError(e),s.genericErrors[e].stack=""}))},staticInit:function(){s.ensureErrnoError(),s.nameTable=new Array(4096),s.mount(O,{},"/"),s.createDefaultDirectories(),s.createDefaultDevices(),s.createSpecialDirectories(),s.filesystems={MEMFS:O,IDBFS:Q,NODEFS:M,WORKERFS:oe}},init:function(e,n,r){s.init.initialized=!0,s.ensureErrnoError(),t.stdin=e||t.stdin,t.stdout=n||t.stdout,t.stderr=r||t.stderr,s.createStandardStreams()},quit:function(){s.init.initialized=!1;var e=t._fflush;e&&e(0);for(var n=0;nthis.length-1||b<0)){var A=b%this.chunkSize,L=b/this.chunkSize|0;return this.getter(L)[A]}},l.prototype.setDataGetter=function(b){this.getter=b},l.prototype.cacheLength=function(){var b=new XMLHttpRequest;if(b.open("HEAD",r,!1),b.send(null),!(b.status>=200&&b.status<300||b.status===304))throw new Error("Couldn't load "+r+". Status: "+b.status);var A=Number(b.getResponseHeader("Content-length")),L,U=(L=b.getResponseHeader("Accept-Ranges"))&&L==="bytes",Y=(L=b.getResponseHeader("Content-Encoding"))&&L==="gzip",H=1024*1024;U||(H=A);var P=function(G,I){if(G>I)throw new Error("invalid range ("+G+", "+I+") or no bytes requested!");if(I>A-1)throw new Error("only "+A+" bytes available! programmer error!");var $=new XMLHttpRequest;if($.open("GET",r,!1),A!==H&&$.setRequestHeader("Range","bytes="+G+"-"+I),typeof Uint8Array<"u"&&($.responseType="arraybuffer"),$.overrideMimeType&&$.overrideMimeType("text/plain; charset=x-user-defined"),$.send(null),!($.status>=200&&$.status<300||$.status===304))throw new Error("Couldn't load "+r+". Status: "+$.status);return $.response!==void 0?new Uint8Array($.response||[]):et($.responseText||"",!0)},R=this;R.setDataGetter(function(G){var I=G*H,$=(G+1)*H-1;if($=Math.min($,A-1),typeof R.chunks[G]>"u"&&(R.chunks[G]=P(I,$)),typeof R.chunks[G]>"u")throw new Error("doXHR failed!");return R.chunks[G]}),(Y||!A)&&(H=A=1,A=this.getter(0).length,H=A,console.log("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=A,this._chunkSize=H,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!C)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var u=new l;Object.defineProperties(u,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var c={isDevice:!1,contents:u}}else var c={isDevice:!1,url:r};var m=s.createFile(e,n,c,i,o);c.contents?m.contents=c.contents:c.url&&(m.contents=null,m.url=c.url),Object.defineProperties(m,{usedBytes:{get:function(){return this.contents.length}}});var y={},v=Object.keys(m.stream_ops);return v.forEach(function(E){var b=m.stream_ops[E];y[E]=function(){if(!s.forceLoadFile(m))throw new s.ErrnoError(29);return b.apply(null,arguments)}}),y.read=function(b,A,L,U,Y){if(!s.forceLoadFile(m))throw new s.ErrnoError(29);var H=b.node.contents;if(Y>=H.length)return 0;var P=Math.min(H.length-Y,U);if(H.slice)for(var R=0;R>2]=i.dev,k[r+4>>2]=0,k[r+8>>2]=i.ino,k[r+12>>2]=i.mode,k[r+16>>2]=i.nlink,k[r+20>>2]=i.uid,k[r+24>>2]=i.gid,k[r+28>>2]=i.rdev,k[r+32>>2]=0,xe=[i.size>>>0,(ue=i.size,+bt(ue)>=1?ue>0?(Tt(+gn(ue/4294967296),4294967295)|0)>>>0:~~+_n((ue-+(~~ue>>>0))/4294967296)>>>0:0)],k[r+40>>2]=xe[0],k[r+44>>2]=xe[1],k[r+48>>2]=4096,k[r+52>>2]=i.blocks,k[r+56>>2]=i.atime.getTime()/1e3|0,k[r+60>>2]=0,k[r+64>>2]=i.mtime.getTime()/1e3|0,k[r+68>>2]=0,k[r+72>>2]=i.ctime.getTime()/1e3|0,k[r+76>>2]=0,xe=[i.ino>>>0,(ue=i.ino,+bt(ue)>=1?ue>0?(Tt(+gn(ue/4294967296),4294967295)|0)>>>0:~~+_n((ue-+(~~ue>>>0))/4294967296)>>>0:0)],k[r+80>>2]=xe[0],k[r+84>>2]=xe[1],0},doMsync:function(e,n,r,i){var o=new Uint8Array(de.subarray(e,e+r));s.msync(n,o,0,r,i)},doMkdir:function(e,n){return e=z.normalize(e),e[e.length-1]==="/"&&(e=e.substr(0,e.length-1)),s.mkdir(e,n,0),0},doMknod:function(e,n,r){switch(n&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return s.mknod(e,n,r),0},doReadlink:function(e,n,r){if(r<=0)return-28;var i=s.readlink(e),o=Math.min(r,je(i)),l=ee[n+o];return ce(i,n,r+1),ee[n+o]=l,o},doAccess:function(e,n){if(n&-8)return-28;var r,i=s.lookupPath(e,{follow:!0});if(r=i.node,!r)return-44;var o="";return n&4&&(o+="r"),n&2&&(o+="w"),n&1&&(o+="x"),o&&s.nodePermissions(r,o)?-2:0},doDup:function(e,n,r){var i=s.getStream(r);return i&&s.close(i),s.open(e,n,0,r,r).fd},doReadv:function(e,n,r,i){for(var o=0,l=0;l>2],c=k[n+(l*8+4)>>2],m=s.read(e,ee,u,c,i);if(m<0)return-1;if(o+=m,m>2],c=k[n+(l*8+4)>>2],m=s.write(e,ee,u,c,i);if(m<0)return-1;o+=m}return o},varargs:0,get:function(e){B.varargs+=4;var n=k[B.varargs-4>>2];return n},getStr:function(){var e=_e(B.get());return e},getStreamFromFD:function(e){e===void 0&&(e=B.get());var n=s.getStream(e);if(!n)throw new s.ErrnoError(8);return n},get64:function(){var e=B.get();return B.get(),e},getZero:function(){B.get()}};function Ti(e,n){B.varargs=n;try{var r=B.getStreamFromFD(),i=B.get();switch(i){case 0:{var o=B.get();if(o<0)return-28;var l;return l=s.open(r.path,r.flags,0,o),l.fd}case 1:case 2:return 0;case 3:return r.flags;case 4:{var o=B.get();return r.flags|=o,0}case 12:{var o=B.get(),u=0;return zn[o+u>>1]=2,0}case 13:case 14:return 0;case 16:case 8:return-28;case 9:return qe(28),-1;default:return-28}}catch(c){return(typeof s>"u"||!(c instanceof s.ErrnoError))&&ae(c),-c.errno}}function Si(e,n){B.varargs=n;try{var r=B.getStreamFromFD(),i=B.get(),o=B.get();return s.read(r,ee,i,o)}catch(l){return(typeof s>"u"||!(l instanceof s.ErrnoError))&&ae(l),-l.errno}}function Pi(e,n){B.varargs=n;try{var r=B.getStreamFromFD(),i=B.get(),o=B.get();return s.write(r,ee,i,o)}catch(l){return(typeof s>"u"||!(l instanceof s.ErrnoError))&&ae(l),-l.errno}}function Ai(e,n){B.varargs=n;try{var r=B.getStr(),i=B.get(),o=B.get(),l=s.open(r,i,o);return l.fd}catch(u){return(typeof s>"u"||!(u instanceof s.ErrnoError))&&ae(u),-u.errno}}function Ri(e,n){B.varargs=n;try{var r=B.getStreamFromFD(),i=B.get();switch(i){case 21509:case 21505:return r.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return r.tty?0:-59;case 21519:{if(!r.tty)return-59;var o=B.get();return k[o>>2]=0,0}case 21520:return r.tty?-28:-59;case 21531:{var o=B.get();return s.ioctl(r,i,o)}case 21523:return r.tty?0:-59;case 21524:return r.tty?0:-59;default:ae("bad ioctl syscall "+i)}}catch(l){return(typeof s>"u"||!(l instanceof s.ErrnoError))&&ae(l),-l.errno}}function Li(e,n){if(e===-1||n===0)return-28;var r=B.mappings[e];if(!r)return 0;if(n===r.len){var i=s.getStream(r.fd);B.doMsync(e,i,n,r.flags),s.munmap(i),B.mappings[e]=null,r.allocated&&Ce(r.malloc)}return 0}function Di(e,n){B.varargs=n;try{var r=B.get(),i=B.get();return Li(r,i)}catch(o){return(typeof s>"u"||!(o instanceof s.ErrnoError))&&ae(o),-o.errno}}function ki(){}var $n={};function rn(e){for(;e.length;){var n=e.pop(),r=e.pop();r(n)}}function an(e){return this.fromWireType(be[e>>2])}var on={},Ke={},Hn={},Ni=48,Fi=57;function Gn(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var n=e.charCodeAt(0);return n>=Ni&&n<=Fi?"_"+e:e}function At(e,n){return e=Gn(e),new Function("body","return function "+e+`() { diff --git a/index.js b/index.js index 778fbe6..162c707 100644 --- a/index.js +++ b/index.js @@ -3,3 +3,5 @@ import { WebAI, cv, ort } from './src/webai.mjs' window.WebAI = WebAI window.cv = cv window.ort = ort + +export { WebAI as default, WebAI, cv, ort} diff --git a/package.json b/package.json index f2c1fc4..700cec6 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "description": "A simple Web AI model deployment tool using JavaScript", "main": "./src/webai.mjs", "types": "./src/webai.d.ts", - "unpkg": "./dist/webai.min.js", - "jsdelivr": "./dist/webai.min.js", + "unpkg": "./dist/webai.min.mjs", + "jsdelivr": "./dist/webai.min.mjs", "scripts": { "dev": "vite", "build": "vite build", diff --git a/vite.config.js b/vite.config.js index 48f58c8..601301d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -6,7 +6,7 @@ export default { }, rollupOptions: { output: { - entryFileNames: `webai.min.js` + entryFileNames: `webai.min.mjs` } } }