diff --git "a/assets/index-BEaQOcTE.js" "b/assets/index-BEaQOcTE.js" new file mode 100644--- /dev/null +++ "b/assets/index-BEaQOcTE.js" @@ -0,0 +1,1790 @@ +import{c5 as getAugmentedNamespace}from"./index-PVyOT18Z.js";var dist={},ortWeb_min={exports:{}};const backends={},backendsSortedByPriority=[],registerBackend=(D,u,b)=>{if(u&&typeof u.init=="function"&&typeof u.createSessionHandler=="function"){const g=backends[D];if(g===void 0)backends[D]={backend:u,priority:b};else{if(g.priority>b)return;if(g.priority===b&&g.backend!==u)throw new Error(`cannot register backend "${D}" using priority ${b}`)}if(b>=0){const p=backendsSortedByPriority.indexOf(D);p!==-1&&backendsSortedByPriority.splice(p,1);for(let h=0;h{const u=D.length===0?backendsSortedByPriority:D,b=[];for(const g of u){const p=backends[g];if(p){if(p.initialized)return p.backend;if(p.aborted)continue;const h=!!p.initPromise;try{return h||(p.initPromise=p.backend.init()),await p.initPromise,p.initialized=!0,p.backend}catch(o){h||b.push({name:g,err:o}),p.aborted=!0}finally{delete p.initPromise}}}throw new Error(`no available backend found. ERR: ${b.map(g=>`[${g.name}] ${g.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(u){if(u!==void 0){if(typeof u!="string"||["verbose","info","warning","error","fatal"].indexOf(u)===-1)throw new Error(`Unsupported logging level: ${u}`);this.logLevelInternal=u}}get logLevel(){return this.logLevelInternal}}const env=new EnvImpl,isBigInt64ArrayAvailable=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",isBigUint64ArrayAvailable=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function",NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);isBigInt64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64"));isBigUint64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64"));const calculateSize=D=>{let u=1;for(let b=0;b{const t=document.createElement("canvas"),e=t.getContext("2d");if(!u||!e)return i();const n=new Image;n.crossOrigin="Anonymous",n.src=u,n.onload=()=>{t.width=n.width,t.height=n.height,e.drawImage(n,0,0,t.width,t.height);const r=e.getImageData(0,0,t.width,t.height);if(b!==void 0){if(b.height!==void 0&&b.height!==t.height)throw new Error("Image input config height doesn't match ImageBitmap height");if(f.height=t.height,b.width!==void 0&&b.width!==t.width)throw new Error("Image input config width doesn't match ImageBitmap width");f.width=t.width}else f.height=t.height,f.width=t.width;s(at.bufferToTensor(r.data,f))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(c!==void 0)return at.bufferToTensor(c,f);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(u){var b,g;const p=document.createElement("canvas").getContext("2d");let h;if(p!=null){const o=this.dims[3],c=this.dims[2],f=this.dims[1],s=u!==void 0&&u.format!==void 0?u.format:"RGB",i=u!==void 0&&((b=u.norm)===null||b===void 0?void 0:b.mean)!==void 0?u.norm.mean:255,t=u!==void 0&&((g=u.norm)===null||g===void 0?void 0:g.bias)!==void 0?u.norm.bias:0,e=c*o;if(u!==void 0){if(u.height!==void 0&&u.height!==c)throw new Error("Image output config height doesn't match tensor height");if(u.width!==void 0&&u.width!==o)throw new Error("Image output config width doesn't match tensor width");if(u.format!==void 0&&f===4&&u.format!=="RGBA"||f===3&&u.format!=="RGB"&&u.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const n=4;let r=0,a=1,l=2,d=3,m=0,y=e,v=e*2,_=-1;s==="RGBA"?(m=0,y=e,v=e*2,_=e*3):s==="RGB"?(m=0,y=e,v=e*2):s==="RBG"&&(m=0,v=e,y=e*2),h=p.createImageData(o,c);for(let T=0;T"u")throw new Error(`input '${s}' is missing in 'feeds'.`);if(o)for(const s of this.outputNames)p[s]=null;const c=await this.handler.run(u,p,h),f={};for(const s in c)Object.hasOwnProperty.call(c,s)&&(f[s]=new Tensor(c[s].type,c[s].data,c[s].dims));return f}static async create(u,b,g,p){let h,o={};if(typeof u=="string"){if(h=u,typeof b=="object"&&b!==null)o=b;else if(typeof b<"u")throw new TypeError("'options' must be an object.")}else if(u instanceof Uint8Array){if(h=u,typeof b=="object"&&b!==null)o=b;else if(typeof b<"u")throw new TypeError("'options' must be an object.")}else if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer){const t=u;let e=0,n=u.byteLength;if(typeof b=="object"&&b!==null)o=b;else if(typeof b=="number"){if(e=b,!Number.isSafeInteger(e))throw new RangeError("'byteOffset' must be an integer.");if(e<0||e>=t.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(n=u.byteLength-e,typeof g=="number"){if(n=g,!Number.isSafeInteger(n))throw new RangeError("'byteLength' must be an integer.");if(n<=0||e+n>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-e}].`);if(typeof p=="object"&&p!==null)o=p;else if(typeof p<"u")throw new TypeError("'options' must be an object.")}else if(typeof g<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof b<"u")throw new TypeError("'options' must be an object.");h=new Uint8Array(t,e,n)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const f=(o.executionProviders||[]).map(t=>typeof t=="string"?t:t.name),i=await(await resolveBackend(f)).createSessionHandler(h,o);return new cn(i)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const InferenceSession=InferenceSession$1,lib=Object.freeze(Object.defineProperty({__proto__:null,InferenceSession,Tensor,env,registerBackend},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(lib);/*! +* ONNX Runtime Web v1.14.0 +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. +*/var hasRequiredOrtWeb_min;function requireOrtWeb_min(){return hasRequiredOrtWeb_min||(hasRequiredOrtWeb_min=1,function(module,exports){(function(D,u){module.exports=u(require$$0)})(self,__WEBPACK_EXTERNAL_MODULE__1670__=>(()=>{var __webpack_modules__={3474:(D,u,b)=>{var g,p=(g=(g=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(h){function o(){return Y.buffer!=ne&&Ee(Y.buffer),me}function c(){return Y.buffer!=ne&&Ee(Y.buffer),Pe}function f(){return Y.buffer!=ne&&Ee(Y.buffer),Oe}function s(){return Y.buffer!=ne&&Ee(Y.buffer),le}function i(){return Y.buffer!=ne&&Ee(Y.buffer),xe}var t,e,n;h=h||{},t||(t=h!==void 0?h:{}),t.ready=new Promise(function(x,O){e=x,n=O});var r,a,l,d,m,y,v=Object.assign({},t),_="./this.program",T=(x,O)=>{throw O},S=typeof window=="object",A=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",I=t.ENVIRONMENT_IS_PTHREAD||!1,R="";function B(x){return t.locateFile?t.locateFile(x,R):R+x}if(w){let x;R=A?b(908).dirname(R)+"/":"//",y=()=>{m||(d=b(1384),m=b(908))},r=function(O,P){return y(),O=m.normalize(O),d.readFileSync(O,P?void 0:"utf8")},l=O=>((O=r(O,!0)).buffer||(O=new Uint8Array(O)),O),a=(O,P,F)=>{y(),O=m.normalize(O),d.readFile(O,function(L,z){L?F(L):P(z.buffer)})},1{if(ze())throw process.exitCode=O,P;P instanceof Ze||V("exiting due to exception: "+P),process.exit(O)},t.inspect=function(){return"[Emscripten Module object]"};try{x=b(9925)}catch(O){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),O}b.g.Worker=x.Worker}else(S||A)&&(A?R=self.location.href:typeof document<"u"&&document.currentScript&&(R=document.currentScript.src),g&&(R=g),R=R.indexOf("blob:")!==0?R.substr(0,R.replace(/[?#].*/,"").lastIndexOf("/")+1):"",w||(r=x=>{var O=new XMLHttpRequest;return O.open("GET",x,!1),O.send(null),O.responseText},A&&(l=x=>{var O=new XMLHttpRequest;return O.open("GET",x,!1),O.responseType="arraybuffer",O.send(null),new Uint8Array(O.response)}),a=(x,O,P)=>{var F=new XMLHttpRequest;F.open("GET",x,!0),F.responseType="arraybuffer",F.onload=()=>{F.status==200||F.status==0&&F.response?O(F.response):P()},F.onerror=P,F.send(null)}));w&&typeof performance>"u"&&(b.g.performance=b(6953).performance);var j=console.log.bind(console),N=console.warn.bind(console);w&&(y(),j=x=>d.writeSync(1,x+` +`),N=x=>d.writeSync(2,x+` +`));var W,k=t.print||j,V=t.printErr||N;Object.assign(t,v),v=null,t.thisProgram&&(_=t.thisProgram),t.quit&&(T=t.quit),t.wasmBinary&&(W=t.wasmBinary);var J=t.noExitRuntime||!1;typeof WebAssembly!="object"&&pe("no native wasm support detected");var Y,te,ne,me,Pe,Oe,le,xe,_e=!1,Ne=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function He(x,O,P){var F=(O>>>=0)+P;for(P=O;x[P]&&!(P>=F);)++P;if(16(L=(240&L)==224?(15&L)<<12|z<<6|K:(7&L)<<18|z<<12|K<<6|63&x[O++])?F+=String.fromCharCode(L):(L-=65536,F+=String.fromCharCode(55296|L>>10,56320|1023&L))}}else F+=String.fromCharCode(L)}return F}function Ae(x,O){return(x>>>=0)?He(c(),x,O):""}function Ce(x,O,P,F){if(!(0>>=0;F=P+F-1;for(var z=0;z=K&&(K=65536+((1023&K)<<10)|1023&x.charCodeAt(++z)),127>=K){if(P>=F)break;O[P++>>>0]=K}else{if(2047>=K){if(P+1>=F)break;O[P++>>>0]=192|K>>6}else{if(65535>=K){if(P+2>=F)break;O[P++>>>0]=224|K>>12}else{if(P+3>=F)break;O[P++>>>0]=240|K>>18,O[P++>>>0]=128|K>>12&63}O[P++>>>0]=128|K>>6&63}O[P++>>>0]=128|63&K}}return O[P>>>0]=0,P-L}function Fe(x){for(var O=0,P=0;P=F?O++:2047>=F?O+=2:55296<=F&&57343>=F?(O+=4,++P):O+=3}return O}function Ee(x){ne=x,t.HEAP8=me=new Int8Array(x),t.HEAP16=new Int16Array(x),t.HEAP32=Oe=new Int32Array(x),t.HEAPU8=Pe=new Uint8Array(x),t.HEAPU16=new Uint16Array(x),t.HEAPU32=le=new Uint32Array(x),t.HEAPF32=new Float32Array(x),t.HEAPF64=xe=new Float64Array(x)}I&&(ne=t.buffer);var we=t.INITIAL_MEMORY||16777216;if(I)Y=t.wasmMemory,ne=t.buffer;else if(t.wasmMemory)Y=t.wasmMemory;else if(!((Y=new WebAssembly.Memory({initial:we/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw V("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),w&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Y&&(ne=Y.buffer),we=ne.byteLength,Ee(ne);var je,Ue=[],Be=[],We=[],Ke=[];function ze(){return J||!1}function Ve(){var x=t.preRun.shift();Ue.unshift(x)}var Se,Me=0,Ye=null;function pe(x){throw I?postMessage({cmd:"onAbort",arg:x}):t.onAbort&&t.onAbort(x),V(x="Aborted("+x+")"),_e=!0,x=new WebAssembly.RuntimeError(x+". Build with -sASSERTIONS for more info."),n(x),x}function ft(){return Se.startsWith("data:application/octet-stream;base64,")}function st(){var x=Se;try{if(x==Se&&W)return new Uint8Array(W);if(l)return l(x);throw"both async and sync fetching of the wasm failed"}catch(O){pe(O)}}Se="ort-wasm-threaded.wasm",ft()||(Se=B(Se));var At={};function Ze(x){this.name="ExitStatus",this.message="Program terminated with exit("+x+")",this.status=x}function ut(x){(x=re.Vb[x])||pe(),re.mc(x)}function ct(x){var O=re.Cc();if(!O)return 6;re.ac.push(O),re.Vb[x.Ub]=O,O.Ub=x.Ub;var P={cmd:"run",start_routine:x.Ic,arg:x.zc,pthread_ptr:x.Ub};return O.$b=()=>{P.time=performance.now(),O.postMessage(P,x.Nc)},O.loaded&&(O.$b(),delete O.$b),0}function Re(x){if(I)return Z(1,1,x);ze()||(re.oc(),t.onExit&&t.onExit(x),_e=!0),T(x,new Ze(x))}function nt(x,O){if(!O&&I)throw It(x),"unwind";ze()||I||(Gt(),tt(We),zt(0),kt[1].length&&Ct(1,10),kt[2].length&&Ct(2,10),re.oc()),Re(x)}var re={Yb:[],ac:[],qc:[],Vb:{},fc:function(){I&&re.Ec()},Pc:function(){},Ec:function(){re.receiveObjectTransfer=re.Gc,re.threadInitTLS=re.pc,re.setExitStatus=re.nc,J=!1},nc:function(){},oc:function(){for(var x of Object.values(re.Vb))re.mc(x);for(x of re.Yb)x.terminate();re.Yb=[]},mc:function(x){var O=x.Ub;delete re.Vb[O],re.Yb.push(x),re.ac.splice(re.ac.indexOf(x),1),x.Ub=0,Nt(O)},Gc:function(){},pc:function(){re.qc.forEach(x=>x())},Fc:function(x,O){x.onmessage=P=>{var F=(P=P.data).cmd;if(x.Ub&&(re.Bc=x.Ub),P.targetThread&&P.targetThread!=Dt()){var L=re.Vb[P.Qc];L?L.postMessage(P,P.transferList):V('Internal error! Worker sent a message "'+F+'" to target pthread '+P.targetThread+", but that thread no longer exists!")}else F==="processProxyingQueue"?C(P.queue):F==="spawnThread"?ct(P):F==="cleanupThread"?ut(P.thread):F==="killThread"?(P=P.thread,F=re.Vb[P],delete re.Vb[P],F.terminate(),Nt(P),re.ac.splice(re.ac.indexOf(F),1),F.Ub=0):F==="cancelThread"?re.Vb[P.thread].postMessage({cmd:"cancel"}):F==="loaded"?(x.loaded=!0,O&&O(x),x.$b&&(x.$b(),delete x.$b)):F==="print"?k("Thread "+P.threadId+": "+P.text):F==="printErr"?V("Thread "+P.threadId+": "+P.text):F==="alert"?alert("Thread "+P.threadId+": "+P.text):P.target==="setimmediate"?x.postMessage(P):F==="onAbort"?t.onAbort&&t.onAbort(P.arg):F&&V("worker sent an unknown command "+F);re.Bc=void 0},x.onerror=P=>{throw V("worker sent an error! "+P.filename+":"+P.lineno+": "+P.message),P},w&&(x.on("message",function(P){x.onmessage({data:P})}),x.on("error",function(P){x.onerror(P)}),x.on("detachedExit",function(){})),x.postMessage({cmd:"load",urlOrBlob:t.mainScriptUrlOrBlob||g,wasmMemory:Y,wasmModule:te})},yc:function(){var x=B("ort-wasm-threaded.worker.js");re.Yb.push(new Worker(x))},Cc:function(){return re.Yb.length==0&&(re.yc(),re.Fc(re.Yb[0])),re.Yb.pop()}};function tt(x){for(;0>2>>>0];x=f()[x+48>>2>>>0],Xt(O,O-x),ue(O)};var Je=[];function ye(x){var O=Je[x];return O||(x>=Je.length&&(Je.length=x+1),Je[x]=O=je.get(x)),O}t.invokeEntryPoint=function(x,O){x=ye(x)(O),ze()?re.nc(x):Yt(x)};var rt,dt,it=[],ae=0,ie=0;function oe(x){this.Zb=x,this.Sb=x-24,this.xc=function(O){s()[this.Sb+4>>2>>>0]=O},this.bc=function(){return s()[this.Sb+4>>2>>>0]},this.wc=function(O){s()[this.Sb+8>>2>>>0]=O},this.Dc=function(){return s()[this.Sb+8>>2>>>0]},this.rc=function(){f()[this.Sb>>2>>>0]=0},this.hc=function(O){O=O?1:0,o()[this.Sb+12>>0>>>0]=O},this.uc=function(){return o()[this.Sb+12>>0>>>0]!=0},this.ic=function(O){O=O?1:0,o()[this.Sb+13>>0>>>0]=O},this.kc=function(){return o()[this.Sb+13>>0>>>0]!=0},this.fc=function(O,P){this.cc(0),this.xc(O),this.wc(P),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(f(),this.Sb>>2,1)},this.Hc=function(){return Atomics.sub(f(),this.Sb>>2,1)===1},this.cc=function(O){s()[this.Sb+16>>2>>>0]=O},this.tc=function(){return s()[this.Sb+16>>2>>>0]},this.vc=function(){if(Kt(this.bc()))return s()[this.Zb>>2>>>0];var O=this.tc();return O!==0?O:this.Zb}}function pt(x){return Bt(new oe(x).Sb)}function ot(x,O,P,F){return I?Z(3,1,x,O,P,F):ht(x,O,P,F)}function ht(x,O,P,F){if(typeof SharedArrayBuffer>"u")return V("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var L=[];return I&&L.length===0?ot(x,O,P,F):(x={Ic:P,Ub:x,zc:F,Nc:L},I?(x.Oc="spawnThread",postMessage(x,L),0):ct(x))}function gt(x,O,P){return I?Z(4,1,x,O,P):0}function mt(x,O){if(I)return Z(5,1,x,O)}function bt(x,O){if(I)return Z(6,1,x,O)}function yt(x,O,P){if(I)return Z(7,1,x,O,P)}function _t(x,O,P){return I?Z(8,1,x,O,P):0}function vt(x,O){if(I)return Z(9,1,x,O)}function wt(x,O,P){if(I)return Z(10,1,x,O,P)}function xt(x,O,P,F){if(I)return Z(11,1,x,O,P,F)}function Tt(x,O,P,F){if(I)return Z(12,1,x,O,P,F)}function St(x,O,P,F){if(I)return Z(13,1,x,O,P,F)}function Ot(x){if(I)return Z(14,1,x)}function E(x,O){if(I)return Z(15,1,x,O)}function $(x,O,P){if(I)return Z(16,1,x,O,P)}function C(x){Atomics.store(f(),x>>2,1),Dt()&&Wt(x),Atomics.compareExchange(f(),x>>2,1,0)}function M(x){return s()[x>>>2]+4294967296*f()[x+4>>>2]}function U(x,O,P,F,L,z){return I?Z(17,1,x,O,P,F,L,z):-52}function H(x,O,P,F,L,z){if(I)return Z(18,1,x,O,P,F,L,z)}function X(x){var O=Fe(x)+1,P=Rt(O);return P&&Ce(x,o(),P,O),P}function Q(x,O,P){function F(he){return(he=he.toTimeString().match(/\(([A-Za-z ]+)\)$/))?he[1]:"GMT"}if(I)return Z(19,1,x,O,P);var L=new Date().getFullYear(),z=new Date(L,0,1),K=new Date(L,6,1);L=z.getTimezoneOffset();var ee=K.getTimezoneOffset(),de=Math.max(L,ee);f()[x>>2>>>0]=60*de,f()[O>>2>>>0]=+(L!=ee),x=F(z),O=F(K),x=X(x),O=X(O),ee>2>>>0]=x,s()[P+4>>2>>>0]=O):(s()[P>>2>>>0]=O,s()[P+4>>2>>>0]=x)}function Z(x,O){var P=arguments.length-2,F=arguments;return Et(()=>{for(var L=Mt(8*P),z=L>>3,K=0;K>>0]=ee}return Ht(x,P,L,O)})}t.executeNotifiedProxyingQueue=C,dt=w?()=>{var x=process.hrtime();return 1e3*x[0]+x[1]/1e6}:I?()=>performance.now()-t.__performance_now_clock_drift:()=>performance.now();var se,ve=[],ke={};function $e(){if(!se){var x,O={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:_||"./this.program"};for(x in ke)ke[x]===void 0?delete O[x]:O[x]=ke[x];var P=[];for(x in O)P.push(x+"="+O[x]);se=P}return se}function G(x,O){if(I)return Z(20,1,x,O);var P=0;return $e().forEach(function(F,L){var z=O+P;for(L=s()[x+4*L>>2>>>0]=z,z=0;z>0>>>0]=F.charCodeAt(z);o()[L>>0>>>0]=0,P+=F.length+1}),0}function ge(x,O){if(I)return Z(21,1,x,O);var P=$e();s()[x>>2>>>0]=P.length;var F=0;return P.forEach(function(L){F+=L.length+1}),s()[O>>2>>>0]=F,0}function Te(x){return I?Z(22,1,x):52}function Ge(x,O,P,F){return I?Z(23,1,x,O,P,F):52}function Qe(x,O,P,F,L){return I?Z(24,1,x,O,P,F,L):70}var kt=[null,[],[]];function Ct(x,O){var P=kt[x];O===0||O===10?((x===1?k:V)(He(P,0)),P.length=0):P.push(O)}function Lt(x,O,P,F){if(I)return Z(25,1,x,O,P,F);for(var L=0,z=0;z>2>>>0],ee=s()[O+4>>2>>>0];O+=8;for(var de=0;de>>0]);L+=ee}return s()[F>>2>>>0]=L,0}var Le=0;function Pt(x){return x%4==0&&(x%100!=0||x%400==0)}var jt=[31,29,31,30,31,30,31,31,30,31,30,31],Vt=[31,28,31,30,31,30,31,31,30,31,30,31];function Ut(x,O,P,F){function L(q,be,Ie){for(q=typeof q=="number"?q.toString():q||"";q.lengthlt?-1:0et-q.getDate())){q.setDate(q.getDate()+be);break}be-=et-q.getDate()+1,q.setDate(1),11>Ie?q.setMonth(Ie+1):(q.setMonth(0),q.setFullYear(q.getFullYear()+1))}return Ie=new Date(q.getFullYear()+1,0,4),be=ee(new Date(q.getFullYear(),0,4)),Ie=ee(Ie),0>=K(be,q)?0>=K(Ie,q)?q.getFullYear()+1:q.getFullYear():q.getFullYear()-1}var he=f()[F+40>>2>>>0];for(var De in F={Lc:f()[F>>2>>>0],Kc:f()[F+4>>2>>>0],dc:f()[F+8>>2>>>0],jc:f()[F+12>>2>>>0],ec:f()[F+16>>2>>>0],Xb:f()[F+20>>2>>>0],Tb:f()[F+24>>2>>>0],Wb:f()[F+28>>2>>>0],Rc:f()[F+32>>2>>>0],Jc:f()[F+36>>2>>>0],Mc:he?Ae(he):""},P=Ae(P),he={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})P=P.replace(new RegExp(De,"g"),he[De]);var Xe="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),qe="January February March April May June July August September October November December".split(" ");for(De in he={"%a":function(q){return Xe[q.Tb].substring(0,3)},"%A":function(q){return Xe[q.Tb]},"%b":function(q){return qe[q.ec].substring(0,3)},"%B":function(q){return qe[q.ec]},"%C":function(q){return z((q.Xb+1900)/100|0,2)},"%d":function(q){return z(q.jc,2)},"%e":function(q){return L(q.jc,2," ")},"%g":function(q){return de(q).toString().substring(2)},"%G":function(q){return de(q)},"%H":function(q){return z(q.dc,2)},"%I":function(q){return(q=q.dc)==0?q=12:12q.dc?"AM":"PM"},"%S":function(q){return z(q.Lc,2)},"%t":function(){return" "},"%u":function(q){return q.Tb||7},"%U":function(q){return z(Math.floor((q.Wb+7-q.Tb)/7),2)},"%V":function(q){var be=Math.floor((q.Wb+7-(q.Tb+6)%7)/7);if(2>=(q.Tb+371-q.Wb-2)%7&&be++,be)be==53&&((Ie=(q.Tb+371-q.Wb)%7)==4||Ie==3&&Pt(q.Xb)||(be=1));else{be=52;var Ie=(q.Tb+7-q.Wb-1)%7;(Ie==4||Ie==5&&Pt(q.Xb%400-1))&&be++}return z(be,2)},"%w":function(q){return q.Tb},"%W":function(q){return z(Math.floor((q.Wb+7-(q.Tb+6)%7)/7),2)},"%y":function(q){return(q.Xb+1900).toString().substring(2)},"%Y":function(q){return q.Xb+1900},"%z":function(q){var be=0<=(q=q.Jc);return q=Math.abs(q)/60,(be?"+":"-")+("0000"+(q/60*100+q%60)).slice(-4)},"%Z":function(q){return q.Mc},"%%":function(){return"%"}},P=P.replace(/%%/g,"\0\0"),he)P.includes(De)&&(P=P.replace(new RegExp(De,"g"),he[De](F)));return De=function(q){var be=Array(Fe(q)+1);return Ce(q,be,0,be.length),be}(P=P.replace(/\0\0/g,"%")),De.length>O?0:(function(q,be){o().set(q,be>>>0)}(De,x),De.length-1)}re.fc();var ln=[null,Re,It,ot,gt,mt,bt,yt,_t,vt,wt,xt,Tt,St,Ot,E,$,U,H,Q,G,ge,Te,Ge,Qe,Lt],fn={b:function(x){return Rt(x+24)+24},n:function(x){return(x=new oe(x)).uc()||(x.hc(!0),ae--),x.ic(!1),it.push(x),x.sc(),x.vc()},ma:function(x){throw V("Unexpected exception thrown, this is not properly supported - aborting"),_e=!0,x},x:function(){fe(0);var x=it.pop();if(x.Hc()&&!x.kc()){var O=x.Dc();O&&ye(O)(x.Zb),pt(x.Zb)}ie=0},e:function(){var x=ie;if(!x)return Le=0;var O=new oe(x);O.cc(x);var P=O.bc();if(!P)return Le=0,x;for(var F=Array.prototype.slice.call(arguments),L=0;LC(F));else if(I)postMessage({targetThread:x,cmd:"processProxyingQueue",queue:F});else{if(!(x=re.Vb[x]))return;x.postMessage({cmd:"processProxyingQueue",queue:F})}return 1},Ea:function(){return-1},Pa:function(x,O){x=new Date(1e3*M(x)),f()[O>>2>>>0]=x.getUTCSeconds(),f()[O+4>>2>>>0]=x.getUTCMinutes(),f()[O+8>>2>>>0]=x.getUTCHours(),f()[O+12>>2>>>0]=x.getUTCDate(),f()[O+16>>2>>>0]=x.getUTCMonth(),f()[O+20>>2>>>0]=x.getUTCFullYear()-1900,f()[O+24>>2>>>0]=x.getUTCDay(),x=(x.getTime()-Date.UTC(x.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,f()[O+28>>2>>>0]=x},Qa:function(x,O){x=new Date(1e3*M(x)),f()[O>>2>>>0]=x.getSeconds(),f()[O+4>>2>>>0]=x.getMinutes(),f()[O+8>>2>>>0]=x.getHours(),f()[O+12>>2>>>0]=x.getDate(),f()[O+16>>2>>>0]=x.getMonth(),f()[O+20>>2>>>0]=x.getFullYear()-1900,f()[O+24>>2>>>0]=x.getDay();var P=new Date(x.getFullYear(),0,1),F=(x.getTime()-P.getTime())/864e5|0;f()[O+28>>2>>>0]=F,f()[O+36>>2>>>0]=-60*x.getTimezoneOffset(),F=new Date(x.getFullYear(),6,1).getTimezoneOffset(),x=0|(F!=(P=P.getTimezoneOffset())&&x.getTimezoneOffset()==Math.min(P,F)),f()[O+32>>2>>>0]=x},Ra:function(x){var O=new Date(f()[x+20>>2>>>0]+1900,f()[x+16>>2>>>0],f()[x+12>>2>>>0],f()[x+8>>2>>>0],f()[x+4>>2>>>0],f()[x>>2>>>0],0),P=f()[x+32>>2>>>0],F=O.getTimezoneOffset(),L=new Date(O.getFullYear(),0,1),z=new Date(O.getFullYear(),6,1).getTimezoneOffset(),K=L.getTimezoneOffset(),ee=Math.min(K,z);return 0>P?f()[x+32>>2>>>0]=+(z!=K&&ee==F):0>2>>>0]=O.getDay(),P=(O.getTime()-L.getTime())/864e5|0,f()[x+28>>2>>>0]=P,f()[x>>2>>>0]=O.getSeconds(),f()[x+4>>2>>>0]=O.getMinutes(),f()[x+8>>2>>>0]=O.getHours(),f()[x+12>>2>>>0]=O.getDate(),f()[x+16>>2>>>0]=O.getMonth(),O.getTime()/1e3|0},Aa:U,Ba:H,Sa:function x(O,P,F){x.Ac||(x.Ac=!0,Q(O,P,F))},y:function(){pe("")},U:function(){if(!w&&!A){var x="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";rt||(rt={}),rt[x]||(rt[x]=1,w&&(x="warning: "+x),V(x))}},ra:function(){return 4294901760},B:dt,Ia:function(x,O,P){c().copyWithin(x>>>0,O>>>0,O+P>>>0)},F:function(){return w?b(3993).cpus().length:navigator.hardwareConcurrency},Da:function(x,O,P){ve.length=O,P>>=3;for(var F=0;F>>0];return(0>x?At[-x-1]:ln[x]).apply(null,ve)},qa:function(x){var O=c().length;if((x>>>=0)<=O||4294901760=P;P*=2){var F=O*(1+.2/P);F=Math.min(F,x+100663296);var L=Math;F=Math.max(x,F),L=L.min.call(L,4294901760,F+(65536-F%65536)%65536);e:{try{Y.grow(L-ne.byteLength+65535>>>16),Ee(Y.buffer);var z=1;break e}catch{}z=void 0}if(z)return!0}return!1},Na:function(){throw"unwind"},Ga:G,Ha:ge,J:nt,I:Te,S:Ge,ga:Qe,R:Lt,d:function(){return Le},na:function x(O,P){x.lc||(x.lc=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var L=new Uint8Array(1);return()=>(crypto.getRandomValues(L),L[0])}if(w)try{var z=b(Object(function(){var K=new Error("Cannot find module 'crypto'");throw K.code="MODULE_NOT_FOUND",K}()));return()=>z.randomBytes(1)[0]}catch{}return()=>pe("randomDevice")}());for(var F=0;F>0>>>0]=x.lc();return 0},ia:function(x,O,P){var F=ce();try{return ye(x)(O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},ja:function(x,O,P){var F=ce();try{return ye(x)(O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},K:function(x){var O=ce();try{return ye(x)()}catch(P){if(ue(O),P!==P+0)throw P;fe(1,0)}},f:function(x,O){var P=ce();try{return ye(x)(O)}catch(F){if(ue(P),F!==F+0)throw F;fe(1,0)}},P:function(x,O,P){var F=ce();try{return ye(x)(O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},Q:function(x,O,P){var F=ce();try{return ye(x)(O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},k:function(x,O,P){var F=ce();try{return ye(x)(O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},p:function(x,O,P,F){var L=ce();try{return ye(x)(O,P,F)}catch(z){if(ue(L),z!==z+0)throw z;fe(1,0)}},q:function(x,O,P,F,L){var z=ce();try{return ye(x)(O,P,F,L)}catch(K){if(ue(z),K!==K+0)throw K;fe(1,0)}},N:function(x,O,P,F,L,z){var K=ce();try{return ye(x)(O,P,F,L,z)}catch(ee){if(ue(K),ee!==ee+0)throw ee;fe(1,0)}},s:function(x,O,P,F,L,z){var K=ce();try{return ye(x)(O,P,F,L,z)}catch(ee){if(ue(K),ee!==ee+0)throw ee;fe(1,0)}},w:function(x,O,P,F,L,z,K){var ee=ce();try{return ye(x)(O,P,F,L,z,K)}catch(de){if(ue(ee),de!==de+0)throw de;fe(1,0)}},L:function(x,O,P,F,L,z,K,ee){var de=ce();try{return ye(x)(O,P,F,L,z,K,ee)}catch(he){if(ue(de),he!==he+0)throw he;fe(1,0)}},E:function(x,O,P,F,L,z,K,ee,de,he,De,Xe){var qe=ce();try{return ye(x)(O,P,F,L,z,K,ee,de,he,De,Xe)}catch(q){if(ue(qe),q!==q+0)throw q;fe(1,0)}},aa:function(x,O,P,F,L,z,K,ee){var de=ce();try{return an(x,O,P,F,L,z,K,ee)}catch(he){if(ue(de),he!==he+0)throw he;fe(1,0)}},_:function(x,O,P,F,L,z,K){var ee=ce();try{return Jt(x,O,P,F,L,z,K)}catch(de){if(ue(ee),de!==de+0)throw de;fe(1,0)}},Z:function(x,O,P,F,L){var z=ce();try{return sn(x,O,P,F,L)}catch(K){if(ue(z),K!==K+0)throw K;fe(1,0)}},ca:function(x,O,P,F){var L=ce();try{return rn(x,O,P,F)}catch(z){if(ue(L),z!==z+0)throw z;fe(1,0)}},$:function(x){var O=ce();try{return Zt(x)}catch(P){if(ue(O),P!==P+0)throw P;fe(1,0)}},ba:function(x,O){var P=ce();try{return on(x,O)}catch(F){if(ue(P),F!==F+0)throw F;fe(1,0)}},Y:function(x,O,P){var F=ce();try{return Qt(x,O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},g:function(x){var O=ce();try{ye(x)()}catch(P){if(ue(O),P!==P+0)throw P;fe(1,0)}},r:function(x,O){var P=ce();try{ye(x)(O)}catch(F){if(ue(P),F!==F+0)throw F;fe(1,0)}},i:function(x,O,P){var F=ce();try{ye(x)(O,P)}catch(L){if(ue(F),L!==L+0)throw L;fe(1,0)}},ha:function(x,O,P,F){var L=ce();try{ye(x)(O,P,F)}catch(z){if(ue(L),z!==z+0)throw z;fe(1,0)}},m:function(x,O,P,F){var L=ce();try{ye(x)(O,P,F)}catch(z){if(ue(L),z!==z+0)throw z;fe(1,0)}},v:function(x,O,P,F,L){var z=ce();try{ye(x)(O,P,F,L)}catch(K){if(ue(z),K!==K+0)throw K;fe(1,0)}},u:function(x,O,P,F,L,z){var K=ce();try{ye(x)(O,P,F,L,z)}catch(ee){if(ue(K),ee!==ee+0)throw ee;fe(1,0)}},O:function(x,O,P,F,L,z,K){var ee=ce();try{ye(x)(O,P,F,L,z,K)}catch(de){if(ue(ee),de!==de+0)throw de;fe(1,0)}},A:function(x,O,P,F,L,z,K,ee){var de=ce();try{ye(x)(O,P,F,L,z,K,ee)}catch(he){if(ue(de),he!==he+0)throw he;fe(1,0)}},ka:function(x,O,P,F,L,z,K,ee,de){var he=ce();try{ye(x)(O,P,F,L,z,K,ee,de)}catch(De){if(ue(he),De!==De+0)throw De;fe(1,0)}},C:function(x,O,P,F,L,z,K,ee,de,he,De){var Xe=ce();try{ye(x)(O,P,F,L,z,K,ee,de,he,De)}catch(qe){if(ue(Xe),qe!==qe+0)throw qe;fe(1,0)}},D:function(x,O,P,F,L,z,K,ee,de,he,De,Xe,qe,q,be,Ie){var et=ce();try{ye(x)(O,P,F,L,z,K,ee,de,he,De,Xe,qe,q,be,Ie)}catch(lt){if(ue(et),lt!==lt+0)throw lt;fe(1,0)}},fa:function(x,O,P,F,L,z,K,ee){var de=ce();try{en(x,O,P,F,L,z,K,ee)}catch(he){if(ue(de),he!==he+0)throw he;fe(1,0)}},da:function(x,O,P,F,L,z,K,ee,de,he,De,Xe){var qe=ce();try{nn(x,O,P,F,L,z,K,ee,de,he,De,Xe)}catch(q){if(ue(qe),q!==q+0)throw q;fe(1,0)}},ea:function(x,O,P,F,L,z){var K=ce();try{tn(x,O,P,F,L,z)}catch(ee){if(ue(K),ee!==ee+0)throw ee;fe(1,0)}},o:function(x){return x},a:Y||t.wasmMemory,G:function(x){Le=x},la:Ut,z:function(x,O,P,F){return Ut(x,O,P,F)}};(function(){function x(L,z){t.asm=L.exports,re.qc.push(t.asm.sb),je=t.asm.ub,Be.unshift(t.asm.Va),te=z,I||(Me--,t.monitorRunDependencies&&t.monitorRunDependencies(Me),Me==0&&Ye&&(L=Ye,Ye=null,L()))}function O(L){x(L.instance,L.module)}function P(L){return function(){if(!W&&(S||A)){if(typeof fetch=="function"&&!Se.startsWith("file://"))return fetch(Se,{credentials:"same-origin"}).then(function(z){if(!z.ok)throw"failed to load wasm binary file at '"+Se+"'";return z.arrayBuffer()}).catch(function(){return st()});if(a)return new Promise(function(z,K){a(Se,function(ee){z(new Uint8Array(ee))},K)})}return Promise.resolve().then(function(){return st()})}().then(function(z){return WebAssembly.instantiate(z,F)}).then(function(z){return z}).then(L,function(z){V("failed to asynchronously prepare wasm: "+z),pe(z)})}var F={a:fn};if(I||(Me++,t.monitorRunDependencies&&t.monitorRunDependencies(Me)),t.instantiateWasm)try{return t.instantiateWasm(F,x)}catch(L){return V("Module.instantiateWasm callback failed with error: "+L),!1}(W||typeof WebAssembly.instantiateStreaming!="function"||ft()||Se.startsWith("file://")||w||typeof fetch!="function"?P(O):fetch(Se,{credentials:"same-origin"}).then(function(L){return WebAssembly.instantiateStreaming(L,F).then(O,function(z){return V("wasm streaming compile failed: "+z),V("falling back to ArrayBuffer instantiation"),P(O)})})).catch(n)})(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.Va).apply(null,arguments)},t._OrtInit=function(){return(t._OrtInit=t.asm.Wa).apply(null,arguments)},t._OrtCreateSessionOptions=function(){return(t._OrtCreateSessionOptions=t.asm.Xa).apply(null,arguments)},t._OrtAppendExecutionProvider=function(){return(t._OrtAppendExecutionProvider=t.asm.Ya).apply(null,arguments)},t._OrtAddSessionConfigEntry=function(){return(t._OrtAddSessionConfigEntry=t.asm.Za).apply(null,arguments)},t._OrtReleaseSessionOptions=function(){return(t._OrtReleaseSessionOptions=t.asm._a).apply(null,arguments)},t._OrtCreateSession=function(){return(t._OrtCreateSession=t.asm.$a).apply(null,arguments)},t._OrtReleaseSession=function(){return(t._OrtReleaseSession=t.asm.ab).apply(null,arguments)},t._OrtGetInputCount=function(){return(t._OrtGetInputCount=t.asm.bb).apply(null,arguments)},t._OrtGetOutputCount=function(){return(t._OrtGetOutputCount=t.asm.cb).apply(null,arguments)},t._OrtGetInputName=function(){return(t._OrtGetInputName=t.asm.db).apply(null,arguments)},t._OrtGetOutputName=function(){return(t._OrtGetOutputName=t.asm.eb).apply(null,arguments)},t._OrtFree=function(){return(t._OrtFree=t.asm.fb).apply(null,arguments)},t._OrtCreateTensor=function(){return(t._OrtCreateTensor=t.asm.gb).apply(null,arguments)},t._OrtGetTensorData=function(){return(t._OrtGetTensorData=t.asm.hb).apply(null,arguments)},t._OrtReleaseTensor=function(){return(t._OrtReleaseTensor=t.asm.ib).apply(null,arguments)},t._OrtCreateRunOptions=function(){return(t._OrtCreateRunOptions=t.asm.jb).apply(null,arguments)},t._OrtAddRunConfigEntry=function(){return(t._OrtAddRunConfigEntry=t.asm.kb).apply(null,arguments)},t._OrtReleaseRunOptions=function(){return(t._OrtReleaseRunOptions=t.asm.lb).apply(null,arguments)},t._OrtRun=function(){return(t._OrtRun=t.asm.mb).apply(null,arguments)},t._OrtEndProfiling=function(){return(t._OrtEndProfiling=t.asm.nb).apply(null,arguments)};var Dt=t._pthread_self=function(){return(Dt=t._pthread_self=t.asm.ob).apply(null,arguments)},Rt=t._malloc=function(){return(Rt=t._malloc=t.asm.pb).apply(null,arguments)},Bt=t._free=function(){return(Bt=t._free=t.asm.qb).apply(null,arguments)},zt=t._fflush=function(){return(zt=t._fflush=t.asm.rb).apply(null,arguments)};t.__emscripten_tls_init=function(){return(t.__emscripten_tls_init=t.asm.sb).apply(null,arguments)};var Gt=t.___funcs_on_exit=function(){return(Gt=t.___funcs_on_exit=t.asm.tb).apply(null,arguments)},qt=t.__emscripten_thread_init=function(){return(qt=t.__emscripten_thread_init=t.asm.vb).apply(null,arguments)};t.__emscripten_thread_crashed=function(){return(t.__emscripten_thread_crashed=t.asm.wb).apply(null,arguments)};var $t,Ht=t._emscripten_run_in_main_runtime_thread_js=function(){return(Ht=t._emscripten_run_in_main_runtime_thread_js=t.asm.xb).apply(null,arguments)},Wt=t.__emscripten_proxy_execute_task_queue=function(){return(Wt=t.__emscripten_proxy_execute_task_queue=t.asm.yb).apply(null,arguments)},Nt=t.__emscripten_thread_free_data=function(){return(Nt=t.__emscripten_thread_free_data=t.asm.zb).apply(null,arguments)},Yt=t.__emscripten_thread_exit=function(){return(Yt=t.__emscripten_thread_exit=t.asm.Ab).apply(null,arguments)},fe=t._setThrew=function(){return(fe=t._setThrew=t.asm.Bb).apply(null,arguments)},Xt=t._emscripten_stack_set_limits=function(){return(Xt=t._emscripten_stack_set_limits=t.asm.Cb).apply(null,arguments)},ce=t.stackSave=function(){return(ce=t.stackSave=t.asm.Db).apply(null,arguments)},ue=t.stackRestore=function(){return(ue=t.stackRestore=t.asm.Eb).apply(null,arguments)},Mt=t.stackAlloc=function(){return(Mt=t.stackAlloc=t.asm.Fb).apply(null,arguments)},Ft=t.___cxa_can_catch=function(){return(Ft=t.___cxa_can_catch=t.asm.Gb).apply(null,arguments)},Kt=t.___cxa_is_pointer_type=function(){return(Kt=t.___cxa_is_pointer_type=t.asm.Hb).apply(null,arguments)},Zt=t.dynCall_j=function(){return(Zt=t.dynCall_j=t.asm.Ib).apply(null,arguments)},Jt=t.dynCall_iiiiij=function(){return(Jt=t.dynCall_iiiiij=t.asm.Jb).apply(null,arguments)},Qt=t.dynCall_jii=function(){return(Qt=t.dynCall_jii=t.asm.Kb).apply(null,arguments)},en=t.dynCall_viiiiij=function(){return(en=t.dynCall_viiiiij=t.asm.Lb).apply(null,arguments)},tn=t.dynCall_vjji=function(){return(tn=t.dynCall_vjji=t.asm.Mb).apply(null,arguments)},nn=t.dynCall_viiijjjii=function(){return(nn=t.dynCall_viiijjjii=t.asm.Nb).apply(null,arguments)},rn=t.dynCall_iij=function(){return(rn=t.dynCall_iij=t.asm.Ob).apply(null,arguments)},on=t.dynCall_ji=function(){return(on=t.dynCall_ji=t.asm.Pb).apply(null,arguments)},an=t.dynCall_iiiiiij=function(){return(an=t.dynCall_iiiiiij=t.asm.Qb).apply(null,arguments)},sn=t.dynCall_iiij=function(){return(sn=t.dynCall_iiij=t.asm.Rb).apply(null,arguments)};function un(){function x(){if(!$t&&($t=!0,t.calledRun=!0,!_e)&&(I||tt(Be),e(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),!I)){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;){var O=t.postRun.shift();Ke.unshift(O)}tt(Ke)}}if(!(0{var g,p=(g=(g=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(h){var o,c,f;h=h||{},o||(o=h!==void 0?h:{}),o.ready=new Promise(function(E,$){c=E,f=$});var s,i,t,e,n,r,a=Object.assign({},o),l="./this.program",d=(E,$)=>{throw $},m=typeof window=="object",y=typeof importScripts=="function",v=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",_="";v?(_=y?b(908).dirname(_)+"/":"//",r=()=>{n||(e=b(1384),n=b(908))},s=function(E,$){return r(),E=n.normalize(E),e.readFileSync(E,$?void 0:"utf8")},t=E=>((E=s(E,!0)).buffer||(E=new Uint8Array(E)),E),i=(E,$,C)=>{r(),E=n.normalize(E),e.readFile(E,function(M,U){M?C(M):$(U.buffer)})},1{if(w||0{var $=new XMLHttpRequest;return $.open("GET",E,!1),$.send(null),$.responseText},y&&(t=E=>{var $=new XMLHttpRequest;return $.open("GET",E,!1),$.responseType="arraybuffer",$.send(null),new Uint8Array($.response)}),i=(E,$,C)=>{var M=new XMLHttpRequest;M.open("GET",E,!0),M.responseType="arraybuffer",M.onload=()=>{M.status==200||M.status==0&&M.response?$(M.response):C()},M.onerror=C,M.send(null)});var T,S=o.print||console.log.bind(console),A=o.printErr||console.warn.bind(console);Object.assign(o,a),a=null,o.thisProgram&&(l=o.thisProgram),o.quit&&(d=o.quit),o.wasmBinary&&(T=o.wasmBinary);var w=o.noExitRuntime||!1;typeof WebAssembly!="object"&&Ee("no native wasm support detected");var I,R,B,j,N,W,k=!1,V=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function J(E,$,C){var M=($>>>=0)+C;for(C=$;E[C]&&!(C>=M);)++C;if(16(U=(240&U)==224?(15&U)<<12|H<<6|X:(7&U)<<18|H<<12|X<<6|63&E[$++])?M+=String.fromCharCode(U):(U-=65536,M+=String.fromCharCode(55296|U>>10,56320|1023&U))}}else M+=String.fromCharCode(U)}return M}function Y(E,$){return(E>>>=0)?J(j,E,$):""}function te(E,$,C,M){if(!(0>>=0;M=C+M-1;for(var H=0;H=X&&(X=65536+((1023&X)<<10)|1023&E.charCodeAt(++H)),127>=X){if(C>=M)break;$[C++>>>0]=X}else{if(2047>=X){if(C+1>=M)break;$[C++>>>0]=192|X>>6}else{if(65535>=X){if(C+2>=M)break;$[C++>>>0]=224|X>>12}else{if(C+3>=M)break;$[C++>>>0]=240|X>>18,$[C++>>>0]=128|X>>12&63}$[C++>>>0]=128|X>>6&63}$[C++>>>0]=128|63&X}}return $[C>>>0]=0,C-U}function ne(E){for(var $=0,C=0;C=M?$++:2047>=M?$+=2:55296<=M&&57343>=M?($+=4,++C):$+=3}return $}function me(){var E=I.buffer;R=E,o.HEAP8=B=new Int8Array(E),o.HEAP16=new Int16Array(E),o.HEAP32=N=new Int32Array(E),o.HEAPU8=j=new Uint8Array(E),o.HEAPU16=new Uint16Array(E),o.HEAPU32=W=new Uint32Array(E),o.HEAPF32=new Float32Array(E),o.HEAPF64=new Float64Array(E)}var Pe,Oe=[],le=[],xe=[],_e=[],Ne=0;function He(){var E=o.preRun.shift();Oe.unshift(E)}var Ae,Ce=0,Fe=null;function Ee(E){throw o.onAbort&&o.onAbort(E),A(E="Aborted("+E+")"),k=!0,E=new WebAssembly.RuntimeError(E+". Build with -sASSERTIONS for more info."),f(E),E}function we(){return Ae.startsWith("data:application/octet-stream;base64,")}if(Ae="ort-wasm.wasm",!we()){var je=Ae;Ae=o.locateFile?o.locateFile(je,_):_+je}function Ue(){var E=Ae;try{if(E==Ae&&T)return new Uint8Array(T);if(t)return t(E);throw"both async and sync fetching of the wasm failed"}catch($){Ee($)}}function Be(E){this.name="ExitStatus",this.message="Program terminated with exit("+E+")",this.status=E}function We(E){for(;0>2>>>0]=$},this.Eb=function(){return W[this.zb+4>>2>>>0]},this.Sb=function($){W[this.zb+8>>2>>>0]=$},this.Wb=function(){return W[this.zb+8>>2>>>0]},this.Tb=function(){N[this.zb>>2>>>0]=0},this.Ib=function($){B[this.zb+12>>0>>>0]=$?1:0},this.Pb=function(){return B[this.zb+12>>0>>>0]!=0},this.Jb=function($){B[this.zb+13>>0>>>0]=$?1:0},this.Lb=function(){return B[this.zb+13>>0>>>0]!=0},this.Rb=function($,C){this.Fb(0),this.Ub($),this.Sb(C),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){N[this.zb>>2>>>0]+=1},this.Xb=function(){var $=N[this.zb>>2>>>0];return N[this.zb>>2>>>0]=$-1,$===1},this.Fb=function($){W[this.zb+16>>2>>>0]=$},this.Ob=function(){return W[this.zb+16>>2>>>0]},this.Qb=function(){if(ht(this.Eb()))return W[this.Db>>2>>>0];var $=this.Ob();return $!==0?$:this.Db}}function Me(E){return rt(new Se(E).zb)}var Ye=[];function pe(E){var $=Ye[E];return $||(E>=Ye.length&&(Ye.length=E+1),Ye[E]=$=Pe.get(E)),$}function ft(E){var $=ne(E)+1,C=ye($);return C&&te(E,B,C,$),C}var st={};function At(){if(!Ze){var E,$={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(E in st)st[E]===void 0?delete $[E]:$[E]=st[E];var C=[];for(E in $)C.push(E+"="+$[E]);Ze=C}return Ze}var Ze,ut=[null,[],[]];function ct(E,$){var C=ut[E];$===0||$===10?((E===1?S:A)(J(C,0)),C.length=0):C.push($)}var Re=0;function nt(E){return E%4==0&&(E%100!=0||E%400==0)}var re=[31,29,31,30,31,30,31,31,30,31,30,31],tt=[31,28,31,30,31,30,31,31,30,31,30,31];function Et(E,$,C,M){function U(G,ge,Te){for(G=typeof G=="number"?G.toString():G||"";G.lengthQe?-1:0Ge-G.getDate())){G.setDate(G.getDate()+ge);break}ge-=Ge-G.getDate()+1,G.setDate(1),11>Te?G.setMonth(Te+1):(G.setMonth(0),G.setFullYear(G.getFullYear()+1))}return Te=new Date(G.getFullYear()+1,0,4),ge=Q(new Date(G.getFullYear(),0,4)),Te=Q(Te),0>=X(ge,G)?0>=X(Te,G)?G.getFullYear()+1:G.getFullYear():G.getFullYear()-1}var se=N[M+40>>2>>>0];for(var ve in M={$b:N[M>>2>>>0],Zb:N[M+4>>2>>>0],Gb:N[M+8>>2>>>0],Kb:N[M+12>>2>>>0],Hb:N[M+16>>2>>>0],Cb:N[M+20>>2>>>0],Ab:N[M+24>>2>>>0],Bb:N[M+28>>2>>>0],bc:N[M+32>>2>>>0],Yb:N[M+36>>2>>>0],ac:se?Y(se):""},C=Y(C),se={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})C=C.replace(new RegExp(ve,"g"),se[ve]);var ke="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),$e="January February March April May June July August September October November December".split(" ");for(ve in se={"%a":function(G){return ke[G.Ab].substring(0,3)},"%A":function(G){return ke[G.Ab]},"%b":function(G){return $e[G.Hb].substring(0,3)},"%B":function(G){return $e[G.Hb]},"%C":function(G){return H((G.Cb+1900)/100|0,2)},"%d":function(G){return H(G.Kb,2)},"%e":function(G){return U(G.Kb,2," ")},"%g":function(G){return Z(G).toString().substring(2)},"%G":function(G){return Z(G)},"%H":function(G){return H(G.Gb,2)},"%I":function(G){return(G=G.Gb)==0?G=12:12G.Gb?"AM":"PM"},"%S":function(G){return H(G.$b,2)},"%t":function(){return" "},"%u":function(G){return G.Ab||7},"%U":function(G){return H(Math.floor((G.Bb+7-G.Ab)/7),2)},"%V":function(G){var ge=Math.floor((G.Bb+7-(G.Ab+6)%7)/7);if(2>=(G.Ab+371-G.Bb-2)%7&&ge++,ge)ge==53&&((Te=(G.Ab+371-G.Bb)%7)==4||Te==3&&nt(G.Cb)||(ge=1));else{ge=52;var Te=(G.Ab+7-G.Bb-1)%7;(Te==4||Te==5&&nt(G.Cb%400-1))&&ge++}return H(ge,2)},"%w":function(G){return G.Ab},"%W":function(G){return H(Math.floor((G.Bb+7-(G.Ab+6)%7)/7),2)},"%y":function(G){return(G.Cb+1900).toString().substring(2)},"%Y":function(G){return G.Cb+1900},"%z":function(G){var ge=0<=(G=G.Yb);return G=Math.abs(G)/60,(ge?"+":"-")+("0000"+(G/60*100+G%60)).slice(-4)},"%Z":function(G){return G.ac},"%%":function(){return"%"}},C=C.replace(/%%/g,"\0\0"),se)C.includes(ve)&&(C=C.replace(new RegExp(ve,"g"),se[ve](M)));return ve=function(G){var ge=Array(ne(G)+1);return te(G,ge,0,ge.length),ge}(C=C.replace(/\0\0/g,"%")),ve.length>$?0:(B.set(ve,E>>>0),ve.length-1)}var It={a:function(E){return ye(E+24)+24},m:function(E){return(E=new Se(E)).Pb()||(E.Ib(!0),ze--),E.Jb(!1),Ke.push(E),E.Nb(),E.Qb()},ia:function(E){throw A("Unexpected exception thrown, this is not properly supported - aborting"),k=!0,E},w:function(){ae(0);var E=Ke.pop();if(E.Xb()&&!E.Lb()){var $=E.Wb();$&&pe($)(E.Db),Me(E.Db)}Ve=0},d:function(){var E=Ve;if(!E)return Re=0;var $=new Se(E);$.Fb(E);var C=$.Eb();if(!C)return Re=0,E;for(var M=Array.prototype.slice.call(arguments),U=0;U>>2]+4294967296*N[E+4>>>2])),N[$>>2>>>0]=E.getUTCSeconds(),N[$+4>>2>>>0]=E.getUTCMinutes(),N[$+8>>2>>>0]=E.getUTCHours(),N[$+12>>2>>>0]=E.getUTCDate(),N[$+16>>2>>>0]=E.getUTCMonth(),N[$+20>>2>>>0]=E.getUTCFullYear()-1900,N[$+24>>2>>>0]=E.getUTCDay(),N[$+28>>2>>>0]=(E.getTime()-Date.UTC(E.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(E,$){E=new Date(1e3*(W[E>>>2]+4294967296*N[E+4>>>2])),N[$>>2>>>0]=E.getSeconds(),N[$+4>>2>>>0]=E.getMinutes(),N[$+8>>2>>>0]=E.getHours(),N[$+12>>2>>>0]=E.getDate(),N[$+16>>2>>>0]=E.getMonth(),N[$+20>>2>>>0]=E.getFullYear()-1900,N[$+24>>2>>>0]=E.getDay();var C=new Date(E.getFullYear(),0,1);N[$+28>>2>>>0]=(E.getTime()-C.getTime())/864e5|0,N[$+36>>2>>>0]=-60*E.getTimezoneOffset();var M=new Date(E.getFullYear(),6,1).getTimezoneOffset();C=C.getTimezoneOffset(),N[$+32>>2>>>0]=0|(M!=C&&E.getTimezoneOffset()==Math.min(C,M))},Fa:function(E){var $=new Date(N[E+20>>2>>>0]+1900,N[E+16>>2>>>0],N[E+12>>2>>>0],N[E+8>>2>>>0],N[E+4>>2>>>0],N[E>>2>>>0],0),C=N[E+32>>2>>>0],M=$.getTimezoneOffset(),U=new Date($.getFullYear(),0,1),H=new Date($.getFullYear(),6,1).getTimezoneOffset(),X=U.getTimezoneOffset(),Q=Math.min(X,H);return 0>C?N[E+32>>2>>>0]=+(H!=X&&Q==M):0>2>>>0]=$.getDay(),N[E+28>>2>>>0]=($.getTime()-U.getTime())/864e5|0,N[E>>2>>>0]=$.getSeconds(),N[E+4>>2>>>0]=$.getMinutes(),N[E+8>>2>>>0]=$.getHours(),N[E+12>>2>>>0]=$.getDate(),N[E+16>>2>>>0]=$.getMonth(),$.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function E($,C,M){E.Vb||(E.Vb=!0,function(U,H,X){function Q($e){return($e=$e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?$e[1]:"GMT"}var Z=new Date().getFullYear(),se=new Date(Z,0,1),ve=new Date(Z,6,1);Z=se.getTimezoneOffset();var ke=ve.getTimezoneOffset();N[U>>2>>>0]=60*Math.max(Z,ke),N[H>>2>>>0]=+(Z!=ke),U=Q(se),H=Q(ve),U=ft(U),H=ft(H),ke>2>>>0]=U,W[X+4>>2>>>0]=H):(W[X>>2>>>0]=H,W[X+4>>2>>>0]=U)}($,C,M))},B:function(){Ee("")},ma:function(){return 4294901760},I:v?()=>{var E=process.hrtime();return 1e3*E[0]+E[1]/1e6}:()=>performance.now(),xa:function(E,$,C){j.copyWithin(E>>>0,$>>>0,$+C>>>0)},G:function(E){var $=j.length;if(4294901760<(E>>>=0))return!1;for(var C=1;4>=C;C*=2){var M=$*(1+.2/C);M=Math.min(M,E+100663296);var U=Math;M=Math.max(E,M),U=U.min.call(U,4294901760,M+(65536-M%65536)%65536);e:{try{I.grow(U-R.byteLength+65535>>>16),me();var H=1;break e}catch{}H=void 0}if(H)return!0}return!1},va:function(E,$){var C=0;return At().forEach(function(M,U){var H=$+C;for(U=W[E+4*U>>2>>>0]=H,H=0;H>0>>>0]=M.charCodeAt(H);B[U>>0>>>0]=0,C+=M.length+1}),0},wa:function(E,$){var C=At();W[E>>2>>>0]=C.length;var M=0;return C.forEach(function(U){M+=U.length+1}),W[$>>2>>>0]=M,0},ba:function(E){w||0>2>>>0],Q=W[$+4>>2>>>0];$+=8;for(var Z=0;Z>>0]);U+=Q}return W[M>>2>>>0]=U,0},c:function(){return Re},ja:function E($,C){E.Mb||(E.Mb=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var U=new Uint8Array(1);return()=>(crypto.getRandomValues(U),U[0])}if(v)try{var H=b(Object(function(){var X=new Error("Cannot find module 'crypto'");throw X.code="MODULE_NOT_FOUND",X}()));return()=>H.randomBytes(1)[0]}catch{}return()=>Ee("randomDevice")}());for(var M=0;M>0>>>0]=E.Mb();return 0},ea:function(E,$,C){var M=ie();try{return pe(E)($,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},fa:function(E,$,C){var M=ie();try{return pe(E)($,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},J:function(E){var $=ie();try{return pe(E)()}catch(C){if(oe($),C!==C+0)throw C;ae(1,0)}},e:function(E,$){var C=ie();try{return pe(E)($)}catch(M){if(oe(C),M!==M+0)throw M;ae(1,0)}},N:function(E,$,C){var M=ie();try{return pe(E)($,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},O:function(E,$,C){var M=ie();try{return pe(E)($,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},j:function(E,$,C){var M=ie();try{return pe(E)($,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},o:function(E,$,C,M){var U=ie();try{return pe(E)($,C,M)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},p:function(E,$,C,M,U){var H=ie();try{return pe(E)($,C,M,U)}catch(X){if(oe(H),X!==X+0)throw X;ae(1,0)}},M:function(E,$,C,M,U,H){var X=ie();try{return pe(E)($,C,M,U,H)}catch(Q){if(oe(X),Q!==Q+0)throw Q;ae(1,0)}},r:function(E,$,C,M,U,H){var X=ie();try{return pe(E)($,C,M,U,H)}catch(Q){if(oe(X),Q!==Q+0)throw Q;ae(1,0)}},v:function(E,$,C,M,U,H,X){var Q=ie();try{return pe(E)($,C,M,U,H,X)}catch(Z){if(oe(Q),Z!==Z+0)throw Z;ae(1,0)}},K:function(E,$,C,M,U,H,X,Q){var Z=ie();try{return pe(E)($,C,M,U,H,X,Q)}catch(se){if(oe(Z),se!==se+0)throw se;ae(1,0)}},D:function(E,$,C,M,U,H,X,Q,Z,se,ve,ke){var $e=ie();try{return pe(E)($,C,M,U,H,X,Q,Z,se,ve,ke)}catch(G){if(oe($e),G!==G+0)throw G;ae(1,0)}},X:function(E,$,C,M,U,H,X,Q){var Z=ie();try{return Tt(E,$,C,M,U,H,X,Q)}catch(se){if(oe(Z),se!==se+0)throw se;ae(1,0)}},V:function(E,$,C,M,U,H,X){var Q=ie();try{return mt(E,$,C,M,U,H,X)}catch(Z){if(oe(Q),Z!==Z+0)throw Z;ae(1,0)}},U:function(E,$,C,M,U){var H=ie();try{return St(E,$,C,M,U)}catch(X){if(oe(H),X!==X+0)throw X;ae(1,0)}},Z:function(E,$,C,M){var U=ie();try{return wt(E,$,C,M)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},W:function(E){var $=ie();try{return gt(E)}catch(C){if(oe($),C!==C+0)throw C;ae(1,0)}},Y:function(E,$){var C=ie();try{return xt(E,$)}catch(M){if(oe(C),M!==M+0)throw M;ae(1,0)}},T:function(E,$,C){var M=ie();try{return bt(E,$,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},f:function(E){var $=ie();try{pe(E)()}catch(C){if(oe($),C!==C+0)throw C;ae(1,0)}},q:function(E,$){var C=ie();try{pe(E)($)}catch(M){if(oe(C),M!==M+0)throw M;ae(1,0)}},h:function(E,$,C){var M=ie();try{pe(E)($,C)}catch(U){if(oe(M),U!==U+0)throw U;ae(1,0)}},da:function(E,$,C,M){var U=ie();try{pe(E)($,C,M)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},l:function(E,$,C,M){var U=ie();try{pe(E)($,C,M)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},t:function(E,$,C,M,U){var H=ie();try{pe(E)($,C,M,U)}catch(X){if(oe(H),X!==X+0)throw X;ae(1,0)}},u:function(E,$,C,M,U,H){var X=ie();try{pe(E)($,C,M,U,H)}catch(Q){if(oe(X),Q!==Q+0)throw Q;ae(1,0)}},x:function(E,$,C,M,U,H,X){var Q=ie();try{pe(E)($,C,M,U,H,X)}catch(Z){if(oe(Q),Z!==Z+0)throw Z;ae(1,0)}},z:function(E,$,C,M,U,H,X,Q){var Z=ie();try{pe(E)($,C,M,U,H,X,Q)}catch(se){if(oe(Z),se!==se+0)throw se;ae(1,0)}},ga:function(E,$,C,M,U,H,X,Q,Z){var se=ie();try{pe(E)($,C,M,U,H,X,Q,Z)}catch(ve){if(oe(se),ve!==ve+0)throw ve;ae(1,0)}},A:function(E,$,C,M,U,H,X,Q,Z,se,ve){var ke=ie();try{pe(E)($,C,M,U,H,X,Q,Z,se,ve)}catch($e){if(oe(ke),$e!==$e+0)throw $e;ae(1,0)}},C:function(E,$,C,M,U,H,X,Q,Z,se,ve,ke,$e,G,ge,Te){var Ge=ie();try{pe(E)($,C,M,U,H,X,Q,Z,se,ve,ke,$e,G,ge,Te)}catch(Qe){if(oe(Ge),Qe!==Qe+0)throw Qe;ae(1,0)}},aa:function(E,$,C,M,U,H,X,Q){var Z=ie();try{yt(E,$,C,M,U,H,X,Q)}catch(se){if(oe(Z),se!==se+0)throw se;ae(1,0)}},_:function(E,$,C,M,U,H,X,Q,Z,se,ve,ke){var $e=ie();try{vt(E,$,C,M,U,H,X,Q,Z,se,ve,ke)}catch(G){if(oe($e),G!==G+0)throw G;ae(1,0)}},$:function(E,$,C,M,U,H){var X=ie();try{_t(E,$,C,M,U,H)}catch(Q){if(oe(X),Q!==Q+0)throw Q;ae(1,0)}},n:function(E){return E},F:function(E){Re=E},ha:Et,y:function(E,$,C,M){return Et(E,$,C,M)}};(function(){function E(U){o.asm=U.exports,I=o.asm.Ka,me(),Pe=o.asm.ib,le.unshift(o.asm.La),Ce--,o.monitorRunDependencies&&o.monitorRunDependencies(Ce),Ce==0&&Fe&&(U=Fe,Fe=null,U())}function $(U){E(U.instance)}function C(U){return function(){if(!T&&(m||y)){if(typeof fetch=="function"&&!Ae.startsWith("file://"))return fetch(Ae,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+Ae+"'";return H.arrayBuffer()}).catch(function(){return Ue()});if(i)return new Promise(function(H,X){i(Ae,function(Q){H(new Uint8Array(Q))},X)})}return Promise.resolve().then(function(){return Ue()})}().then(function(H){return WebAssembly.instantiate(H,M)}).then(function(H){return H}).then(U,function(H){A("failed to asynchronously prepare wasm: "+H),Ee(H)})}var M={a:It};if(Ce++,o.monitorRunDependencies&&o.monitorRunDependencies(Ce),o.instantiateWasm)try{return o.instantiateWasm(M,E)}catch(U){return A("Module.instantiateWasm callback failed with error: "+U),!1}(T||typeof WebAssembly.instantiateStreaming!="function"||we()||Ae.startsWith("file://")||v||typeof fetch!="function"?C($):fetch(Ae,{credentials:"same-origin"}).then(function(U){return WebAssembly.instantiateStreaming(U,M).then($,function(H){return A("wasm streaming compile failed: "+H),A("falling back to ArrayBuffer instantiation"),C($)})})).catch(f)})(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.La).apply(null,arguments)},o._OrtInit=function(){return(o._OrtInit=o.asm.Ma).apply(null,arguments)},o._OrtCreateSessionOptions=function(){return(o._OrtCreateSessionOptions=o.asm.Na).apply(null,arguments)},o._OrtAppendExecutionProvider=function(){return(o._OrtAppendExecutionProvider=o.asm.Oa).apply(null,arguments)},o._OrtAddSessionConfigEntry=function(){return(o._OrtAddSessionConfigEntry=o.asm.Pa).apply(null,arguments)},o._OrtReleaseSessionOptions=function(){return(o._OrtReleaseSessionOptions=o.asm.Qa).apply(null,arguments)},o._OrtCreateSession=function(){return(o._OrtCreateSession=o.asm.Ra).apply(null,arguments)},o._OrtReleaseSession=function(){return(o._OrtReleaseSession=o.asm.Sa).apply(null,arguments)},o._OrtGetInputCount=function(){return(o._OrtGetInputCount=o.asm.Ta).apply(null,arguments)},o._OrtGetOutputCount=function(){return(o._OrtGetOutputCount=o.asm.Ua).apply(null,arguments)},o._OrtGetInputName=function(){return(o._OrtGetInputName=o.asm.Va).apply(null,arguments)},o._OrtGetOutputName=function(){return(o._OrtGetOutputName=o.asm.Wa).apply(null,arguments)},o._OrtFree=function(){return(o._OrtFree=o.asm.Xa).apply(null,arguments)},o._OrtCreateTensor=function(){return(o._OrtCreateTensor=o.asm.Ya).apply(null,arguments)},o._OrtGetTensorData=function(){return(o._OrtGetTensorData=o.asm.Za).apply(null,arguments)},o._OrtReleaseTensor=function(){return(o._OrtReleaseTensor=o.asm._a).apply(null,arguments)},o._OrtCreateRunOptions=function(){return(o._OrtCreateRunOptions=o.asm.$a).apply(null,arguments)},o._OrtAddRunConfigEntry=function(){return(o._OrtAddRunConfigEntry=o.asm.ab).apply(null,arguments)},o._OrtReleaseRunOptions=function(){return(o._OrtReleaseRunOptions=o.asm.bb).apply(null,arguments)},o._OrtRun=function(){return(o._OrtRun=o.asm.cb).apply(null,arguments)},o._OrtEndProfiling=function(){return(o._OrtEndProfiling=o.asm.db).apply(null,arguments)};var Je,ye=o._malloc=function(){return(ye=o._malloc=o.asm.eb).apply(null,arguments)},rt=o._free=function(){return(rt=o._free=o.asm.fb).apply(null,arguments)},dt=o._fflush=function(){return(dt=o._fflush=o.asm.gb).apply(null,arguments)},it=o.___funcs_on_exit=function(){return(it=o.___funcs_on_exit=o.asm.hb).apply(null,arguments)},ae=o._setThrew=function(){return(ae=o._setThrew=o.asm.jb).apply(null,arguments)},ie=o.stackSave=function(){return(ie=o.stackSave=o.asm.kb).apply(null,arguments)},oe=o.stackRestore=function(){return(oe=o.stackRestore=o.asm.lb).apply(null,arguments)},pt=o.stackAlloc=function(){return(pt=o.stackAlloc=o.asm.mb).apply(null,arguments)},ot=o.___cxa_can_catch=function(){return(ot=o.___cxa_can_catch=o.asm.nb).apply(null,arguments)},ht=o.___cxa_is_pointer_type=function(){return(ht=o.___cxa_is_pointer_type=o.asm.ob).apply(null,arguments)},gt=o.dynCall_j=function(){return(gt=o.dynCall_j=o.asm.pb).apply(null,arguments)},mt=o.dynCall_iiiiij=function(){return(mt=o.dynCall_iiiiij=o.asm.qb).apply(null,arguments)},bt=o.dynCall_jii=function(){return(bt=o.dynCall_jii=o.asm.rb).apply(null,arguments)},yt=o.dynCall_viiiiij=function(){return(yt=o.dynCall_viiiiij=o.asm.sb).apply(null,arguments)},_t=o.dynCall_vjji=function(){return(_t=o.dynCall_vjji=o.asm.tb).apply(null,arguments)},vt=o.dynCall_viiijjjii=function(){return(vt=o.dynCall_viiijjjii=o.asm.ub).apply(null,arguments)},wt=o.dynCall_iij=function(){return(wt=o.dynCall_iij=o.asm.vb).apply(null,arguments)},xt=o.dynCall_ji=function(){return(xt=o.dynCall_ji=o.asm.wb).apply(null,arguments)},Tt=o.dynCall_iiiiiij=function(){return(Tt=o.dynCall_iiiiiij=o.asm.xb).apply(null,arguments)},St=o.dynCall_iiij=function(){return(St=o.dynCall_iiij=o.asm.yb).apply(null,arguments)};function Ot(){function E(){if(!Je&&(Je=!0,o.calledRun=!0,!k)){if(We(le),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var $=o.postRun.shift();_e.unshift($)}We(_e)}}if(!(0{D.exports=function(u,b){for(var g=new Array(arguments.length-1),p=0,h=2,o=!0;h{var b=u;b.length=function(c){var f=c.length;if(!f)return 0;for(var s=0;--f%4>1&&c.charAt(f)==="=";)++s;return Math.ceil(3*c.length)/4-s};for(var g=new Array(64),p=new Array(123),h=0;h<64;)p[g[h]=h<26?h+65:h<52?h+71:h<62?h-4:h-59|43]=h++;b.encode=function(c,f,s){for(var i,t=null,e=[],n=0,r=0;f>2],i=(3&a)<<4,r=1;break;case 1:e[n++]=g[i|a>>4],i=(15&a)<<2,r=2;break;case 2:e[n++]=g[i|a>>6],e[n++]=g[63&a],r=0}n>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,e)),n=0)}return r&&(e[n++]=g[i],e[n++]=61,r===1&&(e[n++]=61)),t?(n&&t.push(String.fromCharCode.apply(String,e.slice(0,n))),t.join("")):String.fromCharCode.apply(String,e.slice(0,n))};var o="invalid encoding";b.decode=function(c,f,s){for(var i,t=s,e=0,n=0;n1)break;if((r=p[r])===void 0)throw Error(o);switch(e){case 0:i=r,e=1;break;case 1:f[s++]=i<<2|(48&r)>>4,i=r,e=2;break;case 2:f[s++]=(15&i)<<4|(60&r)>>2,i=r,e=3;break;case 3:f[s++]=(3&i)<<6|r,e=0}}if(e===1)throw Error(o);return s-t},b.test=function(c){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c)}},9211:D=>{function u(){this._listeners={}}D.exports=u,u.prototype.on=function(b,g,p){return(this._listeners[b]||(this._listeners[b]=[])).push({fn:g,ctx:p||this}),this},u.prototype.off=function(b,g){if(b===void 0)this._listeners={};else if(g===void 0)this._listeners[b]=[];else for(var p=this._listeners[b],h=0;h{function u(o){return typeof Float32Array<"u"?function(){var c=new Float32Array([-0]),f=new Uint8Array(c.buffer),s=f[3]===128;function i(r,a,l){c[0]=r,a[l]=f[0],a[l+1]=f[1],a[l+2]=f[2],a[l+3]=f[3]}function t(r,a,l){c[0]=r,a[l]=f[3],a[l+1]=f[2],a[l+2]=f[1],a[l+3]=f[0]}function e(r,a){return f[0]=r[a],f[1]=r[a+1],f[2]=r[a+2],f[3]=r[a+3],c[0]}function n(r,a){return f[3]=r[a],f[2]=r[a+1],f[1]=r[a+2],f[0]=r[a+3],c[0]}o.writeFloatLE=s?i:t,o.writeFloatBE=s?t:i,o.readFloatLE=s?e:n,o.readFloatBE=s?n:e}():function(){function c(s,i,t,e){var n=i<0?1:0;if(n&&(i=-i),i===0)s(1/i>0?0:2147483648,t,e);else if(isNaN(i))s(2143289344,t,e);else if(i>34028234663852886e22)s((n<<31|2139095040)>>>0,t,e);else if(i<11754943508222875e-54)s((n<<31|Math.round(i/1401298464324817e-60))>>>0,t,e);else{var r=Math.floor(Math.log(i)/Math.LN2);s((n<<31|r+127<<23|8388607&Math.round(i*Math.pow(2,-r)*8388608))>>>0,t,e)}}function f(s,i,t){var e=s(i,t),n=2*(e>>31)+1,r=e>>>23&255,a=8388607&e;return r===255?a?NaN:n*(1/0):r===0?1401298464324817e-60*n*a:n*Math.pow(2,r-150)*(a+8388608)}o.writeFloatLE=c.bind(null,b),o.writeFloatBE=c.bind(null,g),o.readFloatLE=f.bind(null,p),o.readFloatBE=f.bind(null,h)}(),typeof Float64Array<"u"?function(){var c=new Float64Array([-0]),f=new Uint8Array(c.buffer),s=f[7]===128;function i(r,a,l){c[0]=r,a[l]=f[0],a[l+1]=f[1],a[l+2]=f[2],a[l+3]=f[3],a[l+4]=f[4],a[l+5]=f[5],a[l+6]=f[6],a[l+7]=f[7]}function t(r,a,l){c[0]=r,a[l]=f[7],a[l+1]=f[6],a[l+2]=f[5],a[l+3]=f[4],a[l+4]=f[3],a[l+5]=f[2],a[l+6]=f[1],a[l+7]=f[0]}function e(r,a){return f[0]=r[a],f[1]=r[a+1],f[2]=r[a+2],f[3]=r[a+3],f[4]=r[a+4],f[5]=r[a+5],f[6]=r[a+6],f[7]=r[a+7],c[0]}function n(r,a){return f[7]=r[a],f[6]=r[a+1],f[5]=r[a+2],f[4]=r[a+3],f[3]=r[a+4],f[2]=r[a+5],f[1]=r[a+6],f[0]=r[a+7],c[0]}o.writeDoubleLE=s?i:t,o.writeDoubleBE=s?t:i,o.readDoubleLE=s?e:n,o.readDoubleBE=s?n:e}():function(){function c(s,i,t,e,n,r){var a=e<0?1:0;if(a&&(e=-e),e===0)s(0,n,r+i),s(1/e>0?0:2147483648,n,r+t);else if(isNaN(e))s(0,n,r+i),s(2146959360,n,r+t);else if(e>17976931348623157e292)s(0,n,r+i),s((a<<31|2146435072)>>>0,n,r+t);else{var l;if(e<22250738585072014e-324)s((l=e/5e-324)>>>0,n,r+i),s((a<<31|l/4294967296)>>>0,n,r+t);else{var d=Math.floor(Math.log(e)/Math.LN2);d===1024&&(d=1023),s(4503599627370496*(l=e*Math.pow(2,-d))>>>0,n,r+i),s((a<<31|d+1023<<20|1048576*l&1048575)>>>0,n,r+t)}}}function f(s,i,t,e,n){var r=s(e,n+i),a=s(e,n+t),l=2*(a>>31)+1,d=a>>>20&2047,m=4294967296*(1048575&a)+r;return d===2047?m?NaN:l*(1/0):d===0?5e-324*l*m:l*Math.pow(2,d-1075)*(m+4503599627370496)}o.writeDoubleLE=c.bind(null,b,0,4),o.writeDoubleBE=c.bind(null,g,4,0),o.readDoubleLE=f.bind(null,p,0,4),o.readDoubleBE=f.bind(null,h,4,0)}(),o}function b(o,c,f){c[f]=255&o,c[f+1]=o>>>8&255,c[f+2]=o>>>16&255,c[f+3]=o>>>24}function g(o,c,f){c[f]=o>>>24,c[f+1]=o>>>16&255,c[f+2]=o>>>8&255,c[f+3]=255&o}function p(o,c){return(o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24)>>>0}function h(o,c){return(o[c]<<24|o[c+1]<<16|o[c+2]<<8|o[c+3])>>>0}D.exports=u(u)},7199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(D){}return null}module.exports=inquire},6662:D=>{D.exports=function(u,b,g){var p=g||8192,h=p>>>1,o=null,c=p;return function(f){if(f<1||f>h)return u(f);c+f>p&&(o=u(p),c=0);var s=b.call(o,c,c+=f);return 7&c&&(c=1+(7|c)),s}}},4997:(D,u)=>{var b=u;b.length=function(g){for(var p=0,h=0,o=0;o191&&o<224?f[s++]=(31&o)<<6|63&g[p++]:o>239&&o<365?(o=((7&o)<<18|(63&g[p++])<<12|(63&g[p++])<<6|63&g[p++])-65536,f[s++]=55296+(o>>10),f[s++]=56320+(1023&o)):f[s++]=(15&o)<<12|(63&g[p++])<<6|63&g[p++],s>8191&&((c||(c=[])).push(String.fromCharCode.apply(String,f)),s=0);return c?(s&&c.push(String.fromCharCode.apply(String,f.slice(0,s))),c.join("")):String.fromCharCode.apply(String,f.slice(0,s))},b.write=function(g,p,h){for(var o,c,f=h,s=0;s>6|192,p[h++]=63&o|128):(64512&o)==55296&&(64512&(c=g.charCodeAt(s+1)))==56320?(o=65536+((1023&o)<<10)+(1023&c),++s,p[h++]=o>>18|240,p[h++]=o>>12&63|128,p[h++]=o>>6&63|128,p[h++]=63&o|128):(p[h++]=o>>12|224,p[h++]=o>>6&63|128,p[h++]=63&o|128);return h-f}},3442:(D,u)=>{u.__esModule=!0;var b=function(){function g(p){if(!p)throw new TypeError("Invalid argument; `value` has no value.");this.value=g.EMPTY,p&&g.isGuid(p)&&(this.value=p)}return g.isGuid=function(p){var h=p.toString();return p&&(p instanceof g||g.validator.test(h))},g.create=function(){return new g([g.gen(2),g.gen(1),g.gen(1),g.gen(1),g.gen(3)].join("-"))},g.createEmpty=function(){return new g("emptyguid")},g.parse=function(p){return new g(p)},g.raw=function(){return[g.gen(2),g.gen(1),g.gen(1),g.gen(1),g.gen(3)].join("-")},g.gen=function(p){for(var h="",o=0;o{D.exports=b;var u=null;try{u=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function b(w,I,R){this.low=0|w,this.high=0|I,this.unsigned=!!R}function g(w){return(w&&w.__isLong__)===!0}b.prototype.__isLong__,Object.defineProperty(b.prototype,"__isLong__",{value:!0}),b.isLong=g;var p={},h={};function o(w,I){var R,B,j;return I?(j=0<=(w>>>=0)&&w<256)&&(B=h[w])?B:(R=f(w,(0|w)<0?-1:0,!0),j&&(h[w]=R),R):(j=-128<=(w|=0)&&w<128)&&(B=p[w])?B:(R=f(w,w<0?-1:0,!1),j&&(p[w]=R),R)}function c(w,I){if(isNaN(w))return I?d:l;if(I){if(w<0)return d;if(w>=n)return T}else{if(w<=-9223372036854776e3)return S;if(w+1>=r)return _}return w<0?c(-w,I).neg():f(w%e|0,w/e|0,I)}function f(w,I,R){return new b(w,I,R)}b.fromInt=o,b.fromNumber=c,b.fromBits=f;var s=Math.pow;function i(w,I,R){if(w.length===0)throw Error("empty string");if(w==="NaN"||w==="Infinity"||w==="+Infinity"||w==="-Infinity")return l;if(typeof I=="number"?(R=I,I=!1):I=!!I,(R=R||10)<2||360)throw Error("interior hyphen");if(B===0)return i(w.substring(1),I,R).neg();for(var j=c(s(R,8)),N=l,W=0;W>>0:this.low},A.toNumber=function(){return this.unsigned?(this.high>>>0)*e+(this.low>>>0):this.high*e+(this.low>>>0)},A.toString=function(w){if((w=w||10)<2||36>>0).toString(w);if((N=k).isZero())return V+W;for(;V.length<6;)V="0"+V;W=""+V+W}},A.getHighBits=function(){return this.high},A.getHighBitsUnsigned=function(){return this.high>>>0},A.getLowBits=function(){return this.low},A.getLowBitsUnsigned=function(){return this.low>>>0},A.getNumBitsAbs=function(){if(this.isNegative())return this.eq(S)?64:this.neg().getNumBitsAbs();for(var w=this.high!=0?this.high:this.low,I=31;I>0&&(w&1<=0},A.isOdd=function(){return(1&this.low)==1},A.isEven=function(){return(1&this.low)==0},A.equals=function(w){return g(w)||(w=t(w)),(this.unsigned===w.unsigned||this.high>>>31!=1||w.high>>>31!=1)&&this.high===w.high&&this.low===w.low},A.eq=A.equals,A.notEquals=function(w){return!this.eq(w)},A.neq=A.notEquals,A.ne=A.notEquals,A.lessThan=function(w){return this.comp(w)<0},A.lt=A.lessThan,A.lessThanOrEqual=function(w){return this.comp(w)<=0},A.lte=A.lessThanOrEqual,A.le=A.lessThanOrEqual,A.greaterThan=function(w){return this.comp(w)>0},A.gt=A.greaterThan,A.greaterThanOrEqual=function(w){return this.comp(w)>=0},A.gte=A.greaterThanOrEqual,A.ge=A.greaterThanOrEqual,A.compare=function(w){if(g(w)||(w=t(w)),this.eq(w))return 0;var I=this.isNegative(),R=w.isNegative();return I&&!R?-1:!I&&R?1:this.unsigned?w.high>>>0>this.high>>>0||w.high===this.high&&w.low>>>0>this.low>>>0?-1:1:this.sub(w).isNegative()?-1:1},A.comp=A.compare,A.negate=function(){return!this.unsigned&&this.eq(S)?S:this.not().add(m)},A.neg=A.negate,A.add=function(w){g(w)||(w=t(w));var I=this.high>>>16,R=65535&this.high,B=this.low>>>16,j=65535&this.low,N=w.high>>>16,W=65535&w.high,k=w.low>>>16,V=0,J=0,Y=0,te=0;return Y+=(te+=j+(65535&w.low))>>>16,J+=(Y+=B+k)>>>16,V+=(J+=R+W)>>>16,V+=I+N,f((Y&=65535)<<16|(te&=65535),(V&=65535)<<16|(J&=65535),this.unsigned)},A.subtract=function(w){return g(w)||(w=t(w)),this.add(w.neg())},A.sub=A.subtract,A.multiply=function(w){if(this.isZero())return l;if(g(w)||(w=t(w)),u)return f(u.mul(this.low,this.high,w.low,w.high),u.get_high(),this.unsigned);if(w.isZero())return l;if(this.eq(S))return w.isOdd()?S:l;if(w.eq(S))return this.isOdd()?S:l;if(this.isNegative())return w.isNegative()?this.neg().mul(w.neg()):this.neg().mul(w).neg();if(w.isNegative())return this.mul(w.neg()).neg();if(this.lt(a)&&w.lt(a))return c(this.toNumber()*w.toNumber(),this.unsigned);var I=this.high>>>16,R=65535&this.high,B=this.low>>>16,j=65535&this.low,N=w.high>>>16,W=65535&w.high,k=w.low>>>16,V=65535&w.low,J=0,Y=0,te=0,ne=0;return te+=(ne+=j*V)>>>16,Y+=(te+=B*V)>>>16,te&=65535,Y+=(te+=j*k)>>>16,J+=(Y+=R*V)>>>16,Y&=65535,J+=(Y+=B*k)>>>16,Y&=65535,J+=(Y+=j*W)>>>16,J+=I*V+R*k+B*W+j*N,f((te&=65535)<<16|(ne&=65535),(J&=65535)<<16|(Y&=65535),this.unsigned)},A.mul=A.multiply,A.divide=function(w){if(g(w)||(w=t(w)),w.isZero())throw Error("division by zero");var I,R,B;if(u)return this.unsigned||this.high!==-2147483648||w.low!==-1||w.high!==-1?f((this.unsigned?u.div_u:u.div_s)(this.low,this.high,w.low,w.high),u.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?d:l;if(this.unsigned){if(w.unsigned||(w=w.toUnsigned()),w.gt(this))return d;if(w.gt(this.shru(1)))return y;B=d}else{if(this.eq(S))return w.eq(m)||w.eq(v)?S:w.eq(S)?m:(I=this.shr(1).div(w).shl(1)).eq(l)?w.isNegative()?m:v:(R=this.sub(w.mul(I)),B=I.add(R.div(w)));if(w.eq(S))return this.unsigned?d:l;if(this.isNegative())return w.isNegative()?this.neg().div(w.neg()):this.neg().div(w).neg();if(w.isNegative())return this.div(w.neg()).neg();B=l}for(R=this;R.gte(w);){I=Math.max(1,Math.floor(R.toNumber()/w.toNumber()));for(var j=Math.ceil(Math.log(I)/Math.LN2),N=j<=48?1:s(2,j-48),W=c(I),k=W.mul(w);k.isNegative()||k.gt(R);)k=(W=c(I-=N,this.unsigned)).mul(w);W.isZero()&&(W=m),B=B.add(W),R=R.sub(k)}return B},A.div=A.divide,A.modulo=function(w){return g(w)||(w=t(w)),u?f((this.unsigned?u.rem_u:u.rem_s)(this.low,this.high,w.low,w.high),u.get_high(),this.unsigned):this.sub(this.div(w).mul(w))},A.mod=A.modulo,A.rem=A.modulo,A.not=function(){return f(~this.low,~this.high,this.unsigned)},A.and=function(w){return g(w)||(w=t(w)),f(this.low&w.low,this.high&w.high,this.unsigned)},A.or=function(w){return g(w)||(w=t(w)),f(this.low|w.low,this.high|w.high,this.unsigned)},A.xor=function(w){return g(w)||(w=t(w)),f(this.low^w.low,this.high^w.high,this.unsigned)},A.shiftLeft=function(w){return g(w)&&(w=w.toInt()),(w&=63)==0?this:w<32?f(this.low<>>32-w,this.unsigned):f(0,this.low<>>w|this.high<<32-w,this.high>>w,this.unsigned):f(this.high>>w-32,this.high>=0?0:-1,this.unsigned)},A.shr=A.shiftRight,A.shiftRightUnsigned=function(w){if(g(w)&&(w=w.toInt()),(w&=63)==0)return this;var I=this.high;return w<32?f(this.low>>>w|I<<32-w,I>>>w,this.unsigned):f(w===32?I:I>>>w-32,0,this.unsigned)},A.shru=A.shiftRightUnsigned,A.shr_u=A.shiftRightUnsigned,A.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},A.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},A.toBytes=function(w){return w?this.toBytesLE():this.toBytesBE()},A.toBytesLE=function(){var w=this.high,I=this.low;return[255&I,I>>>8&255,I>>>16&255,I>>>24,255&w,w>>>8&255,w>>>16&255,w>>>24]},A.toBytesBE=function(){var w=this.high,I=this.low;return[w>>>24,w>>>16&255,w>>>8&255,255&w,I>>>24,I>>>16&255,I>>>8&255,255&I]},b.fromBytes=function(w,I,R){return R?b.fromBytesLE(w,I):b.fromBytesBE(w,I)},b.fromBytesLE=function(w,I){return new b(w[0]|w[1]<<8|w[2]<<16|w[3]<<24,w[4]|w[5]<<8|w[6]<<16|w[7]<<24,I)},b.fromBytesBE=function(w,I){return new b(w[4]<<24|w[5]<<16|w[6]<<8|w[7],w[0]<<24|w[1]<<16|w[2]<<8|w[3],I)}},1446:(D,u,b)=>{var g,p,h,o=b(2100),c=o.Reader,f=o.Writer,s=o.util,i=o.roots.default||(o.roots.default={});i.onnx=((h={}).Version=(g={},(p=Object.create(g))[g[0]="_START_VERSION"]=0,p[g[1]="IR_VERSION_2017_10_10"]=1,p[g[2]="IR_VERSION_2017_10_30"]=2,p[g[3]="IR_VERSION_2017_11_3"]=3,p[g[4]="IR_VERSION_2019_1_22"]=4,p[g[5]="IR_VERSION"]=5,p),h.AttributeProto=function(){function t(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],e)for(var n=Object.keys(e),r=0;r>>3){case 1:a.name=e.string();break;case 21:a.refAttrName=e.string();break;case 13:a.docString=e.string();break;case 20:a.type=e.int32();break;case 2:a.f=e.float();break;case 3:a.i=e.int64();break;case 4:a.s=e.bytes();break;case 5:a.t=i.onnx.TensorProto.decode(e,e.uint32());break;case 6:a.g=i.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(a.floats&&a.floats.length||(a.floats=[]),(7&l)==2)for(var d=e.uint32()+e.pos;e.pos>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?s.base64.decode(e.s,n.s=s.newBuffer(s.base64.length(e.s)),0):e.s.length&&(n.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");n.t=i.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");n.g=i.onnx.GraphProto.fromObject(e.g)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");n.floats=[];for(var r=0;r>>0,e.ints[r].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(n.strings=[],r=0;r>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(r.s=n.bytes===String?s.base64.encode(e.s,0,e.s.length):n.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(r.t=i.onnx.TensorProto.toObject(e.t,n)),e.g!=null&&e.hasOwnProperty("g")&&(r.g=i.onnx.GraphProto.toObject(e.g,n)),e.floats&&e.floats.length){r.floats=[];for(var l=0;l>>0,e.ints[l].high>>>0).toNumber():e.ints[l];if(e.strings&&e.strings.length)for(r.strings=[],l=0;l>>3){case 1:a.name=e.string();break;case 2:a.type=i.onnx.TypeProto.decode(e,e.uint32());break;case 3:a.docString=e.string();break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!s.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var n=i.onnx.TypeProto.verify(e.type);if(n)return"type."+n}return e.docString!=null&&e.hasOwnProperty("docString")&&!s.isString(e.docString)?"docString: string expected":null},t.fromObject=function(e){if(e instanceof i.onnx.ValueInfoProto)return e;var n=new i.onnx.ValueInfoProto;if(e.name!=null&&(n.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");n.type=i.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(n.docString=String(e.docString)),n},t.toObject=function(e,n){n||(n={});var r={};return n.defaults&&(r.name="",r.type=null,r.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(r.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(r.type=i.onnx.TypeProto.toObject(e.type,n)),e.docString!=null&&e.hasOwnProperty("docString")&&(r.docString=e.docString),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},t}(),h.NodeProto=function(){function t(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var n=Object.keys(e),r=0;r>>3){case 1:a.input&&a.input.length||(a.input=[]),a.input.push(e.string());break;case 2:a.output&&a.output.length||(a.output=[]),a.output.push(e.string());break;case 3:a.name=e.string();break;case 4:a.opType=e.string();break;case 7:a.domain=e.string();break;case 5:a.attribute&&a.attribute.length||(a.attribute=[]),a.attribute.push(i.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:a.docString=e.string();break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var n=0;n>>3){case 1:a.irVersion=e.int64();break;case 8:a.opsetImport&&a.opsetImport.length||(a.opsetImport=[]),a.opsetImport.push(i.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:a.producerName=e.string();break;case 3:a.producerVersion=e.string();break;case 4:a.domain=e.string();break;case 5:a.modelVersion=e.int64();break;case 6:a.docString=e.string();break;case 7:a.graph=i.onnx.GraphProto.decode(e,e.uint32());break;case 14:a.metadataProps&&a.metadataProps.length||(a.metadataProps=[]),a.metadataProps.push(i.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!(s.isInteger(e.irVersion)||e.irVersion&&s.isInteger(e.irVersion.low)&&s.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(e.opsetImport!=null&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var n=0;n>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");n.opsetImport=[];for(var r=0;r>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(n.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");n.graph=i.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(n.metadataProps=[],r=0;r>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(r.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(r.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(r.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?r.modelVersion=n.longs===String?String(e.modelVersion):e.modelVersion:r.modelVersion=n.longs===String?s.Long.prototype.toString.call(e.modelVersion):n.longs===Number?new s.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(r.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(r.graph=i.onnx.GraphProto.toObject(e.graph,n)),e.opsetImport&&e.opsetImport.length){r.opsetImport=[];for(var l=0;l>>3){case 1:a.key=e.string();break;case 2:a.value=e.string();break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!s.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!s.isString(e.value)?"value: string expected":null},t.fromObject=function(e){if(e instanceof i.onnx.StringStringEntryProto)return e;var n=new i.onnx.StringStringEntryProto;return e.key!=null&&(n.key=String(e.key)),e.value!=null&&(n.value=String(e.value)),n},t.toObject=function(e,n){n||(n={});var r={};return n.defaults&&(r.key="",r.value=""),e.key!=null&&e.hasOwnProperty("key")&&(r.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(r.value=e.value),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},t}(),h.TensorAnnotation=function(){function t(e){if(this.quantParameterTensorNames=[],e)for(var n=Object.keys(e),r=0;r>>3){case 1:a.tensorName=e.string();break;case 2:a.quantParameterTensorNames&&a.quantParameterTensorNames.length||(a.quantParameterTensorNames=[]),a.quantParameterTensorNames.push(i.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!s.isString(e.tensorName))return"tensorName: string expected";if(e.quantParameterTensorNames!=null&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var n=0;n>>3){case 1:a.node&&a.node.length||(a.node=[]),a.node.push(i.onnx.NodeProto.decode(e,e.uint32()));break;case 2:a.name=e.string();break;case 5:a.initializer&&a.initializer.length||(a.initializer=[]),a.initializer.push(i.onnx.TensorProto.decode(e,e.uint32()));break;case 10:a.docString=e.string();break;case 11:a.input&&a.input.length||(a.input=[]),a.input.push(i.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:a.output&&a.output.length||(a.output=[]),a.output.push(i.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:a.valueInfo&&a.valueInfo.length||(a.valueInfo=[]),a.valueInfo.push(i.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:a.quantizationAnnotation&&a.quantizationAnnotation.length||(a.quantizationAnnotation=[]),a.quantizationAnnotation.push(i.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var n=0;n>>3){case 1:if(a.dims&&a.dims.length||(a.dims=[]),(7&l)==2)for(var d=e.uint32()+e.pos;e.pos>>0,e.dims[r].high>>>0).toNumber())}if(e.dataType!=null&&(n.dataType=0|e.dataType),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");n.segment=i.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(n.floatData=[],r=0;r>>0,e.int64Data[r].high>>>0).toNumber())}if(e.name!=null&&(n.name=String(e.name)),e.docString!=null&&(n.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?s.base64.decode(e.rawData,n.rawData=s.newBuffer(s.base64.length(e.rawData)),0):e.rawData.length&&(n.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(n.externalData=[],r=0;r>>0,e.uint64Data[r].high>>>0).toNumber(!0))}return n},t.toObject=function(e,n){n||(n={});var r={};if((n.arrays||n.defaults)&&(r.dims=[],r.floatData=[],r.int32Data=[],r.stringData=[],r.int64Data=[],r.doubleData=[],r.uint64Data=[],r.externalData=[]),n.defaults&&(r.dataType=0,r.segment=null,r.name="",n.bytes===String?r.rawData="":(r.rawData=[],n.bytes!==Array&&(r.rawData=s.newBuffer(r.rawData))),r.docString="",r.dataLocation=n.enums===String?"DEFAULT":0),e.dims&&e.dims.length){r.dims=[];for(var a=0;a>>0,e.dims[a].high>>>0).toNumber():e.dims[a]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(r.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(r.segment=i.onnx.TensorProto.Segment.toObject(e.segment,n)),e.floatData&&e.floatData.length)for(r.floatData=[],a=0;a>>0,e.int64Data[a].high>>>0).toNumber():e.int64Data[a];if(e.name!=null&&e.hasOwnProperty("name")&&(r.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(r.rawData=n.bytes===String?s.base64.encode(e.rawData,0,e.rawData.length):n.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(r.doubleData=[],a=0;a>>0,e.uint64Data[a].high>>>0).toNumber(!0):e.uint64Data[a];if(e.docString!=null&&e.hasOwnProperty("docString")&&(r.docString=e.docString),e.externalData&&e.externalData.length)for(r.externalData=[],a=0;a>>3){case 1:l.begin=n.int64();break;case 2:l.end=n.int64();break;default:n.skipType(7&d)}}return l},e.decodeDelimited=function(n){return n instanceof c||(n=new c(n)),this.decode(n,n.uint32())},e.verify=function(n){return typeof n!="object"||n===null?"object expected":n.begin!=null&&n.hasOwnProperty("begin")&&!(s.isInteger(n.begin)||n.begin&&s.isInteger(n.begin.low)&&s.isInteger(n.begin.high))?"begin: integer|Long expected":n.end!=null&&n.hasOwnProperty("end")&&!(s.isInteger(n.end)||n.end&&s.isInteger(n.end.low)&&s.isInteger(n.end.high))?"end: integer|Long expected":null},e.fromObject=function(n){if(n instanceof i.onnx.TensorProto.Segment)return n;var r=new i.onnx.TensorProto.Segment;return n.begin!=null&&(s.Long?(r.begin=s.Long.fromValue(n.begin)).unsigned=!1:typeof n.begin=="string"?r.begin=parseInt(n.begin,10):typeof n.begin=="number"?r.begin=n.begin:typeof n.begin=="object"&&(r.begin=new s.LongBits(n.begin.low>>>0,n.begin.high>>>0).toNumber())),n.end!=null&&(s.Long?(r.end=s.Long.fromValue(n.end)).unsigned=!1:typeof n.end=="string"?r.end=parseInt(n.end,10):typeof n.end=="number"?r.end=n.end:typeof n.end=="object"&&(r.end=new s.LongBits(n.end.low>>>0,n.end.high>>>0).toNumber())),r},e.toObject=function(n,r){r||(r={});var a={};if(r.defaults){if(s.Long){var l=new s.Long(0,0,!1);a.begin=r.longs===String?l.toString():r.longs===Number?l.toNumber():l}else a.begin=r.longs===String?"0":0;s.Long?(l=new s.Long(0,0,!1),a.end=r.longs===String?l.toString():r.longs===Number?l.toNumber():l):a.end=r.longs===String?"0":0}return n.begin!=null&&n.hasOwnProperty("begin")&&(typeof n.begin=="number"?a.begin=r.longs===String?String(n.begin):n.begin:a.begin=r.longs===String?s.Long.prototype.toString.call(n.begin):r.longs===Number?new s.LongBits(n.begin.low>>>0,n.begin.high>>>0).toNumber():n.begin),n.end!=null&&n.hasOwnProperty("end")&&(typeof n.end=="number"?a.end=r.longs===String?String(n.end):n.end:a.end=r.longs===String?s.Long.prototype.toString.call(n.end):r.longs===Number?new s.LongBits(n.end.low>>>0,n.end.high>>>0).toNumber():n.end),a},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e}(),t.DataLocation=function(){var e={},n=Object.create(e);return n[e[0]="DEFAULT"]=0,n[e[1]="EXTERNAL"]=1,n}(),t}(),h.TensorShapeProto=function(){function t(e){if(this.dim=[],e)for(var n=Object.keys(e),r=0;r>>3==1?(a.dim&&a.dim.length||(a.dim=[]),a.dim.push(i.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&l)}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dim!=null&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var n=0;n>>3){case 1:d.dimValue=r.int64();break;case 2:d.dimParam=r.string();break;case 3:d.denotation=r.string();break;default:r.skipType(7&m)}}return d},e.decodeDelimited=function(r){return r instanceof c||(r=new c(r)),this.decode(r,r.uint32())},e.verify=function(r){if(typeof r!="object"||r===null)return"object expected";var a={};if(r.dimValue!=null&&r.hasOwnProperty("dimValue")&&(a.value=1,!(s.isInteger(r.dimValue)||r.dimValue&&s.isInteger(r.dimValue.low)&&s.isInteger(r.dimValue.high))))return"dimValue: integer|Long expected";if(r.dimParam!=null&&r.hasOwnProperty("dimParam")){if(a.value===1)return"value: multiple values";if(a.value=1,!s.isString(r.dimParam))return"dimParam: string expected"}return r.denotation!=null&&r.hasOwnProperty("denotation")&&!s.isString(r.denotation)?"denotation: string expected":null},e.fromObject=function(r){if(r instanceof i.onnx.TensorShapeProto.Dimension)return r;var a=new i.onnx.TensorShapeProto.Dimension;return r.dimValue!=null&&(s.Long?(a.dimValue=s.Long.fromValue(r.dimValue)).unsigned=!1:typeof r.dimValue=="string"?a.dimValue=parseInt(r.dimValue,10):typeof r.dimValue=="number"?a.dimValue=r.dimValue:typeof r.dimValue=="object"&&(a.dimValue=new s.LongBits(r.dimValue.low>>>0,r.dimValue.high>>>0).toNumber())),r.dimParam!=null&&(a.dimParam=String(r.dimParam)),r.denotation!=null&&(a.denotation=String(r.denotation)),a},e.toObject=function(r,a){a||(a={});var l={};return a.defaults&&(l.denotation=""),r.dimValue!=null&&r.hasOwnProperty("dimValue")&&(typeof r.dimValue=="number"?l.dimValue=a.longs===String?String(r.dimValue):r.dimValue:l.dimValue=a.longs===String?s.Long.prototype.toString.call(r.dimValue):a.longs===Number?new s.LongBits(r.dimValue.low>>>0,r.dimValue.high>>>0).toNumber():r.dimValue,a.oneofs&&(l.value="dimValue")),r.dimParam!=null&&r.hasOwnProperty("dimParam")&&(l.dimParam=r.dimParam,a.oneofs&&(l.value="dimParam")),r.denotation!=null&&r.hasOwnProperty("denotation")&&(l.denotation=r.denotation),l},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e}(),t}(),h.TypeProto=function(){function t(n){if(n)for(var r=Object.keys(n),a=0;a>>3){case 1:l.tensorType=i.onnx.TypeProto.Tensor.decode(n,n.uint32());break;case 6:l.denotation=n.string();break;default:n.skipType(7&d)}}return l},t.decodeDelimited=function(n){return n instanceof c||(n=new c(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.tensorType!=null&&n.hasOwnProperty("tensorType")){var r=i.onnx.TypeProto.Tensor.verify(n.tensorType);if(r)return"tensorType."+r}return n.denotation!=null&&n.hasOwnProperty("denotation")&&!s.isString(n.denotation)?"denotation: string expected":null},t.fromObject=function(n){if(n instanceof i.onnx.TypeProto)return n;var r=new i.onnx.TypeProto;if(n.tensorType!=null){if(typeof n.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");r.tensorType=i.onnx.TypeProto.Tensor.fromObject(n.tensorType)}return n.denotation!=null&&(r.denotation=String(n.denotation)),r},t.toObject=function(n,r){r||(r={});var a={};return r.defaults&&(a.denotation=""),n.tensorType!=null&&n.hasOwnProperty("tensorType")&&(a.tensorType=i.onnx.TypeProto.Tensor.toObject(n.tensorType,r),r.oneofs&&(a.value="tensorType")),n.denotation!=null&&n.hasOwnProperty("denotation")&&(a.denotation=n.denotation),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},t.Tensor=function(){function n(r){if(r)for(var a=Object.keys(r),l=0;l>>3){case 1:d.elemType=r.int32();break;case 2:d.shape=i.onnx.TensorShapeProto.decode(r,r.uint32());break;default:r.skipType(7&m)}}return d},n.decodeDelimited=function(r){return r instanceof c||(r=new c(r)),this.decode(r,r.uint32())},n.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.elemType!=null&&r.hasOwnProperty("elemType")&&!s.isInteger(r.elemType))return"elemType: integer expected";if(r.shape!=null&&r.hasOwnProperty("shape")){var a=i.onnx.TensorShapeProto.verify(r.shape);if(a)return"shape."+a}return null},n.fromObject=function(r){if(r instanceof i.onnx.TypeProto.Tensor)return r;var a=new i.onnx.TypeProto.Tensor;if(r.elemType!=null&&(a.elemType=0|r.elemType),r.shape!=null){if(typeof r.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");a.shape=i.onnx.TensorShapeProto.fromObject(r.shape)}return a},n.toObject=function(r,a){a||(a={});var l={};return a.defaults&&(l.elemType=0,l.shape=null),r.elemType!=null&&r.hasOwnProperty("elemType")&&(l.elemType=r.elemType),r.shape!=null&&r.hasOwnProperty("shape")&&(l.shape=i.onnx.TensorShapeProto.toObject(r.shape,a)),l},n.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},n}(),t}(),h.OperatorSetIdProto=function(){function t(e){if(e)for(var n=Object.keys(e),r=0;r>>3){case 1:a.domain=e.string();break;case 2:a.version=e.int64();break;default:e.skipType(7&l)}}return a},t.decodeDelimited=function(e){return e instanceof c||(e=new c(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!s.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!(s.isInteger(e.version)||e.version&&s.isInteger(e.version.low)&&s.isInteger(e.version.high))?"version: integer|Long expected":null},t.fromObject=function(e){if(e instanceof i.onnx.OperatorSetIdProto)return e;var n=new i.onnx.OperatorSetIdProto;return e.domain!=null&&(n.domain=String(e.domain)),e.version!=null&&(s.Long?(n.version=s.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?n.version=parseInt(e.version,10):typeof e.version=="number"?n.version=e.version:typeof e.version=="object"&&(n.version=new s.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),n},t.toObject=function(e,n){n||(n={});var r={};if(n.defaults)if(r.domain="",s.Long){var a=new s.Long(0,0,!1);r.version=n.longs===String?a.toString():n.longs===Number?a.toNumber():a}else r.version=n.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(r.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?r.version=n.longs===String?String(e.version):e.version:r.version=n.longs===String?s.Long.prototype.toString.call(e.version):n.longs===Number?new s.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},t}(),h),D.exports=i},2100:(D,u,b)=>{D.exports=b(9482)},9482:(D,u,b)=>{var g=u;function p(){g.util._configure(),g.Writer._configure(g.BufferWriter),g.Reader._configure(g.BufferReader)}g.build="minimal",g.Writer=b(1173),g.BufferWriter=b(3155),g.Reader=b(1408),g.BufferReader=b(593),g.util=b(9693),g.rpc=b(5994),g.roots=b(5054),g.configure=p,p()},1408:(D,u,b)=>{D.exports=f;var g,p=b(9693),h=p.LongBits,o=p.utf8;function c(a,l){return RangeError("index out of range: "+a.pos+" + "+(l||1)+" > "+a.len)}function f(a){this.buf=a,this.pos=0,this.len=a.length}var s,i=typeof Uint8Array<"u"?function(a){if(a instanceof Uint8Array||Array.isArray(a))return new f(a);throw Error("illegal buffer")}:function(a){if(Array.isArray(a))return new f(a);throw Error("illegal buffer")},t=function(){return p.Buffer?function(a){return(f.create=function(l){return p.Buffer.isBuffer(l)?new g(l):i(l)})(a)}:i};function e(){var a=new h(0,0),l=0;if(!(this.len-this.pos>4)){for(;l<3;++l){if(this.pos>=this.len)throw c(this);if(a.lo=(a.lo|(127&this.buf[this.pos])<<7*l)>>>0,this.buf[this.pos++]<128)return a}return a.lo=(a.lo|(127&this.buf[this.pos++])<<7*l)>>>0,a}for(;l<4;++l)if(a.lo=(a.lo|(127&this.buf[this.pos])<<7*l)>>>0,this.buf[this.pos++]<128)return a;if(a.lo=(a.lo|(127&this.buf[this.pos])<<28)>>>0,a.hi=(a.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return a;if(l=0,this.len-this.pos>4){for(;l<5;++l)if(a.hi=(a.hi|(127&this.buf[this.pos])<<7*l+3)>>>0,this.buf[this.pos++]<128)return a}else for(;l<5;++l){if(this.pos>=this.len)throw c(this);if(a.hi=(a.hi|(127&this.buf[this.pos])<<7*l+3)>>>0,this.buf[this.pos++]<128)return a}throw Error("invalid varint encoding")}function n(a,l){return(a[l-4]|a[l-3]<<8|a[l-2]<<16|a[l-1]<<24)>>>0}function r(){if(this.pos+8>this.len)throw c(this,8);return new h(n(this.buf,this.pos+=4),n(this.buf,this.pos+=4))}f.create=t(),f.prototype._slice=p.Array.prototype.subarray||p.Array.prototype.slice,f.prototype.uint32=(s=4294967295,function(){if(s=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(s=(s|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(s=(s|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(s=(s|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(s=(s|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return s;if((this.pos+=5)>this.len)throw this.pos=this.len,c(this,10);return s}),f.prototype.int32=function(){return 0|this.uint32()},f.prototype.sint32=function(){var a=this.uint32();return a>>>1^-(1&a)|0},f.prototype.bool=function(){return this.uint32()!==0},f.prototype.fixed32=function(){if(this.pos+4>this.len)throw c(this,4);return n(this.buf,this.pos+=4)},f.prototype.sfixed32=function(){if(this.pos+4>this.len)throw c(this,4);return 0|n(this.buf,this.pos+=4)},f.prototype.float=function(){if(this.pos+4>this.len)throw c(this,4);var a=p.float.readFloatLE(this.buf,this.pos);return this.pos+=4,a},f.prototype.double=function(){if(this.pos+8>this.len)throw c(this,4);var a=p.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,a},f.prototype.bytes=function(){var a=this.uint32(),l=this.pos,d=this.pos+a;if(d>this.len)throw c(this,a);return this.pos+=a,Array.isArray(this.buf)?this.buf.slice(l,d):l===d?new this.buf.constructor(0):this._slice.call(this.buf,l,d)},f.prototype.string=function(){var a=this.bytes();return o.read(a,0,a.length)},f.prototype.skip=function(a){if(typeof a=="number"){if(this.pos+a>this.len)throw c(this,a);this.pos+=a}else do if(this.pos>=this.len)throw c(this);while(128&this.buf[this.pos++]);return this},f.prototype.skipType=function(a){switch(a){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(a=7&this.uint32())!=4;)this.skipType(a);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+a+" at offset "+this.pos)}return this},f._configure=function(a){g=a,f.create=t(),g._configure();var l=p.Long?"toLong":"toNumber";p.merge(f.prototype,{int64:function(){return e.call(this)[l](!1)},uint64:function(){return e.call(this)[l](!0)},sint64:function(){return e.call(this).zzDecode()[l](!1)},fixed64:function(){return r.call(this)[l](!0)},sfixed64:function(){return r.call(this)[l](!1)}})}},593:(D,u,b)=>{D.exports=h;var g=b(1408);(h.prototype=Object.create(g.prototype)).constructor=h;var p=b(9693);function h(o){g.call(this,o)}h._configure=function(){p.Buffer&&(h.prototype._slice=p.Buffer.prototype.slice)},h.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},h._configure()},5054:D=>{D.exports={}},5994:(D,u,b)=>{u.Service=b(7948)},7948:(D,u,b)=>{D.exports=p;var g=b(9693);function p(h,o,c){if(typeof h!="function")throw TypeError("rpcImpl must be a function");g.EventEmitter.call(this),this.rpcImpl=h,this.requestDelimited=!!o,this.responseDelimited=!!c}(p.prototype=Object.create(g.EventEmitter.prototype)).constructor=p,p.prototype.rpcCall=function h(o,c,f,s,i){if(!s)throw TypeError("request must be specified");var t=this;if(!i)return g.asPromise(h,t,o,c,f,s);if(t.rpcImpl)try{return t.rpcImpl(o,c[t.requestDelimited?"encodeDelimited":"encode"](s).finish(),function(e,n){if(e)return t.emit("error",e,o),i(e);if(n!==null){if(!(n instanceof f))try{n=f[t.responseDelimited?"decodeDelimited":"decode"](n)}catch(r){return t.emit("error",r,o),i(r)}return t.emit("data",n,o),i(null,n)}t.end(!0)})}catch(e){return t.emit("error",e,o),void setTimeout(function(){i(e)},0)}else setTimeout(function(){i(Error("already ended"))},0)},p.prototype.end=function(h){return this.rpcImpl&&(h||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(D,u,b)=>{D.exports=p;var g=b(9693);function p(f,s){this.lo=f>>>0,this.hi=s>>>0}var h=p.zero=new p(0,0);h.toNumber=function(){return 0},h.zzEncode=h.zzDecode=function(){return this},h.length=function(){return 1};var o=p.zeroHash="\0\0\0\0\0\0\0\0";p.fromNumber=function(f){if(f===0)return h;var s=f<0;s&&(f=-f);var i=f>>>0,t=(f-i)/4294967296>>>0;return s&&(t=~t>>>0,i=~i>>>0,++i>4294967295&&(i=0,++t>4294967295&&(t=0))),new p(i,t)},p.from=function(f){if(typeof f=="number")return p.fromNumber(f);if(g.isString(f)){if(!g.Long)return p.fromNumber(parseInt(f,10));f=g.Long.fromString(f)}return f.low||f.high?new p(f.low>>>0,f.high>>>0):h},p.prototype.toNumber=function(f){if(!f&&this.hi>>>31){var s=1+~this.lo>>>0,i=~this.hi>>>0;return s||(i=i+1>>>0),-(s+4294967296*i)}return this.lo+4294967296*this.hi},p.prototype.toLong=function(f){return g.Long?new g.Long(0|this.lo,0|this.hi,!!f):{low:0|this.lo,high:0|this.hi,unsigned:!!f}};var c=String.prototype.charCodeAt;p.fromHash=function(f){return f===o?h:new p((c.call(f,0)|c.call(f,1)<<8|c.call(f,2)<<16|c.call(f,3)<<24)>>>0,(c.call(f,4)|c.call(f,5)<<8|c.call(f,6)<<16|c.call(f,7)<<24)>>>0)},p.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},p.prototype.zzEncode=function(){var f=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^f)>>>0,this.lo=(this.lo<<1^f)>>>0,this},p.prototype.zzDecode=function(){var f=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^f)>>>0,this.hi=(this.hi>>>1^f)>>>0,this},p.prototype.length=function(){var f=this.lo,s=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return i===0?s===0?f<16384?f<128?1:2:f<2097152?3:4:s<16384?s<128?5:6:s<2097152?7:8:i<128?9:10}},9693:function(D,u,b){var g=u;function p(o,c,f){for(var s=Object.keys(c),i=0;i0)},g.Buffer=function(){try{var o=g.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}}(),g._Buffer_from=null,g._Buffer_allocUnsafe=null,g.newBuffer=function(o){return typeof o=="number"?g.Buffer?g._Buffer_allocUnsafe(o):new g.Array(o):g.Buffer?g._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)},g.Array=typeof Uint8Array<"u"?Uint8Array:Array,g.Long=g.global.dcodeIO&&g.global.dcodeIO.Long||g.global.Long||g.inquire("long"),g.key2Re=/^true|false|0|1$/,g.key32Re=/^-?(?:0|[1-9][0-9]*)$/,g.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,g.longToHash=function(o){return o?g.LongBits.from(o).toHash():g.LongBits.zeroHash},g.longFromHash=function(o,c){var f=g.LongBits.fromHash(o);return g.Long?g.Long.fromBits(f.lo,f.hi,c):f.toNumber(!!c)},g.merge=p,g.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)},g.newError=h,g.ProtocolError=h("ProtocolError"),g.oneOfGetter=function(o){for(var c={},f=0;f-1;--i)if(c[s[i]]===1&&this[s[i]]!==void 0&&this[s[i]]!==null)return s[i]}},g.oneOfSetter=function(o){return function(c){for(var f=0;f{D.exports=t;var g,p=b(9693),h=p.LongBits,o=p.base64,c=p.utf8;function f(m,y,v){this.fn=m,this.len=y,this.next=void 0,this.val=v}function s(){}function i(m){this.head=m.head,this.tail=m.tail,this.len=m.len,this.next=m.states}function t(){this.len=0,this.head=new f(s,0,0),this.tail=this.head,this.states=null}var e=function(){return p.Buffer?function(){return(t.create=function(){return new g})()}:function(){return new t}};function n(m,y,v){y[v]=255&m}function r(m,y){this.len=m,this.next=void 0,this.val=y}function a(m,y,v){for(;m.hi;)y[v++]=127&m.lo|128,m.lo=(m.lo>>>7|m.hi<<25)>>>0,m.hi>>>=7;for(;m.lo>127;)y[v++]=127&m.lo|128,m.lo=m.lo>>>7;y[v++]=m.lo}function l(m,y,v){y[v]=255&m,y[v+1]=m>>>8&255,y[v+2]=m>>>16&255,y[v+3]=m>>>24}t.create=e(),t.alloc=function(m){return new p.Array(m)},p.Array!==Array&&(t.alloc=p.pool(t.alloc,p.Array.prototype.subarray)),t.prototype._push=function(m,y,v){return this.tail=this.tail.next=new f(m,y,v),this.len+=y,this},r.prototype=Object.create(f.prototype),r.prototype.fn=function(m,y,v){for(;m>127;)y[v++]=127&m|128,m>>>=7;y[v]=m},t.prototype.uint32=function(m){return this.len+=(this.tail=this.tail.next=new r((m>>>=0)<128?1:m<16384?2:m<2097152?3:m<268435456?4:5,m)).len,this},t.prototype.int32=function(m){return m<0?this._push(a,10,h.fromNumber(m)):this.uint32(m)},t.prototype.sint32=function(m){return this.uint32((m<<1^m>>31)>>>0)},t.prototype.uint64=function(m){var y=h.from(m);return this._push(a,y.length(),y)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(m){var y=h.from(m).zzEncode();return this._push(a,y.length(),y)},t.prototype.bool=function(m){return this._push(n,1,m?1:0)},t.prototype.fixed32=function(m){return this._push(l,4,m>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(m){var y=h.from(m);return this._push(l,4,y.lo)._push(l,4,y.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(m){return this._push(p.float.writeFloatLE,4,m)},t.prototype.double=function(m){return this._push(p.float.writeDoubleLE,8,m)};var d=p.Array.prototype.set?function(m,y,v){y.set(m,v)}:function(m,y,v){for(var _=0;_>>0;if(!y)return this._push(n,1,0);if(p.isString(m)){var v=t.alloc(y=o.length(m));o.decode(m,v,0),m=v}return this.uint32(y)._push(d,y,m)},t.prototype.string=function(m){var y=c.length(m);return y?this.uint32(y)._push(c.write,y,m):this._push(n,1,0)},t.prototype.fork=function(){return this.states=new i(this),this.head=this.tail=new f(s,0,0),this.len=0,this},t.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new f(s,0,0),this.len=0),this},t.prototype.ldelim=function(){var m=this.head,y=this.tail,v=this.len;return this.reset().uint32(v),v&&(this.tail.next=m.next,this.tail=y,this.len+=v),this},t.prototype.finish=function(){for(var m=this.head.next,y=this.constructor.alloc(this.len),v=0;m;)m.fn(m.val,y,v),v+=m.len,m=m.next;return y},t._configure=function(m){g=m,t.create=e(),g._configure()}},3155:(D,u,b)=>{D.exports=h;var g=b(1173);(h.prototype=Object.create(g.prototype)).constructor=h;var p=b(9693);function h(){g.call(this)}function o(c,f,s){c.length<40?p.utf8.write(c,f,s):f.utf8Write?f.utf8Write(c,s):f.write(c,s)}h._configure=function(){h.alloc=p._Buffer_allocUnsafe,h.writeBytesBuffer=p.Buffer&&p.Buffer.prototype instanceof Uint8Array&&p.Buffer.prototype.set.name==="set"?function(c,f,s){f.set(c,s)}:function(c,f,s){if(c.copy)c.copy(f,s,0,c.length);else for(var i=0;i>>0;return this.uint32(f),f&&this._push(h.writeBytesBuffer,f,c),this},h.prototype.string=function(c){var f=p.Buffer.byteLength(c);return this.uint32(f),f&&this._push(o,f,c),this},h._configure()},7714:(D,u,b)=>{u.R=void 0;const g=b(6919),p=b(7448);u.R=new class{async init(){}async createSessionHandler(h,o){const c=new g.Session(o);return await c.loadModel(h),new p.OnnxjsSessionHandler(c)}}},4200:(D,u,b)=>{u.c8=u.rX=void 0;const g=b(1670),p=b(5381),h=b(2157),o=b(2306);u.rX=()=>{if((typeof g.env.wasm.initTimeout!="number"||g.env.wasm.initTimeout<0)&&(g.env.wasm.initTimeout=0),typeof g.env.wasm.simd!="boolean"&&(g.env.wasm.simd=!0),typeof g.env.wasm.proxy!="boolean"&&(g.env.wasm.proxy=!1),typeof g.env.wasm.numThreads!="number"||!Number.isInteger(g.env.wasm.numThreads)||g.env.wasm.numThreads<=0){const c=typeof navigator>"u"?(0,p.cpus)().length:navigator.hardwareConcurrency;g.env.wasm.numThreads=Math.min(4,Math.ceil((c||1)/2))}},u.c8=new class{async init(){(0,u.rX)(),await(0,h.initWasm)()}async createSessionHandler(c,f){const s=new o.OnnxruntimeWebAssemblySessionHandler;return await s.loadModel(c,f),Promise.resolve(s)}}},6018:function(D,u,b){var g=this&&this.__createBinding||(Object.create?function(o,c,f,s){s===void 0&&(s=f);var i=Object.getOwnPropertyDescriptor(c,f);i&&!("get"in i?!c.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return c[f]}}),Object.defineProperty(o,s,i)}:function(o,c,f,s){s===void 0&&(s=f),o[s]=c[f]}),p=this&&this.__exportStar||function(o,c){for(var f in o)f==="default"||Object.prototype.hasOwnProperty.call(c,f)||g(c,o,f)};Object.defineProperty(u,"__esModule",{value:!0}),p(b(1670),u);const h=b(1670);{const o=b(7714).R;(0,h.registerBackend)("webgl",o,-10)}{const o=b(4200).c8;(0,h.registerBackend)("cpu",o,10),(0,h.registerBackend)("wasm",o,10),(0,h.registerBackend)("xnnpack",o,9)}},246:(D,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createAttributeWithCacheKey=void 0;class b{constructor(p){Object.assign(this,p)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(p=>`${this[p]}`).join(";")),this._cacheKey}}u.createAttributeWithCacheKey=g=>new b(g)},7778:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Attribute=void 0;const g=b(1446),p=b(9395),h=b(9162),o=b(2517);var c=p.onnxruntime.experimental.fbs;class f{constructor(i){if(this._attributes=new Map,i!=null){for(const t of i)t instanceof g.onnx.AttributeProto?this._attributes.set(t.name,[f.getValue(t),f.getType(t)]):t instanceof c.Attribute&&this._attributes.set(t.name(),[f.getValue(t),f.getType(t)]);if(this._attributes.sizeh.Tensor.fromProto(n));if(i instanceof c.Attribute)return e.map(n=>h.Tensor.fromOrtTensor(n))}if(t===g.onnx.AttributeProto.AttributeType.STRING&&i instanceof g.onnx.AttributeProto){const n=e;return(0,o.decodeUtf8String)(n)}return t===g.onnx.AttributeProto.AttributeType.STRINGS&&i instanceof g.onnx.AttributeProto?e.map(o.decodeUtf8String):e}static getValueNoCheck(i){return i instanceof g.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(i):this.getValueNoCheckFromOrtFormat(i)}static getValueNoCheckFromOnnxFormat(i){switch(i.type){case g.onnx.AttributeProto.AttributeType.FLOAT:return i.f;case g.onnx.AttributeProto.AttributeType.INT:return i.i;case g.onnx.AttributeProto.AttributeType.STRING:return i.s;case g.onnx.AttributeProto.AttributeType.TENSOR:return i.t;case g.onnx.AttributeProto.AttributeType.GRAPH:return i.g;case g.onnx.AttributeProto.AttributeType.FLOATS:return i.floats;case g.onnx.AttributeProto.AttributeType.INTS:return i.ints;case g.onnx.AttributeProto.AttributeType.STRINGS:return i.strings;case g.onnx.AttributeProto.AttributeType.TENSORS:return i.tensors;case g.onnx.AttributeProto.AttributeType.GRAPHS:return i.graphs;default:throw new Error(`unsupported attribute type: ${g.onnx.AttributeProto.AttributeType[i.type]}`)}}static getValueNoCheckFromOrtFormat(i){switch(i.type()){case c.AttributeType.FLOAT:return i.f();case c.AttributeType.INT:return i.i();case c.AttributeType.STRING:return i.s();case c.AttributeType.TENSOR:return i.t();case c.AttributeType.GRAPH:return i.g();case c.AttributeType.FLOATS:return i.floatsArray();case c.AttributeType.INTS:{const t=[];for(let e=0;e{Object.defineProperty(u,"__esModule",{value:!0}),u.resolveBackend=u.backend=void 0;const g=b(5038),p=new Map;async function h(o){const c=u.backend;if(c[o]!==void 0&&function(f){const s=f;return"initialize"in s&&typeof s.initialize=="function"&&"createSessionHandler"in s&&typeof s.createSessionHandler=="function"&&"dispose"in s&&typeof s.dispose=="function"}(c[o])){const f=c[o];let s=f.initialize();if(typeof s=="object"&&"then"in s&&(s=await s),s)return p.set(o,f),f}}u.backend={webgl:new g.WebGLBackend},u.resolveBackend=async function o(c){if(!c)return o(["webgl"]);{const f=typeof c=="string"?[c]:c;for(const s of f){const i=p.get(s);if(i)return i;const t=await h(s);if(t)return t}}throw new Error("no available backend to use")}},5038:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WebGLBackend=void 0;const g=b(1670),p=b(6231),h=b(6416),o=b(7305);u.WebGLBackend=class{get contextId(){return g.env.webgl.contextId}set contextId(c){g.env.webgl.contextId=c}get matmulMaxBatchSize(){return g.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(c){g.env.webgl.matmulMaxBatchSize=c}get textureCacheMode(){return g.env.webgl.textureCacheMode}set textureCacheMode(c){g.env.webgl.textureCacheMode=c}get pack(){return g.env.webgl.pack}set pack(c){g.env.webgl.pack=c}get async(){return g.env.webgl.async}set async(c){g.env.webgl.async=c}initialize(){try{return this.glContext=(0,o.createWebGLContext)(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),p.Logger.setWithEnv(g.env),p.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(c){return p.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${c}`),!1}}createSessionHandler(c){return new h.WebGLSessionHandler(this,c)}dispose(){this.glContext.dispose()}}},5107:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoordsGlslLib=void 0;const g=b(2517),p=b(8520),h=b(5060),o=b(7859),c=b(9390);class f extends p.GlslLib{constructor(i){super(i)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new p.GlslLibRoutine(` + vec2 offsetToCoords(int offset, int width, int height) { + int t = offset / width; + int s = offset - t*width; + vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height); + return coords; + } + `)}}coordsToOffset(){return{coordsToOffset:new p.GlslLibRoutine(` + int coordsToOffset(vec2 coords, int width, int height) { + float s = coords.s * float(width); + float t = coords.t * float(height); + int offset = int(t) * width + int(s); + return offset; + } + `)}}getOutputSamplingSnippet(){const i=this.context.outputTextureLayout;return i.isPacked?this.getPackedOutputSamplingSnippet(i):this.getUnpackedOutputSamplingSnippet(i)}getPackedOutputSamplingSnippet(i){const t=i.unpackedShape,e=[i.width,i.height],n={},r="getOutputCoords";switch(t.length){case 0:n[r]=this.getOutputScalarCoords();break;case 1:n[r]=this.getOutputPacked1DCoords(t,e);break;case 2:n[r]=this.getOutputPacked2DCoords(t,e);break;case 3:n[r]=this.getOutputPacked3DCoords(t,e);break;default:n[r]=this.getOutputPackedNDCoords(t,e)}const a=` + void setOutput(vec4 val) { + ${(0,h.getGlsl)(this.context.glContext.version).output} = val; + } + `;return n.floatTextureSetRGBA=new p.GlslLibRoutine(a),n}getUnpackedOutputSamplingSnippet(i){const t=i.unpackedShape,e=[i.width,i.height],n={},r="getOutputCoords";switch(t.length){case 0:n[r]=this.getOutputScalarCoords();break;case 1:n[r]=this.getOutputUnpacked1DCoords(t,e);break;case 2:n[r]=this.getOutputUnpacked2DCoords(t,e);break;case 3:n[r]=this.getOutputUnpacked3DCoords(t,e);break;case 4:n[r]=this.getOutputUnpacked4DCoords(t,e);break;case 5:n[r]=this.getOutputUnpacked5DCoords(t,e);break;case 6:n[r]=this.getOutputUnpacked6DCoords(t,e);break;default:throw new Error(`Unsupported output dimensionality: ${t.length}`)}const a=` + void setOutput(float val) { + ${(0,h.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0); + } + `;return n.floatTextureSetR=new p.GlslLibRoutine(a),n}getOutputScalarCoords(){return new p.GlslLibRoutine(` + int getOutputCoords() { + return 0; + } + `)}getOutputPacked1DCoords(i,t){const e=t;let n="";return e[0]===1?(n=` + int getOutputCoords() { + return 2 * int(TexCoords.y * ${e[1]}.0); + } + `,new p.GlslLibRoutine(n)):e[1]===1?(n=` + int getOutputCoords() { + return 2 * int(TexCoords.x * ${e[0]}.0); + } + `,new p.GlslLibRoutine(n)):(n=` + int getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); + } + `,new p.GlslLibRoutine(n))}getOutputPacked2DCoords(i,t){let e="";if(g.ArrayUtil.arraysEqual(i,t))return e=` + ivec2 getOutputCoords() { + return 2 * ivec2(TexCoords.xy * vec2(${t[0]}, ${t[1]})); + } + `,new p.GlslLibRoutine(e);const n=t,r=Math.ceil(i[1]/2);return e=` + ivec2 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + + int index = resTexRC.y * ${n[0]} + resTexRC.x; + + // reverse r and c order for packed texture + int r = imod(index, ${r}) * 2; + int c = 2 * (index / ${r}); + + return ivec2(r, c); + } + `,new p.GlslLibRoutine(e)}getOutputPacked3DCoords(i,t){const e=[t[0],t[1]],n=Math.ceil(i[2]/2),r=n*Math.ceil(i[1]/2),a=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + int index = resTexRC.y * ${e[0]} + resTexRC.x; + + int b = index / ${r}; + index -= b * ${r}; + + // reverse r and c order for packed texture + int r = imod(index, ${n}) * 2; + int c = 2 * (index / ${n}); + + return ivec3(b, r, c); + } + `;return new p.GlslLibRoutine(a)}getOutputPackedNDCoords(i,t){const e=[t[0],t[1]],n=Math.ceil(i[i.length-1]/2),r=n*Math.ceil(i[i.length-2]/2);let a=r,l="",d="b, r, c";for(let y=2;y=0;--d)r[d]=r[d+1]*i[d+1];const a=["r","c","d"],l=r.map((d,m)=>`int ${a[m]} = index / ${d}; ${m===r.length-1?`int ${a[m+1]} = index - ${a[m]} * ${d}`:`index -= ${a[m]} * ${d}`};`).join("");return e=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${l} + return ivec3(r, c, d); + } + `,new p.GlslLibRoutine(e)}getOutputUnpacked4DCoords(i,t){let e="";const n=i.length;let r=null;n<2&&(r=[]),r=new Array(n-1),r[n-2]=i[n-1];for(let d=n-3;d>=0;--d)r[d]=r[d+1]*i[d+1];const a=["r","c","d","d2"],l=r.map((d,m)=>`int ${a[m]} = index / ${d}; ${m===r.length-1?`int ${a[m+1]} = index - ${a[m]} * ${d}`:`index -= ${a[m]} * ${d}`};`).join("");return e=` + ivec4 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${l} + return ivec4(r, c, d, d2); + } + `,new p.GlslLibRoutine(e)}getOutputUnpacked5DCoords(i,t){let e="";const n=i.length;let r=null;n<2&&(r=[]),r=new Array(n-1),r[n-2]=i[n-1];for(let d=n-3;d>=0;--d)r[d]=r[d+1]*i[d+1];const a=["r","c","d","d2","d3"],l=r.map((d,m)=>`int ${a[m]} = index / ${d}; ${m===r.length-1?`int ${a[m+1]} = index - ${a[m]} * ${d}`:`index -= ${a[m]} * ${d}`};`).join("");return e=` + ivec5 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${l} + return ivec5(r, c, d, d2, d3); + } + `,new p.GlslLibRoutine(e)}getOutputUnpacked6DCoords(i,t){let e="";const n=i.length;let r=null;n<2&&(r=[]),r=new Array(n-1),r[n-2]=i[n-1];for(let d=n-3;d>=0;--d)r[d]=r[d+1]*i[d+1];const a=["r","c","d","d2","d3","d4"],l=r.map((d,m)=>`int ${a[m]} = index / ${d}; ${m===r.length-1?`int ${a[m+1]} = index - ${a[m]} * ${d}`:`index -= ${a[m]} * ${d}`};`).join("");return e=` + ivec6 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${l} + return ivec6(r, c, d, d2, d3, d4); + } + `,new p.GlslLibRoutine(e)}getCommonUtilFuncs(){const i={};let t="uvFromFlat";i[t]=new p.GlslLibRoutine(` + vec2 uvFromFlat(int texNumR, int texNumC, int index) { + int texC = index / texNumR; + int texR = index - texC * texNumR; + // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to + // v. + return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC); + } + `),t="packedUVfrom1D",i[t]=new p.GlslLibRoutine(` + vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { + int texelIndex = index / 2; + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),t="packedUVfrom2D",i[t]=new p.GlslLibRoutine(` + vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) { + int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),t="packedUVfrom3D",i[t]=new p.GlslLibRoutine(` + vec2 packedUVfrom3D(int texNumR, int texNumC, + int texelsInBatch, int texelsInLogicalRow, int b, + int row, int col) { + int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); + int texR = index / texNumC; + int texC = index - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),t="sampleTexture";const e=(0,h.getGlsl)(this.context.glContext.version);return i[t]=new p.GlslLibRoutine(` + float sampleTexture(sampler2D textureSampler, vec2 uv) { + return ${e.texture2D}(textureSampler, uv).r; + }`),i}getInputsSamplingSnippets(){const i={},t=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((e,n)=>{const r=this.context.inputTextureLayouts[n],a=(0,c.generateShaderFuncNameFromInputSamplerName)(e);r.isPacked?i[a]=this.getPackedSamplerFromInput(a,e,r):i[a]=this.getUnpackedSamplerFromInput(a,e,r);const l=(0,c.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(e);r.unpackedShape.length<=t.unpackedShape.length&&(r.isPacked?i[l]=this.getPackedSamplerAtOutputCoords(l,r,t,e):i[l]=this.getUnpackedSamplerAtOutputCoords(l,r,t,e))}),i}getPackedSamplerAtOutputCoords(i,t,e,n){const r=t.unpackedShape,a=e.unpackedShape,l=n,d=(0,c.generateShaderFuncNameFromInputSamplerName)(l),m=r.length,y=a.length,v=g.BroadcastUtil.getBroadcastDims(r,a),_=(0,c.getCoordsDataType)(y),T=y-m;let S;const A=(0,c.getGlChannels)();S=m===0?"":y<2&&v.length>=1?"coords = 0;":v.map(N=>`coords.${A[N+T]} = 0;`).join(` +`);let w="";w=y<2&&m>0?"coords":r.map((N,W)=>`coords.${A[W+T]}`).join(", ");let I="return outputValue;";const R=g.ShapeUtil.size(r)===1,B=g.ShapeUtil.size(a)===1;if(m!==1||R||B){if(R&&!B)I=y===1?` + return vec4(outputValue.x, outputValue.x, 0., 0.); + `:` + return vec4(outputValue.x); + `;else if(v.length){const N=m-2,W=m-1;v.indexOf(N)>-1&&v.indexOf(W)>-1?I="return vec4(outputValue.x);":v.indexOf(N)>-1?I="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":v.indexOf(W)>-1&&(I="return vec4(outputValue.xx, outputValue.zz);")}}else I=` + return vec4(outputValue.xy, outputValue.xy); + `;const j=` + vec4 ${i}() { + ${_} coords = getOutputCoords(); + + int lastDim = coords.${A[y-1]}; + coords.${A[y-1]} = coords.${A[y-2]}; + coords.${A[y-2]} = lastDim; + + ${S} + vec4 outputValue = ${d}(${w}); + ${I} + } + `;return new p.GlslLibRoutine(j,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(i,t,e,n){const r=[e.width,e.height],a=[t.width,t.height],l=t.unpackedShape.length,d=e.unpackedShape.length,m=t.unpackedShape,y=e.unpackedShape,v=(0,c.generateShaderFuncNameFromInputSamplerName)(n);if(l===d&&g.ArrayUtil.arraysEqual(a,r)){const B=` + float ${i}() { + return sampleTexture(${n}, TexCoords); + } + `;return new p.GlslLibRoutine(B,["coordinates.sampleTexture"])}const _=(0,c.getCoordsDataType)(d),T=g.BroadcastUtil.getBroadcastDims(m,y),S=d-l;let A;const w=(0,c.getGlChannels)();A=l===0?"":d<2&&T.length>=1?"coords = 0;":T.map(B=>`coords.${w[B+S]} = 0;`).join(` +`);let I="";I=d<2&&l>0?"coords":t.unpackedShape.map((B,j)=>`coords.${w[j+S]}`).join(", ");const R=` + float ${i}() { + ${_} coords = getOutputCoords(); + ${A} + return ${v}(${I}); + } + `;return new p.GlslLibRoutine(R,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(i,t,e){switch(e.unpackedShape.length){case 0:return this.getPackedSamplerScalar(i,t);case 1:return this.getPackedSampler1D(i,t,e);case 2:return this.getPackedSampler2D(i,t,e);case 3:return this.getPackedSampler3D(i,t,e);default:return this.getPackedSamplerND(i,t,e)}}getUnpackedSamplerFromInput(i,t,e){const n=e.unpackedShape;switch(n.length){case 0:return this.getUnpackedSamplerScalar(i,t,e);case 1:return this.getUnpackedSampler1D(i,t,e);case 2:return this.getUnpackedSampler2D(i,t,e);case 3:return this.getUnpackedSampler3D(i,t,e);case 4:return this.getUnpackedSampler4D(i,t,e);case 5:return this.getUnpackedSampler5D(i,t,e);case 6:return this.getUnpackedSampler6D(i,t,e);default:throw new Error(`Unsupported dimension ${n.length}-D`)}}getPackedSamplerScalar(i,t){const e=` + vec4 ${i}() { + return ${(0,h.getGlsl)(this.context.glContext.version).texture2D}(${t}, halfCR); + } + `;return new p.GlslLibRoutine(e)}getPackedSampler1D(i,t,e){const n=[e.width,e.height],r=[n[1],n[0]],a=(0,h.getGlsl)(this.context.glContext.version),l=`vec4 ${i}(int index) { + vec2 uv = packedUVfrom1D( + ${r[0]}, ${r[1]}, index); + return ${a.texture2D}(${t}, uv); + }`;return new p.GlslLibRoutine(l,["coordinates.packedUVfrom1D"])}getPackedSampler2D(i,t,e){const n=e.unpackedShape,r=[e.width,e.height],a=(0,h.getGlsl)(this.context.glContext.version),l=r[0],d=r[1];if(r!=null&&g.ArrayUtil.arraysEqual(n,r)){const _=`vec4 ${i}(int row, int col) { + vec2 uv = (vec2(col, row) + halfCR) / vec2(${d}.0, ${l}.0); + return ${a.texture2D}(${t}, uv); + }`;return new p.GlslLibRoutine(_)}const m=r,y=Math.ceil(n[1]/2),v=`vec4 ${i}(int row, int col) { + vec2 uv = packedUVfrom2D(${m[1]}, ${m[0]}, ${y}, row, col); + return ${a.texture2D}(${t}, uv); + }`;return new p.GlslLibRoutine(v,["coordinates.packedUVfrom2D"])}getPackedSampler3D(i,t,e){const n=e.unpackedShape,r=[e.width,e.height],a=[r[0],r[1]],l=(0,h.getGlsl)(this.context.glContext.version);if(n[0]===1){const _=n.slice(1),T=[1,2],S=(0,c.squeezeInputShape)(n,_),A=["b","row","col"],w=JSON.parse(JSON.stringify(e));w.unpackedShape=S;const I=this.getPackedSamplerFromInput(i,t,w),R=`${I.routineBody} + vec4 ${i}(int b, int row, int col) { + return ${i}(${(0,c.getSqueezedParams)(A,T)}); + } `;return new p.GlslLibRoutine(R,I.dependencies)}const d=a[0],m=a[1],y=Math.ceil(n[2]/2),v=`vec4 ${i}(int b, int row, int col) { + vec2 uv = packedUVfrom3D( + ${m}, ${d}, ${y*Math.ceil(n[1]/2)}, ${y}, b, row, col); + return ${l.texture2D}(${t}, uv);}`;return new p.GlslLibRoutine(v,["coordinates.packedUVfrom3D"])}getPackedSamplerND(i,t,e){const n=e.unpackedShape,r=n.length,a=[e.width,e.height],l=(0,h.getGlsl)(this.context.glContext.version),d=[a[0],a[1]],m=d[1],y=d[0],v=Math.ceil(n[r-1]/2);let _=v*Math.ceil(n[r-2]/2),T="int b, int row, int col",S=`b * ${_} + (row / 2) * ${v} + (col / 2)`;for(let w=2;w{const n=this.context.inputTextureLayouts[e],r=(n.unpackedShape.length>0?n.unpackedShape:n.shape).length;let a=`_${t}`;i[a]=new p.GlslLibRoutine(this.getValueFromSingle(t,r,n.width,n.height,!1),[`shapeUtils.indicesToOffset${a}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),a+="_T",i[a]=new p.GlslLibRoutine(this.getValueFromSingle(t,r,n.width,n.height,!0),[`shapeUtils.indicesToOffset${a}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),i}getValueFromSingle(i,t,e,n,r){let a=`_${i}`;return r&&(a+="_T"),` + float ${a}(int m[${t}]) { + int offset = indicesToOffset${a}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${n}); + float value = getColorAsFloat(${(0,h.getGlsl)(this.context.glContext.version).texture2D}(${i}, coords)); + return value; + } + `}getPackedValueFrom(i,t,e,n,r){let a=`_${i}_Pack`;return r&&(a+="_T"),` + vec4 ${a}(int m[${t}]) { + int offset = indicesToOffset_${i}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${n}); + return ${(0,h.getGlsl)(this.context.glContext.version).texture2D}(${i}, coords); + } + `}}u.CoordsGlslLib=f},8520:(D,u)=>{var b;Object.defineProperty(u,"__esModule",{value:!0}),u.TopologicalSortGlslRoutines=u.GlslLibRoutineNode=u.GlslLibRoutine=u.GlslLib=u.GlslContext=u.FunctionType=void 0,(b=u.FunctionType||(u.FunctionType={}))[b.ValueBased=0]="ValueBased",b[b.Positional=1]="Positional",u.GlslContext=class{constructor(g,p,h,o){this.glContext=g,this.programInfo=p,this.inputTextureLayouts=h,this.outputTextureLayout=o}},u.GlslLib=class{constructor(g){this.context=g}},u.GlslLibRoutine=class{constructor(g,p){this.routineBody=g,this.dependencies=p}},u.GlslLibRoutineNode=class{constructor(g,p,h){this.name=g,this.dependencies=h||[],p&&(this.routineBody=p)}addDependency(g){g&&this.dependencies.push(g)}},u.TopologicalSortGlslRoutines=class{static returnOrderedNodes(g){if(!g||g.length===0)return[];if(g.length===1)return g;const p=new Set,h=new Set,o=new Array;return this.createOrderedNodes(g,p,h,o),o}static createOrderedNodes(g,p,h,o){for(let c=0;c0)for(let f=0;f{Object.defineProperty(u,"__esModule",{value:!0}),u.EncodingGlslLib=void 0;const g=b(8520);class p extends g.GlslLib{constructor(o){super(o)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new g.GlslLibRoutine(`highp vec4 encode(highp float f) { + return vec4(f, 0.0, 0.0, 0.0); + } + `)}}decodeFloat32(){return{decode:new g.GlslLibRoutine(`highp float decode(highp vec4 rgba) { + return rgba.r; + } + `)}}encodeUint8(){const o=p.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new g.GlslLibRoutine(` + highp vec4 encode(highp float f) { + highp float F = abs(f); + highp float Sign = step(0.0,-f); + highp float Exponent = floor(log2(F)); + highp float Mantissa = (exp2(- Exponent) * F); + Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa)); + highp vec4 rgba; + rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0)); + rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0); + rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0))); + rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0))); + ${o} + rgba = rgba / 255.0; // values need to be normalized to [0,1] + return rgba; + } + `)}}decodeUint8(){const o=p.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new g.GlslLibRoutine(` + highp float decode(highp vec4 rgba) { + rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] + ${o} + highp float Sign = 1.0 - step(128.0,rgba[0])*2.0; + highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0; + highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000); + highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 )); + return Result; + } + `)}}static isLittleEndian(){const o=new ArrayBuffer(4),c=new Uint32Array(o),f=new Uint8Array(o);if(c[0]=3735928559,f[0]===239)return!0;if(f[0]===222)return!1;throw new Error("unknown endianness")}}u.EncodingGlslLib=p},9894:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.FragColorGlslLib=void 0;const g=b(8520),p=b(5060);class h extends g.GlslLib{constructor(c){super(c)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const c=(0,p.getGlsl)(this.context.glContext.version);return{setFragColor:new g.GlslLibRoutine(` + void setFragColor(float value) { + ${c.output} = encode(value); + } + `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new g.GlslLibRoutine(` + float getColorAsFloat(vec4 color) { + return decode(color); + } + `,["encoding.decode"])}}}u.FragColorGlslLib=h},2848:(D,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.replaceInlines=void 0;const b=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;u.replaceInlines=function(g){const p={};let h;for(;(h=b.exec(g))!==null;){const o=h[3].split(",").map(c=>{const f=c.trim().split(" ");return f&&f.length===2?{type:f[0],name:f[1]}:null}).filter(c=>c!==null);p[h[2]]={params:o,body:h[4]}}for(const o in p){const c="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",o),f=new RegExp(c,"gm");for(;(h=f.exec(g))!==null;){const s=h[1],i=h[2],t=h[3].split(","),e=s?`${s} ${i};`:"";let n=p[o].body,r="";p[o].params.forEach((l,d)=>{l&&(r+=`${l.type} ${l.name} = ${t[d]}; +`)}),n=`${r} + ${n}`,n=n.replace("return",`${i} = `);const a=` + ${e} + { + ${n} + } + `;g=g.replace(h[0],a)}}return g.replace(b,"")}},8879:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.GlslPreprocessor=void 0;const g=b(8520),p=b(2848),h=b(5483),o=b(5060);u.GlslPreprocessor=class{constructor(c,f,s,i){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new g.GlslContext(c,f,s,i),Object.keys(h.glslRegistry).forEach(e=>{const n=new h.glslRegistry[e](this.context);this.libs[e]=n});const t=this.glslLibRoutineDependencyGraph;for(const e in this.libs){const n=this.libs[e].getFunctions();for(const r in n){const a=e+"."+r;let l;t[a]?(l=t[a],l.routineBody=n[r].routineBody):(l=new g.GlslLibRoutineNode(a,n[r].routineBody),t[a]=l);const d=n[r].dependencies;if(d)for(let m=0;m{const i=s.split(".")[1];c.indexOf(i)!==-1&&f.push(this.glslLibRoutineDependencyGraph[s])}),g.TopologicalSortGlslRoutines.returnOrderedNodes(f)}getUniforms(c,f){const s=[];if(c)for(const i of c)s.push(`uniform sampler2D ${i};`);if(f)for(const i of f)s.push(`uniform ${i.type} ${i.name}${i.arrayLength?`[${i.arrayLength}]`:""};`);return s.join(` +`)}}},5483:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.glslRegistry=void 0;const g=b(5107),p=b(7341),h=b(9894),o=b(2655),c=b(3891);u.glslRegistry={encoding:p.EncodingGlslLib,fragcolor:h.FragColorGlslLib,vec:c.VecGlslLib,shapeUtils:o.ShapeUtilsGlslLib,coordinates:g.CoordsGlslLib}},2655:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ShapeUtilsGlslLib=void 0;const g=b(8520);class p extends g.GlslLib{constructor(o){super(o)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const o=this.context.outputTextureLayout.shape.length,c={};return this.context.programInfo.inputNames.forEach((f,s)=>{const i=this.context.inputTextureLayouts[s].unpackedShape;if(i.length<=o){const t=i.length,e=o-t,n=`bcastIndices_${f}`;let r="";for(let l=0;l{const i=this.context.inputTextureLayouts[s].shape;if(!(i.length<2||i.length>o)){const t=i.length,e=o-t,n=`bcastMatmulIndices_${f}`;let r="";for(let l=0;l{const s=this.context.inputTextureLayouts[f].shape,i=this.context.inputTextureLayouts[f].strides,t=s.length;let e=`indicesToOffset_${c}`;o[e]=new g.GlslLibRoutine(p.indexToOffsetSingle(e,t,i)),e=`indicesToOffset_${c}_T`,o[e]=new g.GlslLibRoutine(p.indexToOffsetSingle(e,t,i.slice().reverse()))}),o}static indexToOffsetSingle(o,c,f){let s="";for(let i=c-1;i>=0;--i)s+=` + offset += indices[${i}] * ${f[i]}; + `;return` + int ${o}(int indices[${c}]) { + int offset = 0; + ${s} + return offset; + } + `}offsetToIndices(){const o={};return this.context.programInfo.inputNames.forEach((c,f)=>{const s=this.context.inputTextureLayouts[f].shape,i=this.context.inputTextureLayouts[f].strides,t=s.length;let e=`offsetToIndices_${c}`;o[e]=new g.GlslLibRoutine(p.offsetToIndicesSingle(e,t,i)),e=`offsetToIndices_${c}_T`,o[e]=new g.GlslLibRoutine(p.offsetToIndicesSingle(e,t,i.slice().reverse()))}),o}static offsetToIndicesSingle(o,c,f){const s=[];for(let i=0;i{const s=this.context.inputTextureLayouts[f].shape,i=s.length,t=`incrementIndices_${c}`;let e="";for(let r=0;r= 0; --i) { + if(i > axis) continue; + indices[i] += 1; + if(indices[i] < shape[i]) { + break; + } + indices[i] = 0; + } + } + `;o[t]=new g.GlslLibRoutine(n)}),o}}u.ShapeUtilsGlslLib=p},5060:(D,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.getDefaultFragShaderMain=u.getFragShaderPreamble=u.getVertexShaderSource=u.getGlsl=void 0;const b={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},g={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function p(h){return h===1?b:g}u.getGlsl=p,u.getVertexShaderSource=function(h){const o=p(h);return`${o.version} + precision highp float; + ${o.attribute} vec3 position; + ${o.attribute} vec2 textureCoord; + + ${o.varyingVertex} vec2 TexCoords; + + void main() + { + gl_Position = vec4(position, 1.0); + TexCoords = textureCoord; + }`},u.getFragShaderPreamble=function(h){const o=p(h);return`${o.version} + precision highp float; + precision highp int; + precision highp sampler2D; + ${o.varyingFrag} vec2 TexCoords; + ${o.outputDeclaration} + const vec2 halfCR = vec2(0.5, 0.5); + + // Custom vector types to handle higher dimenalities. + struct ivec5 + { + int x; + int y; + int z; + int w; + int u; + }; + + struct ivec6 + { + int x; + int y; + int z; + int w; + int u; + int v; + }; + + int imod(int x, int y) { + return x - y * (x / y); + } + + `},u.getDefaultFragShaderMain=function(h,o){return` + void main() { + int indices[${o}]; + toVec(TexCoords, indices); + vec4 result = vec4(process(indices)); + ${p(h).output} = result; + } + `}},3891:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.VecGlslLib=void 0;const g=b(8520);class p extends g.GlslLib{constructor(o){super(o)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const o=this.context.outputTextureLayout.shape.length,c={add:"+=",sub:"-=",mul:"*=",div:"/="},f={};for(const s in c){const i=`${s}Vec`;let t="";for(let n=0;n{Object.defineProperty(u,"__esModule",{value:!0}),u.WebGLInferenceHandler=void 0;const g=b(6231),p=b(9162),h=b(2517),o=b(2403),c=b(7019),f=b(8710),s=b(5611),i=b(4057),t=b(2039);u.WebGLInferenceHandler=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,n){return(0,i.calculateTextureWidthAndHeight)(this.session.layoutStrategy,e,n)}executeProgram(e,n){if(n.length{const T=_.map(A=>`${A.unpackedShape.join(",")};${A.width}x${A.height}`).join("_");let S=v.name;return v.cacheHint&&(S+="["+v.cacheHint+"]"),S+=":"+T,S})(e,r);let l=this.session.programManager.getArtifact(a);const d=l?l.programInfo:typeof e.get=="function"?e.get():e,m=(0,i.createTextureLayoutFromTextureType)(this.session.layoutStrategy,d.output.dims,d.output.textureType),y=this.createTextureData(m,d.output.type);return l||(l=this.session.programManager.build(d,r,y),this.session.programManager.setArtifact(a,l)),this.runProgram(l,r,y),y}run(e,n){return this.executeProgram(e,n).tensor}runProgram(e,n,r){for(let a=0;athis.readTexture(d),async m=>this.readTextureAsync(d),void 0,l),texture:r});return this.setTextureData(d.tensor.dataId,d,e.isPacked),d}getTextureData(e,n=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,n):n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,r=!1){this.session.isInitializer(e)?this.session.setTextureData(e,n,r):(r?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,n)}isTextureLayoutCached(e,n=!1){return!!this.getTextureData(e.dataId,n)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,f.encodeAsUint8)(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,f.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,o.createPackProgramInfoLoader)(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram((0,s.createUnpackProgramInfoLoader)(this,e.tensor),[e.tensor])}}},1640:function(D,u,b){var g=this&&this.__createBinding||(Object.create?function(Y,te,ne,me){me===void 0&&(me=ne);var Pe=Object.getOwnPropertyDescriptor(te,ne);Pe&&!("get"in Pe?!te.__esModule:Pe.writable||Pe.configurable)||(Pe={enumerable:!0,get:function(){return te[ne]}}),Object.defineProperty(Y,me,Pe)}:function(Y,te,ne,me){me===void 0&&(me=ne),Y[me]=te[ne]}),p=this&&this.__setModuleDefault||(Object.create?function(Y,te){Object.defineProperty(Y,"default",{enumerable:!0,value:te})}:function(Y,te){Y.default=te}),h=this&&this.__importStar||function(Y){if(Y&&Y.__esModule)return Y;var te={};if(Y!=null)for(var ne in Y)ne!=="default"&&Object.prototype.hasOwnProperty.call(Y,ne)&&g(te,Y,ne);return p(te,Y),te};Object.defineProperty(u,"__esModule",{value:!0}),u.WEBGL_OP_RESOLVE_RULES=void 0;const o=b(2898),c=h(b(7839)),f=b(4196),s=b(2069),i=b(8138),t=b(9663),e=b(5193),n=b(7992),r=b(1253),a=b(4776),l=b(6572),d=b(3346),m=b(5623),y=b(2870),v=b(2143),_=b(4939),T=b(718),S=b(2268),A=b(8117),w=b(2278),I=b(5524),R=b(5975),B=b(3933),j=b(6558),N=b(5723),W=b(3738),k=h(b(4909)),V=b(8428),J=b(9793);u.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",k.abs],["Acos","","7+",k.acos],["Add","","7+",c.add],["And","","7+",c.and],["Asin","","7+",k.asin],["Atan","","7+",k.atan],["AveragePool","","7+",v.averagePool,v.parseAveragePoolAttributes],["BatchNormalization","","7+",o.batchNormalization,o.parseBatchNormalizationAttributes],["Cast","","6+",f.cast,f.parseCastAttributes],["Ceil","","6+",k.ceil],["Clip","","6-10",k.clip,k.parseClipAttributes],["Clip","","11+",k.clipV11],["Concat","","4+",s.concat,s.parseConcatAttributes],["Conv","","1+",i.conv,i.parseConvAttributes],["ConvTranspose","","1+",t.convTranspose,t.parseConvTransposeAttributes],["Cos","","7+",k.cos],["Div","","7+",c.div],["Dropout","","7+",k.identity],["DepthToSpace","","1+",e.depthToSpace,e.parseDepthToSpaceAttributes],["Equal","","7+",c.equal],["Elu","","6+",k.elu,k.parseEluAttributes],["Exp","","6+",k.exp],["Flatten","","1+",n.flatten,n.parseFlattenAttributes],["Floor","","6+",k.floor],["FusedConv","com.microsoft","1+",i.conv,i.parseConvAttributes],["Gather","","1+",r.gather,r.parseGatherAttributes],["Gemm","","7-10",a.gemm,a.parseGemmAttributesV7],["Gemm","","11+",a.gemm,a.parseGemmAttributesV11],["GlobalAveragePool","","1+",v.globalAveragePool,v.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",v.globalMaxPool],["Greater","","7+",c.greater],["Identity","","1+",k.identity],["ImageScaler","","1+",l.imageScaler,l.parseImageScalerAttributes],["InstanceNormalization","","6+",d.instanceNormalization,d.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",k.leakyRelu,k.parseLeakyReluAttributes],["Less","","7+",c.less],["Log","","6+",k.log],["MatMul","","1+",m.matMul,m.parseMatMulAttributes],["MaxPool","","1+",v.maxPool,v.parseMaxPoolAttributes],["Mul","","7+",c.mul],["Neg","","6+",k.neg],["Not","","1+",k.not],["Or","","7+",c.or],["Pad","","2-10",y.padV2,y.parsePadAttributesV2],["Pad","","11+",y.padV11,y.parsePadAttributesV11],["Pow","","7+",c.pow],["PRelu","","7+",c.pRelu],["ReduceLogSum","","1+",_.reduceLogSum,_.parseReduceAttributes],["ReduceMax","","1+",_.reduceMax,_.parseReduceAttributes],["ReduceMean","","1+",_.reduceMean,_.parseReduceAttributes],["ReduceMin","","1+",_.reduceMin,_.parseReduceAttributes],["ReduceProd","","1+",_.reduceProd,_.parseReduceAttributes],["ReduceSum","","1-12",_.reduceSum,_.parseReduceAttributes],["ReduceSumSquare","","1+",_.reduceLogSumSquare,_.parseReduceAttributes],["Relu","","6+",k.relu],["Reshape","","5+",T.reshape],["Resize","","10",S.resize,S.parseResizeAttributesV10],["Resize","","11+",S.resize,S.parseResizeAttributesV11],["Shape","","1+",A.shape],["Sigmoid","","6+",k.sigmoid],["Sin","","7+",k.sin],["Slice","","10+",w.sliceV10],["Slice","","1-9",w.slice,w.parseSliceAttributes],["Softmax","","1-12",I.softmax,I.parseSoftmaxAttributes],["Softmax","","13+",I.softmaxV13,I.parseSoftmaxAttributesV13],["Split","","2-12",R.split,R.parseSplitAttributes],["Sqrt","","6+",k.sqrt],["Squeeze","","1-12",B.squeeze,B.parseSqueezeAttributes],["Squeeze","","13+",B.squeezeV13],["Sub","","7+",c.sub],["Sum","","6+",j.sum],["Tan","","7+",k.tan],["Tanh","","6+",k.tanh],["Tile","","6+",N.tile],["Transpose","","1+",W.transpose,W.parseTransposeAttributes],["Upsample","","7-8",J.upsample,J.parseUpsampleAttributesV7],["Upsample","","9",J.upsample,J.parseUpsampleAttributesV9],["Unsqueeze","","1-12",V.unsqueeze,V.parseUnsqueezeAttributes],["Unsqueeze","","13+",V.unsqueezeV13],["Xor","","7+",c.xor]]},2898:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseBatchNormalizationAttributes=u.batchNormalization=void 0;const g=b(246),p=b(5060),h=b(2039),o={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[h.TextureType.unpacked,h.TextureType.unpacked,h.TextureType.unpacked,h.TextureType.unpacked,h.TextureType.unpacked]};u.batchNormalization=(s,i,t)=>(f(i),[s.run(Object.assign(Object.assign({},o),{cacheHint:t.cacheKey,get:()=>c(s,i,t)}),i)]),u.parseBatchNormalizationAttributes=s=>{const i=s.attributes.getFloat("epsilon",1e-5),t=s.attributes.getFloat("momentum",.9),e=s.attributes.getInt("spatial",1);return(0,g.createAttributeWithCacheKey)({epsilon:i,momentum:t,spatial:e})};const c=(s,i,t)=>{const e=(0,p.getGlsl)(s.session.backend.glContext.version),n=i[0].dims.length,[r,a]=s.calculateTextureWidthAndHeight(i[1].dims,h.TextureType.unpacked),l=` + float process(int[${n}] indices) { + vec2 position = offsetToCoords(indices[1], ${r}, ${a}); + float scale = getColorAsFloat(${e.texture2D}(Scale, position)); + float mean = getColorAsFloat(${e.texture2D}(Mean, position)); + float variance = getColorAsFloat(${e.texture2D}(Variance, position)); + float b = getColorAsFloat(${e.texture2D}(B, position)); + + return scale * ( (_A(indices) - mean) / sqrt(variance + float(${t.epsilon})) ) + b; + }`;return Object.assign(Object.assign({},o),{output:{dims:i[0].dims,type:i[0].type,textureType:h.TextureType.unpacked},shaderSource:l})},f=s=>{if(!s||s.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const i=s[0],t=s[1],e=s[2],n=s[3],r=s[4];if(i.dims.length<3||t.dims.length!==1||e.dims.length!==1||n.dims.length!==1||r.dims.length!==1)throw new Error("invalid input shape.");if(t.dims[0]!==i.dims[1]||e.dims[0]!==i.dims[1]||n.dims[0]!==i.dims[1]||r.dims[0]!==i.dims[1])throw new Error("invalid input shape.");if(i.type!=="float32"&&i.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||r.type!=="float32"&&r.type!=="float64")throw new Error("invalid input tensor types.")}},7839:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.xor=u.sub=u.pRelu=u.pow=u.or=u.mul=u.less=u.greater=u.equal=u.div=u.and=u.add=u.glslPRelu=u.glslPow=u.glslXor=u.glslOr=u.glslAnd=u.glslLess=u.glslGreater=u.glslEqual=u.glslSub=u.glslMul=u.glslDiv=u.glslAdd=void 0;const g=b(2517),p=b(8520),h=b(5060),o=b(2039);function c(){const _="add_";return{body:` + float ${_}(float a, float b) { + return a + b; + } + vec4 ${_}(vec4 v1, vec4 v2) { + return v1 + v2; + } + `,name:_,type:p.FunctionType.ValueBased}}function f(){const _="div_";return{body:` + float ${_}(float a, float b) { + return a / b; + } + vec4 ${_}(vec4 v1, vec4 v2) { + return v1 / v2; + } + `,name:_,type:p.FunctionType.ValueBased}}function s(){const _="mul_";return{body:` + float ${_}(float a, float b) { + return a * b; + } + vec4 ${_}(vec4 v1, vec4 v2) { + return v1 * v2; + } + `,name:_,type:p.FunctionType.ValueBased}}function i(){const _="sub_";return{body:` + float ${_}(float a, float b) { + return a - b; + } + vec4 ${_}(vec4 v1, vec4 v2) { + return v1 - v2; + } + `,name:_,type:p.FunctionType.ValueBased}}function t(){const _="equal_";return{body:` + float ${_}(float a, float b) { + return float(a == b); + } + vec4 ${_}(vec4 v1, vec4 v2) { + return vec4(equal(v1, v2)); + } + `,name:_,type:p.FunctionType.ValueBased}}function e(){const _="greater_";return{body:` + float ${_}(float a, float b) { + return float(a > b); + } + vec4 ${_}(vec4 v1, vec4 v2) { + return vec4( v1.r > v2.r , + v1.g > v2.g, + v1.b > v2.b, + v1.a > v2.a ); + } + `,name:_,type:p.FunctionType.ValueBased}}function n(){const _="less_";return{body:` + float ${_}(float a, float b) { + return float(a < b); + } + vec4 ${_}(vec4 v1, vec4 v2) { + return vec4( v1.r < v2.r , + v1.g < v2.g, + v1.b < v2.b, + v1.a < v2.a ); + } + `,name:_,type:p.FunctionType.ValueBased}}function r(){const _="and_";return{body:` + float ${_}(float a, float b) { + return float( bool(a) && bool(b) ); + } + vec4 ${_}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r && b2.r , + b1.g && b2.g, + b1.b && b2.b, + b1.a && b2.a ); + } + `,name:_,type:p.FunctionType.ValueBased}}function a(){const _="or_";return{body:` + float ${_}(float a, float b) { + return float( bool(a) || bool(b) ); + } + vec4 ${_}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r || b2.r , + b1.g || b2.g, + b1.b || b2.b, + b1.a || b2.a ); + } + `,name:_,type:p.FunctionType.ValueBased}}function l(){const _="xor_";return{body:` + float ${_}(float a, float b) { + return float( bool(a) ^^ bool(b) ); + } + vec4 ${_}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r ^^ b2.r , + b1.g ^^ b2.g, + b1.b ^^ b2.b, + b1.a ^^ b2.a ); + } + `,name:_,type:p.FunctionType.ValueBased}}function d(){return function(_){const T=`${_}_`;return{body:` + float ${T}(float a, float b) { + return ${_}(a, b); + } + vec4 ${T}(vec4 v1, vec4 v2) { + return ${_}(v1, v2); + } + `,name:T,type:p.FunctionType.ValueBased}}("pow")}function m(){const _="prelu_";return{body:` + float ${_}(float a, float b) { + return a < 0.0 ? a * b: a; + } + vec4 ${_}(vec4 v1, vec4 v2) { + return vec4( + v1.r < 0.0 ? v1.r * v2.r: v1.r, + v1.g < 0.0 ? v1.g * v2.g: v1.g, + v1.b < 0.0 ? v1.b * v2.b: v1.b, + v1.a < 0.0 ? v1.a * v2.a: v1.a + ); + } + `,name:_,type:p.FunctionType.ValueBased}}u.glslAdd=c,u.glslDiv=f,u.glslMul=s,u.glslSub=i,u.glslEqual=t,u.glslGreater=e,u.glslLess=n,u.glslAnd=r,u.glslOr=a,u.glslXor=l,u.glslPow=d,u.glslPRelu=m;const y=(_,T,S,A=T[0].type,w)=>{const I=_.session.pack?o.TextureType.packed:o.TextureType.unpacked;return{name:S.name,inputNames:["A","B"],inputTypes:[I,I],cacheHint:w,get:()=>v(_,T,S,A)}},v=(_,T,S,A=T[0].type)=>{const w=_.session.pack?o.TextureType.packed:o.TextureType.unpacked,I=!g.ShapeUtil.areEqual(T[0].dims,T[1].dims);let R=T[0].dims;const B=_.session.pack;if(I){const W=g.BroadcastUtil.calcShape(T[0].dims,T[1].dims,!1);if(!W)throw new Error("Can't perform binary op on the given tensors");R=W;const k=R.length,V=T[0].dims.length!==0?T[0].dims.length:1,J=T[1].dims.length!==0?T[1].dims.length:1,Y=T[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",te=T[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",ne=(0,h.getGlsl)(_.session.backend.glContext.version),me=B?` + ${S.body} + void main() { + vec4 a = getAAtOutCoords(); + vec4 b = getBAtOutCoords(); + vec4 result = ${S.name}(a, b); + ${ne.output} = result; + }`:` + ${S.body} + float process(int indices[${k}]) { + int aindices[${V}]; + int bindices[${J}]; + ${Y} + ${te} + return ${S.name}(_A(aindices), _B(bindices)); + }`;return{name:S.name,inputNames:["A","B"],inputTypes:[w,w],output:{dims:R,type:A,textureType:w},shaderSource:me,hasMain:B}}const j=(0,h.getGlsl)(_.session.backend.glContext.version),N=` + ${S.body} + void main() { + vec4 v1 = ${j.texture2D}(A, TexCoords); + vec4 v2 = ${j.texture2D}(B, TexCoords); + vec4 result = ${S.name}(v1, v2); + ${j.output} = result; + } + `;return{name:S.name,inputNames:["A","B"],inputTypes:[w,w],output:{dims:T[0].dims,type:A,textureType:w},shaderSource:N,hasMain:!0}};u.add=(_,T)=>[_.run(y(_,T,c()),T)],u.and=(_,T)=>[_.run(y(_,T,r(),"bool"),T)],u.div=(_,T)=>[_.run(y(_,T,f()),T)],u.equal=(_,T)=>[_.run(y(_,T,t(),"bool"),T)],u.greater=(_,T)=>[_.run(y(_,T,e(),"bool"),T)],u.less=(_,T)=>[_.run(y(_,T,n(),"bool"),T)],u.mul=(_,T)=>[_.run(y(_,T,s()),T)],u.or=(_,T)=>[_.run(y(_,T,a(),"bool"),T)],u.pow=(_,T)=>[_.run(y(_,T,d()),T)],u.pRelu=(_,T)=>[_.run(y(_,T,m()),T)],u.sub=(_,T)=>[_.run(y(_,T,i()),T)],u.xor=(_,T)=>[_.run(y(_,T,l(),"bool"),T)]},4196:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseCastAttributes=u.cast=void 0;const g=b(2517);u.cast=(h,o,c)=>(p(o),[h.cast(o[0],c)]),u.parseCastAttributes=h=>g.ProtoUtil.tensorDataTypeFromProto(h.attributes.getInt("to"));const p=h=>{if(!h||h.length!==1)throw new Error("Cast requires 1 input.");if(h[0].type==="string")throw new Error("Invalid input type.")}},1163:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createPackedConcatProgramInfoLoader=void 0;const g=b(5060),p=b(2039),h=b(9390),o=b(2827);u.createPackedConcatProgramInfoLoader=(f,s,i)=>{const t=(e=s.length,n=i.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:e},(r,a)=>`X${a}`),inputTypes:Array(e).fill(p.TextureType.packed),cacheHint:n});var e,n;return Object.assign(Object.assign({},t),{get:()=>((r,a,l,d)=>{const m=l[0].dims.slice();if(d>=m.length||d<-1*m.length)throw new Error("axis specified for concat doesn't match input dimensionality");d<0&&(d=m.length+d);const y=m.slice(0);for(let Y=1;YY.dims),w=(0,h.getGlChannels)(v),I=new Array(A.length-1);I[0]=A[0][d];for(let Y=1;Y= ${I[Y-1]}) { + return getChannel( + getX${Y}(${c(w,R,te)}), + vec2(${c(B,R,te)})); + }`}const W=I.length,k=I[I.length-1];N+=` + return getChannel( + getX${W}(${c(w,R,k)}), + vec2(${c(B,R,k)}));`;const V=(0,g.getGlsl)(r.session.backend.glContext.version),J=` + ${S} + float getValue(${w.map(Y=>"int "+Y)}) { + ${N} + } + + void main() { + ${T} coords = getOutputCoords(); + int lastDim = coords.${w[v-1]}; + coords.${w[v-1]} = coords.${w[v-2]}; + coords.${w[v-2]} = lastDim; + + vec4 result = vec4(getValue(${_}), 0., 0., 0.); + + ${_[v-1]} = ${_[v-1]} + 1; + if (${_[v-1]} < ${y[v-1]}) { + result.g = getValue(${_}); + } + + ${_[v-2]} = ${_[v-2]} + 1; + if (${_[v-2]} < ${y[v-2]}) { + result.a = getValue(${_}); + } + + ${_[v-1]} = ${_[v-1]} - 1; + if (${_[v-2]} < ${y[v-2]} && + ${_[v-1]} < ${y[v-1]}) { + result.b = getValue(${_}); + } + ${V.output} = result; + } + `;return Object.assign(Object.assign({},a),{output:{dims:y,type:l[0].type,textureType:p.TextureType.packed},shaderSource:J,hasMain:!0})})(f,t,s,i.axis)})};const c=(f,s,i)=>{const t=f.indexOf(s);return f.map((e,n)=>n===t?`${e} - ${i}`:e).join()}},2069:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseConcatAttributes=u.concat=void 0;const g=b(246),p=b(2039),h=b(1163);u.concat=(e,n,r)=>(t(n),e.session.pack&&n[0].dims.length>1?[e.run((0,h.createPackedConcatProgramInfoLoader)(e,n,r),n)]:[e.run(o(e,n,r),n)]);const o=(e,n,r)=>{const a=(l=n.length,d=r.cacheKey,{name:"Concat",inputNames:Array.from({length:l},(m,y)=>`X${y}`),inputTypes:Array(l).fill(p.TextureType.unpacked),cacheHint:d});var l,d;return Object.assign(Object.assign({},a),{get:()=>((m,y,v,_)=>{const T=v[0].dims.slice();if(_>=T.length||_<-1*T.length)throw new Error("axis specified for concat doesn't match input dimensionality");_<0&&(_=T.length+_);const S=T.slice(0);for(let j=1;j`int getTextureWhereDataResides(int index) { + ${e.map((n,r)=>`if(index<${n}) {return ${r};} +`).join("")} + }`,f=e=>c(e),s=(e,n)=>{const r=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${n}]) {`];for(let a=0;a{const n=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let r=0;r(0,g.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis")});const t=e=>{if(!e||e.length<1)throw new Error("too few inputs");const n=e[0].type,r=e[0].dims.length;if(n==="string")throw new Error("string tensor is not supported yet");for(const a of e){if(a.type!==n)throw new Error("input tensors should be one type");if(a.dims.length!==r)throw new Error("input tensors should have the same shape")}}},4770:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createUnpackedGroupedConvProgramInfoLoader=void 0;const g=b(6231),p=b(5060),h=b(2039),o=b(8138),c=b(2823);u.createUnpackedGroupedConvProgramInfoLoader=(f,s,i)=>{const t=(e=s.length>2,n=i.cacheKey,{name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[h.TextureType.unpacked,h.TextureType.unpacked,h.TextureType.unpacked]:[h.TextureType.unpacked,h.TextureType.unpacked],cacheHint:n});var e,n;return Object.assign(Object.assign({},t),{get:()=>((r,a,l,d)=>{const m=a.length>2?"value += getBias(output_channel);":"",y=a[0].dims.slice(),v=a[1].dims.slice(),_=v[0]/d.group;g.Logger.verbose("GroupedConv",`autpPad:${d.autoPad}, dilations:${d.dilations}, group:${d.group}, kernelShape:${d.kernelShape}, pads:${d.pads}, strides:${d.strides}`);const T=(0,o.calculateOutputShape)(y,v,d.dilations,d.pads,d.strides),S=(0,p.getGlsl)(r.session.backend.glContext.version),{activationFunction:A,applyActivation:w}=(0,c.getActivationSnippet)(d),I=` + const ivec2 strides = ivec2(${d.strides[0]}, ${d.strides[1]}); + const ivec2 pads = ivec2(${d.pads[0]}, ${d.pads[1]}); + ${A} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + ivec2 xRCCorner = coords.zw * strides - pads; + int group_id = output_channel / ${_}; + + float value = 0.0; + for (int wInChannel = 0; wInChannel < ${v[1]}; wInChannel++) { + int input_channel = group_id * ${v[1]} + wInChannel; + for (int wHeight = 0; wHeight < ${v[2]}; wHeight++) { + int xHeight = xRCCorner.x + wHeight * ${d.dilations[0]}; + + if (xHeight < 0 || xHeight >= ${y[2]}) { + continue; + } + + for (int wWidth = 0; wWidth < ${v[3]}; wWidth++) { + int xWidth = xRCCorner.y + wWidth * ${d.dilations[1]}; + if (xWidth < 0 || xWidth >= ${y[3]}) { + continue; + } + + float xVal = getX(batch, input_channel, xWidth, xHeight); + float wVal = getW(output_channel, wInChannel, wWidth, wHeight); + value += xVal*wVal; + } + } + } + ${m} + ${w} + ${S.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},l),{output:{dims:T,type:a[0].type,textureType:h.TextureType.unpacked},shaderSource:I,hasMain:!0})})(f,s,t,i)})}},1386:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.conv2DPacked=u.conv2DPackedPointwise=void 0;const g=b(8138),p=b(8555),h=b(708);u.conv2DPackedPointwise=(o,c,f)=>{const s=c[0].dims,i=c[1].dims,t=(0,g.calculateOutputShape)(s,i,f.dilations,f.pads,f.strides),e=o.reshapePacked(c[0],[s[1],s[2]*s[3]]),n=o.reshapePacked(c[1],[i[0],i[1]]),r=c.length>2?[n,e,c[2]]:[n,e],a=o.run((0,h.createPackedMatmulProgramInfoLoader)(o,r,f),r);return o.reshapePacked(a,t)},u.conv2DPacked=(o,c,f)=>{const s=c[0].dims,i=c[1].dims,t=(0,g.calculateOutputShape)(s,i,f.dilations,f.pads,f.strides),e=o.run((0,p.createPackedIm2ColProgramInfoLoader)(o,c[0],c[1],t,f),[c[0]]),n=o.reshapePacked(c[1],[i[0],i[1]*i[2]*i[3]]),r=c.length===3?[n,e,c[2]]:[n,e],a=o.run((0,h.createPackedMatmulProgramInfoLoader)(o,r,f),r);return o.reshapePacked(a,t)}},9663:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseConvTransposeAttributes=u.convTranspose=void 0;const g=b(246),p=b(5060),h=b(2039),o=b(2823),c=(n,r,a,l,d,m)=>(n-1)*r+a+(l-1)*d+1-m,f=(n,r,a,l,d)=>{const m=Math.floor(n/2);r==="SAME_UPPER"?(a[l]=m,a[d]=n-m):r==="SAME_LOWER"&&(a[l]=n-m,a[d]=m)};u.convTranspose=(n,r,a)=>(e(r,a),s(n,r,a));const s=(n,r,a)=>{const l=t(a,r);return[i(n,r,l)]},i=(n,r,a)=>n.run(((l,d,m)=>{const y=(v=d.length>2,_=m.cacheKey,{name:"ConvTranspose",inputNames:v?["X","W","B"]:["X","W"],inputTypes:v?[h.TextureType.unpacked,h.TextureType.unpacked,h.TextureType.unpacked]:[h.TextureType.unpacked,h.TextureType.unpacked],cacheHint:_});var v,_;return Object.assign(Object.assign({},y),{get:()=>((T,S,A,w)=>{const I=S.length>2?"getB(output_channel)":"0.0",R=S[0].dims,B=S[1].dims,j=B[1],N=B[0]/w.group,W=[S[0].dims[0],S[1].dims[1]*w.group,...w.outputShape],k=(0,p.getGlsl)(T.session.backend.glContext.version),{activationFunction:V,applyActivation:J}=(0,o.getActivationSnippet)(w),Y=` + const ivec2 strides = ivec2(${w.strides[0]}, ${w.strides[1]}); + const ivec2 pads = ivec2(${w.pads[0]}, ${w.pads[1]}); + ${V} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + + ivec2 loc = coords.zw + pads; + + int group_id = output_channel / ${j}; + int wOutChannel = output_channel - group_id * ${j}; + + float value = ${I}; + for (int inChannelOffset = 0; inChannelOffset < ${N}; inChannelOffset++) { + int input_channel = group_id * ${N} + inChannelOffset; + for (int wWOff = 0; wWOff < ${B[2]}; wWOff++) { + for (int wHOff = 0; wHOff < ${B[3]}; wHOff++) { + ivec2 wOff = ivec2(wWOff * ${w.dilations[0]}, wHOff * ${w.dilations[1]}); + ivec2 wLoc = loc - wOff; + ivec2 wLocIn = wLoc / strides; + if ( + wLocIn * strides == wLoc && + wLocIn.x >= 0 && wLocIn.x < ${R[2]} && + wLocIn.y >= 0 && wLocIn.y < ${R[3]} + ) { + float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); + float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); + value += xVal * wVal; + } + } + } + } + ${J} + ${k.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},A),{output:{dims:W,type:S[0].type,textureType:h.TextureType.unpacked},shaderSource:Y,hasMain:!0})})(l,d,y,m)})})(n,r,a),r),t=(n,r)=>{const a=n.kernelShape.slice();if(n.kernelShape.length===0)for(let y=2;y{const R=y.length-2,B=I.length===0;for(let j=0;j{const r=n.attributes,a=(0,o.parseInternalActivationAttributes)(r),l=r.getString("auto_pad","NOTSET"),d=r.getInts("dilations",[1,1]),m=r.getInt("group",1),y=r.getInts("kernel_shape",[]),v=r.getInts("output_padding",[0,0]),_=r.getInts("output_shape",[]),T=r.getInts("pads",[0,0,0,0]),S=r.getInts("strides",[1,1]);return(0,g.createAttributeWithCacheKey)(Object.assign({autoPad:l,dilations:d,group:m,kernelShape:y,outputPadding:v,outputShape:_,pads:T,strides:S},a))};const e=(n,r)=>{if(!n||n.length!==2&&n.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(n[0].dims.length!==4||n[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(n[0].dims[1]!==n[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const a=n[1].dims[1]*r.group;if(n.length===3&&(n[2].dims.length!==1||n[2].dims[0]!==a))throw new Error("invalid bias");const l=n[0].dims.length-2;if(r.dilations.length!==l)throw new Error(`dilations should be ${l}D`);if(r.strides.length!==l)throw new Error(`strides should be ${l}D`);if(r.pads.length!==2*l)throw new Error(`pads should be ${2*l}D`);if(r.outputPadding.length!==l)throw new Error(`output_padding should be ${l}D`);if(r.kernelShape.length!==0&&r.kernelShape.length!==n[1].dims.length-2)throw new Error("invalid kernel shape");if(r.outputShape.length!==0&&r.outputShape.length!==n[0].dims.length-2)throw new Error("invalid output shape");if(n[0].type!=="float32"||n[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(n.length===3&&n[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},8138:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseConvAttributes=u.conv=u.calculateOutputShape=void 0;const g=b(246),p=b(2517),h=b(4770),o=b(1386),c=b(9828),f=b(2823),s=b(3248),i=b(5623);u.calculateOutputShape=(l,d,m,y,v)=>{const _=l[0],T=l.slice(2),S=T.length,A=d[0],w=d.slice(2).map((R,B)=>R+(R-1)*(m[B]-1)),I=T.map((R,B)=>R+y[B]+y[B+S]).map((R,B)=>Math.floor((R-w[B]+v[B])/v[B]));return[_,A].concat(...I)},u.conv=(l,d,m)=>(a(d,m),t(l,d,m));const t=(l,d,m)=>{const y=r(m,d),v=l.session.pack,_=y.kernelShape[0]===1&&y.kernelShape[1]===1;return y.group>1?[l.run((0,h.createUnpackedGroupedConvProgramInfoLoader)(l,d,y),d)]:_&&v?[e(l,d,y)]:v&&d[0].dims.length===4&&d[0].dims[0]===1&&!_?[(0,o.conv2DPacked)(l,d,y)]:[n(l,d,y)]},e=(l,d,m)=>{const y=d[0].dims,v=d[1].dims,_=(0,u.calculateOutputShape)(y,v,m.dilations,m.pads,m.strides),T=l.reshapeUnpacked(d[0],[y[1],y[2]*y[3]]),S=l.reshapeUnpacked(d[1],[v[0],v[1]]),A=d.length>2?[S,T,d[2]]:[S,T],w=l.run((0,i.createMatmulProgramInfoLoader)(A,m),A);return l.reshapeUnpacked(w,_)},n=(l,d,m)=>{const y=d[0].dims,v=d[1].dims,_=(0,u.calculateOutputShape)(y,v,m.dilations,m.pads,m.strides),T=l.run((0,s.createIm2ColProgramInfoLoader)(l,d[0],d[1],_,m),[d[0]]),S=d.length===3?[T,d[1],d[2]]:[T,d[1]];return l.run((0,c.createDotProductProgramInfoLoader)(l,d,_,m),S)},r=(l,d)=>{const m=l.kernelShape.slice();if(l.kernelShape.length===0)for(let _=2;_{const d=l.attributes,m=(0,f.parseInternalActivationAttributes)(d),y=d.getString("auto_pad","NOTSET"),v=d.getInts("dilations",[1,1]),_=d.getInt("group",1),T=d.getInts("kernel_shape",[]),S=d.getInts("pads",[0,0,0,0]),A=d.getInts("strides",[1,1]);return(0,g.createAttributeWithCacheKey)(Object.assign({autoPad:y,dilations:v,group:_,kernelShape:T,pads:S,strides:A},m))};const a=(l,d)=>{if(!l||l.length!==2&&l.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(l[0].dims.length!==4||l[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(l[0].dims[1]!==l[1].dims[1]*d.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(l.length===3&&(l[2].dims.length!==1||l[1].dims[0]!==l[2].dims[0]))throw new Error("invalid bias");const m=l[0].dims.length-2;if(d.dilations.length!==m)throw new Error(`dilations should be ${m}D`);if(d.strides.length!==m)throw new Error(`strides should be ${m}D`);if(d.pads.length!==2*m)throw new Error(`pads should be ${2*m}D`);if(d.kernelShape.length!==0&&d.kernelShape.length!==l[1].dims.length-2)throw new Error("invalid kernel shape");if(l[0].type!=="float32"||l[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(l.length===3&&l[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},5193:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseDepthToSpaceAttributes=u.depthToSpace=void 0;const g=b(3738);u.depthToSpace=(h,o,c)=>{p(o);const f=c.blocksize,s=f*f,i=c.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],t=c.mode==="DCR"?[o[0].dims[0],f,f,o[0].dims[1]/s,o[0].dims[2],o[0].dims[3]]:[o[0].dims[0],o[0].dims[1]/s,f,f,o[0].dims[2],o[0].dims[3]],e=h.reshapeUnpacked(o[0],t),n={perm:i,cacheKey:`${i}`},[r]=(0,g.transpose)(h,[e],n),a=[o[0].dims[0],o[0].dims[1]/s,o[0].dims[2]*f,o[0].dims[3]*f];return[h.reshapeUnpacked(r,a)]},u.parseDepthToSpaceAttributes=h=>{const o=h.attributes.getInt("blocksize");if(o<1)throw new Error(`blocksize must be >= 1, but got : ${o} for DepthToSpace`);const c=h.attributes.getString("mode","DCR");if(c!=="DCR"&&c!=="CRD")throw new Error(`unrecognized mode: ${c} for DepthToSpace`);return{mode:c,blocksize:o}};const p=h=>{if(h.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${h.length}`);if(h[0].type==="string"||h[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},9828:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createDotProductProgramInfoLoader=void 0;const g=b(2517),p=b(5060),h=b(2039),o=b(2823),c=b(3248);u.createDotProductProgramInfoLoader=(f,s,i,t)=>{const e=((n,r)=>({name:"ConvDotProduct",inputNames:n?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:n?[h.TextureType.unpacked,h.TextureType.packedLastDimension,h.TextureType.unpacked]:[h.TextureType.unpacked,h.TextureType.packedLastDimension],cacheKey:r.activationCacheKey}))(s.length>2,t);return Object.assign(Object.assign({},e),{get:()=>((n,r,a,l,d)=>{const m=a[0].dims,y=a[1].dims,v=[y[0],Math.ceil(m[1]*y[2]*y[3]/4)],_=(0,c.calculateIm2ColDims)(m,y,l),[T,S]=n.calculateTextureWidthAndHeight(v,h.TextureType.packedLastDimension),A=g.ShapeUtil.computeStrides(_),[w,I]=n.calculateTextureWidthAndHeight(_,h.TextureType.packedLastDimension),R=l.length,B=a.length<3?"0.0":"_B(b)",j=Math.ceil(m[1]*y[2]*y[3]/4),{activationFunction:N,applyActivation:W}=(0,o.getActivationSnippet)(d),k=(0,p.getGlsl)(n.session.backend.glContext.version),V=` +${N} +float process(int indices[${R}]) { + int b[1]; + b[0] = indices[1]; + int im2col[4]; + im2col[0] = indices[0]; + im2col[1] = indices[2]; + im2col[2] = indices[3]; + int im2colOffset = im2col[0] * ${A[0]} + im2col[1] * ${A[1]} + im2col[2] * ${A[2]}; + int kernelOffset = indices[1] * ${v[1]}; + float value = ${B}; + for (int i = 0; i < ${j}; ++i) { + vec2 im2colCoords = offsetToCoords(im2colOffset, ${w}, ${I}); + vec2 kernelCoords = offsetToCoords(kernelOffset, ${T}, ${S}); + value += dot(${k.texture2D}(Im2Col, im2colCoords), ${k.texture2D}(K, kernelCoords)); + ++im2colOffset; + ++kernelOffset; + } + ${W} + return value; +}`;return Object.assign(Object.assign({},r),{output:{dims:l,type:a[0].type,textureType:h.TextureType.unpacked},shaderSource:V})})(f,e,s,i,t)})}},7992:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseFlattenAttributes=u.flatten=void 0;const g=b(2517);u.flatten=(h,o,c)=>{p(o,c);const f=g.ShapeUtil.flattenShape(o[0].dims,c);return[h.reshapeUnpacked(o[0],f)]},u.parseFlattenAttributes=h=>h.attributes.getInt("axis",1);const p=(h,o)=>{if(!h||h.length!==1)throw new Error("Flatten requires 1 input.");const c=h[0].dims.length;if(c===0)throw new Error("scalar tensor is not supported.");if(o<-c||o>c)throw new Error("Invalid axis");if(h[0].type==="string")throw new Error("string tensor is not supported.")}},2823:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseInternalActivationAttributes=u.getActivationSnippet=void 0;const g=b(2517),p=b(4909);u.getActivationSnippet=function(h){let o;switch(h.activation){case"Relu":o=(0,p.glslRelu)();break;case"Sigmoid":o=(0,p.glslSigmoid)();break;case"Clip":o=(0,p.glslClip)(h.clipMin,h.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const c=o.name;return{activationFunction:o.body,applyActivation:`value = ${c}_(value);`}},u.parseInternalActivationAttributes=h=>{const o=h.getString("activation","");if(o==="Clip"){const[c,f]=h.getFloats("activation_params",[g.MIN_CLIP,g.MAX_CLIP]);return{activation:o,clipMax:f,clipMin:c,activationCacheKey:`${o}:${c},${f}`}}return{activation:o,activationCacheKey:o}}},1253:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseGatherAttributes=u.gather=void 0;const g=b(246),p=b(782),h=b(2517),o=b(2039);u.gather=(i,t,e)=>(s(t,e.axis),[i.run(f(i,t,e),t)]),u.parseGatherAttributes=i=>(0,g.createAttributeWithCacheKey)({axis:i.attributes.getInt("axis",0)});const c={name:"Gather",inputNames:["A","B"],inputTypes:[o.TextureType.unpacked,o.TextureType.unpacked]},f=(i,t,e)=>{const n=Object.assign(Object.assign({},c),{cacheHint:e.cacheKey});return Object.assign(Object.assign({},n),{get:()=>((r,a,l,d)=>{const m=l[0].dims.slice(),y=l[1].dims.slice(),v=new Array(m.length+y.length-1);d=h.ShapeUtil.normalizeAxis(d,m.length);const _=[];for(let S=0;S{if(!i||i.length!==2)throw new Error("Gather requires 2 inputs.");const e=i[0].dims.length;if(e<1)throw new Error("Invalid input shape.");if(t<-e||t>e-1)throw new Error("Invalid axis.");if(p.NUMBER_TYPES.indexOf(i[0].type)===-1)throw new Error("Invaid input type.");if(i[1].type!=="int32"&&i[1].type!=="int16")throw new Error("Invaid input type.")}},4776:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseGemmAttributesV11=u.parseGemmAttributesV7=u.gemm=void 0;const g=b(246),p=b(2517),h=b(2039);u.gemm=(i,t,e)=>(s(t,e),[i.run(c(t,e),t)]);const o=(i,t)=>{const e=i.attributes.getInt("transA",0)!==0,n=i.attributes.getInt("transB",0)!==0,r=i.attributes.getFloat("alpha",1),a=i.attributes.getFloat("beta",1);return(0,g.createAttributeWithCacheKey)({transA:e,transB:n,alpha:r,beta:a,isOptionalC:t})};u.parseGemmAttributesV7=i=>o(i,!1),u.parseGemmAttributesV11=i=>o(i,!0);const c=(i,t)=>{const e={name:"Gemm",inputNames:i.length===3?["A","B","C"]:["A","B"],inputTypes:i.length===3?[h.TextureType.unpacked,h.TextureType.unpacked,h.TextureType.unpacked]:[h.TextureType.unpacked,h.TextureType.unpacked],key:t.cacheKey};return Object.assign(Object.assign({},e),{get:()=>f(e,i,t)})},f=(i,t,e)=>{const n=t[0].dims.slice(),r=t[1].dims.slice(),[a,l]=p.GemmUtil.getShapeOfGemmResult(n,e.transA,r,e.transB,t.length===3?t[2].dims:void 0),d=[a,l];if(!d)throw new Error("Can't use gemm on the given tensors");let m=n[n.length-1],y="";e.transA&&(m=n[0]),e.transA&&e.transB?y="value += _A_T(a) * _B_T(b);":e.transA&&!e.transB?y="value += _A_T(a) * _B(b);":!e.transA&&e.transB?y="value += _A(a) * _B_T(b);":e.transA||e.transB||(y="value += _A(a) * _B(b);");const v=d.length,_=` + float process(int indices[${v}]) { + int a[${v}]; + int b[${v}]; + ${t.length===3?`int c[${t[2].dims.length}];`:""} + + copyVec(indices, a); + copyVec(indices, b); + ${t.length===3?"bcastIndices_C(indices, c);":""} + + float value = 0.0; + for (int k=0; k<${m}; ++k) { + a[${v-1}] = k; + b[${v-2}] = k; + ${y} + } + + value = value * alpha; + ${t.length===3?"value += beta * _C(c);":""} + return value; + }`;return Object.assign(Object.assign({},i),{output:{dims:d,type:t[0].type,textureType:h.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:e.alpha},{name:"beta",type:"float",data:e.beta}],shaderSource:_})},s=(i,t)=>{if(!i)throw new Error("Input is missing");if(t.isOptionalC&&(i.length<2||i.length>3))throw new Error("Invaid input shape.");if(!t.isOptionalC&&i.length!==3)throw new Error("Gemm requires 3 inputs");if(i.length===3&&i[2].dims.length!==1&&i[2].dims.length!==2)throw new Error("Invalid input shape of C");if(i[0].type!=="float32"&&i[0].type!=="float64"||i[1].type!=="float32"&&i[1].type!=="float64"||i.length===3&&i[2].type!=="float32"&&i[2].type!=="float64")throw new Error("Invalid input type.");if(i[0].type!==i[1].type||i.length===3&&i[0].type!==i[2].type)throw new Error("Input types are mismatched")}},8555:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createPackedIm2ColProgramInfoLoader=void 0;const g=b(5060),p=b(2039),h=b(2827);u.createPackedIm2ColProgramInfoLoader=(o,c,f,s,i)=>{const t=(e=i.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[p.TextureType.packed],cacheHint:e});var e;return Object.assign(Object.assign({},t),{get:()=>((n,r,a,l,d,m)=>{const y=a.dims,v=l.dims,_=d.length,T=[v[1]*v[2]*v[3],d[2]*d[3]],S=v[2]*v[3],A=(0,h.unpackFromChannel)(),w=(0,g.getGlsl)(n.session.backend.glContext.version);let I="";for(let B=0;B<=1;B++)for(let j=0;j<=1;j++)I+=` + blockIndex = rc.x + ${j}; + pos = rc.y + ${B}; + + if(blockIndex < ${T[1]} && pos < ${T[0]}) { + offsetY = int(blockIndex / (${d[_-1]})) * ${m.strides[0]} - + ${m.pads[0]}; + d0 = offsetY + ${m.dilations[0]} * (imod(pos, ${S}) / ${v[2]}); + + if(d0 < ${y[2]} && d0 >= 0) { + offsetX = imod(blockIndex, ${d[_-1]}) * ${m.strides[1]} - + ${m.pads[1]}; + d1 = offsetX + ${m.dilations[1]} * imod(imod(pos, ${S}), ${v[2]}); + + if(d1 < ${y[3]} && d1 >= 0) { + + ch = int(float(pos)/ ${S}.); + innerDims = vec2(d0, d1); + result[${2*B+j}] = getChannel( + getA(0, ch, int(innerDims.x), + int(innerDims.y)), innerDims); + } + } + } + + `;const R=` + ${A} + + void main() { + ivec2 rc = getOutputCoords(); + vec4 result = vec4(0.0); + int blockIndex, pos, offsetY, d0, offsetX, d1, ch; + vec2 innerDims; + ${I} + ${w.output} = result; + } + `;return Object.assign(Object.assign({},r),{output:{dims:T,type:a.type,textureType:p.TextureType.packed},shaderSource:R,hasMain:!0})})(o,t,c,f,s,i)})}},3248:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.calculateIm2ColDims=u.createIm2ColProgramInfoLoader=void 0;const g=b(2039);u.createIm2ColProgramInfoLoader=(p,h,o,c,f)=>{const s=(i=f.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[g.TextureType.unpacked],cacheHint:i});var i;return Object.assign(Object.assign({},s),{get:()=>((t,e,n,r,a,l)=>{const d=n.dims,m=r.dims,y=a.length,v=(0,u.calculateIm2ColDims)(d,m,a,4),_=` + const int XC = ${d[1]}; + const int XH = ${d[2]}; + const int XW = ${d[3]}; + const int KH = ${l.kernelShape[0]}; + const int KW = ${l.kernelShape[1]}; + const int dilationH = ${l.dilations[0]}; + const int dilationW = ${l.dilations[1]}; + const int strideH = ${l.strides[0]}; + const int strideW = ${l.strides[1]}; + const int padH = ${l.pads[0]}; + const int padW = ${l.pads[1]}; + const int KHKW = KH*KW; + const int XCKHKW = XC * KHKW; + const int outputChannels = 4; + vec4 process(int indices[${y}]) { + int b = indices[0]; // batch size + int oh = indices[1] * strideH - padH; //output height + int ow = indices[2] * strideW - padW; //output width + int p = indices[3] * outputChannels; //patch + vec4 value = vec4(0.0); + for(int i=0; i < outputChannels; ++i) { + if(p < XCKHKW) { + int patchC = p / KHKW; + int patchH = (p - patchC*KHKW) / KW; + int patchW = (p - patchC*KHKW) - patchH * KW; + int xh2 = oh + patchH * dilationH; + int xw2 = ow + patchW * dilationW; + int x[${d.length}]; + x[0] = b; + x[1] = patchC; + x[2] = xh2; + x[3] = xw2; + if(xh2 >= 0 && + xh2 < XH && + xw2 >= 0 && + xw2 < XW) { + value[i] = _X(x); + } + } + ++p; + } + return value; + } + `;return Object.assign(Object.assign({},e),{output:{dims:v,type:n.type,textureType:g.TextureType.packedLastDimension},shaderSource:_})})(0,s,h,o,c,f)})},u.calculateIm2ColDims=(p,h,o,c=4)=>[o[0],o[2],o[3],Math.ceil(p[1]*h[2]*h[3]/c)]},6572:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseImageScalerAttributes=u.imageScaler=void 0;const g=b(246),p=b(2039);u.imageScaler=(s,i,t)=>(f(i),[s.run(o(s,i,t),i)]),u.parseImageScalerAttributes=s=>{const i=s.attributes.getFloat("scale"),t=s.attributes.getFloats("bias");return(0,g.createAttributeWithCacheKey)({scale:i,bias:t})};const h={name:"ImageScaler",inputNames:["X"],inputTypes:[p.TextureType.unpacked]},o=(s,i,t)=>{const e=Object.assign(Object.assign({},h),{cacheHint:t.cacheKey});return Object.assign(Object.assign({},e),{get:()=>((n,r,a,l)=>{const d=a[0].dims.slice(),m=d.length,y=` + ${c(l.bias.length)} + float process(int indices[${m}]) { + return _X(indices) * scale + getBias(bias, indices[1]); + }`;return Object.assign(Object.assign({},r),{output:{dims:d,type:a[0].type,textureType:p.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:l.bias.length,data:l.bias},{name:"scale",type:"float",data:l.scale}],shaderSource:y})})(0,e,i,t)})},c=s=>{const i=[`float getBias(float bias[${s}], int channel) {`];for(let t=0;t{if(!s||s.length!==1)throw new Error("ImageScaler requires 1 input.");if(s[0].dims.length!==4)throw new Error("Invalid input shape.");if(s[0].type!=="float32"&&s[0].type!=="float64")throw new Error("Invalid input type.")}},3346:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseInstanceNormalizationAttributes=u.instanceNormalization=void 0;const g=b(5060),p=b(2039);u.instanceNormalization=(i,t,e)=>{s(t);const n=i.run(o(t[0]),t);return[i.run(f(i,t[0],e,n.dims),[t[0],n,t[1],t[2]])]},u.parseInstanceNormalizationAttributes=i=>i.attributes.getFloat("epsilon",1e-5);const h={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[p.TextureType.unpacked]},o=i=>Object.assign(Object.assign({},h),{get:()=>((t,e)=>{const n=e.dims.slice(),r=n[1],a=n[2]*n[3],l=[n[0],r],d=` + vec4 process(int[2] indices) { + vec4 v = vec4(0.0); + int a[4]; + a[0] = indices[0]; + a[1] = indices[1]; + float temp = 0.0; + for(int a2=0; a2<${n[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${n[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += x; + } + } + float mean = temp / float(${a}); + temp = 0.0; + for(int a2=0; a2<${n[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${n[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += (x - mean) * (x - mean); + } + } + v.r = mean; + v.g = temp / float(${a}); + + return v; + }`;return Object.assign(Object.assign({},t),{output:{dims:l,type:e.type,textureType:p.TextureType.packedLastDimension},shaderSource:d})})(h,i)}),c={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[p.TextureType.unpacked,p.TextureType.packedLastDimension,p.TextureType.unpacked,p.TextureType.unpacked]},f=(i,t,e,n)=>{const r=Object.assign(Object.assign({},c),{cacheHint:`${e}`});return Object.assign(Object.assign({},r),{get:()=>((a,l,d,m,y)=>{const v=(0,g.getGlsl)(a.session.backend.glContext.version),[_,T]=a.calculateTextureWidthAndHeight(y,p.TextureType.packedLastDimension),[S,A]=[_/4,T],w=` + vec4 get_MeanAndVariance(int[2] mv) { + int offset = indicesToOffset_MeanAndVariance(mv); + vec2 coords = offsetToCoords(offset, ${S}, ${A}); + return ${v.texture2D}(MeanAndVariance, coords); + } + + float process(int[4] indices) { + int mv[2]; + mv[0] = indices[0]; + mv[1] = indices[1]; + vec4 mean_and_variance = get_MeanAndVariance(mv); + float mean = mean_and_variance.r; + float variance = mean_and_variance.g; + + int sb[1]; + sb[0] = indices[1]; + float scale = _Scale(sb); + float b = _B(sb); + + return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b; + }`;return Object.assign(Object.assign({},l),{output:{dims:d.dims,type:d.type,textureType:p.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:m}],shaderSource:w})})(i,r,t,e,n)})},s=i=>{if(!i||i.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const t=i[0],e=i[1],n=i[2];if(t.dims.length<3||e.dims.length!==1||n.dims.length!==1)throw new Error("Invalid input shape.");if(e.dims[0]!==t.dims[1]||n.dims[0]!==t.dims[1])throw new Error("Input shapes are mismatched.");if(t.type!=="float32"&&t.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||n.type!=="float32"&&n.type!=="float64")throw new Error("Invalid input type.");if(i[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},708:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createPackedMatmulProgramInfoLoader=void 0;const g=b(2517),p=b(5060),h=b(2039),o=b(9390),c=b(2823),f=b(5623);u.createPackedMatmulProgramInfoLoader=(s,i,t)=>{const e=(n=i.length>2,r=t.activationCacheKey,{name:"MatMul (packed)",inputNames:n?["A","B","Bias"]:["A","B"],inputTypes:n?[h.TextureType.packed,h.TextureType.packed,h.TextureType.packed]:[h.TextureType.packed,h.TextureType.packed],cacheHint:r});var n,r;return Object.assign(Object.assign({},e),{get:()=>((a,l,d,m)=>{const y=d.length>2,v=y?"value += getBiasForMatmul();":"",_=d[0].dims,T=d[1].dims,S=g.BroadcastUtil.calcShape(_,T,!0),A=!g.ShapeUtil.areEqual(d[0].dims,d[1].dims);if(!S)throw new Error("Can't use matmul on the given tensors");const w=_[_.length-1],I=Math.ceil(w/2),R=_.length,B=T.length,j=(0,p.getGlsl)(a.session.backend.glContext.version),N=(0,o.getCoordsDataType)(S.length),W=S.length,k=(0,o.getGlChannels)(),{activationFunction:V,applyActivation:J}=(0,c.getActivationSnippet)(m),Y=y?`${(0,f.getBiasForMatmul)(N,k,d[2].dims,S,!0)}`:"",te=A?`${function(Oe,le,xe,_e){let Ne=[],He=[];const Ae=xe[0].dims,Ce=xe[1].dims,Fe=Ae.length,Ee=Ce.length,we=_e.length,je=we-Fe,Ue=we-Ee;Ne=Ae.map((Se,Me)=>`coords.${le[Me+je]}`),Ne[Fe-1]="i*2",Ne.join(", "),He=Ce.map((Se,Me)=>`coords.${le[Me+Ue]}`),He[Ee-2]="i*2",He.join(", ");const Be=g.BroadcastUtil.getBroadcastDims(Ae,_e),We=g.BroadcastUtil.getBroadcastDims(Ce,_e),Ke=Be.map(Se=>`coords.${le[Se+je]} = 0;`).join(` +`),ze=We.map(Se=>`coords.${le[Se+Ue]} = 0;`).join(` +`),Ve=`int lastDim = coords.${le[we-1]}; + coords.${le[we-1]} = coords.${le[we-2]}; + coords.${le[we-2]} = lastDim;`;return` +vec4 getAAtOutCoordsMatmul(int i) { + ${Oe} coords = getOutputCoords(); + ${Ve} + ${Ke} + vec4 outputValue = getA(${Ne}); + return outputValue; +} + +vec4 getBAtOutCoordsMatmul(int i) { + ${Oe} coords = getOutputCoords(); + ${Ve} + ${ze} + vec4 outputValue = getB(${He}); + return outputValue; +}`}(N,k,d,S)}`:"",ne=A?"getAAtOutCoordsMatmul(i)":`getA(${function(Oe,le){let xe="";for(let _e=0;_e{Object.defineProperty(u,"__esModule",{value:!0}),u.getBiasForMatmul=u.createMatmulProgramInfoLoader=u.parseMatMulAttributes=u.matMul=void 0;const g=b(2517),p=b(2039),h=b(9390),o=b(2823),c=b(708);function f(t,e){const n=(r=t.length>2,a=e.activationCacheKey,{name:"MatMul",inputNames:r?["A","B","Bias"]:["A","B"],inputTypes:r?[p.TextureType.unpacked,p.TextureType.unpacked,p.TextureType.unpacked]:[p.TextureType.unpacked,p.TextureType.unpacked],cacheHint:a});var r,a;return Object.assign(Object.assign({},n),{get:()=>function(l,d,m){const y=d[0].dims,v=d[1].dims,_=g.BroadcastUtil.calcShape(y,v,!0);if(!_)throw new Error("Can't use matmul on the given tensors");const T=(0,h.getCoordsDataType)(_.length),S=(0,h.getGlChannels)(),{activationFunction:A,applyActivation:w}=(0,o.getActivationSnippet)(m),I=d.length>2,R=I?"value += getBiasForMatmul();":"",B=I?`${i(T,S,d[2].dims,_,!1)}`:"",j=_.length,N=y.length,W=v.length,k=` + ${A} + ${B} + float process(int indices[${j}]) { + int a[${N}]; + int b[${W}]; + bcastMatmulIndices_A(indices, a); + bcastMatmulIndices_B(indices, b); + + float value; + for (int k=0; k<${y[y.length-1]}; ++k) { + a[${N-1}] = k; + b[${W-2}] = k; + value += _A(a) * _B(b); + } + ${R} + ${w} + return value; + }`;return Object.assign(Object.assign({},l),{output:{dims:_,type:d[0].type,textureType:p.TextureType.unpacked},shaderSource:k})}(n,t,e)})}u.matMul=(t,e,n)=>(s(e),t.session.pack?[t.run((0,c.createPackedMatmulProgramInfoLoader)(t,e,n),e)]:[t.run(f(e,n),e)]),u.parseMatMulAttributes=t=>(0,o.parseInternalActivationAttributes)(t.attributes),u.createMatmulProgramInfoLoader=f;const s=t=>{if(!t||t.length!==2)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.");if(t[0].type!=="float32"&&t[0].type!=="float64"||t[1].type!=="float32"&&t[1].type!=="float64")throw new Error("inputs should be float type");if(t[0].type!==t[1].type)throw new Error("inputs types should match")};function i(t,e,n,r,a){let l="";const d=n.length,m=r.length,y=m-d;l=m<2&&d>0?"coords":n.map((T,S)=>`coords.${e[S+y]}`).join(", ");const v=g.BroadcastUtil.getBroadcastDims(n,r).map(T=>`coords.${e[T+y]} = 0;`).join(` +`);let _="vec4(outputValue.xx, outputValue.yy)";return g.ShapeUtil.size(n)===1&&(_="vec4(outputValue.x)"),a?` +vec4 getBiasForMatmul() { + ${t} coords = getOutputCoords(); + ${v} + vec4 outputValue = getBias(${l}); + return ${_}; +}`:` +float getBiasForMatmul() { + ${t} coords = getOutputCoords(); + ${v} + return getBias(coords.x); +}`}u.getBiasForMatmul=i},2403:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createPackProgramInfoLoader=void 0;const g=b(5060),p=b(2039),h=b(9390),o=b(2827),c={name:"pack",inputNames:["A"],inputTypes:[p.TextureType.unpackedReversed]};u.createPackProgramInfoLoader=(f,s)=>Object.assign(Object.assign({},c),{get:()=>((i,t)=>{const e=(0,g.getGlsl)(i.session.backend.glContext.version),n=t.dims,r=n.length,a=t.dims.length,l=(0,h.getCoordsDataType)(a),d=(0,o.getChannels)("rc",a),m=(y=a,v=d,_=n[n.length-2],T=n[n.length-1],y===0||y===1?"":` + int r = ${v[y-2]}; + int c = ${v[y-1]}; + int rp1 = ${v[y-2]} + 1; + int cp1 = ${v[y-1]} + 1; + bool rEdge = rp1 >= ${T}; + bool cEdge = cp1 >= ${_}; + `);var y,v,_,T;let S;S=r===0?[1,1]:r===1?[n[0],1]:[n[a-1],n[a-2]];const A=function(R,B,j){if(R===0)return"false";if(R===1)return`rc > ${B[0]}`;let N="";for(let W=R-2;W= ${B[W-R+2]}`,W= ${R[0]} ? 0. : getA(rc + 1), + 0, 0`;let N="";if(j>2)for(let W=0;W{Object.defineProperty(u,"__esModule",{value:!0}),u.unpackFromChannel=u.getChannels=u.getVecChannels=void 0;const g=b(9390);function p(h,o){return(0,g.getGlChannels)(o).map(c=>`${h}.${c}`)}u.getVecChannels=p,u.getChannels=function(h,o){return o===1?[h]:p(h,o)},u.unpackFromChannel=function(){return` + float getChannel(vec4 frag, int dim) { + int modCoord = imod(dim, 2); + return modCoord == 0 ? frag.r : frag.g; + } + + float getChannel(vec4 frag, vec2 innerDims) { + vec2 modCoord = mod(innerDims, 2.); + return modCoord.x == 0. ? + (modCoord.y == 0. ? frag.r : frag.g) : + (modCoord.y == 0. ? frag.b : frag.a); + } + `}},2870:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parsePadAttributesV11=u.padV11=u.parsePadAttributesV2=u.padV2=void 0;const g=b(246),p=b(2517),h=b(5060),o=b(2039),c={name:"Pad",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};u.padV2=(l,d,m)=>(i(d),[l.run(Object.assign(Object.assign({},c),{cacheHint:m.cacheKey,get:()=>s(l,d[0],m)}),d)]),u.parsePadAttributesV2=l=>{const d=l.attributes.getString("mode","constant"),m=l.attributes.getFloat("value",0),y=l.attributes.getInts("pads");return(0,g.createAttributeWithCacheKey)({mode:d,value:m,pads:y})},u.padV11=(l,d,m)=>{t(d);const y=f(l,d,m);return(0,u.padV2)(l,[d[0]],y)},u.parsePadAttributesV11=l=>l.attributes.getString("mode","constant");const f=(l,d,m)=>{if(!l.session.isInitializer(d[1].dataId)||d.length>=3&&!l.session.isInitializer(d[2].dataId))throw new Error("dynamic pad attributes are not allowed");const y=Array.from(d[1].integerData),v=d.length>=3?d[2].floatData[0]:0;return(0,g.createAttributeWithCacheKey)({mode:m,pads:y,value:v})},s=(l,d,m)=>{const y=p.ShapeUtil.padShape(d.dims.slice(),m.pads),v=y.length,_=` + ${e(l,d,m)} + float process(int[${v}] indices) { + return padA(indices); + }`;return{name:"Pad",inputNames:["A"],inputTypes:[o.TextureType.unpacked],output:{dims:y,type:d.type,textureType:o.TextureType.unpacked},shaderSource:_}},i=l=>{if(!l||l.length!==1)throw new Error("Pad requires 1 input");if(l[0].type!=="float32"&&l[0].type!=="float64")throw new Error("Invalid input type.")},t=l=>{if(!l||l.length!==2&&l.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(l[1].type!=="int32")throw new Error("Invalid input type.");if(l.length>=3&&l[2].type==="string")throw new Error("Invalid input type.")},e=(l,d,m)=>{const y=(0,h.getGlsl)(l.session.backend.glContext.version),[v,_]=l.calculateTextureWidthAndHeight(d.dims,o.TextureType.unpacked),T=p.ShapeUtil.computeStrides(d.dims);switch(m.mode){case"constant":return n(y,d.dims,T,v,_,m.pads,m.value);case"reflect":return r(y,d.dims,T,v,_,m.pads);case"edge":return a(y,d.dims,T,v,_,m.pads);default:throw new Error("Invalid mode")}},n=(l,d,m,y,v,_,T)=>{const S=d.length;let A="";for(let w=S-1;w>=0;--w)A+=` + k = m[${w}] - ${_[w]}; + if (k < 0) return constant; + if (k >= ${d[w]}) return constant; + offset += k * ${m[w]}; + `;return` + float padA(int m[${S}]) { + const float constant = float(${T}); + int offset = 0; + int k = 0; + ${A} + vec2 coords = offsetToCoords(offset, ${y}, ${v}); + float value = getColorAsFloat(${l.texture2D}(A, coords)); + return value; + } + `},r=(l,d,m,y,v,_)=>{const T=d.length;let S="";for(let A=T-1;A>=0;--A)S+=` + k = m[${A}] - ${_[A]}; + if (k < 0) { k = -k; } + { + const int _2n_1 = ${2*(d[A]-1)}; + k = int( mod( float(k), float(_2n_1) ) ) ; + if(k >= ${d[A]}) { k = _2n_1 - k; } + } + offset += k * ${m[A]}; + `;return` + float padA(int m[${T}]) { + int offset = 0; + int k = 0; + ${S} + vec2 coords = offsetToCoords(offset, ${y}, ${v}); + float value = getColorAsFloat(${l.texture2D}(A, coords)); + return value; + } + `},a=(l,d,m,y,v,_)=>{const T=d.length;let S="";for(let A=T-1;A>=0;--A)S+=` + k = m[${A}] - ${_[A]}; + if (k < 0) k = 0; + if (k >= ${d[A]}) k = ${d[A]-1}; + offset += k * ${m[A]}; + `;return` + float padA(int m[${T}]) { + int offset = 0; + int k = 0; + ${S} + vec2 coords = offsetToCoords(offset, ${y}, ${v}); + float value = getColorAsFloat(${l.texture2D}(A, coords)); + return value; + } + `}},2143:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.globalMaxPool=u.parseMaxPoolAttributes=u.maxPool=u.parseGlobalAveragePoolAttributes=u.globalAveragePool=u.parseAveragePoolAttributes=u.averagePool=void 0;const g=b(246),p=b(2517),h=b(2039);u.averagePool=(a,l,d)=>{t(l);const m={name:"AveragePool",inputNames:["X"],inputTypes:[h.TextureType.unpacked],cacheHint:d.cacheKey};return[a.run(Object.assign(Object.assign({},m),{get:()=>o(l,m,!1,d)}),l)]},u.parseAveragePoolAttributes=a=>{const l=a.attributes.getString("auto_pad","NOTSET"),d=a.attributes.getInt("ceil_mode",0),m=a.attributes.getInt("count_include_pad",0)!==0,y=a.attributes.getInts("kernel_shape"),v=a.attributes.getInts("strides",[]),_=a.attributes.getInts("pads",[]);if(d!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,g.createAttributeWithCacheKey)({autoPad:l,ceilMode:d,countIncludePad:m,kernelShape:y,strides:v,pads:_})};const o=(a,l,d,m)=>{const[y,v]=f(a,m,d),_=p.ShapeUtil.size(y.kernelShape);let T="";y.countIncludePad?T+=`value /= float(${_});`:T+=`value /= float(${_} - pad);`;const S=` + ${e(a[0].dims,y,"value += _X(x);",T,"0.0")} + `;return Object.assign(Object.assign({},l),{output:{dims:v,type:a[0].type,textureType:h.TextureType.unpacked},shaderSource:S})};u.globalAveragePool=(a,l,d)=>{t(l);const m={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[h.TextureType.unpacked],cacheHint:`${d.countIncludePad}`};return[a.run(Object.assign(Object.assign({},m),{get:()=>o(l,m,!0,d)}),l)]},u.parseGlobalAveragePoolAttributes=a=>{const l=a.attributes.getInt("count_include_pad",0)!==0;return(0,g.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:l,kernelShape:[],strides:[],pads:[]})},u.maxPool=(a,l,d)=>{t(l);const m={name:"MaxPool",inputNames:["X"],inputTypes:[h.TextureType.unpacked],cacheHint:d.cacheKey};return[a.run(Object.assign(Object.assign({},m),{get:()=>c(l,m,!1,d)}),l)]},u.parseMaxPoolAttributes=a=>{const l=a.attributes.getString("auto_pad","NOTSET"),d=a.attributes.getInt("ceil_mode",0),m=a.attributes.getInts("kernel_shape"),y=a.attributes.getInts("strides",[]),v=a.attributes.getInts("pads",[]),_=a.attributes.getInt("storage_order",0),T=a.attributes.getInts("dilations",[]);if(_!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(d!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,g.createAttributeWithCacheKey)({autoPad:l,ceilMode:d,countIncludePad:!1,kernelShape:m,strides:y,pads:v,storageOrder:_,dilations:T})};const c=(a,l,d,m)=>{const[y,v]=f(a,m,d),_=` + ${e(a[0].dims,y,` + value = max(_X(x), value); + `,"","-1e5")} + `;return Object.assign(Object.assign({},l),{output:{dims:v,type:a[0].type,textureType:h.TextureType.unpacked},shaderSource:_})},f=(a,l,d)=>{const m=a[0].dims.slice(),y=Object.hasOwnProperty.call(l,"dilations"),v=l.kernelShape.slice(),_=l.strides.slice(),T=y?l.dilations.slice():[],S=l.pads.slice();p.PoolConvUtil.adjustPoolAttributes(d,m,v,_,T,S);const A=p.PoolConvUtil.computePoolOutputShape(d,m,_,T,v,S,l.autoPad),w=Object.assign({},l);return y?Object.assign(w,{kernelShape:v,strides:_,pads:S,dilations:T,cacheKey:l.cacheKey}):Object.assign(w,{kernelShape:v,strides:_,pads:S,cacheKey:l.cacheKey}),[w,A]},s={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},i={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[h.TextureType.unpacked]};u.globalMaxPool=(a,l)=>(t(l),[a.run(Object.assign(Object.assign({},i),{get:()=>c(l,i,!0,s)}),l)]);const t=a=>{if(!a||a.length!==1)throw new Error("Pool ops requires 1 input.");if(a[0].type!=="float32"&&a[0].type!=="float64")throw new Error("Invalid input type.")},e=(a,l,d,m,y)=>{const v=a.length;if(l.kernelShape.length<=2){const _=l.kernelShape[l.kernelShape.length-1],T=l.strides[l.strides.length-1],S=l.pads[l.pads.length/2-1],A=l.pads[l.pads.length-1],w=a[v-1];let I="",R="",B="";if(I=S+A!==0?` + for (int i = 0; i < ${_}; i++) { + x[${v} - 1] = indices[${v} - 1] * ${T} - ${S} + i; + if (x[${v} - 1] < 0 || x[${v} - 1] >= ${w}) { + pad++; + continue; + } + ${d} + }`:` + for (int i = 0; i < ${_}; i++) { + x[${v} - 1] = indices[${v} - 1] * ${T} - ${S} + i; + ${d} + }`,l.kernelShape.length===2){const j=l.kernelShape[l.kernelShape.length-2],N=l.strides[l.strides.length-2],W=l.pads[l.pads.length/2-2],k=l.pads[l.pads.length-2],V=a[v-2];R=W+k!==0?` + for (int j = 0; j < ${j}; j++) { + x[${v} - 2] = indices[${v} - 2] * ${N} - ${W} + j; + if (x[${v} - 2] < 0 || x[${v} - 2] >= ${V}) { + pad+= ${_}; + continue; + } + `:` + for (int j = 0; j < ${j}; j++) { + x[${v} - 2] = indices[${v} - 2] * ${N} - ${W} + j; + `,B=` + } + `}return` + float process(int indices[${v}]) { + int x[${v}]; + copyVec(indices, x); + + float value = ${y}; + int pad = 0; + ${R} + ${I} + ${B} + ${m} + return value; + } + `}{const _=p.ShapeUtil.size(l.kernelShape),T=p.ShapeUtil.computeStrides(l.kernelShape),S=T.length,A=l.pads.length,w=r(S),I=n(a,"inputDims"),R=n(l.pads,"pads"),B=n(T,"kernelStrides"),j=n(l.strides,"strides");let N="";return N=l.pads.reduce((W,k)=>W+k)?` + if (x[j] >= inputDims[j] || x[j] < 0) { + pad++; + isPad = true; + break; + } + } + if (!isPad) { + ${d} + }`:` + } + ${d} + `,` + ${w} + float process(int indices[${v}]) { + int x[${v}]; + copyVec(indices, x); + int offset[${S}]; + int pads[${A}]; + int inputDims[${v}]; + int kernelStrides[${S}]; + int strides[${S}]; + ${R} + ${I} + ${j} + ${B} + + float value = ${y}; + int pad = 0; + bool isPad = false; + for (int i = 0; i < ${_}; i++) { + offsetToIndices(i, kernelStrides, offset); + isPad = false; + for (int j = ${v} - ${S}; j < ${v}; j++) { + x[j] = indices[j] * strides[j - ${v} + ${S}] + + offset[j - ${v} + ${S}] - pads[j - 2]; + ${N} + } + ${m} + + return value; + } + `}},n=(a,l)=>{let d="";for(let m=0;m` + void offsetToIndices(int offset, int[${a}] strides, out int[${a}] indices) { + if (${a} == 0) { + return; + } + for (int i = 0; i < ${a} - 1; ++i) { + indices[i] = offset / strides[i]; + offset -= indices[i] * strides[i]; + } + indices[${a} - 1] = offset; + }`},4939:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.reduceLogSumSquare=u.reduceLogSum=u.reduceProd=u.reduceMin=u.reduceMax=u.reduceMean=u.reduceSum=u.parseReduceAttributes=void 0;const g=b(246),p=b(782),h=b(2517),o=b(2039),c=(i,t,e,n,r)=>{s(t);const a={name:n,inputNames:["A"],inputTypes:[o.TextureType.unpacked]};return[i.run(Object.assign(Object.assign({},a),{cacheHint:e.cacheKey,get:()=>f(i,t,e,n,r,a)}),t)]};u.parseReduceAttributes=i=>{const t=i.attributes.getInts("axes",[]),e=i.attributes.getInt("keepdims",1)===1;return(0,g.createAttributeWithCacheKey)({axes:t,keepDims:e})};const f=(i,t,e,n,r,a)=>{const l=[],d=t[0].dims.length||1,m=[],y=h.ShapeUtil.normalizeAxes(e.axes,t[0].dims.length),v=r(t,y);let _=v[1];for(let S=0;S=0||y.length===0?(e.keepDims&&l.push(1),_=` + for(int j${S} = 0; j${S} < ${t[0].dims[S]}; j${S}++) { + inputIdx[${S}] = j${S}; + ${_} + }`):(m.push(`inputIdx[${S}] = outputIdx[${l.length}];`),l.push(t[0].dims[S]));const T=` + float process(int outputIdx[${l.length||1}]) { + float value; // final result + int inputIdx[${d}]; // addressing input data + ${m.join(` +`)} + ${v[0]} // init ops for reduce max/min + ${_} + ${v[2]} // final computation for reduce mean + return value; + }`;return Object.assign(Object.assign({},a),{output:{dims:l,type:t[0].type,textureType:o.TextureType.unpacked},shaderSource:T})},s=i=>{if(!i||i.length!==1)throw new Error("Reduce op requires 1 input.");if(p.NUMBER_TYPES.indexOf(i[0].type)===-1)throw new Error("Invalid input type.")};u.reduceSum=(i,t,e)=>c(i,t,e,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),u.reduceMean=(i,t,e)=>c(i,t,e,"ReduceMean",(n,r)=>{let a=1;for(let l=0;l=0||r.length===0)&&(a*=n[0].dims[l]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${a}.;`]}),u.reduceMax=(i,t,e)=>c(i,t,e,"ReduceMax",(n,r)=>{const a=[];for(let l=0;l=0||r.length===0)&&a.push(`inputIdx[${l}] = 0;`);return[`${a.join(` +`)} +value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),u.reduceMin=(i,t,e)=>c(i,t,e,"ReduceMin",(n,r)=>{const a=[];for(let l=0;l=0||r.length===0)&&a.push(`inputIdx[${l}] = 0;`);return[`${a.join(` +`)} +value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),u.reduceProd=(i,t,e)=>c(i,t,e,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),u.reduceLogSum=(i,t,e)=>c(i,t,e,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),u.reduceLogSumSquare=(i,t,e)=>c(i,t,e,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7019:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.isReshapeCheap=u.processDims3D=u.createPackedReshape3DProgramInfoLoader=void 0;const g=b(2517),p=b(5060),h=b(2039),o=b(2827);u.createPackedReshape3DProgramInfoLoader=(c,f,s)=>{const i=(t=>({name:"Reshape (packed)",inputTypes:[h.TextureType.packed],inputNames:["A"],cacheHint:`${t}`}))(s);return Object.assign(Object.assign({},i),{get:()=>((t,e,n,r)=>{const a=e.dims,l=r;let d="";for(let v=0;v<4;v++){let _="";switch(v){case 0:_="outputCoords = rc;";break;case 1:_="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:_="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:_="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}d+=` + ${_} + ${v>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""} + int flattenedIndex = getFlattenedIndex(outputCoords); + + ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex); + vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z)); + + result[${v}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); + + ${v>0?"}":""} + `}const m=(0,p.getGlsl)(t.session.backend.glContext.version),y=` + ${function(v){const _=g.ShapeUtil.computeStrides(v),T=["b","r","c"],S="index";return` + ivec3 inputCoordsFromReshapedOutCoords(int index) { + ${_.map((A,w)=>`int ${T[w]} = ${S} / ${A}; ${w===_.length-1?`int ${T[w+1]} = ${S} - ${T[w]} * ${A}`:`index -= ${T[w]} * ${A}`};`).join("")} + return ivec3(b, r, c); + } + `}(a)} + ${function(v){const _=g.ShapeUtil.computeStrides(v);return` + int getFlattenedIndex(ivec3 coords) { + // reverse y, z order + return coords.x * ${_[0]} + coords.z * ${_[1]} + coords.y; + } +`}(l)} + ${(0,o.unpackFromChannel)()} + + void main() { + ivec3 rc = getOutputCoords(); + + vec4 result = vec4(0.0); + + ivec3 outputCoords; + int rows = ${l[2]}; + int cols = ${l[1]}; + + ${d} + ${m.output} = result; + } + `;return Object.assign(Object.assign({},n),{output:{dims:l,type:e.type,textureType:h.TextureType.packed},shaderSource:y,hasMain:!0})})(c,f,i,s)})},u.processDims3D=function(c){if(c.length===0)return[1,1,1];let f=1;for(let s=0;s1?c[c.length-2]:1,c[c.length-1]]},u.isReshapeCheap=function(c,f){let s=!1;return s=c.length===0||f.length===0||(c.length<2||f.length<2?c[c.length-1]===f[f.length-1]:c[c.length-1]===f[f.length-1]&&c[c.length-2]===f[f.length-2]),s}},718:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.reshape=void 0;const g=b(2517);u.reshape=(p,h)=>{const o=g.ShapeUtil.calculateReshapedDims(h[0].dims,h[1].integerData);return p.session.pack?[p.reshapePacked(h[0],o)]:[p.reshapeUnpacked(h[0],o)]}},2268:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseResizeAttributesV11=u.parseResizeAttributesV10=u.resize=void 0;const g=b(5060),p=b(2039),h=b(9390),o=b(2827),c=b(9793),f={name:"Resize",inputNames:["A"],inputTypes:[p.TextureType.packed]};u.resize=(n,r,a)=>((0,c.validateInputs)(r,a),[n.run(Object.assign(Object.assign({},f),{cacheHint:a.cacheKey,get:()=>s(n,r,a)}),r)]),u.parseResizeAttributesV10=n=>(0,c.parseUpsampleAttributes)(n,10),u.parseResizeAttributesV11=n=>(0,c.parseUpsampleAttributes)(n,11);const s=(n,r,a)=>{const l=(0,g.getGlsl)(n.session.backend.glContext.version),[d,m]=i(r,a);if(d.every(N=>N===1)&&a.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},f),{output:{dims:m,type:r[0].type,textureType:p.TextureType.packed},hasMain:!0,shaderSource:`void main() { + vec4 v = ${l.texture2D}(X, TexCoords); + ${l.output} = v; + }`});const y=m.length;if(y<2)throw new Error(`output dimension should be at least 2, but got ${y}`);const v=m[y-2],_=m[y-1],T=r[0].dims;if(y!==T.length)throw new Error(`output dimension should match input ${T.length}, but got ${y}`);const S=T[y-2],A=T[y-1],w=d[y-2],I=d[y-1];let R="";if(a.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${a.mode}'`);switch(a.coordinateTransformMode){case"asymmetric":R=` + vec4 getSourceFracIndex(ivec4 coords) { + return vec4(coords) / scaleWHWH; + } + `;break;case"half_pixel":R=` + vec4 getSourceFracIndex(ivec4 coords) { + return (vec4(coords) + 0.5) / scaleWHWH - 0.5; + } + `;break;case"pytorch_half_pixel":R=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 fcoords = vec4(coords); + return vec4( + ${_}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, + ${v}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, + ${_}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, + ${v}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 + ); + } + `;break;case"align_corners":R=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 resized = vec4(${_}.0 - 1.0, ${v}.0 - 1.0, ${_}.0 - 1.0, + ${v}.0 - 1.0); + vec4 original = vec4(${A}.0 - 1.0, ${S}.0 - 1.0, ${A}.0 - 1.0, + ${S}.0 - 1.0); + vec4 new_scale = original / resized; + return vec4(coords) * new_scale; + } + `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${a.coordinateTransformMode}'`)}const B=(0,h.getCoordsDataType)(y),j=` + const vec2 inputWH = vec2(${S}.0, ${A}.0); + const vec4 scaleWHWH = vec4(float(${w}), float(${I}), float(${w}), float(${I})); + ${(0,o.unpackFromChannel)()} + ${R} + float getAValue(int x10, int r, int c, int d) { + return getChannel(getA(x10, r, c, d), vec2(c, d)); + } + void main() { + ${B} rc = getOutputCoords(); + + int batch = rc[0]; + int depth = rc[1]; + + // retrieve the 4 coordinates that is used in the 4 packed output values. + ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1); + + // calculate the source index in fraction + vec4 sourceFrac = getSourceFracIndex(coords); + + // get the lower and upper bound of the 4 values that will be packed into one texel. + ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy))); + ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw))); + ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy))); + ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw))); + + bool hasNextRow = rc.w < ${v-1}; + bool hasNextCol = rc.z < ${_-1}; + + // pack x00, x01, x10, x11's top-left corner into one vec4 structure + vec4 topLeft = vec4( + getAValue(batch, depth, x00.x, x00.y), + hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0); + + // pack x00, x01, x10, x11's top-right corner into one vec4 structure + vec4 topRight = vec4( + getAValue(batch, depth, x00.x, x00.w), + hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0); + + // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure + vec4 bottomLeft = vec4( + getAValue(batch, depth, x00.z, x00.y), + hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0); + + // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure + vec4 bottomRight = vec4( + getAValue(batch, depth, x00.z, x00.w), + hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0); + + // calculate the interpolation fraction on u and v direction + vec4 frac = vec4(sourceFrac) - floor(sourceFrac); + vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0)); + + vec4 top = mix(topLeft, topRight, clampFrac.ywyw); + vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw); + vec4 newValue = mix(top, bottom, clampFrac.xxzz); + + ${l.output} = vec4(newValue); + } + `;return Object.assign(Object.assign({},f),{output:{dims:m,type:r[0].type,textureType:p.TextureType.packed},hasMain:!0,shaderSource:j})},i=(n,r)=>{const a=n[0].dims;let l,d=r.scales;if(d.length===0){const y=n[r.scalesInputIdx];if(y&&y.size!==0){if(n[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");d=t(y,r.mode,r.isResize)}else{const v=n[r.sizesInputIdx];if(!v||v.size===0)throw new Error("Either scales or sizes MUST be provided as input.");l=Array.from(v.integerData),d=e(l,a,r.mode,r.isResize)}}else if(n[r.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const m=l||a.map((y,v)=>Math.floor(y*d[v]));return[d,m]},t=(n,r,a)=>{const l=Array.from(n.floatData);return(0,c.scalesValidation)(l,r,a),l},e=(n,r,a,l)=>{const d=r.length,m=new Array(d);for(let y=0,v=d;y{Object.defineProperty(u,"__esModule",{value:!0}),u.shape=void 0;const g=b(9162);u.shape=(h,o)=>(p(o),[new g.Tensor([o[0].dims.length],"int32",void 0,void 0,new Int32Array(o[0].dims))]);const p=h=>{if(!h||h.length!==1)throw new Error("Shape requires 1 input.")}},2278:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.sliceV10=u.parseSliceAttributes=u.slice=void 0;const g=b(246),p=b(782),h=b(2517),o=b(2039),c={name:"Slice",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};u.slice=(e,n,r)=>(s(n),[e.run(Object.assign(Object.assign({},c),{cacheHint:r.cacheKey,get:()=>f(e,n[0],r)}),n)]),u.parseSliceAttributes=e=>{const n=e.attributes.getInts("starts"),r=e.attributes.getInts("ends"),a=e.attributes.getInts("axes",[]);return(0,g.createAttributeWithCacheKey)({starts:n,ends:r,axes:a})};const f=(e,n,r)=>{const a=r.axes.length===0?n.dims.slice(0).map((T,S)=>S):r.axes,l=h.ShapeUtil.normalizeAxes(a,n.dims.length),d=r.starts.map((T,S)=>T>n.dims[l[S]]-1?n.dims[l[S]]:h.ShapeUtil.normalizeAxis(T,n.dims[l[S]])),m=r.ends.map((T,S)=>T>n.dims[l[S]]-1?n.dims[l[S]]:h.ShapeUtil.normalizeAxis(T,n.dims[l[S]])),y=n.dims.slice(),v=[];for(let T=0;T0&&v.push(`outputIdx[${l[T]}] += ${d[T]};`);const _=` + float process(int outputIdx[${y.length}]) { + ${v.join(` + `)} + return _A(outputIdx); + }`;return Object.assign(Object.assign({},c),{output:{dims:y,type:n.type,textureType:o.TextureType.unpacked},shaderSource:_})},s=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(p.NUMBER_TYPES.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")};u.sliceV10=(e,n)=>{t(n);const r=i(e,n);return[e.run(Object.assign(Object.assign({},c),{cacheHint:r.cacheKey,get:()=>f(e,n[0],r)}),[n[0]])]};const i=(e,n)=>{if(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)||n.length>=4&&!e.session.isInitializer(n[3].dataId)||n.length>=5&&!e.session.isInitializer(n[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(n.length>=5&&n[4].integerData.some(d=>d!==1))throw new Error("currently non-1 steps is not supported for Slice");const r=Array.from(n[1].integerData),a=Array.from(n[2].integerData),l=n.length>=4?Array.from(n[3].integerData):[];return{starts:r,ends:a,axes:l,cacheKey:`${l};${r};${a}`}},t=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}},5524:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.softmaxV13=u.parseSoftmaxAttributesV13=u.parseSoftmaxAttributes=u.softmax=void 0;const g=b(246),p=b(2517),h=b(5060),o=b(2039),c=b(3738),f={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[o.TextureType.unpacked]},s={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[o.TextureType.unpacked,o.TextureType.unpacked]},i={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]};u.softmax=(l,d,m)=>{a(d);const y=d[0].dims.slice(),v=p.ShapeUtil.normalizeAxis(m.axis,y.length),_=p.ShapeUtil.sizeToDimension(y,v),T=p.ShapeUtil.sizeFromDimension(y,v);return t(l,d,m,_,T)},u.parseSoftmaxAttributes=l=>(0,g.createAttributeWithCacheKey)({axis:l.attributes.getInt("axis",1)}),u.parseSoftmaxAttributesV13=l=>(0,g.createAttributeWithCacheKey)({axis:l.attributes.getInt("axis",-1)}),u.softmaxV13=(l,d,m)=>{a(d);const y=d[0].dims.slice(),v=p.ShapeUtil.normalizeAxis(m.axis,y.length),_=y.length,T=v!==_-1,S=[];let A,w=[],I=[];T&&(w=Array.from({length:_}).map((N,W)=>W),w[v]=_-1,w[_-1]=v,w.map(N=>S.push(y[N])),A=(0,g.createAttributeWithCacheKey)({perm:w}),I=(0,c.transpose)(l,d,A));const R=T?p.ShapeUtil.sizeToDimension(S,_-1):p.ShapeUtil.sizeToDimension(y,_-1),B=T?p.ShapeUtil.sizeFromDimension(S,_-1):p.ShapeUtil.sizeFromDimension(y,_-1),j=t(l,T?I:d,m,R,B);return T?(0,c.transpose)(l,j,A):j};const t=(l,d,m,y,v)=>{const _=e(l,d[0],y,v,[y]),T=l.run(Object.assign(Object.assign({},f),{cacheHint:m.cacheKey,get:()=>_}),d),S=n(l,d[0],y,v,_.output.dims,[y]),A=l.run(Object.assign(Object.assign({},s),{cacheHint:m.cacheKey,get:()=>S}),[d[0],T]),w=r(l,d[0],y,v,_.output.dims,S.output.dims);return[l.run(Object.assign(Object.assign({},i),{cacheHint:m.cacheKey,get:()=>w}),[d[0],T,A])]},e=(l,d,m,y,v)=>{const[_,T]=l.calculateTextureWidthAndHeight(d.dims,o.TextureType.unpacked),S=v.length;if(m<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1)throw new Error("Dimensionality of the output should be 1");if(v[0]!==m)throw new Error("Shape of the output should be equal to logical row count");const A=(0,h.getGlsl)(l.session.backend.glContext.version),w=` + float process(int[${S}] indices) { + int logical_row_start_offset = indices[0] * ${y}; + + float max = getColorAsFloat(${A.texture2D}(A, offsetToCoords(logical_row_start_offset, ${_}, + ${T} ))); + for(int i=1; i<${y}; ++i) + { + float current = getColorAsFloat(${A.texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${_}, ${T}))); + if(current > max) + max = current; + } + + return max; + }`;return Object.assign(Object.assign({},f),{output:{dims:v,type:d.type,textureType:o.TextureType.unpacked},shaderSource:w})},n=(l,d,m,y,v,_)=>{const[T,S]=l.calculateTextureWidthAndHeight(d.dims,o.TextureType.unpacked),A=_.length;if(m<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(_.length!==1)throw new Error("Dimensionality of the output should be 1");if(_[0]!==m)throw new Error("Shape of the output should be equal to logical row count");if(v.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(v[0]!==m)throw new Error("Shape of the intermediate results should be equal to logical row count");const w=` + float process(int[${A}] indices) { + int logical_row_start_offset = indices[0] * ${y}; + + float norm_factor = 0.0; + float max = _Max(indices); + for(int i=0; i<${y}; ++i) + { + norm_factor += exp(getColorAsFloat(${(0,h.getGlsl)(l.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${T}, ${S}))) - max); + } + + return norm_factor; + }`;return Object.assign(Object.assign({},s),{output:{dims:_,type:d.type,textureType:o.TextureType.unpacked},shaderSource:w})},r=(l,d,m,y,v,_)=>{const[T,S]=l.calculateTextureWidthAndHeight(d.dims,o.TextureType.unpacked),A=d.dims.length;if(m<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1||_.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(v[0]!==m||_[0]!==m)throw new Error("Shape of the intermediate results should be equal to logical row count");const w=` + float process(int[${A}] indices) { + + // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) + int offset = coordsToOffset(TexCoords, ${T}, ${S}); + + //determine the logical row for this index + int logical_row_index[1]; + logical_row_index[0] = offset / ${y}; + + float norm_factor = _Norm(logical_row_index); + + // avoid possible division by 0 + // if norm_facor is 0, all elements are zero + // if so, return 0 + if(norm_factor == 0.0) + return 0.0; + + return exp(_A(indices) - _Max(logical_row_index)) / norm_factor; + }`;return Object.assign(Object.assign({},i),{output:{dims:d.dims,type:d.type,textureType:o.TextureType.unpacked},shaderSource:w})},a=l=>{if(!l||l.length!==1)throw new Error("Softmax requires 1 input.");if(l[0].type!=="float32"&&l[0].type!=="float64")throw new Error("Invalid input type")}},5975:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseSplitAttributes=u.split=void 0;const g=b(246),p=b(2517),h=b(2039),o={name:"Split",inputNames:["A"],inputTypes:[h.TextureType.unpacked]};u.split=(i,t,e)=>{s(t);const n=p.ShapeUtil.normalizeAxis(e.axis,t[0].dims.length),r=c(i,t,n,e),a=[];for(let l=0;lf(i,t[0],e,n,l)}),t));return a},u.parseSplitAttributes=i=>{const t=i.attributes.getInt("axis",0),e=i.attributes.getInts("split",[]),n=i.outputs.length;return(0,g.createAttributeWithCacheKey)({axis:t,split:e,numOutputs:n})};const c=(i,t,e,n)=>{const[,r]=p.SplitUtil.splitShape(t[0].dims,e,n.split,n.numOutputs);return r.length},f=(i,t,e,n,r)=>{const[a,l]=p.SplitUtil.splitShape(t.dims,n,e.split,e.numOutputs),d=l[r],m=a[r],y=` + float process(int indices[${m.length}]) { + indices[${n}] += ${d}; + return _A(indices); + } + `;return Object.assign(Object.assign({},o),{cacheHint:`${e.cacheKey}:${r}`,output:{dims:m,type:t.type,textureType:h.TextureType.unpacked},shaderSource:y})},s=i=>{if(!i||i.length!==1)throw new Error("Split requires one input.");if(i[0].type!=="int8"&&i[0].type!=="uint8"&&i[0].type!=="int16"&&i[0].type!=="uint16"&&i[0].type!=="int32"&&i[0].type!=="uint32"&&i[0].type!=="float32"&&i[0].type!=="float64"&&i[0].type!=="bool")throw new Error("Invalid input type.")}},3933:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseSqueezeAttributes=u.squeezeV13=u.squeeze=void 0;const g=b(2517);u.squeeze=(o,c,f)=>{p(c);const s=g.ShapeUtil.squeezeShape(c[0].dims,f);return[o.reshapeUnpacked(c[0],s)]},u.squeezeV13=(o,c)=>(h(c),(0,u.squeeze)(o,[c[0]],Array.from(c[1].integerData))),u.parseSqueezeAttributes=o=>o.attributes.getInts("axes");const p=o=>{if(!o||o.length!==1)throw new Error("Squeeze requires 1 input.");if(o[0].type==="string")throw new Error("invalid input tensor types.")},h=o=>{if(!o||o.length!==2)throw new Error("Squeeze requires 2 inputs.");if(o[1].type!=="int32")throw new Error("Invalid input type.")}},6558:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.sum=void 0;const g=b(5060),p=b(2039);u.sum=(c,f)=>{o(f);const s={name:"Sum",inputNames:f.map((i,t)=>`X${t}`),inputTypes:new Array(f.length).fill(p.TextureType.unpacked)};return[c.run(Object.assign(Object.assign({},s),{get:()=>h(c,f,s)}),f)]};const h=(c,f,s)=>{const i=(0,g.getGlsl)(c.session.backend.glContext.version),t=f[0].dims.slice(),e=` + void main() { + vec4 result = ${f.map((n,r)=>`${i.texture2D}(X${r},TexCoords)`).join(" + ")}; + ${i.output} = result; + } + `;return Object.assign(Object.assign({},s),{output:{dims:t,type:f[0].type,textureType:p.TextureType.unpacked},hasMain:!0,shaderSource:e})},o=c=>{if(!c||c.length===0)throw new Error("Sum requires inputs.");const f=c[0].dims.length;for(let s=1;s{Object.defineProperty(u,"__esModule",{value:!0}),u.tile=void 0;const g=b(782),p=b(2039);u.tile=(c,f)=>{o(f);const s={name:"Tile",inputNames:["A"],inputTypes:[p.TextureType.unpacked]};return[c.run(Object.assign(Object.assign({},s),{get:()=>h(c,f,s)}),f)]};const h=(c,f,s)=>{const i=f[0].dims.slice(),t=new Array(i.length),e=[];for(let a=0;a{if(!c||c.length!==2)throw new Error("Tile requires 2 input.");if(c[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(c[1].dims[0]!==c[0].dims.length)throw new Error("Invalid input shape.");if(g.NUMBER_TYPES.indexOf(c[0].type)===-1)throw new Error("Invalid input type.");if(c[1].type!=="int32"&&c[1].type!=="int16")throw new Error("Invalid repeat type.")}},3738:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseTransposeAttributes=u.transpose=void 0;const g=b(246),p=b(2517),h=b(2039),o={name:"Transpose",inputNames:["A"],inputTypes:[h.TextureType.unpacked]};u.transpose=(e,n,r)=>(t(n),[e.run(Object.assign(Object.assign({},o),{cacheHint:r.cacheKey,get:()=>c(e,n[0],r.perm)}),n)]),u.parseTransposeAttributes=e=>(0,g.createAttributeWithCacheKey)({perm:e.attributes.getInts("perm",[])});const c=(e,n,r)=>{const a=n.dims;r=f(a,r);const l=s(a,r),d=a.length,m=` + ${i("perm",r,d)} + float process(int indices[${d}]) { + int a[${d}]; + perm(a, indices); + return _A(a); + }`;return Object.assign(Object.assign({},o),{output:{dims:l,type:n.type,textureType:h.TextureType.unpacked},shaderSource:m})},f=(e,n)=>(n&&n.length!==e.length&&(n=[...e.keys()].reverse()),n),s=(e,n)=>(n=f(e,n),p.ShapeUtil.sortBasedOnPerm(e,n)),i=(e,n,r)=>{const a=[];a.push(`void ${e}(out int a[${r}], int src[${r}]) {`);for(let l=0;l{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}},8710:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.encodeAsUint8=void 0;const g=b(5060),p=b(2039);u.encodeAsUint8=(h,o)=>{const c=o.shape,f=(0,g.getGlsl)(h.session.backend.glContext.version),s=` + const float FLOAT_MAX = 1.70141184e38; + const float FLOAT_MIN = 1.17549435e-38; + + bool isNaN(float val) { + return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true; + } + + highp vec4 encodeAsUint8(highp float v) { + if (isNaN(v)) { + return vec4(255, 255, 255, 255); + } + + highp float av = abs(v); + + if(av < FLOAT_MIN) { + return vec4(0.0, 0.0, 0.0, 0.0); + } else if(v > FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; + } else if(v < -FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; + } + + highp vec4 c = vec4(0,0,0,0); + + highp float e = floor(log2(av)); + highp float m = exp2(fract(log2(av))) - 1.0; + + c[2] = floor(128.0 * m); + m -= c[2] / 128.0; + c[1] = floor(32768.0 * m); + m -= c[1] / 32768.0; + c[0] = floor(8388608.0 * m); + + highp float ebias = e + 127.0; + c[3] = floor(ebias / 2.0); + ebias -= c[3] * 2.0; + c[2] += floor(ebias) * 128.0; + + c[3] += 128.0 * step(0.0, -v); + + return c / 255.0; + } + + void main() { + float value = ${f.texture2D}(X,TexCoords).r; + ${f.output} = encodeAsUint8(value); + }`,i={name:"Uint8Encode",inputTypes:[p.TextureType.unpacked],inputNames:["X"],output:{dims:c,type:o.tensor.type,textureType:p.TextureType.downloadUint8AsFloat},shaderSource:s,hasMain:!0};return h.executeProgram(i,[o.tensor])}},4909:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.tanh=u.tan=u.sqrt=u.sin=u.sigmoid=u.relu=u.not=u.neg=u.log=u.parseLeakyReluAttributes=u.leakyRelu=u.identity=u.floor=u.exp=u.parseEluAttributes=u.elu=u.cos=u.ceil=u.clipV11=u.parseClipAttributes=u.clip=u.atan=u.asin=u.acos=u.abs=u.glslTanh=u.glslTan=u.glslSqrt=u.glslSigmoid=u.glslRelu=u.glslSin=u.glslNot=u.glslNeg=u.glslLog=u.glslLeakyRelu=u.glslIdentity=u.glslClip=u.glslFloor=u.glslExp=u.glslElu=u.glslCos=u.glslCeil=u.glslAtan=u.glslAsin=u.glslAcos=u.glslAbs=void 0;const g=b(246),p=b(2517),h=b(8520),o=b(5060),c=b(2039);function f(){return j("abs")}function s(){return j("acos")}function i(){return j("asin")}function t(){return j("atan")}function e(){return j("ceil")}function n(){return j("cos")}function r(k){const V="elu";return{body:` + const float alpha = float(${k}); + + float ${V}_(float a) { + return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; + } + vec4 ${V}_(vec4 v) { + return vec4(${V}_(v.x), ${V}_(v.y), ${V}_(v.z), ${V}_(v.w)); + } + `,name:V,type:h.FunctionType.ValueBased}}function a(){return j("exp")}function l(){return j("floor")}function d(k,V){const J="clip";return{body:` + const float min = float(${k}); + const float max = float(${V}); + + float ${J}_(float a) { + return clamp(a, min, max); + } + vec4 ${J}_(vec4 v) { + return clamp(v, min, max); + } + `,name:J,type:h.FunctionType.ValueBased}}function m(){const k="indentity";return{body:` + float ${k}_(float a) { + return a; + } + vec4 ${k}_(vec4 v) { + return v; + } + `,name:k,type:h.FunctionType.ValueBased}}function y(k){const V="leakyRelu";return{body:` + const float alpha = float(${k}); + + float ${V}_(float a) { + return a < 0.0 ? a * alpha : a; + } + vec4 ${V}_(vec4 v) { + return vec4(${V}_(v.x), ${V}_(v.y), ${V}_(v.z), ${V}_(v.w)); + } + `,name:V,type:h.FunctionType.ValueBased}}function v(){return j("log")}function _(){const k="neg";return{body:` + float ${k}_(float a) { + return -a; + } + vec4 ${k}_(vec4 v) { + return -v; + } + `,name:k,type:h.FunctionType.ValueBased}}function T(){const k="not";return{body:` + float ${k}_(float a) { + return float( ! bool(a) ); + } + bool ${k}_(bool a) { + return !a; + } + vec4 ${k}_(vec4 v) { + return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w)); + } + bvec4 ${k}_(bvec4 v) { + return bvec4(!v.x, !v.y, !v.z, !v.w); + } + `,name:k,type:h.FunctionType.ValueBased}}function S(){return j("sin")}function A(){const k="relu";return{body:` + float ${k}_(float a) { + return max( a, 0.0 ); + } + vec4 ${k}_(vec4 v) { + return max( v, 0.0 ); + } + `,name:k,type:h.FunctionType.ValueBased}}function w(){const k="sigmoid";return{body:` + float ${k}_(float a) { + return 1.0 / (1.0 + exp(-a)); + } + vec4 ${k}_(vec4 v) { + return 1.0 / (1.0 + exp(-v)); + } + `,name:k,type:h.FunctionType.ValueBased}}function I(){return j("sqrt")}function R(){return j("tan")}function B(){const k="tanh";return{body:` + float ${k}_(float a) { + a = clamp(a, -10., 10.); + a = exp(2.*a); + return (a - 1.) / (a + 1.); + } + vec4 ${k}_(vec4 v) { + v = clamp(v, -10., 10.); + v = exp(2.*v); + return (v - 1.) / (v + 1.); + } + `,name:k,type:h.FunctionType.ValueBased}}function j(k){return{body:` + float ${k}_(float a) { + return ${k}(a); + } + vec4 ${k}_(vec4 v) { + return ${k}(v); + } + `,name:k,type:h.FunctionType.ValueBased}}u.glslAbs=f,u.glslAcos=s,u.glslAsin=i,u.glslAtan=t,u.glslCeil=e,u.glslCos=n,u.glslElu=r,u.glslExp=a,u.glslFloor=l,u.glslClip=d,u.glslIdentity=m,u.glslLeakyRelu=y,u.glslLog=v,u.glslNeg=_,u.glslNot=T,u.glslSin=S,u.glslRelu=A,u.glslSigmoid=w,u.glslSqrt=I,u.glslTan=R,u.glslTanh=B;const N=(k,V,J,Y)=>{const te=k.session.pack?c.TextureType.packed:c.TextureType.unpacked,ne={name:J.name,inputTypes:[te],inputNames:["A"],cacheHint:Y};return Object.assign(Object.assign({},ne),{get:()=>((me,Pe,Oe,le)=>{const xe=me.session.pack?c.TextureType.packed:c.TextureType.unpacked,_e=(0,o.getGlsl)(me.session.backend.glContext.version);return Object.assign(Object.assign({},Pe),{output:{dims:Oe.dims,type:Oe.type,textureType:xe},shaderSource:` + ${le.body} + void main() { + vec4 v = ${_e.texture2D}(A, TexCoords); + v = ${le.name}_(v); + ${_e.output} = v; + } + `,hasMain:!0})})(k,ne,V,J)})};u.abs=(k,V)=>[k.run(N(k,V[0],f()),V)],u.acos=(k,V)=>[k.run(N(k,V[0],s()),V)],u.asin=(k,V)=>[k.run(N(k,V[0],i()),V)],u.atan=(k,V)=>[k.run(N(k,V[0],t()),V)],u.clip=(k,V,J)=>[k.run(N(k,V[0],d(J.min,J.max),J.cacheKey),V)],u.parseClipAttributes=k=>(0,g.createAttributeWithCacheKey)({min:k.attributes.getFloat("min",p.MIN_CLIP),max:k.attributes.getFloat("max",p.MAX_CLIP)}),u.clipV11=(k,V)=>{const J=W(k,V);return(0,u.clip)(k,[V[0]],J)};const W=(k,V)=>{if(V.length>=3&&(!k.session.isInitializer(V[1].dataId)||!k.session.isInitializer(V[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const J=V.length>=3?V[1].numberData[0]:p.MIN_CLIP,Y=V.length>=3?V[2].numberData[0]:p.MAX_CLIP;return(0,g.createAttributeWithCacheKey)({min:J,max:Y})};u.ceil=(k,V)=>[k.run(N(k,V[0],e()),V)],u.cos=(k,V)=>[k.run(N(k,V[0],n()),V)],u.elu=(k,V,J)=>[k.run(N(k,V[0],r(J.alpha),J.cacheKey),V)],u.parseEluAttributes=k=>(0,g.createAttributeWithCacheKey)({alpha:k.attributes.getFloat("alpha",1)}),u.exp=(k,V)=>[k.run(N(k,V[0],a()),V)],u.floor=(k,V)=>[k.run(N(k,V[0],l()),V)],u.identity=(k,V)=>[k.run(N(k,V[0],m()),V)],u.leakyRelu=(k,V,J)=>[k.run(N(k,V[0],y(J.alpha),J.cacheKey),V)],u.parseLeakyReluAttributes=k=>(0,g.createAttributeWithCacheKey)({alpha:k.attributes.getFloat("alpha",.01)}),u.log=(k,V)=>[k.run(N(k,V[0],v()),V)],u.neg=(k,V)=>[k.run(N(k,V[0],_()),V)],u.not=(k,V)=>[k.run(N(k,V[0],T()),V)],u.relu=(k,V)=>[k.run(N(k,V[0],A()),V)],u.sigmoid=(k,V)=>[k.run(N(k,V[0],w()),V)],u.sin=(k,V)=>[k.run(N(k,V[0],S()),V)],u.sqrt=(k,V)=>[k.run(N(k,V[0],I()),V)],u.tan=(k,V)=>[k.run(N(k,V[0],R()),V)],u.tanh=(k,V)=>[k.run(N(k,V[0],B()),V)]},5611:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createUnpackProgramInfoLoader=u.createUnpackProgramInfo=void 0;const g=b(5060),p=b(2039),h=b(9390),o=b(2827),c={name:"unpack",inputNames:["A"],inputTypes:[p.TextureType.packed]};u.createUnpackProgramInfo=(f,s)=>{const i=s.dims.length,t=(0,o.getChannels)("rc",i),e=t.slice(-2),n=(0,h.getCoordsDataType)(i),r=(0,o.unpackFromChannel)(),a=s.dims.length===0?"":function(m,y){if(m===1)return"rc";let v="";for(let _=0;_Object.assign(Object.assign({},c),{get:()=>(0,u.createUnpackProgramInfo)(f,s)})},8428:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.parseUnsqueezeAttributes=u.unsqueezeV13=u.unsqueeze=void 0;const g=b(2517);u.unsqueeze=(o,c,f)=>{p(c);const s=g.ShapeUtil.unsqueezeShape(c[0].dims,f);return[o.reshapeUnpacked(c[0],s)]},u.unsqueezeV13=(o,c)=>(h(c),(0,u.unsqueeze)(o,[c[0]],Array.from(c[1].integerData))),u.parseUnsqueezeAttributes=o=>o.attributes.getInts("axes");const p=o=>{if(!o||o.length!==1)throw new Error("Unsqueeze requires 1 input.");if(o[0].type==="string")throw new Error("invalid input tensor types.")},h=o=>{if(!o||o.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(o[1].type!=="int32")throw new Error("Invalid input type.")}},9793:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.scalesValidation=u.validateInputs=u.parseUpsampleAttributes=u.parseUpsampleAttributesV9=u.parseUpsampleAttributesV7=u.upsample=void 0;const g=b(246),p=b(5060),h=b(2039),o={name:"Upsample",inputNames:["X"],inputTypes:[h.TextureType.unpacked]};u.upsample=(f,s,i)=>((0,u.validateInputs)(s,i),[f.run(Object.assign(Object.assign({},o),{cacheHint:i.cacheKey,get:()=>c(f,s,i)}),s)]),u.parseUpsampleAttributesV7=f=>(0,u.parseUpsampleAttributes)(f,7),u.parseUpsampleAttributesV9=f=>(0,u.parseUpsampleAttributes)(f,9),u.parseUpsampleAttributes=(f,s)=>{const i=s>=10,t=f.attributes.getString("mode","nearest");if(t!=="nearest"&&t!=="linear"&&(s<11||t!=="cubic"))throw new Error(`unrecognized mode: ${t}`);let e=[];s<9&&(e=f.attributes.getFloats("scales"),(0,u.scalesValidation)(e,t,i));const n=f.attributes.getFloat("extrapolation_value",0),r=s>10?f.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(r)===-1)throw new Error(`coordinate_transform_mode '${r}' is not supported`);const a=r==="tf_crop_and_resize",l=a,d=t==="nearest"&&s>=11?f.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(d)===-1)throw new Error(`nearest_mode '${d}' is not supported`);const m=f.attributes.getFloat("cubic_coeff_a",-.75),y=f.attributes.getInt("exclude_outside",0)!==0;if(y&&t!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const v=s<11||t==="nearest"&&r==="asymmetric"&&d==="floor";let _=0,T=0,S=0;return s>10?f.inputs.length>2?(_=1,T=2,S=3):(T=1,S=2):s===9&&(T=1),(0,g.createAttributeWithCacheKey)({opset:s,isResize:i,mode:t,scales:e,extrapolationValue:n,coordinateTransformMode:r,useExtrapolation:l,needRoiInput:a,nearestMode:d,cubicCoefficientA:m,excludeOutside:y,useNearest2xOptimization:v,roiInputIdx:_,scalesInputIdx:T,sizesInputIdx:S})};const c=(f,s,i)=>{const t=(0,p.getGlsl)(f.session.backend.glContext.version),[e,n]=f.calculateTextureWidthAndHeight(s[0].dims,h.TextureType.unpacked),r=s[0].dims.map((S,A)=>Math.floor(S*i.scales[A])),[a,l]=f.calculateTextureWidthAndHeight(r,h.TextureType.unpacked),d=r.length,m=new Array(d),y=new Array(d);let v=` + int output_pitches[${d}]; + int input_pitches[${d}]; + `;for(let S=d-1;S>=0;S--)m[S]=S===d-1?1:m[S+1]*r[S+1],y[S]=S===d-1?1:y[S+1]*s[0].dims[S+1],v+=` + output_pitches[${S}] = ${m[S]}; + input_pitches[${S}] = ${y[S]}; + `;const _=` + float getInputFloat(int index) { + vec2 coords = offsetToCoords(index, ${e}, ${n}); + float value = getColorAsFloat(${t.texture2D}(X, coords)); + return value; + } + `,T=i.mode==="nearest"?` + ${_} + float process(int indices[${d}]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${a}, ${l}); + + ${v} + + int d, m; + for (int dim = 0; dim < ${d}; ++dim) { + d = output_index / output_pitches[dim]; + m = output_index - d * output_pitches[dim]; + output_index = m; + + if (scales[dim] != 1 && d > 0) { + int d2 = d / scales[dim]; + m = d - d2 * scales[dim]; + d = d2; + } + input_index += input_pitches[dim] * d; + } + + return getInputFloat(input_index); + }`:d===4?` + ${_} + float process(int indices[4]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${a}, ${l}); + + ${v} + + int m; + int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m / output_pitches[1]; + m = m - index_of_dim1 * output_pitches[1]; + index_of_dim2 = m / output_pitches[2]; + m = m - index_of_dim2 * output_pitches[2]; + index_of_dim3 = m; + + int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset; + index_of_input_dim2 = index_of_dim2 / scales[2]; + y_offset = index_of_dim2 - index_of_input_dim2 * scales[2]; + index_of_input_dim3 = index_of_dim3 / scales[3]; + x_offset = index_of_dim3 - index_of_input_dim3 * scales[3]; + + input_index = index_of_dim0 * input_pitches[0] + + index_of_dim1 * input_pitches[1] + + index_of_input_dim2 * input_pitches[2] + + index_of_input_dim3; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim2 = false; + if (index_of_input_dim2 == (${s[0].dims[2]} - 1)) { + // It's the end in dimension 2 + x01 = x00; + end_of_dim2 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[2]); + } + + if (index_of_input_dim3 == (input_pitches[2] - 1)) { + // It's the end in dimension 3 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[3]); + }`:` + ${_} + float process(int indices[2]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${a}, ${l}); + + ${v} + + int m; + int index_of_dim0, index_of_dim1; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m; + + int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset; + index_of_input_dim0 = index_of_dim0 / scales[0]; + y_offset = index_of_dim0 - index_of_input_dim0 * scales[0]; + index_of_input_dim1 = index_of_dim1 / scales[1]; + x_offset = index_of_dim1 - index_of_input_dim1 * scales[1]; + + input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim0 = false; + if (index_of_input_dim0 == (${s[0].dims[0]} - 1)) { + // It's the end in dimension 0 + x01 = x00; + end_of_dim0 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[0]); + } + + if (index_of_input_dim1 == (input_pitches[0] - 1)) { + // It's the end in dimension 1 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[1]); + }`;return Object.assign(Object.assign({},o),{output:{dims:r,type:s[0].type,textureType:h.TextureType.unpacked},shaderSource:T,variables:[{name:"scales",type:"int",arrayLength:i.scales.length,data:i.scales.map(S=>Math.ceil(S))}]})};u.validateInputs=(f,s)=>{if(!f||s.opset<9&&f.length!==1||s.opset>=9&&s.opset<11&&f.length!==2||s.opset>=11&&f.length<2)throw new Error("invalid inputs.");if(s.scales.length>0&&f[0].dims.length!==s.scales.length)throw new Error("Invalid input shape.");if(f[0].type==="string")throw new Error("Invalid input tensor types.")},u.scalesValidation=(f,s,i)=>{if(i){for(const t of f)if(t<=0)throw new Error("Scale value should be greater than 0.")}else for(const t of f)if(t<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(s!=="linear"&&s!=="cubic"||f.length===2||f.length===4&&f[0]===1&&f[1]===1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic') or 4-D inputs with the corresponding outermost 2 scale values being 1 in the ${i?"Resize":"Upsample"} opeartor.`)}},1958:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ProgramManager=void 0;const g=b(1670),p=b(6231),h=b(8879),o=b(5060);u.ProgramManager=class{constructor(c,f,s){this.profiler=c,this.glContext=f,this.textureLayoutStrategy=s,this.repo=new Map,this.attributesBound=!1}getArtifact(c){return this.repo.get(c)}setArtifact(c,f){this.repo.set(c,f)}run(c,f,s){var i;this.profiler.event("op",`ProgramManager.run ${(i=c.programInfo.name)!==null&&i!==void 0?i:"unknown kernel"}`,()=>{var t;const e=this.glContext.gl,n=c.program;e.useProgram(n);try{this.bindOutput(s),this.attributesBound||this.bindAttributes(c.attribLocations),this.bindUniforms(c.uniformLocations,(t=c.programInfo.variables)!==null&&t!==void 0?t:[],f)}catch(r){throw p.Logger.error("ProgramManager",c.programInfo.shaderSource),r}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(c=>this.glContext.deleteProgram(c.program))}build(c,f,s){return this.profiler.event("backend","ProgramManager.build",()=>{const i=new h.GlslPreprocessor(this.glContext,c,f,s),t=i.preprocess(),e=this.compile(t);return{programInfo:c,program:e,uniformLocations:this.getUniformLocations(e,i.context.programInfo.inputNames,i.context.programInfo.variables),attribLocations:this.getAttribLocations(e)}})}compile(c){if(!this.vertexShader){p.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const i=(0,o.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(i,this.glContext.gl.VERTEX_SHADER)}g.env.debug&&p.Logger.verbose("ProrgramManager",`FragShader: +${c} +`);const f=this.glContext.compileShader(c,this.glContext.gl.FRAGMENT_SHADER),s=this.glContext.createProgram(this.vertexShader,f);return this.glContext.deleteShader(f),s}bindOutput(c){const f=c.width,s=c.height;p.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${f}/${s}, shape=${c.shape}, type=${c.tensor.type}`),this.glContext.attachFramebuffer(c.texture,f,s)}bindAttributes(c){const f=c.position,s=c.textureCoord;this.glContext.setVertexAttributes(f,s),this.attributesBound=!0}bindUniforms(c,f,s){var i;const t=this.glContext.gl;let e=0;for(const{name:n,type:r,location:a,arrayLength:l}of c){const d=(i=f.find(m=>m.name===n))===null||i===void 0?void 0:i.data;if(r!=="sampler2D"&&!d)throw new Error(`variable '${n}' does not have data defined in program info`);switch(r){case"sampler2D":this.bindTexture(s[e],a,e),e++;break;case"float":l?t.uniform1fv(a,d):t.uniform1f(a,d);break;case"int":l?t.uniform1iv(a,d):t.uniform1i(a,d);break;default:throw new Error(`Uniform not implemented: ${r}`)}}}bindTexture(c,f,s){this.glContext.bindTextureToUniform(c.texture,s,f)}getAttribLocations(c){return{position:this.getAttribLocation(c,"position"),textureCoord:this.getAttribLocation(c,"textureCoord")}}getUniformLocations(c,f,s){const i=[];if(f)for(const t of f)i.push({name:t,type:"sampler2D",location:this.getUniformLocation(c,t)});if(s)for(const t of s)i.push(Object.assign(Object.assign({},t),{location:this.getUniformLocation(c,t.name)}));return i}getUniformLocation(c,f){const s=this.glContext.gl.getUniformLocation(c,f);if(s===null)throw new Error(`Uniform ${f} not found.`);return s}getAttribLocation(c,f){return this.glContext.gl.getAttribLocation(c,f)}}},6416:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WebGLSessionHandler=void 0;const g=b(6231),p=b(1047),h=b(8316),o=b(1640),c=b(1958),f=b(7859),s=b(5702);u.WebGLSessionHandler=class{constructor(i,t){this.backend=i,this.context=t,this.layoutStrategy=new f.PreferLogicalStrategy(i.glContext.maxTextureSize),this.programManager=new c.ProgramManager(this.context.profiler,i.glContext,this.layoutStrategy),this.textureManager=new s.TextureManager(i.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:i.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=i.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new h.WebGLInferenceHandler(this)}onGraphInitialized(i){const t=i.getValues().filter(e=>e.from===-1&&e.tensor).map(e=>e.tensor.dataId);this.initializers=new Set(t)}isInitializer(i){return!!this.initializers&&this.initializers.has(i)}addInitializer(i){this.initializers.add(i)}getTextureData(i,t){return t?this.packedTextureDataCache.get(i):this.unpackedTextureDataCache.get(i)}setTextureData(i,t,e=!1){g.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),e?this.packedTextureDataCache.set(i,t):this.unpackedTextureDataCache.set(i,t)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(i=>this.textureManager.releaseTexture(i,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(i=>this.textureManager.releaseTexture(i,!0)),this.unpackedTextureDataCache=new Map}resolve(i,t,e){const n=(0,p.resolveOperator)(i,t,o.WEBGL_OP_RESOLVE_RULES);return{impl:n.opImpl,context:n.opInit?n.opInit(i,e):i}}}},7769:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Uint8DataEncoder=u.RGBAFloatDataEncoder=u.RedFloat32DataEncoder=void 0;const g=b(6231);u.RedFloat32DataEncoder=class{constructor(p,h=1){if(h===1)this.internalFormat=p.R32F,this.format=p.RED,this.textureType=p.FLOAT,this.channelSize=h;else{if(h!==4)throw new Error(`Invalid number of channels: ${h}`);this.internalFormat=p.RGBA32F,this.format=p.RGBA,this.textureType=p.FLOAT,this.channelSize=h}}encode(p,h){let o,c;return p.constructor!==Float32Array&&(g.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),c=new Float32Array(p)),h*this.channelSize>p.length?(g.Logger.warning("Encoder","Source data too small. Allocating larger array"),c=p,o=this.allocate(h*this.channelSize),c.forEach((f,s)=>o[s]=f)):(c=p,o=c),o}allocate(p){return new Float32Array(4*p)}decode(p,h){return this.channelSize===1?p.filter((o,c)=>c%4==0).subarray(0,h):p.subarray(0,h)}},u.RGBAFloatDataEncoder=class{constructor(p,h=1,o){if(h!==1&&h!==4)throw new Error(`Invalid number of channels: ${h}`);this.internalFormat=p.RGBA,this.format=p.RGBA,this.channelSize=h,this.textureType=o||p.FLOAT}encode(p,h){let o=p;return this.channelSize===1&&(g.Logger.verbose("Encoder","Exploding into a larger array"),o=this.allocate(h),p.forEach((c,f)=>o[4*f]=c)),o}allocate(p){return new Float32Array(4*p)}decode(p,h){return this.channelSize===1?p.filter((o,c)=>c%4==0).subarray(0,h):p.subarray(0,h)}},u.Uint8DataEncoder=class{constructor(p,h=1){if(this.channelSize=4,h===1)this.internalFormat=p.ALPHA,this.format=p.ALPHA,this.textureType=p.UNSIGNED_BYTE,this.channelSize=h;else{if(h!==4)throw new Error(`Invalid number of channels: ${h}`);this.internalFormat=p.RGBA,this.format=p.RGBA,this.textureType=p.UNSIGNED_BYTE,this.channelSize=h}}encode(p,h){return new Uint8Array(p.buffer,p.byteOffset,p.byteLength)}allocate(p){return new Uint8Array(p*this.channelSize)}decode(p,h){if(p instanceof Uint8Array)return p.subarray(0,h);throw new Error(`Invalid array type: ${p.constructor}`)}}},7859:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.getBatchDim=u.sizeToSquarishShape=u.getRowsCols=u.sizeFromShape=u.isInt=u.parseAxisParam=u.squeezeShape=u.PreferLogicalStrategy=u.AlwaysKeepOriginalSizeStrategy=void 0;const g=b(6231),p=b(2517);function h(i,t){const e=[],n=[],r=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||r?null:o(t,i).sort();let l=0;for(let d=0;dd)&&i[d]===1&&(e.push(i[d]),n.push(d)),a[l]<=d&&l++}i[d]!==1&&(e.push(i[d]),n.push(d))}return{newShape:e,keptDims:n}}function o(i,t){const e=t.length;return i=i==null?t.map((n,r)=>r):[].concat(i),(0,p.assert)(i.every(n=>n>=-e&&n`All values in axis param must be in range [-${e}, ${e}) but got axis ${i}`),(0,p.assert)(i.every(c),()=>`All values in axis param must be integers but got axis ${i}`),i.map(n=>n<0?e+n:n)}function c(i){return i%1==0}function f(i){if(i.length===0)return 1;let t=i[0];for(let e=1;e=i.length?1:i.slice(t.breakAxis).reduce((d,m)=>d*m),l=t.breakAxis<=0?1:i.slice(0,t.breakAxis).reduce((d,m)=>d*m);if(!(a>e||l>e))return[a,l];g.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${i}, breakAxis:${t.breakAxis}`)}const n=i.reduce((a,l)=>a*l);let r=Math.floor(Math.sqrt(n));for(;r=e||n%r!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${i}`);return[r,n/r]}},u.PreferLogicalStrategy=class{constructor(i){this.maxTextureSize=i}computeTextureWH(i,t){const e=this.computeTexture(i,t);return t&&t.isPacked&&(e[0]/=2,e[1]/=2),t&&t.reverseWH?[e[1],e[0]]:e}computeTexture(i,t){const e=t&&t.isPacked;if(i.length===0)return e?[2,2]:[1,1];let n=this.maxTextureSize;if(t&&t.breakAxis!==void 0){const l=t.breakAxis>=i.length?1:i.slice(t.breakAxis).reduce((m,y)=>m*y),d=t.breakAxis<=0?1:i.slice(0,t.breakAxis).reduce((m,y)=>m*y);if(!(l>n||d>n))return[l,d];g.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${i}, breakAxis:${t.breakAxis}`)}let r=i.slice(0);e&&(n*=2,r=r.map((l,d)=>d>=r.length-2?r[d]%2==0?r[d]:r[d]+1:r[d]),r.length===1&&(r=[2,r[0]])),r.length!==2&&(r=h(r).newShape);const a=f(r);return r.length<=1&&a<=n?[1,a]:r.length===2&&r[0]<=n&&r[1]<=n?r:r.length===3&&r[0]*r[1]<=n&&r[2]<=n?[r[0]*r[1],r[2]]:r.length===3&&r[0]<=n&&r[1]*r[2]<=n?[r[0],r[1]*r[2]]:r.length===4&&r[0]*r[1]*r[2]<=n&&r[3]<=n?[r[0]*r[1]*r[2],r[3]]:r.length===4&&r[0]<=n&&r[1]*r[2]*r[3]<=n?[r[0],r[1]*r[2]*r[3]]:e?s(a/4).map(l=>2*l):s(a)}},u.squeezeShape=h,u.parseAxisParam=o,u.isInt=c,u.sizeFromShape=f,u.getRowsCols=function(i){if(i.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[i.length>1?i[i.length-2]:1,i[i.length-1]]},u.sizeToSquarishShape=s,u.getBatchDim=function(i,t=2){return f(i.slice(0,i.length-t))}},4057:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createTextureLayoutFromShape=u.calculateTextureWidthAndHeight=u.createTextureLayoutFromTextureType=void 0;const g=b(2517),p=b(2039);u.createTextureLayoutFromTextureType=(h,o,c)=>{const f=c===p.TextureType.unpacked||c===p.TextureType.unpackedReversed?1:4,s=c===p.TextureType.packed,i=c===p.TextureType.unpackedReversed||c===p.TextureType.packed,t=c===p.TextureType.packedLastDimension?o.length-1:void 0,e=c===p.TextureType.packedLastDimension?o.map((n,r)=>r===o.length-1?4*n:n):void 0;return(0,u.createTextureLayoutFromShape)(h,o,f,e,{isPacked:s,reverseWH:i,breakAxis:t})},u.calculateTextureWidthAndHeight=(h,o,c)=>{const f=(0,u.createTextureLayoutFromTextureType)(h,o,c);return[f.width,f.height]},u.createTextureLayoutFromShape=(h,o,c=1,f,s)=>{const i=!(!s||!s.isPacked),[t,e]=h.computeTextureWH(i&&f||o,s),n=o.length;let r=o.slice(0);if(n===0&&(r=[1]),c===1)f=o;else if(i){if(c!==4)throw new Error("a packed texture must be 4-channel");f=o,n>0&&(r[n-1]=Math.ceil(r[n-1]/2)),n>1&&(r[n-2]=Math.ceil(r[n-2]/2))}else if(!f)throw new Error("Unpacked shape is needed when using channels > 1");return{width:t,height:e,channels:c,isPacked:i,shape:r,strides:g.ShapeUtil.computeStrides(r),unpackedShape:f,reversedWH:s&&s.reverseWH}}},5702:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TextureManager=void 0;const g=b(6231);u.TextureManager=class{constructor(p,h,o,c){this.glContext=p,this.layoutStrategy=h,this.profiler=o,this.config=c,this.pendingRead=new Map,c.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(p,h,o,c){const f=this.toEncoderType(p),s=this.glContext.getEncoder(f,h.channels||1,c);if(h.isPacked&&c===1)throw new Error("not implemented");const i=h.width,t=h.height;let e,n;if(this.config.reuseTextures){e=`${i}x${t}_${s.format}_${s.internalFormat}_${s.textureType}`,n=this.inUseTextures.get(e),n||(n=[],this.inUseTextures.set(e,n));const a=this.idleTextures.get(e);if(a&&a.length>0){const l=a.pop();return n.push(l),c===1&&this.glContext.updateTexture(l,i,t,s,this.toTextureData(p,o)),l}}g.Logger.verbose("TextureManager",`Creating new texture of size ${h.width}x${h.height}`);const r=this.glContext.allocateTexture(i,t,s,this.toTextureData(p,o));return this.config.reuseTextures&&(n.push(r),this.textureLookup.set(r,e)),r}readTexture(p,h,o){return o||(o=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const c=p.shape.reduce((s,i)=>s*i)*o,f=this.glContext.readTexture(p.texture,p.width,p.height,c,this.toEncoderType(h),o);return this.toTensorData(h,f)})}async readTextureAsync(p,h,o){const c=p.tensor.dataId;if(o||(o=1),this.pendingRead.has(c)){const f=this.pendingRead.get(c);return new Promise(s=>f==null?void 0:f.push(s))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(c,[]);const f=p.shape.reduce((e,n)=>e*n)*o;await this.glContext.createAndWaitForFence();const s=this.glContext.readTexture(p.texture,p.width,p.height,f,this.toEncoderType(h),o),i=this.toTensorData(h,s),t=this.pendingRead.get(c);return this.pendingRead.delete(c),t==null||t.forEach(e=>e(i)),i})}readUint8TextureAsFloat(p){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const h=p.shape.reduce((c,f)=>c*f),o=this.glContext.readTexture(p.texture,p.width,p.height,4*h,"byte",4);return new Float32Array(o.buffer,o.byteOffset,h)})}releaseTexture(p,h){let o;if(this.config.reuseTextures&&(o=this.textureLookup.get(p.texture),o)){h&&this.textureLookup.delete(o);const c=this.inUseTextures.get(o);if(c){const f=c.indexOf(p.texture);if(f!==-1){c.splice(f,1);let s=this.idleTextures.get(o);s||(s=[],this.idleTextures.set(o,s)),s.push(p.texture)}}}o&&!h||(g.Logger.verbose("TextureManager",`Deleting texture of size ${p.width}x${p.height}`),this.glContext.deleteTexture(p.texture))}toTensorData(p,h){switch(p){case"int16":return h instanceof Int16Array?h:Int16Array.from(h);case"int32":return h instanceof Int32Array?h:Int32Array.from(h);case"int8":return h instanceof Int8Array?h:Int8Array.from(h);case"uint16":return h instanceof Uint16Array?h:Uint16Array.from(h);case"uint32":return h instanceof Uint32Array?h:Uint32Array.from(h);case"uint8":case"bool":return h instanceof Uint8Array?h:Uint8Array.from(h);case"float32":return h instanceof Float32Array?h:Float32Array.from(h);case"float64":return h instanceof Float64Array?h:Float64Array.from(h);default:throw new Error(`TensorData type ${p} is not supported`)}}toTextureData(p,h){if(h)return h instanceof Float32Array?h:new Float32Array(h)}toEncoderType(p){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},2039:(D,u)=>{var b;Object.defineProperty(u,"__esModule",{value:!0}),u.TextureType=void 0,(b=u.TextureType||(u.TextureType={}))[b.unpacked=0]="unpacked",b[b.unpackedReversed=1]="unpackedReversed",b[b.packed=2]="packed",b[b.downloadUint8AsFloat=3]="downloadUint8AsFloat",b[b.packedLastDimension=4]="packedLastDimension"},9390:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.getGlChannels=u.getCoordsDataType=u.getSqueezedParams=u.squeezeInputShape=u.generateShaderFuncNameFromInputSamplerNameAtOutCoords=u.generateShaderFuncNameFromInputSamplerName=u.repeatedTry=u.getPackedShape=void 0;const g=b(2517);u.getPackedShape=function(p){const h=p.length;return p.slice(0,h-1).concat(p[h-1]/4)},u.repeatedTry=async function(p,h=c=>0,o){return new Promise((c,f)=>{let s=0;const i=()=>{if(p())return void c();s++;const t=h(s);o!=null&&s>=o?f():setTimeout(i,t)};i()})},u.generateShaderFuncNameFromInputSamplerName=function(p){return(0,g.assert)(p!==void 0&&p.length!==0,()=>"empty string found for sampler name"),"get"+p.charAt(0).toUpperCase()+p.slice(1)},u.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(p){return(0,g.assert)(p!==void 0&&p.length!==0,()=>"empty string found for sampler name"),"get"+p.charAt(0).toUpperCase()+p.slice(1)+"AtOutCoords"},u.squeezeInputShape=function(p,h){let o=JSON.parse(JSON.stringify(p));return o=h,o},u.getSqueezedParams=function(p,h){return h.map(o=>p[o]).join(", ")},u.getCoordsDataType=function(p){if(p<=1)return"int";if(p===2)return"ivec2";if(p===3)return"ivec3";if(p===4)return"ivec4";if(p===5)return"ivec5";if(p===6)return"ivec6";throw Error(`GPU for rank ${p} is not yet supported`)},u.getGlChannels=function(p=6){return["x","y","z","w","u","v"].slice(0,p)}},7305:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createNewWebGLContext=u.createWebGLContext=void 0;const g=b(6231),p=b(1713),h={};function o(c){const f=function(){if(typeof document>"u"){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}const t=document.createElement("canvas");return t.width=1,t.height=1,t}();let s;const i={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!c||c==="webgl2")&&(s=f.getContext("webgl2",i),s))try{return new p.WebGLContext(s,2)}catch(t){g.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${t}`)}if((!c||c==="webgl")&&(s=f.getContext("webgl",i)||f.getContext("experimental-webgl",i),s))try{return new p.WebGLContext(s,1)}catch(t){g.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${t}`)}throw new Error("WebGL is not supported")}u.createWebGLContext=function c(f){let s;f&&f!=="webgl2"||!("webgl2"in h)?f&&f!=="webgl"||!("webgl"in h)||(s=h.webgl):s=h.webgl2,s=s||o(f),f=f||s.version===1?"webgl":"webgl2";const i=s.gl;return h[f]=s,i.isContextLost()?(delete h[f],c(f)):(i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),i.disable(i.BLEND),i.disable(i.DITHER),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SAMPLE_COVERAGE),i.enable(i.SCISSOR_TEST),i.enable(i.CULL_FACE),i.cullFace(i.BACK),s)},u.createNewWebGLContext=o},1713:function(D,u,b){var g=this&&this.__createBinding||(Object.create?function(i,t,e,n){n===void 0&&(n=e);var r=Object.getOwnPropertyDescriptor(t,e);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,r)}:function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]}),p=this&&this.__setModuleDefault||(Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t}),h=this&&this.__importStar||function(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var e in i)e!=="default"&&Object.prototype.hasOwnProperty.call(i,e)&&g(t,i,e);return p(t,i),t};Object.defineProperty(u,"__esModule",{value:!0}),u.WebGLContext=u.linearSearchLastTrue=void 0;const o=b(1670),c=h(b(7769)),f=b(9390);function s(i){let t=0;for(;tthis.isTimerResultAvailable(i)),this.getTimerResult(i)}async createAndWaitForFence(){const i=this.createFence(this.gl);return this.pollFence(i)}createFence(i){let t;const e=i,n=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return i.flush(),t=n===null?()=>!0:()=>{const r=e.clientWaitSync(n,0,0);return r===e.ALREADY_SIGNALED||r===e.CONDITION_SATISFIED},{query:n,isFencePassed:t}}async pollFence(i){return new Promise(t=>{this.addItemToPoll(()=>i.isFencePassed(),()=>t())})}pollItems(){const i=s(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=i;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(i+1)}async addItemToPoll(i,t){this.itemsToPoll.push({isDoneFn:i,resolveFn:t}),this.itemsToPoll.length>1||await(0,f.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},1036:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ExecutionPlan=void 0;const g=b(6231);class p{constructor(o,c){this.op=o,this.node=c}}u.ExecutionPlan=class{constructor(h,o,c){this.graph=h,this.profiler=c,this.initialize(o)}initialize(h){this.profiler.event("session","ExecutionPlan.initialize",()=>{const o=this.graph.getNodes();if(o.length!==h.length)throw new Error("The size of nodes and OPs do not match.");this._ops=h.map((c,f)=>new p(c,o[f])),this.reset(),this._starter=[],this._ops.forEach((c,f)=>{let s=!0;for(const i of c.node.inputs)if(!this._values[i]&&this.graph.getInputIndices().indexOf(i)===-1){s=!1;break}s&&this._starter.push(f)})})}reset(){this._values=this.graph.getValues().map(h=>h.tensor)}async execute(h,o){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const c=h.createInferenceHandler(),f=this.graph.getInputIndices();if(o.length!==f.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${o.length} expected: ${f.length}`);o.forEach((r,a)=>{const l=f[a];this._values[l]=r});const s=this._starter.slice(0),i=this.graph.getValues(),t=this.graph.getNodes();let e=0;for(;ethis._values[v]);if(l.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${a.node}`);const d=l;g.Logger.verbose("ExecPlan",`Runing op:${a.node.name} (${d.map((v,_)=>`'${a.node.inputs[_]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);const m=await this.profiler.event("node",a.node.name,async()=>a.op.impl(c,d,a.op.context));if(m.length!==a.node.outputs.length)throw new Error("the size of output does not match model definition.");m.forEach((v,_)=>{const T=a.node.outputs[_];if(this._values[T])throw new Error(`output [${T}] already has value: op:${a.node.name}`);this._values[T]=v});const y=new Set;m.forEach((v,_)=>{const T=a.node.outputs[_];for(const S of i[T].to){const A=t[S];let w=!0;for(const I of A.inputs)if(!this._values[I]){w=!1;break}w&&y.add(S)}}),s.push(...y)}const n=[];for(let r=0;r{Object.defineProperty(u,"__esModule",{value:!0}),u.Graph=void 0;const g=b(1446),p=b(7778),h=b(9395),o=b(9162),c=b(2517);var f=h.onnxruntime.experimental.fbs;u.Graph={from:(e,n)=>new t(e,n)};class s{constructor(n){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,n&&(this.type=c.ProtoUtil.tensorValueTypeFromProto(n.type.tensorType))}get from(){return this._from}get to(){return this._to}}class i{constructor(n,r){n instanceof g.onnx.NodeProto?(this.name=n.name,this.opType=n.opType,this.attributes=new p.Attribute(n.attribute)):n instanceof f.Node&&(this.name=r??n.name(),this.opType=n.opType(),this.attributes=new p.Attribute(c.ProtoUtil.tensorAttributesFromORTFormat(n))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class t{constructor(n,r){if(!n)throw new TypeError("graph is empty");this.buildGraph(n),this.transformGraph(r),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(n){if(n instanceof g.onnx.GraphProto)this.buildGraphFromOnnxFormat(n);else{if(!(n instanceof f.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(n)}}buildGraphFromOnnxFormat(n){const r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const a=new Map;if(!n.input)throw new Error("missing information in graph: input");const l=[];for(const d of n.input){if(r.has(d.name))throw new Error(`duplicated input name: ${d.name}`);const m=this._allData.push(new s(d))-1;r.set(d.name,m),l.push(d.name)}if(!n.initializer)throw new Error("missing information in graph: initializer");for(const d of n.initializer){let m=r.get(d.name);if(m===void 0){const y=new s;y.type={shape:{dims:c.ProtoUtil.tensorDimsFromProto(d.dims)},tensorType:c.ProtoUtil.tensorDataTypeFromProto(d.dataType)},m=this._allData.push(y)-1,r.set(d.name,m)}this._allData[m]._from=-1,this._allData[m].tensor=o.Tensor.fromProto(d)}for(let d=0;d{this._allData[l]._to.forEach(d=>{n.add(d)})});const r=Array.from(n),a=new Array(this._nodes.length).fill("white");for(;r.length>0;){const l=r.pop();a[l]==="gray"?a[l]="black":(r.push(l),a[l]="gray",this._nodes[l].outputs.forEach(d=>{const m=this._allData[d];if(m.tensor!==void 0)throw new Error("node outputs should not be initialized");if(m._from!==l)throw new Error("from property of the Value object doesn't match index of Node being processed");m._to.forEach(y=>{if(a[y]==="gray")throw new Error("model graph is cyclic");a[y]==="white"&&r.push(y)})}))}}transformGraph(n){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),n&&n.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let n=0;for(let r=0;r0&&(this._nodes[r].inputs.forEach(a=>{const l=this._allData[a]._to.indexOf(r+n);l!==-1&&(this._allData[a]._to[l]=r)}),this._nodes[r].outputs.forEach(a=>{this._allData[a]._from&&this._allData[a]._from===r+n&&(this._allData[a]._from=r)})):(n++,this._nodes[r].outputs.forEach(a=>{this._allData[a]._from=-2}),this._nodes.splice(r,1),r--);n=0;for(let r=0;r0){let a=-1;this._allData[r].from!==void 0&&this._allData[r].from!==-1?(a=this._nodes[this._allData[r].from].outputs.indexOf(r+n),a!==-1&&(this._nodes[this._allData[r].from].outputs[a]=r)):(a=this._allInputIndices.indexOf(r+n),a!==-1&&(this._allInputIndices[a]=r)),this._allData[r].to.forEach(l=>{a=this._nodes[l].inputs.indexOf(r+n),a!==-1&&(this._nodes[l].inputs[a]=r)}),this._allData[r].to.length===0&&(a=this._allOutputIndices.indexOf(r+n),a!==-1&&(this._allOutputIndices[a]=r))}}else n++,this._allData.splice(r,1),r--}deleteNode(n){const r=this._nodes[n];if(r.outputs.length>1){for(let v=1;v0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}r.executeNode=!1;const a=r.inputs[0],l=r.outputs[0],d=this._allData[l].to,m=this._allData[a].to.indexOf(n);if(m===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[a].to.splice(m,1),this._allData[l]._to=[];const y=this._allOutputIndices.indexOf(l);if(y!==-1&&(this._allOutputIndices[y]=a),d&&d.length>0)for(const v of d){const _=this._nodes[v].inputs.indexOf(l);if(_===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[v].inputs[_]=a,this._allData[a].to.push(v)}}removeAllDropoutNodes(){let n=0;for(const r of this._nodes){if(r.opType==="Dropout"){if(r.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(r.outputs.length!==1&&r.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(r.outputs.length===2&&this._allData[r.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(n)}n++}}removeAllIdentityNodes(){let n=0;for(const r of this._nodes)r.opType==="Identity"&&this.deleteNode(n),n++}isActivation(n){switch(n.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const n of this._nodes)if(n.opType==="Conv"){const r=this._allData[n.outputs[0]]._to;if(r.length===1&&this.isActivation(this._nodes[r[0]])){const a=this._nodes[r[0]];if(a.opType==="Clip")if(a.inputs.length===1)try{n.attributes.set("activation_params","floats",[a.attributes.getFloat("min"),a.attributes.getFloat("max")])}catch{n.attributes.set("activation_params","floats",[c.MIN_CLIP,c.MAX_CLIP])}else{if(!(a.inputs.length>=3&&this._allData[a.inputs[1]].tensor!==void 0&&this._allData[a.inputs[2]].tensor!==void 0))continue;n.attributes.set("activation_params","floats",[this._allData[a.inputs[1]].tensor.floatData[0],this._allData[a.inputs[2]].tensor.floatData[0]])}n.attributes.set("activation","string",a.opType),this.deleteNode(r[0])}}}}},6231:(D,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.now=u.Profiler=u.Logger=void 0;const b={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},g={none:new class{log(i,t,e){}},console:new class{log(i,t,e){console.log(`${this.color(i)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${t}`)}color(i){switch(i){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${i}`)}}}},p={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let h={"":p};function o(i,t,e,n){if(t===void 0)return r=i,{verbose:o.verbose.bind(null,r),info:o.info.bind(null,r),warning:o.warning.bind(null,r),error:o.error.bind(null,r),fatal:o.fatal.bind(null,r)};if(e===void 0)c(i,t);else if(typeof e=="number"&&n===void 0)c(i,t);else if(typeof e=="string"&&n===void 0)c(i,e,0,t);else{if(typeof e!="string"||typeof n!="number")throw new TypeError("input is valid");c(i,e,0,t)}var r}function c(i,t,e,n){const r=h[n||""]||h[""];b[i]{l.then(async y=>{r&&await r.end(),d(y)},async y=>{r&&await r.end(),m(y)})});if(!a&&r){const d=r.end();if(d&&typeof d.then=="function")return new Promise((m,y)=>{d.then(()=>{m(l)},v=>{y(v)})})}return l}begin(i,t,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){const n=(0,u.now)();return this.flush(n),new f(i,t,n,r=>this.endSync(r))}{const n=e.beginTimer();return new f(i,t,0,async r=>this.end(r),n,e)}}async end(i){const t=await i.checkTimer();this._timingEvents.length=this._flushBatchSize||i-this._flushTime>=this._flushIntervalInMilliseconds){for(const t=this._flushPointer;this._flushPointerperformance.now():Date.now},2644:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Model=void 0;const g=b(5686),p=b(1446),h=b(7070),o=b(9395),c=b(2517);var f=o.onnxruntime.experimental.fbs;u.Model=class{constructor(){}load(s,i,t){if(!t)try{return void this.loadFromOnnxFormat(s,i)}catch(e){if(t!==void 0)throw e}this.loadFromOrtFormat(s,i)}loadFromOnnxFormat(s,i){const t=p.onnx.ModelProto.decode(s);if(c.LongUtil.longToNumber(t.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=t.opsetImport.map(e=>({domain:e.domain,version:c.LongUtil.longToNumber(e.version)})),this._graph=h.Graph.from(t.graph,i)}loadFromOrtFormat(s,i){const t=new g.flatbuffers.ByteBuffer(s),e=f.InferenceSession.getRootAsInferenceSession(t).model();if(c.LongUtil.longToNumber(e.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let n=0;n{Object.defineProperty(u,"__esModule",{value:!0}),u.FLOAT_TYPES=u.INT_TYPES=u.NUMBER_TYPES=void 0,u.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],u.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],u.FLOAT_TYPES=["float32","float64"]},1047:(D,u)=>{function b(g,p){if(p.endsWith("+")){const h=Number.parseInt(p.substring(0,p.length-1),10);return!isNaN(h)&&h<=g}if(p.split("-").length===2){const h=p.split("-"),o=Number.parseInt(h[0],10),c=Number.parseInt(h[1],10);return!isNaN(o)&&!isNaN(c)&&o<=g&&g<=c}return Number.parseInt(p,10)===g}Object.defineProperty(u,"__esModule",{value:!0}),u.resolveOperator=void 0,u.resolveOperator=function(g,p,h){for(const o of h){const c=o[0],f=o[1],s=o[2],i=o[3],t=o[4];if(g.opType===c){for(const e of p)if((e.domain===f||e.domain==="ai.onnx"&&f==="")&&b(e.version,s))return{opImpl:i,opInit:t}}}throw new TypeError(`cannot resolve operator '${g.opType}' with opsets: ${p.map(o=>`${o.domain||"ai.onnx"} v${o.version}`).join(", ")}`)}},9395:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.onnxruntime=void 0;const g=b(5686);var p,h;p=u.onnxruntime||(u.onnxruntime={}),function(o){(function(c){c[c.UNDEFINED=0]="UNDEFINED",c[c.FLOAT=1]="FLOAT",c[c.INT=2]="INT",c[c.STRING=3]="STRING",c[c.TENSOR=4]="TENSOR",c[c.GRAPH=5]="GRAPH",c[c.FLOATS=6]="FLOATS",c[c.INTS=7]="INTS",c[c.STRINGS=8]="STRINGS",c[c.TENSORS=9]="TENSORS",c[c.GRAPHS=10]="GRAPHS",c[c.SPARSE_TENSOR=11]="SPARSE_TENSOR",c[c.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(o.AttributeType||(o.AttributeType={}))}((h=p.experimental||(p.experimental={})).fbs||(h.fbs={})),function(o){(function(c){(function(f){(function(s){s[s.UNKNOWN=0]="UNKNOWN",s[s.VALUE=1]="VALUE",s[s.PARAM=2]="PARAM"})(f.DimensionValueType||(f.DimensionValueType={}))})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){(function(s){s[s.UNDEFINED=0]="UNDEFINED",s[s.FLOAT=1]="FLOAT",s[s.UINT8=2]="UINT8",s[s.INT8=3]="INT8",s[s.UINT16=4]="UINT16",s[s.INT16=5]="INT16",s[s.INT32=6]="INT32",s[s.INT64=7]="INT64",s[s.STRING=8]="STRING",s[s.BOOL=9]="BOOL",s[s.FLOAT16=10]="FLOAT16",s[s.DOUBLE=11]="DOUBLE",s[s.UINT32=12]="UINT32",s[s.UINT64=13]="UINT64",s[s.COMPLEX64=14]="COMPLEX64",s[s.COMPLEX128=15]="COMPLEX128",s[s.BFLOAT16=16]="BFLOAT16"})(f.TensorDataType||(f.TensorDataType={}))})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){(function(s){s[s.Primitive=0]="Primitive",s[s.Fused=1]="Fused"})(f.NodeType||(f.NodeType={}))})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){(function(s){s[s.NONE=0]="NONE",s[s.tensor_type=1]="tensor_type",s[s.sequence_type=2]="sequence_type",s[s.map_type=3]="map_type"})(f.TypeInfoValue||(f.TypeInfoValue={}))})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsShape(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsShape(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}dim(t,e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new o.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}dimLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startShape(t){t.startObject(1)}static addDim(t,e){t.addFieldOffset(0,e,0)}static createDimVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startDimVector(t,e){t.startVector(4,e,4)}static endShape(t){return t.endObject()}static createShape(t,e){return s.startShape(t),s.addDim(t,e),s.endShape(t)}}f.Shape=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDimension(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimension(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}value(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new o.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}denotation(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startDimension(t){t.startObject(2)}static addValue(t,e){t.addFieldOffset(0,e,0)}static addDenotation(t,e){t.addFieldOffset(1,e,0)}static endDimension(t){return t.endObject()}static createDimension(t,e,n){return s.startDimension(t),s.addValue(t,e),s.addDenotation(t,n),s.endDimension(t)}}f.Dimension=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDimensionValue(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimensionValue(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}dimType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):o.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}dimParam(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}static startDimensionValue(t){t.startObject(3)}static addDimType(t,e){t.addFieldInt8(0,e,o.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(t,e){t.addFieldInt64(1,e,t.createLong(0,0))}static addDimParam(t,e){t.addFieldOffset(2,e,0)}static endDimensionValue(t){return t.endObject()}static createDimensionValue(t,e,n,r){return s.startDimensionValue(t),s.addDimType(t,e),s.addDimValue(t,n),s.addDimParam(t,r),s.endDimensionValue(t)}}f.DimensionValue=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTensorTypeAndShape(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensorTypeAndShape(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}elemType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):o.experimental.fbs.TensorDataType.UNDEFINED}shape(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new o.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startTensorTypeAndShape(t){t.startObject(2)}static addElemType(t,e){t.addFieldInt32(0,e,o.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(t,e){t.addFieldOffset(1,e,0)}static endTensorTypeAndShape(t){return t.endObject()}static createTensorTypeAndShape(t,e,n){return s.startTensorTypeAndShape(t),s.addElemType(t,e),s.addShape(t,n),s.endTensorTypeAndShape(t)}}f.TensorTypeAndShape=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMapType(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMapType(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}keyType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):o.experimental.fbs.TensorDataType.UNDEFINED}valueType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new o.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startMapType(t){t.startObject(2)}static addKeyType(t,e){t.addFieldInt32(0,e,o.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(t,e){t.addFieldOffset(1,e,0)}static endMapType(t){return t.endObject()}static createMapType(t,e,n){return s.startMapType(t),s.addKeyType(t,e),s.addValueType(t,n),s.endMapType(t)}}f.MapType=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSequenceType(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSequenceType(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}elemType(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new o.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSequenceType(t){t.startObject(1)}static addElemType(t,e){t.addFieldOffset(0,e,0)}static endSequenceType(t){return t.endObject()}static createSequenceType(t,e){return s.startSequenceType(t),s.addElemType(t,e),s.endSequenceType(t)}}f.SequenceType=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(c.fbs||(c.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(f,s){return this.bb_pos=f,this.bb=s,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(f,s,i,t){return f.prep(4,12),f.writeInt32(t),f.writeInt32(i),f.writeInt32(s),f.offset()}}})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNodeEdge(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodeEdge(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}nodeIndex(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}inputEdges(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new o.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+n)+12*t,this.bb):null}inputEdgesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}outputEdges(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new o.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+n)+12*t,this.bb):null}outputEdgesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNodeEdge(t){t.startObject(3)}static addNodeIndex(t,e){t.addFieldInt32(0,e,0)}static addInputEdges(t,e){t.addFieldOffset(1,e,0)}static startInputEdgesVector(t,e){t.startVector(12,e,4)}static addOutputEdges(t,e){t.addFieldOffset(2,e,0)}static startOutputEdgesVector(t,e){t.startVector(12,e,4)}static endNodeEdge(t){return t.endObject()}static createNodeEdge(t,e,n,r){return s.startNodeEdge(t),s.addNodeIndex(t,e),s.addInputEdges(t,n),s.addOutputEdges(t,r),s.endNodeEdge(t)}}f.NodeEdge=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNode(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNode(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}domain(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}sinceVersion(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0}index(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint32(this.bb_pos+t):0}opType(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):o.experimental.fbs.NodeType.Primitive}executionProviderType(t){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null}inputs(t,e){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,e){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}attributes(t,e){let n=this.bb.__offset(this.bb_pos,24);return n?(e||new o.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}attributesLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCounts(t){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*t):0}inputArgCountsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCountsArray(){let t=this.bb.__offset(this.bb_pos,26);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}implicitInputs(t,e){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}implicitInputsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNode(t){t.startObject(13)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addDomain(t,e){t.addFieldOffset(2,e,0)}static addSinceVersion(t,e){t.addFieldInt32(3,e,0)}static addIndex(t,e){t.addFieldInt32(4,e,0)}static addOpType(t,e){t.addFieldOffset(5,e,0)}static addType(t,e){t.addFieldInt32(6,e,o.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(t,e){t.addFieldOffset(7,e,0)}static addInputs(t,e){t.addFieldOffset(8,e,0)}static createInputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startInputsVector(t,e){t.startVector(4,e,4)}static addOutputs(t,e){t.addFieldOffset(9,e,0)}static createOutputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startOutputsVector(t,e){t.startVector(4,e,4)}static addAttributes(t,e){t.addFieldOffset(10,e,0)}static createAttributesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startAttributesVector(t,e){t.startVector(4,e,4)}static addInputArgCounts(t,e){t.addFieldOffset(11,e,0)}static createInputArgCountsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startInputArgCountsVector(t,e){t.startVector(4,e,4)}static addImplicitInputs(t,e){t.addFieldOffset(12,e,0)}static createImplicitInputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startImplicitInputsVector(t,e){t.startVector(4,e,4)}static endNode(t){return t.endObject()}static createNode(t,e,n,r,a,l,d,m,y,v,_,T,S,A){return s.startNode(t),s.addName(t,e),s.addDocString(t,n),s.addDomain(t,r),s.addSinceVersion(t,a),s.addIndex(t,l),s.addOpType(t,d),s.addType(t,m),s.addExecutionProviderType(t,y),s.addInputs(t,v),s.addOutputs(t,_),s.addAttributes(t,T),s.addInputArgCounts(t,S),s.addImplicitInputs(t,A),s.endNode(t)}}f.Node=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsValueInfo(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsValueInfo(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}type(t){let e=this.bb.__offset(this.bb_pos,8);return e?(t||new o.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startValueInfo(t){t.startObject(3)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addType(t,e){t.addFieldOffset(2,e,0)}static endValueInfo(t){return t.endObject()}static createValueInfo(t,e,n,r){return s.startValueInfo(t),s.addName(t,e),s.addDocString(t,n),s.addType(t,r),s.endValueInfo(t)}}f.ValueInfo=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTypeInfo(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTypeInfo(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}denotation(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}valueType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):o.experimental.fbs.TypeInfoValue.NONE}value(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}static startTypeInfo(t){t.startObject(3)}static addDenotation(t,e){t.addFieldOffset(0,e,0)}static addValueType(t,e){t.addFieldInt8(1,e,o.experimental.fbs.TypeInfoValue.NONE)}static addValue(t,e){t.addFieldOffset(2,e,0)}static endTypeInfo(t){return t.endObject()}static createTypeInfo(t,e,n,r){return s.startTypeInfo(t),s.addDenotation(t,e),s.addValueType(t,n),s.addValue(t,r),s.endTypeInfo(t)}}f.TypeInfo=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsOperatorSetId(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOperatorSetId(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}domain(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}version(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}static startOperatorSetId(t){t.startObject(2)}static addDomain(t,e){t.addFieldOffset(0,e,0)}static addVersion(t,e){t.addFieldInt64(1,e,t.createLong(0,0))}static endOperatorSetId(t){return t.endObject()}static createOperatorSetId(t,e,n){return s.startOperatorSetId(t),s.addDomain(t,e),s.addVersion(t,n),s.endOperatorSetId(t)}}f.OperatorSetId=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTensor(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensor(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}dims(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}dataType(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):o.experimental.fbs.TensorDataType.UNDEFINED}rawData(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}rawDataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}rawDataArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}stringData(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}stringDataLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}static startTensor(t){t.startObject(6)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addDims(t,e){t.addFieldOffset(2,e,0)}static createDimsVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static addDataType(t,e){t.addFieldInt32(3,e,o.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(t,e){t.addFieldOffset(4,e,0)}static createRawDataVector(t,e){t.startVector(1,e.length,1);for(let n=e.length-1;n>=0;n--)t.addInt8(e[n]);return t.endVector()}static startRawDataVector(t,e){t.startVector(1,e,1)}static addStringData(t,e){t.addFieldOffset(5,e,0)}static createStringDataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startStringDataVector(t,e){t.startVector(4,e,4)}static endTensor(t){return t.endObject()}static createTensor(t,e,n,r,a,l,d){return s.startTensor(t),s.addName(t,e),s.addDocString(t,n),s.addDims(t,r),s.addDataType(t,a),s.addRawData(t,l),s.addStringData(t,d),s.endTensor(t)}}f.Tensor=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSparseTensor(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSparseTensor(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}values(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new o.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}indices(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new o.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dims(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSparseTensor(t){t.startObject(3)}static addValues(t,e){t.addFieldOffset(0,e,0)}static addIndices(t,e){t.addFieldOffset(1,e,0)}static addDims(t,e){t.addFieldOffset(2,e,0)}static createDimsVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static endSparseTensor(t){return t.endObject()}static createSparseTensor(t,e,n,r){return s.startSparseTensor(t),s.addValues(t,e),s.addIndices(t,n),s.addDims(t,r),s.endSparseTensor(t)}}f.SparseTensor=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsAttribute(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsAttribute(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):o.experimental.fbs.AttributeType.UNDEFINED}f(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0}i(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}s(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}t(t){let e=this.bb.__offset(this.bb_pos,16);return e?(t||new o.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}g(t){let e=this.bb.__offset(this.bb_pos,18);return e?(t||new o.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}floats(t){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0}floatsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}floatsArray(){let t=this.bb.__offset(this.bb_pos,20);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}ints(t){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}intsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}strings(t,e){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}stringsLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}tensors(t,e){let n=this.bb.__offset(this.bb_pos,26);return n?(e||new o.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}tensorsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}graphs(t,e){let n=this.bb.__offset(this.bb_pos,28);return n?(e||new o.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}graphsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startAttribute(t){t.startObject(13)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addType(t,e){t.addFieldInt32(2,e,o.experimental.fbs.AttributeType.UNDEFINED)}static addF(t,e){t.addFieldFloat32(3,e,0)}static addI(t,e){t.addFieldInt64(4,e,t.createLong(0,0))}static addS(t,e){t.addFieldOffset(5,e,0)}static addT(t,e){t.addFieldOffset(6,e,0)}static addG(t,e){t.addFieldOffset(7,e,0)}static addFloats(t,e){t.addFieldOffset(8,e,0)}static createFloatsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addFloat32(e[n]);return t.endVector()}static startFloatsVector(t,e){t.startVector(4,e,4)}static addInts(t,e){t.addFieldOffset(9,e,0)}static createIntsVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startIntsVector(t,e){t.startVector(8,e,8)}static addStrings(t,e){t.addFieldOffset(10,e,0)}static createStringsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startStringsVector(t,e){t.startVector(4,e,4)}static addTensors(t,e){t.addFieldOffset(11,e,0)}static createTensorsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startTensorsVector(t,e){t.startVector(4,e,4)}static addGraphs(t,e){t.addFieldOffset(12,e,0)}static createGraphsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startGraphsVector(t,e){t.startVector(4,e,4)}static endAttribute(t){return t.endObject()}static createAttribute(t,e,n,r,a,l,d,m,y,v,_,T,S,A){return s.startAttribute(t),s.addName(t,e),s.addDocString(t,n),s.addType(t,r),s.addF(t,a),s.addI(t,l),s.addS(t,d),s.addT(t,m),s.addG(t,y),s.addFloats(t,v),s.addInts(t,_),s.addStrings(t,T),s.addTensors(t,S),s.addGraphs(t,A),s.endAttribute(t)}}f.Attribute=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGraph(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGraph(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}initializers(t,e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new o.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}initializersLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeArgs(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new o.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}nodeArgsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}nodes(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new o.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}maxNodeIndex(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readUint32(this.bb_pos+t):0}nodeEdges(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new o.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}nodeEdgesLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}inputs(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,e){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}sparseInitializers(t,e){let n=this.bb.__offset(this.bb_pos,18);return n?(e||new o.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}sparseInitializersLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGraph(t){t.startObject(8)}static addInitializers(t,e){t.addFieldOffset(0,e,0)}static createInitializersVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startInitializersVector(t,e){t.startVector(4,e,4)}static addNodeArgs(t,e){t.addFieldOffset(1,e,0)}static createNodeArgsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startNodeArgsVector(t,e){t.startVector(4,e,4)}static addNodes(t,e){t.addFieldOffset(2,e,0)}static createNodesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startNodesVector(t,e){t.startVector(4,e,4)}static addMaxNodeIndex(t,e){t.addFieldInt32(3,e,0)}static addNodeEdges(t,e){t.addFieldOffset(4,e,0)}static createNodeEdgesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startNodeEdgesVector(t,e){t.startVector(4,e,4)}static addInputs(t,e){t.addFieldOffset(5,e,0)}static createInputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startInputsVector(t,e){t.startVector(4,e,4)}static addOutputs(t,e){t.addFieldOffset(6,e,0)}static createOutputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startOutputsVector(t,e){t.startVector(4,e,4)}static addSparseInitializers(t,e){t.addFieldOffset(7,e,0)}static createSparseInitializersVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startSparseInitializersVector(t,e){t.startVector(4,e,4)}static endGraph(t){return t.endObject()}static createGraph(t,e,n,r,a,l,d,m,y){return s.startGraph(t),s.addInitializers(t,e),s.addNodeArgs(t,n),s.addNodes(t,r),s.addMaxNodeIndex(t,a),s.addNodeEdges(t,l),s.addInputs(t,d),s.addOutputs(t,m),s.addSparseInitializers(t,y),s.endGraph(t)}}f.Graph=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModel(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsModel(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}irVersion(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}opsetImport(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new o.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}opsetImportLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}producerName(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}producerVersion(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}domain(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}modelVersion(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}docString(t){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,t):null}graph(t){let e=this.bb.__offset(this.bb_pos,18);return e?(t||new o.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}graphDocString(t){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,t):null}static startModel(t){t.startObject(9)}static addIrVersion(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addOpsetImport(t,e){t.addFieldOffset(1,e,0)}static createOpsetImportVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startOpsetImportVector(t,e){t.startVector(4,e,4)}static addProducerName(t,e){t.addFieldOffset(2,e,0)}static addProducerVersion(t,e){t.addFieldOffset(3,e,0)}static addDomain(t,e){t.addFieldOffset(4,e,0)}static addModelVersion(t,e){t.addFieldInt64(5,e,t.createLong(0,0))}static addDocString(t,e){t.addFieldOffset(6,e,0)}static addGraph(t,e){t.addFieldOffset(7,e,0)}static addGraphDocString(t,e){t.addFieldOffset(8,e,0)}static endModel(t){return t.endObject()}static createModel(t,e,n,r,a,l,d,m,y,v){return s.startModel(t),s.addIrVersion(t,e),s.addOpsetImport(t,n),s.addProducerName(t,r),s.addProducerVersion(t,a),s.addDomain(t,l),s.addModelVersion(t,d),s.addDocString(t,m),s.addGraph(t,y),s.addGraphDocString(t,v),s.endModel(t)}}f.Model=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKernelCreateInfos(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelCreateInfos(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}nodeIndices(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}nodeIndicesLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeIndicesArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}kernelDefHashes(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}kernelDefHashesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startKernelCreateInfos(t){t.startObject(2)}static addNodeIndices(t,e){t.addFieldOffset(0,e,0)}static createNodeIndicesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startNodeIndicesVector(t,e){t.startVector(4,e,4)}static addKernelDefHashes(t,e){t.addFieldOffset(1,e,0)}static createKernelDefHashesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startKernelDefHashesVector(t,e){t.startVector(8,e,8)}static endKernelCreateInfos(t){return t.endObject()}static createKernelCreateInfos(t,e,n){return s.startKernelCreateInfos(t),s.addNodeIndices(t,e),s.addKernelDefHashes(t,n),s.endKernelCreateInfos(t)}}f.KernelCreateInfos=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSubGraphSessionState(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSubGraphSessionState(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}graphId(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}sessionState(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new o.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSubGraphSessionState(t){t.startObject(2)}static addGraphId(t,e){t.addFieldOffset(0,e,0)}static addSessionState(t,e){t.addFieldOffset(1,e,0)}static endSubGraphSessionState(t){let e=t.endObject();return t.requiredField(e,4),e}static createSubGraphSessionState(t,e,n){return s.startSubGraphSessionState(t),s.addGraphId(t,e),s.addSessionState(t,n),s.endSubGraphSessionState(t)}}f.SubGraphSessionState=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSessionState(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSessionState(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}kernels(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new o.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}subGraphSessionStates(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new o.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}subGraphSessionStatesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSessionState(t){t.startObject(2)}static addKernels(t,e){t.addFieldOffset(0,e,0)}static addSubGraphSessionStates(t,e){t.addFieldOffset(1,e,0)}static createSubGraphSessionStatesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startSubGraphSessionStatesVector(t,e){t.startVector(4,e,4)}static endSessionState(t){return t.endObject()}static createSessionState(t,e,n){return s.startSessionState(t),s.addKernels(t,e),s.addSubGraphSessionStates(t,n),s.endSessionState(t)}}f.SessionState=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={})),function(o){(function(c){(function(f){class s{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInferenceSession(t,e){return(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInferenceSession(t,e){return t.setPosition(t.position()+g.flatbuffers.SIZE_PREFIX_LENGTH),(e||new s).__init(t.readInt32(t.position())+t.position(),t)}static bufferHasIdentifier(t){return t.__has_identifier("ORTM")}ortVersion(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}model(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new o.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}sessionState(t){let e=this.bb.__offset(this.bb_pos,8);return e?(t||new o.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startInferenceSession(t){t.startObject(3)}static addOrtVersion(t,e){t.addFieldOffset(0,e,0)}static addModel(t,e){t.addFieldOffset(1,e,0)}static addSessionState(t,e){t.addFieldOffset(2,e,0)}static endInferenceSession(t){return t.endObject()}static finishInferenceSessionBuffer(t,e){t.finish(e,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(t,e){t.finish(e,"ORTM",!0)}static createInferenceSession(t,e,n,r){return s.startInferenceSession(t),s.addOrtVersion(t,e),s.addModel(t,n),s.addSessionState(t,r),s.endInferenceSession(t)}}f.InferenceSession=s})(c.fbs||(c.fbs={}))})(o.experimental||(o.experimental={}))}(u.onnxruntime||(u.onnxruntime={}))},7448:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OnnxjsSessionHandler=void 0;const g=b(1670),p=b(9162);u.OnnxjsSessionHandler=class{constructor(h){this.session=h,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(h,o,c){const f=new Map;for(const t in h)if(Object.hasOwnProperty.call(h,t)){const e=h[t];f.set(t,new p.Tensor(e.dims,e.type,void 0,void 0,e.data))}const s=await this.session.run(f),i={};return s.forEach((t,e)=>{i[e]=new g.Tensor(t.type,t.data,t.dims)}),i}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6919:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Session=void 0;const g=b(7067),p=b(1296),h=b(7091),o=b(1036),c=b(6231),f=b(2644);u.Session=class{constructor(s={}){this._initialized=!1,this.backendHint=s.backendHint,this.profiler=c.Profiler.create(s.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(s,i,t){await this.profiler.event("session","Session.loadModel",async()=>{const e=await(0,h.resolveBackend)(this.backendHint);if(this.sessionHandler=e.createSessionHandler(this.context),this._model=new f.Model,typeof s=="string"){const n=s.endsWith(".ort");if(typeof fetch>"u"){const r=await(0,p.promisify)(g.readFile)(s);this.initialize(r,n)}else{const r=await fetch(s),a=await r.arrayBuffer();this.initialize(new Uint8Array(a),n)}}else if(ArrayBuffer.isView(s))this.initialize(s);else{const n=new Uint8Array(s,i||0,t||s.byteLength);this.initialize(n)}})}initialize(s,i){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const t=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(s,t,i),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new o.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(s){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const i=this.normalizeAndValidateInputs(s),t=await this._executionPlan.execute(this.sessionHandler,i);return this.createOutput(t)})}normalizeAndValidateInputs(s){const i=this._model.graph.getInputNames();if(Array.isArray(s)){if(s.length!==i.length)throw new Error(`incorrect input array length: expected ${i.length} but got ${s.length}`)}else{if(s.size!==i.length)throw new Error(`incorrect input map size: expected ${i.length} but got ${s.size}`);const t=new Array(s.size);let e=0;for(let n=0;ntypeof A=="string")))throw new TypeError("cache should be a string array");S&&(this.cache=new Array(T))}else{if(v!==void 0){const A=e(d);if(!(v instanceof A))throw new TypeError(`cache should be type ${A.name}`)}if(S){const A=new ArrayBuffer(T*function(w){switch(w){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${w}`)}}(d));this.cache=function(w,I){return new(e(I))(w)}(A,d)}}}static fromProto(l){if(!l)throw new Error("cannot construct Value from an empty tensor");const d=f.ProtoUtil.tensorDataTypeFromProto(l.dataType),m=f.ProtoUtil.tensorDimsFromProto(l.dims),y=new i(m,d);if(d==="string")l.stringData.forEach((v,_)=>{y.data[_]=(0,f.decodeUtf8String)(v)});else if(l.rawData&&typeof l.rawData.byteLength=="number"&&l.rawData.byteLength>0){const v=y.data,_=new DataView(l.rawData.buffer,l.rawData.byteOffset,l.rawData.byteLength),T=t(l.dataType),S=l.rawData.byteLength/T;if(l.rawData.byteLength%T!=0)throw new Error("invalid buffer length");if(v.length!==S)throw new Error("buffer length mismatch");for(let A=0;A0){const v=y.data,_=new DataView(l.rawDataArray().buffer,l.rawDataArray().byteOffset,l.rawDataLength()),T=t(l.dataType()),S=l.rawDataLength()/T;if(l.rawDataLength()%T!=0)throw new Error("invalid buffer length");if(v.length!==S)throw new Error("buffer length mismatch");for(let A=0;A1&&I>1)return;S[T-A]=Math.max(w,I)}return S}static index(d,m){const y=new Array(m.length);return s.fillIndex(d,m,y),y}static fillIndex(d,m,y){const v=d.length-m.length;for(let _=0;_=0;J--)w[J]=B%T[J],B=Math.floor(B/T[J]);W||(s.fillIndex(w,d.dims,I),j=d.get(I)),k||(s.fillIndex(w,m.dims,R),N=m.get(R)),A.set(w,y(j,N))}}return A}}static isValidBroadcast(d,m){const y=d.length,v=m.length;if(y>v)return!1;for(let _=1;_<=y;_++)if(d[y-_]!==1&&d[y-_]!==m[v-_])return!1;return!0}static getBroadcastDims(d,m){const y=d.length,v=[];for(let _=0;_1&&S===1&&v.unshift(T)}return v}}u.BroadcastUtil=s,u.arrayCopyHelper=function(l,d,m,y,v){if(y<0||y>=d.length)throw new Error("sourceIndex out of bounds");if(m<0||m>=l.length)throw new Error("targetIndex out of bounds");if(y+v>d.length)throw new Error("source indices to be copied are outside bounds");if(m+v>l.length)throw new Error("target array is too small to hold result");for(let _=0;_h.default.isLong(m)?m.toNumber():m)}static tensorValueTypeFromProto(d){return{tensorType:i.tensorDataTypeFromProto(d.elemType),shape:{dims:i.tensorDimsFromProto(d.shape.dim.map(m=>m.dimValue))}}}static tensorDimsFromORTFormat(d){const m=[];for(let y=0;yd.length)throw new Error(`invalid dimension of ${m} for sizeFromDimension as Tensor has ${d.length} dimensions.`);return e.getSizeFromDimensionRange(d,m,d.length)}static sizeToDimension(d,m){if(m<0||m>d.length)throw new Error(`invalid dimension of ${m} for sizeToDimension as Tensor has ${d.length} dimensions.`);return e.getSizeFromDimensionRange(d,0,m)}static getSizeFromDimensionRange(d,m,y){let v=1;for(let _=m;_=0;--v)y[v]=y[v+1]*d[v+1];return y}static transpose(d){return d.slice().reverse()}static indicesToOffset(d,m,y){y===void 0&&(y=d.length);let v=0;for(let _=0;_=m)throw new Error("unsupported axis for this operation.");return d<0?d+m:d}static normalizeAxes(d,m){return d.map(y=>this.normalizeAxis(y,m))}static incrementIndex(d,m,y){if(m.length===0||d.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(y===void 0)y=m.length;else if(y<=0||y>m.length)throw new Error("Incorrect axis to increment on");for(let v=y-1;v>=0&&(d[v]++,!(d[v]=d.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");v[A]=d[A]}else v[A]=m[A];T*=v[A]}}const S=e.size(d);if(_!==-1){if(S%T!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${d}] Output shape: [${m}]`);v[_]=S/T}else if(T!==S)throw new Error("reshapedDims and originalDims don't have matching sizes");return v}static sortBasedOnPerm(d,m){return m?m.map(y=>d[y]):d.slice().reverse()}static padShape(d,m){const y=d.length;return d.map((v,_)=>v+m[_]+m[_+y])}static areEqual(d,m){return d.length===m.length&&d.every((y,v)=>y===m[v])}static validateDimsAndCalcSize(d){if(d.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let m=1;for(const y of d){if(!Number.isInteger(y))throw new TypeError(`Invalid shape: ${y} is not an integer`);if(y<0||y>2147483647)throw new TypeError(`Invalid shape: length ${y} is not allowed`);m*=y}return m}static flattenShape(d,m){m<0&&(m+=d.length);const y=d.reduce((_,T)=>_*T,1),v=d.slice(m).reduce((_,T)=>_*T,1);return[y/v,v]}static squeezeShape(d,m){const y=new Array;m=e.normalizeAxes(m,d.length);for(let v=0;v=0;if(_&&d[v]!==1)throw new Error("squeeze an axis of size different than 1");(m.length===0&&d[v]>1||m.length>0&&!_)&&y.push(d[v])}return y}static unsqueezeShape(d,m){const y=new Array(d.length+m.length);y.fill(0);for(let _=0;_=y.length)throw new Error("'axes' has an out of range axis");if(y[T]!==0)throw new Error("'axes' has a duplicate axis");y[T]=1}let v=0;for(let _=0;_=d.length)throw new Error("sourceIndex out of bounds");if(m<0||m>=l.length)throw new Error("targetIndex out of bounds");if(y+v>d.length)throw new Error("source indices to be copied are outside bounds");if(m+v>l.length)throw new Error("target array is too small to hold result");for(let _=0;_=d.length)throw new Error("sourceIndex out of bounds");if(m<0||m>=l.length)throw new Error("targetIndex out of bounds");if(y+v>d.length)throw new Error("source indices to be copied are outside bounds");if(m+v>l.length)throw new Error("target array is too small to hold result");for(let T=0;T=d.length)throw new Error("sourceIndex out of bounds");if(m<0||m>=l.length)throw new Error("targetIndex out of bounds");if(y+v>d.length)throw new Error("source indices to be copied are outside bounds");if(m+v>l.length)throw new Error("target array is too small to hold result");for(let T=0;T=d.length)throw new Error("sourceIndex out of bounds");if(m<0||m>=l.length)throw new Error("targetIndex out of bounds");if(y+v>d.length)throw new Error("source indices to be copied are outside bounds");if(m+v>l.length)throw new Error("target array is too small to hold result");for(let _=0;_m.push(N));const S=r.calcReduceShape(T,m,!0),A=e.size(S),w=new c.Tensor(S,d.type),I=e.computeStrides(S),R=e.computeStrides(T),B=new Array(T.length);for(let j=0;j=m.length)return T(d[_]);const w=m[v],I=w>=y.length?1:e.size(y.slice(w+1));for(let R=0;R_!==0)}}u.ReduceUtil=r;class a{static adjustPoolAttributes(d,m,y,v,_,T){if(!d&&y.length!==m.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(d)for(let S=0;S=y.length?y.push(m[S+2]):y[S]=m[S+2];for(let S=0;S=y[S]||T[S+y.length]>=y[S])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(d,m,y,v,_,T){if(T){if(_.length!==2*(d.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(m.length!==d.length-2)throw new Error("length of strides should be the length of data dimensions");if(v.length!==d.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let S=0;S{Object.defineProperty(u,"__esModule",{value:!0}),u.iterateExtraOptions=void 0,u.iterateExtraOptions=(b,g,p,h)=>{if(typeof b=="object"&&b!==null){if(p.has(b))throw new Error("Circular reference in options");p.add(b)}Object.entries(b).forEach(([o,c])=>{const f=g?g+o:o;if(typeof c=="object")(0,u.iterateExtraOptions)(c,f+".",p,h);else if(typeof c=="string"||typeof c=="number")h(f,c.toString());else{if(typeof c!="boolean")throw new Error("Can't handle extra config type: "+typeof c);h(f,c?"1":"0")}})}},2157:function(D,u,b){var g,p=this&&this.__createBinding||(Object.create?function(I,R,B,j){j===void 0&&(j=B);var N=Object.getOwnPropertyDescriptor(R,B);N&&!("get"in N?!R.__esModule:N.writable||N.configurable)||(N={enumerable:!0,get:function(){return R[B]}}),Object.defineProperty(I,j,N)}:function(I,R,B,j){j===void 0&&(j=B),I[j]=R[B]}),h=this&&this.__setModuleDefault||(Object.create?function(I,R){Object.defineProperty(I,"default",{enumerable:!0,value:R})}:function(I,R){I.default=R}),o=this&&this.__importStar||function(I){if(I&&I.__esModule)return I;var R={};if(I!=null)for(var B in I)B!=="default"&&Object.prototype.hasOwnProperty.call(I,B)&&p(R,I,B);return h(R,I),R};Object.defineProperty(u,"__esModule",{value:!0}),u.endProfiling=u.run=u.releaseSession=u.createSession=u.createSessionFinalize=u.createSessionAllocate=u.initOrt=u.initWasm=void 0;const c=b(1670),f=o(b(349)),s=b(6361),i=()=>!!c.env.wasm.proxy&&typeof document<"u";let t,e,n,r=!1,a=!1,l=!1;const d=[],m=[],y=[],v=[],_=[],T=[],S=()=>{if(r||!a||l||!t)throw new Error("worker not ready")},A=I=>{switch(I.data.type){case"init-wasm":r=!1,I.data.err?(l=!0,e[1](I.data.err)):(a=!0,e[0]());break;case"init-ort":I.data.err?n[1](I.data.err):n[0]();break;case"create_allocate":I.data.err?d.shift()[1](I.data.err):d.shift()[0](I.data.out);break;case"create_finalize":I.data.err?m.shift()[1](I.data.err):m.shift()[0](I.data.out);break;case"create":I.data.err?y.shift()[1](I.data.err):y.shift()[0](I.data.out);break;case"release":I.data.err?v.shift()[1](I.data.err):v.shift()[0]();break;case"run":I.data.err?_.shift()[1](I.data.err):_.shift()[0](I.data.out);break;case"end-profiling":I.data.err?T.shift()[1](I.data.err):T.shift()[0]()}},w=typeof document<"u"?(g=document==null?void 0:document.currentScript)===null||g===void 0?void 0:g.src:void 0;u.initWasm=async()=>{if(i()){if(a)return;if(r)throw new Error("multiple calls to 'initWasm()' detected.");if(l)throw new Error("previous call to 'initWasm()' failed.");return r=!0,c.env.wasm.wasmPaths===void 0&&w&&w.indexOf("blob:")!==0&&(c.env.wasm.wasmPaths=w.substr(0,+w.lastIndexOf("/")+1)),new Promise((I,R)=>{t==null||t.terminate(),t=b(9710).Z(),t.onmessage=A,e=[I,R];const B={type:"init-wasm",in:c.env.wasm};t.postMessage(B)})}return(0,s.initializeWebAssembly)(c.env.wasm)},u.initOrt=async(I,R)=>{if(i())return S(),new Promise((B,j)=>{n=[B,j];const N={type:"init-ort",in:{numThreads:I,loggingLevel:R}};t.postMessage(N)});f.initOrt(I,R)},u.createSessionAllocate=async I=>i()?(S(),new Promise((R,B)=>{d.push([R,B]);const j={type:"create_allocate",in:{model:I}};t.postMessage(j,[I.buffer])})):f.createSessionAllocate(I),u.createSessionFinalize=async(I,R)=>i()?(S(),new Promise((B,j)=>{m.push([B,j]);const N={type:"create_finalize",in:{modeldata:I,options:R}};t.postMessage(N)})):f.createSessionFinalize(I,R),u.createSession=async(I,R)=>i()?(S(),new Promise((B,j)=>{y.push([B,j]);const N={type:"create",in:{model:I,options:R}};t.postMessage(N,[I.buffer])})):f.createSession(I,R),u.releaseSession=async I=>{if(i())return S(),new Promise((R,B)=>{v.push([R,B]);const j={type:"release",in:I};t.postMessage(j)});f.releaseSession(I)},u.run=async(I,R,B,j,N)=>i()?(S(),new Promise((W,k)=>{_.push([W,k]);const V={type:"run",in:{sessionId:I,inputIndices:R,inputs:B,outputIndices:j,options:N}};t.postMessage(V,f.extractTransferableBuffers(B))})):f.run(I,R,B,j,N),u.endProfiling=async I=>{if(i())return S(),new Promise((R,B)=>{T.push([R,B]);const j={type:"end-profiling",in:I};t.postMessage(j)});f.endProfiling(I)}},586:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.setRunOptions=void 0;const g=b(7967),p=b(4983),h=b(6361);u.setRunOptions=o=>{const c=(0,h.getInstance)();let f=0;const s=[],i=o||{};try{if((o==null?void 0:o.logSeverityLevel)===void 0)i.logSeverityLevel=2;else if(typeof o.logSeverityLevel!="number"||!Number.isInteger(o.logSeverityLevel)||o.logSeverityLevel<0||o.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${o.logSeverityLevel}`);if((o==null?void 0:o.logVerbosityLevel)===void 0)i.logVerbosityLevel=0;else if(typeof o.logVerbosityLevel!="number"||!Number.isInteger(o.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${o.logVerbosityLevel}`);(o==null?void 0:o.terminate)===void 0&&(i.terminate=!1);let t=0;if((o==null?void 0:o.tag)!==void 0&&(t=(0,p.allocWasmString)(o.tag,s)),f=c._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,t),f===0)throw new Error("Can't create run options");return(o==null?void 0:o.extra)!==void 0&&(0,g.iterateExtraOptions)(o.extra,"",new WeakSet,(e,n)=>{const r=(0,p.allocWasmString)(e,s),a=(0,p.allocWasmString)(n,s);if(c._OrtAddRunConfigEntry(f,r,a)!==0)throw new Error(`Can't set a run config entry: ${e} - ${n}`)}),[f,s]}catch(t){throw f!==0&&c._OrtReleaseRunOptions(f),s.forEach(c._free),t}}},2306:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OnnxruntimeWebAssemblySessionHandler=void 0;const g=b(2806),p=b(1670),h=b(2850),o=b(2157);let c;u.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(f){const s=await fetch(f),i=await s.arrayBuffer();return(0,o.createSessionAllocate)(new Uint8Array(i))}async loadModel(f,s){if(c||(await(0,o.initOrt)(p.env.wasm.numThreads,(i=>{switch(i){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${i}`)}})(p.env.logLevel)),c=!0),typeof f=="string")if(typeof fetch>"u"){const i=await(0,h.promisify)(g.readFile)(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,o.createSession)(i,s)}else{const i=await this.createSessionAllocate(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,o.createSessionFinalize)(i,s)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,o.createSession)(f,s)}async dispose(){return(0,o.releaseSession)(this.sessionId)}async run(f,s,i){const t=[],e=[];Object.entries(f).forEach(l=>{const d=l[0],m=l[1],y=this.inputNames.indexOf(d);if(y===-1)throw new Error(`invalid input '${d}'`);t.push(m),e.push(y)});const n=[];Object.entries(s).forEach(l=>{const d=l[0],m=this.outputNames.indexOf(d);if(m===-1)throw new Error(`invalid output '${d}'`);n.push(m)});const r=await(0,o.run)(this.sessionId,e,t.map(l=>[l.type,l.dims,l.data]),n,i),a={};for(let l=0;l{Object.defineProperty(u,"__esModule",{value:!0}),u.setSessionOptions=void 0;const g=b(7967),p=b(4983),h=b(6361);u.setSessionOptions=o=>{const c=(0,h.getInstance)();let f=0;const s=[],i=o||{};(t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});const e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(i);try{(o==null?void 0:o.graphOptimizationLevel)===void 0&&(i.graphOptimizationLevel="all");const t=(r=>{switch(r){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${r}`)}})(i.graphOptimizationLevel);(o==null?void 0:o.enableCpuMemArena)===void 0&&(i.enableCpuMemArena=!0),(o==null?void 0:o.enableMemPattern)===void 0&&(i.enableMemPattern=!0),(o==null?void 0:o.executionMode)===void 0&&(i.executionMode="sequential");const e=(r=>{switch(r){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${r}`)}})(i.executionMode);let n=0;if((o==null?void 0:o.logId)!==void 0&&(n=(0,p.allocWasmString)(o.logId,s)),(o==null?void 0:o.logSeverityLevel)===void 0)i.logSeverityLevel=2;else if(typeof o.logSeverityLevel!="number"||!Number.isInteger(o.logSeverityLevel)||o.logSeverityLevel<0||o.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${o.logSeverityLevel}`);if((o==null?void 0:o.logVerbosityLevel)===void 0)i.logVerbosityLevel=0;else if(typeof o.logVerbosityLevel!="number"||!Number.isInteger(o.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${o.logVerbosityLevel}`);if((o==null?void 0:o.enableProfiling)===void 0&&(i.enableProfiling=!1),f=c._OrtCreateSessionOptions(t,!!i.enableCpuMemArena,!!i.enableMemPattern,e,!!i.enableProfiling,0,n,i.logSeverityLevel,i.logVerbosityLevel),f===0)throw new Error("Can't create session options");return o!=null&&o.executionProviders&&((r,a,l)=>{for(const d of a){let m=typeof d=="string"?d:d.name;switch(m){case"xnnpack":m="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${m}`)}const y=(0,p.allocWasmString)(m,l);if((0,h.getInstance)()._OrtAppendExecutionProvider(r,y)!==0)throw new Error(`Can't append execution provider: ${m}`)}})(f,o.executionProviders,s),(o==null?void 0:o.extra)!==void 0&&(0,g.iterateExtraOptions)(o.extra,"",new WeakSet,(r,a)=>{const l=(0,p.allocWasmString)(r,s),d=(0,p.allocWasmString)(a,s);if(c._OrtAddSessionConfigEntry(f,l,d)!==0)throw new Error(`Can't set a session config entry: ${r} - ${a}`)}),[f,s]}catch(t){throw f!==0&&c._OrtReleaseSessionOptions(f),s.forEach(c._free),t}}},4983:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.allocWasmString=void 0;const g=b(6361);u.allocWasmString=(p,h)=>{const o=(0,g.getInstance)(),c=o.lengthBytesUTF8(p)+1,f=o._malloc(c);return o.stringToUTF8(p,f,c),h.push(f),f}},349:(D,u,b)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.extractTransferableBuffers=u.endProfiling=u.run=u.releaseSession=u.createSession=u.createSessionFinalize=u.createSessionAllocate=u.initOrt=void 0;const g=b(586),p=b(4919),h=b(4983),o=b(6361);u.initOrt=(t,e)=>{const n=(0,o.getInstance)()._OrtInit(t,e);if(n!==0)throw new Error(`Can't initialize onnxruntime. error code = ${n}`)};const c=new Map;u.createSessionAllocate=t=>{const e=(0,o.getInstance)(),n=e._malloc(t.byteLength);return e.HEAPU8.set(t,n),[n,t.byteLength]},u.createSessionFinalize=(t,e)=>{const n=(0,o.getInstance)();let r=0,a=0,l=[];try{if([a,l]=(0,p.setSessionOptions)(e),r=n._OrtCreateSession(t[0],t[1],a),r===0)throw new Error("Can't create a session")}finally{n._free(t[0]),n._OrtReleaseSessionOptions(a),l.forEach(n._free)}const d=n._OrtGetInputCount(r),m=n._OrtGetOutputCount(r),y=[],v=[],_=[],T=[];for(let S=0;S{const n=(0,u.createSessionAllocate)(t);return(0,u.createSessionFinalize)(n,e)},u.releaseSession=t=>{const e=(0,o.getInstance)(),n=c.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=n[1],l=n[2];a.forEach(e._OrtFree),l.forEach(e._OrtFree),e._OrtReleaseSession(r),c.delete(t)};const f=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${t}`)}},s=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${t}`)}},i=t=>{switch(t){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}};u.run=(t,e,n,r,a)=>{const l=(0,o.getInstance)(),d=c.get(t);if(!d)throw new Error("invalid session id");const m=d[0],y=d[1],v=d[2],_=e.length,T=r.length;let S=0,A=[];const w=[],I=[];try{[S,A]=(0,g.setRunOptions)(a);for(let k=0;k<_;k++){const V=n[k][0],J=n[k][1],Y=n[k][2];let te,ne;if(Array.isArray(Y)){ne=4*Y.length,te=l._malloc(ne),I.push(te);let Oe=te/4;for(let le=0;lel.HEAP32[Oe++]=xe);const le=l._OrtCreateTensor(f(V),te,ne,Pe,J.length);if(le===0)throw new Error("Can't create a tensor");w.push(le)}finally{l.stackRestore(me)}}const R=l.stackSave(),B=l.stackAlloc(4*_),j=l.stackAlloc(4*_),N=l.stackAlloc(4*T),W=l.stackAlloc(4*T);try{let k=B/4,V=j/4,J=N/4,Y=W/4;for(let me=0;me<_;me++)l.HEAPU32[k++]=w[me],l.HEAPU32[V++]=y[e[me]];for(let me=0;mewe*je);if(xe=s(He),xe==="string"){const we=[];let je=_e/4;for(let Ue=0;Ue{const e=(0,o.getInstance)(),n=c.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=e._OrtEndProfiling(r);if(a===0)throw new Error("Can't get an profile file name");e._OrtFree(a)},u.extractTransferableBuffers=t=>{const e=[];for(const n of t){const r=n[2];!Array.isArray(r)&&r.buffer&&e.push(r.buffer)}return e}},6361:function(D,u,b){var g=this&&this.__createBinding||(Object.create?function(a,l,d,m){m===void 0&&(m=d);var y=Object.getOwnPropertyDescriptor(l,d);y&&!("get"in y?!l.__esModule:y.writable||y.configurable)||(y={enumerable:!0,get:function(){return l[d]}}),Object.defineProperty(a,m,y)}:function(a,l,d,m){m===void 0&&(m=d),a[m]=l[d]}),p=this&&this.__setModuleDefault||(Object.create?function(a,l){Object.defineProperty(a,"default",{enumerable:!0,value:l})}:function(a,l){a.default=l}),h=this&&this.__importStar||function(a){if(a&&a.__esModule)return a;var l={};if(a!=null)for(var d in a)d!=="default"&&Object.prototype.hasOwnProperty.call(a,d)&&g(l,a,d);return p(l,a),l},o=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(u,"__esModule",{value:!0}),u.dispose=u.getInstance=u.initializeWebAssembly=void 0;const c=h(b(6449)),f=o(b(932)),s=b(3474);let i,t=!1,e=!1,n=!1;const r=(a,l)=>l?a?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":a?"ort-wasm-simd.wasm":"ort-wasm.wasm";u.initializeWebAssembly=async a=>{if(t)return Promise.resolve();if(e)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(n)throw new Error("previous call to 'initializeWebAssembly()' failed.");e=!0;const l=a.initTimeout,d=a.numThreads,m=a.simd,y=d>1&&(()=>{try{return typeof SharedArrayBuffer<"u"&&(typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch{return!1}})(),v=m&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}})(),_=typeof a.wasmPaths=="string"?a.wasmPaths:void 0,T=r(!1,y),S=r(v,y),A=typeof a.wasmPaths=="object"?a.wasmPaths[S]:void 0;let w=!1;const I=[];if(l>0&&I.push(new Promise(R=>{setTimeout(()=>{w=!0,R()},l)})),I.push(new Promise((R,B)=>{const j=y?s:f.default,N={locateFile:(W,k)=>y&&W.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([b(4154)],{type:"text/javascript"})):W===T?A??(_??k)+S:k+W};if(y)if(typeof Blob>"u")N.mainScriptUrlOrBlob=c.join("/","ort-wasm-threaded.js");else{const W=`var ortWasmThreaded=(function(){var _scriptDir;return ${j.toString()}})();`;N.mainScriptUrlOrBlob=new Blob([W],{type:"text/javascript"})}j(N).then(W=>{e=!1,t=!0,i=W,R()},W=>{e=!1,n=!0,B(W)})})),await Promise.race(I),w)throw new Error(`WebAssembly backend initializing failed due to timeout: ${l}ms`)},u.getInstance=()=>{if(t&&i)return i;throw new Error("WebAssembly is not initialized yet.")},u.dispose=()=>{var a;!t||e||n||(e=!0,(a=i.PThread)===null||a===void 0||a.terminateAllThreads(),i=void 0,e=!1,t=!1,n=!0)}},9710:(D,u,b)=>{b.d(u,{Z:()=>h});var g=b(477),p=b.n(g);function h(){return p()('/*!\n* ONNX Runtime Web v1.14.0\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var t={474:(t,e,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){function e(){return j.buffer!=D&&N(j.buffer),P}function r(){return j.buffer!=D&&N(j.buffer),U}function a(){return j.buffer!=D&&N(j.buffer),F}function i(){return j.buffer!=D&&N(j.buffer),I}function o(){return j.buffer!=D&&N(j.buffer),W}var u,c,s;t=t||{},u||(u=void 0!==t?t:{}),u.ready=new Promise((function(t,e){c=t,s=e}));var l,f,p,h,d,y,b=Object.assign({},u),m="./this.program",g=(t,e)=>{throw e},v="object"==typeof window,w="function"==typeof importScripts,_="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,O=u.ENVIRONMENT_IS_PTHREAD||!1,A="";function S(t){return u.locateFile?u.locateFile(t,A):A+t}if(_){let e;A=w?n(908).dirname(A)+"/":"//",y=()=>{d||(h=n(384),d=n(908))},l=function(t,e){return y(),t=d.normalize(t),h.readFileSync(t,e?void 0:"utf8")},p=t=>((t=l(t,!0)).buffer||(t=new Uint8Array(t)),t),f=(t,e,n)=>{y(),t=d.normalize(t),h.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1{if(Q())throw process.exitCode=t,e;e instanceof ct||x("exiting due to exception: "+e),process.exit(t)},u.inspect=function(){return"[Emscripten Module object]"};try{e=n(925)}catch(t){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),t}n.g.Worker=e.Worker}else(v||w)&&(w?A=self.location.href:"undefined"!=typeof document&&document.currentScript&&(A=document.currentScript.src),_scriptDir&&(A=_scriptDir),A=0!==A.indexOf("blob:")?A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):"",_||(l=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},w&&(p=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),f=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)}));_&&"undefined"==typeof performance&&(n.g.performance=n(953).performance);var T=console.log.bind(console),E=console.warn.bind(console);_&&(y(),T=t=>h.writeSync(1,t+"\\n"),E=t=>h.writeSync(2,t+"\\n"));var M,C=u.print||T,x=u.printErr||E;Object.assign(u,b),b=null,u.thisProgram&&(m=u.thisProgram),u.quit&&(g=u.quit),u.wasmBinary&&(M=u.wasmBinary);var R=u.noExitRuntime||!1;"object"!=typeof WebAssembly&&at("no native wasm support detected");var j,k,D,P,U,F,I,W,H=!1,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function Y(t,e){return(t>>>=0)?z(r(),t,e):""}function B(t,e,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function G(t){for(var e=0,n=0;n=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function N(t){D=t,u.HEAP8=P=new Int8Array(t),u.HEAP16=new Int16Array(t),u.HEAP32=F=new Int32Array(t),u.HEAPU8=U=new Uint8Array(t),u.HEAPU16=new Uint16Array(t),u.HEAPU32=I=new Uint32Array(t),u.HEAPF32=new Float32Array(t),u.HEAPF64=W=new Float64Array(t)}O&&(D=u.buffer);var V=u.INITIAL_MEMORY||16777216;if(O)j=u.wasmMemory,D=u.buffer;else if(u.wasmMemory)j=u.wasmMemory;else if(!((j=new WebAssembly.Memory({initial:V/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw x("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),_&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");j&&(D=j.buffer),V=D.byteLength,N(D);var $,q=[],X=[],J=[],Z=[];function Q(){return R||!1}function K(){var t=u.preRun.shift();q.unshift(t)}var tt,et=0,nt=null,rt=null;function at(t){throw O?postMessage({cmd:"onAbort",arg:t}):u.onAbort&&u.onAbort(t),x(t="Aborted("+t+")"),H=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),s(t),t}function it(){return tt.startsWith("data:application/octet-stream;base64,")}function ot(){var t=tt;try{if(t==tt&&M)return new Uint8Array(M);if(p)return p(t);throw"both async and sync fetching of the wasm failed"}catch(t){at(t)}}tt="ort-wasm-threaded.wasm",it()||(tt=S(tt));var ut={};function ct(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function st(t){(t=ht.Vb[t])||at(),ht.mc(t)}function lt(t){var e=ht.Cc();if(!e)return 6;ht.ac.push(e),ht.Vb[t.Ub]=e,e.Ub=t.Ub;var n={cmd:"run",start_routine:t.Ic,arg:t.zc,pthread_ptr:t.Ub};return e.$b=()=>{n.time=performance.now(),e.postMessage(n,t.Nc)},e.loaded&&(e.$b(),delete e.$b),0}function ft(t){if(O)return $t(1,1,t);Q()||(ht.oc(),u.onExit&&u.onExit(t),H=!0),g(t,new ct(t))}function pt(t,e){if(!e&&O)throw bt(t),"unwind";Q()||O||(me(),dt(J),be(0),re[1].length&&ae(1,10),re[2].length&&ae(2,10),ht.oc()),ft(t)}var ht={Yb:[],ac:[],qc:[],Vb:{},fc:function(){O&&ht.Ec()},Pc:function(){},Ec:function(){ht.receiveObjectTransfer=ht.Gc,ht.threadInitTLS=ht.pc,ht.setExitStatus=ht.nc,R=!1},nc:function(){},oc:function(){for(var t of Object.values(ht.Vb))ht.mc(t);for(t of ht.Yb)t.terminate();ht.Yb=[]},mc:function(t){var e=t.Ub;delete ht.Vb[e],ht.Yb.push(t),ht.ac.splice(ht.ac.indexOf(t),1),t.Ub=0,Oe(e)},Gc:function(){},pc:function(){ht.qc.forEach((t=>t()))},Fc:function(t,e){t.onmessage=n=>{var r=(n=n.data).cmd;if(t.Ub&&(ht.Bc=t.Ub),n.targetThread&&n.targetThread!=he()){var a=ht.Vb[n.Qc];a?a.postMessage(n,n.transferList):x(\'Internal error! Worker sent a message "\'+r+\'" to target pthread \'+n.targetThread+", but that thread no longer exists!")}else"processProxyingQueue"===r?zt(n.queue):"spawnThread"===r?lt(n):"cleanupThread"===r?st(n.thread):"killThread"===r?(n=n.thread,r=ht.Vb[n],delete ht.Vb[n],r.terminate(),Oe(n),ht.ac.splice(ht.ac.indexOf(r),1),r.Ub=0):"cancelThread"===r?ht.Vb[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(t.loaded=!0,e&&e(t),t.$b&&(t.$b(),delete t.$b)):"print"===r?C("Thread "+n.threadId+": "+n.text):"printErr"===r?x("Thread "+n.threadId+": "+n.text):"alert"===r?alert("Thread "+n.threadId+": "+n.text):"setimmediate"===n.target?t.postMessage(n):"onAbort"===r?u.onAbort&&u.onAbort(n.arg):r&&x("worker sent an unknown command "+r);ht.Bc=void 0},t.onerror=t=>{throw x("worker sent an error! "+t.filename+":"+t.lineno+": "+t.message),t},_&&(t.on("message",(function(e){t.onmessage({data:e})})),t.on("error",(function(e){t.onerror(e)})),t.on("detachedExit",(function(){}))),t.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||_scriptDir,wasmMemory:j,wasmModule:k})},yc:function(){var t=S("ort-wasm-threaded.worker.js");ht.Yb.push(new Worker(t))},Cc:function(){return 0==ht.Yb.length&&(ht.yc(),ht.Fc(ht.Yb[0])),ht.Yb.pop()}};function dt(t){for(;0>2>>>0];t=a()[t+48>>2>>>0],Te(e,e-t),Me(e)};var mt=[];function gt(t){var e=mt[t];return e||(t>=mt.length&&(mt.length=t+1),mt[t]=e=$.get(t)),e}u.invokeEntryPoint=function(t,e){t=gt(t)(e),Q()?ht.nc(t):Ae(t)};var vt,wt,_t=[],Ot=0,At=0;function St(t){this.Zb=t,this.Sb=t-24,this.xc=function(t){i()[this.Sb+4>>2>>>0]=t},this.bc=function(){return i()[this.Sb+4>>2>>>0]},this.wc=function(t){i()[this.Sb+8>>2>>>0]=t},this.Dc=function(){return i()[this.Sb+8>>2>>>0]},this.rc=function(){a()[this.Sb>>2>>>0]=0},this.hc=function(t){t=t?1:0,e()[this.Sb+12>>0>>>0]=t},this.uc=function(){return 0!=e()[this.Sb+12>>0>>>0]},this.ic=function(t){t=t?1:0,e()[this.Sb+13>>0>>>0]=t},this.kc=function(){return 0!=e()[this.Sb+13>>0>>>0]},this.fc=function(t,e){this.cc(0),this.xc(t),this.wc(e),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(a(),this.Sb>>2,1)},this.Hc=function(){return 1===Atomics.sub(a(),this.Sb>>2,1)},this.cc=function(t){i()[this.Sb+16>>2>>>0]=t},this.tc=function(){return i()[this.Sb+16>>2>>>0]},this.vc=function(){if(Re(this.bc()))return i()[this.Zb>>2>>>0];var t=this.tc();return 0!==t?t:this.Zb}}function Tt(t){return ye(new St(t).Sb)}function Et(t,e,n,r){return O?$t(3,1,t,e,n,r):Mt(t,e,n,r)}function Mt(t,e,n,r){if("undefined"==typeof SharedArrayBuffer)return x("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return O&&0===a.length?Et(t,e,n,r):(t={Ic:n,Ub:t,zc:r,Nc:a},O?(t.Oc="spawnThread",postMessage(t,a),0):lt(t))}function Ct(t,e,n){return O?$t(4,1,t,e,n):0}function xt(t,e){if(O)return $t(5,1,t,e)}function Rt(t,e){if(O)return $t(6,1,t,e)}function jt(t,e,n){if(O)return $t(7,1,t,e,n)}function kt(t,e,n){return O?$t(8,1,t,e,n):0}function Dt(t,e){if(O)return $t(9,1,t,e)}function Pt(t,e,n){if(O)return $t(10,1,t,e,n)}function Ut(t,e,n,r){if(O)return $t(11,1,t,e,n,r)}function Ft(t,e,n,r){if(O)return $t(12,1,t,e,n,r)}function It(t,e,n,r){if(O)return $t(13,1,t,e,n,r)}function Wt(t){if(O)return $t(14,1,t)}function Ht(t,e){if(O)return $t(15,1,t,e)}function Lt(t,e,n){if(O)return $t(16,1,t,e,n)}function zt(t){Atomics.store(a(),t>>2,1),he()&&_e(t),Atomics.compareExchange(a(),t>>2,1,0)}function Yt(t){return i()[t>>>2]+4294967296*a()[t+4>>>2]}function Bt(t,e,n,r,a,i){return O?$t(17,1,t,e,n,r,a,i):-52}function Gt(t,e,n,r,a,i){if(O)return $t(18,1,t,e,n,r,a,i)}function Nt(t){var n=G(t)+1,r=de(n);return r&&B(t,e(),r,n),r}function Vt(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}if(O)return $t(19,1,t,e,n);var o=(new Date).getFullYear(),u=new Date(o,0,1),c=new Date(o,6,1);o=u.getTimezoneOffset();var s=c.getTimezoneOffset(),l=Math.max(o,s);a()[t>>2>>>0]=60*l,a()[e>>2>>>0]=Number(o!=s),t=r(u),e=r(c),t=Nt(t),e=Nt(e),s>2>>>0]=t,i()[n+4>>2>>>0]=e):(i()[n>>2>>>0]=e,i()[n+4>>2>>>0]=t)}function $t(t,e){var n=arguments.length-2,r=arguments;return yt((()=>{for(var a=Ce(8*n),i=a>>3,u=0;u>>0]=c}return we(t,n,a,e)}))}u.executeNotifiedProxyingQueue=zt,wt=_?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:O?()=>performance.now()-u.__performance_now_clock_drift:()=>performance.now();var qt,Xt=[],Jt={};function Zt(){if(!qt){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"};for(t in Jt)void 0===Jt[t]?delete e[t]:e[t]=Jt[t];var n=[];for(t in e)n.push(t+"="+e[t]);qt=n}return qt}function Qt(t,n){if(O)return $t(20,1,t,n);var r=0;return Zt().forEach((function(a,o){var u=n+r;for(o=i()[t+4*o>>2>>>0]=u,u=0;u>0>>>0]=a.charCodeAt(u);e()[o>>0>>>0]=0,r+=a.length+1})),0}function Kt(t,e){if(O)return $t(21,1,t,e);var n=Zt();i()[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),i()[e>>2>>>0]=r,0}function te(t){return O?$t(22,1,t):52}function ee(t,e,n,r){return O?$t(23,1,t,e,n,r):52}function ne(t,e,n,r,a){return O?$t(24,1,t,e,n,r,a):70}var re=[null,[],[]];function ae(t,e){var n=re[t];0===e||10===e?((1===t?C:x)(z(n,0)),n.length=0):n.push(e)}function ie(t,e,n,a){if(O)return $t(25,1,t,e,n,a);for(var o=0,u=0;u>2>>>0],s=i()[e+4>>2>>>0];e+=8;for(var l=0;l>>0]);o+=s}return i()[a>>2>>>0]=o,0}var oe=0;function ue(t){return 0==t%4&&(0!=t%100||0==t%400)}var ce=[31,29,31,30,31,30,31,31,30,31,30,31],se=[31,28,31,30,31,30,31,31,30,31,30,31];function le(t,n,r,i){function o(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.lengtht?-1:0r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=s(new Date(t.getFullYear(),0,4)),n=s(n),0>=c(e,t)?0>=c(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var f=a()[i+40>>2>>>0];for(var p in i={Lc:a()[i>>2>>>0],Kc:a()[i+4>>2>>>0],dc:a()[i+8>>2>>>0],jc:a()[i+12>>2>>>0],ec:a()[i+16>>2>>>0],Xb:a()[i+20>>2>>>0],Tb:a()[i+24>>2>>>0],Wb:a()[i+28>>2>>>0],Rc:a()[i+32>>2>>>0],Jc:a()[i+36>>2>>>0],Mc:f?Y(f):""},r=Y(r),f={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(p,"g"),f[p]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(p in f={"%a":function(t){return h[t.Tb].substring(0,3)},"%A":function(t){return h[t.Tb]},"%b":function(t){return d[t.ec].substring(0,3)},"%B":function(t){return d[t.ec]},"%C":function(t){return u((t.Xb+1900)/100|0,2)},"%d":function(t){return u(t.jc,2)},"%e":function(t){return o(t.jc,2," ")},"%g":function(t){return l(t).toString().substring(2)},"%G":function(t){return l(t)},"%H":function(t){return u(t.dc,2)},"%I":function(t){return 0==(t=t.dc)?t=12:12t.dc?"AM":"PM"},"%S":function(t){return u(t.Lc,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Tb||7},"%U":function(t){return u(Math.floor((t.Wb+7-t.Tb)/7),2)},"%V":function(t){var e=Math.floor((t.Wb+7-(t.Tb+6)%7)/7);if(2>=(t.Tb+371-t.Wb-2)%7&&e++,e)53==e&&(4==(n=(t.Tb+371-t.Wb)%7)||3==n&&ue(t.Xb)||(e=1));else{e=52;var n=(t.Tb+7-t.Wb-1)%7;(4==n||5==n&&ue(t.Xb%400-1))&&e++}return u(e,2)},"%w":function(t){return t.Tb},"%W":function(t){return u(Math.floor((t.Wb+7-(t.Tb+6)%7)/7),2)},"%y":function(t){return(t.Xb+1900).toString().substring(2)},"%Y":function(t){return t.Xb+1900},"%z":function(t){var e=0<=(t=t.Jc);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.Mc},"%%":function(){return"%"}},r=r.replace(/%%/g,"\\0\\0"),f)r.includes(p)&&(r=r.replace(new RegExp(p,"g"),f[p](i)));return p=function(t){var e=Array(G(t)+1);return B(t,e,0,e.length),e}(r=r.replace(/\\0\\0/g,"%")),p.length>n?0:(function(t,n){e().set(t,n>>>0)}(p,t),p.length-1)}ht.fc();var fe=[null,ft,bt,Et,Ct,xt,Rt,jt,kt,Dt,Pt,Ut,Ft,It,Wt,Ht,Lt,Bt,Gt,Vt,Qt,Kt,te,ee,ne,ie],pe={b:function(t){return de(t+24)+24},n:function(t){return(t=new St(t)).uc()||(t.hc(!0),Ot--),t.ic(!1),_t.push(t),t.sc(),t.vc()},ma:function(t){throw x("Unexpected exception thrown, this is not properly supported - aborting"),H=!0,t},x:function(){Se(0);var t=_t.pop();if(t.Hc()&&!t.kc()){var e=t.Dc();e&>(e)(t.Zb),Tt(t.Zb)}At=0},e:function(){var t=At;if(!t)return oe=0;var e=new St(t);e.cc(t);var n=e.bc();if(!n)return oe=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;azt(r)));else if(O)postMessage({targetThread:t,cmd:"processProxyingQueue",queue:r});else{if(!(t=ht.Vb[t]))return;t.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},Ea:function(){return-1},Pa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getUTCSeconds(),a()[e+4>>2>>>0]=t.getUTCMinutes(),a()[e+8>>2>>>0]=t.getUTCHours(),a()[e+12>>2>>>0]=t.getUTCDate(),a()[e+16>>2>>>0]=t.getUTCMonth(),a()[e+20>>2>>>0]=t.getUTCFullYear()-1900,a()[e+24>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[e+28>>2>>>0]=t},Qa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),a()[e+20>>2>>>0]=t.getFullYear()-1900,a()[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1),r=(t.getTime()-n.getTime())/864e5|0;a()[e+28>>2>>>0]=r,a()[e+36>>2>>>0]=-60*t.getTimezoneOffset(),r=new Date(t.getFullYear(),6,1).getTimezoneOffset(),t=0|(r!=(n=n.getTimezoneOffset())&&t.getTimezoneOffset()==Math.min(n,r)),a()[e+32>>2>>>0]=t},Ra:function(t){var e=new Date(a()[t+20>>2>>>0]+1900,a()[t+16>>2>>>0],a()[t+12>>2>>>0],a()[t+8>>2>>>0],a()[t+4>>2>>>0],a()[t>>2>>>0],0),n=a()[t+32>>2>>>0],r=e.getTimezoneOffset(),i=new Date(e.getFullYear(),0,1),o=new Date(e.getFullYear(),6,1).getTimezoneOffset(),u=i.getTimezoneOffset(),c=Math.min(u,o);return 0>n?a()[t+32>>2>>>0]=Number(o!=u&&c==r):0>2>>>0]=e.getDay(),n=(e.getTime()-i.getTime())/864e5|0,a()[t+28>>2>>>0]=n,a()[t>>2>>>0]=e.getSeconds(),a()[t+4>>2>>>0]=e.getMinutes(),a()[t+8>>2>>>0]=e.getHours(),a()[t+12>>2>>>0]=e.getDate(),a()[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},Aa:Bt,Ba:Gt,Sa:function t(e,n,r){t.Ac||(t.Ac=!0,Vt(e,n,r))},y:function(){at("")},U:function(){if(!_&&!w){var t="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";vt||(vt={}),vt[t]||(vt[t]=1,_&&(t="warning: "+t),x(t))}},ra:function(){return 4294901760},B:wt,Ia:function(t,e,n){r().copyWithin(t>>>0,e>>>0,e+n>>>0)},F:function(){return _?n(993).cpus().length:navigator.hardwareConcurrency},Da:function(t,e,n){Xt.length=e,n>>=3;for(var r=0;r>>0];return(0>t?ut[-t-1]:fe[t]).apply(null,Xt)},qa:function(t){var e=r().length;if((t>>>=0)<=e||4294901760=n;n*=2){var a=e*(1+.2/n);a=Math.min(a,t+100663296);var i=Math;a=Math.max(t,a),i=i.min.call(i,4294901760,a+(65536-a%65536)%65536);t:{try{j.grow(i-D.byteLength+65535>>>16),N(j.buffer);var o=1;break t}catch(t){}o=void 0}if(o)return!0}return!1},Na:function(){throw"unwind"},Ga:Qt,Ha:Kt,J:pt,I:te,S:ee,ga:ne,R:ie,d:function(){return oe},na:function t(r,a){t.lc||(t.lc=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(_)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>at("randomDevice")}());for(var i=0;i>0>>>0]=t.lc();return 0},ia:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ja:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},K:function(t){var e=Ee();try{return gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},f:function(t,e){var n=Ee();try{return gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},P:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},Q:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},k:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},p:function(t,e,n,r){var a=Ee();try{return gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},q:function(t,e,n,r,a){var i=Ee();try{return gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},N:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},s:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},w:function(t,e,n,r,a,i,o){var u=Ee();try{return gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},L:function(t,e,n,r,a,i,o,u){var c=Ee();try{return gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},E:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{return gt(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=Ee();try{return He(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},_:function(t,e,n,r,a,i,o){var u=Ee();try{return ke(t,e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},Z:function(t,e,n,r,a){var i=Ee();try{return Le(t,e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},ca:function(t,e,n,r){var a=Ee();try{return Ie(t,e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},$:function(t){var e=Ee();try{return je(t)}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},ba:function(t,e){var n=Ee();try{return We(t,e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},Y:function(t,e,n){var r=Ee();try{return De(t,e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},g:function(t){var e=Ee();try{gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},r:function(t,e){var n=Ee();try{gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},i:function(t,e,n){var r=Ee();try{gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ha:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},m:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},v:function(t,e,n,r,a){var i=Ee();try{gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},u:function(t,e,n,r,a,i){var o=Ee();try{gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},O:function(t,e,n,r,a,i,o){var u=Ee();try{gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},A:function(t,e,n,r,a,i,o,u){var c=Ee();try{gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},ka:function(t,e,n,r,a,i,o,u,c){var s=Ee();try{gt(t)(e,n,r,a,i,o,u,c)}catch(t){if(Me(s),t!==t+0)throw t;Se(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l){var f=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(Me(f),t!==t+0)throw t;Se(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(Me(b),t!==t+0)throw t;Se(1,0)}},fa:function(t,e,n,r,a,i,o,u){var c=Ee();try{Pe(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},da:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{Fe(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},ea:function(t,e,n,r,a,i){var o=Ee();try{Ue(t,e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},o:function(t){return t},a:j||u.wasmMemory,G:function(t){oe=t},la:le,z:function(t,e,n,r){return le(t,e,n,r)}};!function(){function t(t,e){u.asm=t.exports,ht.qc.push(u.asm.sb),$=u.asm.ub,X.unshift(u.asm.Va),k=e,O||(et--,u.monitorRunDependencies&&u.monitorRunDependencies(et),0==et&&(null!==nt&&(clearInterval(nt),nt=null),rt&&(t=rt,rt=null,t())))}function e(e){t(e.instance,e.module)}function n(t){return function(){if(!M&&(v||w)){if("function"==typeof fetch&&!tt.startsWith("file://"))return fetch(tt,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+tt+"\'";return t.arrayBuffer()})).catch((function(){return ot()}));if(f)return new Promise((function(t,e){f(tt,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return ot()}))}().then((function(t){return WebAssembly.instantiate(t,r)})).then((function(t){return t})).then(t,(function(t){x("failed to asynchronously prepare wasm: "+t),at(t)}))}var r={a:pe};if(O||(et++,u.monitorRunDependencies&&u.monitorRunDependencies(et)),u.instantiateWasm)try{return u.instantiateWasm(r,t)}catch(t){return x("Module.instantiateWasm callback failed with error: "+t),!1}(M||"function"!=typeof WebAssembly.instantiateStreaming||it()||tt.startsWith("file://")||_||"function"!=typeof fetch?n(e):fetch(tt,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,r).then(e,(function(t){return x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation"),n(e)}))}))).catch(s)}(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.Va).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.Wa).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.Xa).apply(null,arguments)},u._OrtAppendExecutionProvider=function(){return(u._OrtAppendExecutionProvider=u.asm.Ya).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.Za).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm._a).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.$a).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.ab).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.bb).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.cb).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.db).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.eb).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.fb).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.gb).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.hb).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm.ib).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.jb).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.kb).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.lb).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.mb).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.nb).apply(null,arguments)};var he=u._pthread_self=function(){return(he=u._pthread_self=u.asm.ob).apply(null,arguments)},de=u._malloc=function(){return(de=u._malloc=u.asm.pb).apply(null,arguments)},ye=u._free=function(){return(ye=u._free=u.asm.qb).apply(null,arguments)},be=u._fflush=function(){return(be=u._fflush=u.asm.rb).apply(null,arguments)};u.__emscripten_tls_init=function(){return(u.__emscripten_tls_init=u.asm.sb).apply(null,arguments)};var me=u.___funcs_on_exit=function(){return(me=u.___funcs_on_exit=u.asm.tb).apply(null,arguments)},ge=u.__emscripten_thread_init=function(){return(ge=u.__emscripten_thread_init=u.asm.vb).apply(null,arguments)};u.__emscripten_thread_crashed=function(){return(u.__emscripten_thread_crashed=u.asm.wb).apply(null,arguments)};var ve,we=u._emscripten_run_in_main_runtime_thread_js=function(){return(we=u._emscripten_run_in_main_runtime_thread_js=u.asm.xb).apply(null,arguments)},_e=u.__emscripten_proxy_execute_task_queue=function(){return(_e=u.__emscripten_proxy_execute_task_queue=u.asm.yb).apply(null,arguments)},Oe=u.__emscripten_thread_free_data=function(){return(Oe=u.__emscripten_thread_free_data=u.asm.zb).apply(null,arguments)},Ae=u.__emscripten_thread_exit=function(){return(Ae=u.__emscripten_thread_exit=u.asm.Ab).apply(null,arguments)},Se=u._setThrew=function(){return(Se=u._setThrew=u.asm.Bb).apply(null,arguments)},Te=u._emscripten_stack_set_limits=function(){return(Te=u._emscripten_stack_set_limits=u.asm.Cb).apply(null,arguments)},Ee=u.stackSave=function(){return(Ee=u.stackSave=u.asm.Db).apply(null,arguments)},Me=u.stackRestore=function(){return(Me=u.stackRestore=u.asm.Eb).apply(null,arguments)},Ce=u.stackAlloc=function(){return(Ce=u.stackAlloc=u.asm.Fb).apply(null,arguments)},xe=u.___cxa_can_catch=function(){return(xe=u.___cxa_can_catch=u.asm.Gb).apply(null,arguments)},Re=u.___cxa_is_pointer_type=function(){return(Re=u.___cxa_is_pointer_type=u.asm.Hb).apply(null,arguments)},je=u.dynCall_j=function(){return(je=u.dynCall_j=u.asm.Ib).apply(null,arguments)},ke=u.dynCall_iiiiij=function(){return(ke=u.dynCall_iiiiij=u.asm.Jb).apply(null,arguments)},De=u.dynCall_jii=function(){return(De=u.dynCall_jii=u.asm.Kb).apply(null,arguments)},Pe=u.dynCall_viiiiij=function(){return(Pe=u.dynCall_viiiiij=u.asm.Lb).apply(null,arguments)},Ue=u.dynCall_vjji=function(){return(Ue=u.dynCall_vjji=u.asm.Mb).apply(null,arguments)},Fe=u.dynCall_viiijjjii=function(){return(Fe=u.dynCall_viiijjjii=u.asm.Nb).apply(null,arguments)},Ie=u.dynCall_iij=function(){return(Ie=u.dynCall_iij=u.asm.Ob).apply(null,arguments)},We=u.dynCall_ji=function(){return(We=u.dynCall_ji=u.asm.Pb).apply(null,arguments)},He=u.dynCall_iiiiiij=function(){return(He=u.dynCall_iiiiiij=u.asm.Qb).apply(null,arguments)},Le=u.dynCall_iiij=function(){return(Le=u.dynCall_iiij=u.asm.Rb).apply(null,arguments)};function ze(){function t(){if(!ve&&(ve=!0,u.calledRun=!0,!H)&&(O||dt(X),c(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),!O)){if(u.postRun)for("function"==typeof u.postRun&&(u.postRun=[u.postRun]);u.postRun.length;){var t=u.postRun.shift();Z.unshift(t)}dt(Z)}}if(!(0{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){var e,r,a;t=t||{},e||(e=void 0!==t?t:{}),e.ready=new Promise((function(t,e){r=t,a=e}));var i,o,u,c,s,l,f=Object.assign({},e),p="./this.program",h=(t,e)=>{throw e},d="object"==typeof window,y="function"==typeof importScripts,b="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,m="";b?(m=y?n(908).dirname(m)+"/":"//",l=()=>{s||(c=n(384),s=n(908))},i=function(t,e){return l(),t=s.normalize(t),c.readFileSync(t,e?void 0:"utf8")},u=t=>((t=i(t,!0)).buffer||(t=new Uint8Array(t)),t),o=(t,e,n)=>{l(),t=s.normalize(t),c.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1{if(_||0{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},y&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),o=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var g,v=e.print||console.log.bind(console),w=e.printErr||console.warn.bind(console);Object.assign(e,f),f=null,e.thisProgram&&(p=e.thisProgram),e.quit&&(h=e.quit),e.wasmBinary&&(g=e.wasmBinary);var _=e.noExitRuntime||!1;"object"!=typeof WebAssembly&&V("no native wasm support detected");var O,A,S,T,E,M,C=!1,x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function R(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function j(t,e){return(t>>>=0)?R(T,t,e):""}function k(t,e,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function D(t){for(var e=0,n=0;n=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function P(){var t=O.buffer;A=t,e.HEAP8=S=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=E=new Int32Array(t),e.HEAPU8=T=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=M=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}var U,F=[],I=[],W=[],H=[],L=0;function z(){var t=e.preRun.shift();F.unshift(t)}var Y,B=0,G=null,N=null;function V(t){throw e.onAbort&&e.onAbort(t),w(t="Aborted("+t+")"),C=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),a(t),t}function $(){return Y.startsWith("data:application/octet-stream;base64,")}if(Y="ort-wasm.wasm",!$()){var q=Y;Y=e.locateFile?e.locateFile(q,m):m+q}function X(){var t=Y;try{if(t==Y&&g)return new Uint8Array(g);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){V(t)}}function J(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Z(t){for(;0>2>>>0]=t},this.Eb=function(){return M[this.zb+4>>2>>>0]},this.Sb=function(t){M[this.zb+8>>2>>>0]=t},this.Wb=function(){return M[this.zb+8>>2>>>0]},this.Tb=function(){E[this.zb>>2>>>0]=0},this.Ib=function(t){S[this.zb+12>>0>>>0]=t?1:0},this.Pb=function(){return 0!=S[this.zb+12>>0>>>0]},this.Jb=function(t){S[this.zb+13>>0>>>0]=t?1:0},this.Lb=function(){return 0!=S[this.zb+13>>0>>>0]},this.Rb=function(t,e){this.Fb(0),this.Ub(t),this.Sb(e),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){E[this.zb>>2>>>0]+=1},this.Xb=function(){var t=E[this.zb>>2>>>0];return E[this.zb>>2>>>0]=t-1,1===t},this.Fb=function(t){M[this.zb+16>>2>>>0]=t},this.Ob=function(){return M[this.zb+16>>2>>>0]},this.Qb=function(){if(Mt(this.Eb()))return M[this.Db>>2>>>0];var t=this.Ob();return 0!==t?t:this.Db}}function nt(t){return vt(new et(t).zb)}var rt=[];function at(t){var e=rt[t];return e||(t>=rt.length&&(rt.length=t+1),rt[t]=e=U.get(t)),e}function it(t){var e=D(t)+1,n=gt(e);return n&&k(t,S,n,e),n}var ot={};function ut(){if(!ct){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:p||"./this.program"};for(t in ot)void 0===ot[t]?delete e[t]:e[t]=ot[t];var n=[];for(t in e)n.push(t+"="+e[t]);ct=n}return ct}var ct,st=[null,[],[]];function lt(t,e){var n=st[t];0===e||10===e?((1===t?v:w)(R(n,0)),n.length=0):n.push(e)}var ft=0;function pt(t){return 0==t%4&&(0!=t%100||0==t%400)}var ht=[31,29,31,30,31,30,31,31,30,31,30,31],dt=[31,28,31,30,31,30,31,31,30,31,30,31];function yt(t,e,n,r){function a(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.lengtht?-1:0r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=u(new Date(t.getFullYear(),0,4)),n=u(n),0>=o(e,t)?0>=o(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var s=E[r+40>>2>>>0];for(var l in r={$b:E[r>>2>>>0],Zb:E[r+4>>2>>>0],Gb:E[r+8>>2>>>0],Kb:E[r+12>>2>>>0],Hb:E[r+16>>2>>>0],Cb:E[r+20>>2>>>0],Ab:E[r+24>>2>>>0],Bb:E[r+28>>2>>>0],bc:E[r+32>>2>>>0],Yb:E[r+36>>2>>>0],ac:s?j(s):""},n=j(n),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(l,"g"),s[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(l in s={"%a":function(t){return f[t.Ab].substring(0,3)},"%A":function(t){return f[t.Ab]},"%b":function(t){return p[t.Hb].substring(0,3)},"%B":function(t){return p[t.Hb]},"%C":function(t){return i((t.Cb+1900)/100|0,2)},"%d":function(t){return i(t.Kb,2)},"%e":function(t){return a(t.Kb,2," ")},"%g":function(t){return c(t).toString().substring(2)},"%G":function(t){return c(t)},"%H":function(t){return i(t.Gb,2)},"%I":function(t){return 0==(t=t.Gb)?t=12:12t.Gb?"AM":"PM"},"%S":function(t){return i(t.$b,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Ab||7},"%U":function(t){return i(Math.floor((t.Bb+7-t.Ab)/7),2)},"%V":function(t){var e=Math.floor((t.Bb+7-(t.Ab+6)%7)/7);if(2>=(t.Ab+371-t.Bb-2)%7&&e++,e)53==e&&(4==(n=(t.Ab+371-t.Bb)%7)||3==n&&pt(t.Cb)||(e=1));else{e=52;var n=(t.Ab+7-t.Bb-1)%7;(4==n||5==n&&pt(t.Cb%400-1))&&e++}return i(e,2)},"%w":function(t){return t.Ab},"%W":function(t){return i(Math.floor((t.Bb+7-(t.Ab+6)%7)/7),2)},"%y":function(t){return(t.Cb+1900).toString().substring(2)},"%Y":function(t){return t.Cb+1900},"%z":function(t){var e=0<=(t=t.Yb);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.ac},"%%":function(){return"%"}},n=n.replace(/%%/g,"\\0\\0"),s)n.includes(l)&&(n=n.replace(new RegExp(l,"g"),s[l](r)));return l=function(t){var e=Array(D(t)+1);return k(t,e,0,e.length),e}(n=n.replace(/\\0\\0/g,"%")),l.length>e?0:(S.set(l,t>>>0),l.length-1)}var bt={a:function(t){return gt(t+24)+24},m:function(t){return(t=new et(t)).Pb()||(t.Ib(!0),K--),t.Jb(!1),Q.push(t),t.Nb(),t.Qb()},ia:function(t){throw w("Unexpected exception thrown, this is not properly supported - aborting"),C=!0,t},w:function(){Ot(0);var t=Q.pop();if(t.Xb()&&!t.Lb()){var e=t.Wb();e&&at(e)(t.Db),nt(t.Db)}tt=0},d:function(){var t=tt;if(!t)return ft=0;var e=new et(t);e.Fb(t);var n=e.Eb();if(!n)return ft=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getUTCSeconds(),E[e+4>>2>>>0]=t.getUTCMinutes(),E[e+8>>2>>>0]=t.getUTCHours(),E[e+12>>2>>>0]=t.getUTCDate(),E[e+16>>2>>>0]=t.getUTCMonth(),E[e+20>>2>>>0]=t.getUTCFullYear()-1900,E[e+24>>2>>>0]=t.getUTCDay(),E[e+28>>2>>>0]=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(t,e){t=new Date(1e3*(M[t>>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getSeconds(),E[e+4>>2>>>0]=t.getMinutes(),E[e+8>>2>>>0]=t.getHours(),E[e+12>>2>>>0]=t.getDate(),E[e+16>>2>>>0]=t.getMonth(),E[e+20>>2>>>0]=t.getFullYear()-1900,E[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1);E[e+28>>2>>>0]=(t.getTime()-n.getTime())/864e5|0,E[e+36>>2>>>0]=-60*t.getTimezoneOffset();var r=new Date(t.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),E[e+32>>2>>>0]=0|(r!=n&&t.getTimezoneOffset()==Math.min(n,r))},Fa:function(t){var e=new Date(E[t+20>>2>>>0]+1900,E[t+16>>2>>>0],E[t+12>>2>>>0],E[t+8>>2>>>0],E[t+4>>2>>>0],E[t>>2>>>0],0),n=E[t+32>>2>>>0],r=e.getTimezoneOffset(),a=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear(),6,1).getTimezoneOffset(),o=a.getTimezoneOffset(),u=Math.min(o,i);return 0>n?E[t+32>>2>>>0]=Number(i!=o&&u==r):0>2>>>0]=e.getDay(),E[t+28>>2>>>0]=(e.getTime()-a.getTime())/864e5|0,E[t>>2>>>0]=e.getSeconds(),E[t+4>>2>>>0]=e.getMinutes(),E[t+8>>2>>>0]=e.getHours(),E[t+12>>2>>>0]=e.getDate(),E[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function t(e,n,r){t.Vb||(t.Vb=!0,function(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}var a=(new Date).getFullYear(),i=new Date(a,0,1),o=new Date(a,6,1);a=i.getTimezoneOffset();var u=o.getTimezoneOffset();E[t>>2>>>0]=60*Math.max(a,u),E[e>>2>>>0]=Number(a!=u),t=r(i),e=r(o),t=it(t),e=it(e),u>2>>>0]=t,M[n+4>>2>>>0]=e):(M[n>>2>>>0]=e,M[n+4>>2>>>0]=t)}(e,n,r))},B:function(){V("")},ma:function(){return 4294901760},I:b?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:()=>performance.now(),xa:function(t,e,n){T.copyWithin(t>>>0,e>>>0,e+n>>>0)},G:function(t){var e=T.length;if(4294901760<(t>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=e*(1+.2/n);r=Math.min(r,t+100663296);var a=Math;r=Math.max(t,r),a=a.min.call(a,4294901760,r+(65536-r%65536)%65536);t:{try{O.grow(a-A.byteLength+65535>>>16),P();var i=1;break t}catch(t){}i=void 0}if(i)return!0}return!1},va:function(t,e){var n=0;return ut().forEach((function(r,a){var i=e+n;for(a=M[t+4*a>>2>>>0]=i,i=0;i>0>>>0]=r.charCodeAt(i);S[a>>0>>>0]=0,n+=r.length+1})),0},wa:function(t,e){var n=ut();M[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),M[e>>2>>>0]=r,0},ba:function(t){_||0>2>>>0],u=M[e+4>>2>>>0];e+=8;for(var c=0;c>>0]);a+=u}return M[r>>2>>>0]=a,0},c:function(){return ft},ja:function t(e,r){t.Mb||(t.Mb=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(b)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>V("randomDevice")}());for(var a=0;a>0>>>0]=t.Mb();return 0},ea:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},fa:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},J:function(t){var e=At();try{return at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},e:function(t,e){var n=At();try{return at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},N:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},O:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},j:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},o:function(t,e,n,r){var a=At();try{return at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},p:function(t,e,n,r,a){var i=At();try{return at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},M:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},r:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},v:function(t,e,n,r,a,i,o){var u=At();try{return at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},K:function(t,e,n,r,a,i,o,u){var c=At();try{return at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{return at(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},X:function(t,e,n,r,a,i,o,u){var c=At();try{return Ft(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},V:function(t,e,n,r,a,i,o){var u=At();try{return xt(t,e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},U:function(t,e,n,r,a){var i=At();try{return It(t,e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},Z:function(t,e,n,r){var a=At();try{return Pt(t,e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},W:function(t){var e=At();try{return Ct(t)}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},Y:function(t,e){var n=At();try{return Ut(t,e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},T:function(t,e,n){var r=At();try{return Rt(t,e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},f:function(t){var e=At();try{at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},q:function(t,e){var n=At();try{at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},h:function(t,e,n){var r=At();try{at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},da:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},l:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},t:function(t,e,n,r,a){var i=At();try{at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},u:function(t,e,n,r,a,i){var o=At();try{at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},x:function(t,e,n,r,a,i,o){var u=At();try{at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},z:function(t,e,n,r,a,i,o,u){var c=At();try{at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},ga:function(t,e,n,r,a,i,o,u,c){var s=At();try{at(t)(e,n,r,a,i,o,u,c)}catch(t){if(St(s),t!==t+0)throw t;Ot(1,0)}},A:function(t,e,n,r,a,i,o,u,c,s,l){var f=At();try{at(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(St(f),t!==t+0)throw t;Ot(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=At();try{at(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(St(b),t!==t+0)throw t;Ot(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=At();try{jt(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},_:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{Dt(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},$:function(t,e,n,r,a,i){var o=At();try{kt(t,e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},n:function(t){return t},F:function(t){ft=t},ha:yt,y:function(t,e,n,r){return yt(t,e,n,r)}};!function(){function t(t){e.asm=t.exports,O=e.asm.Ka,P(),U=e.asm.ib,I.unshift(e.asm.La),B--,e.monitorRunDependencies&&e.monitorRunDependencies(B),0==B&&(null!==G&&(clearInterval(G),G=null),N&&(t=N,N=null,t()))}function n(e){t(e.instance)}function r(t){return function(){if(!g&&(d||y)){if("function"==typeof fetch&&!Y.startsWith("file://"))return fetch(Y,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+Y+"\'";return t.arrayBuffer()})).catch((function(){return X()}));if(o)return new Promise((function(t,e){o(Y,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return X()}))}().then((function(t){return WebAssembly.instantiate(t,i)})).then((function(t){return t})).then(t,(function(t){w("failed to asynchronously prepare wasm: "+t),V(t)}))}var i={a:bt};if(B++,e.monitorRunDependencies&&e.monitorRunDependencies(B),e.instantiateWasm)try{return e.instantiateWasm(i,t)}catch(t){return w("Module.instantiateWasm callback failed with error: "+t),!1}(g||"function"!=typeof WebAssembly.instantiateStreaming||$()||Y.startsWith("file://")||b||"function"!=typeof fetch?r(n):fetch(Y,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(n,(function(t){return w("wasm streaming compile failed: "+t),w("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a)}(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.La).apply(null,arguments)},e._OrtInit=function(){return(e._OrtInit=e.asm.Ma).apply(null,arguments)},e._OrtCreateSessionOptions=function(){return(e._OrtCreateSessionOptions=e.asm.Na).apply(null,arguments)},e._OrtAppendExecutionProvider=function(){return(e._OrtAppendExecutionProvider=e.asm.Oa).apply(null,arguments)},e._OrtAddSessionConfigEntry=function(){return(e._OrtAddSessionConfigEntry=e.asm.Pa).apply(null,arguments)},e._OrtReleaseSessionOptions=function(){return(e._OrtReleaseSessionOptions=e.asm.Qa).apply(null,arguments)},e._OrtCreateSession=function(){return(e._OrtCreateSession=e.asm.Ra).apply(null,arguments)},e._OrtReleaseSession=function(){return(e._OrtReleaseSession=e.asm.Sa).apply(null,arguments)},e._OrtGetInputCount=function(){return(e._OrtGetInputCount=e.asm.Ta).apply(null,arguments)},e._OrtGetOutputCount=function(){return(e._OrtGetOutputCount=e.asm.Ua).apply(null,arguments)},e._OrtGetInputName=function(){return(e._OrtGetInputName=e.asm.Va).apply(null,arguments)},e._OrtGetOutputName=function(){return(e._OrtGetOutputName=e.asm.Wa).apply(null,arguments)},e._OrtFree=function(){return(e._OrtFree=e.asm.Xa).apply(null,arguments)},e._OrtCreateTensor=function(){return(e._OrtCreateTensor=e.asm.Ya).apply(null,arguments)},e._OrtGetTensorData=function(){return(e._OrtGetTensorData=e.asm.Za).apply(null,arguments)},e._OrtReleaseTensor=function(){return(e._OrtReleaseTensor=e.asm._a).apply(null,arguments)},e._OrtCreateRunOptions=function(){return(e._OrtCreateRunOptions=e.asm.$a).apply(null,arguments)},e._OrtAddRunConfigEntry=function(){return(e._OrtAddRunConfigEntry=e.asm.ab).apply(null,arguments)},e._OrtReleaseRunOptions=function(){return(e._OrtReleaseRunOptions=e.asm.bb).apply(null,arguments)},e._OrtRun=function(){return(e._OrtRun=e.asm.cb).apply(null,arguments)},e._OrtEndProfiling=function(){return(e._OrtEndProfiling=e.asm.db).apply(null,arguments)};var mt,gt=e._malloc=function(){return(gt=e._malloc=e.asm.eb).apply(null,arguments)},vt=e._free=function(){return(vt=e._free=e.asm.fb).apply(null,arguments)},wt=e._fflush=function(){return(wt=e._fflush=e.asm.gb).apply(null,arguments)},_t=e.___funcs_on_exit=function(){return(_t=e.___funcs_on_exit=e.asm.hb).apply(null,arguments)},Ot=e._setThrew=function(){return(Ot=e._setThrew=e.asm.jb).apply(null,arguments)},At=e.stackSave=function(){return(At=e.stackSave=e.asm.kb).apply(null,arguments)},St=e.stackRestore=function(){return(St=e.stackRestore=e.asm.lb).apply(null,arguments)},Tt=e.stackAlloc=function(){return(Tt=e.stackAlloc=e.asm.mb).apply(null,arguments)},Et=e.___cxa_can_catch=function(){return(Et=e.___cxa_can_catch=e.asm.nb).apply(null,arguments)},Mt=e.___cxa_is_pointer_type=function(){return(Mt=e.___cxa_is_pointer_type=e.asm.ob).apply(null,arguments)},Ct=e.dynCall_j=function(){return(Ct=e.dynCall_j=e.asm.pb).apply(null,arguments)},xt=e.dynCall_iiiiij=function(){return(xt=e.dynCall_iiiiij=e.asm.qb).apply(null,arguments)},Rt=e.dynCall_jii=function(){return(Rt=e.dynCall_jii=e.asm.rb).apply(null,arguments)},jt=e.dynCall_viiiiij=function(){return(jt=e.dynCall_viiiiij=e.asm.sb).apply(null,arguments)},kt=e.dynCall_vjji=function(){return(kt=e.dynCall_vjji=e.asm.tb).apply(null,arguments)},Dt=e.dynCall_viiijjjii=function(){return(Dt=e.dynCall_viiijjjii=e.asm.ub).apply(null,arguments)},Pt=e.dynCall_iij=function(){return(Pt=e.dynCall_iij=e.asm.vb).apply(null,arguments)},Ut=e.dynCall_ji=function(){return(Ut=e.dynCall_ji=e.asm.wb).apply(null,arguments)},Ft=e.dynCall_iiiiiij=function(){return(Ft=e.dynCall_iiiiiij=e.asm.xb).apply(null,arguments)},It=e.dynCall_iiij=function(){return(It=e.dynCall_iiij=e.asm.yb).apply(null,arguments)};function Wt(){function t(){if(!mt&&(mt=!0,e.calledRun=!0,!C)){if(Z(I),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var t=e.postRun.shift();H.unshift(t)}Z(H)}}if(!(0{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iterateExtraOptions=void 0,e.iterateExtraOptions=(t,n,r,a)=>{if("object"==typeof t&&null!==t){if(r.has(t))throw new Error("Circular reference in options");r.add(t)}Object.entries(t).forEach((([t,i])=>{const o=n?n+t:t;if("object"==typeof i)(0,e.iterateExtraOptions)(i,o+".",r,a);else if("string"==typeof i||"number"==typeof i)a(o,i.toString());else{if("boolean"!=typeof i)throw new Error("Can\'t handle extra config type: "+typeof i);a(o,i?"1":"0")}}))}},586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setRunOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};try{if(void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);void 0===(null==t?void 0:t.terminate)&&(u.terminate=!1);let i=0;if(void 0!==(null==t?void 0:t.tag)&&(i=(0,a.allocWasmString)(t.tag,o)),n=e._OrtCreateRunOptions(u.logSeverityLevel,u.logVerbosityLevel,!!u.terminate,i),0===n)throw new Error("Can\'t create run options");return void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddRunConfigEntry(n,i,u))throw new Error(`Can\'t set a run config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseRunOptions(n),o.forEach(e._free),t}}},919:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setSessionOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};(t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});const e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(u);try{void 0===(null==t?void 0:t.graphOptimizationLevel)&&(u.graphOptimizationLevel="all");const c=(t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}})(u.graphOptimizationLevel);void 0===(null==t?void 0:t.enableCpuMemArena)&&(u.enableCpuMemArena=!0),void 0===(null==t?void 0:t.enableMemPattern)&&(u.enableMemPattern=!0),void 0===(null==t?void 0:t.executionMode)&&(u.executionMode="sequential");const s=(t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}})(u.executionMode);let l=0;if(void 0!==(null==t?void 0:t.logId)&&(l=(0,a.allocWasmString)(t.logId,o)),void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);if(void 0===(null==t?void 0:t.enableProfiling)&&(u.enableProfiling=!1),n=e._OrtCreateSessionOptions(c,!!u.enableCpuMemArena,!!u.enableMemPattern,s,!!u.enableProfiling,0,l,u.logSeverityLevel,u.logVerbosityLevel),0===n)throw new Error("Can\'t create session options");return(null==t?void 0:t.executionProviders)&&((t,e,n)=>{for(const r of e){let e="string"==typeof r?r:r.name;switch(e){case"xnnpack":e="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${e}`)}const o=(0,a.allocWasmString)(e,n);if(0!==(0,i.getInstance)()._OrtAppendExecutionProvider(t,o))throw new Error(`Can\'t append execution provider: ${e}`)}})(n,t.executionProviders,o),void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddSessionConfigEntry(n,i,u))throw new Error(`Can\'t set a session config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseSessionOptions(n),o.forEach(e._free),t}}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.allocWasmString=void 0;const r=n(361);e.allocWasmString=(t,e)=>{const n=(0,r.getInstance)(),a=n.lengthBytesUTF8(t)+1,i=n._malloc(a);return n.stringToUTF8(t,i,a),e.push(i),i}},349:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initOrt=void 0;const r=n(586),a=n(919),i=n(983),o=n(361);e.initOrt=(t,e)=>{const n=(0,o.getInstance)()._OrtInit(t,e);if(0!==n)throw new Error(`Can\'t initialize onnxruntime. error code = ${n}`)};const u=new Map;e.createSessionAllocate=t=>{const e=(0,o.getInstance)(),n=e._malloc(t.byteLength);return e.HEAPU8.set(t,n),[n,t.byteLength]},e.createSessionFinalize=(t,e)=>{const n=(0,o.getInstance)();let r=0,i=0,c=[];try{if([i,c]=(0,a.setSessionOptions)(e),r=n._OrtCreateSession(t[0],t[1],i),0===r)throw new Error("Can\'t create a session")}finally{n._free(t[0]),n._OrtReleaseSessionOptions(i),c.forEach(n._free)}const s=n._OrtGetInputCount(r),l=n._OrtGetOutputCount(r),f=[],p=[],h=[],d=[];for(let t=0;t{const r=(0,e.createSessionAllocate)(t);return(0,e.createSessionFinalize)(r,n)},e.releaseSession=t=>{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=n[1],i=n[2];a.forEach(e._OrtFree),i.forEach(e._OrtFree),e._OrtReleaseSession(r),u.delete(t)};const c=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${t}`)}},s=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${t}`)}},l=t=>{switch(t){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}};e.run=(t,e,n,a,f)=>{const p=(0,o.getInstance)(),h=u.get(t);if(!h)throw new Error("invalid session id");const d=h[0],y=h[1],b=h[2],m=e.length,g=a.length;let v=0,w=[];const _=[],O=[];try{[v,w]=(0,r.setRunOptions)(f);for(let t=0;tp.HEAP32[t++]=e));const n=p._OrtCreateTensor(c(e),o,u,l,r.length);if(0===n)throw new Error("Can\'t create a tensor");_.push(n)}finally{p.stackRestore(s)}}const t=p.stackSave(),o=p.stackAlloc(4*m),u=p.stackAlloc(4*m),h=p.stackAlloc(4*g),A=p.stackAlloc(4*g);try{let n=o/4,r=u/4,i=h/4,c=A/4;for(let t=0;tt*e));if(a=s(o),"string"===a){const t=[];let e=i/4;for(let n=0;n{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=e._OrtEndProfiling(r);if(0===a)throw new Error("Can\'t get an profile file name");e._OrtFree(a)},e.extractTransferableBuffers=t=>{const e=[];for(const n of t){const t=n[2];!Array.isArray(t)&&t.buffer&&e.push(t.buffer)}return e}},361:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return a(e,t),e},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const u=i(n(449)),c=o(n(932)),s=n(474);let l,f=!1,p=!1,h=!1;const d=(t,e)=>e?t?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":t?"ort-wasm-simd.wasm":"ort-wasm.wasm";e.initializeWebAssembly=async t=>{if(f)return Promise.resolve();if(p)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(h)throw new Error("previous call to \'initializeWebAssembly()\' failed.");p=!0;const e=t.initTimeout,r=t.numThreads,a=t.simd,i=r>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(t){return!1}})(),o=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(t){return!1}})(),y="string"==typeof t.wasmPaths?t.wasmPaths:void 0,b=d(!1,i),m=d(o,i),g="object"==typeof t.wasmPaths?t.wasmPaths[m]:void 0;let v=!1;const w=[];if(e>0&&w.push(new Promise((t=>{setTimeout((()=>{v=!0,t()}),e)}))),w.push(new Promise(((t,e)=>{const r=i?s:c.default,a={locateFile:(t,e)=>i&&t.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([n(154)],{type:"text/javascript"})):t===b?null!=g?g:(null!=y?y:e)+m:e+t};if(i)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=u.join("/","ort-wasm-threaded.js");else{const t=`var ortWasmThreaded=(function(){var _scriptDir;return ${r.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([t],{type:"text/javascript"})}r(a).then((e=>{p=!1,f=!0,l=e,t()}),(t=>{p=!1,h=!0,e(t)}))}))),await Promise.race(w),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},e.getInstance=()=>{if(f&&l)return l;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var t;!f||p||h||(p=!0,null===(t=l.PThread)||void 0===t||t.terminateAllThreads(),l=void 0,p=!1,f=!1,h=!0)}},154:t=>{"use strict";t.exports=\'"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};\\n\'},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{"use strict";const t=n(349),e=n(361);self.onmessage=n=>{switch(n.data.type){case"init-wasm":(0,e.initializeWebAssembly)(n.data.in).then((()=>postMessage({type:"init-wasm"})),(t=>postMessage({type:"init-wasm",err:t})));break;case"init-ort":try{const{numThreads:e,loggingLevel:r}=n.data.in;(0,t.initOrt)(e,r),postMessage({type:"init-ort"})}catch(t){postMessage({type:"init-ort",err:t})}break;case"create_allocate":try{const{model:e}=n.data.in,r=(0,t.createSessionAllocate)(e);postMessage({type:"create_allocate",out:r})}catch(t){postMessage({type:"create_allocate",err:t})}break;case"create_finalize":try{const{modeldata:e,options:r}=n.data.in,a=(0,t.createSessionFinalize)(e,r);postMessage({type:"create_finalize",out:a})}catch(t){postMessage({type:"create_finalize",err:t})}break;case"create":try{const{model:e,options:r}=n.data.in,a=(0,t.createSession)(e,r);postMessage({type:"create",out:a})}catch(t){postMessage({type:"create",err:t})}break;case"release":try{const e=n.data.in;(0,t.releaseSession)(e),postMessage({type:"release"})}catch(t){postMessage({type:"release",err:t})}break;case"run":try{const{sessionId:e,inputIndices:r,inputs:a,outputIndices:i,options:o}=n.data.in,u=(0,t.run)(e,r,a,i,o);postMessage({type:"run",out:u},(0,t.extractTransferableBuffers)(u))}catch(t){postMessage({type:"run",err:t})}break;case"end-profiling":try{const e=n.data.in;(0,t.endProfiling)(e),postMessage({type:"end-profiling"})}catch(t){postMessage({type:"end-profiling",err:t})}}}})()})();\n',"Worker",void 0,void 0)}},477:D=>{D.exports=function(u,b,g,p){var h=self||window;try{try{var o;try{o=new h.Blob([u])}catch{(o=new(h.BlobBuilder||h.WebKitBlobBuilder||h.MozBlobBuilder||h.MSBlobBuilder)).append(u),o=o.getBlob()}var c=h.URL||h.webkitURL,f=c.createObjectURL(o),s=new h[b](f,g);return c.revokeObjectURL(f),s}catch{return new h[b]("data:application/javascript,".concat(encodeURIComponent(u)),g)}}catch{if(!p)throw Error("Inline worker is not supported");return new h[b](p,g)}}},4154:D=>{D.exports=`"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}}; +`},1670:D=>{D.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(D,u,b)=>{b.r(u),b.d(u,{flatbuffers:()=>g});var g={};g.Offset,g.Table,g.SIZEOF_SHORT=2,g.SIZEOF_INT=4,g.FILE_IDENTIFIER_LENGTH=4,g.SIZE_PREFIX_LENGTH=4,g.Encoding={UTF8_BYTES:1,UTF16_STRING:2},g.int32=new Int32Array(2),g.float32=new Float32Array(g.int32.buffer),g.float64=new Float64Array(g.int32.buffer),g.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,g.Long=function(p,h){this.low=0|p,this.high=0|h},g.Long.create=function(p,h){return p==0&&h==0?g.Long.ZERO:new g.Long(p,h)},g.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},g.Long.prototype.equals=function(p){return this.low==p.low&&this.high==p.high},g.Long.ZERO=new g.Long(0,0),g.Builder=function(p){if(p)h=p;else var h=1024;this.bb=g.ByteBuffer.allocate(h),this.space=h,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},g.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},g.Builder.prototype.forceDefaults=function(p){this.force_defaults=p},g.Builder.prototype.dataBuffer=function(){return this.bb},g.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},g.Builder.prototype.prep=function(p,h){p>this.minalign&&(this.minalign=p);for(var o=1+~(this.bb.capacity()-this.space+h)&p-1;this.space=0&&this.vtable[h]==0;h--);for(var o=h+1;h>=0;h--)this.addInt16(this.vtable[h]!=0?p-this.vtable[h]:0);this.addInt16(p-this.object_start);var c=(o+2)*g.SIZEOF_SHORT;this.addInt16(c);var f=0,s=this.space;e:for(h=0;h=0;s--)this.writeInt8(f.charCodeAt(s))}this.prep(this.minalign,g.SIZEOF_INT+c),this.addOffset(p),c&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},g.Builder.prototype.finishSizePrefixed=function(p,h){this.finish(p,h,!0)},g.Builder.prototype.requiredField=function(p,h){var o=this.bb.capacity()-p,c=o-this.bb.readInt32(o);if(this.bb.readInt16(c+h)==0)throw new Error("FlatBuffers: field "+h+" must be set")},g.Builder.prototype.startVector=function(p,h,o){this.notNested(),this.vector_num_elems=h,this.prep(g.SIZEOF_INT,p*h),this.prep(o,p*h)},g.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},g.Builder.prototype.createString=function(p){if(p instanceof Uint8Array)var h=p;else{h=[];for(var o=0;o=56320?f:(f<<10)+p.charCodeAt(o++)+-56613888)<128?h.push(c):(c<2048?h.push(c>>6&31|192):(c<65536?h.push(c>>12&15|224):h.push(c>>18&7|240,c>>12&63|128),h.push(c>>6&63|128)),h.push(63&c|128))}}this.addInt8(0),this.startVector(1,h.length,1),this.bb.setPosition(this.space-=h.length),o=0;for(var s=this.space,i=this.bb.bytes();o>24},g.ByteBuffer.prototype.readUint8=function(p){return this.bytes_[p]},g.ByteBuffer.prototype.readInt16=function(p){return this.readUint16(p)<<16>>16},g.ByteBuffer.prototype.readUint16=function(p){return this.bytes_[p]|this.bytes_[p+1]<<8},g.ByteBuffer.prototype.readInt32=function(p){return this.bytes_[p]|this.bytes_[p+1]<<8|this.bytes_[p+2]<<16|this.bytes_[p+3]<<24},g.ByteBuffer.prototype.readUint32=function(p){return this.readInt32(p)>>>0},g.ByteBuffer.prototype.readInt64=function(p){return new g.Long(this.readInt32(p),this.readInt32(p+4))},g.ByteBuffer.prototype.readUint64=function(p){return new g.Long(this.readUint32(p),this.readUint32(p+4))},g.ByteBuffer.prototype.readFloat32=function(p){return g.int32[0]=this.readInt32(p),g.float32[0]},g.ByteBuffer.prototype.readFloat64=function(p){return g.int32[g.isLittleEndian?0:1]=this.readInt32(p),g.int32[g.isLittleEndian?1:0]=this.readInt32(p+4),g.float64[0]},g.ByteBuffer.prototype.writeInt8=function(p,h){this.bytes_[p]=h},g.ByteBuffer.prototype.writeUint8=function(p,h){this.bytes_[p]=h},g.ByteBuffer.prototype.writeInt16=function(p,h){this.bytes_[p]=h,this.bytes_[p+1]=h>>8},g.ByteBuffer.prototype.writeUint16=function(p,h){this.bytes_[p]=h,this.bytes_[p+1]=h>>8},g.ByteBuffer.prototype.writeInt32=function(p,h){this.bytes_[p]=h,this.bytes_[p+1]=h>>8,this.bytes_[p+2]=h>>16,this.bytes_[p+3]=h>>24},g.ByteBuffer.prototype.writeUint32=function(p,h){this.bytes_[p]=h,this.bytes_[p+1]=h>>8,this.bytes_[p+2]=h>>16,this.bytes_[p+3]=h>>24},g.ByteBuffer.prototype.writeInt64=function(p,h){this.writeInt32(p,h.low),this.writeInt32(p+4,h.high)},g.ByteBuffer.prototype.writeUint64=function(p,h){this.writeUint32(p,h.low),this.writeUint32(p+4,h.high)},g.ByteBuffer.prototype.writeFloat32=function(p,h){g.float32[0]=h,this.writeInt32(p,g.int32[0])},g.ByteBuffer.prototype.writeFloat64=function(p,h){g.float64[0]=h,this.writeInt32(p,g.int32[g.isLittleEndian?0:1]),this.writeInt32(p+4,g.int32[g.isLittleEndian?1:0])},g.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&s)))}return c},g.ByteBuffer.prototype.__indirect=function(p){return p+this.readInt32(p)},g.ByteBuffer.prototype.__vector=function(p){return p+this.readInt32(p)+g.SIZEOF_INT},g.ByteBuffer.prototype.__vector_len=function(p){return this.readInt32(p+this.readInt32(p))},g.ByteBuffer.prototype.__has_identifier=function(p){if(p.length!=g.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+g.FILE_IDENTIFIER_LENGTH);for(var h=0;h{var u=D&&D.__esModule?()=>D.default:()=>D;return __webpack_require__.d(u,{a:u}),u},__webpack_require__.d=(D,u)=>{for(var b in u)__webpack_require__.o(u,b)&&!__webpack_require__.o(D,b)&&Object.defineProperty(D,b,{enumerable:!0,get:u[b]})},__webpack_require__.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),__webpack_require__.o=(D,u)=>Object.prototype.hasOwnProperty.call(D,u),__webpack_require__.r=D=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(D,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(D,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())}(ortWeb_min)),ortWeb_min.exports}var assetPath={},hasRequiredAssetPath;function requireAssetPath(){if(hasRequiredAssetPath)return assetPath;hasRequiredAssetPath=1,Object.defineProperty(assetPath,"__esModule",{value:!0}),assetPath.baseAssetPath=void 0;const u=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let b="/";return u&&(b=u.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),assetPath.baseAssetPath=b,assetPath}var defaultModelFetcher={},hasRequiredDefaultModelFetcher;function requireDefaultModelFetcher(){if(hasRequiredDefaultModelFetcher)return defaultModelFetcher;hasRequiredDefaultModelFetcher=1,Object.defineProperty(defaultModelFetcher,"__esModule",{value:!0}),defaultModelFetcher.defaultModelFetcher=void 0;const D=u=>fetch(u).then(b=>b.arrayBuffer());return defaultModelFetcher.defaultModelFetcher=D,defaultModelFetcher}var frameProcessor={},logging={},hasRequiredLogging;function requireLogging(){return hasRequiredLogging||(hasRequiredLogging=1,function(D){Object.defineProperty(D,"__esModule",{value:!0}),D.log=D.LOG_PREFIX=void 0,D.LOG_PREFIX="[VAD]";const u=["error","debug","warn"];function b(p){return(...h)=>{console[p](D.LOG_PREFIX,...h)}}const g=u.reduce((p,h)=>(p[h]=b(h),p),{});D.log=g}(logging)),logging}var messages={},hasRequiredMessages;function requireMessages(){if(hasRequiredMessages)return messages;hasRequiredMessages=1,Object.defineProperty(messages,"__esModule",{value:!0}),messages.Message=void 0;var D;return function(u){u.AudioFrame="AUDIO_FRAME",u.SpeechStart="SPEECH_START",u.VADMisfire="VAD_MISFIRE",u.SpeechEnd="SPEECH_END",u.SpeechStop="SPEECH_STOP"}(D||(messages.Message=D={})),messages}var hasRequiredFrameProcessor;function requireFrameProcessor(){if(hasRequiredFrameProcessor)return frameProcessor;hasRequiredFrameProcessor=1,Object.defineProperty(frameProcessor,"__esModule",{value:!0}),frameProcessor.FrameProcessor=frameProcessor.validateOptions=frameProcessor.defaultV5FrameProcessorOptions=frameProcessor.defaultLegacyFrameProcessorOptions=void 0;const D=requireLogging(),u=requireMessages(),b=[512,1024,1536];frameProcessor.defaultLegacyFrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:1,redemptionFrames:8,frameSamples:1536,minSpeechFrames:3,submitUserSpeechOnPause:!1},frameProcessor.defaultV5FrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:3,redemptionFrames:24,frameSamples:512,minSpeechFrames:9,submitUserSpeechOnPause:!1};function g(o){b.includes(o.frameSamples)||D.log.warn("You are using an unusual frame size"),(o.positiveSpeechThreshold<0||o.positiveSpeechThreshold>1)&&D.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(o.negativeSpeechThreshold<0||o.negativeSpeechThreshold>o.positiveSpeechThreshold)&&D.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),o.preSpeechPadFrames<0&&D.log.error("preSpeechPadFrames should be positive"),o.redemptionFrames<0&&D.log.error("redemptionFrames should be positive")}frameProcessor.validateOptions=g;const p=o=>{const c=o.reduce((s,i)=>(s.push(s.at(-1)+i.length),s),[0]),f=new Float32Array(c.at(-1));return o.forEach((s,i)=>{const t=c[i];f.set(s,t)}),f};class h{constructor(c,f,s){this.modelProcessFunc=c,this.modelResetFunc=f,this.options=s,this.speaking=!1,this.redemptionCounter=0,this.active=!1,this.reset=()=>{this.speaking=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0},this.pause=()=>(this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment():(this.reset(),{})),this.resume=()=>{this.active=!0},this.endSegment=()=>{const i=this.audioBuffer;this.audioBuffer=[];const t=this.speaking;this.reset();const e=i.reduce((n,r)=>n+ +r.isSpeech,0);if(t)if(e>=this.options.minSpeechFrames){const n=p(i.map(r=>r.frame));return{msg:u.Message.SpeechEnd,audio:n}}else return{msg:u.Message.VADMisfire};return{}},this.process=async i=>{if(!this.active)return{};const t=await this.modelProcessFunc(i);if(this.audioBuffer.push({frame:i,isSpeech:t.isSpeech>=this.options.positiveSpeechThreshold}),t.isSpeech>=this.options.positiveSpeechThreshold&&this.redemptionCounter&&(this.redemptionCounter=0),t.isSpeech>=this.options.positiveSpeechThreshold&&!this.speaking)return this.speaking=!0,{probs:t,msg:u.Message.SpeechStart,frame:i};if(t.isSpeech=this.options.redemptionFrames){this.redemptionCounter=0,this.speaking=!1;const e=this.audioBuffer;if(this.audioBuffer=[],e.reduce((r,a)=>r+ +a.isSpeech,0)>=this.options.minSpeechFrames){const r=p(e.map(a=>a.frame));return{probs:t,msg:u.Message.SpeechEnd,audio:r,frame:i}}else return{probs:t,msg:u.Message.VADMisfire,frame:i}}if(!this.speaking)for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();return{probs:t,frame:i}},this.audioBuffer=[],this.reset()}}return frameProcessor.FrameProcessor=h,frameProcessor}var nonRealTimeVad={},models={},common={},hasRequiredCommon;function requireCommon(){return hasRequiredCommon||(hasRequiredCommon=1,Object.defineProperty(common,"__esModule",{value:!0})),common}var legacy={},hasRequiredLegacy;function requireLegacy(){if(hasRequiredLegacy)return legacy;hasRequiredLegacy=1;var D;Object.defineProperty(legacy,"__esModule",{value:!0}),legacy.SileroLegacy=void 0;const u=requireLogging();class b{constructor(p,h,o,c,f){this.ortInstance=p,this._session=h,this._h=o,this._c=c,this._sr=f,this.reset_state=()=>{const s=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",s,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",s,[2,1,64])},this.process=async s=>{var a;const t={input:new this.ortInstance.Tensor("float32",s,[1,s.length]),h:this._h,c:this._c,sr:this._sr},e=await this._session.run(t);this._h=e.hn,this._c=e.cn;const[n]=(a=e.output)==null?void 0:a.data;return{notSpeech:1-n,isSpeech:n}}}}return legacy.SileroLegacy=b,D=b,b.new=async(g,p)=>{u.log.debug("initializing vad");const h=await p(),o=await g.InferenceSession.create(h),c=new g.Tensor("int64",[16000n]),f=Array(2*64).fill(0),s=new g.Tensor("float32",f,[2,1,64]),i=new g.Tensor("float32",f,[2,1,64]);return u.log.debug("vad is initialized"),new D(g,o,s,i,c)},legacy}var v5={},hasRequiredV5;function requireV5(){if(hasRequiredV5)return v5;hasRequiredV5=1;var D;Object.defineProperty(v5,"__esModule",{value:!0}),v5.SileroV5=void 0;const u=requireLogging();function b(p){const h=Array(256).fill(0);return new p.Tensor("float32",h,[2,1,128])}class g{constructor(h,o,c,f){this._session=h,this._state=o,this._sr=c,this.ortInstance=f,this.reset_state=()=>{this._state=b(this.ortInstance)},this.process=async s=>{var a;const t={input:new this.ortInstance.Tensor("float32",s,[1,s.length]),state:this._state,sr:this._sr},e=await this._session.run(t);this._state=e.stateN;const[n]=(a=e.output)==null?void 0:a.data;return{notSpeech:1-n,isSpeech:n}}}}return v5.SileroV5=g,D=g,g.new=async(p,h)=>{u.log.debug("Loading VAD...");const o=await h(),c=await p.InferenceSession.create(o),f=new p.Tensor("int64",[16000n]),s=b(p);return u.log.debug("...finished loading VAD"),new D(c,s,f,p)},v5}var hasRequiredModels;function requireModels(){return hasRequiredModels||(hasRequiredModels=1,function(D){var u=models&&models.__createBinding||(Object.create?function(h,o,c,f){f===void 0&&(f=c);var s=Object.getOwnPropertyDescriptor(o,c);(!s||("get"in s?!o.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return o[c]}}),Object.defineProperty(h,f,s)}:function(h,o,c,f){f===void 0&&(f=c),h[f]=o[c]}),b=models&&models.__exportStar||function(h,o){for(var c in h)c!=="default"&&!Object.prototype.hasOwnProperty.call(o,c)&&u(o,h,c)};Object.defineProperty(D,"__esModule",{value:!0}),D.SileroV5=D.SileroLegacy=void 0,b(requireCommon(),D);var g=requireLegacy();Object.defineProperty(D,"SileroLegacy",{enumerable:!0,get:function(){return g.SileroLegacy}});var p=requireV5();Object.defineProperty(D,"SileroV5",{enumerable:!0,get:function(){return p.SileroV5}})}(models)),models}var resampler={},hasRequiredResampler;function requireResampler(){if(hasRequiredResampler)return resampler;hasRequiredResampler=1,Object.defineProperty(resampler,"__esModule",{value:!0}),resampler.Resampler=void 0;const D=requireLogging();class u{constructor(g){this.options=g,this.process=p=>{const h=[];for(const o of p)for(this.inputBuffer.push(o);this.hasEnoughDataForFrame();){const c=this.generateOutputFrame();h.push(c)}return h},this.stream=async function*(p){for(const h of p)for(this.inputBuffer.push(h);this.hasEnoughDataForFrame();)yield this.generateOutputFrame()},g.nativeSampleRate<16e3&&D.log.error("nativeSampleRate is too low. Should have 16000 = targetSampleRate <= nativeSampleRate"),this.inputBuffer=[]}hasEnoughDataForFrame(){return this.inputBuffer.length*this.options.targetSampleRate/this.options.nativeSampleRate>=this.options.targetFrameSize}generateOutputFrame(){const g=new Float32Array(this.options.targetFrameSize);let p=0,h=0;for(;p{const i=await g.SileroLegacy.new(this.ort,this.modelFetcher);this.frameProcessor=new u.FrameProcessor(i.process,i.reset_state,{frameSamples:this.options.frameSamples,positiveSpeechThreshold:this.options.positiveSpeechThreshold,negativeSpeechThreshold:this.options.negativeSpeechThreshold,redemptionFrames:this.options.redemptionFrames,preSpeechPadFrames:this.options.preSpeechPadFrames,minSpeechFrames:this.options.minSpeechFrames,submitUserSpeechOnPause:this.options.submitUserSpeechOnPause}),this.frameProcessor.resume()},this.run=async function*(i,t){const e={nativeSampleRate:t,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},n=new p.Resampler(e);let r=0,a=0,l=0;for await(const y of n.stream(i)){const{msg:v,audio:_}=await this.frameProcessor.process(y);switch(v){case b.Message.SpeechStart:r=l*this.options.frameSamples/16;break;case b.Message.SpeechEnd:a=(l+1)*this.options.frameSamples/16,yield{audio:_,start:r,end:a};break}l++}const{msg:d,audio:m}=this.frameProcessor.endSegment();d==b.Message.SpeechEnd&&(yield{audio:m,start:r,end:l*this.options.frameSamples/16})},(0,u.validateOptions)(s)}}D.PlatformAgnosticNonRealTimeVAD=h}(nonRealTimeVad)),nonRealTimeVad}var utils={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1,Object.defineProperty(utils,"__esModule",{value:!0}),utils.audioFileToArray=utils.encodeWAV=utils.arrayBufferToBase64=utils.minFramesForTargetMS=void 0;function D(c,f,s=16e3){return Math.ceil(c*s/1e3/f)}utils.minFramesForTargetMS=D;function u(c){const f=new Uint8Array(c),s=f.byteLength,i=new Array(s);for(var t=0;t{s.addEventListener("loadend",r=>{const a=s.result;f.decodeAudioData(a,l=>{i=l,f.startRendering().then(d=>{console.log("Rendering completed successfully"),n()}).catch(d=>{console.error(`Rendering failed: ${d}`)})},l=>{console.log(`Error with decoding audio data: ${l}`)})}),s.readAsArrayBuffer(c)}),i===null)throw Error("some shit");let t=i,e=new Float32Array(t.length);for(let n=0;n({...d==="v5"?o.defaultV5FrameProcessorOptions:o.defaultLegacyFrameProcessorOptions,onFrameProcessed:y=>{},onVADMisfire:()=>{c.log.debug("VAD misfire")},onSpeechStart:()=>{c.log.debug("Detected speech start")},onSpeechEnd:()=>{c.log.debug("Detected speech end")},baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.22/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/",stream:void 0,ortConfig:void 0,model:D.DEFAULT_MODEL,workletOptions:{}});D.getDefaultRealTimeVADOptions=r;class a{static async new(m={}){const y={...(0,D.getDefaultRealTimeVADOptions)(m.model??D.DEFAULT_MODEL),...m};(0,o.validateOptions)(y);let v;y.stream===void 0?v=await navigator.mediaDevices.getUserMedia({audio:{...y.additionalAudioConstraints,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}):v=y.stream;const _=new AudioContext,T=new MediaStreamAudioSourceNode(_,{mediaStream:v}),S=await l.new(_,y);return S.receive(T),new a(y,_,v,S,T)}constructor(m,y,v,_,T,S=!1){this.options=m,this.audioContext=y,this.stream=v,this.audioNodeVAD=_,this.sourceNode=T,this.listening=S,this.pause=()=>{this.audioNodeVAD.pause(),this.listening=!1},this.start=()=>{this.audioNodeVAD.start(),this.listening=!0},this.destroy=()=>{this.listening&&this.pause(),this.options.stream===void 0&&this.stream.getTracks().forEach(A=>A.stop()),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()}}}D.MicVAD=a;class l{static async new(m,y={}){const v={...(0,D.getDefaultRealTimeVADOptions)(y.model??D.DEFAULT_MODEL),...y};(0,o.validateOptions)(v),D.ort.env.wasm.wasmPaths=v.onnxWASMBasePath,v.ortConfig!==void 0&&v.ortConfig(D.ort);const _=v.model==="v5"?e:n,T=v.baseAssetPath+_,S=v.model==="v5"?s.SileroV5.new:s.SileroLegacy.new;let A;try{A=await S(D.ort,()=>(0,h.defaultModelFetcher)(T))}catch(R){throw console.error(`Encountered an error while loading model file ${T}`),R}const w=new o.FrameProcessor(A.process,A.reset_state,{frameSamples:v.frameSamples,positiveSpeechThreshold:v.positiveSpeechThreshold,negativeSpeechThreshold:v.negativeSpeechThreshold,redemptionFrames:v.redemptionFrames,preSpeechPadFrames:v.preSpeechPadFrames,minSpeechFrames:v.minSpeechFrames,submitUserSpeechOnPause:v.submitUserSpeechOnPause}),I=new l(m,v,w);return await I.setupAudioNode(),I}constructor(m,y,v){this.ctx=m,this.options=y,this.bufferIndex=0,this.pause=()=>{const _=this.frameProcessor.pause();this.handleFrameProcessorEvent(_)},this.start=()=>{this.frameProcessor.resume()},this.receive=_=>{_.connect(this.audioNode)},this.processFrame=async _=>{const T=await this.frameProcessor.process(_);this.handleFrameProcessorEvent(T)},this.handleFrameProcessorEvent=_=>{switch(_.probs!==void 0&&this.options.onFrameProcessed(_.probs,_.frame),_.msg){case f.Message.SpeechStart:this.options.onSpeechStart();break;case f.Message.VADMisfire:this.options.onVADMisfire();break;case f.Message.SpeechEnd:this.options.onSpeechEnd(_.audio);break}},this.destroy=()=>{var _;this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:f.Message.SpeechStop}),this.audioNode.disconnect(),(_=this.gainNode)==null||_.disconnect()},this.frameProcessor=v}async setupAudioNode(){if("audioWorklet"in this.ctx&&typeof AudioWorkletNode=="function")try{const _=this.options.baseAssetPath+t;await this.ctx.audioWorklet.addModule(_);const T=this.options.workletOptions??{};T.processorOptions={...T.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",T),this.audioNode.port.onmessage=async S=>{var A;switch((A=S.data)==null?void 0:A.message){case f.Message.AudioFrame:let w=S.data.data;w instanceof ArrayBuffer||(w=new ArrayBuffer(S.data.data.byteLength),new Uint8Array(w).set(new Uint8Array(S.data.data)));const I=new Float32Array(w);await this.processFrame(I);break}};return}catch(_){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",_)}this.resampler=new i.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480});const y=4096;this.audioNode=this.ctx.createScriptProcessor(y,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let v=!1;this.audioNode.onaudioprocess=async _=>{if(!v){v=!0;try{const T=_.inputBuffer.getChannelData(0);if(_.outputBuffer.getChannelData(0).fill(0),this.resampler){const A=this.resampler.process(T);for(const w of A)await this.processFrame(w)}}catch(T){console.error("Error processing audio:",T)}finally{v=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}D.AudioNodeVAD=l}(realTimeVad)),realTimeVad}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,function(D){var u=dist&&dist.__createBinding||(Object.create?function(n,r,a,l){l===void 0&&(l=a);var d=Object.getOwnPropertyDescriptor(r,a);(!d||("get"in d?!r.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return r[a]}}),Object.defineProperty(n,l,d)}:function(n,r,a,l){l===void 0&&(l=a),n[l]=r[a]}),b=dist&&dist.__setModuleDefault||(Object.create?function(n,r){Object.defineProperty(n,"default",{enumerable:!0,value:r})}:function(n,r){n.default=r}),g=dist&&dist.__importStar||function(n){if(n&&n.__esModule)return n;var r={};if(n!=null)for(var a in n)a!=="default"&&Object.prototype.hasOwnProperty.call(n,a)&&u(r,n,a);return b(r,n),r};Object.defineProperty(D,"__esModule",{value:!0}),D.NonRealTimeVAD=D.Message=D.FrameProcessor=D.getDefaultRealTimeVADOptions=D.MicVAD=D.DEFAULT_MODEL=D.AudioNodeVAD=D.utils=D.defaultNonRealTimeVADOptions=void 0;const p=g(requireOrtWeb_min()),h=requireAssetPath(),o=requireDefaultModelFetcher(),c=requireFrameProcessor();Object.defineProperty(D,"FrameProcessor",{enumerable:!0,get:function(){return c.FrameProcessor}});const f=requireMessages();Object.defineProperty(D,"Message",{enumerable:!0,get:function(){return f.Message}});const s=requireNonRealTimeVad(),i=requireUtils();D.defaultNonRealTimeVADOptions={modelURL:h.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:o.defaultModelFetcher};class t extends s.PlatformAgnosticNonRealTimeVAD{static async new(r={}){const{modelURL:a,modelFetcher:l}={...D.defaultNonRealTimeVADOptions,...r};return await this._new(()=>l(a),p,r)}}D.NonRealTimeVAD=t,D.utils={audioFileToArray:i.audioFileToArray,minFramesForTargetMS:i.minFramesForTargetMS,arrayBufferToBase64:i.arrayBufferToBase64,encodeWAV:i.encodeWAV};var e=requireRealTimeVad();Object.defineProperty(D,"AudioNodeVAD",{enumerable:!0,get:function(){return e.AudioNodeVAD}}),Object.defineProperty(D,"DEFAULT_MODEL",{enumerable:!0,get:function(){return e.DEFAULT_MODEL}}),Object.defineProperty(D,"MicVAD",{enumerable:!0,get:function(){return e.MicVAD}}),Object.defineProperty(D,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return e.getDefaultRealTimeVADOptions}})}(dist)),dist}var distExports=requireDist();export{distExports as d};