diff --git "a/assets/worker-b9e8d606.js" "b/assets/worker-b9e8d606.js" new file mode 100644--- /dev/null +++ "b/assets/worker-b9e8d606.js" @@ -0,0 +1,1810 @@ +var fn=Object.defineProperty;var gn=(nt,d,n)=>d in nt?fn(nt,d,{enumerable:!0,configurable:!0,writable:!0,value:n}):nt[d]=n;var J=(nt,d,n)=>(gn(nt,typeof d!="symbol"?d+"":d,n),n);(function(){var nt;"use strict";function _mergeNamespaces(d,n){return n.forEach(function(o){o&&typeof o!="string"&&!Array.isArray(o)&&Object.keys(o).forEach(function(s){if(s!=="default"&&!(s in d)){var l=Object.getOwnPropertyDescriptor(o,s);Object.defineProperty(d,s,l.get?l:{enumerable:!0,get:function(){return o[s]}})}})}),Object.freeze(d)}function dispatchCallback(d,n){d&&d(n)}function reverseDictionary(d){return Object.fromEntries(Object.entries(d).map(([n,o])=>[o,n]))}function escapeRegExp(d){return d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Callable=class{constructor(){let d=function(...n){return d._call(...n)};return Object.setPrototypeOf(d,new.target.prototype)}_call(...d){throw Error("Must implement _call method in subclass")}};function isTypedArray(d){var n,o,s;return((s=(o=(n=d==null?void 0:d.prototype)==null?void 0:n.__proto__)==null?void 0:o.constructor)==null?void 0:s.name)==="TypedArray"}function isIntegralNumber(d){return Number.isInteger(d)||typeof d=="bigint"}function exists(d){return d!=null}function mergeArrays(...d){return Array.prototype.concat.apply([],d)}var sharp={},ONNX_NODE=Object.freeze({__proto__:null,default:sharp});function getDefaultExportFromCjs(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}function getAugmentedNamespace(d){if(d.__esModule)return d;var n=d.default;if(typeof n=="function"){var o=function s(){return this instanceof s?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};o.prototype=n.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(d).forEach(function(s){var l=Object.getOwnPropertyDescriptor(d,s);Object.defineProperty(o,s,l.get?l:{enumerable:!0,get:function(){return d[s]}})}),o}var ortWeb_min$1={exports:{}};const backends={},backendsSortedByPriority=[],registerBackend=(d,n,o)=>{if(n&&typeof n.init=="function"&&typeof n.createSessionHandler=="function"){const s=backends[d];if(s===void 0)backends[d]={backend:n,priority:o};else{if(s.priority>o)return;if(s.priority===o&&s.backend!==n)throw new Error(`cannot register backend "${d}" using priority ${o}`)}if(o>=0){const l=backendsSortedByPriority.indexOf(d);l!==-1&&backendsSortedByPriority.splice(l,1);for(let f=0;f<backendsSortedByPriority.length;f++)if(backends[backendsSortedByPriority[f]].priority<=o){backendsSortedByPriority.splice(f,0,d);return}backendsSortedByPriority.push(d)}return}throw new TypeError("not a valid backend")},resolveBackend=async d=>{const n=d.length===0?backendsSortedByPriority:d,o=[];for(const s of n){const l=backends[s];if(l){if(l.initialized)return l.backend;if(l.aborted)continue;const f=!!l.initPromise;try{return f||(l.initPromise=l.backend.init()),await l.initPromise,l.initialized=!0,l.backend}catch(u){f||o.push({name:s,err:u}),l.aborted=!0}finally{delete l.initPromise}}}throw new Error(`no available backend found. ERR: ${o.map(s=>`[${s.name}] ${s.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(n){if(n!==void 0){if(typeof n!="string"||["verbose","info","warning","error","fatal"].indexOf(n)===-1)throw new Error(`Unsupported logging level: ${n}`);this.logLevelInternal=n}}get logLevel(){return this.logLevelInternal}}const env$2=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 n=1;for(let o=0;o<d.length;o++){const s=d[o];if(typeof s!="number"||!Number.isSafeInteger(s))throw new TypeError(`dims[${o}] must be an integer, got: ${s}`);if(s<0)throw new RangeError(`dims[${o}] must be a non-negative integer, got: ${s}`);n*=s}return n};let Tensor$2=class ut{constructor(n,o,s){let l,f,u;if(typeof n=="string")if(l=n,u=s,n==="string"){if(!Array.isArray(o))throw new TypeError("A string tensor's data must be a string array.");f=o}else{const g=NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(n);if(g===void 0)throw new TypeError(`Unsupported tensor type: ${n}.`);if(Array.isArray(o))f=g.from(o);else if(o instanceof g)f=o;else throw new TypeError(`A ${l} tensor's data must be type of ${g}`)}else if(u=o,Array.isArray(n)){if(n.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const g=typeof n[0];if(g==="string")l="string",f=n;else if(g==="boolean")l="bool",f=Uint8Array.from(n);else throw new TypeError(`Invalid element type of data array: ${g}.`)}else{const g=NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(n.constructor);if(g===void 0)throw new TypeError(`Unsupported type for tensor data: ${n.constructor}.`);l=g,f=n}if(u===void 0)u=[f.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");const p=calculateSize(u);if(p!==f.length)throw new Error(`Tensor's size(${p}) does not match data length(${f.length}).`);this.dims=u,this.type=l,this.data=f,this.size=p}static bufferToTensor(n,o){if(n===void 0)throw new Error("Image buffer must be defined");if(o.height===void 0||o.width===void 0)throw new Error("Image height and width must be defined");const{height:s,width:l}=o,f=o.norm;let u,p;f===void 0||f.mean===void 0?u=255:u=f.mean,f===void 0||f.bias===void 0?p=0:p=f.bias;const g=o.bitmapFormat!==void 0?o.bitmapFormat:"RGBA",c=o.tensorFormat!==void 0&&o.tensorFormat!==void 0?o.tensorFormat:"RGB",a=s*l,t=c==="RGBA"?new Float32Array(a*4):new Float32Array(a*3);let e=4,r=0,i=1,h=2,m=3,_=0,b=a,y=a*2,T=-1;g==="RGB"&&(e=3,r=0,i=1,h=2,m=-1),c==="RGBA"?T=a*3:c==="RBG"?(_=0,y=a,b=a*2):c==="BGR"&&(y=0,b=a,_=a*2);for(let S=0;S<a;S++,r+=e,h+=e,i+=e,m+=e)t[_++]=(n[r]+p)/u,t[b++]=(n[i]+p)/u,t[y++]=(n[h]+p)/u,T!==-1&&m!==-1&&(t[T++]=(n[m]+p)/u);return c==="RGBA"?new ut("float32",t,[1,4,s,l]):new ut("float32",t,[1,3,s,l])}static async fromImage(n,o){const s=typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement,l=typeof ImageData<"u"&&n instanceof ImageData,f=typeof ImageBitmap<"u"&&n instanceof ImageBitmap,u=typeof String<"u"&&(n instanceof String||typeof n=="string");let p,g={};if(s){const c=document.createElement("canvas"),a=c.getContext("2d");if(a!=null){let t=n.naturalHeight,e=n.naturalWidth;if(o!==void 0&&o.resizedHeight!==void 0&&o.resizedWidth!==void 0&&(t=o.resizedHeight,e=o.resizedWidth),o!==void 0){if(g=o,o.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");if(g.tensorFormat="RGBA",o.height!==void 0&&o.height!==t)throw new Error("Image input config height doesn't match HTMLImageElement height");if(g.height=t,o.width!==void 0&&o.width!==e)throw new Error("Image input config width doesn't match HTMLImageElement width");g.width=e}else g.tensorFormat="RGBA",g.height=t,g.width=e;c.width=e,c.height=t,a.drawImage(n,0,0,e,t),p=a.getImageData(0,0,e,t).data}else throw new Error("Can not access image data")}else if(l){const c="RGBA";let a,t;if(o!==void 0&&o.resizedWidth!==void 0&&o.resizedHeight!==void 0?(a=o.resizedHeight,t=o.resizedWidth):(a=n.height,t=n.width),o!==void 0){if(g=o,o.bitmapFormat!==void 0&&o.bitmapFormat!==c)throw new Error("Image input config format must be RGBA for ImageData");g.bitmapFormat="RGBA"}else g.bitmapFormat="RGBA";if(g.height=a,g.width=t,o!==void 0){const e=document.createElement("canvas");e.width=t,e.height=a;const r=e.getContext("2d");if(r!=null)r.putImageData(n,0,0),p=r.getImageData(0,0,t,a).data;else throw new Error("Can not access image data")}else p=n.data}else if(f){if(o===void 0)throw new Error("Please provide image config with format for Imagebitmap");if(o.bitmapFormat!==void 0)throw new Error("Image input config format must be defined for ImageBitmap");const c=document.createElement("canvas").getContext("2d");if(c!=null){const a=n.height,t=n.width;if(c.drawImage(n,0,0,t,a),p=c.getImageData(0,0,t,a).data,o!==void 0){if(o.height!==void 0&&o.height!==a)throw new Error("Image input config height doesn't match ImageBitmap height");if(g.height=a,o.width!==void 0&&o.width!==t)throw new Error("Image input config width doesn't match ImageBitmap width");g.width=t}else g.height=a,g.width=t;return ut.bufferToTensor(p,g)}else throw new Error("Can not access image data")}else{if(u)return new Promise((c,a)=>{const t=document.createElement("canvas"),e=t.getContext("2d");if(!n||!e)return a();const r=new Image;r.crossOrigin="Anonymous",r.src=n,r.onload=()=>{t.width=r.width,t.height=r.height,e.drawImage(r,0,0,t.width,t.height);const i=e.getImageData(0,0,t.width,t.height);if(o!==void 0){if(o.height!==void 0&&o.height!==t.height)throw new Error("Image input config height doesn't match ImageBitmap height");if(g.height=t.height,o.width!==void 0&&o.width!==t.width)throw new Error("Image input config width doesn't match ImageBitmap width");g.width=t.width}else g.height=t.height,g.width=t.width;c(ut.bufferToTensor(i.data,g))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(p!==void 0)return ut.bufferToTensor(p,g);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(n){var o,s;const l=document.createElement("canvas").getContext("2d");let f;if(l!=null){const u=this.dims[3],p=this.dims[2],g=this.dims[1],c=n!==void 0&&n.format!==void 0?n.format:"RGB",a=n!==void 0&&((o=n.norm)===null||o===void 0?void 0:o.mean)!==void 0?n.norm.mean:255,t=n!==void 0&&((s=n.norm)===null||s===void 0?void 0:s.bias)!==void 0?n.norm.bias:0,e=p*u;if(n!==void 0){if(n.height!==void 0&&n.height!==p)throw new Error("Image output config height doesn't match tensor height");if(n.width!==void 0&&n.width!==u)throw new Error("Image output config width doesn't match tensor width");if(n.format!==void 0&&g===4&&n.format!=="RGBA"||g===3&&n.format!=="RGB"&&n.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const r=4;let i=0,h=1,m=2,_=3,b=0,y=e,T=e*2,w=-1;c==="RGBA"?(b=0,y=e,T=e*2,w=e*3):c==="RGB"?(b=0,y=e,T=e*2):c==="RBG"&&(b=0,T=e,y=e*2),f=l.createImageData(u,p);for(let S=0;S<p*u;i+=r,h+=r,m+=r,_+=r,S++)f.data[i]=(this.data[b++]-t)*a,f.data[h]=(this.data[y++]-t)*a,f.data[m]=(this.data[T++]-t)*a,f.data[_]=w===-1?255:(this.data[w++]-t)*a}else throw new Error("Can not access image data");return f}reshape(n){return new ut(this.type,this.data,n)}};const Tensor$1=Tensor$2;let InferenceSession$2=class dn{constructor(n){this.handler=n}async run(n,o,s){const l={};let f={};if(typeof n!="object"||n===null||n instanceof Tensor$1||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let u=!0;if(typeof o=="object"){if(o===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(o instanceof Tensor$1)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(o)){if(o.length===0)throw new TypeError("'fetches' cannot be an empty array.");u=!1;for(const c of o){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(c)===-1)throw new RangeError(`'fetches' contains invalid output name: ${c}.`);l[c]=null}if(typeof s=="object"&&s!==null)f=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else{let c=!1;const a=Object.getOwnPropertyNames(o);for(const t of this.outputNames)if(a.indexOf(t)!==-1){const e=o[t];(e===null||e instanceof Tensor$1)&&(c=!0,u=!1,l[t]=e)}if(c){if(typeof s=="object"&&s!==null)f=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else f=o}}else if(typeof o<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const c of this.inputNames)if(typeof n[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(u)for(const c of this.outputNames)l[c]=null;const p=await this.handler.run(n,l,f),g={};for(const c in p)Object.hasOwnProperty.call(p,c)&&(g[c]=new Tensor$1(p[c].type,p[c].data,p[c].dims));return g}static async create(n,o,s,l){let f,u={};if(typeof n=="string"){if(f=n,typeof o=="object"&&o!==null)u=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof Uint8Array){if(f=n,typeof o=="object"&&o!==null)u=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer){const t=n;let e=0,r=n.byteLength;if(typeof o=="object"&&o!==null)u=o;else if(typeof o=="number"){if(e=o,!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(r=n.byteLength-e,typeof s=="number"){if(r=s,!Number.isSafeInteger(r))throw new RangeError("'byteLength' must be an integer.");if(r<=0||e+r>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-e}].`);if(typeof l=="object"&&l!==null)u=l;else if(typeof l<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof o<"u")throw new TypeError("'options' must be an object.");f=new Uint8Array(t,e,r)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const g=(u.executionProviders||[]).map(t=>typeof t=="string"?t:t.name),a=await(await resolveBackend(g)).createSessionHandler(f,u);return new dn(a)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const InferenceSession$1=InferenceSession$2;var lib=Object.freeze({__proto__:null,InferenceSession:InferenceSession$1,Tensor:Tensor$1,env:env$2,registerBackend}),require$$0=getAugmentedNamespace(lib);/*! +* ONNX Runtime Web v1.14.0 +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. +*/(function(module,exports){(function(d,n){module.exports=n(require$$0)})(self,__WEBPACK_EXTERNAL_MODULE__1670__=>(()=>{var __webpack_modules__={3474:(d,n,o)=>{var s,l=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(f){function u(){return Y.buffer!=te&&Me(Y.buffer),he}function p(){return Y.buffer!=te&&Me(Y.buffer),Oe}function g(){return Y.buffer!=te&&Me(Y.buffer),xe}function c(){return Y.buffer!=te&&Me(Y.buffer),ue}function a(){return Y.buffer!=te&&Me(Y.buffer),Se}var t,e,r;f=f||{},t||(t=f!==void 0?f:{}),t.ready=new Promise(function(x,P){e=x,r=P});var i,h,m,_,b,y,T=Object.assign({},t),w="./this.program",S=(x,P)=>{throw P},E=typeof window=="object",O=typeof importScripts=="function",v=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",M=t.ENVIRONMENT_IS_PTHREAD||!1,$="";function V(x){return t.locateFile?t.locateFile(x,$):$+x}if(v){let x;$=O?o(908).dirname($)+"/":"//",y=()=>{b||(_=o(1384),b=o(908))},i=function(P,I){return y(),P=b.normalize(P),_.readFileSync(P,I?void 0:"utf8")},m=P=>((P=i(P,!0)).buffer||(P=new Uint8Array(P)),P),h=(P,I,N)=>{y(),P=b.normalize(P),_.readFile(P,function(z,G){z?N(z):I(G.buffer)})},1<process.argv.length&&(w=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(P){if(!(P instanceof Je))throw P}),process.on("unhandledRejection",function(P){throw P}),S=(P,I)=>{if(Ge())throw process.exitCode=P,I;I instanceof Je||F("exiting due to exception: "+I),process.exit(P)},t.inspect=function(){return"[Emscripten Module object]"};try{x=o(9925)}catch(P){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),P}o.g.Worker=x.Worker}else(E||O)&&(O?$=self.location.href:typeof document<"u"&&document.currentScript&&($=document.currentScript.src),s&&($=s),$=$.indexOf("blob:")!==0?$.substr(0,$.replace(/[?#].*/,"").lastIndexOf("/")+1):"",v||(i=x=>{var P=new XMLHttpRequest;return P.open("GET",x,!1),P.send(null),P.responseText},O&&(m=x=>{var P=new XMLHttpRequest;return P.open("GET",x,!1),P.responseType="arraybuffer",P.send(null),new Uint8Array(P.response)}),h=(x,P,I)=>{var N=new XMLHttpRequest;N.open("GET",x,!0),N.responseType="arraybuffer",N.onload=()=>{N.status==200||N.status==0&&N.response?P(N.response):I()},N.onerror=I,N.send(null)}));v&&typeof performance>"u"&&(o.g.performance=o(6953).performance);var B=console.log.bind(console),L=console.warn.bind(console);v&&(y(),B=x=>_.writeSync(1,x+` +`),L=x=>_.writeSync(2,x+` +`));var D,k=t.print||B,F=t.printErr||L;Object.assign(t,T),T=null,t.thisProgram&&(w=t.thisProgram),t.quit&&(S=t.quit),t.wasmBinary&&(D=t.wasmBinary);var Q=t.noExitRuntime||!1;typeof WebAssembly!="object"&&ge("no native wasm support detected");var Y,ee,te,he,Oe,xe,ue,Se,we=!1,$e=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function He(x,P,I){var N=(P>>>=0)+I;for(I=P;x[I]&&!(I>=N);)++I;if(16<I-P&&x.buffer&&$e)return $e.decode(x.buffer instanceof SharedArrayBuffer?x.slice(P,I):x.subarray(P,I));for(N="";P<I;){var z=x[P++];if(128&z){var G=63&x[P++];if((224&z)==192)N+=String.fromCharCode((31&z)<<6|G);else{var X=63&x[P++];65536>(z=(240&z)==224?(15&z)<<12|G<<6|X:(7&z)<<18|G<<12|X<<6|63&x[P++])?N+=String.fromCharCode(z):(z-=65536,N+=String.fromCharCode(55296|z>>10,56320|1023&z))}}else N+=String.fromCharCode(z)}return N}function Ae(x,P){return(x>>>=0)?He(p(),x,P):""}function Fe(x,P,I,N){if(!(0<N))return 0;var z=I>>>=0;N=I+N-1;for(var G=0;G<x.length;++G){var X=x.charCodeAt(G);if(55296<=X&&57343>=X&&(X=65536+((1023&X)<<10)|1023&x.charCodeAt(++G)),127>=X){if(I>=N)break;P[I++>>>0]=X}else{if(2047>=X){if(I+1>=N)break;P[I++>>>0]=192|X>>6}else{if(65535>=X){if(I+2>=N)break;P[I++>>>0]=224|X>>12}else{if(I+3>=N)break;P[I++>>>0]=240|X>>18,P[I++>>>0]=128|X>>12&63}P[I++>>>0]=128|X>>6&63}P[I++>>>0]=128|63&X}}return P[I>>>0]=0,I-z}function De(x){for(var P=0,I=0;I<x.length;++I){var N=x.charCodeAt(I);127>=N?P++:2047>=N?P+=2:55296<=N&&57343>=N?(P+=4,++I):P+=3}return P}function Me(x){te=x,t.HEAP8=he=new Int8Array(x),t.HEAP16=new Int16Array(x),t.HEAP32=xe=new Int32Array(x),t.HEAPU8=Oe=new Uint8Array(x),t.HEAPU16=new Uint16Array(x),t.HEAPU32=ue=new Uint32Array(x),t.HEAPF32=new Float32Array(x),t.HEAPF64=Se=new Float64Array(x)}M&&(te=t.buffer);var ve=t.INITIAL_MEMORY||16777216;if(M)Y=t.wasmMemory,te=t.buffer;else if(t.wasmMemory)Y=t.wasmMemory;else if(!((Y=new WebAssembly.Memory({initial:ve/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw F("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"),v&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Y&&(te=Y.buffer),ve=te.byteLength,Me(te);var je,ze=[],Ue=[],Ye=[],Qe=[];function Ge(){return Q||!1}function Ve(){var x=t.preRun.shift();ze.unshift(x)}var Pe,Re=0,Ke=null;function ge(x){throw M?postMessage({cmd:"onAbort",arg:x}):t.onAbort&&t.onAbort(x),F(x="Aborted("+x+")"),we=!0,x=new WebAssembly.RuntimeError(x+". Build with -sASSERTIONS for more info."),r(x),x}function pt(){return Pe.startsWith("data:application/octet-stream;base64,")}function lt(){var x=Pe;try{if(x==Pe&&D)return new Uint8Array(D);if(m)return m(x);throw"both async and sync fetching of the wasm failed"}catch(P){ge(P)}}Pe="ort-wasm-threaded.wasm",pt()||(Pe=V(Pe));var At={};function Je(x){this.name="ExitStatus",this.message="Program terminated with exit("+x+")",this.status=x}function ct(x){(x=ie.Vb[x])||ge(),ie.mc(x)}function dt(x){var P=ie.Cc();if(!P)return 6;ie.ac.push(P),ie.Vb[x.Ub]=P,P.Ub=x.Ub;var I={cmd:"run",start_routine:x.Ic,arg:x.zc,pthread_ptr:x.Ub};return P.$b=()=>{I.time=performance.now(),P.postMessage(I,x.Nc)},P.loaded&&(P.$b(),delete P.$b),0}function Le(x){if(M)return Z(1,1,x);Ge()||(ie.oc(),t.onExit&&t.onExit(x),we=!0),S(x,new Je(x))}function it(x,P){if(!P&&M)throw kt(x),"unwind";Ge()||M||(Wt(),rt(Ye),qt(0),Ft[1].length&&Lt(1,10),Ft[2].length&&Lt(2,10),ie.oc()),Le(x)}var ie={Yb:[],ac:[],qc:[],Vb:{},fc:function(){M&&ie.Ec()},Pc:function(){},Ec:function(){ie.receiveObjectTransfer=ie.Gc,ie.threadInitTLS=ie.pc,ie.setExitStatus=ie.nc,Q=!1},nc:function(){},oc:function(){for(var x of Object.values(ie.Vb))ie.mc(x);for(x of ie.Yb)x.terminate();ie.Yb=[]},mc:function(x){var P=x.Ub;delete ie.Vb[P],ie.Yb.push(x),ie.ac.splice(ie.ac.indexOf(x),1),x.Ub=0,Rt(P)},Gc:function(){},pc:function(){ie.qc.forEach(x=>x())},Fc:function(x,P){x.onmessage=I=>{var N=(I=I.data).cmd;if(x.Ub&&(ie.Bc=x.Ub),I.targetThread&&I.targetThread!=Ct()){var z=ie.Vb[I.Qc];z?z.postMessage(I,I.transferList):F('Internal error! Worker sent a message "'+N+'" to target pthread '+I.targetThread+", but that thread no longer exists!")}else N==="processProxyingQueue"?R(I.queue):N==="spawnThread"?dt(I):N==="cleanupThread"?ct(I.thread):N==="killThread"?(I=I.thread,N=ie.Vb[I],delete ie.Vb[I],N.terminate(),Rt(I),ie.ac.splice(ie.ac.indexOf(N),1),N.Ub=0):N==="cancelThread"?ie.Vb[I.thread].postMessage({cmd:"cancel"}):N==="loaded"?(x.loaded=!0,P&&P(x),x.$b&&(x.$b(),delete x.$b)):N==="print"?k("Thread "+I.threadId+": "+I.text):N==="printErr"?F("Thread "+I.threadId+": "+I.text):N==="alert"?alert("Thread "+I.threadId+": "+I.text):I.target==="setimmediate"?x.postMessage(I):N==="onAbort"?t.onAbort&&t.onAbort(I.arg):N&&F("worker sent an unknown command "+N);ie.Bc=void 0},x.onerror=I=>{throw F("worker sent an error! "+I.filename+":"+I.lineno+": "+I.message),I},v&&(x.on("message",function(I){x.onmessage({data:I})}),x.on("error",function(I){x.onerror(I)}),x.on("detachedExit",function(){})),x.postMessage({cmd:"load",urlOrBlob:t.mainScriptUrlOrBlob||s,wasmMemory:Y,wasmModule:ee})},yc:function(){var x=V("ort-wasm-threaded.worker.js");ie.Yb.push(new Worker(x))},Cc:function(){return ie.Yb.length==0&&(ie.yc(),ie.Fc(ie.Yb[0])),ie.Yb.pop()}};function rt(x){for(;0<x.length;)x.shift()(t)}function Mt(x){var P=de();return x=x(),ce(P),x}function kt(x){if(M)return Z(2,0,x);try{it(x)}catch(P){P instanceof Je||P=="unwind"||S(1,P)}}t.PThread=ie,t.establishStackSpace=function(){var x=Ct(),P=g()[x+44>>2>>>0];x=g()[x+48>>2>>>0],Qt(P,P-x),ce(P)};var Ze=[];function ye(x){var P=Ze[x];return P||(x>=Ze.length&&(Ze.length=x+1),Ze[x]=P=je.get(x)),P}t.invokeEntryPoint=function(x,P){x=ye(x)(P),Ge()?ie.nc(x):Xt(x)};var ot,ft,st=[],ae=0,oe=0;function se(x){this.Zb=x,this.Sb=x-24,this.xc=function(P){c()[this.Sb+4>>2>>>0]=P},this.bc=function(){return c()[this.Sb+4>>2>>>0]},this.wc=function(P){c()[this.Sb+8>>2>>>0]=P},this.Dc=function(){return c()[this.Sb+8>>2>>>0]},this.rc=function(){g()[this.Sb>>2>>>0]=0},this.hc=function(P){P=P?1:0,u()[this.Sb+12>>0>>>0]=P},this.uc=function(){return u()[this.Sb+12>>0>>>0]!=0},this.ic=function(P){P=P?1:0,u()[this.Sb+13>>0>>>0]=P},this.kc=function(){return u()[this.Sb+13>>0>>>0]!=0},this.fc=function(P,I){this.cc(0),this.xc(P),this.wc(I),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(g(),this.Sb>>2,1)},this.Hc=function(){return Atomics.sub(g(),this.Sb>>2,1)===1},this.cc=function(P){c()[this.Sb+16>>2>>>0]=P},this.tc=function(){return c()[this.Sb+16>>2>>>0]},this.vc=function(){if(Jt(this.bc()))return c()[this.Zb>>2>>>0];var P=this.tc();return P!==0?P:this.Zb}}function gt(x){return Gt(new se(x).Sb)}function at(x,P,I,N){return M?Z(3,1,x,P,I,N):mt(x,P,I,N)}function mt(x,P,I,N){if(typeof SharedArrayBuffer>"u")return F("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var z=[];return M&&z.length===0?at(x,P,I,N):(x={Ic:I,Ub:x,zc:N,Nc:z},M?(x.Oc="spawnThread",postMessage(x,z),0):dt(x))}function _t(x,P,I){return M?Z(4,1,x,P,I):0}function bt(x,P){if(M)return Z(5,1,x,P)}function yt(x,P){if(M)return Z(6,1,x,P)}function wt(x,P,I){if(M)return Z(7,1,x,P,I)}function Tt(x,P,I){return M?Z(8,1,x,P,I):0}function vt(x,P){if(M)return Z(9,1,x,P)}function xt(x,P,I){if(M)return Z(10,1,x,P,I)}function St(x,P,I,N){if(M)return Z(11,1,x,P,I,N)}function Et(x,P,I,N){if(M)return Z(12,1,x,P,I,N)}function Ot(x,P,I,N){if(M)return Z(13,1,x,P,I,N)}function Pt(x){if(M)return Z(14,1,x)}function A(x,P){if(M)return Z(15,1,x,P)}function C(x,P,I){if(M)return Z(16,1,x,P,I)}function R(x){Atomics.store(g(),x>>2,1),Ct()&&Kt(x),Atomics.compareExchange(g(),x>>2,1,0)}function j(x){return c()[x>>>2]+4294967296*g()[x+4>>>2]}function U(x,P,I,N,z,G){return M?Z(17,1,x,P,I,N,z,G):-52}function H(x,P,I,N,z,G){if(M)return Z(18,1,x,P,I,N,z,G)}function K(x){var P=De(x)+1,I=$t(P);return I&&Fe(x,u(),I,P),I}function ne(x,P,I){function N(me){return(me=me.toTimeString().match(/\(([A-Za-z ]+)\)$/))?me[1]:"GMT"}if(M)return Z(19,1,x,P,I);var z=new Date().getFullYear(),G=new Date(z,0,1),X=new Date(z,6,1);z=G.getTimezoneOffset();var re=X.getTimezoneOffset(),fe=Math.max(z,re);g()[x>>2>>>0]=60*fe,g()[P>>2>>>0]=+(z!=re),x=N(G),P=N(X),x=K(x),P=K(P),re<z?(c()[I>>2>>>0]=x,c()[I+4>>2>>>0]=P):(c()[I>>2>>>0]=P,c()[I+4>>2>>>0]=x)}function Z(x,P){var I=arguments.length-2,N=arguments;return Mt(()=>{for(var z=Bt(8*I),G=z>>3,X=0;X<I;X++){var re=N[2+X];a()[G+X>>>0]=re}return Yt(x,I,z,P)})}t.executeNotifiedProxyingQueue=R,ft=v?()=>{var x=process.hrtime();return 1e3*x[0]+x[1]/1e6}:M?()=>performance.now()-t.__performance_now_clock_drift:()=>performance.now();var le,Te=[],Ne={};function Ce(){if(!le){var x,P={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",_:w||"./this.program"};for(x in Ne)Ne[x]===void 0?delete P[x]:P[x]=Ne[x];var I=[];for(x in P)I.push(x+"="+P[x]);le=I}return le}function q(x,P){if(M)return Z(20,1,x,P);var I=0;return Ce().forEach(function(N,z){var G=P+I;for(z=c()[x+4*z>>2>>>0]=G,G=0;G<N.length;++G)u()[z++>>0>>>0]=N.charCodeAt(G);u()[z>>0>>>0]=0,I+=N.length+1}),0}function _e(x,P){if(M)return Z(21,1,x,P);var I=Ce();c()[x>>2>>>0]=I.length;var N=0;return I.forEach(function(z){N+=z.length+1}),c()[P>>2>>>0]=N,0}function Ee(x){return M?Z(22,1,x):52}function qe(x,P,I,N){return M?Z(23,1,x,P,I,N):52}function et(x,P,I,N,z){return M?Z(24,1,x,P,I,N,z):70}var Ft=[null,[],[]];function Lt(x,P){var I=Ft[x];P===0||P===10?((x===1?k:F)(He(I,0)),I.length=0):I.push(P)}function jt(x,P,I,N){if(M)return Z(25,1,x,P,I,N);for(var z=0,G=0;G<I;G++){var X=c()[P>>2>>>0],re=c()[P+4>>2>>>0];P+=8;for(var fe=0;fe<re;fe++)Lt(x,p()[X+fe>>>0]);z+=re}return c()[N>>2>>>0]=z,0}var Be=0;function It(x){return x%4==0&&(x%100!=0||x%400==0)}var Vt=[31,29,31,30,31,30,31,31,30,31,30,31],zt=[31,28,31,30,31,30,31,31,30,31,30,31];function Ut(x,P,I,N){function z(W,be,ke){for(W=typeof W=="number"?W.toString():W||"";W.length<be;)W=ke[0]+W;return W}function G(W,be){return z(W,be,"0")}function X(W,be){function ke(ht){return 0>ht?-1:0<ht?1:0}var tt;return(tt=ke(W.getFullYear()-be.getFullYear()))===0&&(tt=ke(W.getMonth()-be.getMonth()))===0&&(tt=ke(W.getDate()-be.getDate())),tt}function re(W){switch(W.getDay()){case 0:return new Date(W.getFullYear()-1,11,29);case 1:return W;case 2:return new Date(W.getFullYear(),0,3);case 3:return new Date(W.getFullYear(),0,2);case 4:return new Date(W.getFullYear(),0,1);case 5:return new Date(W.getFullYear()-1,11,31);case 6:return new Date(W.getFullYear()-1,11,30)}}function fe(W){var be=W.Wb;for(W=new Date(new Date(W.Xb+1900,0,1).getTime());0<be;){var ke=W.getMonth(),tt=(It(W.getFullYear())?Vt:zt)[ke];if(!(be>tt-W.getDate())){W.setDate(W.getDate()+be);break}be-=tt-W.getDate()+1,W.setDate(1),11>ke?W.setMonth(ke+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return ke=new Date(W.getFullYear()+1,0,4),be=re(new Date(W.getFullYear(),0,4)),ke=re(ke),0>=X(be,W)?0>=X(ke,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}var me=g()[N+40>>2>>>0];for(var Ie in N={Lc:g()[N>>2>>>0],Kc:g()[N+4>>2>>>0],dc:g()[N+8>>2>>>0],jc:g()[N+12>>2>>>0],ec:g()[N+16>>2>>>0],Xb:g()[N+20>>2>>>0],Tb:g()[N+24>>2>>>0],Wb:g()[N+28>>2>>>0],Rc:g()[N+32>>2>>>0],Jc:g()[N+36>>2>>>0],Mc:me?Ae(me):""},I=Ae(I),me={"%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"})I=I.replace(new RegExp(Ie,"g"),me[Ie]);var Xe="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),We="January February March April May June July August September October November December".split(" ");for(Ie in me={"%a":function(W){return Xe[W.Tb].substring(0,3)},"%A":function(W){return Xe[W.Tb]},"%b":function(W){return We[W.ec].substring(0,3)},"%B":function(W){return We[W.ec]},"%C":function(W){return G((W.Xb+1900)/100|0,2)},"%d":function(W){return G(W.jc,2)},"%e":function(W){return z(W.jc,2," ")},"%g":function(W){return fe(W).toString().substring(2)},"%G":function(W){return fe(W)},"%H":function(W){return G(W.dc,2)},"%I":function(W){return(W=W.dc)==0?W=12:12<W&&(W-=12),G(W,2)},"%j":function(W){for(var be=0,ke=0;ke<=W.ec-1;be+=(It(W.Xb+1900)?Vt:zt)[ke++]);return G(W.jc+be,3)},"%m":function(W){return G(W.ec+1,2)},"%M":function(W){return G(W.Kc,2)},"%n":function(){return` +`},"%p":function(W){return 0<=W.dc&&12>W.dc?"AM":"PM"},"%S":function(W){return G(W.Lc,2)},"%t":function(){return" "},"%u":function(W){return W.Tb||7},"%U":function(W){return G(Math.floor((W.Wb+7-W.Tb)/7),2)},"%V":function(W){var be=Math.floor((W.Wb+7-(W.Tb+6)%7)/7);if(2>=(W.Tb+371-W.Wb-2)%7&&be++,be)be==53&&((ke=(W.Tb+371-W.Wb)%7)==4||ke==3&&It(W.Xb)||(be=1));else{be=52;var ke=(W.Tb+7-W.Wb-1)%7;(ke==4||ke==5&&It(W.Xb%400-1))&&be++}return G(be,2)},"%w":function(W){return W.Tb},"%W":function(W){return G(Math.floor((W.Wb+7-(W.Tb+6)%7)/7),2)},"%y":function(W){return(W.Xb+1900).toString().substring(2)},"%Y":function(W){return W.Xb+1900},"%z":function(W){var be=0<=(W=W.Jc);return W=Math.abs(W)/60,(be?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":function(W){return W.Mc},"%%":function(){return"%"}},I=I.replace(/%%/g,"\0\0"),me)I.includes(Ie)&&(I=I.replace(new RegExp(Ie,"g"),me[Ie](N)));return Ie=function(W){var be=Array(De(W)+1);return Fe(W,be,0,be.length),be}(I=I.replace(/\0\0/g,"%")),Ie.length>P?0:(function(W,be){u().set(W,be>>>0)}(Ie,x),Ie.length-1)}ie.fc();var hn=[null,Le,kt,at,_t,bt,yt,wt,Tt,vt,xt,St,Et,Ot,Pt,A,C,U,H,ne,q,_e,Ee,qe,et,jt],pn={b:function(x){return $t(x+24)+24},n:function(x){return(x=new se(x)).uc()||(x.hc(!0),ae--),x.ic(!1),st.push(x),x.sc(),x.vc()},ma:function(x){throw F("Unexpected exception thrown, this is not properly supported - aborting"),we=!0,x},x:function(){pe(0);var x=st.pop();if(x.Hc()&&!x.kc()){var P=x.Dc();P&&ye(P)(x.Zb),gt(x.Zb)}oe=0},e:function(){var x=oe;if(!x)return Be=0;var P=new se(x);P.cc(x);var I=P.bc();if(!I)return Be=0,x;for(var N=Array.prototype.slice.call(arguments),z=0;z<N.length;z++){var G=N[z];if(G===0||G===I)break;if(Nt(G,I,P.Sb+16))return Be=G,x}return Be=I,x},l:function(){var x=oe;if(!x)return Be=0;var P=new se(x);P.cc(x);var I=P.bc();if(!I)return Be=0,x;for(var N=Array.prototype.slice.call(arguments),z=0;z<N.length;z++){var G=N[z];if(G===0||G===I)break;if(Nt(G,I,P.Sb+16))return Be=G,x}return Be=I,x},h:function(){var x=oe;if(!x)return Be=0;var P=new se(x);P.cc(x);var I=P.bc();if(!I)return Be=0,x;for(var N=Array.prototype.slice.call(arguments),z=0;z<N.length;z++){var G=N[z];if(G===0||G===I)break;if(Nt(G,I,P.Sb+16))return Be=G,x}return Be=I,x},t:gt,M:function(){var x=st.pop();x||ge("no exception to throw");var P=x.Zb;throw x.kc()||(st.push(x),x.ic(!0),x.hc(!1),ae++),oe=P,P},c:function(x,P,I){throw new se(x).fc(P,I),oe=x,ae++,x},pa:function(){return ae},Fa:function(x){Ht(x,!O,1,!E),ie.pc()},T:function(x){M?postMessage({cmd:"cleanupThread",thread:x}):ct(x)},xa:mt,j:function(x){throw oe||(oe=x),x},H:_t,Ma:bt,ua:yt,wa:wt,oa:Tt,Ka:vt,Ca:xt,Ja:St,V:Et,va:Ot,sa:Pt,La:A,ta:C,Ta:function(){},X:function(){ge("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},Ua:function(){ge("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},W:function(){return Date.now()},ya:function(){return 2097152},Oa:function(){return!0},za:function(x,P,I,N){if(x==P)setTimeout(()=>R(N));else if(M)postMessage({targetThread:x,cmd:"processProxyingQueue",queue:N});else{if(!(x=ie.Vb[x]))return;x.postMessage({cmd:"processProxyingQueue",queue:N})}return 1},Ea:function(){return-1},Pa:function(x,P){x=new Date(1e3*j(x)),g()[P>>2>>>0]=x.getUTCSeconds(),g()[P+4>>2>>>0]=x.getUTCMinutes(),g()[P+8>>2>>>0]=x.getUTCHours(),g()[P+12>>2>>>0]=x.getUTCDate(),g()[P+16>>2>>>0]=x.getUTCMonth(),g()[P+20>>2>>>0]=x.getUTCFullYear()-1900,g()[P+24>>2>>>0]=x.getUTCDay(),x=(x.getTime()-Date.UTC(x.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,g()[P+28>>2>>>0]=x},Qa:function(x,P){x=new Date(1e3*j(x)),g()[P>>2>>>0]=x.getSeconds(),g()[P+4>>2>>>0]=x.getMinutes(),g()[P+8>>2>>>0]=x.getHours(),g()[P+12>>2>>>0]=x.getDate(),g()[P+16>>2>>>0]=x.getMonth(),g()[P+20>>2>>>0]=x.getFullYear()-1900,g()[P+24>>2>>>0]=x.getDay();var I=new Date(x.getFullYear(),0,1),N=(x.getTime()-I.getTime())/864e5|0;g()[P+28>>2>>>0]=N,g()[P+36>>2>>>0]=-60*x.getTimezoneOffset(),N=new Date(x.getFullYear(),6,1).getTimezoneOffset(),x=0|(N!=(I=I.getTimezoneOffset())&&x.getTimezoneOffset()==Math.min(I,N)),g()[P+32>>2>>>0]=x},Ra:function(x){var P=new Date(g()[x+20>>2>>>0]+1900,g()[x+16>>2>>>0],g()[x+12>>2>>>0],g()[x+8>>2>>>0],g()[x+4>>2>>>0],g()[x>>2>>>0],0),I=g()[x+32>>2>>>0],N=P.getTimezoneOffset(),z=new Date(P.getFullYear(),0,1),G=new Date(P.getFullYear(),6,1).getTimezoneOffset(),X=z.getTimezoneOffset(),re=Math.min(X,G);return 0>I?g()[x+32>>2>>>0]=+(G!=X&&re==N):0<I!=(re==N)&&(G=Math.max(X,G),P.setTime(P.getTime()+6e4*((0<I?re:G)-N))),g()[x+24>>2>>>0]=P.getDay(),I=(P.getTime()-z.getTime())/864e5|0,g()[x+28>>2>>>0]=I,g()[x>>2>>>0]=P.getSeconds(),g()[x+4>>2>>>0]=P.getMinutes(),g()[x+8>>2>>>0]=P.getHours(),g()[x+12>>2>>>0]=P.getDate(),g()[x+16>>2>>>0]=P.getMonth(),P.getTime()/1e3|0},Aa:U,Ba:H,Sa:function x(P,I,N){x.Ac||(x.Ac=!0,ne(P,I,N))},y:function(){ge("")},U:function(){if(!v&&!O){var x="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";ot||(ot={}),ot[x]||(ot[x]=1,v&&(x="warning: "+x),F(x))}},ra:function(){return 4294901760},B:ft,Ia:function(x,P,I){p().copyWithin(x>>>0,P>>>0,P+I>>>0)},F:function(){return v?o(3993).cpus().length:navigator.hardwareConcurrency},Da:function(x,P,I){Te.length=P,I>>=3;for(var N=0;N<P;N++)Te[N]=a()[I+N>>>0];return(0>x?At[-x-1]:hn[x]).apply(null,Te)},qa:function(x){var P=p().length;if((x>>>=0)<=P||4294901760<x)return!1;for(var I=1;4>=I;I*=2){var N=P*(1+.2/I);N=Math.min(N,x+100663296);var z=Math;N=Math.max(x,N),z=z.min.call(z,4294901760,N+(65536-N%65536)%65536);e:{try{Y.grow(z-te.byteLength+65535>>>16),Me(Y.buffer);var G=1;break e}catch{}G=void 0}if(G)return!0}return!1},Na:function(){throw"unwind"},Ga:q,Ha:_e,J:it,I:Ee,S:qe,ga:et,R:jt,d:function(){return Be},na:function x(P,I){x.lc||(x.lc=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var z=new Uint8Array(1);return()=>(crypto.getRandomValues(z),z[0])}if(v)try{var G=o(Object(function(){var X=new Error("Cannot find module 'crypto'");throw X.code="MODULE_NOT_FOUND",X}()));return()=>G.randomBytes(1)[0]}catch{}return()=>ge("randomDevice")}());for(var N=0;N<I;N++)u()[P+N>>0>>>0]=x.lc();return 0},ia:function(x,P,I){var N=de();try{return ye(x)(P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},ja:function(x,P,I){var N=de();try{return ye(x)(P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},K:function(x){var P=de();try{return ye(x)()}catch(I){if(ce(P),I!==I+0)throw I;pe(1,0)}},f:function(x,P){var I=de();try{return ye(x)(P)}catch(N){if(ce(I),N!==N+0)throw N;pe(1,0)}},P:function(x,P,I){var N=de();try{return ye(x)(P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},Q:function(x,P,I){var N=de();try{return ye(x)(P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},k:function(x,P,I){var N=de();try{return ye(x)(P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},p:function(x,P,I,N){var z=de();try{return ye(x)(P,I,N)}catch(G){if(ce(z),G!==G+0)throw G;pe(1,0)}},q:function(x,P,I,N,z){var G=de();try{return ye(x)(P,I,N,z)}catch(X){if(ce(G),X!==X+0)throw X;pe(1,0)}},N:function(x,P,I,N,z,G){var X=de();try{return ye(x)(P,I,N,z,G)}catch(re){if(ce(X),re!==re+0)throw re;pe(1,0)}},s:function(x,P,I,N,z,G){var X=de();try{return ye(x)(P,I,N,z,G)}catch(re){if(ce(X),re!==re+0)throw re;pe(1,0)}},w:function(x,P,I,N,z,G,X){var re=de();try{return ye(x)(P,I,N,z,G,X)}catch(fe){if(ce(re),fe!==fe+0)throw fe;pe(1,0)}},L:function(x,P,I,N,z,G,X,re){var fe=de();try{return ye(x)(P,I,N,z,G,X,re)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},E:function(x,P,I,N,z,G,X,re,fe,me,Ie,Xe){var We=de();try{return ye(x)(P,I,N,z,G,X,re,fe,me,Ie,Xe)}catch(W){if(ce(We),W!==W+0)throw W;pe(1,0)}},aa:function(x,P,I,N,z,G,X,re){var fe=de();try{return un(x,P,I,N,z,G,X,re)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},_:function(x,P,I,N,z,G,X){var re=de();try{return en(x,P,I,N,z,G,X)}catch(fe){if(ce(re),fe!==fe+0)throw fe;pe(1,0)}},Z:function(x,P,I,N,z){var G=de();try{return ln(x,P,I,N,z)}catch(X){if(ce(G),X!==X+0)throw X;pe(1,0)}},ca:function(x,P,I,N){var z=de();try{return sn(x,P,I,N)}catch(G){if(ce(z),G!==G+0)throw G;pe(1,0)}},$:function(x){var P=de();try{return Zt(x)}catch(I){if(ce(P),I!==I+0)throw I;pe(1,0)}},ba:function(x,P){var I=de();try{return an(x,P)}catch(N){if(ce(I),N!==N+0)throw N;pe(1,0)}},Y:function(x,P,I){var N=de();try{return tn(x,P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},g:function(x){var P=de();try{ye(x)()}catch(I){if(ce(P),I!==I+0)throw I;pe(1,0)}},r:function(x,P){var I=de();try{ye(x)(P)}catch(N){if(ce(I),N!==N+0)throw N;pe(1,0)}},i:function(x,P,I){var N=de();try{ye(x)(P,I)}catch(z){if(ce(N),z!==z+0)throw z;pe(1,0)}},ha:function(x,P,I,N){var z=de();try{ye(x)(P,I,N)}catch(G){if(ce(z),G!==G+0)throw G;pe(1,0)}},m:function(x,P,I,N){var z=de();try{ye(x)(P,I,N)}catch(G){if(ce(z),G!==G+0)throw G;pe(1,0)}},v:function(x,P,I,N,z){var G=de();try{ye(x)(P,I,N,z)}catch(X){if(ce(G),X!==X+0)throw X;pe(1,0)}},u:function(x,P,I,N,z,G){var X=de();try{ye(x)(P,I,N,z,G)}catch(re){if(ce(X),re!==re+0)throw re;pe(1,0)}},O:function(x,P,I,N,z,G,X){var re=de();try{ye(x)(P,I,N,z,G,X)}catch(fe){if(ce(re),fe!==fe+0)throw fe;pe(1,0)}},A:function(x,P,I,N,z,G,X,re){var fe=de();try{ye(x)(P,I,N,z,G,X,re)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},ka:function(x,P,I,N,z,G,X,re,fe){var me=de();try{ye(x)(P,I,N,z,G,X,re,fe)}catch(Ie){if(ce(me),Ie!==Ie+0)throw Ie;pe(1,0)}},C:function(x,P,I,N,z,G,X,re,fe,me,Ie){var Xe=de();try{ye(x)(P,I,N,z,G,X,re,fe,me,Ie)}catch(We){if(ce(Xe),We!==We+0)throw We;pe(1,0)}},D:function(x,P,I,N,z,G,X,re,fe,me,Ie,Xe,We,W,be,ke){var tt=de();try{ye(x)(P,I,N,z,G,X,re,fe,me,Ie,Xe,We,W,be,ke)}catch(ht){if(ce(tt),ht!==ht+0)throw ht;pe(1,0)}},fa:function(x,P,I,N,z,G,X,re){var fe=de();try{nn(x,P,I,N,z,G,X,re)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},da:function(x,P,I,N,z,G,X,re,fe,me,Ie,Xe){var We=de();try{on(x,P,I,N,z,G,X,re,fe,me,Ie,Xe)}catch(W){if(ce(We),W!==W+0)throw W;pe(1,0)}},ea:function(x,P,I,N,z,G){var X=de();try{rn(x,P,I,N,z,G)}catch(re){if(ce(X),re!==re+0)throw re;pe(1,0)}},o:function(x){return x},a:Y||t.wasmMemory,G:function(x){Be=x},la:Ut,z:function(x,P,I,N){return Ut(x,P,I,N)}};(function(){function x(z,G){t.asm=z.exports,ie.qc.push(t.asm.sb),je=t.asm.ub,Ue.unshift(t.asm.Va),ee=G,M||(Re--,t.monitorRunDependencies&&t.monitorRunDependencies(Re),Re==0&&Ke&&(z=Ke,Ke=null,z()))}function P(z){x(z.instance,z.module)}function I(z){return function(){if(!D&&(E||O)){if(typeof fetch=="function"&&!Pe.startsWith("file://"))return fetch(Pe,{credentials:"same-origin"}).then(function(G){if(!G.ok)throw"failed to load wasm binary file at '"+Pe+"'";return G.arrayBuffer()}).catch(function(){return lt()});if(h)return new Promise(function(G,X){h(Pe,function(re){G(new Uint8Array(re))},X)})}return Promise.resolve().then(function(){return lt()})}().then(function(G){return WebAssembly.instantiate(G,N)}).then(function(G){return G}).then(z,function(G){F("failed to asynchronously prepare wasm: "+G),ge(G)})}var N={a:pn};if(M||(Re++,t.monitorRunDependencies&&t.monitorRunDependencies(Re)),t.instantiateWasm)try{return t.instantiateWasm(N,x)}catch(z){return F("Module.instantiateWasm callback failed with error: "+z),!1}(D||typeof WebAssembly.instantiateStreaming!="function"||pt()||Pe.startsWith("file://")||v||typeof fetch!="function"?I(P):fetch(Pe,{credentials:"same-origin"}).then(function(z){return WebAssembly.instantiateStreaming(z,N).then(P,function(G){return F("wasm streaming compile failed: "+G),F("falling back to ArrayBuffer instantiation"),I(P)})})).catch(r)})(),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 Ct=t._pthread_self=function(){return(Ct=t._pthread_self=t.asm.ob).apply(null,arguments)},$t=t._malloc=function(){return($t=t._malloc=t.asm.pb).apply(null,arguments)},Gt=t._free=function(){return(Gt=t._free=t.asm.qb).apply(null,arguments)},qt=t._fflush=function(){return(qt=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 Wt=t.___funcs_on_exit=function(){return(Wt=t.___funcs_on_exit=t.asm.tb).apply(null,arguments)},Ht=t.__emscripten_thread_init=function(){return(Ht=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 Dt,Yt=t._emscripten_run_in_main_runtime_thread_js=function(){return(Yt=t._emscripten_run_in_main_runtime_thread_js=t.asm.xb).apply(null,arguments)},Kt=t.__emscripten_proxy_execute_task_queue=function(){return(Kt=t.__emscripten_proxy_execute_task_queue=t.asm.yb).apply(null,arguments)},Rt=t.__emscripten_thread_free_data=function(){return(Rt=t.__emscripten_thread_free_data=t.asm.zb).apply(null,arguments)},Xt=t.__emscripten_thread_exit=function(){return(Xt=t.__emscripten_thread_exit=t.asm.Ab).apply(null,arguments)},pe=t._setThrew=function(){return(pe=t._setThrew=t.asm.Bb).apply(null,arguments)},Qt=t._emscripten_stack_set_limits=function(){return(Qt=t._emscripten_stack_set_limits=t.asm.Cb).apply(null,arguments)},de=t.stackSave=function(){return(de=t.stackSave=t.asm.Db).apply(null,arguments)},ce=t.stackRestore=function(){return(ce=t.stackRestore=t.asm.Eb).apply(null,arguments)},Bt=t.stackAlloc=function(){return(Bt=t.stackAlloc=t.asm.Fb).apply(null,arguments)},Nt=t.___cxa_can_catch=function(){return(Nt=t.___cxa_can_catch=t.asm.Gb).apply(null,arguments)},Jt=t.___cxa_is_pointer_type=function(){return(Jt=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)},en=t.dynCall_iiiiij=function(){return(en=t.dynCall_iiiiij=t.asm.Jb).apply(null,arguments)},tn=t.dynCall_jii=function(){return(tn=t.dynCall_jii=t.asm.Kb).apply(null,arguments)},nn=t.dynCall_viiiiij=function(){return(nn=t.dynCall_viiiiij=t.asm.Lb).apply(null,arguments)},rn=t.dynCall_vjji=function(){return(rn=t.dynCall_vjji=t.asm.Mb).apply(null,arguments)},on=t.dynCall_viiijjjii=function(){return(on=t.dynCall_viiijjjii=t.asm.Nb).apply(null,arguments)},sn=t.dynCall_iij=function(){return(sn=t.dynCall_iij=t.asm.Ob).apply(null,arguments)},an=t.dynCall_ji=function(){return(an=t.dynCall_ji=t.asm.Pb).apply(null,arguments)},un=t.dynCall_iiiiiij=function(){return(un=t.dynCall_iiiiiij=t.asm.Qb).apply(null,arguments)},ln=t.dynCall_iiij=function(){return(ln=t.dynCall_iiij=t.asm.Rb).apply(null,arguments)};function cn(){function x(){if(!Dt&&(Dt=!0,t.calledRun=!0,!we)&&(M||rt(Ue),e(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),!M)){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;){var P=t.postRun.shift();Qe.unshift(P)}rt(Qe)}}if(!(0<Re))if(M)e(t),M||rt(Ue),postMessage({cmd:"loaded"});else{if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Ve();rt(ze),0<Re||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),x()},1)):x())}}if(t.UTF8ToString=Ae,t.stringToUTF8=function(x,P,I){return Fe(x,p(),P,I)},t.lengthBytesUTF8=De,t.keepRuntimeAlive=Ge,t.wasmMemory=Y,t.stackSave=de,t.stackRestore=ce,t.stackAlloc=Bt,t.ExitStatus=Je,t.PThread=ie,Ke=function x(){Dt||cn(),Dt||(Ke=x)},t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);0<t.preInit.length;)t.preInit.pop()();return cn(),f.ready});d.exports=l},932:(d,n,o)=>{var s,l=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(f){var u,p,g;f=f||{},u||(u=f!==void 0?f:{}),u.ready=new Promise(function(A,C){p=A,g=C});var c,a,t,e,r,i,h=Object.assign({},u),m="./this.program",_=(A,C)=>{throw C},b=typeof window=="object",y=typeof importScripts=="function",T=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",w="";T?(w=y?o(908).dirname(w)+"/":"//",i=()=>{r||(e=o(1384),r=o(908))},c=function(A,C){return i(),A=r.normalize(A),e.readFileSync(A,C?void 0:"utf8")},t=A=>((A=c(A,!0)).buffer||(A=new Uint8Array(A)),A),a=(A,C,R)=>{i(),A=r.normalize(A),e.readFile(A,function(j,U){j?R(j):C(U.buffer)})},1<process.argv.length&&(m=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(A){if(!(A instanceof Ue))throw A}),process.on("unhandledRejection",function(A){throw A}),_=(A,C)=>{if(v||0<$e)throw process.exitCode=A,C;C instanceof Ue||O("exiting due to exception: "+C),process.exit(A)},u.inspect=function(){return"[Emscripten Module object]"}):(b||y)&&(y?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),s&&(w=s),w=w.indexOf("blob:")!==0?w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):"",c=A=>{var C=new XMLHttpRequest;return C.open("GET",A,!1),C.send(null),C.responseText},y&&(t=A=>{var C=new XMLHttpRequest;return C.open("GET",A,!1),C.responseType="arraybuffer",C.send(null),new Uint8Array(C.response)}),a=(A,C,R)=>{var j=new XMLHttpRequest;j.open("GET",A,!0),j.responseType="arraybuffer",j.onload=()=>{j.status==200||j.status==0&&j.response?C(j.response):R()},j.onerror=R,j.send(null)});var S,E=u.print||console.log.bind(console),O=u.printErr||console.warn.bind(console);Object.assign(u,h),h=null,u.thisProgram&&(m=u.thisProgram),u.quit&&(_=u.quit),u.wasmBinary&&(S=u.wasmBinary);var v=u.noExitRuntime||!1;typeof WebAssembly!="object"&&Me("no native wasm support detected");var M,$,V,B,L,D,k=!1,F=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Q(A,C,R){var j=(C>>>=0)+R;for(R=C;A[R]&&!(R>=j);)++R;if(16<R-C&&A.buffer&&F)return F.decode(A.subarray(C,R));for(j="";C<R;){var U=A[C++];if(128&U){var H=63&A[C++];if((224&U)==192)j+=String.fromCharCode((31&U)<<6|H);else{var K=63&A[C++];65536>(U=(240&U)==224?(15&U)<<12|H<<6|K:(7&U)<<18|H<<12|K<<6|63&A[C++])?j+=String.fromCharCode(U):(U-=65536,j+=String.fromCharCode(55296|U>>10,56320|1023&U))}}else j+=String.fromCharCode(U)}return j}function Y(A,C){return(A>>>=0)?Q(B,A,C):""}function ee(A,C,R,j){if(!(0<j))return 0;var U=R>>>=0;j=R+j-1;for(var H=0;H<A.length;++H){var K=A.charCodeAt(H);if(55296<=K&&57343>=K&&(K=65536+((1023&K)<<10)|1023&A.charCodeAt(++H)),127>=K){if(R>=j)break;C[R++>>>0]=K}else{if(2047>=K){if(R+1>=j)break;C[R++>>>0]=192|K>>6}else{if(65535>=K){if(R+2>=j)break;C[R++>>>0]=224|K>>12}else{if(R+3>=j)break;C[R++>>>0]=240|K>>18,C[R++>>>0]=128|K>>12&63}C[R++>>>0]=128|K>>6&63}C[R++>>>0]=128|63&K}}return C[R>>>0]=0,R-U}function te(A){for(var C=0,R=0;R<A.length;++R){var j=A.charCodeAt(R);127>=j?C++:2047>=j?C+=2:55296<=j&&57343>=j?(C+=4,++R):C+=3}return C}function he(){var A=M.buffer;$=A,u.HEAP8=V=new Int8Array(A),u.HEAP16=new Int16Array(A),u.HEAP32=L=new Int32Array(A),u.HEAPU8=B=new Uint8Array(A),u.HEAPU16=new Uint16Array(A),u.HEAPU32=D=new Uint32Array(A),u.HEAPF32=new Float32Array(A),u.HEAPF64=new Float64Array(A)}var Oe,xe=[],ue=[],Se=[],we=[],$e=0;function He(){var A=u.preRun.shift();xe.unshift(A)}var Ae,Fe=0,De=null;function Me(A){throw u.onAbort&&u.onAbort(A),O(A="Aborted("+A+")"),k=!0,A=new WebAssembly.RuntimeError(A+". Build with -sASSERTIONS for more info."),g(A),A}function ve(){return Ae.startsWith("data:application/octet-stream;base64,")}if(Ae="ort-wasm.wasm",!ve()){var je=Ae;Ae=u.locateFile?u.locateFile(je,w):w+je}function ze(){var A=Ae;try{if(A==Ae&&S)return new Uint8Array(S);if(t)return t(A);throw"both async and sync fetching of the wasm failed"}catch(C){Me(C)}}function Ue(A){this.name="ExitStatus",this.message="Program terminated with exit("+A+")",this.status=A}function Ye(A){for(;0<A.length;)A.shift()(u)}var Qe=[],Ge=0,Ve=0;function Pe(A){this.Db=A,this.zb=A-24,this.Ub=function(C){D[this.zb+4>>2>>>0]=C},this.Eb=function(){return D[this.zb+4>>2>>>0]},this.Sb=function(C){D[this.zb+8>>2>>>0]=C},this.Wb=function(){return D[this.zb+8>>2>>>0]},this.Tb=function(){L[this.zb>>2>>>0]=0},this.Ib=function(C){V[this.zb+12>>0>>>0]=C?1:0},this.Pb=function(){return V[this.zb+12>>0>>>0]!=0},this.Jb=function(C){V[this.zb+13>>0>>>0]=C?1:0},this.Lb=function(){return V[this.zb+13>>0>>>0]!=0},this.Rb=function(C,R){this.Fb(0),this.Ub(C),this.Sb(R),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){L[this.zb>>2>>>0]+=1},this.Xb=function(){var C=L[this.zb>>2>>>0];return L[this.zb>>2>>>0]=C-1,C===1},this.Fb=function(C){D[this.zb+16>>2>>>0]=C},this.Ob=function(){return D[this.zb+16>>2>>>0]},this.Qb=function(){if(mt(this.Eb()))return D[this.Db>>2>>>0];var C=this.Ob();return C!==0?C:this.Db}}function Re(A){return ot(new Pe(A).zb)}var Ke=[];function ge(A){var C=Ke[A];return C||(A>=Ke.length&&(Ke.length=A+1),Ke[A]=C=Oe.get(A)),C}function pt(A){var C=te(A)+1,R=ye(C);return R&&ee(A,V,R,C),R}var lt={};function At(){if(!Je){var A,C={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",_:m||"./this.program"};for(A in lt)lt[A]===void 0?delete C[A]:C[A]=lt[A];var R=[];for(A in C)R.push(A+"="+C[A]);Je=R}return Je}var Je,ct=[null,[],[]];function dt(A,C){var R=ct[A];C===0||C===10?((A===1?E:O)(Q(R,0)),R.length=0):R.push(C)}var Le=0;function it(A){return A%4==0&&(A%100!=0||A%400==0)}var ie=[31,29,31,30,31,30,31,31,30,31,30,31],rt=[31,28,31,30,31,30,31,31,30,31,30,31];function Mt(A,C,R,j){function U(q,_e,Ee){for(q=typeof q=="number"?q.toString():q||"";q.length<_e;)q=Ee[0]+q;return q}function H(q,_e){return U(q,_e,"0")}function K(q,_e){function Ee(et){return 0>et?-1:0<et?1:0}var qe;return(qe=Ee(q.getFullYear()-_e.getFullYear()))===0&&(qe=Ee(q.getMonth()-_e.getMonth()))===0&&(qe=Ee(q.getDate()-_e.getDate())),qe}function ne(q){switch(q.getDay()){case 0:return new Date(q.getFullYear()-1,11,29);case 1:return q;case 2:return new Date(q.getFullYear(),0,3);case 3:return new Date(q.getFullYear(),0,2);case 4:return new Date(q.getFullYear(),0,1);case 5:return new Date(q.getFullYear()-1,11,31);case 6:return new Date(q.getFullYear()-1,11,30)}}function Z(q){var _e=q.Bb;for(q=new Date(new Date(q.Cb+1900,0,1).getTime());0<_e;){var Ee=q.getMonth(),qe=(it(q.getFullYear())?ie:rt)[Ee];if(!(_e>qe-q.getDate())){q.setDate(q.getDate()+_e);break}_e-=qe-q.getDate()+1,q.setDate(1),11>Ee?q.setMonth(Ee+1):(q.setMonth(0),q.setFullYear(q.getFullYear()+1))}return Ee=new Date(q.getFullYear()+1,0,4),_e=ne(new Date(q.getFullYear(),0,4)),Ee=ne(Ee),0>=K(_e,q)?0>=K(Ee,q)?q.getFullYear()+1:q.getFullYear():q.getFullYear()-1}var le=L[j+40>>2>>>0];for(var Te in j={$b:L[j>>2>>>0],Zb:L[j+4>>2>>>0],Gb:L[j+8>>2>>>0],Kb:L[j+12>>2>>>0],Hb:L[j+16>>2>>>0],Cb:L[j+20>>2>>>0],Ab:L[j+24>>2>>>0],Bb:L[j+28>>2>>>0],bc:L[j+32>>2>>>0],Yb:L[j+36>>2>>>0],ac:le?Y(le):""},R=Y(R),le={"%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(Te,"g"),le[Te]);var Ne="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ce="January February March April May June July August September October November December".split(" ");for(Te in le={"%a":function(q){return Ne[q.Ab].substring(0,3)},"%A":function(q){return Ne[q.Ab]},"%b":function(q){return Ce[q.Hb].substring(0,3)},"%B":function(q){return Ce[q.Hb]},"%C":function(q){return H((q.Cb+1900)/100|0,2)},"%d":function(q){return H(q.Kb,2)},"%e":function(q){return U(q.Kb,2," ")},"%g":function(q){return Z(q).toString().substring(2)},"%G":function(q){return Z(q)},"%H":function(q){return H(q.Gb,2)},"%I":function(q){return(q=q.Gb)==0?q=12:12<q&&(q-=12),H(q,2)},"%j":function(q){for(var _e=0,Ee=0;Ee<=q.Hb-1;_e+=(it(q.Cb+1900)?ie:rt)[Ee++]);return H(q.Kb+_e,3)},"%m":function(q){return H(q.Hb+1,2)},"%M":function(q){return H(q.Zb,2)},"%n":function(){return` +`},"%p":function(q){return 0<=q.Gb&&12>q.Gb?"AM":"PM"},"%S":function(q){return H(q.$b,2)},"%t":function(){return" "},"%u":function(q){return q.Ab||7},"%U":function(q){return H(Math.floor((q.Bb+7-q.Ab)/7),2)},"%V":function(q){var _e=Math.floor((q.Bb+7-(q.Ab+6)%7)/7);if(2>=(q.Ab+371-q.Bb-2)%7&&_e++,_e)_e==53&&((Ee=(q.Ab+371-q.Bb)%7)==4||Ee==3&&it(q.Cb)||(_e=1));else{_e=52;var Ee=(q.Ab+7-q.Bb-1)%7;(Ee==4||Ee==5&&it(q.Cb%400-1))&&_e++}return H(_e,2)},"%w":function(q){return q.Ab},"%W":function(q){return H(Math.floor((q.Bb+7-(q.Ab+6)%7)/7),2)},"%y":function(q){return(q.Cb+1900).toString().substring(2)},"%Y":function(q){return q.Cb+1900},"%z":function(q){var _e=0<=(q=q.Yb);return q=Math.abs(q)/60,(_e?"+":"-")+("0000"+(q/60*100+q%60)).slice(-4)},"%Z":function(q){return q.ac},"%%":function(){return"%"}},R=R.replace(/%%/g,"\0\0"),le)R.includes(Te)&&(R=R.replace(new RegExp(Te,"g"),le[Te](j)));return Te=function(q){var _e=Array(te(q)+1);return ee(q,_e,0,_e.length),_e}(R=R.replace(/\0\0/g,"%")),Te.length>C?0:(V.set(Te,A>>>0),Te.length-1)}var kt={a:function(A){return ye(A+24)+24},m:function(A){return(A=new Pe(A)).Pb()||(A.Ib(!0),Ge--),A.Jb(!1),Qe.push(A),A.Nb(),A.Qb()},ia:function(A){throw O("Unexpected exception thrown, this is not properly supported - aborting"),k=!0,A},w:function(){ae(0);var A=Qe.pop();if(A.Xb()&&!A.Lb()){var C=A.Wb();C&&ge(C)(A.Db),Re(A.Db)}Ve=0},d:function(){var A=Ve;if(!A)return Le=0;var C=new Pe(A);C.Fb(A);var R=C.Eb();if(!R)return Le=0,A;for(var j=Array.prototype.slice.call(arguments),U=0;U<j.length;U++){var H=j[U];if(H===0||H===R)break;if(at(H,R,C.zb+16))return Le=H,A}return Le=R,A},k:function(){var A=Ve;if(!A)return Le=0;var C=new Pe(A);C.Fb(A);var R=C.Eb();if(!R)return Le=0,A;for(var j=Array.prototype.slice.call(arguments),U=0;U<j.length;U++){var H=j[U];if(H===0||H===R)break;if(at(H,R,C.zb+16))return Le=H,A}return Le=R,A},g:function(){var A=Ve;if(!A)return Le=0;var C=new Pe(A);C.Fb(A);var R=C.Eb();if(!R)return Le=0,A;for(var j=Array.prototype.slice.call(arguments),U=0;U<j.length;U++){var H=j[U];if(H===0||H===R)break;if(at(H,R,C.zb+16))return Le=H,A}return Le=R,A},s:Re,L:function(){var A=Qe.pop();A||Me("no exception to throw");var C=A.Db;throw A.Lb()||(Qe.push(A),A.Jb(!0),A.Ib(!1),Ge++),Ve=C,C},b:function(A,C,R){throw new Pe(A).Rb(C,R),Ve=A,Ge++,A},la:function(){return Ge},i:function(A){throw Ve||(Ve=A),A},H:function(){return 0},Ba:function(){},pa:function(){},ra:function(){},ka:function(){return 0},za:function(){},ua:function(){},ya:function(){},R:function(){},qa:function(){},na:function(){},Aa:function(){},oa:function(){},Ha:function(){},Ja:function(){Me("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},Ia:function(){Me("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},S:function(){return Date.now()},Ca:function(){return!0},Da:function(A,C){A=new Date(1e3*(D[A>>>2]+4294967296*L[A+4>>>2])),L[C>>2>>>0]=A.getUTCSeconds(),L[C+4>>2>>>0]=A.getUTCMinutes(),L[C+8>>2>>>0]=A.getUTCHours(),L[C+12>>2>>>0]=A.getUTCDate(),L[C+16>>2>>>0]=A.getUTCMonth(),L[C+20>>2>>>0]=A.getUTCFullYear()-1900,L[C+24>>2>>>0]=A.getUTCDay(),L[C+28>>2>>>0]=(A.getTime()-Date.UTC(A.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(A,C){A=new Date(1e3*(D[A>>>2]+4294967296*L[A+4>>>2])),L[C>>2>>>0]=A.getSeconds(),L[C+4>>2>>>0]=A.getMinutes(),L[C+8>>2>>>0]=A.getHours(),L[C+12>>2>>>0]=A.getDate(),L[C+16>>2>>>0]=A.getMonth(),L[C+20>>2>>>0]=A.getFullYear()-1900,L[C+24>>2>>>0]=A.getDay();var R=new Date(A.getFullYear(),0,1);L[C+28>>2>>>0]=(A.getTime()-R.getTime())/864e5|0,L[C+36>>2>>>0]=-60*A.getTimezoneOffset();var j=new Date(A.getFullYear(),6,1).getTimezoneOffset();R=R.getTimezoneOffset(),L[C+32>>2>>>0]=0|(j!=R&&A.getTimezoneOffset()==Math.min(R,j))},Fa:function(A){var C=new Date(L[A+20>>2>>>0]+1900,L[A+16>>2>>>0],L[A+12>>2>>>0],L[A+8>>2>>>0],L[A+4>>2>>>0],L[A>>2>>>0],0),R=L[A+32>>2>>>0],j=C.getTimezoneOffset(),U=new Date(C.getFullYear(),0,1),H=new Date(C.getFullYear(),6,1).getTimezoneOffset(),K=U.getTimezoneOffset(),ne=Math.min(K,H);return 0>R?L[A+32>>2>>>0]=+(H!=K&&ne==j):0<R!=(ne==j)&&(H=Math.max(K,H),C.setTime(C.getTime()+6e4*((0<R?ne:H)-j))),L[A+24>>2>>>0]=C.getDay(),L[A+28>>2>>>0]=(C.getTime()-U.getTime())/864e5|0,L[A>>2>>>0]=C.getSeconds(),L[A+4>>2>>>0]=C.getMinutes(),L[A+8>>2>>>0]=C.getHours(),L[A+12>>2>>>0]=C.getDate(),L[A+16>>2>>>0]=C.getMonth(),C.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function A(C,R,j){A.Vb||(A.Vb=!0,function(U,H,K){function ne(Ce){return(Ce=Ce.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ce[1]:"GMT"}var Z=new Date().getFullYear(),le=new Date(Z,0,1),Te=new Date(Z,6,1);Z=le.getTimezoneOffset();var Ne=Te.getTimezoneOffset();L[U>>2>>>0]=60*Math.max(Z,Ne),L[H>>2>>>0]=+(Z!=Ne),U=ne(le),H=ne(Te),U=pt(U),H=pt(H),Ne<Z?(D[K>>2>>>0]=U,D[K+4>>2>>>0]=H):(D[K>>2>>>0]=H,D[K+4>>2>>>0]=U)}(C,R,j))},B:function(){Me("")},ma:function(){return 4294901760},I:T?()=>{var A=process.hrtime();return 1e3*A[0]+A[1]/1e6}:()=>performance.now(),xa:function(A,C,R){B.copyWithin(A>>>0,C>>>0,C+R>>>0)},G:function(A){var C=B.length;if(4294901760<(A>>>=0))return!1;for(var R=1;4>=R;R*=2){var j=C*(1+.2/R);j=Math.min(j,A+100663296);var U=Math;j=Math.max(A,j),U=U.min.call(U,4294901760,j+(65536-j%65536)%65536);e:{try{M.grow(U-$.byteLength+65535>>>16),he();var H=1;break e}catch{}H=void 0}if(H)return!0}return!1},va:function(A,C){var R=0;return At().forEach(function(j,U){var H=C+R;for(U=D[A+4*U>>2>>>0]=H,H=0;H<j.length;++H)V[U++>>0>>>0]=j.charCodeAt(H);V[U>>0>>>0]=0,R+=j.length+1}),0},wa:function(A,C){var R=At();D[A>>2>>>0]=R.length;var j=0;return R.forEach(function(U){j+=U.length+1}),D[C>>2>>>0]=j,0},ba:function(A){v||0<$e||(st(),Ye(Se),ft(0),ct[1].length&&dt(1,10),ct[2].length&&dt(2,10)),v||0<$e||(u.onExit&&u.onExit(A),k=!0),_(A,new Ue(A))},E:function(){return 52},Q:function(){return 52},ca:function(){return 70},P:function(A,C,R,j){for(var U=0,H=0;H<R;H++){var K=D[C>>2>>>0],ne=D[C+4>>2>>>0];C+=8;for(var Z=0;Z<ne;Z++)dt(A,B[K+Z>>>0]);U+=ne}return D[j>>2>>>0]=U,0},c:function(){return Le},ja:function A(C,R){A.Mb||(A.Mb=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var U=new Uint8Array(1);return()=>(crypto.getRandomValues(U),U[0])}if(T)try{var H=o(Object(function(){var K=new Error("Cannot find module 'crypto'");throw K.code="MODULE_NOT_FOUND",K}()));return()=>H.randomBytes(1)[0]}catch{}return()=>Me("randomDevice")}());for(var j=0;j<R;j++)V[C+j>>0>>>0]=A.Mb();return 0},ea:function(A,C,R){var j=oe();try{return ge(A)(C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},fa:function(A,C,R){var j=oe();try{return ge(A)(C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},J:function(A){var C=oe();try{return ge(A)()}catch(R){if(se(C),R!==R+0)throw R;ae(1,0)}},e:function(A,C){var R=oe();try{return ge(A)(C)}catch(j){if(se(R),j!==j+0)throw j;ae(1,0)}},N:function(A,C,R){var j=oe();try{return ge(A)(C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},O:function(A,C,R){var j=oe();try{return ge(A)(C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},j:function(A,C,R){var j=oe();try{return ge(A)(C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},o:function(A,C,R,j){var U=oe();try{return ge(A)(C,R,j)}catch(H){if(se(U),H!==H+0)throw H;ae(1,0)}},p:function(A,C,R,j,U){var H=oe();try{return ge(A)(C,R,j,U)}catch(K){if(se(H),K!==K+0)throw K;ae(1,0)}},M:function(A,C,R,j,U,H){var K=oe();try{return ge(A)(C,R,j,U,H)}catch(ne){if(se(K),ne!==ne+0)throw ne;ae(1,0)}},r:function(A,C,R,j,U,H){var K=oe();try{return ge(A)(C,R,j,U,H)}catch(ne){if(se(K),ne!==ne+0)throw ne;ae(1,0)}},v:function(A,C,R,j,U,H,K){var ne=oe();try{return ge(A)(C,R,j,U,H,K)}catch(Z){if(se(ne),Z!==Z+0)throw Z;ae(1,0)}},K:function(A,C,R,j,U,H,K,ne){var Z=oe();try{return ge(A)(C,R,j,U,H,K,ne)}catch(le){if(se(Z),le!==le+0)throw le;ae(1,0)}},D:function(A,C,R,j,U,H,K,ne,Z,le,Te,Ne){var Ce=oe();try{return ge(A)(C,R,j,U,H,K,ne,Z,le,Te,Ne)}catch(q){if(se(Ce),q!==q+0)throw q;ae(1,0)}},X:function(A,C,R,j,U,H,K,ne){var Z=oe();try{return Et(A,C,R,j,U,H,K,ne)}catch(le){if(se(Z),le!==le+0)throw le;ae(1,0)}},V:function(A,C,R,j,U,H,K){var ne=oe();try{return bt(A,C,R,j,U,H,K)}catch(Z){if(se(ne),Z!==Z+0)throw Z;ae(1,0)}},U:function(A,C,R,j,U){var H=oe();try{return Ot(A,C,R,j,U)}catch(K){if(se(H),K!==K+0)throw K;ae(1,0)}},Z:function(A,C,R,j){var U=oe();try{return xt(A,C,R,j)}catch(H){if(se(U),H!==H+0)throw H;ae(1,0)}},W:function(A){var C=oe();try{return _t(A)}catch(R){if(se(C),R!==R+0)throw R;ae(1,0)}},Y:function(A,C){var R=oe();try{return St(A,C)}catch(j){if(se(R),j!==j+0)throw j;ae(1,0)}},T:function(A,C,R){var j=oe();try{return yt(A,C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},f:function(A){var C=oe();try{ge(A)()}catch(R){if(se(C),R!==R+0)throw R;ae(1,0)}},q:function(A,C){var R=oe();try{ge(A)(C)}catch(j){if(se(R),j!==j+0)throw j;ae(1,0)}},h:function(A,C,R){var j=oe();try{ge(A)(C,R)}catch(U){if(se(j),U!==U+0)throw U;ae(1,0)}},da:function(A,C,R,j){var U=oe();try{ge(A)(C,R,j)}catch(H){if(se(U),H!==H+0)throw H;ae(1,0)}},l:function(A,C,R,j){var U=oe();try{ge(A)(C,R,j)}catch(H){if(se(U),H!==H+0)throw H;ae(1,0)}},t:function(A,C,R,j,U){var H=oe();try{ge(A)(C,R,j,U)}catch(K){if(se(H),K!==K+0)throw K;ae(1,0)}},u:function(A,C,R,j,U,H){var K=oe();try{ge(A)(C,R,j,U,H)}catch(ne){if(se(K),ne!==ne+0)throw ne;ae(1,0)}},x:function(A,C,R,j,U,H,K){var ne=oe();try{ge(A)(C,R,j,U,H,K)}catch(Z){if(se(ne),Z!==Z+0)throw Z;ae(1,0)}},z:function(A,C,R,j,U,H,K,ne){var Z=oe();try{ge(A)(C,R,j,U,H,K,ne)}catch(le){if(se(Z),le!==le+0)throw le;ae(1,0)}},ga:function(A,C,R,j,U,H,K,ne,Z){var le=oe();try{ge(A)(C,R,j,U,H,K,ne,Z)}catch(Te){if(se(le),Te!==Te+0)throw Te;ae(1,0)}},A:function(A,C,R,j,U,H,K,ne,Z,le,Te){var Ne=oe();try{ge(A)(C,R,j,U,H,K,ne,Z,le,Te)}catch(Ce){if(se(Ne),Ce!==Ce+0)throw Ce;ae(1,0)}},C:function(A,C,R,j,U,H,K,ne,Z,le,Te,Ne,Ce,q,_e,Ee){var qe=oe();try{ge(A)(C,R,j,U,H,K,ne,Z,le,Te,Ne,Ce,q,_e,Ee)}catch(et){if(se(qe),et!==et+0)throw et;ae(1,0)}},aa:function(A,C,R,j,U,H,K,ne){var Z=oe();try{wt(A,C,R,j,U,H,K,ne)}catch(le){if(se(Z),le!==le+0)throw le;ae(1,0)}},_:function(A,C,R,j,U,H,K,ne,Z,le,Te,Ne){var Ce=oe();try{vt(A,C,R,j,U,H,K,ne,Z,le,Te,Ne)}catch(q){if(se(Ce),q!==q+0)throw q;ae(1,0)}},$:function(A,C,R,j,U,H){var K=oe();try{Tt(A,C,R,j,U,H)}catch(ne){if(se(K),ne!==ne+0)throw ne;ae(1,0)}},n:function(A){return A},F:function(A){Le=A},ha:Mt,y:function(A,C,R,j){return Mt(A,C,R,j)}};(function(){function A(U){u.asm=U.exports,M=u.asm.Ka,he(),Oe=u.asm.ib,ue.unshift(u.asm.La),Fe--,u.monitorRunDependencies&&u.monitorRunDependencies(Fe),Fe==0&&De&&(U=De,De=null,U())}function C(U){A(U.instance)}function R(U){return function(){if(!S&&(b||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 ze()});if(a)return new Promise(function(H,K){a(Ae,function(ne){H(new Uint8Array(ne))},K)})}return Promise.resolve().then(function(){return ze()})}().then(function(H){return WebAssembly.instantiate(H,j)}).then(function(H){return H}).then(U,function(H){O("failed to asynchronously prepare wasm: "+H),Me(H)})}var j={a:kt};if(Fe++,u.monitorRunDependencies&&u.monitorRunDependencies(Fe),u.instantiateWasm)try{return u.instantiateWasm(j,A)}catch(U){return O("Module.instantiateWasm callback failed with error: "+U),!1}(S||typeof WebAssembly.instantiateStreaming!="function"||ve()||Ae.startsWith("file://")||T||typeof fetch!="function"?R(C):fetch(Ae,{credentials:"same-origin"}).then(function(U){return WebAssembly.instantiateStreaming(U,j).then(C,function(H){return O("wasm streaming compile failed: "+H),O("falling back to ArrayBuffer instantiation"),R(C)})})).catch(g)})(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.La).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.Ma).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.Na).apply(null,arguments)},u._OrtAppendExecutionProvider=function(){return(u._OrtAppendExecutionProvider=u.asm.Oa).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.Pa).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm.Qa).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.Ra).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.Sa).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.Ta).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.Ua).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.Va).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.Wa).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.Xa).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.Ya).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.Za).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm._a).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.$a).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.ab).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.bb).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.cb).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.db).apply(null,arguments)};var Ze,ye=u._malloc=function(){return(ye=u._malloc=u.asm.eb).apply(null,arguments)},ot=u._free=function(){return(ot=u._free=u.asm.fb).apply(null,arguments)},ft=u._fflush=function(){return(ft=u._fflush=u.asm.gb).apply(null,arguments)},st=u.___funcs_on_exit=function(){return(st=u.___funcs_on_exit=u.asm.hb).apply(null,arguments)},ae=u._setThrew=function(){return(ae=u._setThrew=u.asm.jb).apply(null,arguments)},oe=u.stackSave=function(){return(oe=u.stackSave=u.asm.kb).apply(null,arguments)},se=u.stackRestore=function(){return(se=u.stackRestore=u.asm.lb).apply(null,arguments)},gt=u.stackAlloc=function(){return(gt=u.stackAlloc=u.asm.mb).apply(null,arguments)},at=u.___cxa_can_catch=function(){return(at=u.___cxa_can_catch=u.asm.nb).apply(null,arguments)},mt=u.___cxa_is_pointer_type=function(){return(mt=u.___cxa_is_pointer_type=u.asm.ob).apply(null,arguments)},_t=u.dynCall_j=function(){return(_t=u.dynCall_j=u.asm.pb).apply(null,arguments)},bt=u.dynCall_iiiiij=function(){return(bt=u.dynCall_iiiiij=u.asm.qb).apply(null,arguments)},yt=u.dynCall_jii=function(){return(yt=u.dynCall_jii=u.asm.rb).apply(null,arguments)},wt=u.dynCall_viiiiij=function(){return(wt=u.dynCall_viiiiij=u.asm.sb).apply(null,arguments)},Tt=u.dynCall_vjji=function(){return(Tt=u.dynCall_vjji=u.asm.tb).apply(null,arguments)},vt=u.dynCall_viiijjjii=function(){return(vt=u.dynCall_viiijjjii=u.asm.ub).apply(null,arguments)},xt=u.dynCall_iij=function(){return(xt=u.dynCall_iij=u.asm.vb).apply(null,arguments)},St=u.dynCall_ji=function(){return(St=u.dynCall_ji=u.asm.wb).apply(null,arguments)},Et=u.dynCall_iiiiiij=function(){return(Et=u.dynCall_iiiiiij=u.asm.xb).apply(null,arguments)},Ot=u.dynCall_iiij=function(){return(Ot=u.dynCall_iiij=u.asm.yb).apply(null,arguments)};function Pt(){function A(){if(!Ze&&(Ze=!0,u.calledRun=!0,!k)){if(Ye(ue),p(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;){var C=u.postRun.shift();we.unshift(C)}Ye(we)}}if(!(0<Fe)){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)He();Ye(xe),0<Fe||(u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),A()},1)):A())}}if(u.UTF8ToString=Y,u.stringToUTF8=function(A,C,R){return ee(A,B,C,R)},u.lengthBytesUTF8=te,u.stackSave=oe,u.stackRestore=se,u.stackAlloc=gt,De=function A(){Ze||Pt(),Ze||(De=A)},u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);0<u.preInit.length;)u.preInit.pop()();return Pt(),f.ready});d.exports=l},4537:d=>{d.exports=function(n,o){for(var s=new Array(arguments.length-1),l=0,f=2,u=!0;f<arguments.length;)s[l++]=arguments[f++];return new Promise(function(p,g){s[l]=function(c){if(u)if(u=!1,c)g(c);else{for(var a=new Array(arguments.length-1),t=0;t<a.length;)a[t++]=arguments[t];p.apply(null,a)}};try{n.apply(o||null,s)}catch(c){u&&(u=!1,g(c))}})}},7419:(d,n)=>{var o=n;o.length=function(p){var g=p.length;if(!g)return 0;for(var c=0;--g%4>1&&p.charAt(g)==="=";)++c;return Math.ceil(3*p.length)/4-c};for(var s=new Array(64),l=new Array(123),f=0;f<64;)l[s[f]=f<26?f+65:f<52?f+71:f<62?f-4:f-59|43]=f++;o.encode=function(p,g,c){for(var a,t=null,e=[],r=0,i=0;g<c;){var h=p[g++];switch(i){case 0:e[r++]=s[h>>2],a=(3&h)<<4,i=1;break;case 1:e[r++]=s[a|h>>4],a=(15&h)<<2,i=2;break;case 2:e[r++]=s[a|h>>6],e[r++]=s[63&h],i=0}r>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,e)),r=0)}return i&&(e[r++]=s[a],e[r++]=61,i===1&&(e[r++]=61)),t?(r&&t.push(String.fromCharCode.apply(String,e.slice(0,r))),t.join("")):String.fromCharCode.apply(String,e.slice(0,r))};var u="invalid encoding";o.decode=function(p,g,c){for(var a,t=c,e=0,r=0;r<p.length;){var i=p.charCodeAt(r++);if(i===61&&e>1)break;if((i=l[i])===void 0)throw Error(u);switch(e){case 0:a=i,e=1;break;case 1:g[c++]=a<<2|(48&i)>>4,a=i,e=2;break;case 2:g[c++]=(15&a)<<4|(60&i)>>2,a=i,e=3;break;case 3:g[c++]=(3&a)<<6|i,e=0}}if(e===1)throw Error(u);return c-t},o.test=function(p){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(p)}},9211:d=>{function n(){this._listeners={}}d.exports=n,n.prototype.on=function(o,s,l){return(this._listeners[o]||(this._listeners[o]=[])).push({fn:s,ctx:l||this}),this},n.prototype.off=function(o,s){if(o===void 0)this._listeners={};else if(s===void 0)this._listeners[o]=[];else for(var l=this._listeners[o],f=0;f<l.length;)l[f].fn===s?l.splice(f,1):++f;return this},n.prototype.emit=function(o){var s=this._listeners[o];if(s){for(var l=[],f=1;f<arguments.length;)l.push(arguments[f++]);for(f=0;f<s.length;)s[f].fn.apply(s[f++].ctx,l)}return this}},945:d=>{function n(u){return typeof Float32Array<"u"?function(){var p=new Float32Array([-0]),g=new Uint8Array(p.buffer),c=g[3]===128;function a(i,h,m){p[0]=i,h[m]=g[0],h[m+1]=g[1],h[m+2]=g[2],h[m+3]=g[3]}function t(i,h,m){p[0]=i,h[m]=g[3],h[m+1]=g[2],h[m+2]=g[1],h[m+3]=g[0]}function e(i,h){return g[0]=i[h],g[1]=i[h+1],g[2]=i[h+2],g[3]=i[h+3],p[0]}function r(i,h){return g[3]=i[h],g[2]=i[h+1],g[1]=i[h+2],g[0]=i[h+3],p[0]}u.writeFloatLE=c?a:t,u.writeFloatBE=c?t:a,u.readFloatLE=c?e:r,u.readFloatBE=c?r:e}():function(){function p(c,a,t,e){var r=a<0?1:0;if(r&&(a=-a),a===0)c(1/a>0?0:2147483648,t,e);else if(isNaN(a))c(2143289344,t,e);else if(a>34028234663852886e22)c((r<<31|2139095040)>>>0,t,e);else if(a<11754943508222875e-54)c((r<<31|Math.round(a/1401298464324817e-60))>>>0,t,e);else{var i=Math.floor(Math.log(a)/Math.LN2);c((r<<31|i+127<<23|8388607&Math.round(a*Math.pow(2,-i)*8388608))>>>0,t,e)}}function g(c,a,t){var e=c(a,t),r=2*(e>>31)+1,i=e>>>23&255,h=8388607&e;return i===255?h?NaN:r*(1/0):i===0?1401298464324817e-60*r*h:r*Math.pow(2,i-150)*(h+8388608)}u.writeFloatLE=p.bind(null,o),u.writeFloatBE=p.bind(null,s),u.readFloatLE=g.bind(null,l),u.readFloatBE=g.bind(null,f)}(),typeof Float64Array<"u"?function(){var p=new Float64Array([-0]),g=new Uint8Array(p.buffer),c=g[7]===128;function a(i,h,m){p[0]=i,h[m]=g[0],h[m+1]=g[1],h[m+2]=g[2],h[m+3]=g[3],h[m+4]=g[4],h[m+5]=g[5],h[m+6]=g[6],h[m+7]=g[7]}function t(i,h,m){p[0]=i,h[m]=g[7],h[m+1]=g[6],h[m+2]=g[5],h[m+3]=g[4],h[m+4]=g[3],h[m+5]=g[2],h[m+6]=g[1],h[m+7]=g[0]}function e(i,h){return g[0]=i[h],g[1]=i[h+1],g[2]=i[h+2],g[3]=i[h+3],g[4]=i[h+4],g[5]=i[h+5],g[6]=i[h+6],g[7]=i[h+7],p[0]}function r(i,h){return g[7]=i[h],g[6]=i[h+1],g[5]=i[h+2],g[4]=i[h+3],g[3]=i[h+4],g[2]=i[h+5],g[1]=i[h+6],g[0]=i[h+7],p[0]}u.writeDoubleLE=c?a:t,u.writeDoubleBE=c?t:a,u.readDoubleLE=c?e:r,u.readDoubleBE=c?r:e}():function(){function p(c,a,t,e,r,i){var h=e<0?1:0;if(h&&(e=-e),e===0)c(0,r,i+a),c(1/e>0?0:2147483648,r,i+t);else if(isNaN(e))c(0,r,i+a),c(2146959360,r,i+t);else if(e>17976931348623157e292)c(0,r,i+a),c((h<<31|2146435072)>>>0,r,i+t);else{var m;if(e<22250738585072014e-324)c((m=e/5e-324)>>>0,r,i+a),c((h<<31|m/4294967296)>>>0,r,i+t);else{var _=Math.floor(Math.log(e)/Math.LN2);_===1024&&(_=1023),c(4503599627370496*(m=e*Math.pow(2,-_))>>>0,r,i+a),c((h<<31|_+1023<<20|1048576*m&1048575)>>>0,r,i+t)}}}function g(c,a,t,e,r){var i=c(e,r+a),h=c(e,r+t),m=2*(h>>31)+1,_=h>>>20&2047,b=4294967296*(1048575&h)+i;return _===2047?b?NaN:m*(1/0):_===0?5e-324*m*b:m*Math.pow(2,_-1075)*(b+4503599627370496)}u.writeDoubleLE=p.bind(null,o,0,4),u.writeDoubleBE=p.bind(null,s,4,0),u.readDoubleLE=g.bind(null,l,0,4),u.readDoubleBE=g.bind(null,f,4,0)}(),u}function o(u,p,g){p[g]=255&u,p[g+1]=u>>>8&255,p[g+2]=u>>>16&255,p[g+3]=u>>>24}function s(u,p,g){p[g]=u>>>24,p[g+1]=u>>>16&255,p[g+2]=u>>>8&255,p[g+3]=255&u}function l(u,p){return(u[p]|u[p+1]<<8|u[p+2]<<16|u[p+3]<<24)>>>0}function f(u,p){return(u[p]<<24|u[p+1]<<16|u[p+2]<<8|u[p+3])>>>0}d.exports=n(n)},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(n,o,s){var l=s||8192,f=l>>>1,u=null,p=l;return function(g){if(g<1||g>f)return n(g);p+g>l&&(u=n(l),p=0);var c=o.call(u,p,p+=g);return 7&p&&(p=1+(7|p)),c}}},4997:(d,n)=>{var o=n;o.length=function(s){for(var l=0,f=0,u=0;u<s.length;++u)(f=s.charCodeAt(u))<128?l+=1:f<2048?l+=2:(64512&f)==55296&&(64512&s.charCodeAt(u+1))==56320?(++u,l+=4):l+=3;return l},o.read=function(s,l,f){if(f-l<1)return"";for(var u,p=null,g=[],c=0;l<f;)(u=s[l++])<128?g[c++]=u:u>191&&u<224?g[c++]=(31&u)<<6|63&s[l++]:u>239&&u<365?(u=((7&u)<<18|(63&s[l++])<<12|(63&s[l++])<<6|63&s[l++])-65536,g[c++]=55296+(u>>10),g[c++]=56320+(1023&u)):g[c++]=(15&u)<<12|(63&s[l++])<<6|63&s[l++],c>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,g)),c=0);return p?(c&&p.push(String.fromCharCode.apply(String,g.slice(0,c))),p.join("")):String.fromCharCode.apply(String,g.slice(0,c))},o.write=function(s,l,f){for(var u,p,g=f,c=0;c<s.length;++c)(u=s.charCodeAt(c))<128?l[f++]=u:u<2048?(l[f++]=u>>6|192,l[f++]=63&u|128):(64512&u)==55296&&(64512&(p=s.charCodeAt(c+1)))==56320?(u=65536+((1023&u)<<10)+(1023&p),++c,l[f++]=u>>18|240,l[f++]=u>>12&63|128,l[f++]=u>>6&63|128,l[f++]=63&u|128):(l[f++]=u>>12|224,l[f++]=u>>6&63|128,l[f++]=63&u|128);return f-g}},3442:(d,n)=>{n.__esModule=!0;var o=function(){function s(l){if(!l)throw new TypeError("Invalid argument; `value` has no value.");this.value=s.EMPTY,l&&s.isGuid(l)&&(this.value=l)}return s.isGuid=function(l){var f=l.toString();return l&&(l instanceof s||s.validator.test(f))},s.create=function(){return new s([s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-"))},s.createEmpty=function(){return new s("emptyguid")},s.parse=function(l){return new s(l)},s.raw=function(){return[s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-")},s.gen=function(l){for(var f="",u=0;u<l;u++)f+=(65536*(1+Math.random())|0).toString(16).substring(1);return f},s.prototype.equals=function(l){return s.isGuid(l)&&this.value===l.toString()},s.prototype.isEmpty=function(){return this.value===s.EMPTY},s.prototype.toString=function(){return this.value},s.prototype.toJSON=function(){return{value:this.value}},s.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),s.EMPTY="00000000-0000-0000-0000-000000000000",s}();n.Guid=o},3720:d=>{d.exports=o;var n=null;try{n=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 o(v,M,$){this.low=0|v,this.high=0|M,this.unsigned=!!$}function s(v){return(v&&v.__isLong__)===!0}o.prototype.__isLong__,Object.defineProperty(o.prototype,"__isLong__",{value:!0}),o.isLong=s;var l={},f={};function u(v,M){var $,V,B;return M?(B=0<=(v>>>=0)&&v<256)&&(V=f[v])?V:($=g(v,(0|v)<0?-1:0,!0),B&&(f[v]=$),$):(B=-128<=(v|=0)&&v<128)&&(V=l[v])?V:($=g(v,v<0?-1:0,!1),B&&(l[v]=$),$)}function p(v,M){if(isNaN(v))return M?_:m;if(M){if(v<0)return _;if(v>=r)return S}else{if(v<=-i)return E;if(v+1>=i)return w}return v<0?p(-v,M).neg():g(v%e|0,v/e|0,M)}function g(v,M,$){return new o(v,M,$)}o.fromInt=u,o.fromNumber=p,o.fromBits=g;var c=Math.pow;function a(v,M,$){if(v.length===0)throw Error("empty string");if(v==="NaN"||v==="Infinity"||v==="+Infinity"||v==="-Infinity")return m;if(typeof M=="number"?($=M,M=!1):M=!!M,($=$||10)<2||36<$)throw RangeError("radix");var V;if((V=v.indexOf("-"))>0)throw Error("interior hyphen");if(V===0)return a(v.substring(1),M,$).neg();for(var B=p(c($,8)),L=m,D=0;D<v.length;D+=8){var k=Math.min(8,v.length-D),F=parseInt(v.substring(D,D+k),$);if(k<8){var Q=p(c($,k));L=L.mul(Q).add(p(F))}else L=(L=L.mul(B)).add(p(F))}return L.unsigned=M,L}function t(v,M){return typeof v=="number"?p(v,M):typeof v=="string"?a(v,M):g(v.low,v.high,typeof M=="boolean"?M:v.unsigned)}o.fromString=a,o.fromValue=t;var e=4294967296,r=e*e,i=r/2,h=u(1<<24),m=u(0);o.ZERO=m;var _=u(0,!0);o.UZERO=_;var b=u(1);o.ONE=b;var y=u(1,!0);o.UONE=y;var T=u(-1);o.NEG_ONE=T;var w=g(-1,2147483647,!1);o.MAX_VALUE=w;var S=g(-1,-1,!0);o.MAX_UNSIGNED_VALUE=S;var E=g(0,-2147483648,!1);o.MIN_VALUE=E;var O=o.prototype;O.toInt=function(){return this.unsigned?this.low>>>0:this.low},O.toNumber=function(){return this.unsigned?(this.high>>>0)*e+(this.low>>>0):this.high*e+(this.low>>>0)},O.toString=function(v){if((v=v||10)<2||36<v)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(E)){var M=p(v),$=this.div(M),V=$.mul(M).sub(this);return $.toString(v)+V.toInt().toString(v)}return"-"+this.neg().toString(v)}for(var B=p(c(v,6),this.unsigned),L=this,D="";;){var k=L.div(B),F=(L.sub(k.mul(B)).toInt()>>>0).toString(v);if((L=k).isZero())return F+D;for(;F.length<6;)F="0"+F;D=""+F+D}},O.getHighBits=function(){return this.high},O.getHighBitsUnsigned=function(){return this.high>>>0},O.getLowBits=function(){return this.low},O.getLowBitsUnsigned=function(){return this.low>>>0},O.getNumBitsAbs=function(){if(this.isNegative())return this.eq(E)?64:this.neg().getNumBitsAbs();for(var v=this.high!=0?this.high:this.low,M=31;M>0&&!(v&1<<M);M--);return this.high!=0?M+33:M+1},O.isZero=function(){return this.high===0&&this.low===0},O.eqz=O.isZero,O.isNegative=function(){return!this.unsigned&&this.high<0},O.isPositive=function(){return this.unsigned||this.high>=0},O.isOdd=function(){return(1&this.low)==1},O.isEven=function(){return(1&this.low)==0},O.equals=function(v){return s(v)||(v=t(v)),(this.unsigned===v.unsigned||this.high>>>31!=1||v.high>>>31!=1)&&this.high===v.high&&this.low===v.low},O.eq=O.equals,O.notEquals=function(v){return!this.eq(v)},O.neq=O.notEquals,O.ne=O.notEquals,O.lessThan=function(v){return this.comp(v)<0},O.lt=O.lessThan,O.lessThanOrEqual=function(v){return this.comp(v)<=0},O.lte=O.lessThanOrEqual,O.le=O.lessThanOrEqual,O.greaterThan=function(v){return this.comp(v)>0},O.gt=O.greaterThan,O.greaterThanOrEqual=function(v){return this.comp(v)>=0},O.gte=O.greaterThanOrEqual,O.ge=O.greaterThanOrEqual,O.compare=function(v){if(s(v)||(v=t(v)),this.eq(v))return 0;var M=this.isNegative(),$=v.isNegative();return M&&!$?-1:!M&&$?1:this.unsigned?v.high>>>0>this.high>>>0||v.high===this.high&&v.low>>>0>this.low>>>0?-1:1:this.sub(v).isNegative()?-1:1},O.comp=O.compare,O.negate=function(){return!this.unsigned&&this.eq(E)?E:this.not().add(b)},O.neg=O.negate,O.add=function(v){s(v)||(v=t(v));var M=this.high>>>16,$=65535&this.high,V=this.low>>>16,B=65535&this.low,L=v.high>>>16,D=65535&v.high,k=v.low>>>16,F=0,Q=0,Y=0,ee=0;return Y+=(ee+=B+(65535&v.low))>>>16,Q+=(Y+=V+k)>>>16,F+=(Q+=$+D)>>>16,F+=M+L,g((Y&=65535)<<16|(ee&=65535),(F&=65535)<<16|(Q&=65535),this.unsigned)},O.subtract=function(v){return s(v)||(v=t(v)),this.add(v.neg())},O.sub=O.subtract,O.multiply=function(v){if(this.isZero())return m;if(s(v)||(v=t(v)),n)return g(n.mul(this.low,this.high,v.low,v.high),n.get_high(),this.unsigned);if(v.isZero())return m;if(this.eq(E))return v.isOdd()?E:m;if(v.eq(E))return this.isOdd()?E:m;if(this.isNegative())return v.isNegative()?this.neg().mul(v.neg()):this.neg().mul(v).neg();if(v.isNegative())return this.mul(v.neg()).neg();if(this.lt(h)&&v.lt(h))return p(this.toNumber()*v.toNumber(),this.unsigned);var M=this.high>>>16,$=65535&this.high,V=this.low>>>16,B=65535&this.low,L=v.high>>>16,D=65535&v.high,k=v.low>>>16,F=65535&v.low,Q=0,Y=0,ee=0,te=0;return ee+=(te+=B*F)>>>16,Y+=(ee+=V*F)>>>16,ee&=65535,Y+=(ee+=B*k)>>>16,Q+=(Y+=$*F)>>>16,Y&=65535,Q+=(Y+=V*k)>>>16,Y&=65535,Q+=(Y+=B*D)>>>16,Q+=M*F+$*k+V*D+B*L,g((ee&=65535)<<16|(te&=65535),(Q&=65535)<<16|(Y&=65535),this.unsigned)},O.mul=O.multiply,O.divide=function(v){if(s(v)||(v=t(v)),v.isZero())throw Error("division by zero");var M,$,V;if(n)return this.unsigned||this.high!==-2147483648||v.low!==-1||v.high!==-1?g((this.unsigned?n.div_u:n.div_s)(this.low,this.high,v.low,v.high),n.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?_:m;if(this.unsigned){if(v.unsigned||(v=v.toUnsigned()),v.gt(this))return _;if(v.gt(this.shru(1)))return y;V=_}else{if(this.eq(E))return v.eq(b)||v.eq(T)?E:v.eq(E)?b:(M=this.shr(1).div(v).shl(1)).eq(m)?v.isNegative()?b:T:($=this.sub(v.mul(M)),V=M.add($.div(v)));if(v.eq(E))return this.unsigned?_:m;if(this.isNegative())return v.isNegative()?this.neg().div(v.neg()):this.neg().div(v).neg();if(v.isNegative())return this.div(v.neg()).neg();V=m}for($=this;$.gte(v);){M=Math.max(1,Math.floor($.toNumber()/v.toNumber()));for(var B=Math.ceil(Math.log(M)/Math.LN2),L=B<=48?1:c(2,B-48),D=p(M),k=D.mul(v);k.isNegative()||k.gt($);)k=(D=p(M-=L,this.unsigned)).mul(v);D.isZero()&&(D=b),V=V.add(D),$=$.sub(k)}return V},O.div=O.divide,O.modulo=function(v){return s(v)||(v=t(v)),n?g((this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,v.low,v.high),n.get_high(),this.unsigned):this.sub(this.div(v).mul(v))},O.mod=O.modulo,O.rem=O.modulo,O.not=function(){return g(~this.low,~this.high,this.unsigned)},O.and=function(v){return s(v)||(v=t(v)),g(this.low&v.low,this.high&v.high,this.unsigned)},O.or=function(v){return s(v)||(v=t(v)),g(this.low|v.low,this.high|v.high,this.unsigned)},O.xor=function(v){return s(v)||(v=t(v)),g(this.low^v.low,this.high^v.high,this.unsigned)},O.shiftLeft=function(v){return s(v)&&(v=v.toInt()),(v&=63)==0?this:v<32?g(this.low<<v,this.high<<v|this.low>>>32-v,this.unsigned):g(0,this.low<<v-32,this.unsigned)},O.shl=O.shiftLeft,O.shiftRight=function(v){return s(v)&&(v=v.toInt()),(v&=63)==0?this:v<32?g(this.low>>>v|this.high<<32-v,this.high>>v,this.unsigned):g(this.high>>v-32,this.high>=0?0:-1,this.unsigned)},O.shr=O.shiftRight,O.shiftRightUnsigned=function(v){if(s(v)&&(v=v.toInt()),(v&=63)==0)return this;var M=this.high;return v<32?g(this.low>>>v|M<<32-v,M>>>v,this.unsigned):g(v===32?M:M>>>v-32,0,this.unsigned)},O.shru=O.shiftRightUnsigned,O.shr_u=O.shiftRightUnsigned,O.toSigned=function(){return this.unsigned?g(this.low,this.high,!1):this},O.toUnsigned=function(){return this.unsigned?this:g(this.low,this.high,!0)},O.toBytes=function(v){return v?this.toBytesLE():this.toBytesBE()},O.toBytesLE=function(){var v=this.high,M=this.low;return[255&M,M>>>8&255,M>>>16&255,M>>>24,255&v,v>>>8&255,v>>>16&255,v>>>24]},O.toBytesBE=function(){var v=this.high,M=this.low;return[v>>>24,v>>>16&255,v>>>8&255,255&v,M>>>24,M>>>16&255,M>>>8&255,255&M]},o.fromBytes=function(v,M,$){return $?o.fromBytesLE(v,M):o.fromBytesBE(v,M)},o.fromBytesLE=function(v,M){return new o(v[0]|v[1]<<8|v[2]<<16|v[3]<<24,v[4]|v[5]<<8|v[6]<<16|v[7]<<24,M)},o.fromBytesBE=function(v,M){return new o(v[4]<<24|v[5]<<16|v[6]<<8|v[7],v[0]<<24|v[1]<<16|v[2]<<8|v[3],M)}},1446:(d,n,o)=>{var s,l,f,u=o(2100),p=u.Reader,g=u.Writer,c=u.util,a=u.roots.default||(u.roots.default={});a.onnx=((f={}).Version=(s={},(l=Object.create(s))[s[0]="_START_VERSION"]=0,l[s[1]="IR_VERSION_2017_10_10"]=1,l[s[2]="IR_VERSION_2017_10_30"]=2,l[s[3]="IR_VERSION_2017_11_3"]=3,l[s[4]="IR_VERSION_2019_1_22"]=4,l[s[5]="IR_VERSION"]=5,l),f.AttributeProto=function(){function t(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.name="",t.prototype.refAttrName="",t.prototype.docString="",t.prototype.type=0,t.prototype.f=0,t.prototype.i=c.Long?c.Long.fromBits(0,0,!1):0,t.prototype.s=c.newBuffer([]),t.prototype.t=null,t.prototype.g=null,t.prototype.floats=c.emptyArray,t.prototype.ints=c.emptyArray,t.prototype.strings=c.emptyArray,t.prototype.tensors=c.emptyArray,t.prototype.graphs=c.emptyArray,t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.name!=null&&e.hasOwnProperty("name")&&r.uint32(10).string(e.name),e.f!=null&&e.hasOwnProperty("f")&&r.uint32(21).float(e.f),e.i!=null&&e.hasOwnProperty("i")&&r.uint32(24).int64(e.i),e.s!=null&&e.hasOwnProperty("s")&&r.uint32(34).bytes(e.s),e.t!=null&&e.hasOwnProperty("t")&&a.onnx.TensorProto.encode(e.t,r.uint32(42).fork()).ldelim(),e.g!=null&&e.hasOwnProperty("g")&&a.onnx.GraphProto.encode(e.g,r.uint32(50).fork()).ldelim(),e.floats!=null&&e.floats.length){r.uint32(58).fork();for(var i=0;i<e.floats.length;++i)r.float(e.floats[i]);r.ldelim()}if(e.ints!=null&&e.ints.length){for(r.uint32(66).fork(),i=0;i<e.ints.length;++i)r.int64(e.ints[i]);r.ldelim()}if(e.strings!=null&&e.strings.length)for(i=0;i<e.strings.length;++i)r.uint32(74).bytes(e.strings[i]);if(e.tensors!=null&&e.tensors.length)for(i=0;i<e.tensors.length;++i)a.onnx.TensorProto.encode(e.tensors[i],r.uint32(82).fork()).ldelim();if(e.graphs!=null&&e.graphs.length)for(i=0;i<e.graphs.length;++i)a.onnx.GraphProto.encode(e.graphs[i],r.uint32(90).fork()).ldelim();return e.docString!=null&&e.hasOwnProperty("docString")&&r.uint32(106).string(e.docString),e.type!=null&&e.hasOwnProperty("type")&&r.uint32(160).int32(e.type),e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&r.uint32(170).string(e.refAttrName),r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.AttributeProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.name=e.string();break;case 21:h.refAttrName=e.string();break;case 13:h.docString=e.string();break;case 20:h.type=e.int32();break;case 2:h.f=e.float();break;case 3:h.i=e.int64();break;case 4:h.s=e.bytes();break;case 5:h.t=a.onnx.TensorProto.decode(e,e.uint32());break;case 6:h.g=a.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(h.floats&&h.floats.length||(h.floats=[]),(7&m)==2)for(var _=e.uint32()+e.pos;e.pos<_;)h.floats.push(e.float());else h.floats.push(e.float());break;case 8:if(h.ints&&h.ints.length||(h.ints=[]),(7&m)==2)for(_=e.uint32()+e.pos;e.pos<_;)h.ints.push(e.int64());else h.ints.push(e.int64());break;case 9:h.strings&&h.strings.length||(h.strings=[]),h.strings.push(e.bytes());break;case 10:h.tensors&&h.tensors.length||(h.tensors=[]),h.tensors.push(a.onnx.TensorProto.decode(e,e.uint32()));break;case 11:h.graphs&&h.graphs.length||(h.graphs=[]),h.graphs.push(a.onnx.GraphProto.decode(e,e.uint32()));break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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")&&!c.isString(e.name))return"name: string expected";if(e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&!c.isString(e.refAttrName))return"refAttrName: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString))return"docString: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:}if(e.f!=null&&e.hasOwnProperty("f")&&typeof e.f!="number")return"f: number expected";if(e.i!=null&&e.hasOwnProperty("i")&&!(c.isInteger(e.i)||e.i&&c.isInteger(e.i.low)&&c.isInteger(e.i.high)))return"i: integer|Long expected";if(e.s!=null&&e.hasOwnProperty("s")&&!(e.s&&typeof e.s.length=="number"||c.isString(e.s)))return"s: buffer expected";if(e.t!=null&&e.hasOwnProperty("t")&&(i=a.onnx.TensorProto.verify(e.t)))return"t."+i;if(e.g!=null&&e.hasOwnProperty("g")&&(i=a.onnx.GraphProto.verify(e.g)))return"g."+i;if(e.floats!=null&&e.hasOwnProperty("floats")){if(!Array.isArray(e.floats))return"floats: array expected";for(var r=0;r<e.floats.length;++r)if(typeof e.floats[r]!="number")return"floats: number[] expected"}if(e.ints!=null&&e.hasOwnProperty("ints")){if(!Array.isArray(e.ints))return"ints: array expected";for(r=0;r<e.ints.length;++r)if(!(c.isInteger(e.ints[r])||e.ints[r]&&c.isInteger(e.ints[r].low)&&c.isInteger(e.ints[r].high)))return"ints: integer|Long[] expected"}if(e.strings!=null&&e.hasOwnProperty("strings")){if(!Array.isArray(e.strings))return"strings: array expected";for(r=0;r<e.strings.length;++r)if(!(e.strings[r]&&typeof e.strings[r].length=="number"||c.isString(e.strings[r])))return"strings: buffer[] expected"}if(e.tensors!=null&&e.hasOwnProperty("tensors")){if(!Array.isArray(e.tensors))return"tensors: array expected";for(r=0;r<e.tensors.length;++r)if(i=a.onnx.TensorProto.verify(e.tensors[r]))return"tensors."+i}if(e.graphs!=null&&e.hasOwnProperty("graphs")){if(!Array.isArray(e.graphs))return"graphs: array expected";for(r=0;r<e.graphs.length;++r){var i;if(i=a.onnx.GraphProto.verify(e.graphs[r]))return"graphs."+i}}return null},t.fromObject=function(e){if(e instanceof a.onnx.AttributeProto)return e;var r=new a.onnx.AttributeProto;switch(e.name!=null&&(r.name=String(e.name)),e.refAttrName!=null&&(r.refAttrName=String(e.refAttrName)),e.docString!=null&&(r.docString=String(e.docString)),e.type){case"UNDEFINED":case 0:r.type=0;break;case"FLOAT":case 1:r.type=1;break;case"INT":case 2:r.type=2;break;case"STRING":case 3:r.type=3;break;case"TENSOR":case 4:r.type=4;break;case"GRAPH":case 5:r.type=5;break;case"FLOATS":case 6:r.type=6;break;case"INTS":case 7:r.type=7;break;case"STRINGS":case 8:r.type=8;break;case"TENSORS":case 9:r.type=9;break;case"GRAPHS":case 10:r.type=10}if(e.f!=null&&(r.f=Number(e.f)),e.i!=null&&(c.Long?(r.i=c.Long.fromValue(e.i)).unsigned=!1:typeof e.i=="string"?r.i=parseInt(e.i,10):typeof e.i=="number"?r.i=e.i:typeof e.i=="object"&&(r.i=new c.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?c.base64.decode(e.s,r.s=c.newBuffer(c.base64.length(e.s)),0):e.s.length&&(r.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");r.t=a.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");r.g=a.onnx.GraphProto.fromObject(e.g)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");r.floats=[];for(var i=0;i<e.floats.length;++i)r.floats[i]=Number(e.floats[i])}if(e.ints){if(!Array.isArray(e.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");for(r.ints=[],i=0;i<e.ints.length;++i)c.Long?(r.ints[i]=c.Long.fromValue(e.ints[i])).unsigned=!1:typeof e.ints[i]=="string"?r.ints[i]=parseInt(e.ints[i],10):typeof e.ints[i]=="number"?r.ints[i]=e.ints[i]:typeof e.ints[i]=="object"&&(r.ints[i]=new c.LongBits(e.ints[i].low>>>0,e.ints[i].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(r.strings=[],i=0;i<e.strings.length;++i)typeof e.strings[i]=="string"?c.base64.decode(e.strings[i],r.strings[i]=c.newBuffer(c.base64.length(e.strings[i])),0):e.strings[i].length&&(r.strings[i]=e.strings[i])}if(e.tensors){if(!Array.isArray(e.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");for(r.tensors=[],i=0;i<e.tensors.length;++i){if(typeof e.tensors[i]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");r.tensors[i]=a.onnx.TensorProto.fromObject(e.tensors[i])}}if(e.graphs){if(!Array.isArray(e.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");for(r.graphs=[],i=0;i<e.graphs.length;++i){if(typeof e.graphs[i]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");r.graphs[i]=a.onnx.GraphProto.fromObject(e.graphs[i])}}return r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.floats=[],i.ints=[],i.strings=[],i.tensors=[],i.graphs=[]),r.defaults){if(i.name="",i.f=0,c.Long){var h=new c.Long(0,0,!1);i.i=r.longs===String?h.toString():r.longs===Number?h.toNumber():h}else i.i=r.longs===String?"0":0;r.bytes===String?i.s="":(i.s=[],r.bytes!==Array&&(i.s=c.newBuffer(i.s))),i.t=null,i.g=null,i.docString="",i.type=r.enums===String?"UNDEFINED":0,i.refAttrName=""}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.f!=null&&e.hasOwnProperty("f")&&(i.f=r.json&&!isFinite(e.f)?String(e.f):e.f),e.i!=null&&e.hasOwnProperty("i")&&(typeof e.i=="number"?i.i=r.longs===String?String(e.i):e.i:i.i=r.longs===String?c.Long.prototype.toString.call(e.i):r.longs===Number?new c.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(i.s=r.bytes===String?c.base64.encode(e.s,0,e.s.length):r.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(i.t=a.onnx.TensorProto.toObject(e.t,r)),e.g!=null&&e.hasOwnProperty("g")&&(i.g=a.onnx.GraphProto.toObject(e.g,r)),e.floats&&e.floats.length){i.floats=[];for(var m=0;m<e.floats.length;++m)i.floats[m]=r.json&&!isFinite(e.floats[m])?String(e.floats[m]):e.floats[m]}if(e.ints&&e.ints.length)for(i.ints=[],m=0;m<e.ints.length;++m)typeof e.ints[m]=="number"?i.ints[m]=r.longs===String?String(e.ints[m]):e.ints[m]:i.ints[m]=r.longs===String?c.Long.prototype.toString.call(e.ints[m]):r.longs===Number?new c.LongBits(e.ints[m].low>>>0,e.ints[m].high>>>0).toNumber():e.ints[m];if(e.strings&&e.strings.length)for(i.strings=[],m=0;m<e.strings.length;++m)i.strings[m]=r.bytes===String?c.base64.encode(e.strings[m],0,e.strings[m].length):r.bytes===Array?Array.prototype.slice.call(e.strings[m]):e.strings[m];if(e.tensors&&e.tensors.length)for(i.tensors=[],m=0;m<e.tensors.length;++m)i.tensors[m]=a.onnx.TensorProto.toObject(e.tensors[m],r);if(e.graphs&&e.graphs.length)for(i.graphs=[],m=0;m<e.graphs.length;++m)i.graphs[m]=a.onnx.GraphProto.toObject(e.graphs[m],r);return e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.type!=null&&e.hasOwnProperty("type")&&(i.type=r.enums===String?a.onnx.AttributeProto.AttributeType[e.type]:e.type),e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&(i.refAttrName=e.refAttrName),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t.AttributeType=function(){var e={},r=Object.create(e);return r[e[0]="UNDEFINED"]=0,r[e[1]="FLOAT"]=1,r[e[2]="INT"]=2,r[e[3]="STRING"]=3,r[e[4]="TENSOR"]=4,r[e[5]="GRAPH"]=5,r[e[6]="FLOATS"]=6,r[e[7]="INTS"]=7,r[e[8]="STRINGS"]=8,r[e[9]="TENSORS"]=9,r[e[10]="GRAPHS"]=10,r}(),t}(),f.ValueInfoProto=function(){function t(e){if(e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.name="",t.prototype.type=null,t.prototype.docString="",t.create=function(e){return new t(e)},t.encode=function(e,r){return r||(r=g.create()),e.name!=null&&e.hasOwnProperty("name")&&r.uint32(10).string(e.name),e.type!=null&&e.hasOwnProperty("type")&&a.onnx.TypeProto.encode(e.type,r.uint32(18).fork()).ldelim(),e.docString!=null&&e.hasOwnProperty("docString")&&r.uint32(26).string(e.docString),r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.ValueInfoProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.name=e.string();break;case 2:h.type=a.onnx.TypeProto.decode(e,e.uint32());break;case 3:h.docString=e.string();break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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")&&!c.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var r=a.onnx.TypeProto.verify(e.type);if(r)return"type."+r}return e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString)?"docString: string expected":null},t.fromObject=function(e){if(e instanceof a.onnx.ValueInfoProto)return e;var r=new a.onnx.ValueInfoProto;if(e.name!=null&&(r.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");r.type=a.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(r.docString=String(e.docString)),r},t.toObject=function(e,r){r||(r={});var i={};return r.defaults&&(i.name="",i.type=null,i.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(i.type=a.onnx.TypeProto.toObject(e.type,r)),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f.NodeProto=function(){function t(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.input=c.emptyArray,t.prototype.output=c.emptyArray,t.prototype.name="",t.prototype.opType="",t.prototype.domain="",t.prototype.attribute=c.emptyArray,t.prototype.docString="",t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.input!=null&&e.input.length)for(var i=0;i<e.input.length;++i)r.uint32(10).string(e.input[i]);if(e.output!=null&&e.output.length)for(i=0;i<e.output.length;++i)r.uint32(18).string(e.output[i]);if(e.name!=null&&e.hasOwnProperty("name")&&r.uint32(26).string(e.name),e.opType!=null&&e.hasOwnProperty("opType")&&r.uint32(34).string(e.opType),e.attribute!=null&&e.attribute.length)for(i=0;i<e.attribute.length;++i)a.onnx.AttributeProto.encode(e.attribute[i],r.uint32(42).fork()).ldelim();return e.docString!=null&&e.hasOwnProperty("docString")&&r.uint32(50).string(e.docString),e.domain!=null&&e.hasOwnProperty("domain")&&r.uint32(58).string(e.domain),r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.NodeProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.input&&h.input.length||(h.input=[]),h.input.push(e.string());break;case 2:h.output&&h.output.length||(h.output=[]),h.output.push(e.string());break;case 3:h.name=e.string();break;case 4:h.opType=e.string();break;case 7:h.domain=e.string();break;case 5:h.attribute&&h.attribute.length||(h.attribute=[]),h.attribute.push(a.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:h.docString=e.string();break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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 r=0;r<e.input.length;++r)if(!c.isString(e.input[r]))return"input: string[] expected"}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(r=0;r<e.output.length;++r)if(!c.isString(e.output[r]))return"output: string[] expected"}if(e.name!=null&&e.hasOwnProperty("name")&&!c.isString(e.name))return"name: string expected";if(e.opType!=null&&e.hasOwnProperty("opType")&&!c.isString(e.opType))return"opType: string expected";if(e.domain!=null&&e.hasOwnProperty("domain")&&!c.isString(e.domain))return"domain: string expected";if(e.attribute!=null&&e.hasOwnProperty("attribute")){if(!Array.isArray(e.attribute))return"attribute: array expected";for(r=0;r<e.attribute.length;++r){var i=a.onnx.AttributeProto.verify(e.attribute[r]);if(i)return"attribute."+i}}return e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString)?"docString: string expected":null},t.fromObject=function(e){if(e instanceof a.onnx.NodeProto)return e;var r=new a.onnx.NodeProto;if(e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.NodeProto.input: array expected");r.input=[];for(var i=0;i<e.input.length;++i)r.input[i]=String(e.input[i])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.NodeProto.output: array expected");for(r.output=[],i=0;i<e.output.length;++i)r.output[i]=String(e.output[i])}if(e.name!=null&&(r.name=String(e.name)),e.opType!=null&&(r.opType=String(e.opType)),e.domain!=null&&(r.domain=String(e.domain)),e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");for(r.attribute=[],i=0;i<e.attribute.length;++i){if(typeof e.attribute[i]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");r.attribute[i]=a.onnx.AttributeProto.fromObject(e.attribute[i])}}return e.docString!=null&&(r.docString=String(e.docString)),r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.input=[],i.output=[],i.attribute=[]),r.defaults&&(i.name="",i.opType="",i.docString="",i.domain=""),e.input&&e.input.length){i.input=[];for(var h=0;h<e.input.length;++h)i.input[h]=e.input[h]}if(e.output&&e.output.length)for(i.output=[],h=0;h<e.output.length;++h)i.output[h]=e.output[h];if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.opType!=null&&e.hasOwnProperty("opType")&&(i.opType=e.opType),e.attribute&&e.attribute.length)for(i.attribute=[],h=0;h<e.attribute.length;++h)i.attribute[h]=a.onnx.AttributeProto.toObject(e.attribute[h],r);return e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f.ModelProto=function(){function t(e){if(this.opsetImport=[],this.metadataProps=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.irVersion=c.Long?c.Long.fromBits(0,0,!1):0,t.prototype.opsetImport=c.emptyArray,t.prototype.producerName="",t.prototype.producerVersion="",t.prototype.domain="",t.prototype.modelVersion=c.Long?c.Long.fromBits(0,0,!1):0,t.prototype.docString="",t.prototype.graph=null,t.prototype.metadataProps=c.emptyArray,t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.irVersion!=null&&e.hasOwnProperty("irVersion")&&r.uint32(8).int64(e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&r.uint32(18).string(e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&r.uint32(26).string(e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&r.uint32(34).string(e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&r.uint32(40).int64(e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&r.uint32(50).string(e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&a.onnx.GraphProto.encode(e.graph,r.uint32(58).fork()).ldelim(),e.opsetImport!=null&&e.opsetImport.length)for(var i=0;i<e.opsetImport.length;++i)a.onnx.OperatorSetIdProto.encode(e.opsetImport[i],r.uint32(66).fork()).ldelim();if(e.metadataProps!=null&&e.metadataProps.length)for(i=0;i<e.metadataProps.length;++i)a.onnx.StringStringEntryProto.encode(e.metadataProps[i],r.uint32(114).fork()).ldelim();return r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.ModelProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.irVersion=e.int64();break;case 8:h.opsetImport&&h.opsetImport.length||(h.opsetImport=[]),h.opsetImport.push(a.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:h.producerName=e.string();break;case 3:h.producerVersion=e.string();break;case 4:h.domain=e.string();break;case 5:h.modelVersion=e.int64();break;case 6:h.docString=e.string();break;case 7:h.graph=a.onnx.GraphProto.decode(e,e.uint32());break;case 14:h.metadataProps&&h.metadataProps.length||(h.metadataProps=[]),h.metadataProps.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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")&&!(c.isInteger(e.irVersion)||e.irVersion&&c.isInteger(e.irVersion.low)&&c.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 r=0;r<e.opsetImport.length;++r)if(i=a.onnx.OperatorSetIdProto.verify(e.opsetImport[r]))return"opsetImport."+i}if(e.producerName!=null&&e.hasOwnProperty("producerName")&&!c.isString(e.producerName))return"producerName: string expected";if(e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&!c.isString(e.producerVersion))return"producerVersion: string expected";if(e.domain!=null&&e.hasOwnProperty("domain")&&!c.isString(e.domain))return"domain: string expected";if(e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&!(c.isInteger(e.modelVersion)||e.modelVersion&&c.isInteger(e.modelVersion.low)&&c.isInteger(e.modelVersion.high)))return"modelVersion: integer|Long expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString))return"docString: string expected";if(e.graph!=null&&e.hasOwnProperty("graph")&&(i=a.onnx.GraphProto.verify(e.graph)))return"graph."+i;if(e.metadataProps!=null&&e.hasOwnProperty("metadataProps")){if(!Array.isArray(e.metadataProps))return"metadataProps: array expected";for(r=0;r<e.metadataProps.length;++r){var i;if(i=a.onnx.StringStringEntryProto.verify(e.metadataProps[r]))return"metadataProps."+i}}return null},t.fromObject=function(e){if(e instanceof a.onnx.ModelProto)return e;var r=new a.onnx.ModelProto;if(e.irVersion!=null&&(c.Long?(r.irVersion=c.Long.fromValue(e.irVersion)).unsigned=!1:typeof e.irVersion=="string"?r.irVersion=parseInt(e.irVersion,10):typeof e.irVersion=="number"?r.irVersion=e.irVersion:typeof e.irVersion=="object"&&(r.irVersion=new c.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");r.opsetImport=[];for(var i=0;i<e.opsetImport.length;++i){if(typeof e.opsetImport[i]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");r.opsetImport[i]=a.onnx.OperatorSetIdProto.fromObject(e.opsetImport[i])}}if(e.producerName!=null&&(r.producerName=String(e.producerName)),e.producerVersion!=null&&(r.producerVersion=String(e.producerVersion)),e.domain!=null&&(r.domain=String(e.domain)),e.modelVersion!=null&&(c.Long?(r.modelVersion=c.Long.fromValue(e.modelVersion)).unsigned=!1:typeof e.modelVersion=="string"?r.modelVersion=parseInt(e.modelVersion,10):typeof e.modelVersion=="number"?r.modelVersion=e.modelVersion:typeof e.modelVersion=="object"&&(r.modelVersion=new c.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(r.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");r.graph=a.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(r.metadataProps=[],i=0;i<e.metadataProps.length;++i){if(typeof e.metadataProps[i]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");r.metadataProps[i]=a.onnx.StringStringEntryProto.fromObject(e.metadataProps[i])}}return r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.opsetImport=[],i.metadataProps=[]),r.defaults){if(c.Long){var h=new c.Long(0,0,!1);i.irVersion=r.longs===String?h.toString():r.longs===Number?h.toNumber():h}else i.irVersion=r.longs===String?"0":0;i.producerName="",i.producerVersion="",i.domain="",c.Long?(h=new c.Long(0,0,!1),i.modelVersion=r.longs===String?h.toString():r.longs===Number?h.toNumber():h):i.modelVersion=r.longs===String?"0":0,i.docString="",i.graph=null}if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&(typeof e.irVersion=="number"?i.irVersion=r.longs===String?String(e.irVersion):e.irVersion:i.irVersion=r.longs===String?c.Long.prototype.toString.call(e.irVersion):r.longs===Number?new c.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(i.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(i.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?i.modelVersion=r.longs===String?String(e.modelVersion):e.modelVersion:i.modelVersion=r.longs===String?c.Long.prototype.toString.call(e.modelVersion):r.longs===Number?new c.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(i.graph=a.onnx.GraphProto.toObject(e.graph,r)),e.opsetImport&&e.opsetImport.length){i.opsetImport=[];for(var m=0;m<e.opsetImport.length;++m)i.opsetImport[m]=a.onnx.OperatorSetIdProto.toObject(e.opsetImport[m],r)}if(e.metadataProps&&e.metadataProps.length)for(i.metadataProps=[],m=0;m<e.metadataProps.length;++m)i.metadataProps[m]=a.onnx.StringStringEntryProto.toObject(e.metadataProps[m],r);return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f.StringStringEntryProto=function(){function t(e){if(e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.key="",t.prototype.value="",t.create=function(e){return new t(e)},t.encode=function(e,r){return r||(r=g.create()),e.key!=null&&e.hasOwnProperty("key")&&r.uint32(10).string(e.key),e.value!=null&&e.hasOwnProperty("value")&&r.uint32(18).string(e.value),r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.StringStringEntryProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.key=e.string();break;case 2:h.value=e.string();break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!c.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!c.isString(e.value)?"value: string expected":null},t.fromObject=function(e){if(e instanceof a.onnx.StringStringEntryProto)return e;var r=new a.onnx.StringStringEntryProto;return e.key!=null&&(r.key=String(e.key)),e.value!=null&&(r.value=String(e.value)),r},t.toObject=function(e,r){r||(r={});var i={};return r.defaults&&(i.key="",i.value=""),e.key!=null&&e.hasOwnProperty("key")&&(i.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(i.value=e.value),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f.TensorAnnotation=function(){function t(e){if(this.quantParameterTensorNames=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.tensorName="",t.prototype.quantParameterTensorNames=c.emptyArray,t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.tensorName!=null&&e.hasOwnProperty("tensorName")&&r.uint32(10).string(e.tensorName),e.quantParameterTensorNames!=null&&e.quantParameterTensorNames.length)for(var i=0;i<e.quantParameterTensorNames.length;++i)a.onnx.StringStringEntryProto.encode(e.quantParameterTensorNames[i],r.uint32(18).fork()).ldelim();return r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.TensorAnnotation;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.tensorName=e.string();break;case 2:h.quantParameterTensorNames&&h.quantParameterTensorNames.length||(h.quantParameterTensorNames=[]),h.quantParameterTensorNames.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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")&&!c.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 r=0;r<e.quantParameterTensorNames.length;++r){var i=a.onnx.StringStringEntryProto.verify(e.quantParameterTensorNames[r]);if(i)return"quantParameterTensorNames."+i}}return null},t.fromObject=function(e){if(e instanceof a.onnx.TensorAnnotation)return e;var r=new a.onnx.TensorAnnotation;if(e.tensorName!=null&&(r.tensorName=String(e.tensorName)),e.quantParameterTensorNames){if(!Array.isArray(e.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");r.quantParameterTensorNames=[];for(var i=0;i<e.quantParameterTensorNames.length;++i){if(typeof e.quantParameterTensorNames[i]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");r.quantParameterTensorNames[i]=a.onnx.StringStringEntryProto.fromObject(e.quantParameterTensorNames[i])}}return r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.quantParameterTensorNames=[]),r.defaults&&(i.tensorName=""),e.tensorName!=null&&e.hasOwnProperty("tensorName")&&(i.tensorName=e.tensorName),e.quantParameterTensorNames&&e.quantParameterTensorNames.length){i.quantParameterTensorNames=[];for(var h=0;h<e.quantParameterTensorNames.length;++h)i.quantParameterTensorNames[h]=a.onnx.StringStringEntryProto.toObject(e.quantParameterTensorNames[h],r)}return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f.GraphProto=function(){function t(e){if(this.node=[],this.initializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.node=c.emptyArray,t.prototype.name="",t.prototype.initializer=c.emptyArray,t.prototype.docString="",t.prototype.input=c.emptyArray,t.prototype.output=c.emptyArray,t.prototype.valueInfo=c.emptyArray,t.prototype.quantizationAnnotation=c.emptyArray,t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.node!=null&&e.node.length)for(var i=0;i<e.node.length;++i)a.onnx.NodeProto.encode(e.node[i],r.uint32(10).fork()).ldelim();if(e.name!=null&&e.hasOwnProperty("name")&&r.uint32(18).string(e.name),e.initializer!=null&&e.initializer.length)for(i=0;i<e.initializer.length;++i)a.onnx.TensorProto.encode(e.initializer[i],r.uint32(42).fork()).ldelim();if(e.docString!=null&&e.hasOwnProperty("docString")&&r.uint32(82).string(e.docString),e.input!=null&&e.input.length)for(i=0;i<e.input.length;++i)a.onnx.ValueInfoProto.encode(e.input[i],r.uint32(90).fork()).ldelim();if(e.output!=null&&e.output.length)for(i=0;i<e.output.length;++i)a.onnx.ValueInfoProto.encode(e.output[i],r.uint32(98).fork()).ldelim();if(e.valueInfo!=null&&e.valueInfo.length)for(i=0;i<e.valueInfo.length;++i)a.onnx.ValueInfoProto.encode(e.valueInfo[i],r.uint32(106).fork()).ldelim();if(e.quantizationAnnotation!=null&&e.quantizationAnnotation.length)for(i=0;i<e.quantizationAnnotation.length;++i)a.onnx.TensorAnnotation.encode(e.quantizationAnnotation[i],r.uint32(114).fork()).ldelim();return r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.GraphProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.node&&h.node.length||(h.node=[]),h.node.push(a.onnx.NodeProto.decode(e,e.uint32()));break;case 2:h.name=e.string();break;case 5:h.initializer&&h.initializer.length||(h.initializer=[]),h.initializer.push(a.onnx.TensorProto.decode(e,e.uint32()));break;case 10:h.docString=e.string();break;case 11:h.input&&h.input.length||(h.input=[]),h.input.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:h.output&&h.output.length||(h.output=[]),h.output.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:h.valueInfo&&h.valueInfo.length||(h.valueInfo=[]),h.valueInfo.push(a.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:h.quantizationAnnotation&&h.quantizationAnnotation.length||(h.quantizationAnnotation=[]),h.quantizationAnnotation.push(a.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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 r=0;r<e.node.length;++r)if(i=a.onnx.NodeProto.verify(e.node[r]))return"node."+i}if(e.name!=null&&e.hasOwnProperty("name")&&!c.isString(e.name))return"name: string expected";if(e.initializer!=null&&e.hasOwnProperty("initializer")){if(!Array.isArray(e.initializer))return"initializer: array expected";for(r=0;r<e.initializer.length;++r)if(i=a.onnx.TensorProto.verify(e.initializer[r]))return"initializer."+i}if(e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString))return"docString: string expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(r=0;r<e.input.length;++r)if(i=a.onnx.ValueInfoProto.verify(e.input[r]))return"input."+i}if(e.output!=null&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(r=0;r<e.output.length;++r)if(i=a.onnx.ValueInfoProto.verify(e.output[r]))return"output."+i}if(e.valueInfo!=null&&e.hasOwnProperty("valueInfo")){if(!Array.isArray(e.valueInfo))return"valueInfo: array expected";for(r=0;r<e.valueInfo.length;++r)if(i=a.onnx.ValueInfoProto.verify(e.valueInfo[r]))return"valueInfo."+i}if(e.quantizationAnnotation!=null&&e.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(e.quantizationAnnotation))return"quantizationAnnotation: array expected";for(r=0;r<e.quantizationAnnotation.length;++r){var i;if(i=a.onnx.TensorAnnotation.verify(e.quantizationAnnotation[r]))return"quantizationAnnotation."+i}}return null},t.fromObject=function(e){if(e instanceof a.onnx.GraphProto)return e;var r=new a.onnx.GraphProto;if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.GraphProto.node: array expected");r.node=[];for(var i=0;i<e.node.length;++i){if(typeof e.node[i]!="object")throw TypeError(".onnx.GraphProto.node: object expected");r.node[i]=a.onnx.NodeProto.fromObject(e.node[i])}}if(e.name!=null&&(r.name=String(e.name)),e.initializer){if(!Array.isArray(e.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");for(r.initializer=[],i=0;i<e.initializer.length;++i){if(typeof e.initializer[i]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");r.initializer[i]=a.onnx.TensorProto.fromObject(e.initializer[i])}}if(e.docString!=null&&(r.docString=String(e.docString)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.GraphProto.input: array expected");for(r.input=[],i=0;i<e.input.length;++i){if(typeof e.input[i]!="object")throw TypeError(".onnx.GraphProto.input: object expected");r.input[i]=a.onnx.ValueInfoProto.fromObject(e.input[i])}}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.GraphProto.output: array expected");for(r.output=[],i=0;i<e.output.length;++i){if(typeof e.output[i]!="object")throw TypeError(".onnx.GraphProto.output: object expected");r.output[i]=a.onnx.ValueInfoProto.fromObject(e.output[i])}}if(e.valueInfo){if(!Array.isArray(e.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");for(r.valueInfo=[],i=0;i<e.valueInfo.length;++i){if(typeof e.valueInfo[i]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");r.valueInfo[i]=a.onnx.ValueInfoProto.fromObject(e.valueInfo[i])}}if(e.quantizationAnnotation){if(!Array.isArray(e.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");for(r.quantizationAnnotation=[],i=0;i<e.quantizationAnnotation.length;++i){if(typeof e.quantizationAnnotation[i]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");r.quantizationAnnotation[i]=a.onnx.TensorAnnotation.fromObject(e.quantizationAnnotation[i])}}return r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.node=[],i.initializer=[],i.input=[],i.output=[],i.valueInfo=[],i.quantizationAnnotation=[]),r.defaults&&(i.name="",i.docString=""),e.node&&e.node.length){i.node=[];for(var h=0;h<e.node.length;++h)i.node[h]=a.onnx.NodeProto.toObject(e.node[h],r)}if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.initializer&&e.initializer.length)for(i.initializer=[],h=0;h<e.initializer.length;++h)i.initializer[h]=a.onnx.TensorProto.toObject(e.initializer[h],r);if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.input&&e.input.length)for(i.input=[],h=0;h<e.input.length;++h)i.input[h]=a.onnx.ValueInfoProto.toObject(e.input[h],r);if(e.output&&e.output.length)for(i.output=[],h=0;h<e.output.length;++h)i.output[h]=a.onnx.ValueInfoProto.toObject(e.output[h],r);if(e.valueInfo&&e.valueInfo.length)for(i.valueInfo=[],h=0;h<e.valueInfo.length;++h)i.valueInfo[h]=a.onnx.ValueInfoProto.toObject(e.valueInfo[h],r);if(e.quantizationAnnotation&&e.quantizationAnnotation.length)for(i.quantizationAnnotation=[],h=0;h<e.quantizationAnnotation.length;++h)i.quantizationAnnotation[h]=a.onnx.TensorAnnotation.toObject(e.quantizationAnnotation[h],r);return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f.TensorProto=function(){function t(e){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.dims=c.emptyArray,t.prototype.dataType=0,t.prototype.segment=null,t.prototype.floatData=c.emptyArray,t.prototype.int32Data=c.emptyArray,t.prototype.stringData=c.emptyArray,t.prototype.int64Data=c.emptyArray,t.prototype.name="",t.prototype.docString="",t.prototype.rawData=c.newBuffer([]),t.prototype.externalData=c.emptyArray,t.prototype.dataLocation=0,t.prototype.doubleData=c.emptyArray,t.prototype.uint64Data=c.emptyArray,t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.dims!=null&&e.dims.length){r.uint32(10).fork();for(var i=0;i<e.dims.length;++i)r.int64(e.dims[i]);r.ldelim()}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&r.uint32(16).int32(e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&a.onnx.TensorProto.Segment.encode(e.segment,r.uint32(26).fork()).ldelim(),e.floatData!=null&&e.floatData.length){for(r.uint32(34).fork(),i=0;i<e.floatData.length;++i)r.float(e.floatData[i]);r.ldelim()}if(e.int32Data!=null&&e.int32Data.length){for(r.uint32(42).fork(),i=0;i<e.int32Data.length;++i)r.int32(e.int32Data[i]);r.ldelim()}if(e.stringData!=null&&e.stringData.length)for(i=0;i<e.stringData.length;++i)r.uint32(50).bytes(e.stringData[i]);if(e.int64Data!=null&&e.int64Data.length){for(r.uint32(58).fork(),i=0;i<e.int64Data.length;++i)r.int64(e.int64Data[i]);r.ldelim()}if(e.name!=null&&e.hasOwnProperty("name")&&r.uint32(66).string(e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&r.uint32(74).bytes(e.rawData),e.doubleData!=null&&e.doubleData.length){for(r.uint32(82).fork(),i=0;i<e.doubleData.length;++i)r.double(e.doubleData[i]);r.ldelim()}if(e.uint64Data!=null&&e.uint64Data.length){for(r.uint32(90).fork(),i=0;i<e.uint64Data.length;++i)r.uint64(e.uint64Data[i]);r.ldelim()}if(e.docString!=null&&e.hasOwnProperty("docString")&&r.uint32(98).string(e.docString),e.externalData!=null&&e.externalData.length)for(i=0;i<e.externalData.length;++i)a.onnx.StringStringEntryProto.encode(e.externalData[i],r.uint32(106).fork()).ldelim();return e.dataLocation!=null&&e.hasOwnProperty("dataLocation")&&r.uint32(112).int32(e.dataLocation),r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.TensorProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:if(h.dims&&h.dims.length||(h.dims=[]),(7&m)==2)for(var _=e.uint32()+e.pos;e.pos<_;)h.dims.push(e.int64());else h.dims.push(e.int64());break;case 2:h.dataType=e.int32();break;case 3:h.segment=a.onnx.TensorProto.Segment.decode(e,e.uint32());break;case 4:if(h.floatData&&h.floatData.length||(h.floatData=[]),(7&m)==2)for(_=e.uint32()+e.pos;e.pos<_;)h.floatData.push(e.float());else h.floatData.push(e.float());break;case 5:if(h.int32Data&&h.int32Data.length||(h.int32Data=[]),(7&m)==2)for(_=e.uint32()+e.pos;e.pos<_;)h.int32Data.push(e.int32());else h.int32Data.push(e.int32());break;case 6:h.stringData&&h.stringData.length||(h.stringData=[]),h.stringData.push(e.bytes());break;case 7:if(h.int64Data&&h.int64Data.length||(h.int64Data=[]),(7&m)==2)for(_=e.uint32()+e.pos;e.pos<_;)h.int64Data.push(e.int64());else h.int64Data.push(e.int64());break;case 8:h.name=e.string();break;case 12:h.docString=e.string();break;case 9:h.rawData=e.bytes();break;case 13:h.externalData&&h.externalData.length||(h.externalData=[]),h.externalData.push(a.onnx.StringStringEntryProto.decode(e,e.uint32()));break;case 14:h.dataLocation=e.int32();break;case 10:if(h.doubleData&&h.doubleData.length||(h.doubleData=[]),(7&m)==2)for(_=e.uint32()+e.pos;e.pos<_;)h.doubleData.push(e.double());else h.doubleData.push(e.double());break;case 11:if(h.uint64Data&&h.uint64Data.length||(h.uint64Data=[]),(7&m)==2)for(_=e.uint32()+e.pos;e.pos<_;)h.uint64Data.push(e.uint64());else h.uint64Data.push(e.uint64());break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dims!=null&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var r=0;r<e.dims.length;++r)if(!(c.isInteger(e.dims[r])||e.dims[r]&&c.isInteger(e.dims[r].low)&&c.isInteger(e.dims[r].high)))return"dims: integer|Long[] expected"}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&!c.isInteger(e.dataType))return"dataType: integer expected";if(e.segment!=null&&e.hasOwnProperty("segment")&&(i=a.onnx.TensorProto.Segment.verify(e.segment)))return"segment."+i;if(e.floatData!=null&&e.hasOwnProperty("floatData")){if(!Array.isArray(e.floatData))return"floatData: array expected";for(r=0;r<e.floatData.length;++r)if(typeof e.floatData[r]!="number")return"floatData: number[] expected"}if(e.int32Data!=null&&e.hasOwnProperty("int32Data")){if(!Array.isArray(e.int32Data))return"int32Data: array expected";for(r=0;r<e.int32Data.length;++r)if(!c.isInteger(e.int32Data[r]))return"int32Data: integer[] expected"}if(e.stringData!=null&&e.hasOwnProperty("stringData")){if(!Array.isArray(e.stringData))return"stringData: array expected";for(r=0;r<e.stringData.length;++r)if(!(e.stringData[r]&&typeof e.stringData[r].length=="number"||c.isString(e.stringData[r])))return"stringData: buffer[] expected"}if(e.int64Data!=null&&e.hasOwnProperty("int64Data")){if(!Array.isArray(e.int64Data))return"int64Data: array expected";for(r=0;r<e.int64Data.length;++r)if(!(c.isInteger(e.int64Data[r])||e.int64Data[r]&&c.isInteger(e.int64Data[r].low)&&c.isInteger(e.int64Data[r].high)))return"int64Data: integer|Long[] expected"}if(e.name!=null&&e.hasOwnProperty("name")&&!c.isString(e.name))return"name: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString))return"docString: string expected";if(e.rawData!=null&&e.hasOwnProperty("rawData")&&!(e.rawData&&typeof e.rawData.length=="number"||c.isString(e.rawData)))return"rawData: buffer expected";if(e.externalData!=null&&e.hasOwnProperty("externalData")){if(!Array.isArray(e.externalData))return"externalData: array expected";for(r=0;r<e.externalData.length;++r){var i;if(i=a.onnx.StringStringEntryProto.verify(e.externalData[r]))return"externalData."+i}}if(e.dataLocation!=null&&e.hasOwnProperty("dataLocation"))switch(e.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:}if(e.doubleData!=null&&e.hasOwnProperty("doubleData")){if(!Array.isArray(e.doubleData))return"doubleData: array expected";for(r=0;r<e.doubleData.length;++r)if(typeof e.doubleData[r]!="number")return"doubleData: number[] expected"}if(e.uint64Data!=null&&e.hasOwnProperty("uint64Data")){if(!Array.isArray(e.uint64Data))return"uint64Data: array expected";for(r=0;r<e.uint64Data.length;++r)if(!(c.isInteger(e.uint64Data[r])||e.uint64Data[r]&&c.isInteger(e.uint64Data[r].low)&&c.isInteger(e.uint64Data[r].high)))return"uint64Data: integer|Long[] expected"}return null},t.fromObject=function(e){if(e instanceof a.onnx.TensorProto)return e;var r=new a.onnx.TensorProto;if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.TensorProto.dims: array expected");r.dims=[];for(var i=0;i<e.dims.length;++i)c.Long?(r.dims[i]=c.Long.fromValue(e.dims[i])).unsigned=!1:typeof e.dims[i]=="string"?r.dims[i]=parseInt(e.dims[i],10):typeof e.dims[i]=="number"?r.dims[i]=e.dims[i]:typeof e.dims[i]=="object"&&(r.dims[i]=new c.LongBits(e.dims[i].low>>>0,e.dims[i].high>>>0).toNumber())}if(e.dataType!=null&&(r.dataType=0|e.dataType),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");r.segment=a.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(r.floatData=[],i=0;i<e.floatData.length;++i)r.floatData[i]=Number(e.floatData[i])}if(e.int32Data){if(!Array.isArray(e.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");for(r.int32Data=[],i=0;i<e.int32Data.length;++i)r.int32Data[i]=0|e.int32Data[i]}if(e.stringData){if(!Array.isArray(e.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");for(r.stringData=[],i=0;i<e.stringData.length;++i)typeof e.stringData[i]=="string"?c.base64.decode(e.stringData[i],r.stringData[i]=c.newBuffer(c.base64.length(e.stringData[i])),0):e.stringData[i].length&&(r.stringData[i]=e.stringData[i])}if(e.int64Data){if(!Array.isArray(e.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");for(r.int64Data=[],i=0;i<e.int64Data.length;++i)c.Long?(r.int64Data[i]=c.Long.fromValue(e.int64Data[i])).unsigned=!1:typeof e.int64Data[i]=="string"?r.int64Data[i]=parseInt(e.int64Data[i],10):typeof e.int64Data[i]=="number"?r.int64Data[i]=e.int64Data[i]:typeof e.int64Data[i]=="object"&&(r.int64Data[i]=new c.LongBits(e.int64Data[i].low>>>0,e.int64Data[i].high>>>0).toNumber())}if(e.name!=null&&(r.name=String(e.name)),e.docString!=null&&(r.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?c.base64.decode(e.rawData,r.rawData=c.newBuffer(c.base64.length(e.rawData)),0):e.rawData.length&&(r.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(r.externalData=[],i=0;i<e.externalData.length;++i){if(typeof e.externalData[i]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");r.externalData[i]=a.onnx.StringStringEntryProto.fromObject(e.externalData[i])}}switch(e.dataLocation){case"DEFAULT":case 0:r.dataLocation=0;break;case"EXTERNAL":case 1:r.dataLocation=1}if(e.doubleData){if(!Array.isArray(e.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");for(r.doubleData=[],i=0;i<e.doubleData.length;++i)r.doubleData[i]=Number(e.doubleData[i])}if(e.uint64Data){if(!Array.isArray(e.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");for(r.uint64Data=[],i=0;i<e.uint64Data.length;++i)c.Long?(r.uint64Data[i]=c.Long.fromValue(e.uint64Data[i])).unsigned=!0:typeof e.uint64Data[i]=="string"?r.uint64Data[i]=parseInt(e.uint64Data[i],10):typeof e.uint64Data[i]=="number"?r.uint64Data[i]=e.uint64Data[i]:typeof e.uint64Data[i]=="object"&&(r.uint64Data[i]=new c.LongBits(e.uint64Data[i].low>>>0,e.uint64Data[i].high>>>0).toNumber(!0))}return r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.dims=[],i.floatData=[],i.int32Data=[],i.stringData=[],i.int64Data=[],i.doubleData=[],i.uint64Data=[],i.externalData=[]),r.defaults&&(i.dataType=0,i.segment=null,i.name="",r.bytes===String?i.rawData="":(i.rawData=[],r.bytes!==Array&&(i.rawData=c.newBuffer(i.rawData))),i.docString="",i.dataLocation=r.enums===String?"DEFAULT":0),e.dims&&e.dims.length){i.dims=[];for(var h=0;h<e.dims.length;++h)typeof e.dims[h]=="number"?i.dims[h]=r.longs===String?String(e.dims[h]):e.dims[h]:i.dims[h]=r.longs===String?c.Long.prototype.toString.call(e.dims[h]):r.longs===Number?new c.LongBits(e.dims[h].low>>>0,e.dims[h].high>>>0).toNumber():e.dims[h]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(i.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(i.segment=a.onnx.TensorProto.Segment.toObject(e.segment,r)),e.floatData&&e.floatData.length)for(i.floatData=[],h=0;h<e.floatData.length;++h)i.floatData[h]=r.json&&!isFinite(e.floatData[h])?String(e.floatData[h]):e.floatData[h];if(e.int32Data&&e.int32Data.length)for(i.int32Data=[],h=0;h<e.int32Data.length;++h)i.int32Data[h]=e.int32Data[h];if(e.stringData&&e.stringData.length)for(i.stringData=[],h=0;h<e.stringData.length;++h)i.stringData[h]=r.bytes===String?c.base64.encode(e.stringData[h],0,e.stringData[h].length):r.bytes===Array?Array.prototype.slice.call(e.stringData[h]):e.stringData[h];if(e.int64Data&&e.int64Data.length)for(i.int64Data=[],h=0;h<e.int64Data.length;++h)typeof e.int64Data[h]=="number"?i.int64Data[h]=r.longs===String?String(e.int64Data[h]):e.int64Data[h]:i.int64Data[h]=r.longs===String?c.Long.prototype.toString.call(e.int64Data[h]):r.longs===Number?new c.LongBits(e.int64Data[h].low>>>0,e.int64Data[h].high>>>0).toNumber():e.int64Data[h];if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(i.rawData=r.bytes===String?c.base64.encode(e.rawData,0,e.rawData.length):r.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(i.doubleData=[],h=0;h<e.doubleData.length;++h)i.doubleData[h]=r.json&&!isFinite(e.doubleData[h])?String(e.doubleData[h]):e.doubleData[h];if(e.uint64Data&&e.uint64Data.length)for(i.uint64Data=[],h=0;h<e.uint64Data.length;++h)typeof e.uint64Data[h]=="number"?i.uint64Data[h]=r.longs===String?String(e.uint64Data[h]):e.uint64Data[h]:i.uint64Data[h]=r.longs===String?c.Long.prototype.toString.call(e.uint64Data[h]):r.longs===Number?new c.LongBits(e.uint64Data[h].low>>>0,e.uint64Data[h].high>>>0).toNumber(!0):e.uint64Data[h];if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.externalData&&e.externalData.length)for(i.externalData=[],h=0;h<e.externalData.length;++h)i.externalData[h]=a.onnx.StringStringEntryProto.toObject(e.externalData[h],r);return e.dataLocation!=null&&e.hasOwnProperty("dataLocation")&&(i.dataLocation=r.enums===String?a.onnx.TensorProto.DataLocation[e.dataLocation]:e.dataLocation),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t.DataType=function(){var e={},r=Object.create(e);return r[e[0]="UNDEFINED"]=0,r[e[1]="FLOAT"]=1,r[e[2]="UINT8"]=2,r[e[3]="INT8"]=3,r[e[4]="UINT16"]=4,r[e[5]="INT16"]=5,r[e[6]="INT32"]=6,r[e[7]="INT64"]=7,r[e[8]="STRING"]=8,r[e[9]="BOOL"]=9,r[e[10]="FLOAT16"]=10,r[e[11]="DOUBLE"]=11,r[e[12]="UINT32"]=12,r[e[13]="UINT64"]=13,r[e[14]="COMPLEX64"]=14,r[e[15]="COMPLEX128"]=15,r[e[16]="BFLOAT16"]=16,r}(),t.Segment=function(){function e(r){if(r)for(var i=Object.keys(r),h=0;h<i.length;++h)r[i[h]]!=null&&(this[i[h]]=r[i[h]])}return e.prototype.begin=c.Long?c.Long.fromBits(0,0,!1):0,e.prototype.end=c.Long?c.Long.fromBits(0,0,!1):0,e.create=function(r){return new e(r)},e.encode=function(r,i){return i||(i=g.create()),r.begin!=null&&r.hasOwnProperty("begin")&&i.uint32(8).int64(r.begin),r.end!=null&&r.hasOwnProperty("end")&&i.uint32(16).int64(r.end),i},e.encodeDelimited=function(r,i){return this.encode(r,i).ldelim()},e.decode=function(r,i){r instanceof p||(r=p.create(r));for(var h=i===void 0?r.len:r.pos+i,m=new a.onnx.TensorProto.Segment;r.pos<h;){var _=r.uint32();switch(_>>>3){case 1:m.begin=r.int64();break;case 2:m.end=r.int64();break;default:r.skipType(7&_)}}return m},e.decodeDelimited=function(r){return r instanceof p||(r=new p(r)),this.decode(r,r.uint32())},e.verify=function(r){return typeof r!="object"||r===null?"object expected":r.begin!=null&&r.hasOwnProperty("begin")&&!(c.isInteger(r.begin)||r.begin&&c.isInteger(r.begin.low)&&c.isInteger(r.begin.high))?"begin: integer|Long expected":r.end!=null&&r.hasOwnProperty("end")&&!(c.isInteger(r.end)||r.end&&c.isInteger(r.end.low)&&c.isInteger(r.end.high))?"end: integer|Long expected":null},e.fromObject=function(r){if(r instanceof a.onnx.TensorProto.Segment)return r;var i=new a.onnx.TensorProto.Segment;return r.begin!=null&&(c.Long?(i.begin=c.Long.fromValue(r.begin)).unsigned=!1:typeof r.begin=="string"?i.begin=parseInt(r.begin,10):typeof r.begin=="number"?i.begin=r.begin:typeof r.begin=="object"&&(i.begin=new c.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber())),r.end!=null&&(c.Long?(i.end=c.Long.fromValue(r.end)).unsigned=!1:typeof r.end=="string"?i.end=parseInt(r.end,10):typeof r.end=="number"?i.end=r.end:typeof r.end=="object"&&(i.end=new c.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber())),i},e.toObject=function(r,i){i||(i={});var h={};if(i.defaults){if(c.Long){var m=new c.Long(0,0,!1);h.begin=i.longs===String?m.toString():i.longs===Number?m.toNumber():m}else h.begin=i.longs===String?"0":0;c.Long?(m=new c.Long(0,0,!1),h.end=i.longs===String?m.toString():i.longs===Number?m.toNumber():m):h.end=i.longs===String?"0":0}return r.begin!=null&&r.hasOwnProperty("begin")&&(typeof r.begin=="number"?h.begin=i.longs===String?String(r.begin):r.begin:h.begin=i.longs===String?c.Long.prototype.toString.call(r.begin):i.longs===Number?new c.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber():r.begin),r.end!=null&&r.hasOwnProperty("end")&&(typeof r.end=="number"?h.end=i.longs===String?String(r.end):r.end:h.end=i.longs===String?c.Long.prototype.toString.call(r.end):i.longs===Number?new c.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber():r.end),h},e.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},e}(),t.DataLocation=function(){var e={},r=Object.create(e);return r[e[0]="DEFAULT"]=0,r[e[1]="EXTERNAL"]=1,r}(),t}(),f.TensorShapeProto=function(){function t(e){if(this.dim=[],e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.dim=c.emptyArray,t.create=function(e){return new t(e)},t.encode=function(e,r){if(r||(r=g.create()),e.dim!=null&&e.dim.length)for(var i=0;i<e.dim.length;++i)a.onnx.TensorShapeProto.Dimension.encode(e.dim[i],r.uint32(10).fork()).ldelim();return r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.TensorShapeProto;e.pos<i;){var m=e.uint32();m>>>3==1?(h.dim&&h.dim.length||(h.dim=[]),h.dim.push(a.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&m)}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(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 r=0;r<e.dim.length;++r){var i=a.onnx.TensorShapeProto.Dimension.verify(e.dim[r]);if(i)return"dim."+i}}return null},t.fromObject=function(e){if(e instanceof a.onnx.TensorShapeProto)return e;var r=new a.onnx.TensorShapeProto;if(e.dim){if(!Array.isArray(e.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");r.dim=[];for(var i=0;i<e.dim.length;++i){if(typeof e.dim[i]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");r.dim[i]=a.onnx.TensorShapeProto.Dimension.fromObject(e.dim[i])}}return r},t.toObject=function(e,r){r||(r={});var i={};if((r.arrays||r.defaults)&&(i.dim=[]),e.dim&&e.dim.length){i.dim=[];for(var h=0;h<e.dim.length;++h)i.dim[h]=a.onnx.TensorShapeProto.Dimension.toObject(e.dim[h],r)}return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t.Dimension=function(){function e(i){if(i)for(var h=Object.keys(i),m=0;m<h.length;++m)i[h[m]]!=null&&(this[h[m]]=i[h[m]])}var r;return e.prototype.dimValue=c.Long?c.Long.fromBits(0,0,!1):0,e.prototype.dimParam="",e.prototype.denotation="",Object.defineProperty(e.prototype,"value",{get:c.oneOfGetter(r=["dimValue","dimParam"]),set:c.oneOfSetter(r)}),e.create=function(i){return new e(i)},e.encode=function(i,h){return h||(h=g.create()),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&h.uint32(8).int64(i.dimValue),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&h.uint32(18).string(i.dimParam),i.denotation!=null&&i.hasOwnProperty("denotation")&&h.uint32(26).string(i.denotation),h},e.encodeDelimited=function(i,h){return this.encode(i,h).ldelim()},e.decode=function(i,h){i instanceof p||(i=p.create(i));for(var m=h===void 0?i.len:i.pos+h,_=new a.onnx.TensorShapeProto.Dimension;i.pos<m;){var b=i.uint32();switch(b>>>3){case 1:_.dimValue=i.int64();break;case 2:_.dimParam=i.string();break;case 3:_.denotation=i.string();break;default:i.skipType(7&b)}}return _},e.decodeDelimited=function(i){return i instanceof p||(i=new p(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var h={};if(i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(h.value=1,!(c.isInteger(i.dimValue)||i.dimValue&&c.isInteger(i.dimValue.low)&&c.isInteger(i.dimValue.high))))return"dimValue: integer|Long expected";if(i.dimParam!=null&&i.hasOwnProperty("dimParam")){if(h.value===1)return"value: multiple values";if(h.value=1,!c.isString(i.dimParam))return"dimParam: string expected"}return i.denotation!=null&&i.hasOwnProperty("denotation")&&!c.isString(i.denotation)?"denotation: string expected":null},e.fromObject=function(i){if(i instanceof a.onnx.TensorShapeProto.Dimension)return i;var h=new a.onnx.TensorShapeProto.Dimension;return i.dimValue!=null&&(c.Long?(h.dimValue=c.Long.fromValue(i.dimValue)).unsigned=!1:typeof i.dimValue=="string"?h.dimValue=parseInt(i.dimValue,10):typeof i.dimValue=="number"?h.dimValue=i.dimValue:typeof i.dimValue=="object"&&(h.dimValue=new c.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber())),i.dimParam!=null&&(h.dimParam=String(i.dimParam)),i.denotation!=null&&(h.denotation=String(i.denotation)),h},e.toObject=function(i,h){h||(h={});var m={};return h.defaults&&(m.denotation=""),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(typeof i.dimValue=="number"?m.dimValue=h.longs===String?String(i.dimValue):i.dimValue:m.dimValue=h.longs===String?c.Long.prototype.toString.call(i.dimValue):h.longs===Number?new c.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber():i.dimValue,h.oneofs&&(m.value="dimValue")),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&(m.dimParam=i.dimParam,h.oneofs&&(m.value="dimParam")),i.denotation!=null&&i.hasOwnProperty("denotation")&&(m.denotation=i.denotation),m},e.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},e}(),t}(),f.TypeProto=function(){function t(r){if(r)for(var i=Object.keys(r),h=0;h<i.length;++h)r[i[h]]!=null&&(this[i[h]]=r[i[h]])}var e;return t.prototype.tensorType=null,t.prototype.denotation="",Object.defineProperty(t.prototype,"value",{get:c.oneOfGetter(e=["tensorType"]),set:c.oneOfSetter(e)}),t.create=function(r){return new t(r)},t.encode=function(r,i){return i||(i=g.create()),r.tensorType!=null&&r.hasOwnProperty("tensorType")&&a.onnx.TypeProto.Tensor.encode(r.tensorType,i.uint32(10).fork()).ldelim(),r.denotation!=null&&r.hasOwnProperty("denotation")&&i.uint32(50).string(r.denotation),i},t.encodeDelimited=function(r,i){return this.encode(r,i).ldelim()},t.decode=function(r,i){r instanceof p||(r=p.create(r));for(var h=i===void 0?r.len:r.pos+i,m=new a.onnx.TypeProto;r.pos<h;){var _=r.uint32();switch(_>>>3){case 1:m.tensorType=a.onnx.TypeProto.Tensor.decode(r,r.uint32());break;case 6:m.denotation=r.string();break;default:r.skipType(7&_)}}return m},t.decodeDelimited=function(r){return r instanceof p||(r=new p(r)),this.decode(r,r.uint32())},t.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.tensorType!=null&&r.hasOwnProperty("tensorType")){var i=a.onnx.TypeProto.Tensor.verify(r.tensorType);if(i)return"tensorType."+i}return r.denotation!=null&&r.hasOwnProperty("denotation")&&!c.isString(r.denotation)?"denotation: string expected":null},t.fromObject=function(r){if(r instanceof a.onnx.TypeProto)return r;var i=new a.onnx.TypeProto;if(r.tensorType!=null){if(typeof r.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");i.tensorType=a.onnx.TypeProto.Tensor.fromObject(r.tensorType)}return r.denotation!=null&&(i.denotation=String(r.denotation)),i},t.toObject=function(r,i){i||(i={});var h={};return i.defaults&&(h.denotation=""),r.tensorType!=null&&r.hasOwnProperty("tensorType")&&(h.tensorType=a.onnx.TypeProto.Tensor.toObject(r.tensorType,i),i.oneofs&&(h.value="tensorType")),r.denotation!=null&&r.hasOwnProperty("denotation")&&(h.denotation=r.denotation),h},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t.Tensor=function(){function r(i){if(i)for(var h=Object.keys(i),m=0;m<h.length;++m)i[h[m]]!=null&&(this[h[m]]=i[h[m]])}return r.prototype.elemType=0,r.prototype.shape=null,r.create=function(i){return new r(i)},r.encode=function(i,h){return h||(h=g.create()),i.elemType!=null&&i.hasOwnProperty("elemType")&&h.uint32(8).int32(i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&a.onnx.TensorShapeProto.encode(i.shape,h.uint32(18).fork()).ldelim(),h},r.encodeDelimited=function(i,h){return this.encode(i,h).ldelim()},r.decode=function(i,h){i instanceof p||(i=p.create(i));for(var m=h===void 0?i.len:i.pos+h,_=new a.onnx.TypeProto.Tensor;i.pos<m;){var b=i.uint32();switch(b>>>3){case 1:_.elemType=i.int32();break;case 2:_.shape=a.onnx.TensorShapeProto.decode(i,i.uint32());break;default:i.skipType(7&b)}}return _},r.decodeDelimited=function(i){return i instanceof p||(i=new p(i)),this.decode(i,i.uint32())},r.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!c.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var h=a.onnx.TensorShapeProto.verify(i.shape);if(h)return"shape."+h}return null},r.fromObject=function(i){if(i instanceof a.onnx.TypeProto.Tensor)return i;var h=new a.onnx.TypeProto.Tensor;if(i.elemType!=null&&(h.elemType=0|i.elemType),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");h.shape=a.onnx.TensorShapeProto.fromObject(i.shape)}return h},r.toObject=function(i,h){h||(h={});var m={};return h.defaults&&(m.elemType=0,m.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(m.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(m.shape=a.onnx.TensorShapeProto.toObject(i.shape,h)),m},r.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},r}(),t}(),f.OperatorSetIdProto=function(){function t(e){if(e)for(var r=Object.keys(e),i=0;i<r.length;++i)e[r[i]]!=null&&(this[r[i]]=e[r[i]])}return t.prototype.domain="",t.prototype.version=c.Long?c.Long.fromBits(0,0,!1):0,t.create=function(e){return new t(e)},t.encode=function(e,r){return r||(r=g.create()),e.domain!=null&&e.hasOwnProperty("domain")&&r.uint32(10).string(e.domain),e.version!=null&&e.hasOwnProperty("version")&&r.uint32(16).int64(e.version),r},t.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},t.decode=function(e,r){e instanceof p||(e=p.create(e));for(var i=r===void 0?e.len:e.pos+r,h=new a.onnx.OperatorSetIdProto;e.pos<i;){var m=e.uint32();switch(m>>>3){case 1:h.domain=e.string();break;case 2:h.version=e.int64();break;default:e.skipType(7&m)}}return h},t.decodeDelimited=function(e){return e instanceof p||(e=new p(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!c.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!(c.isInteger(e.version)||e.version&&c.isInteger(e.version.low)&&c.isInteger(e.version.high))?"version: integer|Long expected":null},t.fromObject=function(e){if(e instanceof a.onnx.OperatorSetIdProto)return e;var r=new a.onnx.OperatorSetIdProto;return e.domain!=null&&(r.domain=String(e.domain)),e.version!=null&&(c.Long?(r.version=c.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?r.version=parseInt(e.version,10):typeof e.version=="number"?r.version=e.version:typeof e.version=="object"&&(r.version=new c.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),r},t.toObject=function(e,r){r||(r={});var i={};if(r.defaults)if(i.domain="",c.Long){var h=new c.Long(0,0,!1);i.version=r.longs===String?h.toString():r.longs===Number?h.toNumber():h}else i.version=r.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?i.version=r.longs===String?String(e.version):e.version:i.version=r.longs===String?c.Long.prototype.toString.call(e.version):r.longs===Number?new c.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},t}(),f),d.exports=a},2100:(d,n,o)=>{d.exports=o(9482)},9482:(d,n,o)=>{var s=n;function l(){s.util._configure(),s.Writer._configure(s.BufferWriter),s.Reader._configure(s.BufferReader)}s.build="minimal",s.Writer=o(1173),s.BufferWriter=o(3155),s.Reader=o(1408),s.BufferReader=o(593),s.util=o(9693),s.rpc=o(5994),s.roots=o(5054),s.configure=l,l()},1408:(d,n,o)=>{d.exports=g;var s,l=o(9693),f=l.LongBits,u=l.utf8;function p(h,m){return RangeError("index out of range: "+h.pos+" + "+(m||1)+" > "+h.len)}function g(h){this.buf=h,this.pos=0,this.len=h.length}var c,a=typeof Uint8Array<"u"?function(h){if(h instanceof Uint8Array||Array.isArray(h))return new g(h);throw Error("illegal buffer")}:function(h){if(Array.isArray(h))return new g(h);throw Error("illegal buffer")},t=function(){return l.Buffer?function(h){return(g.create=function(m){return l.Buffer.isBuffer(m)?new s(m):a(m)})(h)}:a};function e(){var h=new f(0,0),m=0;if(!(this.len-this.pos>4)){for(;m<3;++m){if(this.pos>=this.len)throw p(this);if(h.lo=(h.lo|(127&this.buf[this.pos])<<7*m)>>>0,this.buf[this.pos++]<128)return h}return h.lo=(h.lo|(127&this.buf[this.pos++])<<7*m)>>>0,h}for(;m<4;++m)if(h.lo=(h.lo|(127&this.buf[this.pos])<<7*m)>>>0,this.buf[this.pos++]<128)return h;if(h.lo=(h.lo|(127&this.buf[this.pos])<<28)>>>0,h.hi=(h.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return h;if(m=0,this.len-this.pos>4){for(;m<5;++m)if(h.hi=(h.hi|(127&this.buf[this.pos])<<7*m+3)>>>0,this.buf[this.pos++]<128)return h}else for(;m<5;++m){if(this.pos>=this.len)throw p(this);if(h.hi=(h.hi|(127&this.buf[this.pos])<<7*m+3)>>>0,this.buf[this.pos++]<128)return h}throw Error("invalid varint encoding")}function r(h,m){return(h[m-4]|h[m-3]<<8|h[m-2]<<16|h[m-1]<<24)>>>0}function i(){if(this.pos+8>this.len)throw p(this,8);return new f(r(this.buf,this.pos+=4),r(this.buf,this.pos+=4))}g.create=t(),g.prototype._slice=l.Array.prototype.subarray||l.Array.prototype.slice,g.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return c;if((this.pos+=5)>this.len)throw this.pos=this.len,p(this,10);return c}),g.prototype.int32=function(){return 0|this.uint32()},g.prototype.sint32=function(){var h=this.uint32();return h>>>1^-(1&h)|0},g.prototype.bool=function(){return this.uint32()!==0},g.prototype.fixed32=function(){if(this.pos+4>this.len)throw p(this,4);return r(this.buf,this.pos+=4)},g.prototype.sfixed32=function(){if(this.pos+4>this.len)throw p(this,4);return 0|r(this.buf,this.pos+=4)},g.prototype.float=function(){if(this.pos+4>this.len)throw p(this,4);var h=l.float.readFloatLE(this.buf,this.pos);return this.pos+=4,h},g.prototype.double=function(){if(this.pos+8>this.len)throw p(this,4);var h=l.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,h},g.prototype.bytes=function(){var h=this.uint32(),m=this.pos,_=this.pos+h;if(_>this.len)throw p(this,h);return this.pos+=h,Array.isArray(this.buf)?this.buf.slice(m,_):m===_?new this.buf.constructor(0):this._slice.call(this.buf,m,_)},g.prototype.string=function(){var h=this.bytes();return u.read(h,0,h.length)},g.prototype.skip=function(h){if(typeof h=="number"){if(this.pos+h>this.len)throw p(this,h);this.pos+=h}else do if(this.pos>=this.len)throw p(this);while(128&this.buf[this.pos++]);return this},g.prototype.skipType=function(h){switch(h){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(h=7&this.uint32())!=4;)this.skipType(h);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+h+" at offset "+this.pos)}return this},g._configure=function(h){s=h,g.create=t(),s._configure();var m=l.Long?"toLong":"toNumber";l.merge(g.prototype,{int64:function(){return e.call(this)[m](!1)},uint64:function(){return e.call(this)[m](!0)},sint64:function(){return e.call(this).zzDecode()[m](!1)},fixed64:function(){return i.call(this)[m](!0)},sfixed64:function(){return i.call(this)[m](!1)}})}},593:(d,n,o)=>{d.exports=f;var s=o(1408);(f.prototype=Object.create(s.prototype)).constructor=f;var l=o(9693);function f(u){s.call(this,u)}f._configure=function(){l.Buffer&&(f.prototype._slice=l.Buffer.prototype.slice)},f.prototype.string=function(){var u=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+u,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+u,this.len))},f._configure()},5054:d=>{d.exports={}},5994:(d,n,o)=>{n.Service=o(7948)},7948:(d,n,o)=>{d.exports=l;var s=o(9693);function l(f,u,p){if(typeof f!="function")throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=f,this.requestDelimited=!!u,this.responseDelimited=!!p}(l.prototype=Object.create(s.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function f(u,p,g,c,a){if(!c)throw TypeError("request must be specified");var t=this;if(!a)return s.asPromise(f,t,u,p,g,c);if(t.rpcImpl)try{return t.rpcImpl(u,p[t.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(e,r){if(e)return t.emit("error",e,u),a(e);if(r!==null){if(!(r instanceof g))try{r=g[t.responseDelimited?"decodeDelimited":"decode"](r)}catch(i){return t.emit("error",i,u),a(i)}return t.emit("data",r,u),a(null,r)}t.end(!0)})}catch(e){return t.emit("error",e,u),void setTimeout(function(){a(e)},0)}else setTimeout(function(){a(Error("already ended"))},0)},l.prototype.end=function(f){return this.rpcImpl&&(f||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(d,n,o)=>{d.exports=l;var s=o(9693);function l(g,c){this.lo=g>>>0,this.hi=c>>>0}var f=l.zero=new l(0,0);f.toNumber=function(){return 0},f.zzEncode=f.zzDecode=function(){return this},f.length=function(){return 1};var u=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(g){if(g===0)return f;var c=g<0;c&&(g=-g);var a=g>>>0,t=(g-a)/4294967296>>>0;return c&&(t=~t>>>0,a=~a>>>0,++a>4294967295&&(a=0,++t>4294967295&&(t=0))),new l(a,t)},l.from=function(g){if(typeof g=="number")return l.fromNumber(g);if(s.isString(g)){if(!s.Long)return l.fromNumber(parseInt(g,10));g=s.Long.fromString(g)}return g.low||g.high?new l(g.low>>>0,g.high>>>0):f},l.prototype.toNumber=function(g){if(!g&&this.hi>>>31){var c=1+~this.lo>>>0,a=~this.hi>>>0;return c||(a=a+1>>>0),-(c+4294967296*a)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(g){return s.Long?new s.Long(0|this.lo,0|this.hi,!!g):{low:0|this.lo,high:0|this.hi,unsigned:!!g}};var p=String.prototype.charCodeAt;l.fromHash=function(g){return g===u?f:new l((p.call(g,0)|p.call(g,1)<<8|p.call(g,2)<<16|p.call(g,3)<<24)>>>0,(p.call(g,4)|p.call(g,5)<<8|p.call(g,6)<<16|p.call(g,7)<<24)>>>0)},l.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)},l.prototype.zzEncode=function(){var g=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^g)>>>0,this.lo=(this.lo<<1^g)>>>0,this},l.prototype.zzDecode=function(){var g=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^g)>>>0,this.hi=(this.hi>>>1^g)>>>0,this},l.prototype.length=function(){var g=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,a=this.hi>>>24;return a===0?c===0?g<16384?g<128?1:2:g<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:a<128?9:10}},9693:function(d,n,o){var s=n;function l(u,p,g){for(var c=Object.keys(p),a=0;a<c.length;++a)u[c[a]]!==void 0&&g||(u[c[a]]=p[c[a]]);return u}function f(u){function p(g,c){if(!(this instanceof p))return new p(g,c);Object.defineProperty(this,"message",{get:function(){return g}}),Error.captureStackTrace?Error.captureStackTrace(this,p):Object.defineProperty(this,"stack",{value:new Error().stack||""}),c&&l(this,c)}return(p.prototype=Object.create(Error.prototype)).constructor=p,Object.defineProperty(p.prototype,"name",{get:function(){return u}}),p.prototype.toString=function(){return this.name+": "+this.message},p}s.asPromise=o(4537),s.base64=o(7419),s.EventEmitter=o(9211),s.float=o(945),s.inquire=o(7199),s.utf8=o(4997),s.pool=o(6662),s.LongBits=o(1945),s.isNode=!!(o.g!==void 0&&o.g&&o.g.process&&o.g.process.versions&&o.g.process.versions.node),s.global=s.isNode&&o.g||typeof window<"u"&&window||typeof self<"u"&&self||this,s.emptyArray=Object.freeze?Object.freeze([]):[],s.emptyObject=Object.freeze?Object.freeze({}):{},s.isInteger=Number.isInteger||function(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u},s.isString=function(u){return typeof u=="string"||u instanceof String},s.isObject=function(u){return u&&typeof u=="object"},s.isset=s.isSet=function(u,p){var g=u[p];return!(g==null||!u.hasOwnProperty(p))&&(typeof g!="object"||(Array.isArray(g)?g.length:Object.keys(g).length)>0)},s.Buffer=function(){try{var u=s.inquire("buffer").Buffer;return u.prototype.utf8Write?u:null}catch{return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(u){return typeof u=="number"?s.Buffer?s._Buffer_allocUnsafe(u):new s.Array(u):s.Buffer?s._Buffer_from(u):typeof Uint8Array>"u"?u:new Uint8Array(u)},s.Array=typeof Uint8Array<"u"?Uint8Array:Array,s.Long=s.global.dcodeIO&&s.global.dcodeIO.Long||s.global.Long||s.inquire("long"),s.key2Re=/^true|false|0|1$/,s.key32Re=/^-?(?:0|[1-9][0-9]*)$/,s.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,s.longToHash=function(u){return u?s.LongBits.from(u).toHash():s.LongBits.zeroHash},s.longFromHash=function(u,p){var g=s.LongBits.fromHash(u);return s.Long?s.Long.fromBits(g.lo,g.hi,p):g.toNumber(!!p)},s.merge=l,s.lcFirst=function(u){return u.charAt(0).toLowerCase()+u.substring(1)},s.newError=f,s.ProtocolError=f("ProtocolError"),s.oneOfGetter=function(u){for(var p={},g=0;g<u.length;++g)p[u[g]]=1;return function(){for(var c=Object.keys(this),a=c.length-1;a>-1;--a)if(p[c[a]]===1&&this[c[a]]!==void 0&&this[c[a]]!==null)return c[a]}},s.oneOfSetter=function(u){return function(p){for(var g=0;g<u.length;++g)u[g]!==p&&delete this[u[g]]}},s.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},s._configure=function(){var u=s.Buffer;u?(s._Buffer_from=u.from!==Uint8Array.from&&u.from||function(p,g){return new u(p,g)},s._Buffer_allocUnsafe=u.allocUnsafe||function(p){return new u(p)}):s._Buffer_from=s._Buffer_allocUnsafe=null}},1173:(d,n,o)=>{d.exports=t;var s,l=o(9693),f=l.LongBits,u=l.base64,p=l.utf8;function g(b,y,T){this.fn=b,this.len=y,this.next=void 0,this.val=T}function c(){}function a(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function t(){this.len=0,this.head=new g(c,0,0),this.tail=this.head,this.states=null}var e=function(){return l.Buffer?function(){return(t.create=function(){return new s})()}:function(){return new t}};function r(b,y,T){y[T]=255&b}function i(b,y){this.len=b,this.next=void 0,this.val=y}function h(b,y,T){for(;b.hi;)y[T++]=127&b.lo|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)y[T++]=127&b.lo|128,b.lo=b.lo>>>7;y[T++]=b.lo}function m(b,y,T){y[T]=255&b,y[T+1]=b>>>8&255,y[T+2]=b>>>16&255,y[T+3]=b>>>24}t.create=e(),t.alloc=function(b){return new l.Array(b)},l.Array!==Array&&(t.alloc=l.pool(t.alloc,l.Array.prototype.subarray)),t.prototype._push=function(b,y,T){return this.tail=this.tail.next=new g(b,y,T),this.len+=y,this},i.prototype=Object.create(g.prototype),i.prototype.fn=function(b,y,T){for(;b>127;)y[T++]=127&b|128,b>>>=7;y[T]=b},t.prototype.uint32=function(b){return this.len+=(this.tail=this.tail.next=new i((b>>>=0)<128?1:b<16384?2:b<2097152?3:b<268435456?4:5,b)).len,this},t.prototype.int32=function(b){return b<0?this._push(h,10,f.fromNumber(b)):this.uint32(b)},t.prototype.sint32=function(b){return this.uint32((b<<1^b>>31)>>>0)},t.prototype.uint64=function(b){var y=f.from(b);return this._push(h,y.length(),y)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(b){var y=f.from(b).zzEncode();return this._push(h,y.length(),y)},t.prototype.bool=function(b){return this._push(r,1,b?1:0)},t.prototype.fixed32=function(b){return this._push(m,4,b>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(b){var y=f.from(b);return this._push(m,4,y.lo)._push(m,4,y.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(b){return this._push(l.float.writeFloatLE,4,b)},t.prototype.double=function(b){return this._push(l.float.writeDoubleLE,8,b)};var _=l.Array.prototype.set?function(b,y,T){y.set(b,T)}:function(b,y,T){for(var w=0;w<b.length;++w)y[T+w]=b[w]};t.prototype.bytes=function(b){var y=b.length>>>0;if(!y)return this._push(r,1,0);if(l.isString(b)){var T=t.alloc(y=u.length(b));u.decode(b,T,0),b=T}return this.uint32(y)._push(_,y,b)},t.prototype.string=function(b){var y=p.length(b);return y?this.uint32(y)._push(p.write,y,b):this._push(r,1,0)},t.prototype.fork=function(){return this.states=new a(this),this.head=this.tail=new g(c,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 g(c,0,0),this.len=0),this},t.prototype.ldelim=function(){var b=this.head,y=this.tail,T=this.len;return this.reset().uint32(T),T&&(this.tail.next=b.next,this.tail=y,this.len+=T),this},t.prototype.finish=function(){for(var b=this.head.next,y=this.constructor.alloc(this.len),T=0;b;)b.fn(b.val,y,T),T+=b.len,b=b.next;return y},t._configure=function(b){s=b,t.create=e(),s._configure()}},3155:(d,n,o)=>{d.exports=f;var s=o(1173);(f.prototype=Object.create(s.prototype)).constructor=f;var l=o(9693);function f(){s.call(this)}function u(p,g,c){p.length<40?l.utf8.write(p,g,c):g.utf8Write?g.utf8Write(p,c):g.write(p,c)}f._configure=function(){f.alloc=l._Buffer_allocUnsafe,f.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&l.Buffer.prototype.set.name==="set"?function(p,g,c){g.set(p,c)}:function(p,g,c){if(p.copy)p.copy(g,c,0,p.length);else for(var a=0;a<p.length;)g[c++]=p[a++]}},f.prototype.bytes=function(p){l.isString(p)&&(p=l._Buffer_from(p,"base64"));var g=p.length>>>0;return this.uint32(g),g&&this._push(f.writeBytesBuffer,g,p),this},f.prototype.string=function(p){var g=l.Buffer.byteLength(p);return this.uint32(g),g&&this._push(u,g,p),this},f._configure()},7714:(d,n,o)=>{n.R=void 0;const s=o(6919),l=o(7448);n.R=new class{async init(){}async createSessionHandler(f,u){const p=new s.Session(u);return await p.loadModel(f),new l.OnnxjsSessionHandler(p)}}},4200:(d,n,o)=>{n.c8=n.rX=void 0;const s=o(1670),l=o(5381),f=o(2157),u=o(2306);n.rX=()=>{if((typeof s.env.wasm.initTimeout!="number"||s.env.wasm.initTimeout<0)&&(s.env.wasm.initTimeout=0),typeof s.env.wasm.simd!="boolean"&&(s.env.wasm.simd=!0),typeof s.env.wasm.proxy!="boolean"&&(s.env.wasm.proxy=!1),typeof s.env.wasm.numThreads!="number"||!Number.isInteger(s.env.wasm.numThreads)||s.env.wasm.numThreads<=0){const p=typeof navigator>"u"?(0,l.cpus)().length:navigator.hardwareConcurrency;s.env.wasm.numThreads=Math.min(4,Math.ceil((p||1)/2))}},n.c8=new class{async init(){(0,n.rX)(),await(0,f.initWasm)()}async createSessionHandler(p,g){const c=new u.OnnxruntimeWebAssemblySessionHandler;return await c.loadModel(p,g),Promise.resolve(c)}}},6018:function(d,n,o){var s=this&&this.__createBinding||(Object.create?function(u,p,g,c){c===void 0&&(c=g);var a=Object.getOwnPropertyDescriptor(p,g);a&&!("get"in a?!p.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return p[g]}}),Object.defineProperty(u,c,a)}:function(u,p,g,c){c===void 0&&(c=g),u[c]=p[g]}),l=this&&this.__exportStar||function(u,p){for(var g in u)g==="default"||Object.prototype.hasOwnProperty.call(p,g)||s(p,u,g)};Object.defineProperty(n,"__esModule",{value:!0}),l(o(1670),n);const f=o(1670);{const u=o(7714).R;(0,f.registerBackend)("webgl",u,-10)}{const u=o(4200).c8;(0,f.registerBackend)("cpu",u,10),(0,f.registerBackend)("wasm",u,10),(0,f.registerBackend)("xnnpack",u,9)}},246:(d,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createAttributeWithCacheKey=void 0;class o{constructor(l){Object.assign(this,l)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(l=>`${this[l]}`).join(";")),this._cacheKey}}n.createAttributeWithCacheKey=s=>new o(s)},7778:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Attribute=void 0;const s=o(1446),l=o(9395),f=o(9162),u=o(2517);var p=l.onnxruntime.experimental.fbs;class g{constructor(a){if(this._attributes=new Map,a!=null){for(const t of a)t instanceof s.onnx.AttributeProto?this._attributes.set(t.name,[g.getValue(t),g.getType(t)]):t instanceof p.Attribute&&this._attributes.set(t.name(),[g.getValue(t),g.getType(t)]);if(this._attributes.size<a.length)throw new Error("duplicated attribute names")}}set(a,t,e){this._attributes.set(a,[e,t])}delete(a){this._attributes.delete(a)}getFloat(a,t){return this.get(a,"float",t)}getInt(a,t){return this.get(a,"int",t)}getString(a,t){return this.get(a,"string",t)}getTensor(a,t){return this.get(a,"tensor",t)}getFloats(a,t){return this.get(a,"floats",t)}getInts(a,t){return this.get(a,"ints",t)}getStrings(a,t){return this.get(a,"strings",t)}getTensors(a,t){return this.get(a,"tensors",t)}get(a,t,e){const r=this._attributes.get(a);if(r===void 0){if(e!==void 0)return e;throw new Error(`required attribute not found: ${a}`)}if(r[1]!==t)throw new Error(`type mismatch: expected ${t} but got ${r[1]}`);return r[0]}static getType(a){const t=a instanceof s.onnx.AttributeProto?a.type:a.type();switch(t){case s.onnx.AttributeProto.AttributeType.FLOAT:return"float";case s.onnx.AttributeProto.AttributeType.INT:return"int";case s.onnx.AttributeProto.AttributeType.STRING:return"string";case s.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case s.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case s.onnx.AttributeProto.AttributeType.INTS:return"ints";case s.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case s.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${s.onnx.AttributeProto.AttributeType[t]}`)}}static getValue(a){const t=a instanceof s.onnx.AttributeProto?a.type:a.type();if(t===s.onnx.AttributeProto.AttributeType.GRAPH||t===s.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");const e=this.getValueNoCheck(a);if(t===s.onnx.AttributeProto.AttributeType.INT&&u.LongUtil.isLong(e))return u.LongUtil.longToNumber(e);if(t===s.onnx.AttributeProto.AttributeType.INTS){const r=e,i=new Array(r.length);for(let h=0;h<r.length;h++){const m=r[h];i[h]=u.LongUtil.longToNumber(m)}return i}if(t===s.onnx.AttributeProto.AttributeType.TENSOR)return a instanceof s.onnx.AttributeProto?f.Tensor.fromProto(e):f.Tensor.fromOrtTensor(e);if(t===s.onnx.AttributeProto.AttributeType.TENSORS){if(a instanceof s.onnx.AttributeProto)return e.map(r=>f.Tensor.fromProto(r));if(a instanceof p.Attribute)return e.map(r=>f.Tensor.fromOrtTensor(r))}if(t===s.onnx.AttributeProto.AttributeType.STRING&&a instanceof s.onnx.AttributeProto){const r=e;return(0,u.decodeUtf8String)(r)}return t===s.onnx.AttributeProto.AttributeType.STRINGS&&a instanceof s.onnx.AttributeProto?e.map(u.decodeUtf8String):e}static getValueNoCheck(a){return a instanceof s.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(a):this.getValueNoCheckFromOrtFormat(a)}static getValueNoCheckFromOnnxFormat(a){switch(a.type){case s.onnx.AttributeProto.AttributeType.FLOAT:return a.f;case s.onnx.AttributeProto.AttributeType.INT:return a.i;case s.onnx.AttributeProto.AttributeType.STRING:return a.s;case s.onnx.AttributeProto.AttributeType.TENSOR:return a.t;case s.onnx.AttributeProto.AttributeType.GRAPH:return a.g;case s.onnx.AttributeProto.AttributeType.FLOATS:return a.floats;case s.onnx.AttributeProto.AttributeType.INTS:return a.ints;case s.onnx.AttributeProto.AttributeType.STRINGS:return a.strings;case s.onnx.AttributeProto.AttributeType.TENSORS:return a.tensors;case s.onnx.AttributeProto.AttributeType.GRAPHS:return a.graphs;default:throw new Error(`unsupported attribute type: ${s.onnx.AttributeProto.AttributeType[a.type]}`)}}static getValueNoCheckFromOrtFormat(a){switch(a.type()){case p.AttributeType.FLOAT:return a.f();case p.AttributeType.INT:return a.i();case p.AttributeType.STRING:return a.s();case p.AttributeType.TENSOR:return a.t();case p.AttributeType.GRAPH:return a.g();case p.AttributeType.FLOATS:return a.floatsArray();case p.AttributeType.INTS:{const t=[];for(let e=0;e<a.intsLength();e++)t.push(a.ints(e));return t}case p.AttributeType.STRINGS:{const t=[];for(let e=0;e<a.stringsLength();e++)t.push(a.strings(e));return t}case p.AttributeType.TENSORS:{const t=[];for(let e=0;e<a.tensorsLength();e++)t.push(a.tensors(e));return t}default:throw new Error(`unsupported attribute type: ${p.AttributeType[a.type()]}`)}}}n.Attribute=g},7091:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.resolveBackend=n.backend=void 0;const s=o(5038),l=new Map;async function f(u){const p=n.backend;if(p[u]!==void 0&&function(g){const c=g;return"initialize"in c&&typeof c.initialize=="function"&&"createSessionHandler"in c&&typeof c.createSessionHandler=="function"&&"dispose"in c&&typeof c.dispose=="function"}(p[u])){const g=p[u];let c=g.initialize();if(typeof c=="object"&&"then"in c&&(c=await c),c)return l.set(u,g),g}}n.backend={webgl:new s.WebGLBackend},n.resolveBackend=async function u(p){if(!p)return u(["webgl"]);{const g=typeof p=="string"?[p]:p;for(const c of g){const a=l.get(c);if(a)return a;const t=await f(c);if(t)return t}}throw new Error("no available backend to use")}},5038:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WebGLBackend=void 0;const s=o(1670),l=o(6231),f=o(6416),u=o(7305);n.WebGLBackend=class{get contextId(){return s.env.webgl.contextId}set contextId(p){s.env.webgl.contextId=p}get matmulMaxBatchSize(){return s.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(p){s.env.webgl.matmulMaxBatchSize=p}get textureCacheMode(){return s.env.webgl.textureCacheMode}set textureCacheMode(p){s.env.webgl.textureCacheMode=p}get pack(){return s.env.webgl.pack}set pack(p){s.env.webgl.pack=p}get async(){return s.env.webgl.async}set async(p){s.env.webgl.async=p}initialize(){try{return this.glContext=(0,u.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),l.Logger.setWithEnv(s.env),l.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(p){return l.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${p}`),!1}}createSessionHandler(p){return new f.WebGLSessionHandler(this,p)}dispose(){this.glContext.dispose()}}},5107:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoordsGlslLib=void 0;const s=o(2517),l=o(8520),f=o(5060),u=o(7859),p=o(9390);class g extends l.GlslLib{constructor(a){super(a)}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 l.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 l.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 a=this.context.outputTextureLayout;return a.isPacked?this.getPackedOutputSamplingSnippet(a):this.getUnpackedOutputSamplingSnippet(a)}getPackedOutputSamplingSnippet(a){const t=a.unpackedShape,e=[a.width,a.height],r={},i="getOutputCoords";switch(t.length){case 0:r[i]=this.getOutputScalarCoords();break;case 1:r[i]=this.getOutputPacked1DCoords(t,e);break;case 2:r[i]=this.getOutputPacked2DCoords(t,e);break;case 3:r[i]=this.getOutputPacked3DCoords(t,e);break;default:r[i]=this.getOutputPackedNDCoords(t,e)}const h=` + void setOutput(vec4 val) { + ${(0,f.getGlsl)(this.context.glContext.version).output} = val; + } + `;return r.floatTextureSetRGBA=new l.GlslLibRoutine(h),r}getUnpackedOutputSamplingSnippet(a){const t=a.unpackedShape,e=[a.width,a.height],r={},i="getOutputCoords";switch(t.length){case 0:r[i]=this.getOutputScalarCoords();break;case 1:r[i]=this.getOutputUnpacked1DCoords(t,e);break;case 2:r[i]=this.getOutputUnpacked2DCoords(t,e);break;case 3:r[i]=this.getOutputUnpacked3DCoords(t,e);break;case 4:r[i]=this.getOutputUnpacked4DCoords(t,e);break;case 5:r[i]=this.getOutputUnpacked5DCoords(t,e);break;case 6:r[i]=this.getOutputUnpacked6DCoords(t,e);break;default:throw new Error(`Unsupported output dimensionality: ${t.length}`)}const h=` + void setOutput(float val) { + ${(0,f.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0); + } + `;return r.floatTextureSetR=new l.GlslLibRoutine(h),r}getOutputScalarCoords(){return new l.GlslLibRoutine(` + int getOutputCoords() { + return 0; + } + `)}getOutputPacked1DCoords(a,t){const e=t;let r="";return e[0]===1?(r=` + int getOutputCoords() { + return 2 * int(TexCoords.y * ${e[1]}.0); + } + `,new l.GlslLibRoutine(r)):e[1]===1?(r=` + int getOutputCoords() { + return 2 * int(TexCoords.x * ${e[0]}.0); + } + `,new l.GlslLibRoutine(r)):(r=` + int getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); + } + `,new l.GlslLibRoutine(r))}getOutputPacked2DCoords(a,t){let e="";if(s.ArrayUtil.arraysEqual(a,t))return e=` + ivec2 getOutputCoords() { + return 2 * ivec2(TexCoords.xy * vec2(${t[0]}, ${t[1]})); + } + `,new l.GlslLibRoutine(e);const r=t,i=Math.ceil(a[1]/2);return e=` + ivec2 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${r[0]}, ${r[1]})); + + int index = resTexRC.y * ${r[0]} + resTexRC.x; + + // reverse r and c order for packed texture + int r = imod(index, ${i}) * 2; + int c = 2 * (index / ${i}); + + return ivec2(r, c); + } + `,new l.GlslLibRoutine(e)}getOutputPacked3DCoords(a,t){const e=[t[0],t[1]],r=Math.ceil(a[2]/2),i=r*Math.ceil(a[1]/2),h=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + int index = resTexRC.y * ${e[0]} + resTexRC.x; + + int b = index / ${i}; + index -= b * ${i}; + + // reverse r and c order for packed texture + int r = imod(index, ${r}) * 2; + int c = 2 * (index / ${r}); + + return ivec3(b, r, c); + } + `;return new l.GlslLibRoutine(h)}getOutputPackedNDCoords(a,t){const e=[t[0],t[1]],r=Math.ceil(a[a.length-1]/2),i=r*Math.ceil(a[a.length-2]/2);let h=i,m="",_="b, r, c";for(let y=2;y<a.length-1;y++)h*=a[a.length-y-1],m=` + int b${y} = index / ${h}; + index -= b${y} * ${h}; + `+m,_=`b${y}, `+_;const b=` + ivec${a.length} getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + int index = resTexRC.y * ${e[0]} + resTexRC.x; + + ${m} + + int b = index / ${i}; + index -= b * ${i}; + + // reverse r and c order for packed texture + int r = imod(index, ${r}) * 2; + int c = 2 * (index / ${r}); + + return ivec${a.length}(${_}); + } + `;return new l.GlslLibRoutine(b)}getOutputUnpacked1DCoords(a,t){const e=` + int getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + return resTexRC.y * ${t[0]} + resTexRC.x; + } + `;return new l.GlslLibRoutine(e)}getOutputUnpacked2DCoords(a,t){const e=` + ivec2 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + int r = index / ${a[1]}; + int c = index - r * ${a[1]}; + return ivec2(r, c); + } + `;return new l.GlslLibRoutine(e)}getOutputUnpacked3DCoords(a,t){let e="";const r=a.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=a[r-1];for(let _=r-3;_>=0;--_)i[_]=i[_+1]*a[_+1];const h=["r","c","d"],m=i.map((_,b)=>`int ${h[b]} = index / ${_}; ${b===i.length-1?`int ${h[b+1]} = index - ${h[b]} * ${_}`:`index -= ${h[b]} * ${_}`};`).join("");return e=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${m} + return ivec3(r, c, d); + } + `,new l.GlslLibRoutine(e)}getOutputUnpacked4DCoords(a,t){let e="";const r=a.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=a[r-1];for(let _=r-3;_>=0;--_)i[_]=i[_+1]*a[_+1];const h=["r","c","d","d2"],m=i.map((_,b)=>`int ${h[b]} = index / ${_}; ${b===i.length-1?`int ${h[b+1]} = index - ${h[b]} * ${_}`:`index -= ${h[b]} * ${_}`};`).join("");return e=` + ivec4 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${m} + return ivec4(r, c, d, d2); + } + `,new l.GlslLibRoutine(e)}getOutputUnpacked5DCoords(a,t){let e="";const r=a.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=a[r-1];for(let _=r-3;_>=0;--_)i[_]=i[_+1]*a[_+1];const h=["r","c","d","d2","d3"],m=i.map((_,b)=>`int ${h[b]} = index / ${_}; ${b===i.length-1?`int ${h[b+1]} = index - ${h[b]} * ${_}`:`index -= ${h[b]} * ${_}`};`).join("");return e=` + ivec5 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${m} + return ivec5(r, c, d, d2, d3); + } + `,new l.GlslLibRoutine(e)}getOutputUnpacked6DCoords(a,t){let e="";const r=a.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=a[r-1];for(let _=r-3;_>=0;--_)i[_]=i[_+1]*a[_+1];const h=["r","c","d","d2","d3","d4"],m=i.map((_,b)=>`int ${h[b]} = index / ${_}; ${b===i.length-1?`int ${h[b+1]} = index - ${h[b]} * ${_}`:`index -= ${h[b]} * ${_}`};`).join("");return e=` + ivec6 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${m} + return ivec6(r, c, d, d2, d3, d4); + } + `,new l.GlslLibRoutine(e)}getCommonUtilFuncs(){const a={};let t="uvFromFlat";a[t]=new l.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",a[t]=new l.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",a[t]=new l.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",a[t]=new l.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,f.getGlsl)(this.context.glContext.version);return a[t]=new l.GlslLibRoutine(` + float sampleTexture(sampler2D textureSampler, vec2 uv) { + return ${e.texture2D}(textureSampler, uv).r; + }`),a}getInputsSamplingSnippets(){const a={},t=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((e,r)=>{const i=this.context.inputTextureLayouts[r],h=(0,p.generateShaderFuncNameFromInputSamplerName)(e);i.isPacked?a[h]=this.getPackedSamplerFromInput(h,e,i):a[h]=this.getUnpackedSamplerFromInput(h,e,i);const m=(0,p.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(e);i.unpackedShape.length<=t.unpackedShape.length&&(i.isPacked?a[m]=this.getPackedSamplerAtOutputCoords(m,i,t,e):a[m]=this.getUnpackedSamplerAtOutputCoords(m,i,t,e))}),a}getPackedSamplerAtOutputCoords(a,t,e,r){const i=t.unpackedShape,h=e.unpackedShape,m=r,_=(0,p.generateShaderFuncNameFromInputSamplerName)(m),b=i.length,y=h.length,T=s.BroadcastUtil.getBroadcastDims(i,h),w=(0,p.getCoordsDataType)(y),S=y-b;let E;const O=(0,p.getGlChannels)();E=b===0?"":y<2&&T.length>=1?"coords = 0;":T.map(L=>`coords.${O[L+S]} = 0;`).join(` +`);let v="";v=y<2&&b>0?"coords":i.map((L,D)=>`coords.${O[D+S]}`).join(", ");let M="return outputValue;";const $=s.ShapeUtil.size(i)===1,V=s.ShapeUtil.size(h)===1;if(b!==1||$||V){if($&&!V)M=y===1?` + return vec4(outputValue.x, outputValue.x, 0., 0.); + `:` + return vec4(outputValue.x); + `;else if(T.length){const L=b-2,D=b-1;T.indexOf(L)>-1&&T.indexOf(D)>-1?M="return vec4(outputValue.x);":T.indexOf(L)>-1?M="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":T.indexOf(D)>-1&&(M="return vec4(outputValue.xx, outputValue.zz);")}}else M=` + return vec4(outputValue.xy, outputValue.xy); + `;const B=` + vec4 ${a}() { + ${w} coords = getOutputCoords(); + + int lastDim = coords.${O[y-1]}; + coords.${O[y-1]} = coords.${O[y-2]}; + coords.${O[y-2]} = lastDim; + + ${E} + vec4 outputValue = ${_}(${v}); + ${M} + } + `;return new l.GlslLibRoutine(B,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(a,t,e,r){const i=[e.width,e.height],h=[t.width,t.height],m=t.unpackedShape.length,_=e.unpackedShape.length,b=t.unpackedShape,y=e.unpackedShape,T=(0,p.generateShaderFuncNameFromInputSamplerName)(r);if(m===_&&s.ArrayUtil.arraysEqual(h,i)){const V=` + float ${a}() { + return sampleTexture(${r}, TexCoords); + } + `;return new l.GlslLibRoutine(V,["coordinates.sampleTexture"])}const w=(0,p.getCoordsDataType)(_),S=s.BroadcastUtil.getBroadcastDims(b,y),E=_-m;let O;const v=(0,p.getGlChannels)();O=m===0?"":_<2&&S.length>=1?"coords = 0;":S.map(V=>`coords.${v[V+E]} = 0;`).join(` +`);let M="";M=_<2&&m>0?"coords":t.unpackedShape.map((V,B)=>`coords.${v[B+E]}`).join(", ");const $=` + float ${a}() { + ${w} coords = getOutputCoords(); + ${O} + return ${T}(${M}); + } + `;return new l.GlslLibRoutine($,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(a,t,e){switch(e.unpackedShape.length){case 0:return this.getPackedSamplerScalar(a,t);case 1:return this.getPackedSampler1D(a,t,e);case 2:return this.getPackedSampler2D(a,t,e);case 3:return this.getPackedSampler3D(a,t,e);default:return this.getPackedSamplerND(a,t,e)}}getUnpackedSamplerFromInput(a,t,e){const r=e.unpackedShape;switch(r.length){case 0:return this.getUnpackedSamplerScalar(a,t,e);case 1:return this.getUnpackedSampler1D(a,t,e);case 2:return this.getUnpackedSampler2D(a,t,e);case 3:return this.getUnpackedSampler3D(a,t,e);case 4:return this.getUnpackedSampler4D(a,t,e);case 5:return this.getUnpackedSampler5D(a,t,e);case 6:return this.getUnpackedSampler6D(a,t,e);default:throw new Error(`Unsupported dimension ${r.length}-D`)}}getPackedSamplerScalar(a,t){const e=` + vec4 ${a}() { + return ${(0,f.getGlsl)(this.context.glContext.version).texture2D}(${t}, halfCR); + } + `;return new l.GlslLibRoutine(e)}getPackedSampler1D(a,t,e){const r=[e.width,e.height],i=[r[1],r[0]],h=(0,f.getGlsl)(this.context.glContext.version),m=`vec4 ${a}(int index) { + vec2 uv = packedUVfrom1D( + ${i[0]}, ${i[1]}, index); + return ${h.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(m,["coordinates.packedUVfrom1D"])}getPackedSampler2D(a,t,e){const r=e.unpackedShape,i=[e.width,e.height],h=(0,f.getGlsl)(this.context.glContext.version),m=i[0],_=i[1];if(i!=null&&s.ArrayUtil.arraysEqual(r,i)){const w=`vec4 ${a}(int row, int col) { + vec2 uv = (vec2(col, row) + halfCR) / vec2(${_}.0, ${m}.0); + return ${h.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(w)}const b=i,y=Math.ceil(r[1]/2),T=`vec4 ${a}(int row, int col) { + vec2 uv = packedUVfrom2D(${b[1]}, ${b[0]}, ${y}, row, col); + return ${h.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(T,["coordinates.packedUVfrom2D"])}getPackedSampler3D(a,t,e){const r=e.unpackedShape,i=[e.width,e.height],h=[i[0],i[1]],m=(0,f.getGlsl)(this.context.glContext.version);if(r[0]===1){const w=r.slice(1),S=[1,2],E=(0,p.squeezeInputShape)(r,w),O=["b","row","col"],v=JSON.parse(JSON.stringify(e));v.unpackedShape=E;const M=this.getPackedSamplerFromInput(a,t,v),$=`${M.routineBody} + vec4 ${a}(int b, int row, int col) { + return ${a}(${(0,p.getSqueezedParams)(O,S)}); + } `;return new l.GlslLibRoutine($,M.dependencies)}const _=h[0],b=h[1],y=Math.ceil(r[2]/2),T=`vec4 ${a}(int b, int row, int col) { + vec2 uv = packedUVfrom3D( + ${b}, ${_}, ${y*Math.ceil(r[1]/2)}, ${y}, b, row, col); + return ${m.texture2D}(${t}, uv);}`;return new l.GlslLibRoutine(T,["coordinates.packedUVfrom3D"])}getPackedSamplerND(a,t,e){const r=e.unpackedShape,i=r.length,h=[e.width,e.height],m=(0,f.getGlsl)(this.context.glContext.version),_=[h[0],h[1]],b=_[1],y=_[0],T=Math.ceil(r[i-1]/2);let w=T*Math.ceil(r[i-2]/2),S="int b, int row, int col",E=`b * ${w} + (row / 2) * ${T} + (col / 2)`;for(let v=2;v<i-1;v++)S=`int b${v}, `+S,w*=r[i-v-1],E=`b${v} * ${w} + `+E;const O=`vec4 ${a}(${S}) { + int index = ${E}; + int texR = index / ${y}; + int texC = index - texR * ${y}; + vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${y}, ${b}); + return ${m.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(O)}getUnpackedSamplerScalar(a,t,e){const[r,i]=[e.width,e.height];if(r===1&&i===1){const m=` + float ${a}() { + return sampleTexture(${t}, halfCR); + } + `;return new l.GlslLibRoutine(m,["coordinates.sampleTexture"])}const h=` + float ${a}() { + int offset_${t} = coordsToOffset(TexCoords, ${r}, ${i}); + vec2 uv = uvFromFlat(${r}, ${i}, offset_${t}); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(h,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(a,t,e){const r=e.width,i=e.height;if(i===1&&r===1){const m=` + float ${a}(int index) { + return sampleTexture(${t}, halfCR); + } + `;return new l.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(i===1){const m=` + float ${a}(int index) { + vec2 uv = vec2((float(index) + 0.5) / ${r}.0, 0.5); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(r===1){const m=` + float ${a}(int index) { + vec2 uv = vec2(0.5, (float(index) + 0.5) / ${i}.0); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(m,["coordinates.sampleTexture"])}const h=` + float ${a}(int index) { + vec2 uv = uvFromFlat(${r}, ${i}, index); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(h,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(a,t,e){const r=e.unpackedShape,i=[e.height,e.width];if(i!=null&&s.ArrayUtil.arraysEqual(r,i)){const w=` + float ${a}(int row, int col) { + vec2 uv = (vec2(row, col) + halfCR) / vec2(${i[1]}.0, ${i[0]}.0); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(w,["coordinates.sampleTexture"])}const{newShape:h,keptDims:m}=(0,u.squeezeShape)(r),_=h;if(_.length<r.length){const w=(0,p.squeezeInputShape)(r,_),S=JSON.parse(JSON.stringify(e));S.unpackedShape=w;const E=["col","row"],O=` + ${this.getUnpackedSamplerFromInput(a,t,S).routineBody} + float ${a}(int row, int col) { + return ${a}(${(0,p.getSqueezedParams)(E,m)}); + } + `;return new l.GlslLibRoutine(O,["coordinates.sampleTexture"])}const b=i[1],y=i[0];if(y===1){const w=` + float ${a}(int row, int col) { + int offset_${t} = coordsToOffset(TexCoords, ${b}, ${y}); + float index = dot(vec3(row, col, offset_${t}), vec3(${r[1]}, 1, 1)); + vec2 uv = vec2(0.5, (index + 0.5) / ${b}.0); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(w,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(b===1){const w=` + float ${a}(int row, int col) { + int offset_${t} = coordsToOffset(TexCoords, ${b}, ${y}); + float index = dot(vec3(row, col, offset_${t}), vec3(${r[1]}, 1, 1)); + vec2 uv = vec2((index + 0.5) / ${y}.0, 0.5); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(w,["coordinates.sampleTexture","coordinates.coordsToOffset"])}const T=` + float ${a}(int row, int col) { + int index = col * ${r[1]} + row; + vec2 uv = uvFromFlat(${b}, ${y}, index); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(T,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(a,t,e){const r=e.unpackedShape,i=r[1]*r[2],h=r[2],{newShape:m,keptDims:_}=(0,u.squeezeShape)(r),b=m;if(b.length<r.length){const T=(0,p.squeezeInputShape)(r,b),w=["batch","col","row"],S=JSON.parse(JSON.stringify(e));S.unpackedShape=T;const E=this.getUnpackedSamplerFromInput(a,t,S),O=_.reverse(),v=` + ${E.routineBody} + float ${a}(int batch, int row, int col) { + return ${a}(${(0,p.getSqueezedParams)(w,O)}); + } + `;return new l.GlslLibRoutine(v,E.dependencies)}const y=` + float ${a}(int depth, int row, int col) { + // Explicitly use integer operations as dot() only works on floats. + int index = depth * ${i} + col * ${h} + row; + vec2 uv = uvFromFlat(${e.width}, ${e.height}, index); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(y,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(a,t,e){const r=e.unpackedShape,i=r[3],h=r[2]*i,m=` + float ${a}(int row, int col, int depth, int depth2) { + int index = row * ${r[1]*h} + col * ${h} + + depth2 * ${i} + depth; + vec2 uv = uvFromFlat(${e.width}, ${e.height}, index); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(m,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(a,t,e){const r=e.unpackedShape,i=r[4],h=r[3]*i,m=r[2]*h,_=r[1]*m,{newShape:b,keptDims:y}=(0,u.squeezeShape)(r);if(b.length<r.length){const w=(0,p.squeezeInputShape)(r,b),S=["row","col","depth","depth2","depth3"],E=JSON.parse(JSON.stringify(e));E.unpackedShape=w;const O=` + ${this.getUnpackedSamplerFromInput(a,t,E).routineBody} + float ${a}(int row, int col, int depth, int depth2, int depth3) { + return ${a}(${(0,p.getSqueezedParams)(S,y)}); + } + `;return new l.GlslLibRoutine(O,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const T=` + float ${a}(int row, int col, int depth, int depth2, int depth3) { + int index = row * ${_} + col * ${m} + depth * ${h} + + depth3 * ${i} + depth2; + vec2 uv = uvFromFlat(${e.width}, ${e.height}, index); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(T,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(a,t,e){const r=e.unpackedShape,i=r[5],h=r[4]*i,m=r[3]*h,_=r[2]*m,b=r[1]*_,{newShape:y,keptDims:T}=(0,u.squeezeShape)(r);if(y.length<r.length){const S=(0,p.squeezeInputShape)(r,y),E=["row","col","depth","depth2","depth3","depth4"],O=JSON.parse(JSON.stringify(e));O.unpackedShape=S;const v=` + ${this.getUnpackedSamplerFromInput(a,t,O).routineBody} + float ${a}(int row, int col, int depth, + int depth2, int depth3, int depth4) { + return ${a}(${(0,p.getSqueezedParams)(E,T)}); + } + `;return new l.GlslLibRoutine(v,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const w=` + float ${a}(int row, int col, int depth, + int depth2, int depth3, int depth4) { + int index = row * ${b} + col * ${_} + depth * ${m} + + depth2 * ${h} + depth3 * ${i} + depth4; + vec2 uv = uvFromFlat(${e.width}, ${e.height}, index); + return sampleTexture(${t}, uv); + } + `;return new l.GlslLibRoutine(w,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){const a=this.context.outputTextureLayout,t=a.shape.length,e=a.strides,r=a.width,i=a.height,h=[];for(let _=0;_<t-1;++_)h.push(` + c[${_}] = offset / ${e[_]};`),h.push(` + offset -= c[${_}] * ${e[_]};`);h.push(` + c[${t-1}] = offset;`);const m=` + void toVec(vec2 texCoords, out int c[${t}]) { + int offset = coordsToOffset(texCoords, ${r}, ${i}); + ${h.join("")} + } + void toVec(int offset, out int c[${t}]) { + ${h.join("")} + } + `;return{toVec:new l.GlslLibRoutine(m,["coordinates.coordsToOffset"])}}valueFrom(){const a={};return this.context.programInfo.inputNames.forEach((t,e)=>{const r=this.context.inputTextureLayouts[e],i=(r.unpackedShape.length>0?r.unpackedShape:r.shape).length;let h=`_${t}`;a[h]=new l.GlslLibRoutine(this.getValueFromSingle(t,i,r.width,r.height,!1),[`shapeUtils.indicesToOffset${h}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),h+="_T",a[h]=new l.GlslLibRoutine(this.getValueFromSingle(t,i,r.width,r.height,!0),[`shapeUtils.indicesToOffset${h}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),a}getValueFromSingle(a,t,e,r,i){let h=`_${a}`;return i&&(h+="_T"),` + float ${h}(int m[${t}]) { + int offset = indicesToOffset${h}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${r}); + float value = getColorAsFloat(${(0,f.getGlsl)(this.context.glContext.version).texture2D}(${a}, coords)); + return value; + } + `}getPackedValueFrom(a,t,e,r,i){let h=`_${a}_Pack`;return i&&(h+="_T"),` + vec4 ${h}(int m[${t}]) { + int offset = indicesToOffset_${a}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${r}); + return ${(0,f.getGlsl)(this.context.glContext.version).texture2D}(${a}, coords); + } + `}}n.CoordsGlslLib=g},8520:(d,n)=>{var o;Object.defineProperty(n,"__esModule",{value:!0}),n.TopologicalSortGlslRoutines=n.GlslLibRoutineNode=n.GlslLibRoutine=n.GlslLib=n.GlslContext=n.FunctionType=void 0,(o=n.FunctionType||(n.FunctionType={}))[o.ValueBased=0]="ValueBased",o[o.Positional=1]="Positional",n.GlslContext=class{constructor(s,l,f,u){this.glContext=s,this.programInfo=l,this.inputTextureLayouts=f,this.outputTextureLayout=u}},n.GlslLib=class{constructor(s){this.context=s}},n.GlslLibRoutine=class{constructor(s,l){this.routineBody=s,this.dependencies=l}},n.GlslLibRoutineNode=class{constructor(s,l,f){this.name=s,this.dependencies=f||[],l&&(this.routineBody=l)}addDependency(s){s&&this.dependencies.push(s)}},n.TopologicalSortGlslRoutines=class{static returnOrderedNodes(s){if(!s||s.length===0)return[];if(s.length===1)return s;const l=new Set,f=new Set,u=new Array;return this.createOrderedNodes(s,l,f,u),u}static createOrderedNodes(s,l,f,u){for(let p=0;p<s.length;++p)this.dfsTraverse(s[p],l,f,u)}static dfsTraverse(s,l,f,u){if(!s||f.has(s.name))return;if(l.has(s.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");l.add(s.name);const p=s.dependencies;if(p&&p.length>0)for(let g=0;g<p.length;++g)this.dfsTraverse(p[g],l,f,u);u.push(s),f.add(s.name),l.delete(s.name)}}},7341:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EncodingGlslLib=void 0;const s=o(8520);class l extends s.GlslLib{constructor(u){super(u)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new s.GlslLibRoutine(`highp vec4 encode(highp float f) { + return vec4(f, 0.0, 0.0, 0.0); + } + `)}}decodeFloat32(){return{decode:new s.GlslLibRoutine(`highp float decode(highp vec4 rgba) { + return rgba.r; + } + `)}}encodeUint8(){const u=l.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new s.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))); + ${u} + rgba = rgba / 255.0; // values need to be normalized to [0,1] + return rgba; + } + `)}}decodeUint8(){const u=l.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new s.GlslLibRoutine(` + highp float decode(highp vec4 rgba) { + rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] + ${u} + 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 u=new ArrayBuffer(4),p=new Uint32Array(u),g=new Uint8Array(u);if(p[0]=3735928559,g[0]===239)return!0;if(g[0]===222)return!1;throw new Error("unknown endianness")}}n.EncodingGlslLib=l},9894:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FragColorGlslLib=void 0;const s=o(8520),l=o(5060);class f extends s.GlslLib{constructor(p){super(p)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const p=(0,l.getGlsl)(this.context.glContext.version);return{setFragColor:new s.GlslLibRoutine(` + void setFragColor(float value) { + ${p.output} = encode(value); + } + `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new s.GlslLibRoutine(` + float getColorAsFloat(vec4 color) { + return decode(color); + } + `,["encoding.decode"])}}}n.FragColorGlslLib=f},2848:(d,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.replaceInlines=void 0;const o=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;n.replaceInlines=function(s){const l={};let f;for(;(f=o.exec(s))!==null;){const u=f[3].split(",").map(p=>{const g=p.trim().split(" ");return g&&g.length===2?{type:g[0],name:g[1]}:null}).filter(p=>p!==null);l[f[2]]={params:u,body:f[4]}}for(const u in l){const p="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",u),g=new RegExp(p,"gm");for(;(f=g.exec(s))!==null;){const c=f[1],a=f[2],t=f[3].split(","),e=c?`${c} ${a};`:"";let r=l[u].body,i="";l[u].params.forEach((m,_)=>{m&&(i+=`${m.type} ${m.name} = ${t[_]}; +`)}),r=`${i} + ${r}`,r=r.replace("return",`${a} = `);const h=` + ${e} + { + ${r} + } + `;s=s.replace(f[0],h)}}return s.replace(o,"")}},8879:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GlslPreprocessor=void 0;const s=o(8520),l=o(2848),f=o(5483),u=o(5060);n.GlslPreprocessor=class{constructor(p,g,c,a){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new s.GlslContext(p,g,c,a),Object.keys(f.glslRegistry).forEach(e=>{const r=new f.glslRegistry[e](this.context);this.libs[e]=r});const t=this.glslLibRoutineDependencyGraph;for(const e in this.libs){const r=this.libs[e].getFunctions();for(const i in r){const h=e+"."+i;let m;t[h]?(m=t[h],m.routineBody=r[i].routineBody):(m=new s.GlslLibRoutineNode(h,r[i].routineBody),t[h]=m);const _=r[i].dependencies;if(_)for(let b=0;b<_.length;++b)if(t[_[b]])m.addDependency(t[_[b]]);else{const y=new s.GlslLibRoutineNode(_[b]);t[_[b]]=y,m.addDependency(y)}}}}preprocess(){const p=this.context.programInfo;let g=p.shaderSource;return this.context.programInfo.hasMain||(g=`${g} + ${(0,u.getDefaultFragShaderMain)(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),g=(0,l.replaceInlines)(g),`${(0,u.getFragShaderPreamble)(this.context.glContext.version)} + ${this.getUniforms(p.inputNames,p.variables)} + ${this.getImports(g)} + ${g}`}getImports(p){const g=this.selectGlslLibRoutinesToBeIncluded(p);if(g.length===0)return"";let c="";for(let a=0;a<g.length;++a){if(!g[a].routineBody)throw new Error(`Missing body for the Glsl Library routine: ${g[a].name}`);c+=g[a].routineBody+` +`}return c}selectGlslLibRoutinesToBeIncluded(p){const g=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(c=>{const a=c.split(".")[1];p.indexOf(a)!==-1&&g.push(this.glslLibRoutineDependencyGraph[c])}),s.TopologicalSortGlslRoutines.returnOrderedNodes(g)}getUniforms(p,g){const c=[];if(p)for(const a of p)c.push(`uniform sampler2D ${a};`);if(g)for(const a of g)c.push(`uniform ${a.type} ${a.name}${a.arrayLength?`[${a.arrayLength}]`:""};`);return c.join(` +`)}}},5483:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.glslRegistry=void 0;const s=o(5107),l=o(7341),f=o(9894),u=o(2655),p=o(3891);n.glslRegistry={encoding:l.EncodingGlslLib,fragcolor:f.FragColorGlslLib,vec:p.VecGlslLib,shapeUtils:u.ShapeUtilsGlslLib,coordinates:s.CoordsGlslLib}},2655:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ShapeUtilsGlslLib=void 0;const s=o(8520);class l extends s.GlslLib{constructor(u){super(u)}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 u=this.context.outputTextureLayout.shape.length,p={};return this.context.programInfo.inputNames.forEach((g,c)=>{const a=this.context.inputTextureLayouts[c].unpackedShape;if(a.length<=u){const t=a.length,e=u-t,r=`bcastIndices_${g}`;let i="";for(let m=0;m<t;++m)i+=` + realIndices[${m}] = int( mod(float(bcastedIndices[${e+m}]), ${a[m]}.0) ); + `;const h=` + void ${r} (int bcastedIndices[${u}], out int realIndices[${t}]) { + ${i} + } + `;p[r]=new s.GlslLibRoutine(h)}}),p}bcastMatmulIndex(){const u=this.context.outputTextureLayout.shape.length,p={};return this.context.programInfo.inputNames.forEach((g,c)=>{const a=this.context.inputTextureLayouts[c].shape;if(!(a.length<2||a.length>u)){const t=a.length,e=u-t,r=`bcastMatmulIndices_${g}`;let i="";for(let m=0;m<t-2;++m)i+=` + realIndices[${m}] = int( mod(float(bcastedIndices[${e+m}]), ${a[m]}.0) ); + `;const h=` + void ${r}(int bcastedIndices[${u}], out int realIndices[${t}]) { + ${i} + realIndices[${t-1}] = bcastedIndices[${u-1}]; + realIndices[${t-2}] = bcastedIndices[${u-2}]; + } + `;p[r]=new s.GlslLibRoutine(h)}}),p}indicesToOffset(){const u={};return this.context.programInfo.inputNames.forEach((p,g)=>{const c=this.context.inputTextureLayouts[g].shape,a=this.context.inputTextureLayouts[g].strides,t=c.length;let e=`indicesToOffset_${p}`;u[e]=new s.GlslLibRoutine(l.indexToOffsetSingle(e,t,a)),e=`indicesToOffset_${p}_T`,u[e]=new s.GlslLibRoutine(l.indexToOffsetSingle(e,t,a.slice().reverse()))}),u}static indexToOffsetSingle(u,p,g){let c="";for(let a=p-1;a>=0;--a)c+=` + offset += indices[${a}] * ${g[a]}; + `;return` + int ${u}(int indices[${p}]) { + int offset = 0; + ${c} + return offset; + } + `}offsetToIndices(){const u={};return this.context.programInfo.inputNames.forEach((p,g)=>{const c=this.context.inputTextureLayouts[g].shape,a=this.context.inputTextureLayouts[g].strides,t=c.length;let e=`offsetToIndices_${p}`;u[e]=new s.GlslLibRoutine(l.offsetToIndicesSingle(e,t,a)),e=`offsetToIndices_${p}_T`,u[e]=new s.GlslLibRoutine(l.offsetToIndicesSingle(e,t,a.slice().reverse()))}),u}static offsetToIndicesSingle(u,p,g){const c=[];for(let a=0;a<p-1;++a)c.push(` + indices[${a}] = offset / ${g[a]};`),c.push(` + offset -= indices[${a}] * ${g[a]};`);return c.push(` + indices[${p-1}] = offset;`),` + void ${u}(int offset, out int indices[${p}]) { + ${c.join("")} + } + `}incrementIndices(){const u={};return this.context.programInfo.inputNames.forEach((p,g)=>{const c=this.context.inputTextureLayouts[g].shape,a=c.length,t=`incrementIndices_${p}`;let e="";for(let i=0;i<a;++i)e+=` + shape[${i}] = ${c[i]};`;const r=` + void ${t}(int axis, out int indices[${a}]) { + int shape[${a}]; + ${e}; + for(int i = ${a} -1 ; i >= 0; --i) { + if(i > axis) continue; + indices[i] += 1; + if(indices[i] < shape[i]) { + break; + } + indices[i] = 0; + } + } + `;u[t]=new s.GlslLibRoutine(r)}),u}}n.ShapeUtilsGlslLib=l},5060:(d,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getDefaultFragShaderMain=n.getFragShaderPreamble=n.getVertexShaderSource=n.getGlsl=void 0;const o={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},s={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function l(f){return f===1?o:s}n.getGlsl=l,n.getVertexShaderSource=function(f){const u=l(f);return`${u.version} + precision highp float; + ${u.attribute} vec3 position; + ${u.attribute} vec2 textureCoord; + + ${u.varyingVertex} vec2 TexCoords; + + void main() + { + gl_Position = vec4(position, 1.0); + TexCoords = textureCoord; + }`},n.getFragShaderPreamble=function(f){const u=l(f);return`${u.version} + precision highp float; + precision highp int; + precision highp sampler2D; + ${u.varyingFrag} vec2 TexCoords; + ${u.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); + } + + `},n.getDefaultFragShaderMain=function(f,u){return` + void main() { + int indices[${u}]; + toVec(TexCoords, indices); + vec4 result = vec4(process(indices)); + ${l(f).output} = result; + } + `}},3891:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.VecGlslLib=void 0;const s=o(8520);class l extends s.GlslLib{constructor(u){super(u)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const u=this.context.outputTextureLayout.shape.length,p={add:"+=",sub:"-=",mul:"*=",div:"/="},g={};for(const c in p){const a=`${c}Vec`;let t="";for(let r=0;r<u;++r)t+=` + dest[${r}] ${p[c]} src[${r}]; + `;const e=` + void ${a}(int src[${u}], out int dest[${u}]) { + ${t} + } + `;g[a]=new s.GlslLibRoutine(e)}return g}copyVec(){const u=this.context.outputTextureLayout.shape.length;let p="";for(let c=0;c<u;++c)p+=` + dest[${c}] = src[${c}]; + `;const g=` + void copyVec(int src[${u}], out int dest[${u}]) { + ${p} + } + `;return{copyVec:new s.GlslLibRoutine(g)}}setVecItem(){const u=this.context.outputTextureLayout.shape.length;let p=` + if(index < 0) + index =${u} + index; + if (index == 0) + m[0] = value; + `;for(let c=1;c<u-1;++c)p+=` + else if (index == ${c}) + m[${c}] = value; + `;p+=` + else + m[${u-1}] = value; + `;const g=` + void setVecItem(out int m[${u}], int index, int value) { + ${p} + } + `;return{setVecItem:new s.GlslLibRoutine(g)}}getVecItem(){const u=this.context.outputTextureLayout.shape.length;let p=` + if(index < 0) + index = ${u} + index; + if (index == 0) + return m[0]; + `;for(let c=1;c<u-1;++c)p+=` + else if (index == ${c}) + return m[${c}]; + `;p+=` + else + return m[${u-1}]; + `;const g=` + int getVecItem(int m[${u}], int index) { + ${p} + } + `;return{getVecItem:new s.GlslLibRoutine(g)}}}n.VecGlslLib=l},8316:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WebGLInferenceHandler=void 0;const s=o(6231),l=o(9162),f=o(2517),u=o(2403),p=o(7019),g=o(8710),c=o(5611),a=o(4057),t=o(2039);n.WebGLInferenceHandler=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,r){return(0,a.calculateTextureWidthAndHeight)(this.session.layoutStrategy,e,r)}executeProgram(e,r){if(r.length<e.inputNames.length)throw new Error(`Input size mustn't be less than ${e.inputNames.length}.`);if(e.inputNames.length!==e.inputTypes.length)throw new Error("input names size does not match input types");const i=[];for(let T=0;T<e.inputNames.length;++T)i[T]=this.getOrCreateTextureData(r[T],e.inputTypes[T]);const h=((T,w)=>{const S=w.map(O=>`${O.unpackedShape.join(",")};${O.width}x${O.height}`).join("_");let E=T.name;return T.cacheHint&&(E+="["+T.cacheHint+"]"),E+=":"+S,E})(e,i);let m=this.session.programManager.getArtifact(h);const _=m?m.programInfo:typeof e.get=="function"?e.get():e,b=(0,a.createTextureLayoutFromTextureType)(this.session.layoutStrategy,_.output.dims,_.output.textureType),y=this.createTextureData(b,_.output.type);return m||(m=this.session.programManager.build(_,i,y),this.session.programManager.setArtifact(h,m)),this.runProgram(m,i,y),y}run(e,r){return this.executeProgram(e,r).tensor}runProgram(e,r,i){for(let h=0;h<r.length;++h)if(!!r[h].isPacked!=(e.programInfo.inputTypes[h]===t.TextureType.packed))throw new Error(`input[${h}] property packed inconsistent`);if(!!i.isPacked!=(e.programInfo.output.textureType===t.TextureType.packed))throw new Error("output property packed inconsistent");this.session.programManager.run(e,r,i)}getOrCreateTextureData(e,r){let i=this.getTextureData(e.dataId,r===t.TextureType.packed);if(!i&&(i=this.getTextureData(e.dataId,r!==t.TextureType.packed),i))return r===t.TextureType.packed?this.pack(i):this.unpack(i);if(!i){const h=(0,a.createTextureLayoutFromTextureType)(this.session.layoutStrategy,e.dims,r);if(r===t.TextureType.packedLastDimension){const b=e.dims;if(b.length===4){const y=[b[0],Math.ceil(b[1]*b[2]*b[3]/4)],T=(0,a.createTextureLayoutFromTextureType)(this.session.layoutStrategy,y,r);let w=e.numberData;if(b[1]*b[2]*b[3]%4!=0){const S=b[0],E=b[1]*b[2]*b[3],O=Math.ceil(E*1/4)*4;w=new Float32Array(S*O);for(let v=0;v<S;++v){const M=v*E,$=v*O+v%1*E;w.set(e.numberData.subarray(M,M+E),$)}}return this.createTextureData(T,e.type,w,e,1)}}if(r===t.TextureType.packed){const m=(0,a.createTextureLayoutFromShape)(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),_=this.createTextureData(m,e.type,e.numberData,e,1);i=this.pack(_)}else i=this.createTextureData(h,e.type,e.numberData,e,1)}return i}createTextureDataFromLayoutBindTensor(e,r,i,h){return this.createTextureData(e,r,i,h,1)}createTextureData(e,r,i,h,m){s.Logger.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);const _=this.session.textureManager.createTextureFromLayout(r,e,i,m);return this.createTextureDataFromTexture(e,r,_,h)}reshapeUnpacked(e,r){const i=this.getOrCreateTextureData(e,t.TextureType.unpacked),h={channels:i.channels,height:i.height,width:i.width,shape:r.length!==0?r:[1],strides:f.ShapeUtil.computeStrides(r),unpackedShape:r};return this.createTextureDataFromTexture(h,e.type,i.texture).tensor}reshapePacked(e,r){const i=this.getOrCreateTextureData(e,t.TextureType.packed);if((0,p.isReshapeCheap)(e.dims,r)){const y={channels:i.channels,height:i.height,width:i.width,shape:r.length!==0?r:[1],strides:f.ShapeUtil.computeStrides(r),unpackedShape:r,isPacked:!0};return this.createTextureDataFromTexture(y,e.type,i.texture).tensor}const h=(0,p.processDims3D)(e.dims),m=(0,p.processDims3D)(r),_=this.reshapePacked(e,h),b=this.run((0,p.createPackedReshape3DProgramInfoLoader)(this,_,m),[_]);return this.reshapePacked(b,r)}cast(e,r){const i=this.getOrCreateTextureData(e,t.TextureType.unpacked);return this.createTextureDataFromTexture(i,r,i.texture).tensor}createTextureDataFromTexture(e,r,i,h,m){const _=Object.assign(Object.assign({},e),{tensor:h||new l.Tensor(e.unpackedShape,r,b=>this.readTexture(_),async b=>this.readTextureAsync(_),void 0,m),texture:i});return this.setTextureData(_.tensor.dataId,_,e.isPacked),_}getTextureData(e,r=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,r):r?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,r,i=!1){this.session.isInitializer(e)?this.session.setTextureData(e,r,i):(i?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,r)}isTextureLayoutCached(e,r=!1){return!!this.getTextureData(e.dataId,r)}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,g.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,g.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,u.createPackProgramInfoLoader)(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram((0,c.createUnpackProgramInfoLoader)(this,e.tensor),[e.tensor])}}},1640:function(d,n,o){var s=this&&this.__createBinding||(Object.create?function(Y,ee,te,he){he===void 0&&(he=te);var Oe=Object.getOwnPropertyDescriptor(ee,te);Oe&&!("get"in Oe?!ee.__esModule:Oe.writable||Oe.configurable)||(Oe={enumerable:!0,get:function(){return ee[te]}}),Object.defineProperty(Y,he,Oe)}:function(Y,ee,te,he){he===void 0&&(he=te),Y[he]=ee[te]}),l=this&&this.__setModuleDefault||(Object.create?function(Y,ee){Object.defineProperty(Y,"default",{enumerable:!0,value:ee})}:function(Y,ee){Y.default=ee}),f=this&&this.__importStar||function(Y){if(Y&&Y.__esModule)return Y;var ee={};if(Y!=null)for(var te in Y)te!=="default"&&Object.prototype.hasOwnProperty.call(Y,te)&&s(ee,Y,te);return l(ee,Y),ee};Object.defineProperty(n,"__esModule",{value:!0}),n.WEBGL_OP_RESOLVE_RULES=void 0;const u=o(2898),p=f(o(7839)),g=o(4196),c=o(2069),a=o(8138),t=o(9663),e=o(5193),r=o(7992),i=o(1253),h=o(4776),m=o(6572),_=o(3346),b=o(5623),y=o(2870),T=o(2143),w=o(4939),S=o(718),E=o(2268),O=o(8117),v=o(2278),M=o(5524),$=o(5975),V=o(3933),B=o(6558),L=o(5723),D=o(3738),k=f(o(4909)),F=o(8428),Q=o(9793);n.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",k.abs],["Acos","","7+",k.acos],["Add","","7+",p.add],["And","","7+",p.and],["Asin","","7+",k.asin],["Atan","","7+",k.atan],["AveragePool","","7+",T.averagePool,T.parseAveragePoolAttributes],["BatchNormalization","","7+",u.batchNormalization,u.parseBatchNormalizationAttributes],["Cast","","6+",g.cast,g.parseCastAttributes],["Ceil","","6+",k.ceil],["Clip","","6-10",k.clip,k.parseClipAttributes],["Clip","","11+",k.clipV11],["Concat","","4+",c.concat,c.parseConcatAttributes],["Conv","","1+",a.conv,a.parseConvAttributes],["ConvTranspose","","1+",t.convTranspose,t.parseConvTransposeAttributes],["Cos","","7+",k.cos],["Div","","7+",p.div],["Dropout","","7+",k.identity],["DepthToSpace","","1+",e.depthToSpace,e.parseDepthToSpaceAttributes],["Equal","","7+",p.equal],["Elu","","6+",k.elu,k.parseEluAttributes],["Exp","","6+",k.exp],["Flatten","","1+",r.flatten,r.parseFlattenAttributes],["Floor","","6+",k.floor],["FusedConv","com.microsoft","1+",a.conv,a.parseConvAttributes],["Gather","","1+",i.gather,i.parseGatherAttributes],["Gemm","","7-10",h.gemm,h.parseGemmAttributesV7],["Gemm","","11+",h.gemm,h.parseGemmAttributesV11],["GlobalAveragePool","","1+",T.globalAveragePool,T.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",T.globalMaxPool],["Greater","","7+",p.greater],["Identity","","1+",k.identity],["ImageScaler","","1+",m.imageScaler,m.parseImageScalerAttributes],["InstanceNormalization","","6+",_.instanceNormalization,_.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",k.leakyRelu,k.parseLeakyReluAttributes],["Less","","7+",p.less],["Log","","6+",k.log],["MatMul","","1+",b.matMul,b.parseMatMulAttributes],["MaxPool","","1+",T.maxPool,T.parseMaxPoolAttributes],["Mul","","7+",p.mul],["Neg","","6+",k.neg],["Not","","1+",k.not],["Or","","7+",p.or],["Pad","","2-10",y.padV2,y.parsePadAttributesV2],["Pad","","11+",y.padV11,y.parsePadAttributesV11],["Pow","","7+",p.pow],["PRelu","","7+",p.pRelu],["ReduceLogSum","","1+",w.reduceLogSum,w.parseReduceAttributes],["ReduceMax","","1+",w.reduceMax,w.parseReduceAttributes],["ReduceMean","","1+",w.reduceMean,w.parseReduceAttributes],["ReduceMin","","1+",w.reduceMin,w.parseReduceAttributes],["ReduceProd","","1+",w.reduceProd,w.parseReduceAttributes],["ReduceSum","","1-12",w.reduceSum,w.parseReduceAttributes],["ReduceSumSquare","","1+",w.reduceLogSumSquare,w.parseReduceAttributes],["Relu","","6+",k.relu],["Reshape","","5+",S.reshape],["Resize","","10",E.resize,E.parseResizeAttributesV10],["Resize","","11+",E.resize,E.parseResizeAttributesV11],["Shape","","1+",O.shape],["Sigmoid","","6+",k.sigmoid],["Sin","","7+",k.sin],["Slice","","10+",v.sliceV10],["Slice","","1-9",v.slice,v.parseSliceAttributes],["Softmax","","1-12",M.softmax,M.parseSoftmaxAttributes],["Softmax","","13+",M.softmaxV13,M.parseSoftmaxAttributesV13],["Split","","2-12",$.split,$.parseSplitAttributes],["Sqrt","","6+",k.sqrt],["Squeeze","","1-12",V.squeeze,V.parseSqueezeAttributes],["Squeeze","","13+",V.squeezeV13],["Sub","","7+",p.sub],["Sum","","6+",B.sum],["Tan","","7+",k.tan],["Tanh","","6+",k.tanh],["Tile","","6+",L.tile],["Transpose","","1+",D.transpose,D.parseTransposeAttributes],["Upsample","","7-8",Q.upsample,Q.parseUpsampleAttributesV7],["Upsample","","9",Q.upsample,Q.parseUpsampleAttributesV9],["Unsqueeze","","1-12",F.unsqueeze,F.parseUnsqueezeAttributes],["Unsqueeze","","13+",F.unsqueezeV13],["Xor","","7+",p.xor]]},2898:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseBatchNormalizationAttributes=n.batchNormalization=void 0;const s=o(246),l=o(5060),f=o(2039),u={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[f.TextureType.unpacked,f.TextureType.unpacked,f.TextureType.unpacked,f.TextureType.unpacked,f.TextureType.unpacked]};n.batchNormalization=(c,a,t)=>(g(a),[c.run(Object.assign(Object.assign({},u),{cacheHint:t.cacheKey,get:()=>p(c,a,t)}),a)]),n.parseBatchNormalizationAttributes=c=>{const a=c.attributes.getFloat("epsilon",1e-5),t=c.attributes.getFloat("momentum",.9),e=c.attributes.getInt("spatial",1);return(0,s.createAttributeWithCacheKey)({epsilon:a,momentum:t,spatial:e})};const p=(c,a,t)=>{const e=(0,l.getGlsl)(c.session.backend.glContext.version),r=a[0].dims.length,[i,h]=c.calculateTextureWidthAndHeight(a[1].dims,f.TextureType.unpacked),m=` + float process(int[${r}] indices) { + vec2 position = offsetToCoords(indices[1], ${i}, ${h}); + 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({},u),{output:{dims:a[0].dims,type:a[0].type,textureType:f.TextureType.unpacked},shaderSource:m})},g=c=>{if(!c||c.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const a=c[0],t=c[1],e=c[2],r=c[3],i=c[4];if(a.dims.length<3||t.dims.length!==1||e.dims.length!==1||r.dims.length!==1||i.dims.length!==1)throw new Error("invalid input shape.");if(t.dims[0]!==a.dims[1]||e.dims[0]!==a.dims[1]||r.dims[0]!==a.dims[1]||i.dims[0]!==a.dims[1])throw new Error("invalid input shape.");if(a.type!=="float32"&&a.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("invalid input tensor types.")}},7839:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.xor=n.sub=n.pRelu=n.pow=n.or=n.mul=n.less=n.greater=n.equal=n.div=n.and=n.add=n.glslPRelu=n.glslPow=n.glslXor=n.glslOr=n.glslAnd=n.glslLess=n.glslGreater=n.glslEqual=n.glslSub=n.glslMul=n.glslDiv=n.glslAdd=void 0;const s=o(2517),l=o(8520),f=o(5060),u=o(2039);function p(){const w="add_";return{body:` + float ${w}(float a, float b) { + return a + b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 + v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function g(){const w="div_";return{body:` + float ${w}(float a, float b) { + return a / b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 / v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function c(){const w="mul_";return{body:` + float ${w}(float a, float b) { + return a * b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 * v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function a(){const w="sub_";return{body:` + float ${w}(float a, float b) { + return a - b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 - v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function t(){const w="equal_";return{body:` + float ${w}(float a, float b) { + return float(a == b); + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4(equal(v1, v2)); + } + `,name:w,type:l.FunctionType.ValueBased}}function e(){const w="greater_";return{body:` + float ${w}(float a, float b) { + return float(a > b); + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4( v1.r > v2.r , + v1.g > v2.g, + v1.b > v2.b, + v1.a > v2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function r(){const w="less_";return{body:` + float ${w}(float a, float b) { + return float(a < b); + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4( v1.r < v2.r , + v1.g < v2.g, + v1.b < v2.b, + v1.a < v2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function i(){const w="and_";return{body:` + float ${w}(float a, float b) { + return float( bool(a) && bool(b) ); + } + vec4 ${w}(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:w,type:l.FunctionType.ValueBased}}function h(){const w="or_";return{body:` + float ${w}(float a, float b) { + return float( bool(a) || bool(b) ); + } + vec4 ${w}(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:w,type:l.FunctionType.ValueBased}}function m(){const w="xor_";return{body:` + float ${w}(float a, float b) { + return float( bool(a) ^^ bool(b) ); + } + vec4 ${w}(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:w,type:l.FunctionType.ValueBased}}function _(){return function(w){const S=`${w}_`;return{body:` + float ${S}(float a, float b) { + return ${w}(a, b); + } + vec4 ${S}(vec4 v1, vec4 v2) { + return ${w}(v1, v2); + } + `,name:S,type:l.FunctionType.ValueBased}}("pow")}function b(){const w="prelu_";return{body:` + float ${w}(float a, float b) { + return a < 0.0 ? a * b: a; + } + vec4 ${w}(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:w,type:l.FunctionType.ValueBased}}n.glslAdd=p,n.glslDiv=g,n.glslMul=c,n.glslSub=a,n.glslEqual=t,n.glslGreater=e,n.glslLess=r,n.glslAnd=i,n.glslOr=h,n.glslXor=m,n.glslPow=_,n.glslPRelu=b;const y=(w,S,E,O=S[0].type,v)=>{const M=w.session.pack?u.TextureType.packed:u.TextureType.unpacked;return{name:E.name,inputNames:["A","B"],inputTypes:[M,M],cacheHint:v,get:()=>T(w,S,E,O)}},T=(w,S,E,O=S[0].type)=>{const v=w.session.pack?u.TextureType.packed:u.TextureType.unpacked,M=!s.ShapeUtil.areEqual(S[0].dims,S[1].dims);let $=S[0].dims;const V=w.session.pack;if(M){const D=s.BroadcastUtil.calcShape(S[0].dims,S[1].dims,!1);if(!D)throw new Error("Can't perform binary op on the given tensors");$=D;const k=$.length,F=S[0].dims.length!==0?S[0].dims.length:1,Q=S[1].dims.length!==0?S[1].dims.length:1,Y=S[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",ee=S[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",te=(0,f.getGlsl)(w.session.backend.glContext.version),he=V?` + ${E.body} + void main() { + vec4 a = getAAtOutCoords(); + vec4 b = getBAtOutCoords(); + vec4 result = ${E.name}(a, b); + ${te.output} = result; + }`:` + ${E.body} + float process(int indices[${k}]) { + int aindices[${F}]; + int bindices[${Q}]; + ${Y} + ${ee} + return ${E.name}(_A(aindices), _B(bindices)); + }`;return{name:E.name,inputNames:["A","B"],inputTypes:[v,v],output:{dims:$,type:O,textureType:v},shaderSource:he,hasMain:V}}const B=(0,f.getGlsl)(w.session.backend.glContext.version),L=` + ${E.body} + void main() { + vec4 v1 = ${B.texture2D}(A, TexCoords); + vec4 v2 = ${B.texture2D}(B, TexCoords); + vec4 result = ${E.name}(v1, v2); + ${B.output} = result; + } + `;return{name:E.name,inputNames:["A","B"],inputTypes:[v,v],output:{dims:S[0].dims,type:O,textureType:v},shaderSource:L,hasMain:!0}};n.add=(w,S)=>[w.run(y(w,S,p()),S)],n.and=(w,S)=>[w.run(y(w,S,i(),"bool"),S)],n.div=(w,S)=>[w.run(y(w,S,g()),S)],n.equal=(w,S)=>[w.run(y(w,S,t(),"bool"),S)],n.greater=(w,S)=>[w.run(y(w,S,e(),"bool"),S)],n.less=(w,S)=>[w.run(y(w,S,r(),"bool"),S)],n.mul=(w,S)=>[w.run(y(w,S,c()),S)],n.or=(w,S)=>[w.run(y(w,S,h(),"bool"),S)],n.pow=(w,S)=>[w.run(y(w,S,_()),S)],n.pRelu=(w,S)=>[w.run(y(w,S,b()),S)],n.sub=(w,S)=>[w.run(y(w,S,a()),S)],n.xor=(w,S)=>[w.run(y(w,S,m(),"bool"),S)]},4196:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseCastAttributes=n.cast=void 0;const s=o(2517);n.cast=(f,u,p)=>(l(u),[f.cast(u[0],p)]),n.parseCastAttributes=f=>s.ProtoUtil.tensorDataTypeFromProto(f.attributes.getInt("to"));const l=f=>{if(!f||f.length!==1)throw new Error("Cast requires 1 input.");if(f[0].type==="string")throw new Error("Invalid input type.")}},1163:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createPackedConcatProgramInfoLoader=void 0;const s=o(5060),l=o(2039),f=o(9390),u=o(2827);n.createPackedConcatProgramInfoLoader=(g,c,a)=>{const t=(e=c.length,r=a.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:e},(i,h)=>`X${h}`),inputTypes:Array(e).fill(l.TextureType.packed),cacheHint:r});var e,r;return Object.assign(Object.assign({},t),{get:()=>((i,h,m,_)=>{const b=m[0].dims.slice();if(_>=b.length||_<-1*b.length)throw new Error("axis specified for concat doesn't match input dimensionality");_<0&&(_=b.length+_);const y=b.slice(0);for(let Y=1;Y<m.length;Y++){const ee=m[Y].dims.slice();for(let te=0;te<b.length;te++)if(te===_)y[_]+=ee[te];else if(b[te]!==ee[te])throw new Error("non concat dimensions must match")}const T=y.length,w=(0,u.getChannels)("coords",T),S=(0,f.getCoordsDataType)(T),E=(0,u.unpackFromChannel)(),O=m.map(Y=>Y.dims),v=(0,f.getGlChannels)(T),M=new Array(O.length-1);M[0]=O[0][_];for(let Y=1;Y<M.length;Y++)M[Y]=M[Y-1]+O[Y][_];const $=v[_],V=v.slice(-2),B=v.join();let L=`if (${$} < ${M[0]}) { + return getChannel( + getX0(${B}), vec2(${V.join()})); + }`;for(let Y=1;Y<M.length;Y++){const ee=M[Y-1];L+=` + if (${$} < ${M[Y]} && ${$} >= ${M[Y-1]}) { + return getChannel( + getX${Y}(${p(v,$,ee)}), + vec2(${p(V,$,ee)})); + }`}const D=M.length,k=M[M.length-1];L+=` + return getChannel( + getX${D}(${p(v,$,k)}), + vec2(${p(V,$,k)}));`;const F=(0,s.getGlsl)(i.session.backend.glContext.version),Q=` + ${E} + float getValue(${v.map(Y=>"int "+Y)}) { + ${L} + } + + void main() { + ${S} coords = getOutputCoords(); + int lastDim = coords.${v[T-1]}; + coords.${v[T-1]} = coords.${v[T-2]}; + coords.${v[T-2]} = lastDim; + + vec4 result = vec4(getValue(${w}), 0., 0., 0.); + + ${w[T-1]} = ${w[T-1]} + 1; + if (${w[T-1]} < ${y[T-1]}) { + result.g = getValue(${w}); + } + + ${w[T-2]} = ${w[T-2]} + 1; + if (${w[T-2]} < ${y[T-2]}) { + result.a = getValue(${w}); + } + + ${w[T-1]} = ${w[T-1]} - 1; + if (${w[T-2]} < ${y[T-2]} && + ${w[T-1]} < ${y[T-1]}) { + result.b = getValue(${w}); + } + ${F.output} = result; + } + `;return Object.assign(Object.assign({},h),{output:{dims:y,type:m[0].type,textureType:l.TextureType.packed},shaderSource:Q,hasMain:!0})})(g,t,c,a.axis)})};const p=(g,c,a)=>{const t=g.indexOf(c);return g.map((e,r)=>r===t?`${e} - ${a}`:e).join()}},2069:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseConcatAttributes=n.concat=void 0;const s=o(246),l=o(2039),f=o(1163);n.concat=(e,r,i)=>(t(r),e.session.pack&&r[0].dims.length>1?[e.run((0,f.createPackedConcatProgramInfoLoader)(e,r,i),r)]:[e.run(u(e,r,i),r)]);const u=(e,r,i)=>{const h=(m=r.length,_=i.cacheKey,{name:"Concat",inputNames:Array.from({length:m},(b,y)=>`X${y}`),inputTypes:Array(m).fill(l.TextureType.unpacked),cacheHint:_});var m,_;return Object.assign(Object.assign({},h),{get:()=>((b,y,T,w)=>{const S=T[0].dims.slice();if(w>=S.length||w<-1*S.length)throw new Error("axis specified for concat doesn't match input dimensionality");w<0&&(w=S.length+w);const E=S.slice(0);for(let B=1;B<T.length;B++){const L=T[B].dims.slice();for(let D=0;D<S.length;D++)if(D===w)E[w]+=L[D];else if(S[D]!==L[D])throw new Error("non concat dimensions must match")}const O=E.length,v=new Array(T.length);let M=0;for(let B=0;B<v.length;++B)M+=T[B].dims[w],v[B]=M;let $="";$=T.length<5?p(v):g(v);const V=` + ${c(T.length,O)} + ${a(v)} + ${$} + float process(int indices[${O}]) { + int textureIndex = getTextureWhereDataResides (indices[${w}]); + + if(textureIndex != 0) { + indices[${w}] = indices[${w}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1))); + } + + return fetchDataFromCorrectTexture(textureIndex, indices); + }`;return Object.assign(Object.assign({},y),{output:{dims:E,type:T[0].type,textureType:l.TextureType.unpacked},shaderSource:V})})(0,h,r,i.axis)})},p=e=>`int getTextureWhereDataResides(int index) { + ${e.map((r,i)=>`if(index<${r}) {return ${i};} +`).join("")} + }`,g=e=>p(e),c=(e,r)=>{const i=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let h=0;h<e;++h)h===0?i.push(` if (textureIndex == ${h}) { return _X${h}(indices); }`):h===e-1?i.push(` else { return _X${h}(indices); }`):i.push(` else if (textureIndex == ${h}) { return _X${h}(indices); }`);return i.push(" }"),i.join(` +`)},a=e=>{const r=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let i=0;i<e.length;++i)i===0?r.push(` if (index == ${i}) { return ${e[i]}; }`):i===e.length-1?r.push(` else { return ${e[i]}; }`):r.push(` else if (index == ${i}) { return ${e[i]}; }`);return r.push(" }"),r.join(` +`)};n.parseConcatAttributes=e=>(0,s.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis")});const t=e=>{if(!e||e.length<1)throw new Error("too few inputs");const r=e[0].type,i=e[0].dims.length;if(r==="string")throw new Error("string tensor is not supported yet");for(const h of e){if(h.type!==r)throw new Error("input tensors should be one type");if(h.dims.length!==i)throw new Error("input tensors should have the same shape")}}},4770:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createUnpackedGroupedConvProgramInfoLoader=void 0;const s=o(6231),l=o(5060),f=o(2039),u=o(8138),p=o(2823);n.createUnpackedGroupedConvProgramInfoLoader=(g,c,a)=>{const t=(e=c.length>2,r=a.cacheKey,{name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[f.TextureType.unpacked,f.TextureType.unpacked,f.TextureType.unpacked]:[f.TextureType.unpacked,f.TextureType.unpacked],cacheHint:r});var e,r;return Object.assign(Object.assign({},t),{get:()=>((i,h,m,_)=>{const b=h.length>2?"value += getBias(output_channel);":"",y=h[0].dims.slice(),T=h[1].dims.slice(),w=T[0]/_.group;s.Logger.verbose("GroupedConv",`autpPad:${_.autoPad}, dilations:${_.dilations}, group:${_.group}, kernelShape:${_.kernelShape}, pads:${_.pads}, strides:${_.strides}`);const S=(0,u.calculateOutputShape)(y,T,_.dilations,_.pads,_.strides),E=(0,l.getGlsl)(i.session.backend.glContext.version),{activationFunction:O,applyActivation:v}=(0,p.getActivationSnippet)(_),M=` + const ivec2 strides = ivec2(${_.strides[0]}, ${_.strides[1]}); + const ivec2 pads = ivec2(${_.pads[0]}, ${_.pads[1]}); + ${O} + 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 / ${w}; + + float value = 0.0; + for (int wInChannel = 0; wInChannel < ${T[1]}; wInChannel++) { + int input_channel = group_id * ${T[1]} + wInChannel; + for (int wHeight = 0; wHeight < ${T[2]}; wHeight++) { + int xHeight = xRCCorner.x + wHeight * ${_.dilations[0]}; + + if (xHeight < 0 || xHeight >= ${y[2]}) { + continue; + } + + for (int wWidth = 0; wWidth < ${T[3]}; wWidth++) { + int xWidth = xRCCorner.y + wWidth * ${_.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; + } + } + } + ${b} + ${v} + ${E.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},m),{output:{dims:S,type:h[0].type,textureType:f.TextureType.unpacked},shaderSource:M,hasMain:!0})})(g,c,t,a)})}},1386:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.conv2DPacked=n.conv2DPackedPointwise=void 0;const s=o(8138),l=o(8555),f=o(708);n.conv2DPackedPointwise=(u,p,g)=>{const c=p[0].dims,a=p[1].dims,t=(0,s.calculateOutputShape)(c,a,g.dilations,g.pads,g.strides),e=u.reshapePacked(p[0],[c[1],c[2]*c[3]]),r=u.reshapePacked(p[1],[a[0],a[1]]),i=p.length>2?[r,e,p[2]]:[r,e],h=u.run((0,f.createPackedMatmulProgramInfoLoader)(u,i,g),i);return u.reshapePacked(h,t)},n.conv2DPacked=(u,p,g)=>{const c=p[0].dims,a=p[1].dims,t=(0,s.calculateOutputShape)(c,a,g.dilations,g.pads,g.strides),e=u.run((0,l.createPackedIm2ColProgramInfoLoader)(u,p[0],p[1],t,g),[p[0]]),r=u.reshapePacked(p[1],[a[0],a[1]*a[2]*a[3]]),i=p.length===3?[r,e,p[2]]:[r,e],h=u.run((0,f.createPackedMatmulProgramInfoLoader)(u,i,g),i);return u.reshapePacked(h,t)}},9663:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseConvTransposeAttributes=n.convTranspose=void 0;const s=o(246),l=o(5060),f=o(2039),u=o(2823),p=(r,i,h,m,_,b)=>(r-1)*i+h+(m-1)*_+1-b,g=(r,i,h,m,_)=>{const b=Math.floor(r/2);i==="SAME_UPPER"?(h[m]=b,h[_]=r-b):i==="SAME_LOWER"&&(h[m]=r-b,h[_]=b)};n.convTranspose=(r,i,h)=>(e(i,h),c(r,i,h));const c=(r,i,h)=>{const m=t(h,i);return[a(r,i,m)]},a=(r,i,h)=>r.run(((m,_,b)=>{const y=(T=_.length>2,w=b.cacheKey,{name:"ConvTranspose",inputNames:T?["X","W","B"]:["X","W"],inputTypes:T?[f.TextureType.unpacked,f.TextureType.unpacked,f.TextureType.unpacked]:[f.TextureType.unpacked,f.TextureType.unpacked],cacheHint:w});var T,w;return Object.assign(Object.assign({},y),{get:()=>((S,E,O,v)=>{const M=E.length>2?"getB(output_channel)":"0.0",$=E[0].dims,V=E[1].dims,B=V[1],L=V[0]/v.group,D=[E[0].dims[0],E[1].dims[1]*v.group,...v.outputShape],k=(0,l.getGlsl)(S.session.backend.glContext.version),{activationFunction:F,applyActivation:Q}=(0,u.getActivationSnippet)(v),Y=` + const ivec2 strides = ivec2(${v.strides[0]}, ${v.strides[1]}); + const ivec2 pads = ivec2(${v.pads[0]}, ${v.pads[1]}); + ${F} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + + ivec2 loc = coords.zw + pads; + + int group_id = output_channel / ${B}; + int wOutChannel = output_channel - group_id * ${B}; + + float value = ${M}; + for (int inChannelOffset = 0; inChannelOffset < ${L}; inChannelOffset++) { + int input_channel = group_id * ${L} + inChannelOffset; + for (int wWOff = 0; wWOff < ${V[2]}; wWOff++) { + for (int wHOff = 0; wHOff < ${V[3]}; wHOff++) { + ivec2 wOff = ivec2(wWOff * ${v.dilations[0]}, wHOff * ${v.dilations[1]}); + ivec2 wLoc = loc - wOff; + ivec2 wLocIn = wLoc / strides; + if ( + wLocIn * strides == wLoc && + wLocIn.x >= 0 && wLocIn.x < ${$[2]} && + wLocIn.y >= 0 && wLocIn.y < ${$[3]} + ) { + float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); + float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); + value += xVal * wVal; + } + } + } + } + ${Q} + ${k.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},O),{output:{dims:D,type:E[0].type,textureType:f.TextureType.unpacked},shaderSource:Y,hasMain:!0})})(m,_,y,b)})})(r,i,h),i),t=(r,i)=>{const h=r.kernelShape.slice();if(r.kernelShape.length===0)for(let y=2;y<i[1].dims.length;++y)h.push(i[1].dims[y]);const m=r.pads.slice(),_=r.outputShape.slice();((y,T,w,S,E,O,v,M)=>{const $=y.length-2,V=M.length===0;for(let B=0;B<$;++B){const L=V?y[B+2]*O[B]:M[B],D=p(y[B+2],O[B],E[B],T[B],w[B],L);g(D,S,E,B,B+$),V&&M.push(O[B]*(y[B+2]-1)+v[B]+(T[B]-1)*w[B]+1-E[B]-E[B+$])}})(i[0].dims,h,r.dilations,r.autoPad,m,r.strides,r.outputPadding,_);const b=Object.assign({},r);return Object.assign(b,{kernelShape:h,pads:m,outputShape:_,cacheKey:r.cacheKey}),b};n.parseConvTransposeAttributes=r=>{const i=r.attributes,h=(0,u.parseInternalActivationAttributes)(i),m=i.getString("auto_pad","NOTSET"),_=i.getInts("dilations",[1,1]),b=i.getInt("group",1),y=i.getInts("kernel_shape",[]),T=i.getInts("output_padding",[0,0]),w=i.getInts("output_shape",[]),S=i.getInts("pads",[0,0,0,0]),E=i.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:m,dilations:_,group:b,kernelShape:y,outputPadding:T,outputShape:w,pads:S,strides:E},h))};const e=(r,i)=>{if(!r||r.length!==2&&r.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(r[0].dims.length!==4||r[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(r[0].dims[1]!==r[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const h=r[1].dims[1]*i.group;if(r.length===3&&(r[2].dims.length!==1||r[2].dims[0]!==h))throw new Error("invalid bias");const m=r[0].dims.length-2;if(i.dilations.length!==m)throw new Error(`dilations should be ${m}D`);if(i.strides.length!==m)throw new Error(`strides should be ${m}D`);if(i.pads.length!==2*m)throw new Error(`pads should be ${2*m}D`);if(i.outputPadding.length!==m)throw new Error(`output_padding should be ${m}D`);if(i.kernelShape.length!==0&&i.kernelShape.length!==r[1].dims.length-2)throw new Error("invalid kernel shape");if(i.outputShape.length!==0&&i.outputShape.length!==r[0].dims.length-2)throw new Error("invalid output shape");if(r[0].type!=="float32"||r[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(r.length===3&&r[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},8138:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseConvAttributes=n.conv=n.calculateOutputShape=void 0;const s=o(246),l=o(2517),f=o(4770),u=o(1386),p=o(9828),g=o(2823),c=o(3248),a=o(5623);n.calculateOutputShape=(m,_,b,y,T)=>{const w=m[0],S=m.slice(2),E=S.length,O=_[0],v=_.slice(2).map(($,V)=>$+($-1)*(b[V]-1)),M=S.map(($,V)=>$+y[V]+y[V+E]).map(($,V)=>Math.floor(($-v[V]+T[V])/T[V]));return[w,O].concat(...M)},n.conv=(m,_,b)=>(h(_,b),t(m,_,b));const t=(m,_,b)=>{const y=i(b,_),T=m.session.pack,w=y.kernelShape[0]===1&&y.kernelShape[1]===1;return y.group>1?[m.run((0,f.createUnpackedGroupedConvProgramInfoLoader)(m,_,y),_)]:w&&T?[e(m,_,y)]:T&&_[0].dims.length===4&&_[0].dims[0]===1&&!w?[(0,u.conv2DPacked)(m,_,y)]:[r(m,_,y)]},e=(m,_,b)=>{const y=_[0].dims,T=_[1].dims,w=(0,n.calculateOutputShape)(y,T,b.dilations,b.pads,b.strides),S=m.reshapeUnpacked(_[0],[y[1],y[2]*y[3]]),E=m.reshapeUnpacked(_[1],[T[0],T[1]]),O=_.length>2?[E,S,_[2]]:[E,S],v=m.run((0,a.createMatmulProgramInfoLoader)(O,b),O);return m.reshapeUnpacked(v,w)},r=(m,_,b)=>{const y=_[0].dims,T=_[1].dims,w=(0,n.calculateOutputShape)(y,T,b.dilations,b.pads,b.strides),S=m.run((0,c.createIm2ColProgramInfoLoader)(m,_[0],_[1],w,b),[_[0]]),E=_.length===3?[S,_[1],_[2]]:[S,_[1]];return m.run((0,p.createDotProductProgramInfoLoader)(m,_,w,b),E)},i=(m,_)=>{const b=m.kernelShape.slice();if(m.kernelShape.length===0)for(let w=2;w<_[1].dims.length;++w)b.push(_[1].dims[w]);const y=m.pads.slice();l.PoolConvUtil.adjustPadsBasedOnAutoPad(_[0].dims,m.strides,m.dilations,b,y,m.autoPad);const T=Object.assign({},m);return Object.assign(T,{kernelShape:b,pads:y,cacheKey:m.cacheKey}),T};n.parseConvAttributes=m=>{const _=m.attributes,b=(0,g.parseInternalActivationAttributes)(_),y=_.getString("auto_pad","NOTSET"),T=_.getInts("dilations",[1,1]),w=_.getInt("group",1),S=_.getInts("kernel_shape",[]),E=_.getInts("pads",[0,0,0,0]),O=_.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:y,dilations:T,group:w,kernelShape:S,pads:E,strides:O},b))};const h=(m,_)=>{if(!m||m.length!==2&&m.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(m[0].dims.length!==4||m[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(m[0].dims[1]!==m[1].dims[1]*_.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(m.length===3&&(m[2].dims.length!==1||m[1].dims[0]!==m[2].dims[0]))throw new Error("invalid bias");const b=m[0].dims.length-2;if(_.dilations.length!==b)throw new Error(`dilations should be ${b}D`);if(_.strides.length!==b)throw new Error(`strides should be ${b}D`);if(_.pads.length!==2*b)throw new Error(`pads should be ${2*b}D`);if(_.kernelShape.length!==0&&_.kernelShape.length!==m[1].dims.length-2)throw new Error("invalid kernel shape");if(m[0].type!=="float32"||m[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(m.length===3&&m[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},5193:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseDepthToSpaceAttributes=n.depthToSpace=void 0;const s=o(3738);n.depthToSpace=(f,u,p)=>{l(u);const g=p.blocksize,c=g*g,a=p.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],t=p.mode==="DCR"?[u[0].dims[0],g,g,u[0].dims[1]/c,u[0].dims[2],u[0].dims[3]]:[u[0].dims[0],u[0].dims[1]/c,g,g,u[0].dims[2],u[0].dims[3]],e=f.reshapeUnpacked(u[0],t),r={perm:a,cacheKey:`${a}`},[i]=(0,s.transpose)(f,[e],r),h=[u[0].dims[0],u[0].dims[1]/c,u[0].dims[2]*g,u[0].dims[3]*g];return[f.reshapeUnpacked(i,h)]},n.parseDepthToSpaceAttributes=f=>{const u=f.attributes.getInt("blocksize");if(u<1)throw new Error(`blocksize must be >= 1, but got : ${u} for DepthToSpace`);const p=f.attributes.getString("mode","DCR");if(p!=="DCR"&&p!=="CRD")throw new Error(`unrecognized mode: ${p} for DepthToSpace`);return{mode:p,blocksize:u}};const l=f=>{if(f.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${f.length}`);if(f[0].type==="string"||f[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},9828:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDotProductProgramInfoLoader=void 0;const s=o(2517),l=o(5060),f=o(2039),u=o(2823),p=o(3248);n.createDotProductProgramInfoLoader=(g,c,a,t)=>{const e=((r,i)=>({name:"ConvDotProduct",inputNames:r?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:r?[f.TextureType.unpacked,f.TextureType.packedLastDimension,f.TextureType.unpacked]:[f.TextureType.unpacked,f.TextureType.packedLastDimension],cacheKey:i.activationCacheKey}))(c.length>2,t);return Object.assign(Object.assign({},e),{get:()=>((r,i,h,m,_)=>{const b=h[0].dims,y=h[1].dims,T=[y[0],Math.ceil(b[1]*y[2]*y[3]/4)],w=(0,p.calculateIm2ColDims)(b,y,m),[S,E]=r.calculateTextureWidthAndHeight(T,f.TextureType.packedLastDimension),O=s.ShapeUtil.computeStrides(w),[v,M]=r.calculateTextureWidthAndHeight(w,f.TextureType.packedLastDimension),$=m.length,V=h.length<3?"0.0":"_B(b)",B=Math.ceil(b[1]*y[2]*y[3]/4),{activationFunction:L,applyActivation:D}=(0,u.getActivationSnippet)(_),k=(0,l.getGlsl)(r.session.backend.glContext.version),F=` +${L} +float process(int indices[${$}]) { + 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] * ${O[0]} + im2col[1] * ${O[1]} + im2col[2] * ${O[2]}; + int kernelOffset = indices[1] * ${T[1]}; + float value = ${V}; + for (int i = 0; i < ${B}; ++i) { + vec2 im2colCoords = offsetToCoords(im2colOffset, ${v}, ${M}); + vec2 kernelCoords = offsetToCoords(kernelOffset, ${S}, ${E}); + value += dot(${k.texture2D}(Im2Col, im2colCoords), ${k.texture2D}(K, kernelCoords)); + ++im2colOffset; + ++kernelOffset; + } + ${D} + return value; +}`;return Object.assign(Object.assign({},i),{output:{dims:m,type:h[0].type,textureType:f.TextureType.unpacked},shaderSource:F})})(g,e,c,a,t)})}},7992:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseFlattenAttributes=n.flatten=void 0;const s=o(2517);n.flatten=(f,u,p)=>{l(u,p);const g=s.ShapeUtil.flattenShape(u[0].dims,p);return[f.reshapeUnpacked(u[0],g)]},n.parseFlattenAttributes=f=>f.attributes.getInt("axis",1);const l=(f,u)=>{if(!f||f.length!==1)throw new Error("Flatten requires 1 input.");const p=f[0].dims.length;if(p===0)throw new Error("scalar tensor is not supported.");if(u<-p||u>p)throw new Error("Invalid axis");if(f[0].type==="string")throw new Error("string tensor is not supported.")}},2823:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseInternalActivationAttributes=n.getActivationSnippet=void 0;const s=o(2517),l=o(4909);n.getActivationSnippet=function(f){let u;switch(f.activation){case"Relu":u=(0,l.glslRelu)();break;case"Sigmoid":u=(0,l.glslSigmoid)();break;case"Clip":u=(0,l.glslClip)(f.clipMin,f.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const p=u.name;return{activationFunction:u.body,applyActivation:`value = ${p}_(value);`}},n.parseInternalActivationAttributes=f=>{const u=f.getString("activation","");if(u==="Clip"){const[p,g]=f.getFloats("activation_params",[s.MIN_CLIP,s.MAX_CLIP]);return{activation:u,clipMax:g,clipMin:p,activationCacheKey:`${u}:${p},${g}`}}return{activation:u,activationCacheKey:u}}},1253:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseGatherAttributes=n.gather=void 0;const s=o(246),l=o(782),f=o(2517),u=o(2039);n.gather=(a,t,e)=>(c(t,e.axis),[a.run(g(a,t,e),t)]),n.parseGatherAttributes=a=>(0,s.createAttributeWithCacheKey)({axis:a.attributes.getInt("axis",0)});const p={name:"Gather",inputNames:["A","B"],inputTypes:[u.TextureType.unpacked,u.TextureType.unpacked]},g=(a,t,e)=>{const r=Object.assign(Object.assign({},p),{cacheHint:e.cacheKey});return Object.assign(Object.assign({},r),{get:()=>((i,h,m,_)=>{const b=m[0].dims.slice(),y=m[1].dims.slice(),T=new Array(b.length+y.length-1);_=f.ShapeUtil.normalizeAxis(_,b.length);const w=[];for(let E=0;E<T.length;E++)E<_?(T[E]=b[E],w.push(`inputIdx[${E}] = outputIdx[${E}];`)):E<_+y.length?(T[E]=y[E-_],w.push(`indexDataIdx[${E-_}] = outputIdx[${E}];`)):(T[E]=b[E-y.length+1],w.push(`inputIdx[${E-y.length+1}] = outputIdx[${E}];`));const S=` + float process(int outputIdx[${T.length||1}]) { + int inputIdx[${b.length}]; + int indexDataIdx[${y.length||1}]; + indexDataIdx[0] = 0; + ${w.join(` + `)} + int idx = int(_B(indexDataIdx)); + inputIdx[${_}] = idx < 0 ? idx + ${b[_]} : idx; + return _A(inputIdx); + }`;return Object.assign(Object.assign({},h),{output:{dims:T,type:m[0].type,textureType:u.TextureType.unpacked},shaderSource:S})})(0,r,t,e.axis)})},c=(a,t)=>{if(!a||a.length!==2)throw new Error("Gather requires 2 inputs.");const e=a[0].dims.length;if(e<1)throw new Error("Invalid input shape.");if(t<-e||t>e-1)throw new Error("Invalid axis.");if(l.NUMBER_TYPES.indexOf(a[0].type)===-1)throw new Error("Invaid input type.");if(a[1].type!=="int32"&&a[1].type!=="int16")throw new Error("Invaid input type.")}},4776:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseGemmAttributesV11=n.parseGemmAttributesV7=n.gemm=void 0;const s=o(246),l=o(2517),f=o(2039);n.gemm=(a,t,e)=>(c(t,e),[a.run(p(t,e),t)]);const u=(a,t)=>{const e=a.attributes.getInt("transA",0)!==0,r=a.attributes.getInt("transB",0)!==0,i=a.attributes.getFloat("alpha",1),h=a.attributes.getFloat("beta",1);return(0,s.createAttributeWithCacheKey)({transA:e,transB:r,alpha:i,beta:h,isOptionalC:t})};n.parseGemmAttributesV7=a=>u(a,!1),n.parseGemmAttributesV11=a=>u(a,!0);const p=(a,t)=>{const e={name:"Gemm",inputNames:a.length===3?["A","B","C"]:["A","B"],inputTypes:a.length===3?[f.TextureType.unpacked,f.TextureType.unpacked,f.TextureType.unpacked]:[f.TextureType.unpacked,f.TextureType.unpacked],key:t.cacheKey};return Object.assign(Object.assign({},e),{get:()=>g(e,a,t)})},g=(a,t,e)=>{const r=t[0].dims.slice(),i=t[1].dims.slice(),[h,m]=l.GemmUtil.getShapeOfGemmResult(r,e.transA,i,e.transB,t.length===3?t[2].dims:void 0),_=[h,m];if(!_)throw new Error("Can't use gemm on the given tensors");let b=r[r.length-1],y="";e.transA&&(b=r[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 T=_.length,w=` + float process(int indices[${T}]) { + int a[${T}]; + int b[${T}]; + ${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<${b}; ++k) { + a[${T-1}] = k; + b[${T-2}] = k; + ${y} + } + + value = value * alpha; + ${t.length===3?"value += beta * _C(c);":""} + return value; + }`;return Object.assign(Object.assign({},a),{output:{dims:_,type:t[0].type,textureType:f.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:e.alpha},{name:"beta",type:"float",data:e.beta}],shaderSource:w})},c=(a,t)=>{if(!a)throw new Error("Input is missing");if(t.isOptionalC&&(a.length<2||a.length>3))throw new Error("Invaid input shape.");if(!t.isOptionalC&&a.length!==3)throw new Error("Gemm requires 3 inputs");if(a.length===3&&a[2].dims.length!==1&&a[2].dims.length!==2)throw new Error("Invalid input shape of C");if(a[0].type!=="float32"&&a[0].type!=="float64"||a[1].type!=="float32"&&a[1].type!=="float64"||a.length===3&&a[2].type!=="float32"&&a[2].type!=="float64")throw new Error("Invalid input type.");if(a[0].type!==a[1].type||a.length===3&&a[0].type!==a[2].type)throw new Error("Input types are mismatched")}},8555:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createPackedIm2ColProgramInfoLoader=void 0;const s=o(5060),l=o(2039),f=o(2827);n.createPackedIm2ColProgramInfoLoader=(u,p,g,c,a)=>{const t=(e=a.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[l.TextureType.packed],cacheHint:e});var e;return Object.assign(Object.assign({},t),{get:()=>((r,i,h,m,_,b)=>{const y=h.dims,T=m.dims,w=_.length,S=[T[1]*T[2]*T[3],_[2]*_[3]],E=T[2]*T[3],O=(0,f.unpackFromChannel)(),v=(0,s.getGlsl)(r.session.backend.glContext.version);let M="";for(let V=0;V<=1;V++)for(let B=0;B<=1;B++)M+=` + blockIndex = rc.x + ${B}; + pos = rc.y + ${V}; + + if(blockIndex < ${S[1]} && pos < ${S[0]}) { + offsetY = int(blockIndex / (${_[w-1]})) * ${b.strides[0]} - + ${b.pads[0]}; + d0 = offsetY + ${b.dilations[0]} * (imod(pos, ${E}) / ${T[2]}); + + if(d0 < ${y[2]} && d0 >= 0) { + offsetX = imod(blockIndex, ${_[w-1]}) * ${b.strides[1]} - + ${b.pads[1]}; + d1 = offsetX + ${b.dilations[1]} * imod(imod(pos, ${E}), ${T[2]}); + + if(d1 < ${y[3]} && d1 >= 0) { + + ch = int(float(pos)/ ${E}.); + innerDims = vec2(d0, d1); + result[${2*V+B}] = getChannel( + getA(0, ch, int(innerDims.x), + int(innerDims.y)), innerDims); + } + } + } + + `;const $=` + ${O} + + void main() { + ivec2 rc = getOutputCoords(); + vec4 result = vec4(0.0); + int blockIndex, pos, offsetY, d0, offsetX, d1, ch; + vec2 innerDims; + ${M} + ${v.output} = result; + } + `;return Object.assign(Object.assign({},i),{output:{dims:S,type:h.type,textureType:l.TextureType.packed},shaderSource:$,hasMain:!0})})(u,t,p,g,c,a)})}},3248:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.calculateIm2ColDims=n.createIm2ColProgramInfoLoader=void 0;const s=o(2039);n.createIm2ColProgramInfoLoader=(l,f,u,p,g)=>{const c=(a=g.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[s.TextureType.unpacked],cacheHint:a});var a;return Object.assign(Object.assign({},c),{get:()=>((t,e,r,i,h,m)=>{const _=r.dims,b=i.dims,y=h.length,T=(0,n.calculateIm2ColDims)(_,b,h,4),w=` + const int XC = ${_[1]}; + const int XH = ${_[2]}; + const int XW = ${_[3]}; + const int KH = ${m.kernelShape[0]}; + const int KW = ${m.kernelShape[1]}; + const int dilationH = ${m.dilations[0]}; + const int dilationW = ${m.dilations[1]}; + const int strideH = ${m.strides[0]}; + const int strideW = ${m.strides[1]}; + const int padH = ${m.pads[0]}; + const int padW = ${m.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[${_.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:T,type:r.type,textureType:s.TextureType.packedLastDimension},shaderSource:w})})(0,c,f,u,p,g)})},n.calculateIm2ColDims=(l,f,u,p=4)=>[u[0],u[2],u[3],Math.ceil(l[1]*f[2]*f[3]/p)]},6572:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseImageScalerAttributes=n.imageScaler=void 0;const s=o(246),l=o(2039);n.imageScaler=(c,a,t)=>(g(a),[c.run(u(c,a,t),a)]),n.parseImageScalerAttributes=c=>{const a=c.attributes.getFloat("scale"),t=c.attributes.getFloats("bias");return(0,s.createAttributeWithCacheKey)({scale:a,bias:t})};const f={name:"ImageScaler",inputNames:["X"],inputTypes:[l.TextureType.unpacked]},u=(c,a,t)=>{const e=Object.assign(Object.assign({},f),{cacheHint:t.cacheKey});return Object.assign(Object.assign({},e),{get:()=>((r,i,h,m)=>{const _=h[0].dims.slice(),b=_.length,y=` + ${p(m.bias.length)} + float process(int indices[${b}]) { + return _X(indices) * scale + getBias(bias, indices[1]); + }`;return Object.assign(Object.assign({},i),{output:{dims:_,type:h[0].type,textureType:l.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:m.bias.length,data:m.bias},{name:"scale",type:"float",data:m.scale}],shaderSource:y})})(0,e,a,t)})},p=c=>{const a=[`float getBias(float bias[${c}], int channel) {`];for(let t=0;t<c;++t)t===0?a.push(` if (channel == ${t}) { return bias[${t}]; }`):t===c-1?a.push(` else { return bias[${t}]; }`):a.push(` else if (channel == ${t}) { return bias[${t}]; }`);return a.push(" }"),a.join(` +`)},g=c=>{if(!c||c.length!==1)throw new Error("ImageScaler requires 1 input.");if(c[0].dims.length!==4)throw new Error("Invalid input shape.");if(c[0].type!=="float32"&&c[0].type!=="float64")throw new Error("Invalid input type.")}},3346:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseInstanceNormalizationAttributes=n.instanceNormalization=void 0;const s=o(5060),l=o(2039);n.instanceNormalization=(a,t,e)=>{c(t);const r=a.run(u(t[0]),t);return[a.run(g(a,t[0],e,r.dims),[t[0],r,t[1],t[2]])]},n.parseInstanceNormalizationAttributes=a=>a.attributes.getFloat("epsilon",1e-5);const f={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[l.TextureType.unpacked]},u=a=>Object.assign(Object.assign({},f),{get:()=>((t,e)=>{const r=e.dims.slice(),i=r[1],h=r[2]*r[3],m=[r[0],i],_=` + 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<${r[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${r[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += x; + } + } + float mean = temp / float(${h}); + temp = 0.0; + for(int a2=0; a2<${r[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${r[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += (x - mean) * (x - mean); + } + } + v.r = mean; + v.g = temp / float(${h}); + + return v; + }`;return Object.assign(Object.assign({},t),{output:{dims:m,type:e.type,textureType:l.TextureType.packedLastDimension},shaderSource:_})})(f,a)}),p={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[l.TextureType.unpacked,l.TextureType.packedLastDimension,l.TextureType.unpacked,l.TextureType.unpacked]},g=(a,t,e,r)=>{const i=Object.assign(Object.assign({},p),{cacheHint:`${e}`});return Object.assign(Object.assign({},i),{get:()=>((h,m,_,b,y)=>{const T=(0,s.getGlsl)(h.session.backend.glContext.version),[w,S]=h.calculateTextureWidthAndHeight(y,l.TextureType.packedLastDimension),[E,O]=[w/4,S],v=` + vec4 get_MeanAndVariance(int[2] mv) { + int offset = indicesToOffset_MeanAndVariance(mv); + vec2 coords = offsetToCoords(offset, ${E}, ${O}); + return ${T.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({},m),{output:{dims:_.dims,type:_.type,textureType:l.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:b}],shaderSource:v})})(a,i,t,e,r)})},c=a=>{if(!a||a.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const t=a[0],e=a[1],r=a[2];if(t.dims.length<3||e.dims.length!==1||r.dims.length!==1)throw new Error("Invalid input shape.");if(e.dims[0]!==t.dims[1]||r.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"||r.type!=="float32"&&r.type!=="float64")throw new Error("Invalid input type.");if(a[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},708:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createPackedMatmulProgramInfoLoader=void 0;const s=o(2517),l=o(5060),f=o(2039),u=o(9390),p=o(2823),g=o(5623);n.createPackedMatmulProgramInfoLoader=(c,a,t)=>{const e=(r=a.length>2,i=t.activationCacheKey,{name:"MatMul (packed)",inputNames:r?["A","B","Bias"]:["A","B"],inputTypes:r?[f.TextureType.packed,f.TextureType.packed,f.TextureType.packed]:[f.TextureType.packed,f.TextureType.packed],cacheHint:i});var r,i;return Object.assign(Object.assign({},e),{get:()=>((h,m,_,b)=>{const y=_.length>2,T=y?"value += getBiasForMatmul();":"",w=_[0].dims,S=_[1].dims,E=s.BroadcastUtil.calcShape(w,S,!0),O=!s.ShapeUtil.areEqual(_[0].dims,_[1].dims);if(!E)throw new Error("Can't use matmul on the given tensors");const v=w[w.length-1],M=Math.ceil(v/2),$=w.length,V=S.length,B=(0,l.getGlsl)(h.session.backend.glContext.version),L=(0,u.getCoordsDataType)(E.length),D=E.length,k=(0,u.getGlChannels)(),{activationFunction:F,applyActivation:Q}=(0,p.getActivationSnippet)(b),Y=y?`${(0,g.getBiasForMatmul)(L,k,_[2].dims,E,!0)}`:"",ee=O?`${function(xe,ue,Se,we){let $e=[],He=[];const Ae=Se[0].dims,Fe=Se[1].dims,De=Ae.length,Me=Fe.length,ve=we.length,je=ve-De,ze=ve-Me;$e=Ae.map((Pe,Re)=>`coords.${ue[Re+je]}`),$e[De-1]="i*2",$e.join(", "),He=Fe.map((Pe,Re)=>`coords.${ue[Re+ze]}`),He[Me-2]="i*2",He.join(", ");const Ue=s.BroadcastUtil.getBroadcastDims(Ae,we),Ye=s.BroadcastUtil.getBroadcastDims(Fe,we),Qe=Ue.map(Pe=>`coords.${ue[Pe+je]} = 0;`).join(` +`),Ge=Ye.map(Pe=>`coords.${ue[Pe+ze]} = 0;`).join(` +`),Ve=`int lastDim = coords.${ue[ve-1]}; + coords.${ue[ve-1]} = coords.${ue[ve-2]}; + coords.${ue[ve-2]} = lastDim;`;return` +vec4 getAAtOutCoordsMatmul(int i) { + ${xe} coords = getOutputCoords(); + ${Ve} + ${Qe} + vec4 outputValue = getA(${$e}); + return outputValue; +} + +vec4 getBAtOutCoordsMatmul(int i) { + ${xe} coords = getOutputCoords(); + ${Ve} + ${Ge} + vec4 outputValue = getB(${He}); + return outputValue; +}`}(L,k,_,E)}`:"",te=O?"getAAtOutCoordsMatmul(i)":`getA(${function(xe,ue){let Se="";for(let we=0;we<ue-2;we++)Se+=`rc.${xe[we]}, `;return Se+=`rc.${xe[ue-2]}, i*2`,Se}(k,$)})`,he=O?"getBAtOutCoordsMatmul(i)":`getB(${function(xe,ue){let Se="";for(let we=0;we<ue-2;we++)Se+=`rc.${xe[we]}, `;return Se+=`i*2, rc.${xe[ue-1]}`,Se}(k,V)})`,Oe=` + ${ee} + ${Y} + ${F} + void main() { + ${O?"":`${L} rc = + getOutputCoords(); int lastDim = rc.${k[D-1]}; rc.${k[D-1]} = + rc.${k[D-2]}; rc.${k[D-2]} = lastDim; + `} + + vec4 value = vec4(0); + for (int i = 0; i < ${M}; i++) { + vec4 a = ${te}; + vec4 b = ${he}; + + value += (a.rrbb * b.rgrg); + value += (a.ggaa * b.baba); + } + ${T} + ${Q} + ${B.output} = value; + }`;return Object.assign(Object.assign({},m),{output:{dims:E,type:_[0].type,textureType:f.TextureType.packed},shaderSource:Oe,hasMain:!0})})(c,e,a,t)})}},5623:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getBiasForMatmul=n.createMatmulProgramInfoLoader=n.parseMatMulAttributes=n.matMul=void 0;const s=o(2517),l=o(2039),f=o(9390),u=o(2823),p=o(708);function g(t,e){const r=(i=t.length>2,h=e.activationCacheKey,{name:"MatMul",inputNames:i?["A","B","Bias"]:["A","B"],inputTypes:i?[l.TextureType.unpacked,l.TextureType.unpacked,l.TextureType.unpacked]:[l.TextureType.unpacked,l.TextureType.unpacked],cacheHint:h});var i,h;return Object.assign(Object.assign({},r),{get:()=>function(m,_,b){const y=_[0].dims,T=_[1].dims,w=s.BroadcastUtil.calcShape(y,T,!0);if(!w)throw new Error("Can't use matmul on the given tensors");const S=(0,f.getCoordsDataType)(w.length),E=(0,f.getGlChannels)(),{activationFunction:O,applyActivation:v}=(0,u.getActivationSnippet)(b),M=_.length>2,$=M?"value += getBiasForMatmul();":"",V=M?`${a(S,E,_[2].dims,w,!1)}`:"",B=w.length,L=y.length,D=T.length,k=` + ${O} + ${V} + float process(int indices[${B}]) { + int a[${L}]; + int b[${D}]; + bcastMatmulIndices_A(indices, a); + bcastMatmulIndices_B(indices, b); + + float value; + for (int k=0; k<${y[y.length-1]}; ++k) { + a[${L-1}] = k; + b[${D-2}] = k; + value += _A(a) * _B(b); + } + ${$} + ${v} + return value; + }`;return Object.assign(Object.assign({},m),{output:{dims:w,type:_[0].type,textureType:l.TextureType.unpacked},shaderSource:k})}(r,t,e)})}n.matMul=(t,e,r)=>(c(e),t.session.pack?[t.run((0,p.createPackedMatmulProgramInfoLoader)(t,e,r),e)]:[t.run(g(e,r),e)]),n.parseMatMulAttributes=t=>(0,u.parseInternalActivationAttributes)(t.attributes),n.createMatmulProgramInfoLoader=g;const c=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 a(t,e,r,i,h){let m="";const _=r.length,b=i.length,y=b-_;m=b<2&&_>0?"coords":r.map((S,E)=>`coords.${e[E+y]}`).join(", ");const T=s.BroadcastUtil.getBroadcastDims(r,i).map(S=>`coords.${e[S+y]} = 0;`).join(` +`);let w="vec4(outputValue.xx, outputValue.yy)";return s.ShapeUtil.size(r)===1&&(w="vec4(outputValue.x)"),h?` +vec4 getBiasForMatmul() { + ${t} coords = getOutputCoords(); + ${T} + vec4 outputValue = getBias(${m}); + return ${w}; +}`:` +float getBiasForMatmul() { + ${t} coords = getOutputCoords(); + ${T} + return getBias(coords.x); +}`}n.getBiasForMatmul=a},2403:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createPackProgramInfoLoader=void 0;const s=o(5060),l=o(2039),f=o(9390),u=o(2827),p={name:"pack",inputNames:["A"],inputTypes:[l.TextureType.unpackedReversed]};n.createPackProgramInfoLoader=(g,c)=>Object.assign(Object.assign({},p),{get:()=>((a,t)=>{const e=(0,s.getGlsl)(a.session.backend.glContext.version),r=t.dims,i=r.length,h=t.dims.length,m=(0,f.getCoordsDataType)(h),_=(0,u.getChannels)("rc",h),b=(y=h,T=_,w=r[r.length-2],S=r[r.length-1],y===0||y===1?"":` + int r = ${T[y-2]}; + int c = ${T[y-1]}; + int rp1 = ${T[y-2]} + 1; + int cp1 = ${T[y-1]} + 1; + bool rEdge = rp1 >= ${S}; + bool cEdge = cp1 >= ${w}; + `);var y,T,w,S;let E;E=i===0?[1,1]:i===1?[r[0],1]:[r[h-1],r[h-2]];const O=function($,V,B){if($===0)return"false";if($===1)return`rc > ${V[0]}`;let L="";for(let D=$-2;D<$;D++)L+=`${B[D]} >= ${V[D-$+2]}`,D<$-1&&(L+="||");return L}(h,E,_),v=function($,V){const B=$.length;if(B===0)return"getA(), 0, 0, 0";if(B===1)return`getA(rc), + rc + 1 >= ${$[0]} ? 0. : getA(rc + 1), + 0, 0`;let L="";if(B>2)for(let D=0;D<B-2;++D)L+=`${V[D]},`;return`getA(${L}r, c), + rEdge ? 0. : getA(${L}rp1, c), + cEdge ? 0. : getA(${L}r, cp1), + rEdge || cEdge ? 0. : getA(${L}rp1, cp1)`}(r,_),M=` + void main() { + ${m} rc = getOutputCoords(); + + if(${O}) { + ${e.output} = vec4(0); + } else { + ${b} + + ${e.output} = vec4(${v}); + } + } + `;return Object.assign(Object.assign({},p),{hasMain:!0,output:{dims:t.dims,type:t.type,textureType:l.TextureType.packed},shaderSource:M})})(g,c)})},2827:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.unpackFromChannel=n.getChannels=n.getVecChannels=void 0;const s=o(9390);function l(f,u){return(0,s.getGlChannels)(u).map(p=>`${f}.${p}`)}n.getVecChannels=l,n.getChannels=function(f,u){return u===1?[f]:l(f,u)},n.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,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parsePadAttributesV11=n.padV11=n.parsePadAttributesV2=n.padV2=void 0;const s=o(246),l=o(2517),f=o(5060),u=o(2039),p={name:"Pad",inputNames:["A"],inputTypes:[u.TextureType.unpacked]};n.padV2=(m,_,b)=>(a(_),[m.run(Object.assign(Object.assign({},p),{cacheHint:b.cacheKey,get:()=>c(m,_[0],b)}),_)]),n.parsePadAttributesV2=m=>{const _=m.attributes.getString("mode","constant"),b=m.attributes.getFloat("value",0),y=m.attributes.getInts("pads");return(0,s.createAttributeWithCacheKey)({mode:_,value:b,pads:y})},n.padV11=(m,_,b)=>{t(_);const y=g(m,_,b);return(0,n.padV2)(m,[_[0]],y)},n.parsePadAttributesV11=m=>m.attributes.getString("mode","constant");const g=(m,_,b)=>{if(!m.session.isInitializer(_[1].dataId)||_.length>=3&&!m.session.isInitializer(_[2].dataId))throw new Error("dynamic pad attributes are not allowed");const y=Array.from(_[1].integerData),T=_.length>=3?_[2].floatData[0]:0;return(0,s.createAttributeWithCacheKey)({mode:b,pads:y,value:T})},c=(m,_,b)=>{const y=l.ShapeUtil.padShape(_.dims.slice(),b.pads),T=y.length,w=` + ${e(m,_,b)} + float process(int[${T}] indices) { + return padA(indices); + }`;return{name:"Pad",inputNames:["A"],inputTypes:[u.TextureType.unpacked],output:{dims:y,type:_.type,textureType:u.TextureType.unpacked},shaderSource:w}},a=m=>{if(!m||m.length!==1)throw new Error("Pad requires 1 input");if(m[0].type!=="float32"&&m[0].type!=="float64")throw new Error("Invalid input type.")},t=m=>{if(!m||m.length!==2&&m.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(m[1].type!=="int32")throw new Error("Invalid input type.");if(m.length>=3&&m[2].type==="string")throw new Error("Invalid input type.")},e=(m,_,b)=>{const y=(0,f.getGlsl)(m.session.backend.glContext.version),[T,w]=m.calculateTextureWidthAndHeight(_.dims,u.TextureType.unpacked),S=l.ShapeUtil.computeStrides(_.dims);switch(b.mode){case"constant":return r(y,_.dims,S,T,w,b.pads,b.value);case"reflect":return i(y,_.dims,S,T,w,b.pads);case"edge":return h(y,_.dims,S,T,w,b.pads);default:throw new Error("Invalid mode")}},r=(m,_,b,y,T,w,S)=>{const E=_.length;let O="";for(let v=E-1;v>=0;--v)O+=` + k = m[${v}] - ${w[v]}; + if (k < 0) return constant; + if (k >= ${_[v]}) return constant; + offset += k * ${b[v]}; + `;return` + float padA(int m[${E}]) { + const float constant = float(${S}); + int offset = 0; + int k = 0; + ${O} + vec2 coords = offsetToCoords(offset, ${y}, ${T}); + float value = getColorAsFloat(${m.texture2D}(A, coords)); + return value; + } + `},i=(m,_,b,y,T,w)=>{const S=_.length;let E="";for(let O=S-1;O>=0;--O)E+=` + k = m[${O}] - ${w[O]}; + if (k < 0) { k = -k; } + { + const int _2n_1 = ${2*(_[O]-1)}; + k = int( mod( float(k), float(_2n_1) ) ) ; + if(k >= ${_[O]}) { k = _2n_1 - k; } + } + offset += k * ${b[O]}; + `;return` + float padA(int m[${S}]) { + int offset = 0; + int k = 0; + ${E} + vec2 coords = offsetToCoords(offset, ${y}, ${T}); + float value = getColorAsFloat(${m.texture2D}(A, coords)); + return value; + } + `},h=(m,_,b,y,T,w)=>{const S=_.length;let E="";for(let O=S-1;O>=0;--O)E+=` + k = m[${O}] - ${w[O]}; + if (k < 0) k = 0; + if (k >= ${_[O]}) k = ${_[O]-1}; + offset += k * ${b[O]}; + `;return` + float padA(int m[${S}]) { + int offset = 0; + int k = 0; + ${E} + vec2 coords = offsetToCoords(offset, ${y}, ${T}); + float value = getColorAsFloat(${m.texture2D}(A, coords)); + return value; + } + `}},2143:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.globalMaxPool=n.parseMaxPoolAttributes=n.maxPool=n.parseGlobalAveragePoolAttributes=n.globalAveragePool=n.parseAveragePoolAttributes=n.averagePool=void 0;const s=o(246),l=o(2517),f=o(2039);n.averagePool=(h,m,_)=>{t(m);const b={name:"AveragePool",inputNames:["X"],inputTypes:[f.TextureType.unpacked],cacheHint:_.cacheKey};return[h.run(Object.assign(Object.assign({},b),{get:()=>u(m,b,!1,_)}),m)]},n.parseAveragePoolAttributes=h=>{const m=h.attributes.getString("auto_pad","NOTSET"),_=h.attributes.getInt("ceil_mode",0),b=h.attributes.getInt("count_include_pad",0)!==0,y=h.attributes.getInts("kernel_shape"),T=h.attributes.getInts("strides",[]),w=h.attributes.getInts("pads",[]);if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,s.createAttributeWithCacheKey)({autoPad:m,ceilMode:_,countIncludePad:b,kernelShape:y,strides:T,pads:w})};const u=(h,m,_,b)=>{const[y,T]=g(h,b,_),w=l.ShapeUtil.size(y.kernelShape);let S="";y.countIncludePad?S+=`value /= float(${w});`:S+=`value /= float(${w} - pad);`;const E=` + ${e(h[0].dims,y,"value += _X(x);",S,"0.0")} + `;return Object.assign(Object.assign({},m),{output:{dims:T,type:h[0].type,textureType:f.TextureType.unpacked},shaderSource:E})};n.globalAveragePool=(h,m,_)=>{t(m);const b={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[f.TextureType.unpacked],cacheHint:`${_.countIncludePad}`};return[h.run(Object.assign(Object.assign({},b),{get:()=>u(m,b,!0,_)}),m)]},n.parseGlobalAveragePoolAttributes=h=>{const m=h.attributes.getInt("count_include_pad",0)!==0;return(0,s.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:m,kernelShape:[],strides:[],pads:[]})},n.maxPool=(h,m,_)=>{t(m);const b={name:"MaxPool",inputNames:["X"],inputTypes:[f.TextureType.unpacked],cacheHint:_.cacheKey};return[h.run(Object.assign(Object.assign({},b),{get:()=>p(m,b,!1,_)}),m)]},n.parseMaxPoolAttributes=h=>{const m=h.attributes.getString("auto_pad","NOTSET"),_=h.attributes.getInt("ceil_mode",0),b=h.attributes.getInts("kernel_shape"),y=h.attributes.getInts("strides",[]),T=h.attributes.getInts("pads",[]),w=h.attributes.getInt("storage_order",0),S=h.attributes.getInts("dilations",[]);if(w!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,s.createAttributeWithCacheKey)({autoPad:m,ceilMode:_,countIncludePad:!1,kernelShape:b,strides:y,pads:T,storageOrder:w,dilations:S})};const p=(h,m,_,b)=>{const[y,T]=g(h,b,_),w=` + ${e(h[0].dims,y,` + value = max(_X(x), value); + `,"","-1e5")} + `;return Object.assign(Object.assign({},m),{output:{dims:T,type:h[0].type,textureType:f.TextureType.unpacked},shaderSource:w})},g=(h,m,_)=>{const b=h[0].dims.slice(),y=Object.hasOwnProperty.call(m,"dilations"),T=m.kernelShape.slice(),w=m.strides.slice(),S=y?m.dilations.slice():[],E=m.pads.slice();l.PoolConvUtil.adjustPoolAttributes(_,b,T,w,S,E);const O=l.PoolConvUtil.computePoolOutputShape(_,b,w,S,T,E,m.autoPad),v=Object.assign({},m);return y?Object.assign(v,{kernelShape:T,strides:w,pads:E,dilations:S,cacheKey:m.cacheKey}):Object.assign(v,{kernelShape:T,strides:w,pads:E,cacheKey:m.cacheKey}),[v,O]},c={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},a={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[f.TextureType.unpacked]};n.globalMaxPool=(h,m)=>(t(m),[h.run(Object.assign(Object.assign({},a),{get:()=>p(m,a,!0,c)}),m)]);const t=h=>{if(!h||h.length!==1)throw new Error("Pool ops requires 1 input.");if(h[0].type!=="float32"&&h[0].type!=="float64")throw new Error("Invalid input type.")},e=(h,m,_,b,y)=>{const T=h.length;if(m.kernelShape.length<=2){const w=m.kernelShape[m.kernelShape.length-1],S=m.strides[m.strides.length-1],E=m.pads[m.pads.length/2-1],O=m.pads[m.pads.length-1],v=h[T-1];let M="",$="",V="";if(M=E+O!==0?` + for (int i = 0; i < ${w}; i++) { + x[${T} - 1] = indices[${T} - 1] * ${S} - ${E} + i; + if (x[${T} - 1] < 0 || x[${T} - 1] >= ${v}) { + pad++; + continue; + } + ${_} + }`:` + for (int i = 0; i < ${w}; i++) { + x[${T} - 1] = indices[${T} - 1] * ${S} - ${E} + i; + ${_} + }`,m.kernelShape.length===2){const B=m.kernelShape[m.kernelShape.length-2],L=m.strides[m.strides.length-2],D=m.pads[m.pads.length/2-2],k=m.pads[m.pads.length-2],F=h[T-2];$=D+k!==0?` + for (int j = 0; j < ${B}; j++) { + x[${T} - 2] = indices[${T} - 2] * ${L} - ${D} + j; + if (x[${T} - 2] < 0 || x[${T} - 2] >= ${F}) { + pad+= ${w}; + continue; + } + `:` + for (int j = 0; j < ${B}; j++) { + x[${T} - 2] = indices[${T} - 2] * ${L} - ${D} + j; + `,V=` + } + `}return` + float process(int indices[${T}]) { + int x[${T}]; + copyVec(indices, x); + + float value = ${y}; + int pad = 0; + ${$} + ${M} + ${V} + ${b} + return value; + } + `}{const w=l.ShapeUtil.size(m.kernelShape),S=l.ShapeUtil.computeStrides(m.kernelShape),E=S.length,O=m.pads.length,v=i(E),M=r(h,"inputDims"),$=r(m.pads,"pads"),V=r(S,"kernelStrides"),B=r(m.strides,"strides");let L="";return L=m.pads.reduce((D,k)=>D+k)?` + if (x[j] >= inputDims[j] || x[j] < 0) { + pad++; + isPad = true; + break; + } + } + if (!isPad) { + ${_} + }`:` + } + ${_} + `,` + ${v} + float process(int indices[${T}]) { + int x[${T}]; + copyVec(indices, x); + int offset[${E}]; + int pads[${O}]; + int inputDims[${T}]; + int kernelStrides[${E}]; + int strides[${E}]; + ${$} + ${M} + ${B} + ${V} + + float value = ${y}; + int pad = 0; + bool isPad = false; + for (int i = 0; i < ${w}; i++) { + offsetToIndices(i, kernelStrides, offset); + isPad = false; + for (int j = ${T} - ${E}; j < ${T}; j++) { + x[j] = indices[j] * strides[j - ${T} + ${E}] + + offset[j - ${T} + ${E}] - pads[j - 2]; + ${L} + } + ${b} + + return value; + } + `}},r=(h,m)=>{let _="";for(let b=0;b<h.length;b++)_+=` + ${m}[${b}] = ${h[b]}; + `;return _},i=h=>` + void offsetToIndices(int offset, int[${h}] strides, out int[${h}] indices) { + if (${h} == 0) { + return; + } + for (int i = 0; i < ${h} - 1; ++i) { + indices[i] = offset / strides[i]; + offset -= indices[i] * strides[i]; + } + indices[${h} - 1] = offset; + }`},4939:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.reduceLogSumSquare=n.reduceLogSum=n.reduceProd=n.reduceMin=n.reduceMax=n.reduceMean=n.reduceSum=n.parseReduceAttributes=void 0;const s=o(246),l=o(782),f=o(2517),u=o(2039),p=(a,t,e,r,i)=>{c(t);const h={name:r,inputNames:["A"],inputTypes:[u.TextureType.unpacked]};return[a.run(Object.assign(Object.assign({},h),{cacheHint:e.cacheKey,get:()=>g(a,t,e,r,i,h)}),t)]};n.parseReduceAttributes=a=>{const t=a.attributes.getInts("axes",[]),e=a.attributes.getInt("keepdims",1)===1;return(0,s.createAttributeWithCacheKey)({axes:t,keepDims:e})};const g=(a,t,e,r,i,h)=>{const m=[],_=t[0].dims.length||1,b=[],y=f.ShapeUtil.normalizeAxes(e.axes,t[0].dims.length),T=i(t,y);let w=T[1];for(let E=0;E<t[0].dims.length;E++)y.indexOf(E)>=0||y.length===0?(e.keepDims&&m.push(1),w=` + for(int j${E} = 0; j${E} < ${t[0].dims[E]}; j${E}++) { + inputIdx[${E}] = j${E}; + ${w} + }`):(b.push(`inputIdx[${E}] = outputIdx[${m.length}];`),m.push(t[0].dims[E]));const S=` + float process(int outputIdx[${m.length||1}]) { + float value; // final result + int inputIdx[${_}]; // addressing input data + ${b.join(` +`)} + ${T[0]} // init ops for reduce max/min + ${w} + ${T[2]} // final computation for reduce mean + return value; + }`;return Object.assign(Object.assign({},h),{output:{dims:m,type:t[0].type,textureType:u.TextureType.unpacked},shaderSource:S})},c=a=>{if(!a||a.length!==1)throw new Error("Reduce op requires 1 input.");if(l.NUMBER_TYPES.indexOf(a[0].type)===-1)throw new Error("Invalid input type.")};n.reduceSum=(a,t,e)=>p(a,t,e,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),n.reduceMean=(a,t,e)=>p(a,t,e,"ReduceMean",(r,i)=>{let h=1;for(let m=0;m<r[0].dims.length;m++)(i.indexOf(m)>=0||i.length===0)&&(h*=r[0].dims[m]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${h}.;`]}),n.reduceMax=(a,t,e)=>p(a,t,e,"ReduceMax",(r,i)=>{const h=[];for(let m=0;m<r[0].dims.length;m++)(i.indexOf(m)>=0||i.length===0)&&h.push(`inputIdx[${m}] = 0;`);return[`${h.join(` +`)} +value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),n.reduceMin=(a,t,e)=>p(a,t,e,"ReduceMin",(r,i)=>{const h=[];for(let m=0;m<r[0].dims.length;m++)(i.indexOf(m)>=0||i.length===0)&&h.push(`inputIdx[${m}] = 0;`);return[`${h.join(` +`)} +value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),n.reduceProd=(a,t,e)=>p(a,t,e,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),n.reduceLogSum=(a,t,e)=>p(a,t,e,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),n.reduceLogSumSquare=(a,t,e)=>p(a,t,e,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7019:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isReshapeCheap=n.processDims3D=n.createPackedReshape3DProgramInfoLoader=void 0;const s=o(2517),l=o(5060),f=o(2039),u=o(2827);n.createPackedReshape3DProgramInfoLoader=(p,g,c)=>{const a=(t=>({name:"Reshape (packed)",inputTypes:[f.TextureType.packed],inputNames:["A"],cacheHint:`${t}`}))(c);return Object.assign(Object.assign({},a),{get:()=>((t,e,r,i)=>{const h=e.dims,m=i;let _="";for(let T=0;T<4;T++){let w="";switch(T){case 0:w="outputCoords = rc;";break;case 1:w="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:w="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:w="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}_+=` + ${w} + ${T>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[${T}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); + + ${T>0?"}":""} + `}const b=(0,l.getGlsl)(t.session.backend.glContext.version),y=` + ${function(T){const w=s.ShapeUtil.computeStrides(T),S=["b","r","c"],E="index";return` + ivec3 inputCoordsFromReshapedOutCoords(int index) { + ${w.map((O,v)=>`int ${S[v]} = ${E} / ${O}; ${v===w.length-1?`int ${S[v+1]} = ${E} - ${S[v]} * ${O}`:`index -= ${S[v]} * ${O}`};`).join("")} + return ivec3(b, r, c); + } + `}(h)} + ${function(T){const w=s.ShapeUtil.computeStrides(T);return` + int getFlattenedIndex(ivec3 coords) { + // reverse y, z order + return coords.x * ${w[0]} + coords.z * ${w[1]} + coords.y; + } +`}(m)} + ${(0,u.unpackFromChannel)()} + + void main() { + ivec3 rc = getOutputCoords(); + + vec4 result = vec4(0.0); + + ivec3 outputCoords; + int rows = ${m[2]}; + int cols = ${m[1]}; + + ${_} + ${b.output} = result; + } + `;return Object.assign(Object.assign({},r),{output:{dims:m,type:e.type,textureType:f.TextureType.packed},shaderSource:y,hasMain:!0})})(p,g,a,c)})},n.processDims3D=function(p){if(p.length===0)return[1,1,1];let g=1;for(let c=0;c<p.length-2;++c)g*=p[c];return[g,p.length>1?p[p.length-2]:1,p[p.length-1]]},n.isReshapeCheap=function(p,g){let c=!1;return c=p.length===0||g.length===0||(p.length<2||g.length<2?p[p.length-1]===g[g.length-1]:p[p.length-1]===g[g.length-1]&&p[p.length-2]===g[g.length-2]),c}},718:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.reshape=void 0;const s=o(2517);n.reshape=(l,f)=>{const u=s.ShapeUtil.calculateReshapedDims(f[0].dims,f[1].integerData);return l.session.pack?[l.reshapePacked(f[0],u)]:[l.reshapeUnpacked(f[0],u)]}},2268:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseResizeAttributesV11=n.parseResizeAttributesV10=n.resize=void 0;const s=o(5060),l=o(2039),f=o(9390),u=o(2827),p=o(9793),g={name:"Resize",inputNames:["A"],inputTypes:[l.TextureType.packed]};n.resize=(r,i,h)=>((0,p.validateInputs)(i,h),[r.run(Object.assign(Object.assign({},g),{cacheHint:h.cacheKey,get:()=>c(r,i,h)}),i)]),n.parseResizeAttributesV10=r=>(0,p.parseUpsampleAttributes)(r,10),n.parseResizeAttributesV11=r=>(0,p.parseUpsampleAttributes)(r,11);const c=(r,i,h)=>{const m=(0,s.getGlsl)(r.session.backend.glContext.version),[_,b]=a(i,h);if(_.every(L=>L===1)&&h.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},g),{output:{dims:b,type:i[0].type,textureType:l.TextureType.packed},hasMain:!0,shaderSource:`void main() { + vec4 v = ${m.texture2D}(X, TexCoords); + ${m.output} = v; + }`});const y=b.length;if(y<2)throw new Error(`output dimension should be at least 2, but got ${y}`);const T=b[y-2],w=b[y-1],S=i[0].dims;if(y!==S.length)throw new Error(`output dimension should match input ${S.length}, but got ${y}`);const E=S[y-2],O=S[y-1],v=_[y-2],M=_[y-1];let $="";if(h.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${h.mode}'`);switch(h.coordinateTransformMode){case"asymmetric":$=` + vec4 getSourceFracIndex(ivec4 coords) { + return vec4(coords) / scaleWHWH; + } + `;break;case"half_pixel":$=` + vec4 getSourceFracIndex(ivec4 coords) { + return (vec4(coords) + 0.5) / scaleWHWH - 0.5; + } + `;break;case"pytorch_half_pixel":$=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 fcoords = vec4(coords); + return vec4( + ${w}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, + ${T}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, + ${w}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, + ${T}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 + ); + } + `;break;case"align_corners":$=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 resized = vec4(${w}.0 - 1.0, ${T}.0 - 1.0, ${w}.0 - 1.0, + ${T}.0 - 1.0); + vec4 original = vec4(${O}.0 - 1.0, ${E}.0 - 1.0, ${O}.0 - 1.0, + ${E}.0 - 1.0); + vec4 new_scale = original / resized; + return vec4(coords) * new_scale; + } + `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${h.coordinateTransformMode}'`)}const V=(0,f.getCoordsDataType)(y),B=` + const vec2 inputWH = vec2(${E}.0, ${O}.0); + const vec4 scaleWHWH = vec4(float(${v}), float(${M}), float(${v}), float(${M})); + ${(0,u.unpackFromChannel)()} + ${$} + float getAValue(int x10, int r, int c, int d) { + return getChannel(getA(x10, r, c, d), vec2(c, d)); + } + void main() { + ${V} 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 < ${T-1}; + bool hasNextCol = rc.z < ${w-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); + + ${m.output} = vec4(newValue); + } + `;return Object.assign(Object.assign({},g),{output:{dims:b,type:i[0].type,textureType:l.TextureType.packed},hasMain:!0,shaderSource:B})},a=(r,i)=>{const h=r[0].dims;let m,_=i.scales;if(_.length===0){const y=r[i.scalesInputIdx];if(y&&y.size!==0){if(r[i.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");_=t(y,i.mode,i.isResize)}else{const T=r[i.sizesInputIdx];if(!T||T.size===0)throw new Error("Either scales or sizes MUST be provided as input.");m=Array.from(T.integerData),_=e(m,h,i.mode,i.isResize)}}else if(r[i.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const b=m||h.map((y,T)=>Math.floor(y*_[T]));return[_,b]},t=(r,i,h)=>{const m=Array.from(r.floatData);return(0,p.scalesValidation)(m,i,h),m},e=(r,i,h,m)=>{const _=i.length,b=new Array(_);for(let y=0,T=_;y<T;y++)if(i[y]===0){if(r[y]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");b[y]=1}else b[y]=r[y]/i[y];return(0,p.scalesValidation)(b,h,m),b}},8117:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.shape=void 0;const s=o(9162);n.shape=(f,u)=>(l(u),[new s.Tensor([u[0].dims.length],"int32",void 0,void 0,new Int32Array(u[0].dims))]);const l=f=>{if(!f||f.length!==1)throw new Error("Shape requires 1 input.")}},2278:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.sliceV10=n.parseSliceAttributes=n.slice=void 0;const s=o(246),l=o(782),f=o(2517),u=o(2039),p={name:"Slice",inputNames:["A"],inputTypes:[u.TextureType.unpacked]};n.slice=(e,r,i)=>(c(r),[e.run(Object.assign(Object.assign({},p),{cacheHint:i.cacheKey,get:()=>g(e,r[0],i)}),r)]),n.parseSliceAttributes=e=>{const r=e.attributes.getInts("starts"),i=e.attributes.getInts("ends"),h=e.attributes.getInts("axes",[]);return(0,s.createAttributeWithCacheKey)({starts:r,ends:i,axes:h})};const g=(e,r,i)=>{const h=i.axes.length===0?r.dims.slice(0).map((S,E)=>E):i.axes,m=f.ShapeUtil.normalizeAxes(h,r.dims.length),_=i.starts.map((S,E)=>S>r.dims[m[E]]-1?r.dims[m[E]]:f.ShapeUtil.normalizeAxis(S,r.dims[m[E]])),b=i.ends.map((S,E)=>S>r.dims[m[E]]-1?r.dims[m[E]]:f.ShapeUtil.normalizeAxis(S,r.dims[m[E]])),y=r.dims.slice(),T=[];for(let S=0;S<m.length;S++)y[m[S]]=b[S]-_[S],_[S]>0&&T.push(`outputIdx[${m[S]}] += ${_[S]};`);const w=` + float process(int outputIdx[${y.length}]) { + ${T.join(` + `)} + return _A(outputIdx); + }`;return Object.assign(Object.assign({},p),{output:{dims:y,type:r.type,textureType:u.TextureType.unpacked},shaderSource:w})},c=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(l.NUMBER_TYPES.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")};n.sliceV10=(e,r)=>{t(r);const i=a(e,r);return[e.run(Object.assign(Object.assign({},p),{cacheHint:i.cacheKey,get:()=>g(e,r[0],i)}),[r[0]])]};const a=(e,r)=>{if(!e.session.isInitializer(r[1].dataId)||!e.session.isInitializer(r[2].dataId)||r.length>=4&&!e.session.isInitializer(r[3].dataId)||r.length>=5&&!e.session.isInitializer(r[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(r.length>=5&&r[4].integerData.some(_=>_!==1))throw new Error("currently non-1 steps is not supported for Slice");const i=Array.from(r[1].integerData),h=Array.from(r[2].integerData),m=r.length>=4?Array.from(r[3].integerData):[];return{starts:i,ends:h,axes:m,cacheKey:`${m};${i};${h}`}},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,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.softmaxV13=n.parseSoftmaxAttributesV13=n.parseSoftmaxAttributes=n.softmax=void 0;const s=o(246),l=o(2517),f=o(5060),u=o(2039),p=o(3738),g={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[u.TextureType.unpacked]},c={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[u.TextureType.unpacked,u.TextureType.unpacked]},a={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[u.TextureType.unpacked,u.TextureType.unpacked,u.TextureType.unpacked]};n.softmax=(m,_,b)=>{h(_);const y=_[0].dims.slice(),T=l.ShapeUtil.normalizeAxis(b.axis,y.length),w=l.ShapeUtil.sizeToDimension(y,T),S=l.ShapeUtil.sizeFromDimension(y,T);return t(m,_,b,w,S)},n.parseSoftmaxAttributes=m=>(0,s.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",1)}),n.parseSoftmaxAttributesV13=m=>(0,s.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",-1)}),n.softmaxV13=(m,_,b)=>{h(_);const y=_[0].dims.slice(),T=l.ShapeUtil.normalizeAxis(b.axis,y.length),w=y.length,S=T!==w-1,E=[];let O,v=[],M=[];S&&(v=Array.from({length:w}).map((L,D)=>D),v[T]=w-1,v[w-1]=T,v.map(L=>E.push(y[L])),O=(0,s.createAttributeWithCacheKey)({perm:v}),M=(0,p.transpose)(m,_,O));const $=S?l.ShapeUtil.sizeToDimension(E,w-1):l.ShapeUtil.sizeToDimension(y,w-1),V=S?l.ShapeUtil.sizeFromDimension(E,w-1):l.ShapeUtil.sizeFromDimension(y,w-1),B=t(m,S?M:_,b,$,V);return S?(0,p.transpose)(m,B,O):B};const t=(m,_,b,y,T)=>{const w=e(m,_[0],y,T,[y]),S=m.run(Object.assign(Object.assign({},g),{cacheHint:b.cacheKey,get:()=>w}),_),E=r(m,_[0],y,T,w.output.dims,[y]),O=m.run(Object.assign(Object.assign({},c),{cacheHint:b.cacheKey,get:()=>E}),[_[0],S]),v=i(m,_[0],y,T,w.output.dims,E.output.dims);return[m.run(Object.assign(Object.assign({},a),{cacheHint:b.cacheKey,get:()=>v}),[_[0],S,O])]},e=(m,_,b,y,T)=>{const[w,S]=m.calculateTextureWidthAndHeight(_.dims,u.TextureType.unpacked),E=T.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1)throw new Error("Dimensionality of the output should be 1");if(T[0]!==b)throw new Error("Shape of the output should be equal to logical row count");const O=(0,f.getGlsl)(m.session.backend.glContext.version),v=` + float process(int[${E}] indices) { + int logical_row_start_offset = indices[0] * ${y}; + + float max = getColorAsFloat(${O.texture2D}(A, offsetToCoords(logical_row_start_offset, ${w}, + ${S} ))); + for(int i=1; i<${y}; ++i) + { + float current = getColorAsFloat(${O.texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${w}, ${S}))); + if(current > max) + max = current; + } + + return max; + }`;return Object.assign(Object.assign({},g),{output:{dims:T,type:_.type,textureType:u.TextureType.unpacked},shaderSource:v})},r=(m,_,b,y,T,w)=>{const[S,E]=m.calculateTextureWidthAndHeight(_.dims,u.TextureType.unpacked),O=w.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(w.length!==1)throw new Error("Dimensionality of the output should be 1");if(w[0]!==b)throw new Error("Shape of the output should be equal to logical row count");if(T.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(T[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const v=` + float process(int[${O}] 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,f.getGlsl)(m.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${S}, ${E}))) - max); + } + + return norm_factor; + }`;return Object.assign(Object.assign({},c),{output:{dims:w,type:_.type,textureType:u.TextureType.unpacked},shaderSource:v})},i=(m,_,b,y,T,w)=>{const[S,E]=m.calculateTextureWidthAndHeight(_.dims,u.TextureType.unpacked),O=_.dims.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1||w.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(T[0]!==b||w[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const v=` + float process(int[${O}] indices) { + + // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) + int offset = coordsToOffset(TexCoords, ${S}, ${E}); + + //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({},a),{output:{dims:_.dims,type:_.type,textureType:u.TextureType.unpacked},shaderSource:v})},h=m=>{if(!m||m.length!==1)throw new Error("Softmax requires 1 input.");if(m[0].type!=="float32"&&m[0].type!=="float64")throw new Error("Invalid input type")}},5975:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseSplitAttributes=n.split=void 0;const s=o(246),l=o(2517),f=o(2039),u={name:"Split",inputNames:["A"],inputTypes:[f.TextureType.unpacked]};n.split=(a,t,e)=>{c(t);const r=l.ShapeUtil.normalizeAxis(e.axis,t[0].dims.length),i=p(a,t,r,e),h=[];for(let m=0;m<i;++m)h.push(a.run(Object.assign(Object.assign({},u),{cacheHint:`${e.cacheKey};${m}`,get:()=>g(a,t[0],e,r,m)}),t));return h},n.parseSplitAttributes=a=>{const t=a.attributes.getInt("axis",0),e=a.attributes.getInts("split",[]),r=a.outputs.length;return(0,s.createAttributeWithCacheKey)({axis:t,split:e,numOutputs:r})};const p=(a,t,e,r)=>{const[,i]=l.SplitUtil.splitShape(t[0].dims,e,r.split,r.numOutputs);return i.length},g=(a,t,e,r,i)=>{const[h,m]=l.SplitUtil.splitShape(t.dims,r,e.split,e.numOutputs),_=m[i],b=h[i],y=` + float process(int indices[${b.length}]) { + indices[${r}] += ${_}; + return _A(indices); + } + `;return Object.assign(Object.assign({},u),{cacheHint:`${e.cacheKey}:${i}`,output:{dims:b,type:t.type,textureType:f.TextureType.unpacked},shaderSource:y})},c=a=>{if(!a||a.length!==1)throw new Error("Split requires one input.");if(a[0].type!=="int8"&&a[0].type!=="uint8"&&a[0].type!=="int16"&&a[0].type!=="uint16"&&a[0].type!=="int32"&&a[0].type!=="uint32"&&a[0].type!=="float32"&&a[0].type!=="float64"&&a[0].type!=="bool")throw new Error("Invalid input type.")}},3933:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseSqueezeAttributes=n.squeezeV13=n.squeeze=void 0;const s=o(2517);n.squeeze=(u,p,g)=>{l(p);const c=s.ShapeUtil.squeezeShape(p[0].dims,g);return[u.reshapeUnpacked(p[0],c)]},n.squeezeV13=(u,p)=>(f(p),(0,n.squeeze)(u,[p[0]],Array.from(p[1].integerData))),n.parseSqueezeAttributes=u=>u.attributes.getInts("axes");const l=u=>{if(!u||u.length!==1)throw new Error("Squeeze requires 1 input.");if(u[0].type==="string")throw new Error("invalid input tensor types.")},f=u=>{if(!u||u.length!==2)throw new Error("Squeeze requires 2 inputs.");if(u[1].type!=="int32")throw new Error("Invalid input type.")}},6558:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.sum=void 0;const s=o(5060),l=o(2039);n.sum=(p,g)=>{u(g);const c={name:"Sum",inputNames:g.map((a,t)=>`X${t}`),inputTypes:new Array(g.length).fill(l.TextureType.unpacked)};return[p.run(Object.assign(Object.assign({},c),{get:()=>f(p,g,c)}),g)]};const f=(p,g,c)=>{const a=(0,s.getGlsl)(p.session.backend.glContext.version),t=g[0].dims.slice(),e=` + void main() { + vec4 result = ${g.map((r,i)=>`${a.texture2D}(X${i},TexCoords)`).join(" + ")}; + ${a.output} = result; + } + `;return Object.assign(Object.assign({},c),{output:{dims:t,type:g[0].type,textureType:l.TextureType.unpacked},hasMain:!0,shaderSource:e})},u=p=>{if(!p||p.length===0)throw new Error("Sum requires inputs.");const g=p[0].dims.length;for(let c=1;c<p.length;c++){if(g!==p[c].dims.length)throw new Error("Input shapes are mismatched.");for(let a=0;a<g;a++)if(p[0].dims[a]!==p[c].dims[a])throw new Error("Input shapes are not matched.")}if(p[0].type!=="float32"&&p[0].type!=="float64")throw new Error("Invalid input type.");for(let c=1;c<p.length;c++)if(p[0].type!==p[c].type)throw new Error("Input types are not matched.")}},5723:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tile=void 0;const s=o(782),l=o(2039);n.tile=(p,g)=>{u(g);const c={name:"Tile",inputNames:["A"],inputTypes:[l.TextureType.unpacked]};return[p.run(Object.assign(Object.assign({},c),{get:()=>f(p,g,c)}),g)]};const f=(p,g,c)=>{const a=g[0].dims.slice(),t=new Array(a.length),e=[];for(let h=0;h<a.length;h++)t[h]=a[h]*g[1].numberData[h],e.push(`inputIdx[${h}] = int(mod(float(outputIdx[${h}]), ${a[h]}.));`);const r=t.length,i=` + float process(int outputIdx[${r}]) { + int inputIdx[${r}]; + ${e.join(` +`)} + return _A(inputIdx); + } + `;return Object.assign(Object.assign({},c),{output:{dims:t,type:g[0].type,textureType:l.TextureType.unpacked},shaderSource:i})},u=p=>{if(!p||p.length!==2)throw new Error("Tile requires 2 input.");if(p[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(p[1].dims[0]!==p[0].dims.length)throw new Error("Invalid input shape.");if(s.NUMBER_TYPES.indexOf(p[0].type)===-1)throw new Error("Invalid input type.");if(p[1].type!=="int32"&&p[1].type!=="int16")throw new Error("Invalid repeat type.")}},3738:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseTransposeAttributes=n.transpose=void 0;const s=o(246),l=o(2517),f=o(2039),u={name:"Transpose",inputNames:["A"],inputTypes:[f.TextureType.unpacked]};n.transpose=(e,r,i)=>(t(r),[e.run(Object.assign(Object.assign({},u),{cacheHint:i.cacheKey,get:()=>p(e,r[0],i.perm)}),r)]),n.parseTransposeAttributes=e=>(0,s.createAttributeWithCacheKey)({perm:e.attributes.getInts("perm",[])});const p=(e,r,i)=>{const h=r.dims;i=g(h,i);const m=c(h,i),_=h.length,b=` + ${a("perm",i,_)} + float process(int indices[${_}]) { + int a[${_}]; + perm(a, indices); + return _A(a); + }`;return Object.assign(Object.assign({},u),{output:{dims:m,type:r.type,textureType:f.TextureType.unpacked},shaderSource:b})},g=(e,r)=>(r&&r.length!==e.length&&(r=[...e.keys()].reverse()),r),c=(e,r)=>(r=g(e,r),l.ShapeUtil.sortBasedOnPerm(e,r)),a=(e,r,i)=>{const h=[];h.push(`void ${e}(out int a[${i}], int src[${i}]) {`);for(let m=0;m<i;++m)h.push(` a[${r[m]}]=src[${m}];`);return h.push(" }"),h.join(` +`)},t=e=>{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,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.encodeAsUint8=void 0;const s=o(5060),l=o(2039);n.encodeAsUint8=(f,u)=>{const p=u.shape,g=(0,s.getGlsl)(f.session.backend.glContext.version),c=` + 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 = ${g.texture2D}(X,TexCoords).r; + ${g.output} = encodeAsUint8(value); + }`,a={name:"Uint8Encode",inputTypes:[l.TextureType.unpacked],inputNames:["X"],output:{dims:p,type:u.tensor.type,textureType:l.TextureType.downloadUint8AsFloat},shaderSource:c,hasMain:!0};return f.executeProgram(a,[u.tensor])}},4909:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tanh=n.tan=n.sqrt=n.sin=n.sigmoid=n.relu=n.not=n.neg=n.log=n.parseLeakyReluAttributes=n.leakyRelu=n.identity=n.floor=n.exp=n.parseEluAttributes=n.elu=n.cos=n.ceil=n.clipV11=n.parseClipAttributes=n.clip=n.atan=n.asin=n.acos=n.abs=n.glslTanh=n.glslTan=n.glslSqrt=n.glslSigmoid=n.glslRelu=n.glslSin=n.glslNot=n.glslNeg=n.glslLog=n.glslLeakyRelu=n.glslIdentity=n.glslClip=n.glslFloor=n.glslExp=n.glslElu=n.glslCos=n.glslCeil=n.glslAtan=n.glslAsin=n.glslAcos=n.glslAbs=void 0;const s=o(246),l=o(2517),f=o(8520),u=o(5060),p=o(2039);function g(){return B("abs")}function c(){return B("acos")}function a(){return B("asin")}function t(){return B("atan")}function e(){return B("ceil")}function r(){return B("cos")}function i(k){const F="elu";return{body:` + const float alpha = float(${k}); + + float ${F}_(float a) { + return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; + } + vec4 ${F}_(vec4 v) { + return vec4(${F}_(v.x), ${F}_(v.y), ${F}_(v.z), ${F}_(v.w)); + } + `,name:F,type:f.FunctionType.ValueBased}}function h(){return B("exp")}function m(){return B("floor")}function _(k,F){const Q="clip";return{body:` + const float min = float(${k}); + const float max = float(${F}); + + float ${Q}_(float a) { + return clamp(a, min, max); + } + vec4 ${Q}_(vec4 v) { + return clamp(v, min, max); + } + `,name:Q,type:f.FunctionType.ValueBased}}function b(){const k="indentity";return{body:` + float ${k}_(float a) { + return a; + } + vec4 ${k}_(vec4 v) { + return v; + } + `,name:k,type:f.FunctionType.ValueBased}}function y(k){const F="leakyRelu";return{body:` + const float alpha = float(${k}); + + float ${F}_(float a) { + return a < 0.0 ? a * alpha : a; + } + vec4 ${F}_(vec4 v) { + return vec4(${F}_(v.x), ${F}_(v.y), ${F}_(v.z), ${F}_(v.w)); + } + `,name:F,type:f.FunctionType.ValueBased}}function T(){return B("log")}function w(){const k="neg";return{body:` + float ${k}_(float a) { + return -a; + } + vec4 ${k}_(vec4 v) { + return -v; + } + `,name:k,type:f.FunctionType.ValueBased}}function S(){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:f.FunctionType.ValueBased}}function E(){return B("sin")}function O(){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:f.FunctionType.ValueBased}}function v(){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:f.FunctionType.ValueBased}}function M(){return B("sqrt")}function $(){return B("tan")}function V(){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:f.FunctionType.ValueBased}}function B(k){return{body:` + float ${k}_(float a) { + return ${k}(a); + } + vec4 ${k}_(vec4 v) { + return ${k}(v); + } + `,name:k,type:f.FunctionType.ValueBased}}n.glslAbs=g,n.glslAcos=c,n.glslAsin=a,n.glslAtan=t,n.glslCeil=e,n.glslCos=r,n.glslElu=i,n.glslExp=h,n.glslFloor=m,n.glslClip=_,n.glslIdentity=b,n.glslLeakyRelu=y,n.glslLog=T,n.glslNeg=w,n.glslNot=S,n.glslSin=E,n.glslRelu=O,n.glslSigmoid=v,n.glslSqrt=M,n.glslTan=$,n.glslTanh=V;const L=(k,F,Q,Y)=>{const ee=k.session.pack?p.TextureType.packed:p.TextureType.unpacked,te={name:Q.name,inputTypes:[ee],inputNames:["A"],cacheHint:Y};return Object.assign(Object.assign({},te),{get:()=>((he,Oe,xe,ue)=>{const Se=he.session.pack?p.TextureType.packed:p.TextureType.unpacked,we=(0,u.getGlsl)(he.session.backend.glContext.version);return Object.assign(Object.assign({},Oe),{output:{dims:xe.dims,type:xe.type,textureType:Se},shaderSource:` + ${ue.body} + void main() { + vec4 v = ${we.texture2D}(A, TexCoords); + v = ${ue.name}_(v); + ${we.output} = v; + } + `,hasMain:!0})})(k,te,F,Q)})};n.abs=(k,F)=>[k.run(L(k,F[0],g()),F)],n.acos=(k,F)=>[k.run(L(k,F[0],c()),F)],n.asin=(k,F)=>[k.run(L(k,F[0],a()),F)],n.atan=(k,F)=>[k.run(L(k,F[0],t()),F)],n.clip=(k,F,Q)=>[k.run(L(k,F[0],_(Q.min,Q.max),Q.cacheKey),F)],n.parseClipAttributes=k=>(0,s.createAttributeWithCacheKey)({min:k.attributes.getFloat("min",l.MIN_CLIP),max:k.attributes.getFloat("max",l.MAX_CLIP)}),n.clipV11=(k,F)=>{const Q=D(k,F);return(0,n.clip)(k,[F[0]],Q)};const D=(k,F)=>{if(F.length>=3&&(!k.session.isInitializer(F[1].dataId)||!k.session.isInitializer(F[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const Q=F.length>=3?F[1].numberData[0]:l.MIN_CLIP,Y=F.length>=3?F[2].numberData[0]:l.MAX_CLIP;return(0,s.createAttributeWithCacheKey)({min:Q,max:Y})};n.ceil=(k,F)=>[k.run(L(k,F[0],e()),F)],n.cos=(k,F)=>[k.run(L(k,F[0],r()),F)],n.elu=(k,F,Q)=>[k.run(L(k,F[0],i(Q.alpha),Q.cacheKey),F)],n.parseEluAttributes=k=>(0,s.createAttributeWithCacheKey)({alpha:k.attributes.getFloat("alpha",1)}),n.exp=(k,F)=>[k.run(L(k,F[0],h()),F)],n.floor=(k,F)=>[k.run(L(k,F[0],m()),F)],n.identity=(k,F)=>[k.run(L(k,F[0],b()),F)],n.leakyRelu=(k,F,Q)=>[k.run(L(k,F[0],y(Q.alpha),Q.cacheKey),F)],n.parseLeakyReluAttributes=k=>(0,s.createAttributeWithCacheKey)({alpha:k.attributes.getFloat("alpha",.01)}),n.log=(k,F)=>[k.run(L(k,F[0],T()),F)],n.neg=(k,F)=>[k.run(L(k,F[0],w()),F)],n.not=(k,F)=>[k.run(L(k,F[0],S()),F)],n.relu=(k,F)=>[k.run(L(k,F[0],O()),F)],n.sigmoid=(k,F)=>[k.run(L(k,F[0],v()),F)],n.sin=(k,F)=>[k.run(L(k,F[0],E()),F)],n.sqrt=(k,F)=>[k.run(L(k,F[0],M()),F)],n.tan=(k,F)=>[k.run(L(k,F[0],$()),F)],n.tanh=(k,F)=>[k.run(L(k,F[0],V()),F)]},5611:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createUnpackProgramInfoLoader=n.createUnpackProgramInfo=void 0;const s=o(5060),l=o(2039),f=o(9390),u=o(2827),p={name:"unpack",inputNames:["A"],inputTypes:[l.TextureType.packed]};n.createUnpackProgramInfo=(g,c)=>{const a=c.dims.length,t=(0,u.getChannels)("rc",a),e=t.slice(-2),r=(0,f.getCoordsDataType)(a),i=(0,u.unpackFromChannel)(),h=c.dims.length===0?"":function(b,y){if(b===1)return"rc";let T="";for(let w=0;w<b;w++)T+=y[w],w<b-1&&(T+=",");return T}(a,t),m=a<=1?"rc":`vec2(${e.join(",")})`,_=` + ${i} + void main() { + ${r} rc = getOutputCoords(); + + // Sample the texture with the coords to get the rgba channel value. + vec4 packedInput = getA(${h}); + + ${(0,s.getGlsl)(g.session.backend.glContext.version).output} = vec4(getChannel(packedInput, ${m}), 0, 0, 0); + } + `;return Object.assign(Object.assign({},p),{hasMain:!0,output:{dims:c.dims,type:c.type,textureType:l.TextureType.unpacked},shaderSource:_})},n.createUnpackProgramInfoLoader=(g,c)=>Object.assign(Object.assign({},p),{get:()=>(0,n.createUnpackProgramInfo)(g,c)})},8428:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.parseUnsqueezeAttributes=n.unsqueezeV13=n.unsqueeze=void 0;const s=o(2517);n.unsqueeze=(u,p,g)=>{l(p);const c=s.ShapeUtil.unsqueezeShape(p[0].dims,g);return[u.reshapeUnpacked(p[0],c)]},n.unsqueezeV13=(u,p)=>(f(p),(0,n.unsqueeze)(u,[p[0]],Array.from(p[1].integerData))),n.parseUnsqueezeAttributes=u=>u.attributes.getInts("axes");const l=u=>{if(!u||u.length!==1)throw new Error("Unsqueeze requires 1 input.");if(u[0].type==="string")throw new Error("invalid input tensor types.")},f=u=>{if(!u||u.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(u[1].type!=="int32")throw new Error("Invalid input type.")}},9793:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.scalesValidation=n.validateInputs=n.parseUpsampleAttributes=n.parseUpsampleAttributesV9=n.parseUpsampleAttributesV7=n.upsample=void 0;const s=o(246),l=o(5060),f=o(2039),u={name:"Upsample",inputNames:["X"],inputTypes:[f.TextureType.unpacked]};n.upsample=(g,c,a)=>((0,n.validateInputs)(c,a),[g.run(Object.assign(Object.assign({},u),{cacheHint:a.cacheKey,get:()=>p(g,c,a)}),c)]),n.parseUpsampleAttributesV7=g=>(0,n.parseUpsampleAttributes)(g,7),n.parseUpsampleAttributesV9=g=>(0,n.parseUpsampleAttributes)(g,9),n.parseUpsampleAttributes=(g,c)=>{const a=c>=10,t=g.attributes.getString("mode","nearest");if(t!=="nearest"&&t!=="linear"&&(c<11||t!=="cubic"))throw new Error(`unrecognized mode: ${t}`);let e=[];c<9&&(e=g.attributes.getFloats("scales"),(0,n.scalesValidation)(e,t,a));const r=g.attributes.getFloat("extrapolation_value",0),i=c>10?g.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(i)===-1)throw new Error(`coordinate_transform_mode '${i}' is not supported`);const h=i==="tf_crop_and_resize",m=h,_=t==="nearest"&&c>=11?g.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(_)===-1)throw new Error(`nearest_mode '${_}' is not supported`);const b=g.attributes.getFloat("cubic_coeff_a",-.75),y=g.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 T=c<11||t==="nearest"&&i==="asymmetric"&&_==="floor";let w=0,S=0,E=0;return c>10?g.inputs.length>2?(w=1,S=2,E=3):(S=1,E=2):c===9&&(S=1),(0,s.createAttributeWithCacheKey)({opset:c,isResize:a,mode:t,scales:e,extrapolationValue:r,coordinateTransformMode:i,useExtrapolation:m,needRoiInput:h,nearestMode:_,cubicCoefficientA:b,excludeOutside:y,useNearest2xOptimization:T,roiInputIdx:w,scalesInputIdx:S,sizesInputIdx:E})};const p=(g,c,a)=>{const t=(0,l.getGlsl)(g.session.backend.glContext.version),[e,r]=g.calculateTextureWidthAndHeight(c[0].dims,f.TextureType.unpacked),i=c[0].dims.map((E,O)=>Math.floor(E*a.scales[O])),[h,m]=g.calculateTextureWidthAndHeight(i,f.TextureType.unpacked),_=i.length,b=new Array(_),y=new Array(_);let T=` + int output_pitches[${_}]; + int input_pitches[${_}]; + `;for(let E=_-1;E>=0;E--)b[E]=E===_-1?1:b[E+1]*i[E+1],y[E]=E===_-1?1:y[E+1]*c[0].dims[E+1],T+=` + output_pitches[${E}] = ${b[E]}; + input_pitches[${E}] = ${y[E]}; + `;const w=` + float getInputFloat(int index) { + vec2 coords = offsetToCoords(index, ${e}, ${r}); + float value = getColorAsFloat(${t.texture2D}(X, coords)); + return value; + } + `,S=a.mode==="nearest"?` + ${w} + float process(int indices[${_}]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${h}, ${m}); + + ${T} + + int d, m; + for (int dim = 0; dim < ${_}; ++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); + }`:_===4?` + ${w} + float process(int indices[4]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${h}, ${m}); + + ${T} + + 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 == (${c[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]); + }`:` + ${w} + float process(int indices[2]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${h}, ${m}); + + ${T} + + 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 == (${c[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({},u),{output:{dims:i,type:c[0].type,textureType:f.TextureType.unpacked},shaderSource:S,variables:[{name:"scales",type:"int",arrayLength:a.scales.length,data:a.scales.map(E=>Math.ceil(E))}]})};n.validateInputs=(g,c)=>{if(!g||c.opset<9&&g.length!==1||c.opset>=9&&c.opset<11&&g.length!==2||c.opset>=11&&g.length<2)throw new Error("invalid inputs.");if(c.scales.length>0&&g[0].dims.length!==c.scales.length)throw new Error("Invalid input shape.");if(g[0].type==="string")throw new Error("Invalid input tensor types.")},n.scalesValidation=(g,c,a)=>{if(a){for(const t of g)if(t<=0)throw new Error("Scale value should be greater than 0.")}else for(const t of g)if(t<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(c!=="linear"&&c!=="cubic"||g.length===2||g.length===4&&g[0]===1&&g[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 ${a?"Resize":"Upsample"} opeartor.`)}},1958:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ProgramManager=void 0;const s=o(1670),l=o(6231),f=o(8879),u=o(5060);n.ProgramManager=class{constructor(p,g,c){this.profiler=p,this.glContext=g,this.textureLayoutStrategy=c,this.repo=new Map,this.attributesBound=!1}getArtifact(p){return this.repo.get(p)}setArtifact(p,g){this.repo.set(p,g)}run(p,g,c){var a;this.profiler.event("op",`ProgramManager.run ${(a=p.programInfo.name)!==null&&a!==void 0?a:"unknown kernel"}`,()=>{var t;const e=this.glContext.gl,r=p.program;e.useProgram(r);try{this.bindOutput(c),this.attributesBound||this.bindAttributes(p.attribLocations),this.bindUniforms(p.uniformLocations,(t=p.programInfo.variables)!==null&&t!==void 0?t:[],g)}catch(i){throw l.Logger.error("ProgramManager",p.programInfo.shaderSource),i}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(p=>this.glContext.deleteProgram(p.program))}build(p,g,c){return this.profiler.event("backend","ProgramManager.build",()=>{const a=new f.GlslPreprocessor(this.glContext,p,g,c),t=a.preprocess(),e=this.compile(t);return{programInfo:p,program:e,uniformLocations:this.getUniformLocations(e,a.context.programInfo.inputNames,a.context.programInfo.variables),attribLocations:this.getAttribLocations(e)}})}compile(p){if(!this.vertexShader){l.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const a=(0,u.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(a,this.glContext.gl.VERTEX_SHADER)}s.env.debug&&l.Logger.verbose("ProrgramManager",`FragShader: +${p} +`);const g=this.glContext.compileShader(p,this.glContext.gl.FRAGMENT_SHADER),c=this.glContext.createProgram(this.vertexShader,g);return this.glContext.deleteShader(g),c}bindOutput(p){const g=p.width,c=p.height;l.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${g}/${c}, shape=${p.shape}, type=${p.tensor.type}`),this.glContext.attachFramebuffer(p.texture,g,c)}bindAttributes(p){const g=p.position,c=p.textureCoord;this.glContext.setVertexAttributes(g,c),this.attributesBound=!0}bindUniforms(p,g,c){var a;const t=this.glContext.gl;let e=0;for(const{name:r,type:i,location:h,arrayLength:m}of p){const _=(a=g.find(b=>b.name===r))===null||a===void 0?void 0:a.data;if(i!=="sampler2D"&&!_)throw new Error(`variable '${r}' does not have data defined in program info`);switch(i){case"sampler2D":this.bindTexture(c[e],h,e),e++;break;case"float":m?t.uniform1fv(h,_):t.uniform1f(h,_);break;case"int":m?t.uniform1iv(h,_):t.uniform1i(h,_);break;default:throw new Error(`Uniform not implemented: ${i}`)}}}bindTexture(p,g,c){this.glContext.bindTextureToUniform(p.texture,c,g)}getAttribLocations(p){return{position:this.getAttribLocation(p,"position"),textureCoord:this.getAttribLocation(p,"textureCoord")}}getUniformLocations(p,g,c){const a=[];if(g)for(const t of g)a.push({name:t,type:"sampler2D",location:this.getUniformLocation(p,t)});if(c)for(const t of c)a.push(Object.assign(Object.assign({},t),{location:this.getUniformLocation(p,t.name)}));return a}getUniformLocation(p,g){const c=this.glContext.gl.getUniformLocation(p,g);if(c===null)throw new Error(`Uniform ${g} not found.`);return c}getAttribLocation(p,g){return this.glContext.gl.getAttribLocation(p,g)}}},6416:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WebGLSessionHandler=void 0;const s=o(6231),l=o(1047),f=o(8316),u=o(1640),p=o(1958),g=o(7859),c=o(5702);n.WebGLSessionHandler=class{constructor(a,t){this.backend=a,this.context=t,this.layoutStrategy=new g.PreferLogicalStrategy(a.glContext.maxTextureSize),this.programManager=new p.ProgramManager(this.context.profiler,a.glContext,this.layoutStrategy),this.textureManager=new c.TextureManager(a.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:a.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=a.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new f.WebGLInferenceHandler(this)}onGraphInitialized(a){const t=a.getValues().filter(e=>e.from===-1&&e.tensor).map(e=>e.tensor.dataId);this.initializers=new Set(t)}isInitializer(a){return!!this.initializers&&this.initializers.has(a)}addInitializer(a){this.initializers.add(a)}getTextureData(a,t){return t?this.packedTextureDataCache.get(a):this.unpackedTextureDataCache.get(a)}setTextureData(a,t,e=!1){s.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),e?this.packedTextureDataCache.set(a,t):this.unpackedTextureDataCache.set(a,t)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(a=>this.textureManager.releaseTexture(a,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(a=>this.textureManager.releaseTexture(a,!0)),this.unpackedTextureDataCache=new Map}resolve(a,t,e){const r=(0,l.resolveOperator)(a,t,u.WEBGL_OP_RESOLVE_RULES);return{impl:r.opImpl,context:r.opInit?r.opInit(a,e):a}}}},7769:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Uint8DataEncoder=n.RGBAFloatDataEncoder=n.RedFloat32DataEncoder=void 0;const s=o(6231);n.RedFloat32DataEncoder=class{constructor(l,f=1){if(f===1)this.internalFormat=l.R32F,this.format=l.RED,this.textureType=l.FLOAT,this.channelSize=f;else{if(f!==4)throw new Error(`Invalid number of channels: ${f}`);this.internalFormat=l.RGBA32F,this.format=l.RGBA,this.textureType=l.FLOAT,this.channelSize=f}}encode(l,f){let u,p;return l.constructor!==Float32Array&&(s.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),p=new Float32Array(l)),f*this.channelSize>l.length?(s.Logger.warning("Encoder","Source data too small. Allocating larger array"),p=l,u=this.allocate(f*this.channelSize),p.forEach((g,c)=>u[c]=g)):(p=l,u=p),u}allocate(l){return new Float32Array(4*l)}decode(l,f){return this.channelSize===1?l.filter((u,p)=>p%4==0).subarray(0,f):l.subarray(0,f)}},n.RGBAFloatDataEncoder=class{constructor(l,f=1,u){if(f!==1&&f!==4)throw new Error(`Invalid number of channels: ${f}`);this.internalFormat=l.RGBA,this.format=l.RGBA,this.channelSize=f,this.textureType=u||l.FLOAT}encode(l,f){let u=l;return this.channelSize===1&&(s.Logger.verbose("Encoder","Exploding into a larger array"),u=this.allocate(f),l.forEach((p,g)=>u[4*g]=p)),u}allocate(l){return new Float32Array(4*l)}decode(l,f){return this.channelSize===1?l.filter((u,p)=>p%4==0).subarray(0,f):l.subarray(0,f)}},n.Uint8DataEncoder=class{constructor(l,f=1){if(this.channelSize=4,f===1)this.internalFormat=l.ALPHA,this.format=l.ALPHA,this.textureType=l.UNSIGNED_BYTE,this.channelSize=f;else{if(f!==4)throw new Error(`Invalid number of channels: ${f}`);this.internalFormat=l.RGBA,this.format=l.RGBA,this.textureType=l.UNSIGNED_BYTE,this.channelSize=f}}encode(l,f){return new Uint8Array(l.buffer,l.byteOffset,l.byteLength)}allocate(l){return new Uint8Array(l*this.channelSize)}decode(l,f){if(l instanceof Uint8Array)return l.subarray(0,f);throw new Error(`Invalid array type: ${l.constructor}`)}}},7859:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getBatchDim=n.sizeToSquarishShape=n.getRowsCols=n.sizeFromShape=n.isInt=n.parseAxisParam=n.squeezeShape=n.PreferLogicalStrategy=n.AlwaysKeepOriginalSizeStrategy=void 0;const s=o(6231),l=o(2517);function f(a,t){const e=[],r=[],i=t!=null&&Array.isArray(t)&&t.length===0,h=t==null||i?null:u(t,a).sort();let m=0;for(let _=0;_<a.length;++_){if(h!=null){if(h[m]===_&&a[_]!==1)throw new Error(`Can't squeeze axis ${_} since its dim '${a[_]}' is not 1`);(h[m]==null||h[m]>_)&&a[_]===1&&(e.push(a[_]),r.push(_)),h[m]<=_&&m++}a[_]!==1&&(e.push(a[_]),r.push(_))}return{newShape:e,keptDims:r}}function u(a,t){const e=t.length;return a=a==null?t.map((r,i)=>i):[].concat(a),(0,l.assert)(a.every(r=>r>=-e&&r<e),()=>`All values in axis param must be in range [-${e}, ${e}) but got axis ${a}`),(0,l.assert)(a.every(p),()=>`All values in axis param must be integers but got axis ${a}`),a.map(r=>r<0?e+r:r)}function p(a){return a%1==0}function g(a){if(a.length===0)return 1;let t=a[0];for(let e=1;e<a.length;e++)t*=a[e];return t}function c(a){const t=Math.ceil(Math.sqrt(a));return[t,Math.ceil(a/t)]}n.AlwaysKeepOriginalSizeStrategy=class{constructor(a){this.maxTextureSize=a}computeTextureWH(a,t){if(a.length===0)return[1,1];const e=this.maxTextureSize;if(t&&t.breakAxis!==void 0){const h=t.breakAxis>=a.length?1:a.slice(t.breakAxis).reduce((_,b)=>_*b),m=t.breakAxis<=0?1:a.slice(0,t.breakAxis).reduce((_,b)=>_*b);if(!(h>e||m>e))return[h,m];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${a}, breakAxis:${t.breakAxis}`)}const r=a.reduce((h,m)=>h*m);let i=Math.floor(Math.sqrt(r));for(;i<e&&i<r&&r%i!=0;i++);if(i>=e||r%i!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${a}`);return[i,r/i]}},n.PreferLogicalStrategy=class{constructor(a){this.maxTextureSize=a}computeTextureWH(a,t){const e=this.computeTexture(a,t);return t&&t.isPacked&&(e[0]/=2,e[1]/=2),t&&t.reverseWH?[e[1],e[0]]:e}computeTexture(a,t){const e=t&&t.isPacked;if(a.length===0)return e?[2,2]:[1,1];let r=this.maxTextureSize;if(t&&t.breakAxis!==void 0){const m=t.breakAxis>=a.length?1:a.slice(t.breakAxis).reduce((b,y)=>b*y),_=t.breakAxis<=0?1:a.slice(0,t.breakAxis).reduce((b,y)=>b*y);if(!(m>r||_>r))return[m,_];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${a}, breakAxis:${t.breakAxis}`)}let i=a.slice(0);e&&(r*=2,i=i.map((m,_)=>_>=i.length-2?i[_]%2==0?i[_]:i[_]+1:i[_]),i.length===1&&(i=[2,i[0]])),i.length!==2&&(i=f(i).newShape);const h=g(i);return i.length<=1&&h<=r?[1,h]:i.length===2&&i[0]<=r&&i[1]<=r?i:i.length===3&&i[0]*i[1]<=r&&i[2]<=r?[i[0]*i[1],i[2]]:i.length===3&&i[0]<=r&&i[1]*i[2]<=r?[i[0],i[1]*i[2]]:i.length===4&&i[0]*i[1]*i[2]<=r&&i[3]<=r?[i[0]*i[1]*i[2],i[3]]:i.length===4&&i[0]<=r&&i[1]*i[2]*i[3]<=r?[i[0],i[1]*i[2]*i[3]]:e?c(h/4).map(m=>2*m):c(h)}},n.squeezeShape=f,n.parseAxisParam=u,n.isInt=p,n.sizeFromShape=g,n.getRowsCols=function(a){if(a.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[a.length>1?a[a.length-2]:1,a[a.length-1]]},n.sizeToSquarishShape=c,n.getBatchDim=function(a,t=2){return g(a.slice(0,a.length-t))}},4057:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createTextureLayoutFromShape=n.calculateTextureWidthAndHeight=n.createTextureLayoutFromTextureType=void 0;const s=o(2517),l=o(2039);n.createTextureLayoutFromTextureType=(f,u,p)=>{const g=p===l.TextureType.unpacked||p===l.TextureType.unpackedReversed?1:4,c=p===l.TextureType.packed,a=p===l.TextureType.unpackedReversed||p===l.TextureType.packed,t=p===l.TextureType.packedLastDimension?u.length-1:void 0,e=p===l.TextureType.packedLastDimension?u.map((r,i)=>i===u.length-1?4*r:r):void 0;return(0,n.createTextureLayoutFromShape)(f,u,g,e,{isPacked:c,reverseWH:a,breakAxis:t})},n.calculateTextureWidthAndHeight=(f,u,p)=>{const g=(0,n.createTextureLayoutFromTextureType)(f,u,p);return[g.width,g.height]},n.createTextureLayoutFromShape=(f,u,p=1,g,c)=>{const a=!(!c||!c.isPacked),[t,e]=f.computeTextureWH(a&&g||u,c),r=u.length;let i=u.slice(0);if(r===0&&(i=[1]),p===1)g=u;else if(a){if(p!==4)throw new Error("a packed texture must be 4-channel");g=u,r>0&&(i[r-1]=Math.ceil(i[r-1]/2)),r>1&&(i[r-2]=Math.ceil(i[r-2]/2))}else if(!g)throw new Error("Unpacked shape is needed when using channels > 1");return{width:t,height:e,channels:p,isPacked:a,shape:i,strides:s.ShapeUtil.computeStrides(i),unpackedShape:g,reversedWH:c&&c.reverseWH}}},5702:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TextureManager=void 0;const s=o(6231);n.TextureManager=class{constructor(l,f,u,p){this.glContext=l,this.layoutStrategy=f,this.profiler=u,this.config=p,this.pendingRead=new Map,p.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(l,f,u,p){const g=this.toEncoderType(l),c=this.glContext.getEncoder(g,f.channels||1,p);if(f.isPacked&&p===1)throw new Error("not implemented");const a=f.width,t=f.height;let e,r;if(this.config.reuseTextures){e=`${a}x${t}_${c.format}_${c.internalFormat}_${c.textureType}`,r=this.inUseTextures.get(e),r||(r=[],this.inUseTextures.set(e,r));const h=this.idleTextures.get(e);if(h&&h.length>0){const m=h.pop();return r.push(m),p===1&&this.glContext.updateTexture(m,a,t,c,this.toTextureData(l,u)),m}}s.Logger.verbose("TextureManager",`Creating new texture of size ${f.width}x${f.height}`);const i=this.glContext.allocateTexture(a,t,c,this.toTextureData(l,u));return this.config.reuseTextures&&(r.push(i),this.textureLookup.set(i,e)),i}readTexture(l,f,u){return u||(u=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const p=l.shape.reduce((c,a)=>c*a)*u,g=this.glContext.readTexture(l.texture,l.width,l.height,p,this.toEncoderType(f),u);return this.toTensorData(f,g)})}async readTextureAsync(l,f,u){const p=l.tensor.dataId;if(u||(u=1),this.pendingRead.has(p)){const g=this.pendingRead.get(p);return new Promise(c=>g==null?void 0:g.push(c))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(p,[]);const g=l.shape.reduce((e,r)=>e*r)*u;await this.glContext.createAndWaitForFence();const c=this.glContext.readTexture(l.texture,l.width,l.height,g,this.toEncoderType(f),u),a=this.toTensorData(f,c),t=this.pendingRead.get(p);return this.pendingRead.delete(p),t==null||t.forEach(e=>e(a)),a})}readUint8TextureAsFloat(l){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const f=l.shape.reduce((p,g)=>p*g),u=this.glContext.readTexture(l.texture,l.width,l.height,4*f,"byte",4);return new Float32Array(u.buffer,u.byteOffset,f)})}releaseTexture(l,f){let u;if(this.config.reuseTextures&&(u=this.textureLookup.get(l.texture),u)){f&&this.textureLookup.delete(u);const p=this.inUseTextures.get(u);if(p){const g=p.indexOf(l.texture);if(g!==-1){p.splice(g,1);let c=this.idleTextures.get(u);c||(c=[],this.idleTextures.set(u,c)),c.push(l.texture)}}}u&&!f||(s.Logger.verbose("TextureManager",`Deleting texture of size ${l.width}x${l.height}`),this.glContext.deleteTexture(l.texture))}toTensorData(l,f){switch(l){case"int16":return f instanceof Int16Array?f:Int16Array.from(f);case"int32":return f instanceof Int32Array?f:Int32Array.from(f);case"int8":return f instanceof Int8Array?f:Int8Array.from(f);case"uint16":return f instanceof Uint16Array?f:Uint16Array.from(f);case"uint32":return f instanceof Uint32Array?f:Uint32Array.from(f);case"uint8":case"bool":return f instanceof Uint8Array?f:Uint8Array.from(f);case"float32":return f instanceof Float32Array?f:Float32Array.from(f);case"float64":return f instanceof Float64Array?f:Float64Array.from(f);default:throw new Error(`TensorData type ${l} is not supported`)}}toTextureData(l,f){if(f)return f instanceof Float32Array?f:new Float32Array(f)}toEncoderType(l){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},2039:(d,n)=>{var o;Object.defineProperty(n,"__esModule",{value:!0}),n.TextureType=void 0,(o=n.TextureType||(n.TextureType={}))[o.unpacked=0]="unpacked",o[o.unpackedReversed=1]="unpackedReversed",o[o.packed=2]="packed",o[o.downloadUint8AsFloat=3]="downloadUint8AsFloat",o[o.packedLastDimension=4]="packedLastDimension"},9390:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getGlChannels=n.getCoordsDataType=n.getSqueezedParams=n.squeezeInputShape=n.generateShaderFuncNameFromInputSamplerNameAtOutCoords=n.generateShaderFuncNameFromInputSamplerName=n.repeatedTry=n.getPackedShape=void 0;const s=o(2517);n.getPackedShape=function(l){const f=l.length;return l.slice(0,f-1).concat(l[f-1]/4)},n.repeatedTry=async function(l,f=p=>0,u){return new Promise((p,g)=>{let c=0;const a=()=>{if(l())return void p();c++;const t=f(c);u!=null&&c>=u?g():setTimeout(a,t)};a()})},n.generateShaderFuncNameFromInputSamplerName=function(l){return(0,s.assert)(l!==void 0&&l.length!==0,()=>"empty string found for sampler name"),"get"+l.charAt(0).toUpperCase()+l.slice(1)},n.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(l){return(0,s.assert)(l!==void 0&&l.length!==0,()=>"empty string found for sampler name"),"get"+l.charAt(0).toUpperCase()+l.slice(1)+"AtOutCoords"},n.squeezeInputShape=function(l,f){let u=JSON.parse(JSON.stringify(l));return u=f,u},n.getSqueezedParams=function(l,f){return f.map(u=>l[u]).join(", ")},n.getCoordsDataType=function(l){if(l<=1)return"int";if(l===2)return"ivec2";if(l===3)return"ivec3";if(l===4)return"ivec4";if(l===5)return"ivec5";if(l===6)return"ivec6";throw Error(`GPU for rank ${l} is not yet supported`)},n.getGlChannels=function(l=6){return["x","y","z","w","u","v"].slice(0,l)}},7305:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createNewWebGLContext=n.createWebGLContext=void 0;const s=o(6231),l=o(1713),f={};function u(p){const g=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 c;const a={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!p||p==="webgl2")&&(c=g.getContext("webgl2",a),c))try{return new l.WebGLContext(c,2)}catch(t){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${t}`)}if((!p||p==="webgl")&&(c=g.getContext("webgl",a)||g.getContext("experimental-webgl",a),c))try{return new l.WebGLContext(c,1)}catch(t){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${t}`)}throw new Error("WebGL is not supported")}n.createWebGLContext=function p(g){let c;g&&g!=="webgl2"||!("webgl2"in f)?g&&g!=="webgl"||!("webgl"in f)||(c=f.webgl):c=f.webgl2,c=c||u(g),g=g||c.version===1?"webgl":"webgl2";const a=c.gl;return f[g]=c,a.isContextLost()?(delete f[g],p(g)):(a.disable(a.DEPTH_TEST),a.disable(a.STENCIL_TEST),a.disable(a.BLEND),a.disable(a.DITHER),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SAMPLE_COVERAGE),a.enable(a.SCISSOR_TEST),a.enable(a.CULL_FACE),a.cullFace(a.BACK),c)},n.createNewWebGLContext=u},1713:function(d,n,o){var s=this&&this.__createBinding||(Object.create?function(a,t,e,r){r===void 0&&(r=e);var i=Object.getOwnPropertyDescriptor(t,e);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(a,r,i)}:function(a,t,e,r){r===void 0&&(r=e),a[r]=t[e]}),l=this&&this.__setModuleDefault||(Object.create?function(a,t){Object.defineProperty(a,"default",{enumerable:!0,value:t})}:function(a,t){a.default=t}),f=this&&this.__importStar||function(a){if(a&&a.__esModule)return a;var t={};if(a!=null)for(var e in a)e!=="default"&&Object.prototype.hasOwnProperty.call(a,e)&&s(t,a,e);return l(t,a),t};Object.defineProperty(n,"__esModule",{value:!0}),n.WebGLContext=n.linearSearchLastTrue=void 0;const u=o(1670),p=f(o(7769)),g=o(9390);function c(a){let t=0;for(;t<a.length&&a[t]();++t);return t-1}n.linearSearchLastTrue=c,n.WebGLContext=class{constructor(a,t){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=a,this.version=t,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(a,t,e,r){const i=this.gl,h=i.createTexture();i.bindTexture(i.TEXTURE_2D,h),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);const m=r?e.encode(r,a*t):null;return i.texImage2D(i.TEXTURE_2D,0,e.internalFormat,a,t,0,e.format,e.textureType,m),this.checkError(),h}updateTexture(a,t,e,r,i){const h=this.gl;h.bindTexture(h.TEXTURE_2D,a);const m=r.encode(i,t*e);h.texSubImage2D(h.TEXTURE_2D,0,0,0,t,e,r.format,r.textureType,m),this.checkError()}attachFramebuffer(a,t,e){const r=this.gl;r.bindTexture(r.TEXTURE_2D,a),r.bindFramebuffer(r.FRAMEBUFFER,this.framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),this.checkError(),r.viewport(0,0,t,e),r.scissor(0,0,t,e)}readTexture(a,t,e,r,i,h){const m=this.gl;h||(h=1),this.frameBufferBound||this.attachFramebuffer(a,t,e);const _=this.getEncoder(i,h),b=_.allocate(t*e);return m.bindTexture(m.TEXTURE_2D,a),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,a,0),m.readPixels(0,0,t,e,m.RGBA,_.textureType,b),this.checkError(),_.decode(b,r)}isFramebufferReady(){return!0}getActiveTexture(){const a=this.gl;return"TEXTURE"+(a.getParameter(this.gl.ACTIVE_TEXTURE)-a.TEXTURE0)}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(a,t){const e=this.gl;e.vertexAttribPointer(a,3,e.FLOAT,!1,20,0),e.enableVertexAttribArray(a),t!==-1&&(e.vertexAttribPointer(t,2,e.FLOAT,!1,20,12),e.enableVertexAttribArray(t)),this.checkError()}createProgram(a,t){const e=this.gl,r=e.createProgram();return e.attachShader(r,a),e.attachShader(r,t),e.linkProgram(r),r}compileShader(a,t){const e=this.gl,r=e.createShader(t);if(!r)throw new Error(`createShader() returned null with type ${t}`);if(e.shaderSource(r,a),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${e.getShaderInfoLog(r)} +Shader source: +${a}`);return r}deleteShader(a){this.gl.deleteShader(a)}bindTextureToUniform(a,t,e){const r=this.gl;r.activeTexture(r.TEXTURE0+t),this.checkError(),r.bindTexture(r.TEXTURE_2D,a),this.checkError(),r.uniform1i(e,t),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(u.env.debug){const a=this.gl,t=a.getError();let e="";switch(t){case a.NO_ERROR:return;case a.INVALID_ENUM:e="INVALID_ENUM";break;case a.INVALID_VALUE:e="INVALID_VALUE";break;case a.INVALID_OPERATION:e="INVALID_OPERATION";break;case a.INVALID_FRAMEBUFFER_OPERATION:e="INVALID_FRAMEBUFFER_OPERATION";break;case a.OUT_OF_MEMORY:e="OUT_OF_MEMORY";break;case a.CONTEXT_LOST_WEBGL:e="CONTEXT_LOST_WEBGL";break;default:e=`Unknown WebGL Error: ${t.toString(16)}`}throw new Error(e)}}deleteTexture(a){this.gl.deleteTexture(a)}deleteProgram(a){this.gl.deleteProgram(a)}getEncoder(a,t,e=0){if(this.version===2)return new p.RedFloat32DataEncoder(this.gl,t);switch(a){case"float":return e===1||this.isRenderFloat32Supported?new p.RGBAFloatDataEncoder(this.gl,t):new p.RGBAFloatDataEncoder(this.gl,t,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new p.Uint8DataEncoder(this.gl,t);default:throw new Error(`Invalid dataType: ${a}`)}}clearActiveTextures(){const a=this.gl;for(let t=0;t<this.maxTextureImageUnits;++t)a.activeTexture(a.TEXTURE0+t),a.bindTexture(a.TEXTURE_2D,null)}dispose(){if(this.disposed)return;const a=this.gl;a.bindFramebuffer(a.FRAMEBUFFER,null),a.deleteFramebuffer(this.framebuffer),a.bindBuffer(a.ARRAY_BUFFER,null),a.deleteBuffer(this.vertexbuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),a.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){const a=this.gl,t=a.createBuffer();if(!t)throw new Error("createBuffer() returned null");const e=this.createDefaultGeometry();return a.bindBuffer(a.ARRAY_BUFFER,t),a.bufferData(a.ARRAY_BUFFER,e,a.STATIC_DRAW),this.checkError(),t}createFramebuffer(){const a=this.gl.createFramebuffer();if(!a)throw new Error("createFramebuffer returned null");return a}queryVitalParameters(){const a=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){const a=this.gl,t=a.createTexture();a.bindTexture(a.TEXTURE_2D,t);const e=this.version===2?a.RGBA32F:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,e,1,1,0,a.RGBA,a.FLOAT,null);const r=a.createFramebuffer();a.bindFramebuffer(a.FRAMEBUFFER,r),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,t,0);const i=a.checkFramebufferStatus(a.FRAMEBUFFER)===a.FRAMEBUFFER_COMPLETE;return a.bindTexture(a.TEXTURE_2D,null),a.bindFramebuffer(a.FRAMEBUFFER,null),a.deleteTexture(t),a.deleteFramebuffer(r),i}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){const a=this.gl;let t,e,r,i,h;try{t=a.createTexture(),e=a.createFramebuffer(),a.bindTexture(a.TEXTURE_2D,t);const m=this.version===2?a.RGBA32F:a.RGBA;return a.texImage2D(a.TEXTURE_2D,0,m,1,1,0,a.RGBA,a.FLOAT,null),a.bindFramebuffer(a.FRAMEBUFFER,e),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,t,0),a.enable(a.BLEND),r=a.createShader(a.VERTEX_SHADER),!!r&&(a.shaderSource(r,"void main(){}"),a.compileShader(r),i=a.createShader(a.FRAGMENT_SHADER),!!i&&(a.shaderSource(i,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),a.compileShader(i),h=a.createProgram(),!!h&&(a.attachShader(h,r),a.attachShader(h,i),a.linkProgram(h),a.useProgram(h),a.drawArrays(a.POINTS,0,1),a.getError()===a.NO_ERROR)))}finally{a.disable(a.BLEND),h&&a.deleteProgram(h),r&&a.deleteShader(r),i&&a.deleteShader(i),e&&(a.bindFramebuffer(a.FRAMEBUFFER,null),a.deleteFramebuffer(e)),t&&(a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(t))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const a=this.gl,t=this.disjointTimerQueryWebgl2Extension,e=a.createQuery();return a.beginQuery(t.TIME_ELAPSED_EXT,e),e}throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const a=this.gl,t=this.disjointTimerQueryWebgl2Extension;a.endQuery(t.TIME_ELAPSED_EXT)}}isTimerResultAvailable(a){let t=!1,e=!1;if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const r=this.gl,i=this.disjointTimerQueryWebgl2Extension;t=r.getQueryParameter(a,r.QUERY_RESULT_AVAILABLE),e=r.getParameter(i.GPU_DISJOINT_EXT)}return t&&!e}getTimerResult(a){let t=0;if(this.version!==2)throw new Error("WebGL1 profiling currently not supported");{const e=this.gl;t=e.getQueryParameter(a,e.QUERY_RESULT),e.deleteQuery(a)}return t/1e6}async waitForQueryAndGetTime(a){return await(0,g.repeatedTry)(()=>this.isTimerResultAvailable(a)),this.getTimerResult(a)}async createAndWaitForFence(){const a=this.createFence(this.gl);return this.pollFence(a)}createFence(a){let t;const e=a,r=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return a.flush(),t=r===null?()=>!0:()=>{const i=e.clientWaitSync(r,0,0);return i===e.ALREADY_SIGNALED||i===e.CONDITION_SATISFIED},{query:r,isFencePassed:t}}async pollFence(a){return new Promise(t=>{this.addItemToPoll(()=>a.isFencePassed(),()=>t())})}pollItems(){const a=c(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=a;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(a+1)}async addItemToPoll(a,t){this.itemsToPoll.push({isDoneFn:a,resolveFn:t}),this.itemsToPoll.length>1||await(0,g.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},1036:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExecutionPlan=void 0;const s=o(6231);class l{constructor(u,p){this.op=u,this.node=p}}n.ExecutionPlan=class{constructor(f,u,p){this.graph=f,this.profiler=p,this.initialize(u)}initialize(f){this.profiler.event("session","ExecutionPlan.initialize",()=>{const u=this.graph.getNodes();if(u.length!==f.length)throw new Error("The size of nodes and OPs do not match.");this._ops=f.map((p,g)=>new l(p,u[g])),this.reset(),this._starter=[],this._ops.forEach((p,g)=>{let c=!0;for(const a of p.node.inputs)if(!this._values[a]&&this.graph.getInputIndices().indexOf(a)===-1){c=!1;break}c&&this._starter.push(g)})})}reset(){this._values=this.graph.getValues().map(f=>f.tensor)}async execute(f,u){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const p=f.createInferenceHandler(),g=this.graph.getInputIndices();if(u.length!==g.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${u.length} expected: ${g.length}`);u.forEach((i,h)=>{const m=g[h];this._values[m]=i});const c=this._starter.slice(0),a=this.graph.getValues(),t=this.graph.getNodes();let e=0;for(;e<c.length;){const i=c[e++],h=this._ops[i],m=h.node.inputs.map(T=>this._values[T]);if(m.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${h.node}`);const _=m;s.Logger.verbose("ExecPlan",`Runing op:${h.node.name} (${_.map((T,w)=>`'${h.node.inputs[w]}': ${T.type}[${T.dims.join(",")}]`).join(", ")})`);const b=await this.profiler.event("node",h.node.name,async()=>h.op.impl(p,_,h.op.context));if(b.length!==h.node.outputs.length)throw new Error("the size of output does not match model definition.");b.forEach((T,w)=>{const S=h.node.outputs[w];if(this._values[S])throw new Error(`output [${S}] already has value: op:${h.node.name}`);this._values[S]=T});const y=new Set;b.forEach((T,w)=>{const S=h.node.outputs[w];for(const E of a[S].to){const O=t[E];let v=!0;for(const M of O.inputs)if(!this._values[M]){v=!1;break}v&&y.add(E)}}),c.push(...y)}const r=[];for(let i=0;i<this.graph.getOutputIndices().length;i++){const h=this.graph.getOutputIndices()[i],m=this._values[h];if(m===void 0)throw new Error(`required output [${h}] does not have value`);h===0?await m.getData():m.data,r.push(m)}return s.Logger.verbose("ExecPlan","disposing of inferenceHandler"),p.dispose(),r})}}},7070:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Graph=void 0;const s=o(1446),l=o(7778),f=o(9395),u=o(9162),p=o(2517);var g=f.onnxruntime.experimental.fbs;n.Graph={from:(e,r)=>new t(e,r)};class c{constructor(r){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,r&&(this.type=p.ProtoUtil.tensorValueTypeFromProto(r.type.tensorType))}get from(){return this._from}get to(){return this._to}}class a{constructor(r,i){r instanceof s.onnx.NodeProto?(this.name=r.name,this.opType=r.opType,this.attributes=new l.Attribute(r.attribute)):r instanceof g.Node&&(this.name=i??r.name(),this.opType=r.opType(),this.attributes=new l.Attribute(p.ProtoUtil.tensorAttributesFromORTFormat(r))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class t{constructor(r,i){if(!r)throw new TypeError("graph is empty");this.buildGraph(r),this.transformGraph(i),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(r){if(r instanceof s.onnx.GraphProto)this.buildGraphFromOnnxFormat(r);else{if(!(r instanceof g.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(r)}}buildGraphFromOnnxFormat(r){const i=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const h=new Map;if(!r.input)throw new Error("missing information in graph: input");const m=[];for(const _ of r.input){if(i.has(_.name))throw new Error(`duplicated input name: ${_.name}`);const b=this._allData.push(new c(_))-1;i.set(_.name,b),m.push(_.name)}if(!r.initializer)throw new Error("missing information in graph: initializer");for(const _ of r.initializer){let b=i.get(_.name);if(b===void 0){const y=new c;y.type={shape:{dims:p.ProtoUtil.tensorDimsFromProto(_.dims)},tensorType:p.ProtoUtil.tensorDataTypeFromProto(_.dataType)},b=this._allData.push(y)-1,i.set(_.name,b)}this._allData[b]._from=-1,this._allData[b].tensor=u.Tensor.fromProto(_)}for(let _=0;_<this._allData.length;_++)this._allData[_].tensor||(this._allInputIndices.push(_),this._allInputNames.push(m[_]));if(!r.output)throw new Error("missing information in graph: output");for(const _ of r.output){if(i.has(_.name))throw new Error(`duplicated output name: ${_.name}`);const b=this._allData.push(new c(_))-1;i.set(_.name,b),this._allOutputIndices.push(b),this._allOutputNames.push(_.name)}if(!r.node)throw new Error("missing information in graph: node");for(const _ of r.node){if(!_.name)for(let y=0;;y++){const T=`unnamed_${_.opType}_${y}`;if(!h.has(T)){_.name=T;break}}if(h.has(_.name))throw new Error(`duplicated node name: ${_.name}`);const b=this._nodes.push(new a(_))-1;h.set(_.name,b)}for(let _=0;_<this._nodes.length;_++){const b=this._nodes[_],y=r.node[_];if(!y.output)throw new Error(`missing output for node: ${y.name}`);for(const T of y.output){let w=i.get(T);if(w===void 0&&(w=this._allData.push(new c)-1,i.set(T,w)),b.outputs.push(w),this._allData[w]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${w}`);if(this._allData[w]._from=_,y.opType==="Constant"){if(!y.attribute||y.attribute.length!==1||!y.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!y.output||y.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");b.outputs.pop(),b.executeNode=!1,this._allData[w]._from=-1,this._allData[w].tensor=u.Tensor.fromProto(y.attribute[0].t)}}}for(let _=0;_<this._nodes.length;_++){const b=this._nodes[_],y=r.node[_];if(!y.input)throw new Error(`missing input for node: ${y.name}`);for(const T of y.input){const w=i.get(T);if(w===void 0){if(T===""&&y.input.length===3&&y.opType==="Resize")continue;throw new Error(`unrecognized input '${T}' for node: ${y.name}`)}b.inputs.push(w),this._allData[w]._to.push(_)}}return!0}buildGraphFromOrtFormat(r){var i,h,m;const _=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const b=new Map,y=[];for(let T=0;T<r.inputsLength();T++){const w=r.inputs(T);if(_.has(w))throw new Error(`duplicated input name: ${w}`);for(let S=0;S<r.nodeArgsLength();S++)if(((i=r.nodeArgs(S))===null||i===void 0?void 0:i.name())===w){const E=new c;if(((m=(h=r.nodeArgs(S))===null||h===void 0?void 0:h.type())===null||m===void 0?void 0:m.valueType())!==g.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");const O=r.nodeArgs(S).type().value(new g.TensorTypeAndShape),v=p.ProtoUtil.tensorDataTypeFromProto(O.elemType()),M=O.shape(),$=[];for(let B=0;B<M.dimLength();B++)$.push(p.LongUtil.longToNumber(M.dim(B).value().dimValue()));E.type={shape:{dims:$},tensorType:v};const V=this._allData.push(E)-1;_.set(w,V),y.push(w)}}for(let T=0;T<r.initializersLength();T++){const w=r.initializers(T);let S=_.get(w.name());if(S===void 0){const E=new c,O=p.ProtoUtil.tensorDimsFromORTFormat(w),v=p.ProtoUtil.tensorDataTypeFromProto(w.dataType());E.type={shape:{dims:O},tensorType:v},S=this._allData.push(E)-1,_.set(w.name(),S)}this._allData[S]._from=-1,this._allData[S].tensor=u.Tensor.fromOrtTensor(w)}for(let T=0;T<this._allData.length;T++)this._allData[T].tensor||(this._allInputIndices.push(T),this._allInputNames.push(y[T]));for(let T=0;T<r.outputsLength();T++){const w=r.outputs(T);if(_.has(w))throw new Error(`duplicated output name: ${w}`);const S=this._allData.push(new c)-1;_.set(w,S),this._allOutputIndices.push(S),this._allOutputNames.push(w)}if(!r.nodes)throw new Error("missing information in graph: node");for(let T=0;T<r.nodesLength();T++){const w=r.nodes(T);let S=w.name();if(!S)for(let O=0;S=`unnamed_${w.opType()}_${O}`,b.has(S);O++);if(b.has(S))throw new Error(`duplicated node name: ${S}`);const E=this._nodes.push(new a(w,S))-1;b.set(S,E)}for(let T=0;T<this._nodes.length;T++){const w=this._nodes[T],S=r.nodes(T);if(S==null)throw new Error(`No node exists at index ${T}`);if((S==null?void 0:S.outputsLength())===0)throw new Error(`missing output for node: ${S.name}`);for(let E=0;E<(S==null?void 0:S.outputsLength());E++){const O=S==null?void 0:S.outputs(E);let v=_.get(O);if(v===void 0&&(v=this._allData.push(new c)-1,_.set(O,v)),w.outputs.push(v),this._allData[v]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${v}`);if(this._allData[v]._from=T,S.opType()==="Constant"){if(S.attributesLength()!==1||!S.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(S.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");w.outputs.pop(),w.executeNode=!1,this._allData[v]._from=-1,this._allData[v].tensor=u.Tensor.fromOrtTensor(S.attributes(0).t())}}}for(let T=0;T<this._nodes.length;T++){const w=this._nodes[T],S=r.nodes(T);if(S.inputsLength()===0)throw new Error(`missing input for node: ${S.name}`);for(let E=0;E<S.inputsLength();E++){const O=S.inputs(E),v=_.get(O);if(v===void 0)throw new Error(`unrecognized input '${O}' for node: ${S.name()}`);w.inputs.push(v),this._allData[v]._to.push(T)}}}checkIsAcyclic(){const r=new Set;this._allInputIndices.forEach(m=>{this._allData[m]._to.forEach(_=>{r.add(_)})});const i=Array.from(r),h=new Array(this._nodes.length).fill("white");for(;i.length>0;){const m=i.pop();h[m]==="gray"?h[m]="black":(i.push(m),h[m]="gray",this._nodes[m].outputs.forEach(_=>{const b=this._allData[_];if(b.tensor!==void 0)throw new Error("node outputs should not be initialized");if(b._from!==m)throw new Error("from property of the Value object doesn't match index of Node being processed");b._to.forEach(y=>{if(h[y]==="gray")throw new Error("model graph is cyclic");h[y]==="white"&&i.push(y)})}))}}transformGraph(r){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),r&&r.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let r=0;for(let i=0;i<this._nodes.length;i++)this._nodes[i].executeNode?r>0&&(this._nodes[i].inputs.forEach(h=>{const m=this._allData[h]._to.indexOf(i+r);m!==-1&&(this._allData[h]._to[m]=i)}),this._nodes[i].outputs.forEach(h=>{this._allData[h]._from&&this._allData[h]._from===i+r&&(this._allData[h]._from=i)})):(r++,this._nodes[i].outputs.forEach(h=>{this._allData[h]._from=-2}),this._nodes.splice(i,1),i--);r=0;for(let i=0;i<this._allData.length;i++)if(this._allData[i].from!==-2||this._allOutputIndices.indexOf(i+r)!==-1){if(r>0){let h=-1;this._allData[i].from!==void 0&&this._allData[i].from!==-1?(h=this._nodes[this._allData[i].from].outputs.indexOf(i+r),h!==-1&&(this._nodes[this._allData[i].from].outputs[h]=i)):(h=this._allInputIndices.indexOf(i+r),h!==-1&&(this._allInputIndices[h]=i)),this._allData[i].to.forEach(m=>{h=this._nodes[m].inputs.indexOf(i+r),h!==-1&&(this._nodes[m].inputs[h]=i)}),this._allData[i].to.length===0&&(h=this._allOutputIndices.indexOf(i+r),h!==-1&&(this._allOutputIndices[h]=i))}}else r++,this._allData.splice(i,1),i--}deleteNode(r){const i=this._nodes[r];if(i.outputs.length>1){for(let T=1;T<i.outputs.length;T++)if(this._allData[i.outputs[T]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}i.executeNode=!1;const h=i.inputs[0],m=i.outputs[0],_=this._allData[m].to,b=this._allData[h].to.indexOf(r);if(b===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[h].to.splice(b,1),this._allData[m]._to=[];const y=this._allOutputIndices.indexOf(m);if(y!==-1&&(this._allOutputIndices[y]=h),_&&_.length>0)for(const T of _){const w=this._nodes[T].inputs.indexOf(m);if(w===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[T].inputs[w]=h,this._allData[h].to.push(T)}}removeAllDropoutNodes(){let r=0;for(const i of this._nodes){if(i.opType==="Dropout"){if(i.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(i.outputs.length!==1&&i.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(i.outputs.length===2&&this._allData[i.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(r)}r++}}removeAllIdentityNodes(){let r=0;for(const i of this._nodes)i.opType==="Identity"&&this.deleteNode(r),r++}isActivation(r){switch(r.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const r of this._nodes)if(r.opType==="Conv"){const i=this._allData[r.outputs[0]]._to;if(i.length===1&&this.isActivation(this._nodes[i[0]])){const h=this._nodes[i[0]];if(h.opType==="Clip")if(h.inputs.length===1)try{r.attributes.set("activation_params","floats",[h.attributes.getFloat("min"),h.attributes.getFloat("max")])}catch{r.attributes.set("activation_params","floats",[p.MIN_CLIP,p.MAX_CLIP])}else{if(!(h.inputs.length>=3&&this._allData[h.inputs[1]].tensor!==void 0&&this._allData[h.inputs[2]].tensor!==void 0))continue;r.attributes.set("activation_params","floats",[this._allData[h.inputs[1]].tensor.floatData[0],this._allData[h.inputs[2]].tensor.floatData[0]])}r.attributes.set("activation","string",h.opType),this.deleteNode(i[0])}}}}},6231:(d,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.now=n.Profiler=n.Logger=void 0;const o={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},s={none:new class{log(a,t,e){}},console:new class{log(a,t,e){console.log(`${this.color(a)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${t}`)}color(a){switch(a){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: ${a}`)}}}},l={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let f={"":l};function u(a,t,e,r){if(t===void 0)return i=a,{verbose:u.verbose.bind(null,i),info:u.info.bind(null,i),warning:u.warning.bind(null,i),error:u.error.bind(null,i),fatal:u.fatal.bind(null,i)};if(e===void 0)p(a,t);else if(typeof e=="number"&&r===void 0)p(a,t);else if(typeof e=="string"&&r===void 0)p(a,e,0,t);else{if(typeof e!="string"||typeof r!="number")throw new TypeError("input is valid");p(a,e,0,t)}var i}function p(a,t,e,r){const i=f[r||""]||f[""];o[a]<o[i.minimalSeverity]||(i.logDateTime&&(t=`${new Date().toISOString()}|${t}`),i.logSourceLocation,s[i.provider].log(a,t,r))}(function(a){function t(r){f={},e("",r||{})}function e(r,i){if(r==="*")t(i);else{const h=f[r]||l;f[r]={provider:i.provider||h.provider,minimalSeverity:i.minimalSeverity||h.minimalSeverity,logDateTime:i.logDateTime===void 0?h.logDateTime:i.logDateTime,logSourceLocation:i.logSourceLocation===void 0?h.logSourceLocation:i.logSourceLocation}}}a.verbose=function(r,i){a("verbose",r,i)},a.info=function(r,i){a("info",r,i)},a.warning=function(r,i){a("warning",r,i)},a.error=function(r,i){a("error",r,i)},a.fatal=function(r,i){a("fatal",r,i)},a.reset=t,a.set=e,a.setWithEnv=function(r){const i={};r.logLevel&&(i.minimalSeverity=r.logLevel),e("",i)}})(u||(u={})),n.Logger=u;class g{constructor(t,e,r,i,h,m){this.category=t,this.name=e,this.startTime=r,this.endCallback=i,this.timer=h,this.ctx=m}end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}}class c{constructor(t,e,r,i){this.category=t,this.name=e,this.startTime=r,this.endTime=i}}n.Profiler=class{static create(a){return a===void 0?new this:new this(a.maxNumberEvents,a.flushBatchSize,a.flushIntervalInMilliseconds)}constructor(a,t,e){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=a===void 0?1e4:a,this._flushBatchSize=t===void 0?10:t,this._flushIntervalInMilliseconds=e===void 0?5e3:e}start(){this._started=!0,this._timingEvents=[],this._flushTime=(0,n.now)(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(a,t,e,r){const i=this._started?this.begin(a,t,r):void 0;let h=!1;const m=e();if(m&&typeof m.then=="function")return h=!0,new Promise((_,b)=>{m.then(async y=>{i&&await i.end(),_(y)},async y=>{i&&await i.end(),b(y)})});if(!h&&i){const _=i.end();if(_&&typeof _.then=="function")return new Promise((b,y)=>{_.then(()=>{b(m)},T=>{y(T)})})}return m}begin(a,t,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){const r=(0,n.now)();return this.flush(r),new g(a,t,r,i=>this.endSync(i))}{const r=e.beginTimer();return new g(a,t,0,async i=>this.end(i),r,e)}}async end(a){const t=await a.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new c(a.category,a.name,a.startTime,t)),this.flush(t))}endSync(a){const t=(0,n.now)();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new c(a.category,a.name,a.startTime,t)),this.flush(t))}logOneEvent(a){n.Logger.verbose(`Profiler.${a.category}`,`${(a.endTime-a.startTime).toFixed(2)}ms on event '${a.name}' at ${a.endTime.toFixed(2)}`)}flush(a){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||a-this._flushTime>=this._flushIntervalInMilliseconds){for(const t=this._flushPointer;this._flushPointer<t+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=(0,n.now)()}}get started(){return this._started}},n.now=typeof performance<"u"&&performance.now?()=>performance.now():Date.now},2644:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Model=void 0;const s=o(5686),l=o(1446),f=o(7070),u=o(9395),p=o(2517);var g=u.onnxruntime.experimental.fbs;n.Model=class{constructor(){}load(c,a,t){if(!t)try{return void this.loadFromOnnxFormat(c,a)}catch(e){if(t!==void 0)throw e}this.loadFromOrtFormat(c,a)}loadFromOnnxFormat(c,a){const t=l.onnx.ModelProto.decode(c);if(p.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:p.LongUtil.longToNumber(e.version)})),this._graph=f.Graph.from(t.graph,a)}loadFromOrtFormat(c,a){const t=new s.flatbuffers.ByteBuffer(c),e=g.InferenceSession.getRootAsInferenceSession(t).model();if(p.LongUtil.longToNumber(e.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let r=0;r<e.opsetImportLength();r++){const i=e.opsetImport(r);this._opsets.push({domain:i==null?void 0:i.domain(),version:p.LongUtil.longToNumber(i.version())})}this._graph=f.Graph.from(e.graph(),a)}get graph(){return this._graph}get opsets(){return this._opsets}}},782:(d,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FLOAT_TYPES=n.INT_TYPES=n.NUMBER_TYPES=void 0,n.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],n.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],n.FLOAT_TYPES=["float32","float64"]},1047:(d,n)=>{function o(s,l){if(l.endsWith("+")){const f=Number.parseInt(l.substring(0,l.length-1),10);return!isNaN(f)&&f<=s}if(l.split("-").length===2){const f=l.split("-"),u=Number.parseInt(f[0],10),p=Number.parseInt(f[1],10);return!isNaN(u)&&!isNaN(p)&&u<=s&&s<=p}return Number.parseInt(l,10)===s}Object.defineProperty(n,"__esModule",{value:!0}),n.resolveOperator=void 0,n.resolveOperator=function(s,l,f){for(const u of f){const p=u[0],g=u[1],c=u[2],a=u[3],t=u[4];if(s.opType===p){for(const e of l)if((e.domain===g||e.domain==="ai.onnx"&&g==="")&&o(e.version,c))return{opImpl:a,opInit:t}}}throw new TypeError(`cannot resolve operator '${s.opType}' with opsets: ${l.map(u=>`${u.domain||"ai.onnx"} v${u.version}`).join(", ")}`)}},9395:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.onnxruntime=void 0;const s=o(5686);var l,f;l=n.onnxruntime||(n.onnxruntime={}),function(u){(function(p){p[p.UNDEFINED=0]="UNDEFINED",p[p.FLOAT=1]="FLOAT",p[p.INT=2]="INT",p[p.STRING=3]="STRING",p[p.TENSOR=4]="TENSOR",p[p.GRAPH=5]="GRAPH",p[p.FLOATS=6]="FLOATS",p[p.INTS=7]="INTS",p[p.STRINGS=8]="STRINGS",p[p.TENSORS=9]="TENSORS",p[p.GRAPHS=10]="GRAPHS",p[p.SPARSE_TENSOR=11]="SPARSE_TENSOR",p[p.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(u.AttributeType||(u.AttributeType={}))}((f=l.experimental||(l.experimental={})).fbs||(f.fbs={})),function(u){(function(p){(function(g){(function(c){c[c.UNKNOWN=0]="UNKNOWN",c[c.VALUE=1]="VALUE",c[c.PARAM=2]="PARAM"})(g.DimensionValueType||(g.DimensionValueType={}))})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){(function(c){c[c.UNDEFINED=0]="UNDEFINED",c[c.FLOAT=1]="FLOAT",c[c.UINT8=2]="UINT8",c[c.INT8=3]="INT8",c[c.UINT16=4]="UINT16",c[c.INT16=5]="INT16",c[c.INT32=6]="INT32",c[c.INT64=7]="INT64",c[c.STRING=8]="STRING",c[c.BOOL=9]="BOOL",c[c.FLOAT16=10]="FLOAT16",c[c.DOUBLE=11]="DOUBLE",c[c.UINT32=12]="UINT32",c[c.UINT64=13]="UINT64",c[c.COMPLEX64=14]="COMPLEX64",c[c.COMPLEX128=15]="COMPLEX128",c[c.BFLOAT16=16]="BFLOAT16"})(g.TensorDataType||(g.TensorDataType={}))})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){(function(c){c[c.Primitive=0]="Primitive",c[c.Fused=1]="Fused"})(g.NodeType||(g.NodeType={}))})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){(function(c){c[c.NONE=0]="NONE",c[c.tensor_type=1]="tensor_type",c[c.sequence_type=2]="sequence_type",c[c.map_type=3]="map_type"})(g.TypeInfoValue||(g.TypeInfoValue={}))})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsShape(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}dim(t,e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new u.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startDimVector(t,e){t.startVector(4,e,4)}static endShape(t){return t.endObject()}static createShape(t,e){return c.startShape(t),c.addDim(t,e),c.endShape(t)}}g.Shape=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimension(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}value(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new u.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,r){return c.startDimension(t),c.addValue(t,e),c.addDenotation(t,r),c.endDimension(t)}}g.Dimension=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimensionValue(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.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,u.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,r,i){return c.startDimensionValue(t),c.addDimType(t,e),c.addDimValue(t,r),c.addDimParam(t,i),c.endDimensionValue(t)}}g.DimensionValue=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensorTypeAndShape(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.experimental.fbs.TensorDataType.UNDEFINED}shape(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new u.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,u.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(t,e){t.addFieldOffset(1,e,0)}static endTensorTypeAndShape(t){return t.endObject()}static createTensorTypeAndShape(t,e,r){return c.startTensorTypeAndShape(t),c.addElemType(t,e),c.addShape(t,r),c.endTensorTypeAndShape(t)}}g.TensorTypeAndShape=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMapType(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.experimental.fbs.TensorDataType.UNDEFINED}valueType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new u.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,u.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(t,e){t.addFieldOffset(1,e,0)}static endMapType(t){return t.endObject()}static createMapType(t,e,r){return c.startMapType(t),c.addKeyType(t,e),c.addValueType(t,r),c.endMapType(t)}}g.MapType=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSequenceType(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}elemType(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new u.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 c.startSequenceType(t),c.addElemType(t,e),c.endSequenceType(t)}}g.SequenceType=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(p.fbs||(p.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(g,c){return this.bb_pos=g,this.bb=c,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(g,c,a,t){return g.prep(4,12),g.writeInt32(t),g.writeInt32(a),g.writeInt32(c),g.offset()}}})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodeEdge(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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 r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,8);return r?(e||new u.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+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,r,i){return c.startNodeEdge(t),c.addNodeIndex(t,e),c.addInputEdges(t,r),c.addOutputEdges(t,i),c.endNodeEdge(t)}}g.NodeEdge=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNode(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.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 r=this.bb.__offset(this.bb_pos,20);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,22);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,24);return r?(e||new u.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,28);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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,u.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addInt32(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startImplicitInputsVector(t,e){t.startVector(4,e,4)}static endNode(t){return t.endObject()}static createNode(t,e,r,i,h,m,_,b,y,T,w,S,E,O){return c.startNode(t),c.addName(t,e),c.addDocString(t,r),c.addDomain(t,i),c.addSinceVersion(t,h),c.addIndex(t,m),c.addOpType(t,_),c.addType(t,b),c.addExecutionProviderType(t,y),c.addInputs(t,T),c.addOutputs(t,w),c.addAttributes(t,S),c.addInputArgCounts(t,E),c.addImplicitInputs(t,O),c.endNode(t)}}g.Node=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsValueInfo(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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 u.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,r,i){return c.startValueInfo(t),c.addName(t,e),c.addDocString(t,r),c.addType(t,i),c.endValueInfo(t)}}g.ValueInfo=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTypeInfo(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.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,u.experimental.fbs.TypeInfoValue.NONE)}static addValue(t,e){t.addFieldOffset(2,e,0)}static endTypeInfo(t){return t.endObject()}static createTypeInfo(t,e,r,i){return c.startTypeInfo(t),c.addDenotation(t,e),c.addValueType(t,r),c.addValue(t,i),c.endTypeInfo(t)}}g.TypeInfo=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOperatorSetId(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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,r){return c.startOperatorSetId(t),c.addDomain(t,e),c.addVersion(t,r),c.endOperatorSetId(t)}}g.OperatorSetId=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensor(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.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 r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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 r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static addDataType(t,e){t.addFieldInt32(3,e,u.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 r=e.length-1;r>=0;r--)t.addInt8(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startStringDataVector(t,e){t.startVector(4,e,4)}static endTensor(t){return t.endObject()}static createTensor(t,e,r,i,h,m,_){return c.startTensor(t),c.addName(t,e),c.addDocString(t,r),c.addDims(t,i),c.addDataType(t,h),c.addRawData(t,m),c.addStringData(t,_),c.endTensor(t)}}g.Tensor=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSparseTensor(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}values(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new u.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 u.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 r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static endSparseTensor(t){return t.endObject()}static createSparseTensor(t,e,r,i){return c.startSparseTensor(t),c.addValues(t,e),c.addIndices(t,r),c.addDims(t,i),c.endSparseTensor(t)}}g.SparseTensor=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsAttribute(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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):u.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 u.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 u.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 r=this.bb.__offset(this.bb_pos,24);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,26);return r?(e||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,28);return r?(e||new u.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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,u.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 r=e.length-1;r>=0;r--)t.addFloat32(e[r]);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 r=e.length-1;r>=0;r--)t.addInt64(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startGraphsVector(t,e){t.startVector(4,e,4)}static endAttribute(t){return t.endObject()}static createAttribute(t,e,r,i,h,m,_,b,y,T,w,S,E,O){return c.startAttribute(t),c.addName(t,e),c.addDocString(t,r),c.addType(t,i),c.addF(t,h),c.addI(t,m),c.addS(t,_),c.addT(t,b),c.addG(t,y),c.addFloats(t,T),c.addInts(t,w),c.addStrings(t,S),c.addTensors(t,E),c.addGraphs(t,O),c.endAttribute(t)}}g.Attribute=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGraph(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}initializers(t,e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,8);return r?(e||new u.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,12);return r?(e||new u.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,16);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+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 r=this.bb.__offset(this.bb_pos,18);return r?(e||new u.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startSparseInitializersVector(t,e){t.startVector(4,e,4)}static endGraph(t){return t.endObject()}static createGraph(t,e,r,i,h,m,_,b,y){return c.startGraph(t),c.addInitializers(t,e),c.addNodeArgs(t,r),c.addNodes(t,i),c.addMaxNodeIndex(t,h),c.addNodeEdges(t,m),c.addInputs(t,_),c.addOutputs(t,b),c.addSparseInitializers(t,y),c.endGraph(t)}}g.Graph=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsModel(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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 r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 u.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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,r,i,h,m,_,b,y,T){return c.startModel(t),c.addIrVersion(t,e),c.addOpsetImport(t,r),c.addProducerName(t,i),c.addProducerVersion(t,h),c.addDomain(t,m),c.addModelVersion(t,_),c.addDocString(t,b),c.addGraph(t,y),c.addGraphDocString(t,T),c.endModel(t)}}g.Model=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelCreateInfos(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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 r=e.length-1;r>=0;r--)t.addInt32(e[r]);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 r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startKernelDefHashesVector(t,e){t.startVector(8,e,8)}static endKernelCreateInfos(t){return t.endObject()}static createKernelCreateInfos(t,e,r){return c.startKernelCreateInfos(t),c.addNodeIndices(t,e),c.addKernelDefHashes(t,r),c.endKernelCreateInfos(t)}}g.KernelCreateInfos=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSubGraphSessionState(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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 u.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,r){return c.startSubGraphSessionState(t),c.addGraphId(t,e),c.addSessionState(t,r),c.endSubGraphSessionState(t)}}g.SubGraphSessionState=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSessionState(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}kernels(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new u.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}subGraphSessionStates(t,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startSubGraphSessionStatesVector(t,e){t.startVector(4,e,4)}static endSessionState(t){return t.endObject()}static createSessionState(t,e,r){return c.startSessionState(t),c.addKernels(t,e),c.addSubGraphSessionStates(t,r),c.endSessionState(t)}}g.SessionState=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(u){(function(p){(function(g){class c{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 c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInferenceSession(t,e){return t.setPosition(t.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__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 u.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 u.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,r,i){return c.startInferenceSession(t),c.addOrtVersion(t,e),c.addModel(t,r),c.addSessionState(t,i),c.endInferenceSession(t)}}g.InferenceSession=c})(p.fbs||(p.fbs={}))})(u.experimental||(u.experimental={}))}(n.onnxruntime||(n.onnxruntime={}))},7448:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OnnxjsSessionHandler=void 0;const s=o(1670),l=o(9162);n.OnnxjsSessionHandler=class{constructor(f){this.session=f,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(f,u,p){const g=new Map;for(const t in f)if(Object.hasOwnProperty.call(f,t)){const e=f[t];g.set(t,new l.Tensor(e.dims,e.type,void 0,void 0,e.data))}const c=await this.session.run(g),a={};return c.forEach((t,e)=>{a[e]=new s.Tensor(t.type,t.data,t.dims)}),a}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6919:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Session=void 0;const s=o(7067),l=o(1296),f=o(7091),u=o(1036),p=o(6231),g=o(2644);n.Session=class{constructor(c={}){this._initialized=!1,this.backendHint=c.backendHint,this.profiler=p.Profiler.create(c.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(c,a,t){await this.profiler.event("session","Session.loadModel",async()=>{const e=await(0,f.resolveBackend)(this.backendHint);if(this.sessionHandler=e.createSessionHandler(this.context),this._model=new g.Model,typeof c=="string"){const r=c.endsWith(".ort");if(typeof fetch>"u"){const i=await(0,l.promisify)(s.readFile)(c);this.initialize(i,r)}else{const i=await fetch(c),h=await i.arrayBuffer();this.initialize(new Uint8Array(h),r)}}else if(ArrayBuffer.isView(c))this.initialize(c);else{const r=new Uint8Array(c,a||0,t||c.byteLength);this.initialize(r)}})}initialize(c,a){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(c,t,a),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new u.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(c){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const a=this.normalizeAndValidateInputs(c),t=await this._executionPlan.execute(this.sessionHandler,a);return this.createOutput(t)})}normalizeAndValidateInputs(c){const a=this._model.graph.getInputNames();if(Array.isArray(c)){if(c.length!==a.length)throw new Error(`incorrect input array length: expected ${a.length} but got ${c.length}`)}else{if(c.size!==a.length)throw new Error(`incorrect input map size: expected ${a.length} but got ${c.size}`);const t=new Array(c.size);let e=0;for(let r=0;r<a.length;++r){const i=c.get(a[r]);if(!i)throw new Error(`missing input tensor for: '${name}'`);t[e++]=i}c=t}if(this.context.graphInputTypes&&this.context.graphInputTypes.length!==0&&this.context.graphInputDims&&this.context.graphInputDims.length!==0)this.validateInputTensorDims(this.context.graphInputDims,c,!1);else{const t=this._model.graph.getInputIndices(),e=this._model.graph.getValues(),r=new Array(t.length);for(let i=0;i<t.length;++i){const h=e[t[i]];r[i]=h.type.shape.dims,this.context.graphInputTypes.push(h.type.tensorType),this.context.graphInputDims.push(c[i].dims)}this.validateInputTensorDims(r,c,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,c),c}validateInputTensorTypes(c,a){for(let t=0;t<a.length;t++){const e=c[t],r=a[t].type;if(e!==r)throw new Error(`input tensor[${t}] check failed: expected type '${e}' but got ${r}`)}}validateInputTensorDims(c,a,t){for(let e=0;e<a.length;e++){const r=c[e],i=a[e].dims;if(!this.compareTensorDims(r,i,t))throw new Error(`input tensor[${e}] check failed: expected shape '[${r.join(",")}]' but got [${i.join(",")}]`)}}compareTensorDims(c,a,t){if(c.length!==a.length)return!1;for(let e=0;e<c.length;++e)if(c[e]!==a[e]&&(!t||c[e]!==0))return!1;return!0}createOutput(c){const a=this._model.graph.getOutputNames();if(c.length!==a.length)throw new Error("expected number of outputs do not match number of generated outputs");const t=new Map;for(let e=0;e<a.length;++e)t.set(a[e],c[e]);return t}initializeOps(c){const a=c.getNodes();this._ops=new Array(a.length);for(let t=0;t<a.length;t++)this._ops[t]=this.sessionHandler.resolve(a[t],this._model.opsets,c)}}},9162:function(d,n,o){var s=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(n,"__esModule",{value:!0}),n.Tensor=void 0;const l=o(3442),f=s(o(3720)),u=o(1446),p=o(9395),g=o(2517);var c=p.onnxruntime.experimental.fbs;class a{get data(){if(this.cache===void 0){const m=this.dataProvider(this.dataId);if(m.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=m}return this.cache}get stringData(){if(this.type!=="string")throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(m){return this.data[g.ShapeUtil.indicesToOffset(m,this.strides)]}set(m,_){this.data[g.ShapeUtil.indicesToOffset(m,this.strides)]=_}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=g.ShapeUtil.computeStrides(this.dims)),this._strides}constructor(m,_,b,y,T,w=l.Guid.create()){this.dims=m,this.type=_,this.dataProvider=b,this.asyncDataProvider=y,this.cache=T,this.dataId=w,this.size=g.ShapeUtil.validateDimsAndCalcSize(m);const S=this.size,E=b===void 0&&y===void 0&&T===void 0;if(T!==void 0&&T.length!==S)throw new RangeError("Input dims doesn't match data length.");if(_==="string"){if(!(T===void 0||Array.isArray(T)&&T.every(O=>typeof O=="string")))throw new TypeError("cache should be a string array");E&&(this.cache=new Array(S))}else{if(T!==void 0){const O=e(_);if(!(T instanceof O))throw new TypeError(`cache should be type ${O.name}`)}if(E){const O=new ArrayBuffer(S*function(v){switch(v){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 ${v}`)}}(_));this.cache=function(v,M){return new(e(M))(v)}(O,_)}}}static fromProto(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const _=g.ProtoUtil.tensorDataTypeFromProto(m.dataType),b=g.ProtoUtil.tensorDimsFromProto(m.dims),y=new a(b,_);if(_==="string")m.stringData.forEach((T,w)=>{y.data[w]=(0,g.decodeUtf8String)(T)});else if(m.rawData&&typeof m.rawData.byteLength=="number"&&m.rawData.byteLength>0){const T=y.data,w=new DataView(m.rawData.buffer,m.rawData.byteOffset,m.rawData.byteLength),S=t(m.dataType),E=m.rawData.byteLength/S;if(m.rawData.byteLength%S!=0)throw new Error("invalid buffer length");if(T.length!==E)throw new Error("buffer length mismatch");for(let O=0;O<E;O++){const v=i(w,m.dataType,O*S);T[O]=v}}else{let T;switch(m.dataType){case u.onnx.TensorProto.DataType.FLOAT:T=m.floatData;break;case u.onnx.TensorProto.DataType.INT32:case u.onnx.TensorProto.DataType.INT16:case u.onnx.TensorProto.DataType.UINT16:case u.onnx.TensorProto.DataType.INT8:case u.onnx.TensorProto.DataType.UINT8:case u.onnx.TensorProto.DataType.BOOL:T=m.int32Data;break;case u.onnx.TensorProto.DataType.INT64:T=m.int64Data;break;case u.onnx.TensorProto.DataType.DOUBLE:T=m.doubleData;break;case u.onnx.TensorProto.DataType.UINT32:case u.onnx.TensorProto.DataType.UINT64:T=m.uint64Data;break;default:throw new Error("unspecific error")}if(T==null)throw new Error("failed to populate data from a tensorproto value");const w=y.data;if(w.length!==T.length)throw new Error("array length mismatch");for(let S=0;S<T.length;S++){const E=T[S];f.default.isLong(E)?w[S]=r(E,m.dataType):w[S]=E}}return y}static fromData(m,_,b){return new a(_,b,void 0,void 0,m)}static fromOrtTensor(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const _=g.ProtoUtil.tensorDimsFromORTFormat(m),b=g.ProtoUtil.tensorDataTypeFromProto(m.dataType()),y=new a(_,b);if(b==="string")for(let T=0;T<m.stringDataLength();T++)y.data[T]=m.stringData(T);else if(m.rawDataArray()&&typeof m.rawDataLength()=="number"&&m.rawDataLength()>0){const T=y.data,w=new DataView(m.rawDataArray().buffer,m.rawDataArray().byteOffset,m.rawDataLength()),S=t(m.dataType()),E=m.rawDataLength()/S;if(m.rawDataLength()%S!=0)throw new Error("invalid buffer length");if(T.length!==E)throw new Error("buffer length mismatch");for(let O=0;O<E;O++){const v=i(w,m.dataType(),O*S);T[O]=v}}return y}}function t(h){switch(h){case u.onnx.TensorProto.DataType.UINT8:case u.onnx.TensorProto.DataType.INT8:case u.onnx.TensorProto.DataType.BOOL:return 1;case u.onnx.TensorProto.DataType.UINT16:case u.onnx.TensorProto.DataType.INT16:return 2;case u.onnx.TensorProto.DataType.FLOAT:case u.onnx.TensorProto.DataType.INT32:case u.onnx.TensorProto.DataType.UINT32:return 4;case u.onnx.TensorProto.DataType.INT64:case u.onnx.TensorProto.DataType.DOUBLE:case u.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${u.onnx.TensorProto.DataType[h]}`)}}function e(h){switch(h){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function r(h,m){if(m===u.onnx.TensorProto.DataType.INT64||m===c.TensorDataType.INT64){if(h.greaterThanOrEqual(2147483648)||h.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else{if(m!==u.onnx.TensorProto.DataType.UINT32&&m!==c.TensorDataType.UINT32&&m!==u.onnx.TensorProto.DataType.UINT64&&m!==c.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${u.onnx.TensorProto.DataType[m]}`);if(h.greaterThanOrEqual(4294967296)||h.lessThan(0))throw new TypeError("uint64 is not supported")}return h.toNumber()}function i(h,m,_){switch(m){case u.onnx.TensorProto.DataType.BOOL:case u.onnx.TensorProto.DataType.UINT8:return h.getUint8(_);case u.onnx.TensorProto.DataType.INT8:return h.getInt8(_);case u.onnx.TensorProto.DataType.UINT16:return h.getUint16(_,!0);case u.onnx.TensorProto.DataType.INT16:return h.getInt16(_,!0);case u.onnx.TensorProto.DataType.FLOAT:return h.getFloat32(_,!0);case u.onnx.TensorProto.DataType.INT32:return h.getInt32(_,!0);case u.onnx.TensorProto.DataType.UINT32:return h.getUint32(_,!0);case u.onnx.TensorProto.DataType.INT64:return r(f.default.fromBits(h.getUint32(_,!0),h.getUint32(_+4,!0),!1),m);case u.onnx.TensorProto.DataType.DOUBLE:return h.getFloat64(_,!0);case u.onnx.TensorProto.DataType.UINT64:return r(f.default.fromBits(h.getUint32(_,!0),h.getUint32(_+4,!0),!0),m);default:throw new Error(`cannot read from DataView for type ${u.onnx.TensorProto.DataType[m]}`)}}n.Tensor=a},2517:function(d,n,o){var s=this&&this.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(n,"__esModule",{value:!0}),n.decodeUtf8String=n.MAX_CLIP=n.MIN_CLIP=n.PoolConvUtil=n.ReduceUtil=n.SplitUtil=n.MathUtil=n.ShapeUtil=n.LongUtil=n.ProtoUtil=n.GemmUtil=n.arrayCopyHelper=n.BroadcastUtil=n.MatMulUtil=n.ArrayUtil=n.assert=n.checkInputsShape=void 0;const l=o(5686),f=s(o(3720)),u=o(1446),p=o(9162);n.checkInputsShape=function(m,..._){if(!m||m.length!==_.length)return!1;for(let b=0;b<m.length;b++)if(!m[b].dims||m[b].dims.length!==_[b])return!1;return!0},n.assert=function(m,_){if(!m)throw new Error(typeof _=="string"?_:_())},n.ArrayUtil=class{static arraysEqual(m,_){if(m.length!==_.length)return!1;for(let b=0;b<m.length;b++)if(m[b]!==_[b])return!1;return!0}};class g{static preprocessInputShapes(_,b){return[_.length===1?[1,_[0]]:_,b.length===1?[b[0],1]:b]}static postprocessOutputShape(_,b,y){b===1&&_.splice(_.length-2,1),y===1&&_.pop()}static calcMatMulShape(_,b){return _[1]!==b[0]?void 0:[_[0],b[1]]}}n.MatMulUtil=g;class c{static calcShape(_,b,y=!1){const T=_.length,w=b.length;if(T===0)return b;if(w===0)return _;const S=Math.max(_.length,b.length),E=new Array(S);if(y){if(T<2||w<2)return;const O=g.calcMatMulShape([_[T-2],_[T-1]],[b[w-2],b[w-1]]);if(O===void 0)return;[E[S-2],E[S-1]]=O}for(let O=y?3:1;O<=S;O++){const v=T-O<0?1:_[T-O],M=w-O<0?1:b[w-O];if(v!==M&&v>1&&M>1)return;E[S-O]=Math.max(v,M)}return E}static index(_,b){const y=new Array(b.length);return c.fillIndex(_,b,y),y}static fillIndex(_,b,y){const T=_.length-b.length;for(let w=0;w<b.length;w++)y[w]=_[T+w]%b[w]}static calc(_,b,y,T,w){const S=c.calcShape(_.dims,b.dims);if(S){if(T&&!e.areEqual(S,_.dims))return;const E=e.size(S),O=T?_:new p.Tensor(S,w||_.type);if(S.length===0)O.set([],y(_.get([]),b.get([])));else{const v=new Array(S.length),M=new Array(_.dims.length),$=new Array(b.dims.length);let V,B=0,L=0,D=!1,k=!1;_.dims.length===0&&(B=_.get([]),D=!0),b.dims.length===0&&(L=b.get([]),k=!0);for(let F=0;F<E;F++){V=F;for(let Q=S.length-1;Q>=0;Q--)v[Q]=V%S[Q],V=Math.floor(V/S[Q]);D||(c.fillIndex(v,_.dims,M),B=_.get(M)),k||(c.fillIndex(v,b.dims,$),L=b.get($)),O.set(v,y(B,L))}}return O}}static isValidBroadcast(_,b){const y=_.length,T=b.length;if(y>T)return!1;for(let w=1;w<=y;w++)if(_[y-w]!==1&&_[y-w]!==b[T-w])return!1;return!0}static getBroadcastDims(_,b){const y=_.length,T=[];for(let w=0;w<y;w++){const S=y-1-w,E=_[S]||1;(b[b.length-1-w]||1)>1&&E===1&&T.unshift(S)}return T}}n.BroadcastUtil=c,n.arrayCopyHelper=function(m,_,b,y,T){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<T;w++)m[b+w]=_[y+w]},n.GemmUtil=class{static getShapeOfGemmResult(m,_,b,y,T){if(m.length!==2||b.length!==2)throw new Error("shape need to be of size 2");let w,S,E;_?(w=m[1],S=m[0]):(w=m[0],S=m[1]);let O=-1;if(y?(E=b[0],O=1):(E=b[1],O=0),b[O]!==S)throw new Error("dimension mismatch");if(w<=0||E<=0||S<=0)throw new Error("invalid shape specified");if(T&&!c.isValidBroadcast(T,[w,E]))throw new Error("gemm: invalid bias shape for broadcast");return[w,E,S]}};class a{static tensorDataTypeFromProto(_){switch(_){case u.onnx.TensorProto.DataType.INT8:return"int8";case u.onnx.TensorProto.DataType.UINT8:return"uint8";case u.onnx.TensorProto.DataType.BOOL:return"bool";case u.onnx.TensorProto.DataType.INT16:return"int16";case u.onnx.TensorProto.DataType.UINT16:return"uint16";case u.onnx.TensorProto.DataType.INT32:return"int32";case u.onnx.TensorProto.DataType.UINT32:return"uint32";case u.onnx.TensorProto.DataType.FLOAT:return"float32";case u.onnx.TensorProto.DataType.DOUBLE:return"float64";case u.onnx.TensorProto.DataType.STRING:return"string";case u.onnx.TensorProto.DataType.INT64:return"int32";case u.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${u.onnx.TensorProto.DataType[_]}`)}}static tensorDataTypeStringToEnum(_){switch(_){case"int8":return u.onnx.TensorProto.DataType.INT8;case"uint8":return u.onnx.TensorProto.DataType.UINT8;case"bool":return u.onnx.TensorProto.DataType.BOOL;case"int16":return u.onnx.TensorProto.DataType.INT16;case"uint16":return u.onnx.TensorProto.DataType.UINT16;case"int32":return u.onnx.TensorProto.DataType.INT32;case"uint32":return u.onnx.TensorProto.DataType.UINT32;case"float32":return u.onnx.TensorProto.DataType.FLOAT;case"float64":return u.onnx.TensorProto.DataType.DOUBLE;case"string":return u.onnx.TensorProto.DataType.STRING;case"int64":return u.onnx.TensorProto.DataType.INT64;case"uint64":return u.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${_}`)}}static tensorDimsFromProto(_){return _.map(b=>f.default.isLong(b)?b.toNumber():b)}static tensorValueTypeFromProto(_){return{tensorType:a.tensorDataTypeFromProto(_.elemType),shape:{dims:a.tensorDimsFromProto(_.shape.dim.map(b=>b.dimValue))}}}static tensorDimsFromORTFormat(_){const b=[];for(let y=0;y<_.dimsLength();y++)b.push(t.longToNumber(_.dims(y)));return b}static tensorAttributesFromORTFormat(_){const b=[];for(let y=0;y<_.attributesLength();y++)b.push(_.attributes(y));return b}}n.ProtoUtil=a;class t{static longToNumber(_,b){return f.default.isLong(_)?_.toNumber():_ instanceof l.flatbuffers.Long?f.default.fromValue({low:_.low,high:_.high,unsigned:b!=null&&b}).toNumber():_}static isLong(_){return f.default.isLong(_)||_ instanceof l.flatbuffers.Long}}n.LongUtil=t;class e{static size(_){return e.getSizeFromDimensionRange(_,0,_.length)}static sizeFromDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeFromDimension as Tensor has ${_.length} dimensions.`);return e.getSizeFromDimensionRange(_,b,_.length)}static sizeToDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeToDimension as Tensor has ${_.length} dimensions.`);return e.getSizeFromDimensionRange(_,0,b)}static getSizeFromDimensionRange(_,b,y){let T=1;for(let w=b;w<y;w++){if(_[w]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");T*=_[w]}return T}static computeStrides(_){const b=_.length;if(b===0)return[];if(b===1)return[1];const y=new Array(b);y[b-1]=1,y[b-2]=_[b-1];for(let T=b-3;T>=0;--T)y[T]=y[T+1]*_[T+1];return y}static transpose(_){return _.slice().reverse()}static indicesToOffset(_,b,y){y===void 0&&(y=_.length);let T=0;for(let w=0;w<y;++w)T+=b[w]*_[w];return T}static offsetToIndices(_,b){const y=b.length;if(y===0)return[];if(y===1)return[_*b[0]];const T=new Array(b.length);for(let w=0;w<T.length-1;++w)T[w]=Math.floor(_/b[w]),_-=T[w]*b[w];return T[T.length-1]=_,T}static normalizeAxis(_,b){if(_<-b&&_>=b)throw new Error("unsupported axis for this operation.");return _<0?_+b:_}static normalizeAxes(_,b){return _.map(y=>this.normalizeAxis(y,b))}static incrementIndex(_,b,y){if(b.length===0||_.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(y===void 0)y=b.length;else if(y<=0||y>b.length)throw new Error("Incorrect axis to increment on");for(let T=y-1;T>=0&&(_[T]++,!(_[T]<b[T]));--T)_[T]=0}static calculateReshapedDims(_,b){if(b.length===0){if(_.length===0||e.size(_)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const y=b.length,T=new Array(y);let w=-1,S=1;for(let O=0;O<y;O++){if(b[O]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(b[O]===-1){if(w!==-1)throw new Error("at most one dimension in shape hints can be -1");w=O}else{if(b[O]===0){if(O>=_.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");T[O]=_[O]}else T[O]=b[O];S*=T[O]}}const E=e.size(_);if(w!==-1){if(E%S!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${_}] Output shape: [${b}]`);T[w]=E/S}else if(S!==E)throw new Error("reshapedDims and originalDims don't have matching sizes");return T}static sortBasedOnPerm(_,b){return b?b.map(y=>_[y]):_.slice().reverse()}static padShape(_,b){const y=_.length;return _.map((T,w)=>T+b[w]+b[w+y])}static areEqual(_,b){return _.length===b.length&&_.every((y,T)=>y===b[T])}static validateDimsAndCalcSize(_){if(_.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let b=1;for(const y of _){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`);b*=y}return b}static flattenShape(_,b){b<0&&(b+=_.length);const y=_.reduce((w,S)=>w*S,1),T=_.slice(b).reduce((w,S)=>w*S,1);return[y/T,T]}static squeezeShape(_,b){const y=new Array;b=e.normalizeAxes(b,_.length);for(let T=0;T<_.length;T++){const w=b.indexOf(T)>=0;if(w&&_[T]!==1)throw new Error("squeeze an axis of size different than 1");(b.length===0&&_[T]>1||b.length>0&&!w)&&y.push(_[T])}return y}static unsqueezeShape(_,b){const y=new Array(_.length+b.length);y.fill(0);for(let w=0;w<b.length;w++){const S=e.normalizeAxis(b[w],y.length);if(S>=y.length)throw new Error("'axes' has an out of range axis");if(y[S]!==0)throw new Error("'axes' has a duplicate axis");y[S]=1}let T=0;for(let w=0;w<y.length;w++)y[w]===0&&(y[w]=_[T++]);if(T!==_.length)throw new Error("the unsqueezed dimension could not be established");return y}}n.ShapeUtil=e,n.MathUtil=class{static sqr(m,_,b,y,T){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<T;w++)m[b+w]+=Math.pow(_[y+w],2)}static axpy(m,_,b,y,T,w){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let S=0;S<T;S++)m[b+S]+=w*_[y+S]}static powx(m,_,b,y,T,w){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let S=0;S<T;S++)m[b+S]=Math.pow(_[y+S],w)}static mul(m,_,b,y,T){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<T;w++)m[b+w]=_[y+w]*m[b+w]}};class r{static splitShape(_,b,y,T){if(y.length===0){if(!T)throw new Error("need to know number of outputs when the 'split' attribute is not specified");r.determineSplit(_[b],T,y)}const w=[],S=[0];for(let E=0;E<y.length;++E){E!==0&&S.push(S[E-1]+y[E-1]);const O=_.slice();O[b]=y[E],w.push(O)}return[w,S]}static determineSplit(_,b,y){if(_%b!=0)throw new Error("cannot split tensor to equal sized parts");for(let T=0;T<b;++T)y.push(_/b)}}n.SplitUtil=r;class i{static calcReduce(_,b,y,T,w){const S=_.dims.slice(0);b.length===0&&S.forEach((B,L)=>b.push(L));const E=i.calcReduceShape(S,b,!0),O=e.size(E),v=new p.Tensor(E,_.type),M=e.computeStrides(E),$=e.computeStrides(S),V=new Array(S.length);for(let B=0;B<O;B++){const L=e.offsetToIndices(B,M);c.fillIndex(L,S,V),v.set(L,i.calcReduceByAxis(_.numberData,b,S,0,e.indicesToOffset(V,$),T,w))}return y?v:new p.Tensor(i.calcReduceShape(S,b,y),v.type,void 0,void 0,v.data,v.dataId)}static calcReduceByAxis(_,b,y,T,w,S,E){let O=0;if(T>=b.length)return S(_[w]);const v=b[T],M=v>=y.length?1:e.size(y.slice(v+1));for(let $=0;$<y[v];$++)O=$===0?i.calcReduceByAxis(_,b,y,T+1,w,S,E):E(O,i.calcReduceByAxis(_,b,y,T+1,w,S,E)),w+=M;return O}static calcReduceShape(_,b,y){const T=_.slice();for(let w=0;w<b.length;w++)T[b[w]]=y?1:0;return T.filter(w=>w!==0)}}n.ReduceUtil=i;class h{static adjustPoolAttributes(_,b,y,T,w,S){if(!_&&y.length!==b.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(_)for(let E=0;E<b.length-2;E++)E>=y.length?y.push(b[E+2]):y[E]=b[E+2];for(let E=0;E<y.length;E++)if(E<T.length){if(T[E]<0)throw new Error("strides should be greater than or equal to 1")}else T.push(1);for(let E=0;E<y.length;E++)if(E<w.length){if(w[E]<0)throw new Error("dilations should be greater than or equal to 1")}else w.push(1);for(let E=0;E<2*y.length;E++)if(E<S.length){if(S[E]<0)throw new Error("pad should be greater than or equal to 1")}else S.push(0);for(let E=0;E<y.length;E++){if(y[E]<=0)throw new Error("kernel shapes need to be greater than 0");if(S[E]>=y[E]||S[E+y.length]>=y[E])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(_,b,y,T,w,S){if(S){if(w.length!==2*(_.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(b.length!==_.length-2)throw new Error("length of strides should be the length of data dimensions");if(T.length!==_.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let E=0;E<_.length-2;E++)h.adjustPadAndReturnShape(_[E+2],b[E],y[E],T[E],w,E,E+_.length-2,S)}}static computePoolOutputShape(_,b,y,T,w,S,E){if(b.length<=0)throw new Error("input shape must be of size greater than 0");const O=[b[0],b[1]];return h.computeShapeHelper(_,b,O,y,T,w,S,E),O}static computeConvOutputShape(_,b,y,T,w,S,E){if(_.length<=0||b.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const O=[_[0],b[0]];return h.computeShapeHelper(!1,_,O,y,T,w,S,E),O}static computeShapeHelper(_,b,y,T,w,S,E,O){if(_)for(let v=0;v<b.length-2;v++)y.push(1);else for(let v=0;v<b.length-2;v++)y.push(h.adjustPadAndReturnShape(b[v+2],T[v],w[v],S[v],E,v,v+b.length-2,O))}static adjustPadAndReturnShape(_,b,y,T,w,S,E,O){const v=y*(T-1)+1;if(!O||O==="NOTSET")return Math.floor((_+w[S]+w[E]-v)/b+1);switch(O){case"VALID":return w[S]=0,w[E]=0,Math.floor((_-v)/b+1);case"SAME_LOWER":case"SAME_UPPER":if(y!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{const M=((_+b-1)/b-1)*b+T-_;return w[S]=Math.floor(O==="SAME_LOWER"?(M+1)/2:M/2),w[E]=M-w[S],Math.floor((_+M-T)/b+1)}default:throw new Error("Unsupported AutoPad type")}}}n.PoolConvUtil=h,n.MIN_CLIP=-34028234663852886e22,n.MAX_CLIP=34028234663852886e22,n.decodeUtf8String=function(m){return new TextDecoder().decode(m)}},7967:(d,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.iterateExtraOptions=void 0,n.iterateExtraOptions=(o,s,l,f)=>{if(typeof o=="object"&&o!==null){if(l.has(o))throw new Error("Circular reference in options");l.add(o)}Object.entries(o).forEach(([u,p])=>{const g=s?s+u:u;if(typeof p=="object")(0,n.iterateExtraOptions)(p,g+".",l,f);else if(typeof p=="string"||typeof p=="number")f(g,p.toString());else{if(typeof p!="boolean")throw new Error("Can't handle extra config type: "+typeof p);f(g,p?"1":"0")}})}},2157:function(d,n,o){var s,l=this&&this.__createBinding||(Object.create?function(M,$,V,B){B===void 0&&(B=V);var L=Object.getOwnPropertyDescriptor($,V);L&&!("get"in L?!$.__esModule:L.writable||L.configurable)||(L={enumerable:!0,get:function(){return $[V]}}),Object.defineProperty(M,B,L)}:function(M,$,V,B){B===void 0&&(B=V),M[B]=$[V]}),f=this&&this.__setModuleDefault||(Object.create?function(M,$){Object.defineProperty(M,"default",{enumerable:!0,value:$})}:function(M,$){M.default=$}),u=this&&this.__importStar||function(M){if(M&&M.__esModule)return M;var $={};if(M!=null)for(var V in M)V!=="default"&&Object.prototype.hasOwnProperty.call(M,V)&&l($,M,V);return f($,M),$};Object.defineProperty(n,"__esModule",{value:!0}),n.endProfiling=n.run=n.releaseSession=n.createSession=n.createSessionFinalize=n.createSessionAllocate=n.initOrt=n.initWasm=void 0;const p=o(1670),g=u(o(349)),c=o(6361),a=()=>!!p.env.wasm.proxy&&typeof document<"u";let t,e,r,i=!1,h=!1,m=!1;const _=[],b=[],y=[],T=[],w=[],S=[],E=()=>{if(i||!h||m||!t)throw new Error("worker not ready")},O=M=>{switch(M.data.type){case"init-wasm":i=!1,M.data.err?(m=!0,e[1](M.data.err)):(h=!0,e[0]());break;case"init-ort":M.data.err?r[1](M.data.err):r[0]();break;case"create_allocate":M.data.err?_.shift()[1](M.data.err):_.shift()[0](M.data.out);break;case"create_finalize":M.data.err?b.shift()[1](M.data.err):b.shift()[0](M.data.out);break;case"create":M.data.err?y.shift()[1](M.data.err):y.shift()[0](M.data.out);break;case"release":M.data.err?T.shift()[1](M.data.err):T.shift()[0]();break;case"run":M.data.err?w.shift()[1](M.data.err):w.shift()[0](M.data.out);break;case"end-profiling":M.data.err?S.shift()[1](M.data.err):S.shift()[0]()}},v=typeof document<"u"?(s=document==null?void 0:document.currentScript)===null||s===void 0?void 0:s.src:void 0;n.initWasm=async()=>{if(a()){if(h)return;if(i)throw new Error("multiple calls to 'initWasm()' detected.");if(m)throw new Error("previous call to 'initWasm()' failed.");return i=!0,p.env.wasm.wasmPaths===void 0&&v&&v.indexOf("blob:")!==0&&(p.env.wasm.wasmPaths=v.substr(0,+v.lastIndexOf("/")+1)),new Promise((M,$)=>{t==null||t.terminate(),t=o(9710).Z(),t.onmessage=O,e=[M,$];const V={type:"init-wasm",in:p.env.wasm};t.postMessage(V)})}return(0,c.initializeWebAssembly)(p.env.wasm)},n.initOrt=async(M,$)=>{if(a())return E(),new Promise((V,B)=>{r=[V,B];const L={type:"init-ort",in:{numThreads:M,loggingLevel:$}};t.postMessage(L)});g.initOrt(M,$)},n.createSessionAllocate=async M=>a()?(E(),new Promise(($,V)=>{_.push([$,V]);const B={type:"create_allocate",in:{model:M}};t.postMessage(B,[M.buffer])})):g.createSessionAllocate(M),n.createSessionFinalize=async(M,$)=>a()?(E(),new Promise((V,B)=>{b.push([V,B]);const L={type:"create_finalize",in:{modeldata:M,options:$}};t.postMessage(L)})):g.createSessionFinalize(M,$),n.createSession=async(M,$)=>a()?(E(),new Promise((V,B)=>{y.push([V,B]);const L={type:"create",in:{model:M,options:$}};t.postMessage(L,[M.buffer])})):g.createSession(M,$),n.releaseSession=async M=>{if(a())return E(),new Promise(($,V)=>{T.push([$,V]);const B={type:"release",in:M};t.postMessage(B)});g.releaseSession(M)},n.run=async(M,$,V,B,L)=>a()?(E(),new Promise((D,k)=>{w.push([D,k]);const F={type:"run",in:{sessionId:M,inputIndices:$,inputs:V,outputIndices:B,options:L}};t.postMessage(F,g.extractTransferableBuffers(V))})):g.run(M,$,V,B,L),n.endProfiling=async M=>{if(a())return E(),new Promise(($,V)=>{S.push([$,V]);const B={type:"end-profiling",in:M};t.postMessage(B)});g.endProfiling(M)}},586:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.setRunOptions=void 0;const s=o(7967),l=o(4983),f=o(6361);n.setRunOptions=u=>{const p=(0,f.getInstance)();let g=0;const c=[],a=u||{};try{if((u==null?void 0:u.logSeverityLevel)===void 0)a.logSeverityLevel=2;else if(typeof u.logSeverityLevel!="number"||!Number.isInteger(u.logSeverityLevel)||u.logSeverityLevel<0||u.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${u.logSeverityLevel}`);if((u==null?void 0:u.logVerbosityLevel)===void 0)a.logVerbosityLevel=0;else if(typeof u.logVerbosityLevel!="number"||!Number.isInteger(u.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${u.logVerbosityLevel}`);(u==null?void 0:u.terminate)===void 0&&(a.terminate=!1);let t=0;if((u==null?void 0:u.tag)!==void 0&&(t=(0,l.allocWasmString)(u.tag,c)),g=p._OrtCreateRunOptions(a.logSeverityLevel,a.logVerbosityLevel,!!a.terminate,t),g===0)throw new Error("Can't create run options");return(u==null?void 0:u.extra)!==void 0&&(0,s.iterateExtraOptions)(u.extra,"",new WeakSet,(e,r)=>{const i=(0,l.allocWasmString)(e,c),h=(0,l.allocWasmString)(r,c);if(p._OrtAddRunConfigEntry(g,i,h)!==0)throw new Error(`Can't set a run config entry: ${e} - ${r}`)}),[g,c]}catch(t){throw g!==0&&p._OrtReleaseRunOptions(g),c.forEach(p._free),t}}},2306:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OnnxruntimeWebAssemblySessionHandler=void 0;const s=o(2806),l=o(1670),f=o(2850),u=o(2157);let p;n.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(g){const c=await fetch(g),a=await c.arrayBuffer();return(0,u.createSessionAllocate)(new Uint8Array(a))}async loadModel(g,c){if(p||(await(0,u.initOrt)(l.env.wasm.numThreads,(a=>{switch(a){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: ${a}`)}})(l.env.logLevel)),p=!0),typeof g=="string")if(typeof fetch>"u"){const a=await(0,f.promisify)(s.readFile)(g);[this.sessionId,this.inputNames,this.outputNames]=await(0,u.createSession)(a,c)}else{const a=await this.createSessionAllocate(g);[this.sessionId,this.inputNames,this.outputNames]=await(0,u.createSessionFinalize)(a,c)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,u.createSession)(g,c)}async dispose(){return(0,u.releaseSession)(this.sessionId)}async run(g,c,a){const t=[],e=[];Object.entries(g).forEach(m=>{const _=m[0],b=m[1],y=this.inputNames.indexOf(_);if(y===-1)throw new Error(`invalid input '${_}'`);t.push(b),e.push(y)});const r=[];Object.entries(c).forEach(m=>{const _=m[0],b=this.outputNames.indexOf(_);if(b===-1)throw new Error(`invalid output '${_}'`);r.push(b)});const i=await(0,u.run)(this.sessionId,e,t.map(m=>[m.type,m.dims,m.data]),r,a),h={};for(let m=0;m<i.length;m++)h[this.outputNames[r[m]]]=new l.Tensor(i[m][0],i[m][2],i[m][1]);return h}startProfiling(){}endProfiling(){(0,u.endProfiling)(this.sessionId)}}},4919:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.setSessionOptions=void 0;const s=o(7967),l=o(4983),f=o(6361);n.setSessionOptions=u=>{const p=(0,f.getInstance)();let g=0;const c=[],a=u||{};(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")})(a);try{(u==null?void 0:u.graphOptimizationLevel)===void 0&&(a.graphOptimizationLevel="all");const t=(i=>{switch(i){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${i}`)}})(a.graphOptimizationLevel);(u==null?void 0:u.enableCpuMemArena)===void 0&&(a.enableCpuMemArena=!0),(u==null?void 0:u.enableMemPattern)===void 0&&(a.enableMemPattern=!0),(u==null?void 0:u.executionMode)===void 0&&(a.executionMode="sequential");const e=(i=>{switch(i){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${i}`)}})(a.executionMode);let r=0;if((u==null?void 0:u.logId)!==void 0&&(r=(0,l.allocWasmString)(u.logId,c)),(u==null?void 0:u.logSeverityLevel)===void 0)a.logSeverityLevel=2;else if(typeof u.logSeverityLevel!="number"||!Number.isInteger(u.logSeverityLevel)||u.logSeverityLevel<0||u.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${u.logSeverityLevel}`);if((u==null?void 0:u.logVerbosityLevel)===void 0)a.logVerbosityLevel=0;else if(typeof u.logVerbosityLevel!="number"||!Number.isInteger(u.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${u.logVerbosityLevel}`);if((u==null?void 0:u.enableProfiling)===void 0&&(a.enableProfiling=!1),g=p._OrtCreateSessionOptions(t,!!a.enableCpuMemArena,!!a.enableMemPattern,e,!!a.enableProfiling,0,r,a.logSeverityLevel,a.logVerbosityLevel),g===0)throw new Error("Can't create session options");return u!=null&&u.executionProviders&&((i,h,m)=>{for(const _ of h){let b=typeof _=="string"?_:_.name;switch(b){case"xnnpack":b="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${b}`)}const y=(0,l.allocWasmString)(b,m);if((0,f.getInstance)()._OrtAppendExecutionProvider(i,y)!==0)throw new Error(`Can't append execution provider: ${b}`)}})(g,u.executionProviders,c),(u==null?void 0:u.extra)!==void 0&&(0,s.iterateExtraOptions)(u.extra,"",new WeakSet,(i,h)=>{const m=(0,l.allocWasmString)(i,c),_=(0,l.allocWasmString)(h,c);if(p._OrtAddSessionConfigEntry(g,m,_)!==0)throw new Error(`Can't set a session config entry: ${i} - ${h}`)}),[g,c]}catch(t){throw g!==0&&p._OrtReleaseSessionOptions(g),c.forEach(p._free),t}}},4983:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.allocWasmString=void 0;const s=o(6361);n.allocWasmString=(l,f)=>{const u=(0,s.getInstance)(),p=u.lengthBytesUTF8(l)+1,g=u._malloc(p);return u.stringToUTF8(l,g,p),f.push(g),g}},349:(d,n,o)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.extractTransferableBuffers=n.endProfiling=n.run=n.releaseSession=n.createSession=n.createSessionFinalize=n.createSessionAllocate=n.initOrt=void 0;const s=o(586),l=o(4919),f=o(4983),u=o(6361);n.initOrt=(t,e)=>{const r=(0,u.getInstance)()._OrtInit(t,e);if(r!==0)throw new Error(`Can't initialize onnxruntime. error code = ${r}`)};const p=new Map;n.createSessionAllocate=t=>{const e=(0,u.getInstance)(),r=e._malloc(t.byteLength);return e.HEAPU8.set(t,r),[r,t.byteLength]},n.createSessionFinalize=(t,e)=>{const r=(0,u.getInstance)();let i=0,h=0,m=[];try{if([h,m]=(0,l.setSessionOptions)(e),i=r._OrtCreateSession(t[0],t[1],h),i===0)throw new Error("Can't create a session")}finally{r._free(t[0]),r._OrtReleaseSessionOptions(h),m.forEach(r._free)}const _=r._OrtGetInputCount(i),b=r._OrtGetOutputCount(i),y=[],T=[],w=[],S=[];for(let E=0;E<_;E++){const O=r._OrtGetInputName(i,E);if(O===0)throw new Error("Can't get an input name");T.push(O),y.push(r.UTF8ToString(O))}for(let E=0;E<b;E++){const O=r._OrtGetOutputName(i,E);if(O===0)throw new Error("Can't get an output name");S.push(O),w.push(r.UTF8ToString(O))}return p.set(i,[i,T,S]),[i,y,w]},n.createSession=(t,e)=>{const r=(0,n.createSessionAllocate)(t);return(0,n.createSessionFinalize)(r,e)},n.releaseSession=t=>{const e=(0,u.getInstance)(),r=p.get(t);if(!r)throw new Error("invalid session id");const i=r[0],h=r[1],m=r[2];h.forEach(e._OrtFree),m.forEach(e._OrtFree),e._OrtReleaseSession(i),p.delete(t)};const g=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}`)}},c=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}`)}},a=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}`)}};n.run=(t,e,r,i,h)=>{const m=(0,u.getInstance)(),_=p.get(t);if(!_)throw new Error("invalid session id");const b=_[0],y=_[1],T=_[2],w=e.length,S=i.length;let E=0,O=[];const v=[],M=[];try{[E,O]=(0,s.setRunOptions)(h);for(let k=0;k<w;k++){const F=r[k][0],Q=r[k][1],Y=r[k][2];let ee,te;if(Array.isArray(Y)){te=4*Y.length,ee=m._malloc(te),M.push(ee);let xe=ee/4;for(let ue=0;ue<Y.length;ue++){if(typeof Y[ue]!="string")throw new TypeError(`tensor data at index ${ue} is not a string`);m.HEAPU32[xe++]=(0,f.allocWasmString)(Y[ue],M)}}else te=Y.byteLength,ee=m._malloc(te),M.push(ee),m.HEAPU8.set(new Uint8Array(Y.buffer,Y.byteOffset,te),ee);const he=m.stackSave(),Oe=m.stackAlloc(4*Q.length);try{let xe=Oe/4;Q.forEach(Se=>m.HEAP32[xe++]=Se);const ue=m._OrtCreateTensor(g(F),ee,te,Oe,Q.length);if(ue===0)throw new Error("Can't create a tensor");v.push(ue)}finally{m.stackRestore(he)}}const $=m.stackSave(),V=m.stackAlloc(4*w),B=m.stackAlloc(4*w),L=m.stackAlloc(4*S),D=m.stackAlloc(4*S);try{let k=V/4,F=B/4,Q=L/4,Y=D/4;for(let he=0;he<w;he++)m.HEAPU32[k++]=v[he],m.HEAPU32[F++]=y[e[he]];for(let he=0;he<S;he++)m.HEAPU32[Q++]=0,m.HEAPU32[Y++]=T[i[he]];let ee=m._OrtRun(b,B,V,w,D,S,L,E);const te=[];if(ee===0)for(let he=0;he<S;he++){const Oe=m.HEAPU32[L/4+he],xe=m.stackSave(),ue=m.stackAlloc(16);let Se,we=0;try{if(ee=m._OrtGetTensorData(Oe,ue,ue+4,ue+8,ue+12),ee!==0)throw new Error(`Can't access output tensor data. error code = ${ee}`);let $e=ue/4;const He=m.HEAPU32[$e++];we=m.HEAPU32[$e++];const Ae=m.HEAPU32[$e++],Fe=m.HEAPU32[$e++],De=[];for(let ve=0;ve<Fe;ve++)De.push(m.HEAPU32[Ae/4+ve]);m._OrtFree(Ae);const Me=De.length===0?1:De.reduce((ve,je)=>ve*je);if(Se=c(He),Se==="string"){const ve=[];let je=we/4;for(let ze=0;ze<Me;ze++){const Ue=m.HEAPU32[je++],Ye=ze===Me-1?void 0:m.HEAPU32[je]-Ue;ve.push(m.UTF8ToString(Ue,Ye))}te.push([Se,De,ve])}else{const ve=new(a(Se))(Me);new Uint8Array(ve.buffer,ve.byteOffset,ve.byteLength).set(m.HEAPU8.subarray(we,we+ve.byteLength)),te.push([Se,De,ve])}}finally{m.stackRestore(xe),Se==="string"&&we&&m._free(we),m._OrtReleaseTensor(Oe)}}if(ee===0)return te;throw new Error(`failed to call OrtRun(). error code = ${ee}.`)}finally{m.stackRestore($)}}finally{v.forEach(m._OrtReleaseTensor),M.forEach(m._free),m._OrtReleaseRunOptions(E),O.forEach(m._free)}},n.endProfiling=t=>{const e=(0,u.getInstance)(),r=p.get(t);if(!r)throw new Error("invalid session id");const i=r[0],h=e._OrtEndProfiling(i);if(h===0)throw new Error("Can't get an profile file name");e._OrtFree(h)},n.extractTransferableBuffers=t=>{const e=[];for(const r of t){const i=r[2];!Array.isArray(i)&&i.buffer&&e.push(i.buffer)}return e}},6361:function(d,n,o){var s=this&&this.__createBinding||(Object.create?function(h,m,_,b){b===void 0&&(b=_);var y=Object.getOwnPropertyDescriptor(m,_);y&&!("get"in y?!m.__esModule:y.writable||y.configurable)||(y={enumerable:!0,get:function(){return m[_]}}),Object.defineProperty(h,b,y)}:function(h,m,_,b){b===void 0&&(b=_),h[b]=m[_]}),l=this&&this.__setModuleDefault||(Object.create?function(h,m){Object.defineProperty(h,"default",{enumerable:!0,value:m})}:function(h,m){h.default=m}),f=this&&this.__importStar||function(h){if(h&&h.__esModule)return h;var m={};if(h!=null)for(var _ in h)_!=="default"&&Object.prototype.hasOwnProperty.call(h,_)&&s(m,h,_);return l(m,h),m},u=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(n,"__esModule",{value:!0}),n.dispose=n.getInstance=n.initializeWebAssembly=void 0;const p=f(o(6449)),g=u(o(932)),c=o(3474);let a,t=!1,e=!1,r=!1;const i=(h,m)=>m?h?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":h?"ort-wasm-simd.wasm":"ort-wasm.wasm";n.initializeWebAssembly=async h=>{if(t)return Promise.resolve();if(e)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(r)throw new Error("previous call to 'initializeWebAssembly()' failed.");e=!0;const m=h.initTimeout,_=h.numThreads,b=h.simd,y=_>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}})(),T=b&&(()=>{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}})(),w=typeof h.wasmPaths=="string"?h.wasmPaths:void 0,S=i(!1,y),E=i(T,y),O=typeof h.wasmPaths=="object"?h.wasmPaths[E]:void 0;let v=!1;const M=[];if(m>0&&M.push(new Promise($=>{setTimeout(()=>{v=!0,$()},m)})),M.push(new Promise(($,V)=>{const B=y?c:g.default,L={locateFile:(D,k)=>y&&D.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([o(4154)],{type:"text/javascript"})):D===S?O??(w??k)+E:k+D};if(y)if(typeof Blob>"u")L.mainScriptUrlOrBlob=p.join("/","ort-wasm-threaded.js");else{const D=`var ortWasmThreaded=(function(){var _scriptDir;return ${B.toString()}})();`;L.mainScriptUrlOrBlob=new Blob([D],{type:"text/javascript"})}B(L).then(D=>{e=!1,t=!0,a=D,$()},D=>{e=!1,r=!0,V(D)})})),await Promise.race(M),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${m}ms`)},n.getInstance=()=>{if(t&&a)return a;throw new Error("WebAssembly is not initialized yet.")},n.dispose=()=>{var h;!t||e||r||(e=!0,(h=a.PThread)===null||h===void 0||h.terminateAllThreads(),a=void 0,e=!1,t=!1,r=!0)}},9710:(d,n,o)=>{o.d(n,{Z:()=>f});var s=o(477),l=o.n(s);function f(){return l()('/*!\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<process.argv.length&&(m=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof ct))throw t})),process.on("unhandledRejection",(function(t){throw t})),g=(t,e)=>{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<n-e&&t.buffer&&L)return L.decode(t.buffer instanceof SharedArrayBuffer?t.slice(e,n):t.subarray(e,n));for(r="";e<n;){var a=t[e++];if(128&a){var i=63&t[e++];if(192==(224&a))r+=String.fromCharCode((31&a)<<6|i);else{var o=63&t[e++];65536>(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<r))return 0;var a=n>>>=0;r=n+r-1;for(var i=0;i<t.length;++i){var o=t.charCodeAt(i);if(55296<=o&&57343>=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<t.length;++n){var r=t.charCodeAt(n);127>=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<t.length;)t.shift()(u)}function yt(t){var e=Ee();return t=t(),Me(e),t}function bt(t){if(O)return $t(2,0,t);try{pt(t)}catch(t){t instanceof ct||"unwind"==t||g(1,t)}}u.PThread=ht,u.establishStackSpace=function(){var t=he(),e=a()[t+44>>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<o?(i()[n>>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<n;u++){var c=r[2+u];o()[i+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<a.length;++u)e()[o++>>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<n;u++){var c=i()[e>>2>>>0],s=i()[e+4>>2>>>0];e+=8;for(var l=0;l<s;l++)ae(t,r()[c+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.length<e;)t=n[0]+t;return t}function u(t,e){return o(t,e,"0")}function c(t,e){function n(t){return 0>t?-1:0<t?1:0}var r;return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function s(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function l(t){var e=t.Wb;for(t=new Date(new Date(t.Xb+1900,0,1).getTime());0<e;){var n=t.getMonth(),r=(ue(t.getFullYear())?ce:se)[n];if(!(e>r-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:12<t&&(t-=12),u(t,2)},"%j":function(t){for(var e=0,n=0;n<=t.ec-1;e+=(ue(t.Xb+1900)?ce:se)[n++]);return u(t.jc+e,3)},"%m":function(t){return u(t.ec+1,2)},"%M":function(t){return u(t.Kc,2)},"%n":function(){return"\\n"},"%p":function(t){return 0<=t.dc&&12>t.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;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(xe(i,n,e.Sb+16))return oe=i,t}return oe=n,t},l: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;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(xe(i,n,e.Sb+16))return oe=i,t}return oe=n,t},h: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;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(xe(i,n,e.Sb+16))return oe=i,t}return oe=n,t},t:Tt,M:function(){var t=_t.pop();t||at("no exception to throw");var e=t.Zb;throw t.kc()||(_t.push(t),t.ic(!0),t.hc(!1),Ot++),At=e,e},c:function(t,e,n){throw new St(t).fc(e,n),At=t,Ot++,t},pa:function(){return Ot},Fa:function(t){ge(t,!w,1,!v),ht.pc()},T:function(t){O?postMessage({cmd:"cleanupThread",thread:t}):st(t)},xa:Mt,j:function(t){throw At||(At=t),t},H:Ct,Ma:xt,ua:Rt,wa:jt,oa:kt,Ka:Dt,Ca:Pt,Ja:Ut,V:Ft,va:It,sa:Wt,La:Ht,ta:Lt,Ta:function(){},X:function(){at("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},Ua:function(){at("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},W:function(){return Date.now()},ya:function(){return 2097152},Oa:function(){return!0},za:function(t,e,n,r){if(t==e)setTimeout((()=>zt(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<n!=(c==r)&&(o=Math.max(u,o),e.setTime(e.getTime()+6e4*((0<n?c:o)-r))),a()[t+24>>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<e;r++)Xt[r]=o()[n+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<t)return!1;for(var n=1;4>=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<a;i++)e()[r+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<et))if(O)c(u),O||dt(X),postMessage({cmd:"loaded"});else{if(u.preRun)for("function"==typeof u.preRun&&(u.preRun=[u.preRun]);u.preRun.length;)K();dt(q),0<et||(u.setStatus?(u.setStatus("Running..."),setTimeout((function(){setTimeout((function(){u.setStatus("")}),1),t()}),1)):t())}}if(u.UTF8ToString=Y,u.stringToUTF8=function(t,e,n){return B(t,r(),e,n)},u.lengthBytesUTF8=G,u.keepRuntimeAlive=Q,u.wasmMemory=j,u.stackSave=Ee,u.stackRestore=Me,u.stackAlloc=Ce,u.ExitStatus=ct,u.PThread=ht,rt=function t(){ve||ze(),ve||(rt=t)},u.preInit)for("function"==typeof u.preInit&&(u.preInit=[u.preInit]);0<u.preInit.length;)u.preInit.pop()();return ze(),t.ready});t.exports=r},932:(t,e,n)=>{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<process.argv.length&&(p=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof J))throw t})),process.on("unhandledRejection",(function(t){throw t})),h=(t,e)=>{if(_||0<L)throw process.exitCode=t,e;e instanceof J||w("exiting due to exception: "+e),process.exit(t)},e.inspect=function(){return"[Emscripten Module object]"}):(d||y)&&(y?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),_scriptDir&&(m=_scriptDir),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=t=>{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<n-e&&t.buffer&&x)return x.decode(t.subarray(e,n));for(r="";e<n;){var a=t[e++];if(128&a){var i=63&t[e++];if(192==(224&a))r+=String.fromCharCode((31&a)<<6|i);else{var o=63&t[e++];65536>(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<r))return 0;var a=n>>>=0;r=n+r-1;for(var i=0;i<t.length;++i){var o=t.charCodeAt(i);if(55296<=o&&57343>=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<t.length;++n){var r=t.charCodeAt(n);127>=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<t.length;)t.shift()(e)}var Q=[],K=0,tt=0;function et(t){this.Db=t,this.zb=t-24,this.Ub=function(t){M[this.zb+4>>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.length<e;)t=n[0]+t;return t}function i(t,e){return a(t,e,"0")}function o(t,e){function n(t){return 0>t?-1:0<t?1:0}var r;return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function u(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function c(t){var e=t.Bb;for(t=new Date(new Date(t.Cb+1900,0,1).getTime());0<e;){var n=t.getMonth(),r=(pt(t.getFullYear())?ht:dt)[n];if(!(e>r-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:12<t&&(t-=12),i(t,2)},"%j":function(t){for(var e=0,n=0;n<=t.Hb-1;e+=(pt(t.Cb+1900)?ht:dt)[n++]);return i(t.Kb+e,3)},"%m":function(t){return i(t.Hb+1,2)},"%M":function(t){return i(t.Zb,2)},"%n":function(){return"\\n"},"%p":function(t){return 0<=t.Gb&&12>t.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<r.length;a++){var i=r[a];if(0===i||i===n)break;if(Et(i,n,e.zb+16))return ft=i,t}return ft=n,t},k: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<r.length;a++){var i=r[a];if(0===i||i===n)break;if(Et(i,n,e.zb+16))return ft=i,t}return ft=n,t},g: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<r.length;a++){var i=r[a];if(0===i||i===n)break;if(Et(i,n,e.zb+16))return ft=i,t}return ft=n,t},s:nt,L:function(){var t=Q.pop();t||V("no exception to throw");var e=t.Db;throw t.Lb()||(Q.push(t),t.Jb(!0),t.Ib(!1),K++),tt=e,e},b:function(t,e,n){throw new et(t).Rb(e,n),tt=t,K++,t},la:function(){return K},i:function(t){throw tt||(tt=t),t},H:function(){return 0},Ba:function(){},pa:function(){},ra:function(){},ka:function(){return 0},za:function(){},ua:function(){},ya:function(){},R:function(){},qa:function(){},na:function(){},Aa:function(){},oa:function(){},Ha:function(){},Ja:function(){V("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},Ia:function(){V("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},S:function(){return Date.now()},Ca:function(){return!0},Da:function(t,e){t=new Date(1e3*(M[t>>>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<n!=(u==r)&&(i=Math.max(o,i),e.setTime(e.getTime()+6e4*((0<n?u:i)-r))),E[t+24>>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<a?(M[n>>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<r.length;++i)S[a++>>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<L||(_t(),Z(W),wt(0),st[1].length&<(1,10),st[2].length&<(2,10)),_||0<L||(e.onExit&&e.onExit(t),C=!0),h(t,new J(t))},E:function(){return 52},Q:function(){return 52},ca:function(){return 70},P:function(t,e,n,r){for(var a=0,i=0;i<n;i++){var o=M[e>>2>>>0],u=M[e+4>>2>>>0];e+=8;for(var c=0;c<u;c++)lt(t,T[o+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<r;a++)S[e+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<B)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)z();Z(F),0<B||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),t()}),1)):t())}}if(e.UTF8ToString=j,e.stringToUTF8=function(t,e,n){return k(t,T,e,n)},e.lengthBytesUTF8=D,e.stackSave=At,e.stackRestore=St,e.stackAlloc=Tt,N=function t(){mt||Wt(),mt||(N=t)},e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return Wt(),t.ready});t.exports=r},967:(t,e)=>{"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<s;t++){const e=n._OrtGetInputName(r,t);if(0===e)throw new Error("Can\'t get an input name");p.push(e),f.push(n.UTF8ToString(e))}for(let t=0;t<l;t++){const e=n._OrtGetOutputName(r,t);if(0===e)throw new Error("Can\'t get an output name");d.push(e),h.push(n.UTF8ToString(e))}return u.set(r,[r,p,d]),[r,f,h]},e.createSession=(t,n)=>{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;t<m;t++){const e=n[t][0],r=n[t][1],a=n[t][2];let o,u;if(Array.isArray(a)){u=4*a.length,o=p._malloc(u),O.push(o);let t=o/4;for(let e=0;e<a.length;e++){if("string"!=typeof a[e])throw new TypeError(`tensor data at index ${e} is not a string`);p.HEAPU32[t++]=(0,i.allocWasmString)(a[e],O)}}else u=a.byteLength,o=p._malloc(u),O.push(o),p.HEAPU8.set(new Uint8Array(a.buffer,a.byteOffset,u),o);const s=p.stackSave(),l=p.stackAlloc(4*r.length);try{let t=l/4;r.forEach((e=>p.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;t<m;t++)p.HEAPU32[n++]=_[t],p.HEAPU32[r++]=y[e[t]];for(let t=0;t<g;t++)p.HEAPU32[i++]=0,p.HEAPU32[c++]=b[a[t]];let f=p._OrtRun(d,u,o,m,A,g,h,v);const w=[];if(0===f)for(let t=0;t<g;t++){const e=p.HEAPU32[h/4+t],n=p.stackSave(),r=p.stackAlloc(16);let a,i=0;try{if(f=p._OrtGetTensorData(e,r,r+4,r+8,r+12),0!==f)throw new Error(`Can\'t access output tensor data. error code = ${f}`);let t=r/4;const o=p.HEAPU32[t++];i=p.HEAPU32[t++];const u=p.HEAPU32[t++],c=p.HEAPU32[t++],h=[];for(let t=0;t<c;t++)h.push(p.HEAPU32[u/4+t]);p._OrtFree(u);const d=0===h.length?1:h.reduce(((t,e)=>t*e));if(a=s(o),"string"===a){const t=[];let e=i/4;for(let n=0;n<d;n++){const r=p.HEAPU32[e++],a=n===d-1?void 0:p.HEAPU32[e]-r;t.push(p.UTF8ToString(r,a))}w.push([a,h,t])}else{const t=new(l(a))(d);new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(p.HEAPU8.subarray(i,i+t.byteLength)),w.push([a,h,t])}}finally{p.stackRestore(n),"string"===a&&i&&p._free(i),p._OrtReleaseTensor(e)}}if(0===f)return w;throw new Error(`failed to call OrtRun(). error code = ${f}.`)}finally{p.stackRestore(t)}}finally{_.forEach(p._OrtReleaseTensor),O.forEach(p._free),p._OrtReleaseRunOptions(v),w.forEach(p._free)}},e.endProfiling=t=>{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(n,o,s,l){var f=self||window;try{try{var u;try{u=new f.Blob([n])}catch{(u=new(f.BlobBuilder||f.WebKitBlobBuilder||f.MozBlobBuilder||f.MSBlobBuilder)).append(n),u=u.getBlob()}var p=f.URL||f.webkitURL,g=p.createObjectURL(u),c=new f[o](g,s);return p.revokeObjectURL(g),c}catch{return new f[o]("data:application/javascript,".concat(encodeURIComponent(n)),s)}}catch{if(!l)throw Error("Inline worker is not supported");return new f[o](l,s)}}},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,n,o)=>{o.r(n),o.d(n,{flatbuffers:()=>s});var s={};s.Offset,s.Table,s.SIZEOF_SHORT=2,s.SIZEOF_INT=4,s.FILE_IDENTIFIER_LENGTH=4,s.SIZE_PREFIX_LENGTH=4,s.Encoding={UTF8_BYTES:1,UTF16_STRING:2},s.int32=new Int32Array(2),s.float32=new Float32Array(s.int32.buffer),s.float64=new Float64Array(s.int32.buffer),s.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,s.Long=function(l,f){this.low=0|l,this.high=0|f},s.Long.create=function(l,f){return l==0&&f==0?s.Long.ZERO:new s.Long(l,f)},s.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},s.Long.prototype.equals=function(l){return this.low==l.low&&this.high==l.high},s.Long.ZERO=new s.Long(0,0),s.Builder=function(l){if(l)f=l;else var f=1024;this.bb=s.ByteBuffer.allocate(f),this.space=f,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},s.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},s.Builder.prototype.forceDefaults=function(l){this.force_defaults=l},s.Builder.prototype.dataBuffer=function(){return this.bb},s.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},s.Builder.prototype.prep=function(l,f){l>this.minalign&&(this.minalign=l);for(var u=1+~(this.bb.capacity()-this.space+f)&l-1;this.space<u+l+f;){var p=this.bb.capacity();this.bb=s.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-p}this.pad(u)},s.Builder.prototype.pad=function(l){for(var f=0;f<l;f++)this.bb.writeInt8(--this.space,0)},s.Builder.prototype.writeInt8=function(l){this.bb.writeInt8(this.space-=1,l)},s.Builder.prototype.writeInt16=function(l){this.bb.writeInt16(this.space-=2,l)},s.Builder.prototype.writeInt32=function(l){this.bb.writeInt32(this.space-=4,l)},s.Builder.prototype.writeInt64=function(l){this.bb.writeInt64(this.space-=8,l)},s.Builder.prototype.writeFloat32=function(l){this.bb.writeFloat32(this.space-=4,l)},s.Builder.prototype.writeFloat64=function(l){this.bb.writeFloat64(this.space-=8,l)},s.Builder.prototype.addInt8=function(l){this.prep(1,0),this.writeInt8(l)},s.Builder.prototype.addInt16=function(l){this.prep(2,0),this.writeInt16(l)},s.Builder.prototype.addInt32=function(l){this.prep(4,0),this.writeInt32(l)},s.Builder.prototype.addInt64=function(l){this.prep(8,0),this.writeInt64(l)},s.Builder.prototype.addFloat32=function(l){this.prep(4,0),this.writeFloat32(l)},s.Builder.prototype.addFloat64=function(l){this.prep(8,0),this.writeFloat64(l)},s.Builder.prototype.addFieldInt8=function(l,f,u){(this.force_defaults||f!=u)&&(this.addInt8(f),this.slot(l))},s.Builder.prototype.addFieldInt16=function(l,f,u){(this.force_defaults||f!=u)&&(this.addInt16(f),this.slot(l))},s.Builder.prototype.addFieldInt32=function(l,f,u){(this.force_defaults||f!=u)&&(this.addInt32(f),this.slot(l))},s.Builder.prototype.addFieldInt64=function(l,f,u){!this.force_defaults&&f.equals(u)||(this.addInt64(f),this.slot(l))},s.Builder.prototype.addFieldFloat32=function(l,f,u){(this.force_defaults||f!=u)&&(this.addFloat32(f),this.slot(l))},s.Builder.prototype.addFieldFloat64=function(l,f,u){(this.force_defaults||f!=u)&&(this.addFloat64(f),this.slot(l))},s.Builder.prototype.addFieldOffset=function(l,f,u){(this.force_defaults||f!=u)&&(this.addOffset(f),this.slot(l))},s.Builder.prototype.addFieldStruct=function(l,f,u){f!=u&&(this.nested(f),this.slot(l))},s.Builder.prototype.nested=function(l){if(l!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},s.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},s.Builder.prototype.slot=function(l){this.vtable[l]=this.offset()},s.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},s.Builder.growByteBuffer=function(l){var f=l.capacity();if(3221225472&f)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var u=f<<1,p=s.ByteBuffer.allocate(u);return p.setPosition(u-f),p.bytes().set(l.bytes(),u-f),p},s.Builder.prototype.addOffset=function(l){this.prep(s.SIZEOF_INT,0),this.writeInt32(this.offset()-l+s.SIZEOF_INT)},s.Builder.prototype.startObject=function(l){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=l;for(var f=0;f<l;f++)this.vtable[f]=0;this.isNested=!0,this.object_start=this.offset()},s.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var l=this.offset(),f=this.vtable_in_use-1;f>=0&&this.vtable[f]==0;f--);for(var u=f+1;f>=0;f--)this.addInt16(this.vtable[f]!=0?l-this.vtable[f]:0);this.addInt16(l-this.object_start);var p=(u+2)*s.SIZEOF_SHORT;this.addInt16(p);var g=0,c=this.space;e:for(f=0;f<this.vtables.length;f++){var a=this.bb.capacity()-this.vtables[f];if(p==this.bb.readInt16(a)){for(var t=s.SIZEOF_SHORT;t<p;t+=s.SIZEOF_SHORT)if(this.bb.readInt16(c+t)!=this.bb.readInt16(a+t))continue e;g=this.vtables[f];break}}return g?(this.space=this.bb.capacity()-l,this.bb.writeInt32(this.space,g-l)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-l,this.offset()-l)),this.isNested=!1,l},s.Builder.prototype.finish=function(l,f,u){var p=u?s.SIZE_PREFIX_LENGTH:0;if(f){var g=f;if(this.prep(this.minalign,s.SIZEOF_INT+s.FILE_IDENTIFIER_LENGTH+p),g.length!=s.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+s.FILE_IDENTIFIER_LENGTH);for(var c=s.FILE_IDENTIFIER_LENGTH-1;c>=0;c--)this.writeInt8(g.charCodeAt(c))}this.prep(this.minalign,s.SIZEOF_INT+p),this.addOffset(l),p&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},s.Builder.prototype.finishSizePrefixed=function(l,f){this.finish(l,f,!0)},s.Builder.prototype.requiredField=function(l,f){var u=this.bb.capacity()-l,p=u-this.bb.readInt32(u);if(this.bb.readInt16(p+f)==0)throw new Error("FlatBuffers: field "+f+" must be set")},s.Builder.prototype.startVector=function(l,f,u){this.notNested(),this.vector_num_elems=f,this.prep(s.SIZEOF_INT,l*f),this.prep(u,l*f)},s.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},s.Builder.prototype.createString=function(l){if(l instanceof Uint8Array)var f=l;else{f=[];for(var u=0;u<l.length;){var p,g=l.charCodeAt(u++);(p=g<55296||g>=56320?g:(g<<10)+l.charCodeAt(u++)+-56613888)<128?f.push(p):(p<2048?f.push(p>>6&31|192):(p<65536?f.push(p>>12&15|224):f.push(p>>18&7|240,p>>12&63|128),f.push(p>>6&63|128)),f.push(63&p|128))}}this.addInt8(0),this.startVector(1,f.length,1),this.bb.setPosition(this.space-=f.length),u=0;for(var c=this.space,a=this.bb.bytes();u<f.length;u++)a[c++]=f[u];return this.endVector()},s.Builder.prototype.createLong=function(l,f){return s.Long.create(l,f)},s.ByteBuffer=function(l){this.bytes_=l,this.position_=0},s.ByteBuffer.allocate=function(l){return new s.ByteBuffer(new Uint8Array(l))},s.ByteBuffer.prototype.clear=function(){this.position_=0},s.ByteBuffer.prototype.bytes=function(){return this.bytes_},s.ByteBuffer.prototype.position=function(){return this.position_},s.ByteBuffer.prototype.setPosition=function(l){this.position_=l},s.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},s.ByteBuffer.prototype.readInt8=function(l){return this.readUint8(l)<<24>>24},s.ByteBuffer.prototype.readUint8=function(l){return this.bytes_[l]},s.ByteBuffer.prototype.readInt16=function(l){return this.readUint16(l)<<16>>16},s.ByteBuffer.prototype.readUint16=function(l){return this.bytes_[l]|this.bytes_[l+1]<<8},s.ByteBuffer.prototype.readInt32=function(l){return this.bytes_[l]|this.bytes_[l+1]<<8|this.bytes_[l+2]<<16|this.bytes_[l+3]<<24},s.ByteBuffer.prototype.readUint32=function(l){return this.readInt32(l)>>>0},s.ByteBuffer.prototype.readInt64=function(l){return new s.Long(this.readInt32(l),this.readInt32(l+4))},s.ByteBuffer.prototype.readUint64=function(l){return new s.Long(this.readUint32(l),this.readUint32(l+4))},s.ByteBuffer.prototype.readFloat32=function(l){return s.int32[0]=this.readInt32(l),s.float32[0]},s.ByteBuffer.prototype.readFloat64=function(l){return s.int32[s.isLittleEndian?0:1]=this.readInt32(l),s.int32[s.isLittleEndian?1:0]=this.readInt32(l+4),s.float64[0]},s.ByteBuffer.prototype.writeInt8=function(l,f){this.bytes_[l]=f},s.ByteBuffer.prototype.writeUint8=function(l,f){this.bytes_[l]=f},s.ByteBuffer.prototype.writeInt16=function(l,f){this.bytes_[l]=f,this.bytes_[l+1]=f>>8},s.ByteBuffer.prototype.writeUint16=function(l,f){this.bytes_[l]=f,this.bytes_[l+1]=f>>8},s.ByteBuffer.prototype.writeInt32=function(l,f){this.bytes_[l]=f,this.bytes_[l+1]=f>>8,this.bytes_[l+2]=f>>16,this.bytes_[l+3]=f>>24},s.ByteBuffer.prototype.writeUint32=function(l,f){this.bytes_[l]=f,this.bytes_[l+1]=f>>8,this.bytes_[l+2]=f>>16,this.bytes_[l+3]=f>>24},s.ByteBuffer.prototype.writeInt64=function(l,f){this.writeInt32(l,f.low),this.writeInt32(l+4,f.high)},s.ByteBuffer.prototype.writeUint64=function(l,f){this.writeUint32(l,f.low),this.writeUint32(l+4,f.high)},s.ByteBuffer.prototype.writeFloat32=function(l,f){s.float32[0]=f,this.writeInt32(l,s.int32[0])},s.ByteBuffer.prototype.writeFloat64=function(l,f){s.float64[0]=f,this.writeInt32(l,s.int32[s.isLittleEndian?0:1]),this.writeInt32(l+4,s.int32[s.isLittleEndian?1:0])},s.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+s.SIZEOF_INT+s.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var l="",f=0;f<s.FILE_IDENTIFIER_LENGTH;f++)l+=String.fromCharCode(this.readInt8(this.position_+s.SIZEOF_INT+f));return l},s.ByteBuffer.prototype.__offset=function(l,f){var u=l-this.readInt32(l);return f<this.readInt16(u)?this.readInt16(u+f):0},s.ByteBuffer.prototype.__union=function(l,f){return l.bb_pos=f+this.readInt32(f),l.bb=this,l},s.ByteBuffer.prototype.__string=function(l,f){l+=this.readInt32(l);var u=this.readInt32(l),p="",g=0;if(l+=s.SIZEOF_INT,f===s.Encoding.UTF8_BYTES)return this.bytes_.subarray(l,l+u);for(;g<u;){var c,a=this.readUint8(l+g++);if(a<192)c=a;else{var t=this.readUint8(l+g++);if(a<224)c=(31&a)<<6|63&t;else{var e=this.readUint8(l+g++);c=a<240?(15&a)<<12|(63&t)<<6|63&e:(7&a)<<18|(63&t)<<12|(63&e)<<6|63&this.readUint8(l+g++)}}c<65536?p+=String.fromCharCode(c):(c-=65536,p+=String.fromCharCode(55296+(c>>10),56320+(1023&c)))}return p},s.ByteBuffer.prototype.__indirect=function(l){return l+this.readInt32(l)},s.ByteBuffer.prototype.__vector=function(l){return l+this.readInt32(l)+s.SIZEOF_INT},s.ByteBuffer.prototype.__vector_len=function(l){return this.readInt32(l+this.readInt32(l))},s.ByteBuffer.prototype.__has_identifier=function(l){if(l.length!=s.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+s.FILE_IDENTIFIER_LENGTH);for(var f=0;f<s.FILE_IDENTIFIER_LENGTH;f++)if(l.charCodeAt(f)!=this.readInt8(this.position_+s.SIZEOF_INT+f))return!1;return!0},s.ByteBuffer.prototype.createLong=function(l,f){return s.Long.create(l,f)}}},__webpack_module_cache__={};function __webpack_require__(d){var n=__webpack_module_cache__[d];if(n!==void 0)return n.exports;var o=__webpack_module_cache__[d]={exports:{}};return __webpack_modules__[d].call(o.exports,o,o.exports,__webpack_require__),o.exports}__webpack_require__.n=d=>{var n=d&&d.__esModule?()=>d.default:()=>d;return __webpack_require__.d(n,{a:n}),n},__webpack_require__.d=(d,n)=>{for(var o in n)__webpack_require__.o(n,o)&&!__webpack_require__.o(d,o)&&Object.defineProperty(d,o,{enumerable:!0,get:n[o]})},__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,n)=>Object.prototype.hasOwnProperty.call(d,n),__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$1);var ortWeb_minExports=ortWeb_min$1.exports,ortWeb_min=getDefaultExportFromCjs(ortWeb_minExports),ONNX_WEB=_mergeNamespaces({__proto__:null,default:ortWeb_min},[ortWeb_minExports]);let ONNX;const executionProviders=["wasm"];typeof process<"u"&&((nt=process==null?void 0:process.release)==null?void 0:nt.name)==="node"?(ONNX=sharp??ONNX_NODE,executionProviders.unshift("cpu")):(ONNX=ortWeb_min??ONNX_WEB,typeof navigator<"u"&&/iP(hone|od|ad).+16_4.+AppleWebKit/.test(navigator.userAgent)&&(ONNX.env.wasm.simd=!1));const{env:onnx_env}=ONNX,VERSION="2.17.1",WEB_CACHE_AVAILABLE=typeof self<"u"&&"caches"in self,FS_AVAILABLE=!isEmpty(sharp),PATH_AVAILABLE=!isEmpty(sharp),RUNNING_LOCALLY=FS_AVAILABLE&&PATH_AVAILABLE,__dirname=RUNNING_LOCALLY?sharp.dirname(sharp.dirname(sharp.fileURLToPath(self.location.href))):"./",DEFAULT_CACHE_DIR=RUNNING_LOCALLY?sharp.join(__dirname,"/.cache/"):null,DEFAULT_LOCAL_MODEL_PATH="/models/",localModelPath=RUNNING_LOCALLY?sharp.join(__dirname,DEFAULT_LOCAL_MODEL_PATH):DEFAULT_LOCAL_MODEL_PATH;onnx_env!=null&&onnx_env.wasm&&(onnx_env.wasm.wasmPaths=RUNNING_LOCALLY?sharp.join(__dirname,"/dist/"):`https://cdn.jsdelivr.net/npm/@xenova/transformers@${VERSION}/dist/`);const env$1={backends:{onnx:onnx_env,tfjs:{}},__dirname,version:VERSION,allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!0,localModelPath,useFS:FS_AVAILABLE,useBrowserCache:WEB_CACHE_AVAILABLE,useFSCache:FS_AVAILABLE,cacheDir:DEFAULT_CACHE_DIR,useCustomCache:!1,customCache:null};function isEmpty(d){return Object.keys(d).length===0}globalThis.ReadableStream||(globalThis.ReadableStream=sharp.ReadableStream);class FileResponse{constructor(n){J(this,"_CONTENT_TYPE_MAP",{txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif"});if(this.filePath=n,this.headers=new Headers,this.exists=sharp.existsSync(n),this.exists){this.status=200,this.statusText="OK";let o=sharp.statSync(n);this.headers.set("content-length",o.size.toString()),this.updateContentType();let s=this;this.body=new ReadableStream({start(l){s.arrayBuffer().then(f=>{l.enqueue(new Uint8Array(f)),l.close()})}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){const n=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",this._CONTENT_TYPE_MAP[n]??"application/octet-stream")}clone(){let n=new FileResponse(this.filePath);return n.exists=this.exists,n.status=this.status,n.statusText=this.statusText,n.headers=new Headers(this.headers),n}async arrayBuffer(){return(await sharp.promises.readFile(this.filePath)).buffer}async blob(){const n=await sharp.promises.readFile(this.filePath);return new Blob([n],{type:this.headers.get("content-type")})}async text(){return await sharp.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}}function isValidHttpUrl(d,n=null){let o;try{o=new URL(d)}catch{return!1}return n&&!n.includes(o.hostname)?!1:o.protocol==="http:"||o.protocol==="https:"}async function getFile(d){var n,o,s,l;if(env$1.useFS&&!isValidHttpUrl(d))return new FileResponse(d);if(typeof process<"u"&&((n=process==null?void 0:process.release)==null?void 0:n.name)==="node"){const f=!!((o=process.env)!=null&&o.TESTING_REMOTELY),u=env$1.version,p=new Headers;if(p.set("User-Agent",`transformers.js/${u}; is_ci/${f};`),isValidHttpUrl(d,["huggingface.co","hf.co"])){const c=((s=process.env)==null?void 0:s.HF_TOKEN)??((l=process.env)==null?void 0:l.HF_ACCESS_TOKEN);c&&p.set("Authorization",`Bearer ${c}`)}return fetch(d,{headers:p})}else return fetch(d)}const ERROR_MAPPING={400:"Bad request error occurred while trying to load file",401:"Unauthorized access to file",403:"Forbidden access to file",404:"Could not locate file",408:"Request timeout error occurred while trying to load file",500:"Internal server error error occurred while trying to load file",502:"Bad gateway error occurred while trying to load file",503:"Service unavailable error occurred while trying to load file",504:"Gateway timeout error occurred while trying to load file"};function handleError(d,n,o){if(!o)return null;const s=ERROR_MAPPING[d]??`Error (${d}) occurred while trying to load file`;throw Error(`${s}: "${n}".`)}class FileCache{constructor(n){this.path=n}async match(n){let o=sharp.join(this.path,n),s=new FileResponse(o);if(s.exists)return s}async put(n,o){const s=Buffer.from(await o.arrayBuffer());let l=sharp.join(this.path,n);try{await sharp.promises.mkdir(sharp.dirname(l),{recursive:!0}),await sharp.promises.writeFile(l,s)}catch(f){console.warn("An error occurred while writing the file to cache:",f)}}}async function tryCache(d,...n){for(let o of n)try{let s=await d.match(o);if(s)return s}catch{continue}}async function getModelFile(d,n,o=!0,s={}){if(!env$1.allowLocalModels&&s.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");dispatchCallback(s.progress_callback,{status:"initiate",name:d,file:n});let l;if(!l&&env$1.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{l=await caches.open("transformers-cache")}catch(_){console.warn("An error occurred while opening the browser cache:",_)}}if(!l&&env$1.useFSCache&&(l=new FileCache(s.cache_dir??env$1.cacheDir)),!l&&env$1.useCustomCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");const f=s.revision??"main";let u=pathJoin(d,n),p=pathJoin(env$1.localModelPath,u),g=pathJoin(env$1.remoteHost,env$1.remotePathTemplate.replaceAll("{model}",d).replaceAll("{revision}",encodeURIComponent(f)),n),c=f==="main"?u:pathJoin(d,f,n),a,t=l instanceof FileCache?c:g,e=!1,r;l&&(r=await tryCache(l,p,t));const i=r!==void 0;if(r===void 0){if(env$1.allowLocalModels)if(isValidHttpUrl(u)){if(s.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${u}.`)}else try{r=await getFile(p),a=p}catch(b){console.warn(`Unable to load from local path "${p}": "${b}"`)}if(r===void 0||r.status===404){if(s.local_files_only||!env$1.allowRemoteModels){if(o)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${p}".`);return null}if(r=await getFile(g),r.status!==200)return handleError(r.status,g,o);a=t}e=l&&typeof Response<"u"&&r instanceof Response&&r.status===200}dispatchCallback(s.progress_callback,{status:"download",name:d,file:n});const h={status:"progress",name:d,file:n};let m;return s.progress_callback?i&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent)?(m=new Uint8Array(await r.arrayBuffer()),dispatchCallback(s.progress_callback,{...h,progress:100,loaded:m.length,total:m.length})):m=await readResponse(r,_=>{dispatchCallback(s.progress_callback,{...h,..._})}):m=new Uint8Array(await r.arrayBuffer()),e&&a&&await l.match(a)===void 0&&await l.put(a,new Response(m,{headers:r.headers})).catch(_=>{console.warn(`Unable to add response to browser cache: ${_}.`)}),dispatchCallback(s.progress_callback,{status:"done",name:d,file:n}),m}async function getModelJSON(d,n,o=!0,s={}){let l=await getModelFile(d,n,o,s);if(l===null)return{};let u=new TextDecoder("utf-8").decode(l);return JSON.parse(u)}async function readResponse(d,n){const o=d.headers.get("Content-Length");o===null&&console.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let s=parseInt(o??"0"),l=new Uint8Array(s),f=0;const u=d.body.getReader();async function p(){const{done:g,value:c}=await u.read();if(g)return;let a=f+c.length;if(a>s){s=a;let e=new Uint8Array(s);e.set(l),l=e}l.set(c,f),f=a;const t=f/s*100;return n({progress:t,loaded:f,total:s}),p()}return await p(),l}function pathJoin(...d){return d=d.map((n,o)=>(o&&(n=n.replace(new RegExp("^/"),"")),o!==d.length-1&&(n=n.replace(new RegExp("/$"),"")),n)),d.join("/")}function permute_data(d,n,o){const s=new Array(o.length),l=new Array(o.length);for(let p=o.length-1,g=1;p>=0;--p)l[p]=g,s[p]=n[o[p]],g*=s[p];const f=o.map((p,g)=>l[o.indexOf(g)]),u=new d.constructor(d.length);for(let p=0;p<d.length;++p){let g=0;for(let c=n.length-1,a=p;c>=0;--c)g+=a%n[c]*f[c],a=Math.floor(a/n[c]);u[g]=d[p]}return[u,s]}function softmax(d){const n=max(d)[0],o=d.map(f=>Math.exp(f-n)),s=o.reduce((f,u)=>f+u,0);return o.map(f=>f/s)}function log_softmax(d){return softmax(d).map(s=>Math.log(s))}function getTopItems(d,n=0){return d=Array.from(d).map((o,s)=>[s,o]).sort((o,s)=>s[1]-o[1]),n!==null&&n>0&&(d=d.slice(0,n)),d}function min(d){if(d.length===0)throw Error("Array must not be empty");let n=d[0],o=0;for(let s=1;s<d.length;++s)d[s]<n&&(n=d[s],o=s);return[n,o]}function max(d){if(d.length===0)throw Error("Array must not be empty");let n=d[0],o=0;for(let s=1;s<d.length;++s)d[s]>n&&(n=d[s],o=s);return[Number(n),o]}function medianFilter(d,n){if(n%2===0||n<=0)throw new Error("Window size must be a positive odd number");const o=new d.constructor(d.length),s=new d.constructor(n),l=Math.floor(n/2);for(let f=0;f<d.length;++f){let u=0;for(let p=-l;p<=l;++p){let g=f+p;g<0?g=Math.abs(g):g>=d.length&&(g=2*(d.length-1)-g),s[u++]=d[g]}s.sort(),o[f]=s[l]}return o}function round(d,n){const o=Math.pow(10,n);return Math.round(d*o)/o}const DataTypeMap=Object.freeze({float32:Float32Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array}),ONNXTensor$1=ONNX.Tensor;class Tensor{constructor(...n){J(this,"dims");J(this,"type");J(this,"data");J(this,"size");return n[0]instanceof ONNXTensor$1?Object.assign(this,n[0]):Object.assign(this,new ONNXTensor$1(n[0],n[1],n[2])),new Proxy(this,{get:(o,s)=>{if(typeof s=="string"){let l=Number(s);if(Number.isInteger(l))return o._getitem(l)}return o[s]},set:(o,s,l)=>o[s]=l})}*[Symbol.iterator](){const[n,...o]=this.dims;if(o.length>0){const s=o.reduce((l,f)=>l*f);for(let l=0;l<n;++l)yield this._subarray(l,s,o)}else yield*this.data}_getitem(n){const[o,...s]=this.dims;if(n=safeIndex(n,o),s.length>0){const l=s.reduce((f,u)=>f*u);return this._subarray(n,l,s)}else return new Tensor(this.type,[this.data[n]],s)}indexOf(n){for(let o=0;o<this.data.length;++o)if(this.data[o]==n)return o;return-1}_subarray(n,o,s){const l=n*o,f=(n+1)*o,u="subarray"in this.data?this.data.subarray(l,f):this.data.slice(l,f);return new Tensor(this.type,u,s)}item(){if(this.data.length!==1)throw new Error(`a Tensor with ${this.data.length} elements cannot be converted to Scalar`);return this.data[0]}tolist(){return reshape(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){for(let n=0;n<this.data.length;++n)this.data[n]=1/(1+Math.exp(-this.data[n]));return this}mul(n){return this.clone().mul_(n)}mul_(n){for(let o=0;o<this.data.length;++o)this.data[o]*=n;return this}add(n){return this.clone().add_(n)}add_(n){for(let o=0;o<this.data.length;++o)this.data[o]+=n;return this}clone(){return new Tensor(this.type,this.data.slice(),this.dims.slice())}slice(...n){let o=[],s=[];for(let g=0;g<this.dims.length;++g){let c=n[g];if(c==null)s.push([0,this.dims[g]]),o.push(this.dims[g]);else if(typeof c=="number")c=safeIndex(c,this.dims[g],g),s.push([c,c+1]);else if(Array.isArray(c)&&c.length===2){if(c[0]>c[1])throw new Error(`Invalid slice: ${c}`);let a=[Math.max(c[0],0),Math.min(c[1],this.dims[g])];s.push(a),o.push(a[1]-a[0])}else throw new Error(`Invalid slice: ${c}`)}let l=s.map(([g,c])=>c-g),f=l.reduce((g,c)=>g*c),u=new this.data.constructor(f);const p=this.stride();for(let g=0;g<f;++g){let c=0;for(let a=l.length-1,t=g;a>=0;--a){const e=l[a];c+=(t%e+s[a][0])*p[a],t=Math.floor(t/e)}u[g]=this.data[c]}return new Tensor(this.type,u,o)}permute(...n){return permute(this,n)}transpose(...n){return this.permute(...n)}sum(n=null,o=!1){return this.norm(1,n,o)}norm(n="fro",o=null,s=!1){if(n==="fro")n=2;else if(typeof n=="string")throw Error(`Unsupported norm: ${n}`);if(o===null){let u=this.data.reduce((p,g)=>p+g**n,0)**(1/n);return new Tensor(this.type,[u],[])}o=safeIndex(o,this.dims.length);const l=this.dims.slice();l[o]=1;const f=new this.data.constructor(this.data.length/this.dims[o]);for(let u=0;u<this.data.length;++u){let p=0;for(let g=this.dims.length-1,c=u,a=1;g>=0;--g){const t=this.dims[g];if(g!==o){const e=c%t;p+=e*a,a*=l[g]}c=Math.floor(c/t)}f[p]+=this.data[u]**n}if(n!==1)for(let u=0;u<f.length;++u)f[u]=f[u]**(1/n);return s||l.splice(o,1),new Tensor(this.type,f,l)}normalize_(n=2,o=1){o=safeIndex(o,this.dims.length);const s=this.norm(n,o,!0);for(let l=0;l<this.data.length;++l){let f=0;for(let u=this.dims.length-1,p=l,g=1;u>=0;--u){const c=this.dims[u];if(u!==o){const a=p%c;f+=a*g,g*=this.dims[u]}p=Math.floor(p/c)}this.data[l]/=s.data[f]}return this}normalize(n=2,o=1){return this.clone().normalize_(n,o)}stride(){return dimsToStride(this.dims)}squeeze(n=null){return new Tensor(this.type,this.data,calc_squeeze_dims(this.dims,n))}squeeze_(n=null){return this.dims=calc_squeeze_dims(this.dims,n),this}unsqueeze(n=null){return new Tensor(this.type,this.data,calc_unsqueeze_dims(this.dims,n))}unsqueeze_(n=null){return this.dims=calc_unsqueeze_dims(this.dims,n),this}flatten_(n=0,o=-1){o=(o+this.dims.length)%this.dims.length;let s=this.dims.slice(0,n),l=this.dims.slice(n,o+1),f=this.dims.slice(o+1);return this.dims=[...s,l.reduce((u,p)=>u*p,1),...f],this}flatten(n=0,o=-1){return this.clone().flatten_(n,o)}view(...n){let o=-1;for(let s=0;s<n.length;++s)if(n[s]===-1){if(o!==-1)throw new Error("Only one dimension can be inferred");o=s}if(o!==-1){const s=n.reduce((l,f,u)=>u!==o?l*f:l,1);n[o]=this.data.length/s}return new Tensor(this.type,this.data,n)}neg_(){for(let n=0;n<this.data.length;++n)this.data[n]=-this.data[n];return this}neg(){return this.clone().neg_()}clamp_(n,o){for(let s=0;s<this.data.length;++s)this.data[s]=Math.min(Math.max(this.data[s],n),o);return this}clamp(n,o){return this.clone().clamp_(n,o)}round_(){for(let n=0;n<this.data.length;++n)this.data[n]=Math.round(this.data[n]);return this}round(){return this.clone().round_()}to(n){if(this.type===n)return this;if(!DataTypeMap.hasOwnProperty(n))throw new Error(`Unsupported type: ${n}`);return new Tensor(n,DataTypeMap[n].from(this.data),this.dims)}}function reshape(d,n){const o=d.length,s=n.reduce((f,u)=>f*u);if(o!==s)throw Error(`cannot reshape array of size ${o} into shape (${n})`);let l=d;for(let f=n.length-1;f>=0;f--)l=l.reduce((u,p)=>{let g=u[u.length-1];return g.length<n[f]?g.push(p):u.push([p]),u},[[]]);return l[0]}function permute(d,n){const[o,s]=permute_data(d.data,d.dims,n);return new Tensor(d.type,o,s)}function calc_squeeze_dims(d,n){return d=d.slice(),n===null?d=d.filter(o=>o!==1):typeof n=="number"?d[n]===1&&d.splice(n,1):Array.isArray(n)&&(d=d.filter((o,s)=>o!==1||!n.includes(s))),d}function calc_unsqueeze_dims(d,n){return n=safeIndex(n,d.length+1),d=d.slice(),d.splice(n,0,1),d}function safeIndex(d,n,o=null){if(d<-n||d>=n)throw new Error(`IndexError: index ${d} is out of bounds for dimension${o===null?"":" "+o} with size ${n}`);return d<0&&(d=(d%n+n)%n),d}function cat(d,n=0){n=safeIndex(n,d[0].dims.length);const o=d[0].dims.slice();o[n]=d.reduce((u,p)=>u+p.dims[n],0);const s=o.reduce((u,p)=>u*p,1),l=new d[0].data.constructor(s),f=d[0].type;if(n===0){let u=0;for(let p of d)l.set(p.data,u),u+=p.data.length}else{let u=0;for(let p=0;p<d.length;++p){let g=d[p];for(let c=0;c<g.data.length;++c){let a=0;for(let t=g.dims.length-1,e=c,r=1;t>=0;--t){const i=g.dims[t];let h=e%i;t===n&&(h+=u),a+=h*r,r*=o[t],e=Math.floor(e/i)}l[a]=g.data[c]}u+=g.dims[n]}}return new Tensor(f,l,o)}function stack(d,n=0){return cat(d.map(o=>o.unsqueeze(n)),n)}function std_mean(d,n=null,o=1,s=!1){if(n===null){const c=d.data.reduce((r,i)=>r+i,0)/d.data.length,a=Math.sqrt(d.data.reduce((r,i)=>r+(i-c)**2,0)/(d.data.length-o)),t=new Tensor(d.type,[c],[]);return[new Tensor(d.type,[a],[]),t]}n=safeIndex(n,d.dims.length);const l=mean(d,n,s),f=d.dims.slice();f[n]=1;const u=new d.data.constructor(d.data.length/d.dims[n]);for(let g=0;g<d.data.length;++g){let c=0;for(let a=d.dims.length-1,t=g,e=1;a>=0;--a){const r=d.dims[a];if(a!==n){const i=t%r;c+=i*e,e*=f[a]}t=Math.floor(t/r)}u[c]+=(d.data[g]-l.data[c])**2}for(let g=0;g<u.length;++g)u[g]=Math.sqrt(u[g]/(d.dims[n]-o));return s||f.splice(n,1),[new Tensor(d.type,u,f),l]}function mean(d,n=null,o=!1){if(n===null){let f=d.data.reduce((u,p)=>u+p,0);return new Tensor(d.type,[f/d.data.length],[])}n=safeIndex(n,d.dims.length);const s=d.dims.slice();s[n]=1;const l=new d.data.constructor(d.data.length/d.dims[n]);for(let f=0;f<d.data.length;++f){let u=0;for(let p=d.dims.length-1,g=f,c=1;p>=0;--p){const a=d.dims[p];if(p!==n){const t=g%a;u+=t*c,c*=s[p]}g=Math.floor(g/a)}l[u]+=d.data[f]}if(d.dims[n]!==1)for(let f=0;f<l.length;++f)l[f]=l[f]/d.dims[n];return o||s.splice(n,1),new Tensor(d.type,l,s)}function dynamicTimeWarping(d){const[n,o]=d.dims,s=[n+1,o+1],l=new Tensor("float32",new Float32Array(s[0]*s[1]).fill(1/0),s),f=new Tensor("float32",new Float32Array(s[0]*s[1]).fill(-1),s);l[0].data[0]=0;for(let a=1;a<o+1;++a)for(let t=1;t<n+1;++t){const e=l[t-1][a-1].item(),r=l[t-1][a].item(),i=l[t][a-1].item();let h,m;e<r&&e<i?(h=e,m=0):r<e&&r<i?(h=r,m=1):(h=i,m=2),l[t].data[a]=d[t-1][a-1].item()+h,f[t].data[a]=m}let u=n,p=o;f.data.fill(2,0,s[1]);for(let a=0;a<s[0];++a)f[a].data[0]=1;let g=[],c=[];for(;u>0||p>0;)switch(g.push(u-1),c.push(p-1),f[u][p].item()){case 0:--u,--p;break;case 1:--u;break;case 2:--p;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${u}, ${p}]. Please file a bug report.`)}return g.reverse(),c.reverse(),[g,c]}function dimsToStride(d){const n=new Array(d.length);for(let o=d.length-1,s=1;o>=0;--o)n[o]=s,s*=d[o];return n}function ones(d){const n=d.reduce((o,s)=>o*s,1);return new Tensor("int64",new BigInt64Array(n).fill(1n),d)}function ones_like(d){return ones(d.dims)}class PriorityQueue{constructor(n=(o,s)=>o>s){this._heap=[],this._comparator=n}get size(){return this._heap.length}isEmpty(){return this.size===0}peek(){return this._heap[0]}push(...n){return this.extend(n)}extend(n){for(const o of n)this._heap.push(o),this._siftUp();return this.size}pop(){const n=this.peek(),o=this.size-1;return o>0&&this._swap(0,o),this._heap.pop(),this._siftDown(),n}replace(n){const o=this.peek();return this._heap[0]=n,this._siftDown(),o}_parent(n){return(n+1>>>1)-1}_left(n){return(n<<1)+1}_right(n){return n+1<<1}_greater(n,o){return this._comparator(this._heap[n],this._heap[o])}_swap(n,o){const s=this._heap[n];this._heap[n]=this._heap[o],this._heap[o]=s}_siftUp(){let n=this.size-1;for(;n>0&&this._greater(n,this._parent(n));)this._swap(n,this._parent(n)),n=this._parent(n)}_siftDown(){let n=0;for(;this._left(n)<this.size&&this._greater(this._left(n),n)||this._right(n)<this.size&&this._greater(this._right(n),n);){const o=this._right(n)<this.size&&this._greater(this._right(n),this._left(n))?this._right(n):this._left(n);this._swap(n,o),n=o}}}class CharTrie{constructor(){this.root=CharTrieNode.default()}extend(n){for(let o of n)this.push(o)}push(n){let o=this.root;for(let s of n){let l=o.children.get(s);l===void 0&&(l=CharTrieNode.default(),o.children.set(s,l)),o=l}o.isLeaf=!0}*commonPrefixSearch(n){let o=this.root,s="";for(let l=0;l<n.length&&o!==void 0;++l){const f=n[l];s+=f,o=o.children.get(f),o!==void 0&&o.isLeaf&&(yield s)}}}class CharTrieNode{constructor(n,o){this.isLeaf=n,this.children=o}static default(){return new CharTrieNode(!1,new Map)}}class TokenLattice{constructor(n,o,s){this.sentence=n,this.len=n.length,this.bosTokenId=o,this.eosTokenId=s,this.nodes=[],this.beginNodes=Array.from({length:this.len+1},()=>[]),this.endNodes=Array.from({length:this.len+1},()=>[]);const l=new TokenLatticeNode(this.bosTokenId,0,0,0,0),f=new TokenLatticeNode(this.eosTokenId,1,this.len,0,0);this.nodes.push(l.clone()),this.nodes.push(f.clone()),this.beginNodes[this.len].push(f),this.endNodes[0].push(l)}insert(n,o,s,l){const f=this.nodes.length,u=new TokenLatticeNode(l,f,n,o,s);this.beginNodes[n].push(u),this.endNodes[n+o].push(u),this.nodes.push(u)}viterbi(){const n=this.len;let o=0;for(;o<=n;){if(this.beginNodes[o].length==0)return[];for(let p of this.beginNodes[o]){p.prev=null;let g=0,c=null;for(let a of this.endNodes[o]){const t=a.backtraceScore+p.score;(c===null||t>g)&&(c=a.clone(),g=t)}if(c!==null)p.prev=c,p.backtraceScore=g;else return[]}++o}const s=[],f=this.beginNodes[n][0].prev;if(f===null)return[];let u=f.clone();for(;u.prev!==null;)s.push(u.clone()),u=u.clone().prev.clone();return s.reverse(),s}piece(n){return this.sentence.slice(n.pos,n.pos+n.length)}tokens(){return this.viterbi().map(o=>this.piece(o))}tokenIds(){return this.viterbi().map(o=>o.tokenId)}}class TokenLatticeNode{constructor(n,o,s,l,f){this.tokenId=n,this.nodeId=o,this.pos=s,this.length=l,this.score=f,this.prev=null,this.backtraceScore=0}clone(){const n=new TokenLatticeNode(this.tokenId,this.nodeId,this.pos,this.length,this.score);return n.prev=this.prev,n.backtraceScore=this.backtraceScore,n}}var TOKEN_TYPES=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",BooleanLiteral:"BooleanLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Set:"Set",If:"If",For:"For",In:"In",Is:"Is",NotIn:"NotIn",Else:"Else",EndIf:"EndIf",ElseIf:"ElseIf",EndFor:"EndFor",And:"And",Or:"Or",Not:"UnaryOperator"}),KEYWORDS=Object.freeze({set:TOKEN_TYPES.Set,for:TOKEN_TYPES.For,in:TOKEN_TYPES.In,is:TOKEN_TYPES.Is,if:TOKEN_TYPES.If,else:TOKEN_TYPES.Else,endif:TOKEN_TYPES.EndIf,elif:TOKEN_TYPES.ElseIf,endfor:TOKEN_TYPES.EndFor,and:TOKEN_TYPES.And,or:TOKEN_TYPES.Or,not:TOKEN_TYPES.Not,"not in":TOKEN_TYPES.NotIn,true:TOKEN_TYPES.BooleanLiteral,false:TOKEN_TYPES.BooleanLiteral}),Token=class{constructor(d,n){this.value=d,this.type=n}};function isWord(d){return/\w/.test(d)}function isInteger(d){return/[0-9]/.test(d)}var ORDERED_MAPPING_TABLE=[["{%",TOKEN_TYPES.OpenStatement],["%}",TOKEN_TYPES.CloseStatement],["{{",TOKEN_TYPES.OpenExpression],["}}",TOKEN_TYPES.CloseExpression],["(",TOKEN_TYPES.OpenParen],[")",TOKEN_TYPES.CloseParen],["{",TOKEN_TYPES.OpenCurlyBracket],["}",TOKEN_TYPES.CloseCurlyBracket],["[",TOKEN_TYPES.OpenSquareBracket],["]",TOKEN_TYPES.CloseSquareBracket],[",",TOKEN_TYPES.Comma],[".",TOKEN_TYPES.Dot],[":",TOKEN_TYPES.Colon],["|",TOKEN_TYPES.Pipe],["<=",TOKEN_TYPES.ComparisonBinaryOperator],[">=",TOKEN_TYPES.ComparisonBinaryOperator],["==",TOKEN_TYPES.ComparisonBinaryOperator],["!=",TOKEN_TYPES.ComparisonBinaryOperator],["<",TOKEN_TYPES.ComparisonBinaryOperator],[">",TOKEN_TYPES.ComparisonBinaryOperator],["+",TOKEN_TYPES.AdditiveBinaryOperator],["-",TOKEN_TYPES.AdditiveBinaryOperator],["*",TOKEN_TYPES.MultiplicativeBinaryOperator],["/",TOKEN_TYPES.MultiplicativeBinaryOperator],["%",TOKEN_TYPES.MultiplicativeBinaryOperator],["=",TOKEN_TYPES.Equals]],ESCAPE_CHARACTERS=new Map([["n",` +`],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function preprocess(d,n={}){return d.endsWith(` +`)&&(d=d.slice(0,-1)),d=d.replace(/{#.*?#}/gs,"{##}"),n.lstrip_blocks&&(d=d.replace(/^[ \t]*({[#%])/gm,"$1")),n.trim_blocks&&(d=d.replace(/([#%]})\n/g,"$1")),d.replace(/{##}/g,"").replace(/-%}\s*/g,"%}").replace(/\s*{%-/g,"{%").replace(/-}}\s*/g,"}}").replace(/\s*{{-/g,"{{")}function tokenize(d,n={}){var u,p,g;const o=[],s=preprocess(d,n);let l=0;const f=c=>{let a="";for(;c(s[l]);){if(s[l]==="\\"){if(++l,l>=s.length)throw new SyntaxError("Unexpected end of input");const t=s[l++],e=ESCAPE_CHARACTERS.get(t);if(e===void 0)throw new SyntaxError(`Unexpected escaped character: ${t}`);a+=e;continue}if(a+=s[l++],l>=s.length)throw new SyntaxError("Unexpected end of input")}return a};e:for(;l<s.length;){const c=(u=o.at(-1))==null?void 0:u.type;if(c===void 0||c===TOKEN_TYPES.CloseStatement||c===TOKEN_TYPES.CloseExpression){let t="";for(;l<s.length&&!(s[l]==="{"&&(s[l+1]==="%"||s[l+1]==="{"));)t+=s[l++];if(t.length>0){o.push(new Token(t,TOKEN_TYPES.Text));continue}}f(t=>/\s/.test(t));const a=s[l];if(a==="-"||a==="+"){const t=(p=o.at(-1))==null?void 0:p.type;if(t===TOKEN_TYPES.Text||t===void 0)throw new SyntaxError(`Unexpected character: ${a}`);switch(t){case TOKEN_TYPES.Identifier:case TOKEN_TYPES.NumericLiteral:case TOKEN_TYPES.BooleanLiteral:case TOKEN_TYPES.StringLiteral:case TOKEN_TYPES.CloseParen:case TOKEN_TYPES.CloseSquareBracket:break;default:{++l;const e=f(isInteger);o.push(new Token(`${a}${e}`,e.length>0?TOKEN_TYPES.NumericLiteral:TOKEN_TYPES.UnaryOperator));continue}}}for(const[t,e]of ORDERED_MAPPING_TABLE)if(s.slice(l,l+t.length)===t){o.push(new Token(t,e)),l+=t.length;continue e}if(a==="'"||a==='"'){++l;const t=f(e=>e!==a);o.push(new Token(t,TOKEN_TYPES.StringLiteral)),++l;continue}if(isInteger(a)){const t=f(isInteger);o.push(new Token(t,TOKEN_TYPES.NumericLiteral));continue}if(isWord(a)){const t=f(isWord),e=Object.hasOwn(KEYWORDS,t)?KEYWORDS[t]:TOKEN_TYPES.Identifier;e===TOKEN_TYPES.In&&((g=o.at(-1))==null?void 0:g.type)===TOKEN_TYPES.Not?(o.pop(),o.push(new Token("not in",TOKEN_TYPES.NotIn))):o.push(new Token(t,e));continue}throw new SyntaxError(`Unexpected character: ${a}`)}return o}var Statement=class{constructor(){J(this,"type","Statement")}},Program=class extends Statement{constructor(n){super();J(this,"type","Program");this.body=n}},If=class extends Statement{constructor(n,o,s){super();J(this,"type","If");this.test=n,this.body=o,this.alternate=s}},For=class extends Statement{constructor(n,o,s){super();J(this,"type","For");this.loopvar=n,this.iterable=o,this.body=s}},SetStatement=class extends Statement{constructor(n,o){super();J(this,"type","Set");this.assignee=n,this.value=o}},Expression=class extends Statement{constructor(){super(...arguments);J(this,"type","Expression")}},MemberExpression=class extends Expression{constructor(n,o,s){super();J(this,"type","MemberExpression");this.object=n,this.property=o,this.computed=s}},CallExpression=class extends Expression{constructor(n,o){super();J(this,"type","CallExpression");this.callee=n,this.args=o}},Identifier=class extends Expression{constructor(n){super();J(this,"type","Identifier");this.value=n}},Literal=class extends Expression{constructor(n){super();J(this,"type","Literal");this.value=n}},NumericLiteral=class extends Literal{constructor(){super(...arguments);J(this,"type","NumericLiteral")}},StringLiteral=class extends Literal{constructor(){super(...arguments);J(this,"type","StringLiteral")}},BooleanLiteral=class extends Literal{constructor(){super(...arguments);J(this,"type","BooleanLiteral")}},ArrayLiteral=class extends Literal{constructor(){super(...arguments);J(this,"type","ArrayLiteral")}},TupleLiteral=class extends Literal{constructor(){super(...arguments);J(this,"type","TupleLiteral")}},ObjectLiteral=class extends Literal{constructor(){super(...arguments);J(this,"type","ObjectLiteral")}},BinaryExpression=class extends Expression{constructor(n,o,s){super();J(this,"type","BinaryExpression");this.operator=n,this.left=o,this.right=s}},FilterExpression=class extends Expression{constructor(n,o){super();J(this,"type","FilterExpression");this.operand=n,this.filter=o}},TestExpression=class extends Expression{constructor(n,o,s){super();J(this,"type","TestExpression");this.operand=n,this.negate=o,this.test=s}},UnaryExpression=class extends Expression{constructor(n,o){super();J(this,"type","UnaryExpression");this.operator=n,this.argument=o}},SliceExpression=class extends Expression{constructor(n=void 0,o=void 0,s=void 0){super();J(this,"type","SliceExpression");this.start=n,this.stop=o,this.step=s}},KeywordArgumentExpression=class extends Expression{constructor(n,o){super();J(this,"type","KeywordArgumentExpression");this.key=n,this.value=o}};function parse(d){const n=new Program([]);let o=0;function s(D,k){const F=d[o++];if(!F||F.type!==D)throw new Error(`Parser Error: ${k}. ${F.type} !== ${D}.`);return F}function l(){switch(d[o].type){case TOKEN_TYPES.Text:return p();case TOKEN_TYPES.OpenStatement:return g();case TOKEN_TYPES.OpenExpression:return c();default:throw new SyntaxError(`Unexpected token type: ${d[o].type}`)}}function f(...D){return o+D.length<=d.length&&D.some((k,F)=>k!==d[o+F].type)}function u(...D){return o+D.length<=d.length&&D.every((k,F)=>k===d[o+F].type)}function p(){return new StringLiteral(s(TOKEN_TYPES.Text,"Expected text token").value)}function g(){s(TOKEN_TYPES.OpenStatement,"Expected opening statement token");let D;switch(d[o].type){case TOKEN_TYPES.Set:++o,D=a(),s(TOKEN_TYPES.CloseStatement,"Expected closing statement token");break;case TOKEN_TYPES.If:++o,D=t(),s(TOKEN_TYPES.OpenStatement,"Expected {% token"),s(TOKEN_TYPES.EndIf,"Expected endif token"),s(TOKEN_TYPES.CloseStatement,"Expected %} token");break;case TOKEN_TYPES.For:++o,D=r(),s(TOKEN_TYPES.OpenStatement,"Expected {% token"),s(TOKEN_TYPES.EndFor,"Expected endfor token"),s(TOKEN_TYPES.CloseStatement,"Expected %} token");break;default:throw new SyntaxError(`Unknown statement type: ${d[o].type}`)}return D}function c(){s(TOKEN_TYPES.OpenExpression,"Expected opening expression token");const D=i();return s(TOKEN_TYPES.CloseExpression,"Expected closing expression token"),D}function a(){const D=i();if(u(TOKEN_TYPES.Equals)){++o;const k=a();return new SetStatement(D,k)}return D}function t(){var Q,Y,ee,te,he,Oe,xe,ue;const D=i();s(TOKEN_TYPES.CloseStatement,"Expected closing statement token");const k=[],F=[];for(;!(((Q=d[o])==null?void 0:Q.type)===TOKEN_TYPES.OpenStatement&&(((Y=d[o+1])==null?void 0:Y.type)===TOKEN_TYPES.ElseIf||((ee=d[o+1])==null?void 0:ee.type)===TOKEN_TYPES.Else||((te=d[o+1])==null?void 0:te.type)===TOKEN_TYPES.EndIf));)k.push(l());if(((he=d[o])==null?void 0:he.type)===TOKEN_TYPES.OpenStatement&&((Oe=d[o+1])==null?void 0:Oe.type)!==TOKEN_TYPES.EndIf)if(++o,u(TOKEN_TYPES.ElseIf))s(TOKEN_TYPES.ElseIf,"Expected elseif token"),F.push(t());else for(s(TOKEN_TYPES.Else,"Expected else token"),s(TOKEN_TYPES.CloseStatement,"Expected closing statement token");!(((xe=d[o])==null?void 0:xe.type)===TOKEN_TYPES.OpenStatement&&((ue=d[o+1])==null?void 0:ue.type)===TOKEN_TYPES.EndIf);)F.push(l());return new If(D,k,F)}function e(D=!1){const k=D?L:i,F=[k()],Q=u(TOKEN_TYPES.Comma);for(;Q&&(++o,F.push(k()),!!u(TOKEN_TYPES.Comma)););return Q?new TupleLiteral(F):F[0]}function r(){const D=e(!0);if(!(D instanceof Identifier||D instanceof TupleLiteral))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${D.type} instead`);s(TOKEN_TYPES.In,"Expected `in` keyword following loop variable");const k=i();s(TOKEN_TYPES.CloseStatement,"Expected closing statement token");const F=[];for(;f(TOKEN_TYPES.OpenStatement,TOKEN_TYPES.EndFor);)F.push(l());return new For(D,k,F)}function i(){return h()}function h(){const D=m();if(u(TOKEN_TYPES.If)){++o;const k=m();s(TOKEN_TYPES.Else,"Expected else token");const F=m();return new If(k,[D],[F])}return D}function m(){let D=_();for(;u(TOKEN_TYPES.Or);){const k=d[o];++o;const F=_();D=new BinaryExpression(k,D,F)}return D}function _(){let D=b();for(;u(TOKEN_TYPES.And);){const k=d[o];++o;const F=b();D=new BinaryExpression(k,D,F)}return D}function b(){let D;for(;u(TOKEN_TYPES.Not);){const k=d[o];++o;const F=b();D=new UnaryExpression(k,F)}return D??y()}function y(){let D=T();for(;u(TOKEN_TYPES.ComparisonBinaryOperator)||u(TOKEN_TYPES.In)||u(TOKEN_TYPES.NotIn);){const k=d[o];++o;const F=T();D=new BinaryExpression(k,D,F)}return D}function T(){let D=$();for(;u(TOKEN_TYPES.AdditiveBinaryOperator);){const k=d[o];++o;const F=$();D=new BinaryExpression(k,D,F)}return D}function w(){const D=M();return u(TOKEN_TYPES.OpenParen)?S(D):D}function S(D){let k=new CallExpression(D,E());return u(TOKEN_TYPES.OpenParen)&&(k=S(k)),k}function E(){s(TOKEN_TYPES.OpenParen,"Expected opening parenthesis for arguments list");const D=O();return s(TOKEN_TYPES.CloseParen,"Expected closing parenthesis for arguments list"),D}function O(){const D=[];for(;!u(TOKEN_TYPES.CloseParen);){let k=i();if(u(TOKEN_TYPES.Equals)){if(++o,!(k instanceof Identifier))throw new SyntaxError("Expected identifier for keyword argument");const F=i();k=new KeywordArgumentExpression(k,F)}D.push(k),u(TOKEN_TYPES.Comma)&&++o}return D}function v(){const D=[];let k=!1;for(;!u(TOKEN_TYPES.CloseSquareBracket);)u(TOKEN_TYPES.Colon)?(D.push(void 0),++o,k=!0):(D.push(i()),u(TOKEN_TYPES.Colon)&&(++o,k=!0));if(D.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(k){if(D.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new SliceExpression(...D)}return D[0]}function M(){let D=L();for(;u(TOKEN_TYPES.Dot)||u(TOKEN_TYPES.OpenSquareBracket);){const k=d[o];++o;let F;const Q=k.type!==TOKEN_TYPES.Dot;if(Q)F=v(),s(TOKEN_TYPES.CloseSquareBracket,"Expected closing square bracket");else if(F=L(),F.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");D=new MemberExpression(D,F,Q)}return D}function $(){let D=V();for(;u(TOKEN_TYPES.MultiplicativeBinaryOperator);){const k=d[o];++o;const F=V();D=new BinaryExpression(k,D,F)}return D}function V(){let D=B();for(;u(TOKEN_TYPES.Is);){++o;const k=u(TOKEN_TYPES.Not);k&&++o;let F=L();if(F instanceof BooleanLiteral&&(F=new Identifier(F.value.toString())),!(F instanceof Identifier))throw new SyntaxError("Expected identifier for the test");D=new TestExpression(D,k,F)}return D}function B(){let D=w();for(;u(TOKEN_TYPES.Pipe);){++o;let k=L();if(!(k instanceof Identifier))throw new SyntaxError("Expected identifier for the filter");u(TOKEN_TYPES.OpenParen)&&(k=S(k)),D=new FilterExpression(D,k)}return D}function L(){const D=d[o];switch(D.type){case TOKEN_TYPES.NumericLiteral:return++o,new NumericLiteral(Number(D.value));case TOKEN_TYPES.StringLiteral:return++o,new StringLiteral(D.value);case TOKEN_TYPES.BooleanLiteral:return++o,new BooleanLiteral(D.value==="true");case TOKEN_TYPES.Identifier:return++o,new Identifier(D.value);case TOKEN_TYPES.OpenParen:{++o;const k=e();if(d[o].type!==TOKEN_TYPES.CloseParen)throw new SyntaxError(`Expected closing parenthesis, got ${d[o].type} instead`);return++o,k}case TOKEN_TYPES.OpenSquareBracket:{++o;const k=[];for(;!u(TOKEN_TYPES.CloseSquareBracket);)k.push(i()),u(TOKEN_TYPES.Comma)&&++o;return++o,new ArrayLiteral(k)}case TOKEN_TYPES.OpenCurlyBracket:{++o;const k=new Map;for(;!u(TOKEN_TYPES.CloseCurlyBracket);){const F=i();s(TOKEN_TYPES.Colon,"Expected colon between key and value in object literal");const Q=i();k.set(F,Q),u(TOKEN_TYPES.Comma)&&++o}return++o,new ObjectLiteral(k)}default:throw new SyntaxError(`Unexpected token: ${D.type}`)}}for(;o<d.length;)n.body.push(l());return n}function range(d,n,o=1){n===void 0&&(n=d,d=0);const s=[];for(let l=d;l<n;l+=o)s.push(l);return s}function slice(d,n,o,s=1){const l=Math.sign(s);l>=0?(n=(n??(n=0))<0?Math.max(d.length+n,0):Math.min(n,d.length),o=(o??(o=d.length))<0?Math.max(d.length+o,0):Math.min(o,d.length)):(n=(n??(n=d.length-1))<0?Math.max(d.length+n,-1):Math.min(n,d.length-1),o=(o??(o=-1))<-1?Math.max(d.length+o,-1):Math.min(o,d.length-1));const f=[];for(let u=n;l*u<l*o;u+=s)f.push(d[u]);return f}function titleCase(d){return d.replace(/\b\w/g,n=>n.toUpperCase())}var RuntimeValue=class{constructor(d=void 0){J(this,"type","RuntimeValue");J(this,"value");J(this,"builtins",new Map);this.value=d}__bool__(){return new BooleanValue(!!this.value)}},NumericValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","NumericValue")}},StringValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","StringValue");J(this,"builtins",new Map([["upper",new FunctionValue(()=>new StringValue(this.value.toUpperCase()))],["lower",new FunctionValue(()=>new StringValue(this.value.toLowerCase()))],["strip",new FunctionValue(()=>new StringValue(this.value.trim()))],["title",new FunctionValue(()=>new StringValue(titleCase(this.value)))],["length",new NumericValue(this.value.length)]]))}},BooleanValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","BooleanValue")}},ObjectValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","ObjectValue");J(this,"builtins",new Map([["get",new FunctionValue(([n,o])=>{if(!(n instanceof StringValue))throw new Error(`Object key must be a string: got ${n.type}`);return this.value.get(n.value)??o??new NullValue})],["items",new FunctionValue(()=>new ArrayValue(Array.from(this.value.entries()).map(([n,o])=>new ArrayValue([new StringValue(n),o]))))]]))}__bool__(){return new BooleanValue(this.value.size>0)}},ArrayValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","ArrayValue");J(this,"builtins",new Map([["length",new NumericValue(this.value.length)]]))}__bool__(){return new BooleanValue(this.value.length>0)}},TupleValue=class extends ArrayValue{constructor(){super(...arguments);J(this,"type","TupleValue")}},FunctionValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","FunctionValue")}},NullValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","NullValue")}},UndefinedValue=class extends RuntimeValue{constructor(){super(...arguments);J(this,"type","UndefinedValue")}},Environment=class{constructor(d){J(this,"variables",new Map([["namespace",new FunctionValue(d=>{if(d.length===0)return new ObjectValue(new Map);if(d.length!==1||!(d[0]instanceof ObjectValue))throw new Error("`namespace` expects either zero arguments or a single object argument");return d[0]})]]));J(this,"tests",new Map([["boolean",d=>d.type==="BooleanValue"],["callable",d=>d instanceof FunctionValue],["odd",d=>{if(d.type!=="NumericValue")throw new Error(`Cannot apply test "odd" to type: ${d.type}`);return d.value%2!==0}],["even",d=>{if(d.type!=="NumericValue")throw new Error(`Cannot apply test "even" to type: ${d.type}`);return d.value%2===0}],["false",d=>d.type==="BooleanValue"&&!d.value],["true",d=>d.type==="BooleanValue"&&d.value],["number",d=>d.type==="NumericValue"],["integer",d=>d.type==="NumericValue"&&Number.isInteger(d.value)],["iterable",d=>d instanceof ArrayValue||d instanceof StringValue],["lower",d=>{const n=d.value;return d.type==="StringValue"&&n===n.toLowerCase()}],["upper",d=>{const n=d.value;return d.type==="StringValue"&&n===n.toUpperCase()}],["none",d=>d.type==="NullValue"],["defined",d=>d.type!=="UndefinedValue"],["undefined",d=>d.type==="UndefinedValue"],["equalto",(d,n)=>d.value===n.value]]));this.parent=d}set(d,n){return this.declareVariable(d,convertToRuntimeValues(n))}declareVariable(d,n){if(this.variables.has(d))throw new SyntaxError(`Variable already declared: ${d}`);return this.variables.set(d,n),n}setVariable(d,n){return this.variables.set(d,n),n}resolve(d){if(this.variables.has(d))return this;if(this.parent)return this.parent.resolve(d);throw new Error(`Unknown variable: ${d}`)}lookupVariable(d){try{return this.resolve(d).variables.get(d)??new UndefinedValue}catch{return new UndefinedValue}}},Interpreter=class{constructor(d){J(this,"global");this.global=d??new Environment}run(d){return this.evaluate(d,this.global)}evaluateBinaryExpression(d,n){const o=this.evaluate(d.left,n);switch(d.operator.value){case"and":return o.__bool__().value?this.evaluate(d.right,n):o;case"or":return o.__bool__().value?o:this.evaluate(d.right,n)}const s=this.evaluate(d.right,n);switch(d.operator.value){case"==":return new BooleanValue(o.value==s.value);case"!=":return new BooleanValue(o.value!=s.value)}if(o instanceof UndefinedValue||s instanceof UndefinedValue)throw new Error("Cannot perform operation on undefined values");if(o instanceof NullValue||s instanceof NullValue)throw new Error("Cannot perform operation on null values");if(o instanceof NumericValue&&s instanceof NumericValue)switch(d.operator.value){case"+":return new NumericValue(o.value+s.value);case"-":return new NumericValue(o.value-s.value);case"*":return new NumericValue(o.value*s.value);case"/":return new NumericValue(o.value/s.value);case"%":return new NumericValue(o.value%s.value);case"<":return new BooleanValue(o.value<s.value);case">":return new BooleanValue(o.value>s.value);case">=":return new BooleanValue(o.value>=s.value);case"<=":return new BooleanValue(o.value<=s.value)}else if(o instanceof ArrayValue&&s instanceof ArrayValue)switch(d.operator.value){case"+":return new ArrayValue(o.value.concat(s.value))}else if(s instanceof ArrayValue){const l=s.value.find(f=>f.value===o.value)!==void 0;switch(d.operator.value){case"in":return new BooleanValue(l);case"not in":return new BooleanValue(!l)}}if(o instanceof StringValue||s instanceof StringValue)switch(d.operator.value){case"+":return new StringValue(o.value.toString()+s.value.toString())}if(o instanceof StringValue&&s instanceof StringValue)switch(d.operator.value){case"in":return new BooleanValue(s.value.includes(o.value));case"not in":return new BooleanValue(!s.value.includes(o.value))}if(o instanceof StringValue&&s instanceof ObjectValue)switch(d.operator.value){case"in":return new BooleanValue(s.value.has(o.value));case"not in":return new BooleanValue(!s.value.has(o.value))}throw new SyntaxError(`Unknown operator "${d.operator.value}" between ${o.type} and ${s.type}`)}evaluateFilterExpression(d,n){const o=this.evaluate(d.operand,n);if(d.filter.type==="Identifier"){const s=d.filter;if(o instanceof ArrayValue)switch(s.value){case"list":return o;case"first":return o.value[0];case"last":return o.value[o.value.length-1];case"length":return new NumericValue(o.value.length);case"reverse":return new ArrayValue(o.value.reverse());case"sort":return new ArrayValue(o.value.sort((l,f)=>{if(l.type!==f.type)throw new Error(`Cannot compare different types: ${l.type} and ${f.type}`);switch(l.type){case"NumericValue":return l.value-f.value;case"StringValue":return l.value.localeCompare(f.value);default:throw new Error(`Cannot compare type: ${l.type}`)}}));default:throw new Error(`Unknown ArrayValue filter: ${s.value}`)}else if(o instanceof StringValue)switch(s.value){case"length":return new NumericValue(o.value.length);case"upper":return new StringValue(o.value.toUpperCase());case"lower":return new StringValue(o.value.toLowerCase());case"title":return new StringValue(titleCase(o.value));case"capitalize":return new StringValue(o.value.charAt(0).toUpperCase()+o.value.slice(1));case"trim":return new StringValue(o.value.trim());default:throw new Error(`Unknown StringValue filter: ${s.value}`)}else if(o instanceof NumericValue)switch(s.value){case"abs":return new NumericValue(Math.abs(o.value));default:throw new Error(`Unknown NumericValue filter: ${s.value}`)}else if(o instanceof ObjectValue)switch(s.value){case"items":return new ArrayValue(Array.from(o.value.entries()).map(([l,f])=>new ArrayValue([new StringValue(l),f])));case"length":return new NumericValue(o.value.size);default:throw new Error(`Unknown ObjectValue filter: ${s.value}`)}throw new Error(`Cannot apply filter "${s.value}" to type: ${o.type}`)}else if(d.filter.type==="CallExpression"){const s=d.filter;if(s.callee.type!=="Identifier")throw new Error(`Unknown filter: ${s.callee.type}`);const l=s.callee.value;if(o instanceof ArrayValue){switch(l){case"selectattr":{if(o.value.some(a=>!(a instanceof ObjectValue)))throw new Error("`selectattr` can only be applied to array of objects");if(s.args.some(a=>a.type!=="StringLiteral"))throw new Error("arguments of `selectattr` must be strings");const[f,u,p]=s.args.map(a=>this.evaluate(a,n));let g;if(u){const a=n.tests.get(u.value);if(!a)throw new Error(`Unknown test: ${u.value}`);g=a}else g=(...a)=>a[0].__bool__().value;const c=o.value.filter(a=>{const t=a.value.get(f.value);return t?g(t,p):!1});return new ArrayValue(c)}}throw new Error(`Unknown ArrayValue filter: ${l}`)}else throw new Error(`Cannot apply filter "${l}" to type: ${o.type}`)}throw new Error(`Unknown filter: ${d.filter.type}`)}evaluateTestExpression(d,n){const o=this.evaluate(d.operand,n),s=n.tests.get(d.test.value);if(!s)throw new Error(`Unknown test: ${d.test.value}`);const l=s(o);return new BooleanValue(d.negate?!l:l)}evaluateUnaryExpression(d,n){const o=this.evaluate(d.argument,n);switch(d.operator.value){case"not":return new BooleanValue(!o.value);default:throw new SyntaxError(`Unknown operator: ${d.operator.value}`)}}evalProgram(d,n){return this.evaluateBlock(d.body,n)}evaluateBlock(d,n){let o="";for(const s of d){const l=this.evaluate(s,n);l.type!=="NullValue"&&l.type!=="UndefinedValue"&&(o+=l.value)}return new StringValue(o)}evaluateIdentifier(d,n){return n.lookupVariable(d.value)}evaluateCallExpression(d,n){const o=[],s=new Map;for(const f of d.args)if(f.type==="KeywordArgumentExpression"){const u=f;s.set(u.key.value,this.evaluate(u.value,n))}else o.push(this.evaluate(f,n));s.size>0&&o.push(new ObjectValue(s));const l=this.evaluate(d.callee,n);if(l.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${l.type}`);return l.value(o,n)}evaluateSliceExpression(d,n,o){if(!(d instanceof ArrayValue||d instanceof StringValue))throw new Error("Slice object must be an array or string");const s=this.evaluate(n.start,o),l=this.evaluate(n.stop,o),f=this.evaluate(n.step,o);if(!(s instanceof NumericValue||s instanceof UndefinedValue))throw new Error("Slice start must be numeric or undefined");if(!(l instanceof NumericValue||l instanceof UndefinedValue))throw new Error("Slice stop must be numeric or undefined");if(!(f instanceof NumericValue||f instanceof UndefinedValue))throw new Error("Slice step must be numeric or undefined");return d instanceof ArrayValue?new ArrayValue(slice(d.value,s.value,l.value,f.value)):new StringValue(slice(Array.from(d.value),s.value,l.value,f.value).join(""))}evaluateMemberExpression(d,n){const o=this.evaluate(d.object,n);let s;if(d.computed){if(d.property.type==="SliceExpression")return this.evaluateSliceExpression(o,d.property,n);s=this.evaluate(d.property,n)}else s=new StringValue(d.property.value);let l;if(o instanceof ObjectValue){if(!(s instanceof StringValue))throw new Error(`Cannot access property with non-string: got ${s.type}`);l=o.value.get(s.value)??o.builtins.get(s.value)}else if(o instanceof ArrayValue||o instanceof StringValue)if(s instanceof NumericValue)l=o.value.at(s.value),o instanceof StringValue&&(l=new StringValue(o.value.at(s.value)));else if(s instanceof StringValue)l=o.builtins.get(s.value);else throw new Error(`Cannot access property with non-string/non-number: got ${s.type}`);else{if(!(s instanceof StringValue))throw new Error(`Cannot access property with non-string: got ${s.type}`);l=o.builtins.get(s.value)}return l instanceof RuntimeValue?l:new UndefinedValue}evaluateSet(d,n){const o=this.evaluate(d.value,n);if(d.assignee.type==="Identifier"){const s=d.assignee.value;n.setVariable(s,o)}else if(d.assignee.type==="MemberExpression"){const s=d.assignee,l=this.evaluate(s.object,n);if(!(l instanceof ObjectValue))throw new Error("Cannot assign to member of non-object");if(s.property.type!=="Identifier")throw new Error("Cannot assign to member with non-identifier property");l.value.set(s.property.value,o)}else throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(d.assignee)}`);return new NullValue}evaluateIf(d,n){const o=this.evaluate(d.test,n);return this.evaluateBlock(o.__bool__().value?d.body:d.alternate,n)}evaluateFor(d,n){const o=new Environment(n),s=this.evaluate(d.iterable,o);if(!(s instanceof ArrayValue))throw new Error(`Expected iterable type in for loop: got ${s.type}`);let l="";for(let f=0;f<s.value.length;++f){const u=new Map([["index",new NumericValue(f+1)],["index0",new NumericValue(f)],["revindex",new NumericValue(s.value.length-f)],["revindex0",new NumericValue(s.value.length-f-1)],["first",new BooleanValue(f===0)],["last",new BooleanValue(f===s.value.length-1)],["length",new NumericValue(s.value.length)],["previtem",f>0?s.value[f-1]:new UndefinedValue],["nextitem",f<s.value.length-1?s.value[f+1]:new UndefinedValue]]);o.setVariable("loop",new ObjectValue(u));const p=s.value[f];if(d.loopvar.type==="Identifier")o.setVariable(d.loopvar.value,p);else if(d.loopvar.type==="TupleLiteral"){const c=d.loopvar;if(p.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${p.type}`);const a=p;if(c.value.length!==a.value.length)throw new Error(`Too ${c.value.length>a.value.length?"few":"many"} items to unpack`);for(let t=0;t<c.value.length;++t){if(c.value[t].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${c.value[t].type}`);o.setVariable(c.value[t].value,a.value[t])}}const g=this.evaluateBlock(d.body,o);l+=g.value}return new StringValue(l)}evaluate(d,n){if(d===void 0)return new UndefinedValue;switch(d.type){case"Program":return this.evalProgram(d,n);case"Set":return this.evaluateSet(d,n);case"If":return this.evaluateIf(d,n);case"For":return this.evaluateFor(d,n);case"NumericLiteral":return new NumericValue(Number(d.value));case"StringLiteral":return new StringValue(d.value);case"BooleanLiteral":return new BooleanValue(d.value);case"ArrayLiteral":return new ArrayValue(d.value.map(o=>this.evaluate(o,n)));case"TupleLiteral":return new TupleValue(d.value.map(o=>this.evaluate(o,n)));case"ObjectLiteral":{const o=new Map;for(const[s,l]of d.value){const f=this.evaluate(s,n);if(!(f instanceof StringValue))throw new Error(`Object keys must be strings: got ${f.type}`);o.set(f.value,this.evaluate(l,n))}return new ObjectValue(o)}case"Identifier":return this.evaluateIdentifier(d,n);case"CallExpression":return this.evaluateCallExpression(d,n);case"MemberExpression":return this.evaluateMemberExpression(d,n);case"UnaryExpression":return this.evaluateUnaryExpression(d,n);case"BinaryExpression":return this.evaluateBinaryExpression(d,n);case"FilterExpression":return this.evaluateFilterExpression(d,n);case"TestExpression":return this.evaluateTestExpression(d,n);default:throw new SyntaxError(`Unknown node type: ${d.type}`)}}};function convertToRuntimeValues(d){switch(typeof d){case"number":return new NumericValue(d);case"string":return new StringValue(d);case"boolean":return new BooleanValue(d);case"object":return d===null?new NullValue:Array.isArray(d)?new ArrayValue(d.map(convertToRuntimeValues)):new ObjectValue(new Map(Object.entries(d).map(([n,o])=>[n,convertToRuntimeValues(o)])));case"function":return new FunctionValue((n,o)=>{const s=d(...n.map(l=>l.value))??null;return convertToRuntimeValues(s)});default:throw new Error(`Cannot convert to runtime value: ${d}`)}}var Template=class{constructor(d){J(this,"parsed");const n=tokenize(d,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=parse(n)}render(d){const n=new Environment;n.set("false",!1),n.set("true",!0),n.set("raise_exception",l=>{throw new Error(l)}),n.set("range",range);for(const[l,f]of Object.entries(d))n.set(l,f);return new Interpreter(n).run(this.parsed).value}};async function loadTokenizer(d,n){const o=await Promise.all([getModelJSON(d,"tokenizer.json",!0,n),getModelJSON(d,"tokenizer_config.json",!0,n)]);return n.legacy!==null&&(o[1].legacy=n.legacy),o}function regexSplit(d,n){const o=[];let s=0;for(const l of d.matchAll(n)){const f=l[0];s<l.index&&o.push(d.slice(s,l.index)),f.length>0&&o.push(f),s=l.index+f.length}return s<d.length&&o.push(d.slice(s)),o}function createPattern(d,n=!0){if(d.Regex!==void 0){let o=d.Regex.replace(/\\([#&~])/g,"$1");for(const[s,l]of PROBLEMATIC_REGEX_MAP)o=o.replaceAll(s,l);return new RegExp(o,"gu")}else if(d.String!==void 0){const o=escapeRegExp(d.String);return new RegExp(n?o:`(${o})`,"gu")}else return console.warn("Unknown pattern type:",d),null}function objectToMap(d){return new Map(Object.entries(d))}function prepareTensorForDecode(d){const n=d.dims;switch(n.length){case 1:return d.tolist();case 2:if(n[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return d.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${n.length}.`)}}function clean_up_tokenization(d){return d.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n\'t/g,"n't").replace(/ \'m/g,"'m").replace(/ \'s/g,"'s").replace(/ \'ve/g,"'ve").replace(/ \'re/g,"'re")}function remove_accents(d){return d.replace(/[\u0300-\u036f]/g,"")}function lowercase_and_remove_accent(d){return remove_accents(d.toLowerCase())}function fuse(d,n,o){const s=[];let l=0;for(;l<d.length;){if(s.push(d[l]),(o.get(d[l])??n)!==n){++l;continue}for(;l<d.length&&(o.get(d[l])??n)===n;)++l}return s}function whitespace_split(d){return d.match(/\S+/g)||[]}const PUNCTUATION_REGEX="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",PROBLEMATIC_REGEX_MAP=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"]]);class AddedToken{constructor(n){this.content=n.content,this.id=n.id,this.single_word=n.single_word??!1,this.lstrip=n.lstrip??!1,this.rstrip=n.rstrip??!1,this.special=n.special??!1,this.normalized=n.normalized??null}}class TokenizerModel extends Callable{constructor(n){super(),this.config=n,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}static fromConfig(n,...o){switch(n.type){case"WordPiece":return new WordPieceTokenizer(n);case"Unigram":return new Unigram(n,...o);case"BPE":return new BPE(n);default:if(n.vocab)return new LegacyTokenizerModel(n,...o);throw new Error(`Unknown TokenizerModel type: ${n.type}`)}}_call(n){let o=this.encode(n);return this.fuse_unk&&(o=fuse(o,this.unk_token_id,this.tokens_to_ids)),o}encode(n){throw Error("encode should be implemented in subclass.")}convert_tokens_to_ids(n){return n.map(o=>this.tokens_to_ids.get(o)??this.unk_token_id)}convert_ids_to_tokens(n){return n.map(o=>this.vocab[o]??this.unk_token)}}class WordPieceTokenizer extends TokenizerModel{constructor(n){super(n),this.tokens_to_ids=objectToMap(n.vocab),this.unk_token_id=this.tokens_to_ids.get(n.unk_token),this.unk_token=n.unk_token,this.max_input_chars_per_word=n.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(const[o,s]of this.tokens_to_ids)this.vocab[s]=o}encode(n){const o=[];for(const s of n){const l=[...s];if(l.length>this.max_input_chars_per_word){o.push(this.unk_token);continue}let f=!1,u=0;const p=[];for(;u<l.length;){let g=l.length,c=null;for(;u<g;){let a=l.slice(u,g).join("");if(u>0&&(a=this.config.continuing_subword_prefix+a),this.tokens_to_ids.has(a)){c=a;break}--g}if(c===null){f=!0;break}p.push(c),u=g}f?o.push(this.unk_token):o.push(...p)}return o}}class Unigram extends TokenizerModel{constructor(n,o){super(n);const s=n.vocab.length;this.vocab=new Array(s),this.scores=new Array(s);for(let l=0;l<s;++l){const f=n.vocab[l];this.vocab[l]=f[0],this.scores[l]=f[1]}this.unk_token_id=n.unk_id,this.unk_token=this.vocab[n.unk_id],this.tokens_to_ids=new Map(this.vocab.map((l,f)=>[l,f])),this.bosToken=" ",this.bosTokenId=this.tokens_to_ids.get(this.bosToken),this.eosToken=o.eos_token,this.eosTokenId=this.tokens_to_ids.get(this.eosToken),this.unkToken=this.vocab[this.unk_token_id],this.minScore=min(this.scores)[0],this.unkScore=this.minScore-10,this.scores[this.unk_token_id]=this.unkScore,this.trie=new CharTrie,this.trie.extend(this.vocab),this.fuse_unk=!0}populateNodes(n){const o=n.sentence,s=o.length;let l=0;for(;l<s;){let u=!1;for(let p of this.trie.commonPrefixSearch(o.slice(l))){const g=this.tokens_to_ids.get(p),c=this.scores[g],a=p.length;n.insert(l,a,c,g),!u&&a===1&&(u=!0)}u||n.insert(l,1,this.unkScore,this.unk_token_id),l+=1}}tokenize(n){const o=new TokenLattice(n,this.bosTokenId,this.eosTokenId);return this.populateNodes(o),o.tokens()}encode(n){const o=[];for(const s of n){const l=this.tokenize(s);o.push(...l)}return o}}const BYTES_TO_UNICODE=(()=>{const d=[...Array.from({length:"~".charCodeAt(0)-"!".charCodeAt(0)+1},(l,f)=>f+"!".charCodeAt(0)),...Array.from({length:"¬".charCodeAt(0)-"¡".charCodeAt(0)+1},(l,f)=>f+"¡".charCodeAt(0)),...Array.from({length:"ÿ".charCodeAt(0)-"®".charCodeAt(0)+1},(l,f)=>f+"®".charCodeAt(0))],n=d.slice();let o=0;for(let l=0;l<256;++l)d.includes(l)||(d.push(l),n.push(256+o),o+=1);const s=n.map(l=>String.fromCharCode(l));return Object.fromEntries(d.map((l,f)=>[l,s[f]]))})(),UNICODE_TO_BYTES=reverseDictionary(BYTES_TO_UNICODE);class BPE extends TokenizerModel{constructor(n){super(n),this.BPE_SPLIT_TOKEN=" ",this.tokens_to_ids=objectToMap(n.vocab),this.unk_token_id=this.tokens_to_ids.get(n.unk_token),this.unk_token=n.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(const[o,s]of this.tokens_to_ids)this.vocab[s]=o;this.bpe_ranks=new Map(n.merges.map((o,s)=>[o,s])),this.merges=n.merges.map(o=>o.split(this.BPE_SPLIT_TOKEN)),this.end_of_word_suffix=n.end_of_word_suffix,this.continuing_subword_suffix=n.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.cache=new Map}bpe(n){if(n.length===0)return[];const o=this.cache.get(n);if(o!==void 0)return o;const s=Array.from(n);this.end_of_word_suffix&&(s[s.length-1]+=this.end_of_word_suffix);let l=[];if(s.length>1){const f=new PriorityQueue((g,c)=>g.score<c.score);let u={token:s[0],bias:0,prev:null,next:null},p=u;for(let g=1;g<s.length;++g){const c={bias:g/s.length,token:s[g],prev:p,next:null};p.next=c,this._add_node(f,p),p=c}for(;!f.isEmpty();){const g=f.pop();if(g.deleted||!g.next||g.next.deleted)continue;if(g.deleted=!0,g.next.deleted=!0,g.prev){const a={...g.prev};g.prev.deleted=!0,g.prev=a,a.prev?a.prev.next=a:u=a}const c={token:g.token+g.next.token,bias:g.bias,prev:g.prev,next:g.next.next};c.prev?(c.prev.next=c,this._add_node(f,c.prev)):u=c,c.next&&(c.next.prev=c,this._add_node(f,c))}for(let g=u;g!==null;g=g.next)l.push(g.token)}else l=s;if(this.continuing_subword_suffix)for(let f=0;f<l.length-1;++f)l[f]+=this.continuing_subword_suffix;return this.cache.set(n,l),l}_add_node(n,o){const s=this.bpe_ranks.get(o.token+this.BPE_SPLIT_TOKEN+o.next.token);s!==void 0&&(o.score=s+o.bias,n.push(o))}encode(n){const o=[];for(const s of n){if(this.ignore_merges&&this.tokens_to_ids.has(s)){o.push(s);continue}const l=this.bpe(s);for(const f of l)this.tokens_to_ids.has(f)?o.push(f):this.byte_fallback?o.push(...Array.from(this.text_encoder.encode(f)).map(u=>`<0x${u.toString(16).toUpperCase().padStart(2,"0")}>`)):o.push(this.unk_token)}return o}}class LegacyTokenizerModel extends TokenizerModel{constructor(n,o){super(n),this.tokens_to_ids=objectToMap(o.target_lang?n.vocab[o.target_lang]:n.vocab),this.bos_token=o.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=o.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=o.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=o.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(const[s,l]of this.tokens_to_ids)this.vocab[l]=s}encode(n){return n}}class Normalizer extends Callable{constructor(n){super(),this.config=n}static fromConfig(n){if(n===null)return null;switch(n.type){case"BertNormalizer":return new BertNormalizer(n);case"Precompiled":return new Precompiled(n);case"Sequence":return new NormalizerSequence(n);case"Replace":return new Replace(n);case"NFC":return new NFC(n);case"NFKC":return new NFKC(n);case"NFKD":return new NFKD(n);case"Strip":return new StripNormalizer(n);case"StripAccents":return new StripAccents(n);case"Lowercase":return new Lowercase(n);case"Prepend":return new Prepend(n);default:throw new Error(`Unknown Normalizer type: ${n.type}`)}}normalize(n){throw Error("normalize should be implemented in subclass.")}_call(n){return this.normalize(n)}}class Replace extends Normalizer{normalize(n){const o=createPattern(this.config.pattern);return o===null?n:n.replaceAll(o,this.config.content)}}class NFC extends Normalizer{normalize(n){return n=n.normalize("NFC"),n}}class NFKC extends Normalizer{normalize(n){return n=n.normalize("NFKC"),n}}class NFKD extends Normalizer{normalize(n){return n=n.normalize("NFKD"),n}}class StripNormalizer extends Normalizer{normalize(n){return this.config.strip_left&&this.config.strip_right?n=n.trim():(this.config.strip_left&&(n=n.trimStart()),this.config.strip_right&&(n=n.trimEnd())),n}}class StripAccents extends Normalizer{normalize(n){return n=remove_accents(n),n}}class Lowercase extends Normalizer{normalize(n){return n=n.toLowerCase(),n}}class Prepend extends Normalizer{normalize(n){return n=this.config.prepend+n,n}}class NormalizerSequence extends Normalizer{constructor(n){super(n),this.normalizers=n.normalizers.map(o=>Normalizer.fromConfig(o))}normalize(n){return this.normalizers.reduce((o,s)=>s.normalize(o),n)}}class BertNormalizer extends Normalizer{_tokenize_chinese_chars(n){const o=[];for(let s=0;s<n.length;++s){const l=n[s],f=l.charCodeAt(0);this._is_chinese_char(f)?(o.push(" "),o.push(l),o.push(" ")):o.push(l)}return o.join("")}_is_chinese_char(n){return n>=19968&&n<=40959||n>=13312&&n<=19903||n>=131072&&n<=173791||n>=173824&&n<=177983||n>=177984&&n<=178207||n>=178208&&n<=183983||n>=63744&&n<=64255||n>=194560&&n<=195103}stripAccents(n){return n.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}_is_control(n){switch(n){case" ":case` +`:case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(n)}}_clean_text(n){const o=[];for(const s of n){const l=s.charCodeAt(0);l===0||l===65533||this._is_control(s)||(/^\s$/.test(s)?o.push(" "):o.push(s))}return o.join("")}normalize(n){return this.config.clean_text&&(n=this._clean_text(n)),this.config.handle_chinese_chars&&(n=this._tokenize_chinese_chars(n)),this.config.lowercase?(n=n.toLowerCase(),this.config.strip_accents!==!1&&(n=this.stripAccents(n))):this.config.strip_accents&&(n=this.stripAccents(n)),n}}class PreTokenizer extends Callable{static fromConfig(n){if(n===null)return null;switch(n.type){case"BertPreTokenizer":return new BertPreTokenizer(n);case"Sequence":return new PreTokenizerSequence(n);case"Whitespace":return new WhitespacePreTokenizer(n);case"WhitespaceSplit":return new WhitespaceSplit(n);case"Metaspace":return new MetaspacePreTokenizer(n);case"ByteLevel":return new ByteLevelPreTokenizer(n);case"Split":return new SplitPreTokenizer(n);case"Punctuation":return new PunctuationPreTokenizer(n);case"Digits":return new DigitsPreTokenizer(n);case"Replace":return new ReplacePreTokenizer(n);default:throw new Error(`Unknown PreTokenizer type: ${n.type}`)}}pre_tokenize_text(n,o){throw Error("pre_tokenize_text should be implemented in subclass.")}pre_tokenize(n,o){return(Array.isArray(n)?n.map(s=>this.pre_tokenize_text(s,o)):this.pre_tokenize_text(n,o)).flat()}_call(n,o){return this.pre_tokenize(n,o)}}class BertPreTokenizer extends PreTokenizer{constructor(n){super(),this.pattern=new RegExp(`[^\\s${PUNCTUATION_REGEX}]+|[${PUNCTUATION_REGEX}]`,"gu")}pre_tokenize_text(n,o){return n.trim().match(this.pattern)||[]}}class ByteLevelPreTokenizer extends PreTokenizer{constructor(n){super(),this.config=n,this.add_prefix_space=this.config.add_prefix_space,this.trim_offsets=this.config.trim_offsets,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=BYTES_TO_UNICODE,this.text_encoder=new TextEncoder}pre_tokenize_text(n,o){return this.add_prefix_space&&!n.startsWith(" ")&&(n=" "+n),(this.use_regex?n.match(this.pattern)||[]:[n]).map(l=>Array.from(this.text_encoder.encode(l),f=>this.byte_encoder[f]).join(""))}}class SplitPreTokenizer extends PreTokenizer{constructor(n){super(),this.config=n,this.pattern=createPattern(this.config.pattern,this.config.invert)}pre_tokenize_text(n,o){return this.pattern===null?[]:this.config.invert?n.match(this.pattern)||[]:regexSplit(n,this.pattern)}}class PunctuationPreTokenizer extends PreTokenizer{constructor(n){super(),this.config=n,this.pattern=new RegExp(`[^${PUNCTUATION_REGEX}]+|[${PUNCTUATION_REGEX}]+`,"gu")}pre_tokenize_text(n,o){return n.match(this.pattern)||[]}}class DigitsPreTokenizer extends PreTokenizer{constructor(n){super(),this.config=n;const o=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(o,"gu")}pre_tokenize_text(n,o){return n.match(this.pattern)||[]}}class PostProcessor extends Callable{constructor(n){super(),this.config=n}static fromConfig(n){if(n===null)return null;switch(n.type){case"TemplateProcessing":return new TemplateProcessing(n);case"ByteLevel":return new ByteLevelPostProcessor(n);case"RobertaProcessing":return new RobertaProcessing(n);case"BertProcessing":return new BertProcessing(n);default:throw new Error(`Unknown PostProcessor type: ${n.type}`)}}post_process(n,...o){throw Error("post_process should be implemented in subclass.")}_call(n,...o){return this.post_process(n,...o)}}class BertProcessing extends PostProcessor{constructor(n){super(n),this.cls=n.cls[0],this.sep=n.sep[0]}post_process(n,o=null,{add_special_tokens:s=!0}={}){s&&(n=mergeArrays([this.cls],n,[this.sep]));let l=new Array(n.length).fill(0);if(o!==null){const f=s&&this instanceof RobertaProcessing?[this.sep]:[],u=s?[this.sep]:[];n=mergeArrays(n,f,o,u),l=mergeArrays(l,new Array(o.length+f.length+u.length).fill(1))}return{tokens:n,token_type_ids:l}}}class RobertaProcessing extends BertProcessing{}class TemplateProcessing extends PostProcessor{constructor(n){super(n),this.single=n.single,this.pair=n.pair}post_process(n,o=null,{add_special_tokens:s=!0}={}){const l=o===null?this.single:this.pair;let f=[],u=[];for(const p of l)"SpecialToken"in p?s&&(f.push(p.SpecialToken.id),u.push(p.SpecialToken.type_id)):"Sequence"in p&&(p.Sequence.id==="A"?(f=mergeArrays(f,n),u=mergeArrays(u,new Array(n.length).fill(p.Sequence.type_id))):p.Sequence.id==="B"&&(f=mergeArrays(f,o),u=mergeArrays(u,new Array(o.length).fill(p.Sequence.type_id))));return{tokens:f,token_type_ids:u}}}class ByteLevelPostProcessor extends PostProcessor{post_process(n,o=null){return o&&(n=mergeArrays(n,o)),{tokens:n}}}class Decoder extends Callable{constructor(n){super(),this.config=n,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=n.trim_offsets}static fromConfig(n){if(n===null)return null;switch(n.type){case"WordPiece":return new WordPieceDecoder(n);case"Metaspace":return new MetaspaceDecoder(n);case"ByteLevel":return new ByteLevelDecoder(n);case"Replace":return new ReplaceDecoder(n);case"ByteFallback":return new ByteFallback(n);case"Fuse":return new FuseDecoder(n);case"Strip":return new StripDecoder(n);case"Sequence":return new DecoderSequence(n);case"CTC":return new CTCDecoder(n);case"BPEDecoder":return new BPEDecoder(n);default:throw new Error(`Unknown Decoder type: ${n.type}`)}}_call(n){return this.decode(n)}decode(n){return this.decode_chain(n).join("")}decode_chain(n){throw Error("`decode_chain` should be implemented in subclass.")}}class ReplaceDecoder extends Decoder{decode_chain(n){const o=createPattern(this.config.pattern);return o===null?n:n.map(s=>s.replaceAll(o,this.config.content))}}class ByteFallback extends Decoder{constructor(n){super(n),this.text_decoder=new TextDecoder}decode_chain(n){const o=[];let s=[];for(const l of n){let f=null;if(l.length===6&&l.startsWith("<0x")&&l.endsWith(">")){const u=parseInt(l.slice(3,5),16);isNaN(u)||(f=u)}if(f!==null)s.push(f);else{if(s.length>0){const u=this.text_decoder.decode(Uint8Array.from(s));o.push(u),s=[]}o.push(l)}}if(s.length>0){const l=this.text_decoder.decode(Uint8Array.from(s));o.push(l),s=[]}return o}}class FuseDecoder extends Decoder{decode_chain(n){return[n.join("")]}}class StripDecoder extends Decoder{constructor(n){super(n),this.content=this.config.content,this.start=this.config.start,this.stop=this.config.stop}decode_chain(n){return n.map(o=>{let s=0;for(let f=0;f<this.start&&o[f]===this.content;++f){s=f+1;continue}let l=o.length;for(let f=0;f<this.stop;++f){const u=o.length-f-1;if(o[u]===this.content){l=u;continue}else break}return o.slice(s,l)})}}class WordPieceDecoder extends Decoder{constructor(n){super(n),this.cleanup=n.cleanup}decode_chain(n){return n.map((o,s)=>(s!==0&&(o.startsWith(this.config.prefix)?o=o.replace(this.config.prefix,""):o=" "+o),this.cleanup&&(o=clean_up_tokenization(o)),o))}}class ByteLevelDecoder extends Decoder{constructor(n){super(n),this.byte_decoder=UNICODE_TO_BYTES,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(n){const o=n.join(""),s=new Uint8Array([...o].map(f=>this.byte_decoder[f]));return this.text_decoder.decode(s)}decode_chain(n){const o=[];let s=[];for(const l of n)this.added_tokens.find(f=>f.content===l)!==void 0?(s.length>0&&(o.push(this.convert_tokens_to_string(s)),s=[]),o.push(l)):s.push(l);return s.length>0&&o.push(this.convert_tokens_to_string(s)),o}}class CTCDecoder extends Decoder{constructor(n){super(n),this.pad_token=this.config.pad_token,this.word_delimiter_token=this.config.word_delimiter_token,this.cleanup=this.config.cleanup}convert_tokens_to_string(n){if(n.length===0)return"";const o=[n[0]];for(let f=1;f<n.length;++f)n[f]!==o.at(-1)&&o.push(n[f]);let l=o.filter(f=>f!==this.pad_token).join("");return this.cleanup&&(l=clean_up_tokenization(l).replaceAll(this.word_delimiter_token," ").trim()),l}decode_chain(n){return[this.convert_tokens_to_string(n)]}}class DecoderSequence extends Decoder{constructor(n){super(n),this.decoders=n.decoders.map(o=>Decoder.fromConfig(o))}decode_chain(n){return this.decoders.reduce((o,s)=>s.decode_chain(o),n)}}class BPEDecoder extends Decoder{constructor(n){super(n),this.suffix=this.config.suffix}decode_chain(n){return n.map((o,s)=>o.replaceAll(this.suffix,s===n.length-1?"":" "))}}class VitsDecoder extends Decoder{decode_chain(n){let o="";for(let s=1;s<n.length;s+=2)o+=n[s];return[o]}}class MetaspacePreTokenizer extends PreTokenizer{constructor(n){super(),this.addPrefixSpace=n.add_prefix_space,this.replacement=n.replacement,this.strRep=n.str_rep||this.replacement,this.prepend_scheme=n.prepend_scheme??"always"}pre_tokenize_text(n,{section_index:o=void 0}={}){let s=n.replaceAll(" ",this.strRep);return this.addPrefixSpace&&!s.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&o===0)&&(s=this.strRep+s),[s]}}class MetaspaceDecoder extends Decoder{constructor(n){super(n),this.addPrefixSpace=n.add_prefix_space,this.replacement=n.replacement}decode_chain(n){const o=[];for(let s=0;s<n.length;++s){let l=n[s].replaceAll(this.replacement," ");this.addPrefixSpace&&s==0&&l.startsWith(" ")&&(l=l.substring(1)),o.push(l)}return o}}class Precompiled extends Normalizer{constructor(n){super(n),this.charsmap=n.precompiled_charsmap}normalize(n){return n=n.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,""),n=n.replace(/[\u0009\u000A\u000C\u000D\u1680\u200B\u200C\u200E\u200F\u2028\u2029\u2581\uFEFF\uFFFD]/gm," "),n.includes("~")?n=n.split("~").map(s=>s.normalize("NFKC")).join("~"):n=n.normalize("NFKC"),n}}class PreTokenizerSequence extends PreTokenizer{constructor(n){super(),this.tokenizers=n.pretokenizers.map(o=>PreTokenizer.fromConfig(o))}pre_tokenize_text(n,o){return this.tokenizers.reduce((s,l)=>l.pre_tokenize(s,o),[n])}}class WhitespacePreTokenizer extends PreTokenizer{constructor(n){super()}pre_tokenize_text(n,o){return n.match(/\w+|[^\w\s]+/g)||[]}}class WhitespaceSplit extends PreTokenizer{constructor(n){super()}pre_tokenize_text(n,o){return whitespace_split(n)}}class ReplacePreTokenizer extends PreTokenizer{constructor(n){super(),this.config=n,this.pattern=createPattern(this.config.pattern),this.content=this.config.content}pre_tokenize_text(n,o){return this.pattern===null?[n]:[n.replaceAll(this.pattern,this.config.content)]}}const SPECIAL_TOKEN_ATTRIBUTES=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function padHelper(d,n,o,s){for(const l of Object.keys(d)){const f=n-d[l].length,u=o(l),p=new Array(f).fill(u);d[l]=s==="right"?mergeArrays(d[l],p):mergeArrays(p,d[l])}}function truncateHelper(d,n){for(const o of Object.keys(d))d[o].length=n}class PreTrainedTokenizer extends Callable{constructor(o,s){super();J(this,"return_token_type_ids",!1);J(this,"_default_chat_template",`{% for message in messages %}{{'<|im_start|>' + message['role'] + ' +' + message['content'] + '<|im_end|>' + ' +'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant +' }}{% endif %}`);this._tokenizer_config=s,this.normalizer=Normalizer.fromConfig(o.normalizer),this.pre_tokenizer=PreTokenizer.fromConfig(o.pre_tokenizer),this.model=TokenizerModel.fromConfig(o.model,s),this.post_processor=PostProcessor.fromConfig(o.post_processor),this.decoder=Decoder.fromConfig(o.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];for(const l of o.added_tokens){const f=new AddedToken(l);this.added_tokens.push(f),this.model.tokens_to_ids.set(f.content,f.id),this.model.vocab[f.id]=f.content,f.special&&(this.special_tokens.push(f.content),this.all_special_ids.push(f.id))}if(this.additional_special_tokens=s.additional_special_tokens??[],this.special_tokens.push(...this.additional_special_tokens),this.special_tokens=[...new Set(this.special_tokens)],this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.added_tokens_regex=this.added_tokens.length>0?new RegExp(this.added_tokens.map(l=>`${l.lstrip?"\\s*":""}(${escapeRegExp(l.content)})${l.rstrip?"\\s*":""}`).join("|")):null,this.mask_token=this.getToken("mask_token"),this.mask_token_id=this.model.tokens_to_ids.get(this.mask_token),this.pad_token=this.getToken("pad_token","eos_token"),this.pad_token_id=this.model.tokens_to_ids.get(this.pad_token),this.sep_token=this.getToken("sep_token"),this.sep_token_id=this.model.tokens_to_ids.get(this.sep_token),this.unk_token=this.getToken("unk_token"),this.unk_token_id=this.model.tokens_to_ids.get(this.unk_token),this.model_max_length=s.model_max_length,this.remove_space=s.remove_space,this.clean_up_tokenization_spaces=s.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=s.do_lowercase_and_remove_accent??!1,this.padding_side="right",this.legacy=!1,this.chat_template=s.chat_template??null,Array.isArray(this.chat_template)){const l=Object.create(null);for(const{name:f,template:u}of this.chat_template){if(typeof f!="string"||typeof u!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');l[f]=u}this.chat_template=l}this._compiled_template_cache=new Map}getToken(...o){for(const s of o){const l=this._tokenizer_config[s];if(l)if(typeof l=="object"){if(l.__type==="AddedToken")return l.content;throw Error(`Unknown token: ${l}`)}else return l}return null}static async from_pretrained(o,{progress_callback:s=null,config:l=null,cache_dir:f=null,local_files_only:u=!1,revision:p="main",legacy:g=null}={}){const c=await loadTokenizer(o,{progress_callback:s,config:l,cache_dir:f,local_files_only:u,revision:p,legacy:g});return new this(...c)}_call(o,{text_pair:s=null,add_special_tokens:l=!0,padding:f=!1,truncation:u=null,max_length:p=null,return_tensor:g=!0}={}){const c=Array.isArray(o);let a;if(c){if(o.length===0)throw Error("text array must be non-empty");if(s!==null){if(Array.isArray(s)){if(o.length!==s.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");a=o.map((e,r)=>this._encode_plus(e,s[r],{add_special_tokens:l}))}else a=o.map(e=>this._encode_plus(e,null,{add_special_tokens:l}))}else{if(o==null)throw Error("text may not be null or undefined");if(Array.isArray(s))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");a=[this._encode_plus(o,s,{add_special_tokens:l})]}if(p===null?f==="max_length"?p=this.model_max_length:p=max(a.map(e=>e.input_ids.length))[0]:u||console.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation=true` to explicitly truncate examples to max length."),p=Math.min(p,this.model_max_length),f||u)for(let e=0;e<a.length;++e)a[e].input_ids.length!==p&&(a[e].input_ids.length>p?u&&truncateHelper(a[e],p):f&&padHelper(a[e],p,r=>r==="input_ids"?this.pad_token_id:0,this.padding_side));const t={};if(g){if(!(f&&u)&&a.some(r=>{var i;for(const h of Object.keys(r))if(r[h].length!==((i=a[0][h])==null?void 0:i.length))return!0;return!1}))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");const e=[a.length,a[0].input_ids.length];for(const r of Object.keys(a[0]))t[r]=new Tensor("int64",BigInt64Array.from(a.flatMap(i=>i[r]).map(BigInt)),e)}else{for(const e of Object.keys(a[0]))t[e]=a.map(r=>r[e]);if(!c)for(const e of Object.keys(t))t[e]=t[e][0]}return t}_encode_text(o){return o===null?null:(this.added_tokens_regex?o.split(this.added_tokens_regex).filter(f=>f):[o]).map((f,u)=>{if(this.added_tokens.find(g=>g.content===f)!==void 0)return f;{if(this.remove_space===!0&&(f=f.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(f=lowercase_and_remove_accent(f)),this.normalizer!==null&&(f=this.normalizer(f)),f.length===0)return[];const g=this.pre_tokenizer!==null?this.pre_tokenizer(f,{section_index:u}):[f];return this.model(g)}}).flat()}_encode_plus(o,s=null,{add_special_tokens:l=!0}={}){const f=this._encode_text(o),u=this._encode_text(s),p=this.post_processor?this.post_processor(f,u,{add_special_tokens:l}):{tokens:mergeArrays(f??[],u??[])},g=this.model.convert_tokens_to_ids(p.tokens),c={input_ids:g,attention_mask:new Array(g.length).fill(1)};return this.return_token_type_ids&&p.token_type_ids&&(c.token_type_ids=p.token_type_ids),c}encode(o,s=null,{add_special_tokens:l=!0}={}){const{input_ids:f}=this._encode_plus(o,s,{add_special_tokens:l});return f}batch_decode(o,s={}){return o instanceof Tensor&&(o=o.tolist()),o.map(l=>this.decode(l,s))}decode(o,s={}){if(o instanceof Tensor&&(o=prepareTensorForDecode(o)),!Array.isArray(o)||o.length===0||!isIntegralNumber(o[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(o,s)}decode_single(o,{skip_special_tokens:s=!1,clean_up_tokenization_spaces:l=null}){let f=this.model.convert_ids_to_tokens(o);s&&(f=f.filter(p=>!this.special_tokens.includes(p)));let u=this.decoder?this.decoder(f):f.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(u=u.replaceAll(this.decoder.end_of_word_suffix," "),s&&(u=u.trim())),(l??this.clean_up_tokenization_spaces)&&(u=clean_up_tokenization(u)),u}get default_chat_template(){return this._warned_about_chat_template||(console.warn("No chat template is defined for this tokenizer - using a default chat template that implements the ChatML format. If the default is not appropriate for your model, please set `tokenizer.chat_template` to an appropriate template. See https://huggingface.co/docs/transformers/main/chat_templating for more information."),this._warned_about_chat_template=!0),this._default_chat_template}apply_chat_template(o,{chat_template:s=null,add_generation_prompt:l=!1,tokenize:f=!0,padding:u=!1,truncation:p=!1,max_length:g=null,return_tensor:c=!0,tokenizer_kwargs:a={},...t}={}){if(this.chat_template&&typeof this.chat_template=="object"||this.chat_template===null&&this.default_chat_template&&typeof this.default_chat_template=="object"){const h=this.chat_template??this.default_chat_template;if(s!==null&&Object.hasOwn(h,s))s=h[s];else if(s===null&&"default"in h)s=h.default;else if(s===null)throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(h).sort()}.`)}else s??(s=this.chat_template??this.default_chat_template);if(typeof s!="string")throw Error(`chat_template must be a string, but got ${typeof s}`);let e=this._compiled_template_cache.get(s);e===void 0&&(e=new Template(s),this._compiled_template_cache.set(s,e));const r=Object.create(null);for(const h of SPECIAL_TOKEN_ATTRIBUTES){const m=this.getToken(h);m&&(r[h]=m)}const i=e.render({messages:o,add_generation_prompt:l,...r,...t});return f?this._call(i,{add_special_tokens:!1,padding:u,truncation:p,max_length:g,return_tensor:c,...a}).input_ids:i}}class BertTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class AlbertTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class MobileBertTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class SqueezeBertTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class DebertaTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class DebertaV2Tokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class HerbertTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class ConvBertTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class RoFormerTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class DistilBertTokenizer extends PreTrainedTokenizer{}class CamembertTokenizer extends PreTrainedTokenizer{}class XLMTokenizer extends PreTrainedTokenizer{constructor(o,s){super(o,s);J(this,"return_token_type_ids",!0);console.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}}class ElectraTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"return_token_type_ids",!0)}}class T5Tokenizer extends PreTrainedTokenizer{}class GPT2Tokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"_default_chat_template",'{% for message in messages %}" "{{ message.content }}{{ eos_token }}" "{% endfor %}')}}class BartTokenizer extends PreTrainedTokenizer{}class MBartTokenizer extends PreTrainedTokenizer{constructor(n,o){super(n,o),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(n,o,s){return _build_translation_inputs(this,n,o,s)}}class MBart50Tokenizer extends MBartTokenizer{}class RobertaTokenizer extends PreTrainedTokenizer{}class BloomTokenizer extends GPT2Tokenizer{constructor(n,o){var f,u;const s=".,!?…。,、।۔،",l=(u=(f=n.pre_tokenizer)==null?void 0:f.pretokenizers[0])==null?void 0:u.pattern;l&&l.Regex===` ?[^(\\s|[${s}])]+`&&(l.Regex=` ?[^\\s${s}]+`),super(n,o)}}const SPIECE_UNDERLINE="▁";class LlamaTokenizer extends PreTrainedTokenizer{constructor(o,s){super(o,s);J(this,"_default_chat_template",`{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% elif USE_DEFAULT_PROMPT == true and not '<<SYS>>' in messages[0]['content'] %}{% set loop_messages = messages %}{% set system_message = 'DEFAULT_SYSTEM_MESSAGE' %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>> +' + system_message + ' +<</SYS>> + +' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'system' %}{{ '<<SYS>> +' + content.strip() + ' +<</SYS>> + +' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}`);J(this,"DEFAULT_SYSTEM_PROMPT",`You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. + +If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.`);this.use_default_system_prompt=s.use_default_system_prompt??!1,this.legacy=s.legacy??!0,this.legacy||(this.normalizer=null,this.pre_tokenizer=new MetaspacePreTokenizer({replacement:SPIECE_UNDERLINE,add_prefix_space:!0,prepend_scheme:"first"}))}_encode_text(o){if(o===null)return null;if(this.legacy||o.length===0)return super._encode_text(o);let s=super._encode_text(SPIECE_UNDERLINE+o.replaceAll(SPIECE_UNDERLINE," "));return s.length>1&&s[0]===SPIECE_UNDERLINE&&this.special_tokens.includes(s[1])&&(s=s.slice(1)),s}get default_chat_template(){return super.default_chat_template.replaceAll("USE_DEFAULT_PROMPT",this.use_default_system_prompt?"true":"false").replaceAll("DEFAULT_SYSTEM_MESSAGE",this.DEFAULT_SYSTEM_PROMPT.replaceAll(` +`,"\\n").replaceAll("'","\\'"))}}class CodeLlamaTokenizer extends LlamaTokenizer{}class XLMRobertaTokenizer extends PreTrainedTokenizer{}class MPNetTokenizer extends PreTrainedTokenizer{}class FalconTokenizer extends PreTrainedTokenizer{}class GPTNeoXTokenizer extends PreTrainedTokenizer{}class EsmTokenizer extends PreTrainedTokenizer{}class Qwen2Tokenizer extends PreTrainedTokenizer{}class GemmaTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"_default_chat_template",`{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% endif %}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '<start_of_turn>' + role + ' +' + message['content'] | trim + '<end_of_turn> +' }}{% endfor %}{% if add_generation_prompt %}{{'<start_of_turn>model +'}}{% endif %}`)}}class Grok1Tokenizer extends PreTrainedTokenizer{}function _build_translation_inputs(d,n,o,s){if(!("language_codes"in d)||!Array.isArray(d.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in d)||!(d.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in d)||typeof d.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");const l=s.src_lang,f=s.tgt_lang;if(!d.language_codes.includes(f))throw new Error(`Target language code "${f}" is not valid. Must be one of: {${d.language_codes.join(", ")}}`);if(l!==void 0){if(!d.language_codes.includes(l))throw new Error(`Source language code "${l}" is not valid. Must be one of: {${d.language_codes.join(", ")}}`);for(const u of d.post_processor.config.single)if("SpecialToken"in u&&d.languageRegex.test(u.SpecialToken.id)){u.SpecialToken.id=d.lang_to_token(l);break}}return s.forced_bos_token_id=d.model.convert_tokens_to_ids([d.lang_to_token(f)])[0],d._call(n,o)}class NllbTokenizer extends PreTrainedTokenizer{constructor(n,o){super(n,o),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(n,o,s){return _build_translation_inputs(this,n,o,s)}}class M2M100Tokenizer extends PreTrainedTokenizer{constructor(n,o){super(n,o),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s.slice(2,-2)),this.lang_to_token=s=>`__${s}__`}_build_translation_inputs(n,o,s){return _build_translation_inputs(this,n,o,s)}}const WHISPER_LANGUAGES=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["ar","arabic"],["sv","swedish"],["it","italian"],["id","indonesian"],["hi","hindi"],["fi","finnish"],["vi","vietnamese"],["he","hebrew"],["uk","ukrainian"],["el","greek"],["ms","malay"],["cs","czech"],["ro","romanian"],["da","danish"],["hu","hungarian"],["ta","tamil"],["no","norwegian"],["th","thai"],["ur","urdu"],["hr","croatian"],["bg","bulgarian"],["lt","lithuanian"],["la","latin"],["mi","maori"],["ml","malayalam"],["cy","welsh"],["sk","slovak"],["te","telugu"],["fa","persian"],["lv","latvian"],["bn","bengali"],["sr","serbian"],["az","azerbaijani"],["sl","slovenian"],["kn","kannada"],["et","estonian"],["mk","macedonian"],["br","breton"],["eu","basque"],["is","icelandic"],["hy","armenian"],["ne","nepali"],["mn","mongolian"],["bs","bosnian"],["kk","kazakh"],["sq","albanian"],["sw","swahili"],["gl","galician"],["mr","marathi"],["pa","punjabi"],["si","sinhala"],["km","khmer"],["sn","shona"],["yo","yoruba"],["so","somali"],["af","afrikaans"],["oc","occitan"],["ka","georgian"],["be","belarusian"],["tg","tajik"],["sd","sindhi"],["gu","gujarati"],["am","amharic"],["yi","yiddish"],["lo","lao"],["uz","uzbek"],["fo","faroese"],["ht","haitian creole"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],WHISPER_LANGUAGE_MAPPING=new Map(WHISPER_LANGUAGES),WHISPER_TO_LANGUAGE_CODE_MAPPING=new Map([...WHISPER_LANGUAGES.map(([d,n])=>[n,d]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);class WhisperTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"_default_chat_template",'{% for message in messages %}" "{{ message.content }}{{ eos_token }}" "{% endfor %}')}_decode_asr(o,{return_timestamps:s=!1,return_language:l=!1,time_precision:f=null,force_full_sequences:u=!0}={}){if(f===null)throw Error("Must specify time_precision");let p=null;const g=s==="word";function c(){return{language:p,timestamp:[null,null],text:""}}const a=[];let t=c(),e=0;const r=this.model.convert_tokens_to_ids(["<|notimestamps|>"])[0]+1;let i=[],h=[],m=!1,_=null;const b=new Set(this.all_special_ids);for(const w of o){const S=w.tokens,E=g?w.token_timestamps:null;let O=null,v=r;if("stride"in w){const[V,B,L]=w.stride;if(e-=B,_=V-L,B&&(v=B/f+r),L)for(let D=S.length-1;D>=0;--D){const k=S[D];if(k>=r){if(O!==null&&(k-r)*f<_)break;O=k}}}let M=[],$=[];for(let V=0;V<S.length;++V){const B=S[V];if(b.has(B)){const L=this.decode([B]),D=WHISPER_LANGUAGE_MAPPING.get(L.slice(2,-2));if(D!==void 0){if(p!==null&&D!==p&&!s){i.push(M);const k=this.findLongestCommonSequence(i)[0],F=this.decode(k);t.text=F,a.push(t),i=[],M=[],t=c()}p=t.language=D}}else if(B>=r){const L=(B-r)*f+e,D=round(L,2);if(O!==null&&B>=O)m=!0;else if(m||i.length>0&&B<v)m=!1;else if(t.timestamp[0]===null)t.timestamp[0]=D;else if(D!==t.timestamp[0]){t.timestamp[1]=D,i.push(M),g&&h.push($);const[k,F]=this.findLongestCommonSequence(i,h),Q=this.decode(k);t.text=Q,g&&(t.words=this.collateWordTimestamps(k,F,p)),a.push(t),i=[],M=[],h=[],$=[],t=c()}}else if(M.push(B),g){let L=round(E[V]+e,2),D;V+1<E.length?D=round(E[V+1]+e,2):D=null,$.push([L,D])}}if("stride"in w){const[V,B,L]=w.stride;e+=V-L}M.length>0?(i.push(M),g&&h.push($)):i.every(V=>V.length===0)&&(t=c(),i=[],M=[],h=[],$=[])}if(i.length>0){if(u&&s)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");const[w,S]=this.findLongestCommonSequence(i,h),E=this.decode(w);t.text=E,g&&(t.words=this.collateWordTimestamps(w,S,p)),a.push(t)}let y=Object.create(null);const T=a.map(w=>w.text).join("");if(s||l){for(let w=0;w<a.length;++w){const S=a[w];s||delete S.timestamp,l||delete S.language}if(g){const w=[];for(const S of a)for(const E of S.words)w.push(E);y={chunks:w}}else y={chunks:a}}return[T,y]}findLongestCommonSequence(o,s=null){let l=o[0],f=l.length,u=[];const p=Array.isArray(s)&&s.length>0;let g=p?[]:null,c=p?s[0]:null;for(let a=1;a<o.length;++a){const t=o[a];let e=0,r=[f,f,0,0];const i=t.length;for(let w=1;w<f+i;++w){const S=w/1e4,E=Math.max(0,f-w),O=Math.min(f,f+i-w),v=l.slice(E,O),M=Math.max(0,w-f),$=Math.min(i,w),V=t.slice(M,$);if(v.length!==V.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");const B=v.filter((D,k)=>D===V[k]).length,L=B/w+S;B>1&&L>e&&(e=L,r=[E,O,M,$])}const[h,m,_,b]=r,y=Math.floor((m+h)/2),T=Math.floor((b+_)/2);u.push(...l.slice(0,y)),l=t.slice(T),f=l.length,p&&(g.push(...c.slice(0,y)),c=s[a].slice(T))}return u.push(...l),p?(g.push(...c),[u,g]):[u,[]]}collateWordTimestamps(o,s,l){const[f,u,p]=this.combineTokensIntoWords(o,l),g=[];for(let c=0;c<f.length;++c){const a=p[c];g.push({text:f[c],timestamp:[s[a.at(0)][0],s[a.at(-1)][1]]})}return g}combineTokensIntoWords(o,s,l=`"'“¡¿([{-`,f=`"'.。,,!!??::”)]}、`){s=s??"english";let u,p,g;return["chinese","japanese","thai","lao","myanmar"].includes(s)?[u,p,g]=this.splitTokensOnUnicode(o):[u,p,g]=this.splitTokensOnSpaces(o),this.mergePunctuations(u,p,g,l,f)}decode(o,s){let l;return s&&s.decode_with_timestamps?(o instanceof Tensor&&(o=prepareTensorForDecode(o)),l=this.decodeWithTimestamps(o,s)):l=super.decode(o,s),l}decodeWithTimestamps(o,s){const l=(s==null?void 0:s.time_precision)??.02,f=Array.from(this.all_special_ids).at(-1)+1;let u=[[]];for(const p of o)if(p>=f){const g=round((p-f)*l,2);u.push(`<|${g}|>`),u.push([])}else u[u.length-1].push(p);return u=u.map(p=>typeof p=="string"?p:super.decode(p,s)),u.join("")}splitTokensOnUnicode(o){const s=this.decode(o,{decode_with_timestamps:!0}),l="�",f=[],u=[],p=[];let g=[],c=[],a=0;for(let t=0;t<o.length;++t){const e=o[t];g.push(e),c.push(t);const r=this.decode(g,{decode_with_timestamps:!0});(!r.includes(l)||s[a+r.indexOf(l)]===l)&&(f.push(r),u.push(g),p.push(c),g=[],c=[],a+=r.length)}return[f,u,p]}splitTokensOnSpaces(o){const[s,l,f]=this.splitTokensOnUnicode(o),u=[],p=[],g=[],c=new RegExp(`^[${PUNCTUATION_REGEX}]$`,"gu");for(let a=0;a<s.length;++a){const t=s[a],e=l[a],r=f[a],i=e[0]>=this.model.tokens_to_ids.get("<|endoftext|>"),h=t.startsWith(" "),m=t.trim(),_=c.test(m);if(i||h||_||u.length===0)u.push(t),p.push(e),g.push(r);else{const b=u.length-1;u[b]+=t,p[b].push(...e),g[b].push(...r)}}return[u,p,g]}mergePunctuations(o,s,l,f,u){const p=structuredClone(o),g=structuredClone(s),c=structuredClone(l);let a=p.length-2,t=p.length-1;for(;a>=0;)p[a].startsWith(" ")&&f.includes(p[a].trim())?(p[t]=p[a]+p[t],g[t]=mergeArrays(g[a],g[t]),c[t]=mergeArrays(c[a],c[t]),p[a]="",g[a]=[],c[a]=[]):t=a,--a;for(a=0,t=1;t<p.length;)!p[a].endsWith(" ")&&u.includes(p[t])?(p[a]+=p[t],g[a]=mergeArrays(g[a],g[t]),c[a]=mergeArrays(c[a],c[t]),p[t]="",g[t]=[],c[t]=[]):a=t,++t;return[p.filter(e=>e),g.filter(e=>e.length>0),c.filter(e=>e.length>0)]}get_decoder_prompt_ids({language:o=null,task:s=null,no_timestamps:l=!0}={}){const f=[];if(o){o=o.toLowerCase();let u=WHISPER_TO_LANGUAGE_CODE_MAPPING.get(o);if(u===void 0)if(WHISPER_LANGUAGE_MAPPING.has(o))u=o;else{const c=o.length===2?WHISPER_LANGUAGE_MAPPING.keys():WHISPER_LANGUAGE_MAPPING.values();throw new Error(`Language "${o}" is not supported. Must be one of: ${JSON.stringify(c)}`)}const p=this.model.tokens_to_ids.get(`<|${u}|>`);if(p===void 0)throw new Error(`Unable to find language "${u}" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.`);f.push(p)}else f.push(null);if(s){if(s=s.toLowerCase(),s!=="transcribe"&&s!=="translate")throw new Error(`Task "${s}" is not supported. Must be one of: ["transcribe", "translate"]`);const u=this.model.tokens_to_ids.get(`<|${s}|>`);if(u===void 0)throw new Error(`Unable to find task "${s}" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.`);f.push(u)}else f.push(null);if(l){const u=this.model.tokens_to_ids.get("<|notimestamps|>");if(u===void 0)throw new Error('Unable to find "<|notimestamps|>" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.');f.push(u)}return f.map((u,p)=>[p+1,u]).filter(u=>u[1]!==null)}}class CodeGenTokenizer extends PreTrainedTokenizer{}class CLIPTokenizer extends PreTrainedTokenizer{}class SiglipTokenizer extends PreTrainedTokenizer{}class MarianTokenizer extends PreTrainedTokenizer{constructor(n,o){super(n,o),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=this.model.vocab.filter(s=>this.languageRegex.test(s)),console.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(n){if(n===null)return null;const[o,...s]=n.trim().split(this.languageRegex);if(s.length===0)return super._encode_text(o);if(s.length===2){const[l,f]=s;return this.supported_language_codes.includes(l)||console.warn(`Unsupported language code "${l}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),mergeArrays([l],super._encode_text(f))}}}class Wav2Vec2CTCTokenizer extends PreTrainedTokenizer{}class BlenderbotTokenizer extends PreTrainedTokenizer{constructor(){super(...arguments);J(this,"_default_chat_template","{% for message in messages %}{% if message['role'] == 'user' %}{{ ' ' }}{% endif %}{{ message['content'] }}{% if not loop.last %}{{ ' ' }}{% endif %}{% endfor %}{{ eos_token }}")}}class BlenderbotSmallTokenizer extends BlenderbotTokenizer{}class SpeechT5Tokenizer extends PreTrainedTokenizer{}class NougatTokenizer extends PreTrainedTokenizer{}class VitsTokenizer extends PreTrainedTokenizer{constructor(n,o){super(n,o),this.decoder=new VitsDecoder({})}}class CohereTokenizer extends PreTrainedTokenizer{}class AutoTokenizer{static async from_pretrained(n,{quantized:o=!0,progress_callback:s=null,config:l=null,cache_dir:f=null,local_files_only:u=!1,revision:p="main",legacy:g=null}={}){var r;const[c,a]=await loadTokenizer(n,{quantized:o,progress_callback:s,config:l,cache_dir:f,local_files_only:u,revision:p,legacy:g}),t=((r=a.tokenizer_class)==null?void 0:r.replace(/Fast$/,""))??"PreTrainedTokenizer";let e=this.TOKENIZER_CLASS_MAPPING[t];return e||(console.warn(`Unknown tokenizer class "${t}", attempting to construct from base class.`),e=PreTrainedTokenizer),new e(c,a)}}J(AutoTokenizer,"TOKENIZER_CLASS_MAPPING",{T5Tokenizer,DistilBertTokenizer,CamembertTokenizer,DebertaTokenizer,DebertaV2Tokenizer,BertTokenizer,HerbertTokenizer,ConvBertTokenizer,RoFormerTokenizer,XLMTokenizer,ElectraTokenizer,MobileBertTokenizer,SqueezeBertTokenizer,AlbertTokenizer,GPT2Tokenizer,BartTokenizer,MBartTokenizer,MBart50Tokenizer,RobertaTokenizer,WhisperTokenizer,CodeGenTokenizer,CLIPTokenizer,SiglipTokenizer,MarianTokenizer,BloomTokenizer,NllbTokenizer,M2M100Tokenizer,LlamaTokenizer,CodeLlamaTokenizer,XLMRobertaTokenizer,MPNetTokenizer,FalconTokenizer,GPTNeoXTokenizer,EsmTokenizer,Wav2Vec2CTCTokenizer,BlenderbotTokenizer,BlenderbotSmallTokenizer,SpeechT5Tokenizer,NougatTokenizer,VitsTokenizer,Qwen2Tokenizer,GemmaTokenizer,Grok1Tokenizer,CohereTokenizer,PreTrainedTokenizer});async function loadConfig(d,n){return await getModelJSON(d,"config.json",!0,n)}class PretrainedConfig{constructor(n){this.model_type=null,this.is_encoder_decoder=!1,Object.assign(this,n)}static async from_pretrained(n,{progress_callback:o=null,config:s=null,cache_dir:l=null,local_files_only:f=!1,revision:u="main"}={}){let p=s??await loadConfig(n,{progress_callback:o,config:s,cache_dir:l,local_files_only:f,revision:u});return new this(p)}}class AutoConfig{static async from_pretrained(...n){return PretrainedConfig.from_pretrained(...n)}}class LogitsProcessorList extends Callable{constructor(){super(),this.processors=[]}push(n){this.processors.push(n)}extend(n){this.processors.push(...n)}_call(n,o){for(let s of o)this.processors.forEach(l=>l(n,s))}[Symbol.iterator](){return this.processors.values()}}class LogitsProcessor extends Callable{_call(n,o){throw Error("`_call` should be implemented in a subclass")}}class ForceTokensLogitsProcessor extends LogitsProcessor{constructor(n){super(),this.force_token_map=Object.fromEntries(n??[])}_call(n,o){let s=this.force_token_map[n.length];return exists(s)&&(o.data.fill(-1/0),o.data[s]=0),o}}class ForcedBOSTokenLogitsProcessor extends LogitsProcessor{constructor(n){super(),this.bos_token_id=n}_call(n,o){return n.length===1&&(o.data.fill(-1/0),o.data[this.bos_token_id]=0),o}}class ForcedEOSTokenLogitsProcessor extends LogitsProcessor{constructor(n,o){super(),this.max_length=n,this.forced_eos_token_id=o}_call(n,o){}}class SuppressTokensAtBeginLogitsProcessor extends LogitsProcessor{constructor(n,o){super(),this.begin_suppress_tokens=n,this.begin_index=o}_call(n,o){if(n.length===this.begin_index)for(let s of this.begin_suppress_tokens)o.data[s]=-1/0;return o}}class WhisperTimeStampLogitsProcessor extends LogitsProcessor{constructor(n){super(),this.eos_token_id=n.eos_token_id,this.no_timestamps_token_id=n.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=(n.forced_decoder_ids||[]).length+2,n.forced_decoder_ids.slice(-1)[0][1]===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=n.max_initial_timestamp_index}_call(n,o){const s=o.data;if(s[this.no_timestamps_token_id]=-1/0,n.length===this.begin_index-1)return s.fill(-1/0),s[this.timestamp_begin]=0,o;const l=n.slice(this.begin_index),f=l.length>=1&&l[l.length-1]>=this.timestamp_begin,u=l.length<2||l[l.length-2]>=this.timestamp_begin;if(f&&(u?s.subarray(this.timestamp_begin).fill(-1/0):s.subarray(0,this.eos_token_id).fill(-1/0)),n.length===this.begin_index&&this.max_initial_timestamp_index!==null){const a=this.timestamp_begin+this.max_initial_timestamp_index;s.subarray(a+1).fill(-1/0)}const p=log_softmax(s),g=Math.log(p.subarray(this.timestamp_begin).map(Math.exp).reduce((a,t)=>a+t)),c=max(p.subarray(0,this.timestamp_begin))[0];return g>c&&s.subarray(0,this.timestamp_begin).fill(-1/0),o}}class NoRepeatNGramLogitsProcessor extends LogitsProcessor{constructor(n){super(),this.no_repeat_ngram_size=n}getNgrams(n){const o=n.length,s=[];for(let f=0;f<o+1-this.no_repeat_ngram_size;++f){const u=[];for(let p=0;p<this.no_repeat_ngram_size;++p)u.push(n[f+p]);s.push(u)}const l=new Map;for(const f of s){const u=f.slice(0,f.length-1),p=JSON.stringify(u),g=l.get(p)??[];g.push(f[f.length-1]),l.set(p,g)}return l}getGeneratedNgrams(n,o){const s=o.slice(o.length+1-this.no_repeat_ngram_size,o.length);return n.get(JSON.stringify(s))??[]}calcBannedNgramTokens(n){const o=[];if(n.length+1<this.no_repeat_ngram_size)return o;{const s=this.getNgrams(n);return this.getGeneratedNgrams(s,n)}}_call(n,o){const s=this.calcBannedNgramTokens(n);for(const l of s)o.data[l]=-1/0;return o}}class RepetitionPenaltyLogitsProcessor extends LogitsProcessor{constructor(n){super(),this.penalty=n}_call(n,o){for(const s of n)o.data[s]<0?o.data[s]*=this.penalty:o.data[s]/=this.penalty;return o}}class MinLengthLogitsProcessor extends LogitsProcessor{constructor(n,o){super(),this.min_length=n,this.eos_token_id=Array.isArray(o)?o:[o]}_call(n,o){if(n.length<this.min_length)for(const s of this.eos_token_id)o.data[s]=-1/0;return o}}class MinNewTokensLengthLogitsProcessor extends LogitsProcessor{constructor(n,o,s){super(),this.prompt_length_to_skip=n,this.min_new_tokens=o,this.eos_token_id=Array.isArray(s)?s:[s]}_call(n,o){if(n.length-this.prompt_length_to_skip<this.min_new_tokens)for(const l of this.eos_token_id)o.data[l]=-1/0;return o}}class NoBadWordsLogitsProcessor extends LogitsProcessor{constructor(n,o){super(),this.bad_words_ids=n,this.eos_token_id=Array.isArray(o)?o:[o]}_call(n,o){for(const s of this.bad_words_ids){let l=!0;for(let f=1;f<=s.length-1&&s.length<n.length;++f)if(s.at(-f-1)!==n.at(-f)){l=!1;break}l&&(o.data[s.at(-1)]=-1/0)}return o}}const GenerationConfig=class{constructor(d={}){this.max_length=d.max_length??20,this.max_new_tokens=d.max_new_tokens??null,this.min_length=d.min_length??0,this.min_new_tokens=d.min_new_tokens??null,this.early_stopping=d.early_stopping??!1,this.max_time=d.max_time??null,this.do_sample=d.do_sample??!1,this.num_beams=d.num_beams??1,this.num_beam_groups=d.num_beam_groups??1,this.penalty_alpha=d.penalty_alpha??null,this.use_cache=d.use_cache??!0,this.temperature=d.temperature??1,this.top_k=d.top_k??50,this.top_p=d.top_p??1,this.typical_p=d.typical_p??1,this.epsilon_cutoff=d.epsilon_cutoff??0,this.eta_cutoff=d.eta_cutoff??0,this.diversity_penalty=d.diversity_penalty??0,this.repetition_penalty=d.repetition_penalty??1,this.encoder_repetition_penalty=d.encoder_repetition_penalty??1,this.length_penalty=d.length_penalty??1,this.no_repeat_ngram_size=d.no_repeat_ngram_size??0,this.bad_words_ids=d.bad_words_ids??null,this.force_words_ids=d.force_words_ids??null,this.renormalize_logits=d.renormalize_logits??!1,this.constraints=d.constraints??null,this.forced_bos_token_id=d.forced_bos_token_id??null,this.forced_eos_token_id=d.forced_eos_token_id??null,this.remove_invalid_values=d.remove_invalid_values??!1,this.exponential_decay_length_penalty=d.exponential_decay_length_penalty??null,this.suppress_tokens=d.suppress_tokens??null,this.begin_suppress_tokens=d.begin_suppress_tokens??null,this.forced_decoder_ids=d.forced_decoder_ids??null,this.num_return_sequences=d.num_return_sequences??1,this.output_attentions=d.output_attentions??!1,this.output_hidden_states=d.output_hidden_states??!1,this.output_scores=d.output_scores??!1,this.return_dict_in_generate=d.return_dict_in_generate??!1,this.pad_token_id=d.pad_token_id??null,this.bos_token_id=d.bos_token_id??null,this.eos_token_id=d.eos_token_id??null,this.encoder_no_repeat_ngram_size=d.encoder_no_repeat_ngram_size??0,this.decoder_start_token_id=d.decoder_start_token_id??null,this.generation_kwargs=d.generation_kwargs??{}}};class Sampler extends Callable{constructor(n){super(),this.generation_config=n}_call(n,o=-1){return this.sample(n,o)}sample(n,o){throw Error("sample should be implemented in subclasses.")}getLogits(n,o){let s=n.dims.at(-1),l=n.data;if(o===-1)l=l.slice(-s);else{let f=o*s;l=l.slice(f,f+s)}return this.generation_config.temperature>0&&(l=l.map(f=>f/this.generation_config.temperature)),l}randomSelect(n){let o=n.reduce((l,f)=>l+f,0),s=Math.random()*o;for(let l=0;l<n.length;++l)if(s-=n[l],s<=0)return l;return 0}static getSampler(n){if(n.do_sample)return new MultinomialSampler(n);if(n.num_beams>1)return new BeamSearchSampler(n);if(n.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${n.num_return_sequences}.`);return new GreedySampler(n)}}class GreedySampler extends Sampler{sample(n,o=-1){let s=this.getLogits(n,o);return[[max(s)[1],0]]}}class MultinomialSampler extends Sampler{sample(n,o=-1){let s=n.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));const l=this.getLogits(n,o),f=getTopItems(l,s),u=softmax(f.map(p=>p[1]));return Array.from({length:this.generation_config.num_beams},()=>{const p=this.randomSelect(u);return[f[p][0],Math.log(u[p])]})}}class BeamSearchSampler extends Sampler{sample(n,o=-1){let s=n.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));const l=this.getLogits(n,o),f=getTopItems(l,s),u=softmax(f.map(p=>p[1]));return Array.from({length:this.generation_config.num_beams},(p,g)=>[f[g][0],Math.log(u[g])])}}const{InferenceSession,Tensor:ONNXTensor,env}=ONNX,MODEL_TYPES={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,MaskGeneration:5},MODEL_TYPE_MAPPING=new Map,MODEL_NAME_TO_CLASS_MAPPING=new Map,MODEL_CLASS_TO_NAME_MAPPING=new Map;async function constructSession(d,n,o){let s=`onnx/${n}${o.quantized?"_quantized":""}.onnx`,l=await getModelFile(d,s,!0,o);try{return await InferenceSession.create(l,{executionProviders})}catch(f){if(executionProviders.length===1&&executionProviders[0]==="wasm")throw f;return console.warn(f),console.warn("Something went wrong during model construction (most likely a missing operation). Using `wasm` as a fallback. "),await InferenceSession.create(l,{executionProviders:["wasm"]})}}function validateInputs(d,n){const o=Object.create(null),s=[];for(const u of d.inputNames){const p=n[u];if(!(p instanceof Tensor)){s.push(u);continue}o[u]=env.wasm.proxy?p.clone():p}if(s.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);const l=Object.keys(n).length,f=d.inputNames.length;if(l>f){let u=Object.keys(n).filter(p=>!d.inputNames.includes(p));console.warn(`WARNING: Too many inputs were provided (${l} > ${f}). The following inputs will be ignored: "${u.join(", ")}".`)}return o}async function sessionRun(d,n){const o=validateInputs(d,n);try{let s=await d.run(o);return s=replaceTensors(s),s}catch(s){throw console.error(`An error occurred during model execution: "${s}".`),console.error("Inputs given to model:",o),s}}function replaceTensors(d){for(let n in d)d[n]instanceof ONNXTensor?d[n]=new Tensor(d[n]):typeof d[n]=="object"&&replaceTensors(d[n]);return d}function toI64Tensor(d){if(d instanceof Tensor)return d;if(d.length===0)throw Error("items must be non-empty");if(Array.isArray(d[0])){if(d.some(n=>n.length!==d[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new Tensor("int64",BigInt64Array.from(d.flat().map(n=>BigInt(n))),[d.length,d[0].length])}else return new Tensor("int64",BigInt64Array.from(d.map(n=>BigInt(n))),[1,d.length])}function prepareAttentionMask(d,n){let o=d.config.pad_token_id??null,s=d.config.eos_token_id??null;isIntegralNumber(s)&&(s=[s]);let l=n.indexOf(o)!==-1,f=s===null||!s.includes(o);if(l&&f){let u=BigInt64Array.from(n.data.map(p=>p!=o));return new Tensor("int64",u,n.dims)}else return ones_like(n)}function preparePositionIds(d,n,o){if(!d.inputNames.includes("position_ids"))return;const s=new BigInt64Array(n.attention_mask.data.length);for(let l=0;l<n.attention_mask.dims[0];++l){let f=l*n.attention_mask.dims[1],u=BigInt(0);for(let p=0;p<n.attention_mask.dims[1];++p){const g=f+p;n.attention_mask.data[g]===0n?s[g]=BigInt(1):(s[g]=u,u+=n.attention_mask.data[g])}}n.position_ids=new Tensor("int64",s,n.attention_mask.dims),o&&(n.position_ids=n.position_ids.slice(null,-1).unsqueeze_(-1))}function boolTensor(d){return new Tensor("bool",[d],[1])}async function seq2seqForward(d,n){let{encoder_outputs:o,past_key_values:s}=n;o||(o=(await encoderForward(d,n)).last_hidden_state);let l={input_ids:n.decoder_input_ids,encoder_hidden_states:o};const f=!!s;d.decoder_merged_session.inputNames.includes("use_cache_branch")&&(l.use_cache_branch=boolTensor(f)),d.decoder_merged_session.inputNames.includes("encoder_attention_mask")&&(l.encoder_attention_mask=n.attention_mask),preparePositionIds(d.decoder_merged_session,l,f),d.addPastKeyValues(l,s);const u=await sessionRun(d.decoder_merged_session,l);let p=u.logits;s=d.getPastKeyValues(u,s);const g=d.getAttentions(u);return new Seq2SeqLMOutput({logits:p,past_key_values:s,encoder_outputs:o,...g})}function seq2seqStartBeams(d,n,o,s){let l=[],f=0;const u=d.requires_attention_mask??!0;let p=o.decoder_input_ids??o.decoder_start_token_id??o.bos_token_id??o.eos_token_id;p instanceof Tensor?p=p.tolist().flat():Array.isArray(p)||(p=[p]);for(let g of n){g.dims=[1,...g.dims];let c={inputs:g,encoder_outputs:null,prev_model_outputs:null,output_token_ids:p,done:!1,score:0,id:f++};u&&(c.attention_mask=prepareAttentionMask(d,g)),l.push(c)}return l}async function seq2seqRunBeam(d,n){var u;const o=d.main_input_name;let s=n.output_token_ids;n.prev_model_outputs&&(s=s.slice(-1));let l={[o]:n.inputs,decoder_input_ids:toI64Tensor(s),encoder_outputs:n.encoder_outputs,past_key_values:(u=n.prev_model_outputs)==null?void 0:u.past_key_values};n.attention_mask&&(l.attention_mask=n.attention_mask);let f=await d.forward(l);return n.prev_model_outputs=f,n.encoder_outputs=f.encoder_outputs,f}function seq2seqUpdatebeam(d,n){d.output_token_ids=[...d.output_token_ids,n]}async function encoderForward(d,n){const o=Object.create(null);for(const s of d.session.inputNames)o[s]=n[s];return d.session.inputNames.includes("token_type_ids")&&!o.token_type_ids&&(o.token_type_ids=new Tensor("int64",new BigInt64Array(o.input_ids.data.length),o.input_ids.dims)),await sessionRun(d.session,o)}async function decoderForward(d,n){let{input_ids:o,past_key_values:s,attention_mask:l}=n,f={input_ids:o,attention_mask:l??prepareAttentionMask(d,o)};const u=!!s;d.session.inputNames.includes("use_cache_branch")&&(f.use_cache_branch=boolTensor(u)),preparePositionIds(d.session,f,u),d.addPastKeyValues(f,s);let p=await sessionRun(d.session,f),g=p.logits;return s=d.getPastKeyValues(p,s),{logits:g,past_key_values:s}}function decoderStartBeams(d,n,o,s,l){let f=[],u=0;for(let p of n){let g=p.tolist().map(Number);p.dims=[1,...p.dims];let c;l?(c=l[u],c.dims=[1,...c.dims]):c=prepareAttentionMask(d,p);let a={input:p,model_input_ids:p,attention_mask:c,prev_model_outputs:null,output_token_ids:g,num_output_tokens:s,done:!1,score:0,id:u++};f.push(a)}return f}async function decoderRunBeam(d,n){var f;let o=new BigInt64Array(n.output_token_ids.length).fill(1n),s={input_ids:n.model_input_ids,attention_mask:new Tensor("int64",o,[1,o.length]),past_key_values:(f=n.prev_model_outputs)==null?void 0:f.past_key_values},l=await d.forward(s);return n.prev_model_outputs=l,l}function decoderUpdatebeam(d,n){d.output_token_ids=[...d.output_token_ids,n],d.model_input_ids=new Tensor("int64",[BigInt(n)],[1,1])}class PreTrainedModel extends Callable{constructor(o,s){super();J(this,"main_input_name","input_ids");this.config=o,this.session=s;const l=MODEL_CLASS_TO_NAME_MAPPING.get(this.constructor),f=MODEL_TYPE_MAPPING.get(l);this.can_generate=!1,this._runBeam=null,this._getStartBeams=null,this._updateBeam=null,this._forward=null,f===MODEL_TYPES.DecoderOnly?(this.can_generate=!0,this._runBeam=decoderRunBeam,this._getStartBeams=decoderStartBeams,this._updateBeam=decoderUpdatebeam,this._forward=decoderForward):f===MODEL_TYPES.Seq2Seq||f===MODEL_TYPES.Vision2Seq?(this.can_generate=!0,this._runBeam=seq2seqRunBeam,this._getStartBeams=seq2seqStartBeams,this._updateBeam=seq2seqUpdatebeam,this._forward=seq2seqForward):f===MODEL_TYPES.EncoderDecoder?this._forward=encoderForward:this._forward=encoderForward}async dispose(){const o=[];for(let s of Object.keys(this)){const l=this[s];l instanceof InferenceSession&&o.push(l.handler.dispose())}return await Promise.all(o)}static async from_pretrained(o,{quantized:s=!0,progress_callback:l=null,config:f=null,cache_dir:u=null,local_files_only:p=!1,revision:g="main",model_file_name:c=null}={}){let a={quantized:s,progress_callback:l,config:f,cache_dir:u,local_files_only:p,revision:g,model_file_name:c};const t=MODEL_CLASS_TO_NAME_MAPPING.get(this),e=MODEL_TYPE_MAPPING.get(t);let r;return e===MODEL_TYPES.DecoderOnly?r=await Promise.all([AutoConfig.from_pretrained(o,a),constructSession(o,a.model_file_name??"decoder_model_merged",a),getModelJSON(o,"generation_config.json",!1,a)]):e===MODEL_TYPES.Seq2Seq||e===MODEL_TYPES.Vision2Seq?r=await Promise.all([AutoConfig.from_pretrained(o,a),constructSession(o,"encoder_model",a),constructSession(o,"decoder_model_merged",a),getModelJSON(o,"generation_config.json",!1,a)]):e===MODEL_TYPES.MaskGeneration?r=await Promise.all([AutoConfig.from_pretrained(o,a),constructSession(o,"vision_encoder",a),constructSession(o,"prompt_encoder_mask_decoder",a)]):e===MODEL_TYPES.EncoderDecoder?r=await Promise.all([AutoConfig.from_pretrained(o,a),constructSession(o,"encoder_model",a),constructSession(o,"decoder_model_merged",a)]):(e!==MODEL_TYPES.EncoderOnly&&console.warn(`Model type for '${t??(f==null?void 0:f.model_type)}' not found, assuming encoder-only architecture. Please report this at https://github.com/xenova/transformers.js/issues/new/choose.`),r=await Promise.all([AutoConfig.from_pretrained(o,a),constructSession(o,a.model_file_name??"model",a)])),new this(...r)}async _call(o){return await this.forward(o)}async forward(o){return await this._forward(this,o)}_get_logits_processor(o,s,l=null){const f=new LogitsProcessorList;if(o.repetition_penalty!==null&&o.repetition_penalty!==1&&f.push(new RepetitionPenaltyLogitsProcessor(o.repetition_penalty)),o.no_repeat_ngram_size!==null&&o.no_repeat_ngram_size>0&&f.push(new NoRepeatNGramLogitsProcessor(o.no_repeat_ngram_size)),o.bad_words_ids!==null&&f.push(new NoBadWordsLogitsProcessor(o.bad_words_ids,o.eos_token_id)),o.min_length!==null&&o.eos_token_id!==null&&o.min_length>0&&f.push(new MinLengthLogitsProcessor(o.min_length,o.eos_token_id)),o.min_new_tokens!==null&&o.eos_token_id!==null&&o.min_new_tokens>0&&f.push(new MinNewTokensLengthLogitsProcessor(s,o.min_new_tokens,o.eos_token_id)),o.forced_bos_token_id!==null&&f.push(new ForcedBOSTokenLogitsProcessor(o.forced_bos_token_id)),o.forced_eos_token_id!==null&&f.push(new ForcedEOSTokenLogitsProcessor(o.max_length,o.forced_eos_token_id)),o.begin_suppress_tokens!==null){let u=s>1||o.forced_bos_token_id===null?s:s+1;o.forced_decoder_ids!==null&&(u+=o.forced_decoder_ids[o.forced_decoder_ids.length-1][0]),f.push(new SuppressTokensAtBeginLogitsProcessor(o.begin_suppress_tokens,u))}return o.forced_decoder_ids!==null&&f.push(new ForceTokensLogitsProcessor(o.forced_decoder_ids)),l!==null&&f.extend(l),f}_get_generation_config(o){let s=new GenerationConfig(this.config);return"generation_config"in this&&Object.assign(s,this.generation_config),o!==null&&Object.assign(s,o),s}async generate(o,s=null,l=null,{inputs_attention_mask:f=null}={}){if(!this.can_generate){let _=`The current model class (${MODEL_CLASS_TO_NAME_MAPPING.get(this.constructor)}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;const b=this.config.model_type,y=MODEL_WITH_LM_HEAD_MAPPING_NAMES.get(b)??MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES.get(b)??MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES.get(b)??MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES.get(b);throw y&&(_+=` Please use the following class instead: '${y[0]}'`),Error(_)}if(!(o instanceof Tensor)&&!isTypedArray(o)&&!Array.isArray(o))throw Error(`\`inputs\` must be a Tensor, TypedArray, or Array, but is "${o.constructor.name}".`);let u;if(this.config.is_encoder_decoder)u=0;else if(u=o instanceof Tensor?o.dims.at(-1):o.length,u===0)throw Error("Must supply a non-empty array of input token ids.");s=this._get_generation_config(s),l=l??new LogitsProcessorList,l=this._get_logits_processor(s,u,l);let p=s.eos_token_id;p!==null&&!Array.isArray(p)&&(p=[p]);let g=1;const c=g+(s.max_new_tokens??1/0),a=Number.isInteger(s.max_length)&&(s.max_new_tokens??null)===null;let t=Sampler.getSampler(s),e=this.getStartBeams(o,s,g,f);for(;e.some(m=>!m.done)&&g<c;){let m=[];for(let _ of e){if(_.done){m.push(_);continue}if(a&&_.output_token_ids.length>=s.max_length){_.done=!0,m.push(_);continue}let b=await this.runBeam(_);s.output_attentions&&this.addAttentionsToBeam(_,b),s.output_scores;let y=b.logits.slice(null,-1,null);l(_.output_token_ids,y);let T=t(y);for(let[w,S]of T){let E={..._};this.updateBeam(E,w),E.score+=S,p&&p.includes(w)&&(E.done=!0),m.push(E)}}++g,m=this.groupBeams(m).map(_=>_.sort((b,y)=>y.score-b.score).slice(0,s.num_beams)),e=m.flat(),s.callback_function&&s.callback_function(e)}const r=this.groupBeams(e),i=m=>r.map(_=>s.num_return_sequences>1?_.slice(0,s.num_return_sequences).map(b=>b[m]):[_[0][m]]).flat(),h=i("output_token_ids");if(s.return_dict_in_generate){const m=i("decoder_attentions"),_=i("cross_attentions");return{sequences:h,decoder_attentions:m,cross_attentions:_}}else return h}addAttentionsToBeam(o,s){if(this.config.is_encoder_decoder){if(!s.cross_attentions||s.cross_attentions.length===0)throw Error("`output_attentions` is true, but the model did not produce cross-attentions. This is most likely because the model was not exported with `output_attentions=True`.");o.cross_attentions||(o.cross_attentions=[]),o.cross_attentions.push(s.cross_attentions)}if(!s.decoder_attentions||s.decoder_attentions.length===0)throw Error("`output_attentions` is true, but the model did not produce decoder-attentions. This is most likely because the model was not exported with `output_attentions=True`.");o.decoder_attentions||(o.decoder_attentions=[]),o.decoder_attentions.push(s.decoder_attentions)}groupBeams(o){const s=Object.create(null);for(const l of o)s[l.id]===void 0?s[l.id]=[l]:s[l.id].push(l);return Object.values(s)}getPastKeyValues(o,s){const l=Object.create(null);for(const f in o)if(f.startsWith("present")){let u=f.replace("present","past_key_values");s&&f.includes("encoder")?l[u]=s[u]:l[u]=o[f]}return l}getAttentions(o){const s=Object.create(null);for(const l of["cross_attentions","decoder_attentions"]){const f=[];for(const u in o)if(u.startsWith(l)){const p=u.split(".").pop();f[p]=o[u]}s[l]=f}return s}addPastKeyValues(o,s){if(s)Object.assign(o,s);else if(this.config.is_encoder_decoder&&(this.add_encoder_pkv??!0)){let f=[1,this.num_encoder_heads,0,this.encoder_dim_kv],u=[1,this.num_decoder_heads,0,this.decoder_dim_kv];for(let p=0;p<this.num_decoder_layers;++p)o[`past_key_values.${p}.encoder.key`]=new Tensor("float32",[],f),o[`past_key_values.${p}.encoder.value`]=new Tensor("float32",[],f),o[`past_key_values.${p}.decoder.key`]=new Tensor("float32",[],u),o[`past_key_values.${p}.decoder.value`]=new Tensor("float32",[],u)}else if(this.config.model_type==="falcon"){let f=[1*this.num_heads,0,this.dim_kv];for(let u=0;u<this.num_layers;++u)o[`past_key_values.${u}.key`]=new Tensor("float32",[],f),o[`past_key_values.${u}.value`]=new Tensor("float32",[],f)}else if(this.config.multi_query){let f=[1*this.num_heads,0,2*this.dim_kv];for(let u=0;u<this.num_layers;++u)o[`past_key_values.${u}.key_value`]=new Tensor("float32",[],f)}else if(this.config.model_type==="bloom"){let f=[1*this.num_heads,this.dim_kv,0],u=[1*this.num_heads,0,this.dim_kv];for(let p=0;p<this.num_layers;++p)o[`past_key_values.${p}.key`]=new Tensor("float32",[],f),o[`past_key_values.${p}.value`]=new Tensor("float32",[],u)}else{let f=[1,this.num_heads,0,this.dim_kv];for(let u=0;u<this.num_layers;++u)o[`past_key_values.${u}.key`]=new Tensor("float32",[],f),o[`past_key_values.${u}.value`]=new Tensor("float32",[],f)}}getStartBeams(o,s,l,f){return this._getStartBeams(this,o,s,l,f)}async runBeam(o){return await this._runBeam(this,o)}updateBeam(o,s){return this._updateBeam(o,s)}}class ModelOutput{}class BertPreTrainedModel extends PreTrainedModel{}class BertModel extends BertPreTrainedModel{}class BertForMaskedLM extends BertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class BertForSequenceClassification extends BertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class BertForTokenClassification extends BertPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class BertForQuestionAnswering extends BertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class NomicBertPreTrainedModel extends PreTrainedModel{}class NomicBertModel extends NomicBertPreTrainedModel{}class RoFormerPreTrainedModel extends PreTrainedModel{}class RoFormerModel extends RoFormerPreTrainedModel{}class RoFormerForMaskedLM extends RoFormerPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class RoFormerForSequenceClassification extends RoFormerPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class RoFormerForTokenClassification extends RoFormerPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class RoFormerForQuestionAnswering extends RoFormerPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class ConvBertPreTrainedModel extends PreTrainedModel{}class ConvBertModel extends ConvBertPreTrainedModel{}class ConvBertForMaskedLM extends ConvBertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class ConvBertForSequenceClassification extends ConvBertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class ConvBertForTokenClassification extends ConvBertPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class ConvBertForQuestionAnswering extends ConvBertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class ElectraPreTrainedModel extends PreTrainedModel{}class ElectraModel extends ElectraPreTrainedModel{}class ElectraForMaskedLM extends ElectraPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class ElectraForSequenceClassification extends ElectraPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class ElectraForTokenClassification extends ElectraPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class ElectraForQuestionAnswering extends ElectraPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class CamembertPreTrainedModel extends PreTrainedModel{}class CamembertModel extends CamembertPreTrainedModel{}class CamembertForMaskedLM extends CamembertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class CamembertForSequenceClassification extends CamembertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class CamembertForTokenClassification extends CamembertPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class CamembertForQuestionAnswering extends CamembertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class DebertaPreTrainedModel extends PreTrainedModel{}class DebertaModel extends DebertaPreTrainedModel{}class DebertaForMaskedLM extends DebertaPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class DebertaForSequenceClassification extends DebertaPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class DebertaForTokenClassification extends DebertaPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class DebertaForQuestionAnswering extends DebertaPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class DebertaV2PreTrainedModel extends PreTrainedModel{}class DebertaV2Model extends DebertaV2PreTrainedModel{}class DebertaV2ForMaskedLM extends DebertaV2PreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class DebertaV2ForSequenceClassification extends DebertaV2PreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class DebertaV2ForTokenClassification extends DebertaV2PreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class DebertaV2ForQuestionAnswering extends DebertaV2PreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class DistilBertPreTrainedModel extends PreTrainedModel{}class DistilBertModel extends DistilBertPreTrainedModel{}class DistilBertForSequenceClassification extends DistilBertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class DistilBertForTokenClassification extends DistilBertPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class DistilBertForQuestionAnswering extends DistilBertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class DistilBertForMaskedLM extends DistilBertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class EsmPreTrainedModel extends PreTrainedModel{}class EsmModel extends EsmPreTrainedModel{}class EsmForMaskedLM extends EsmPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class EsmForSequenceClassification extends EsmPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class EsmForTokenClassification extends EsmPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class MobileBertPreTrainedModel extends PreTrainedModel{}class MobileBertModel extends MobileBertPreTrainedModel{}class MobileBertForMaskedLM extends MobileBertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class MobileBertForSequenceClassification extends MobileBertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class MobileBertForQuestionAnswering extends MobileBertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class MPNetPreTrainedModel extends PreTrainedModel{}class MPNetModel extends MPNetPreTrainedModel{}class MPNetForMaskedLM extends MPNetPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class MPNetForSequenceClassification extends MPNetPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class MPNetForTokenClassification extends MPNetPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class MPNetForQuestionAnswering extends MPNetPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class SqueezeBertPreTrainedModel extends PreTrainedModel{}class SqueezeBertModel extends SqueezeBertPreTrainedModel{}class SqueezeBertForMaskedLM extends SqueezeBertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class SqueezeBertForSequenceClassification extends SqueezeBertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class SqueezeBertForQuestionAnswering extends SqueezeBertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class AlbertPreTrainedModel extends PreTrainedModel{}class AlbertModel extends AlbertPreTrainedModel{}class AlbertForSequenceClassification extends AlbertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class AlbertForQuestionAnswering extends AlbertPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class AlbertForMaskedLM extends AlbertPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class T5PreTrainedModel extends PreTrainedModel{}class T5Model extends T5PreTrainedModel{}class T5ForConditionalGeneration extends T5PreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.num_decoder_layers,this.num_decoder_heads=this.config.num_heads,this.decoder_dim_kv=this.config.d_kv,this.num_encoder_layers=this.config.num_layers,this.num_encoder_heads=this.config.num_heads,this.encoder_dim_kv=this.config.d_kv}}class LongT5PreTrainedModel extends PreTrainedModel{}class LongT5Model extends LongT5PreTrainedModel{}class LongT5ForConditionalGeneration extends LongT5PreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.num_decoder_layers,this.num_decoder_heads=this.config.num_heads,this.decoder_dim_kv=this.config.d_kv,this.num_encoder_layers=this.config.num_layers,this.num_encoder_heads=this.config.num_heads,this.encoder_dim_kv=this.config.d_kv}}class MT5PreTrainedModel extends PreTrainedModel{}class MT5Model extends MT5PreTrainedModel{}class MT5ForConditionalGeneration extends MT5PreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.num_decoder_layers,this.num_decoder_heads=this.config.num_heads,this.decoder_dim_kv=this.config.d_kv,this.num_encoder_layers=this.config.num_layers,this.num_encoder_heads=this.config.num_heads,this.encoder_dim_kv=this.config.d_kv}}class BartPretrainedModel extends PreTrainedModel{}class BartModel extends BartPretrainedModel{}class BartForConditionalGeneration extends BartPretrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class BartForSequenceClassification extends BartPretrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class MBartPreTrainedModel extends PreTrainedModel{}class MBartModel extends MBartPreTrainedModel{}class MBartForConditionalGeneration extends MBartPreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class MBartForSequenceClassification extends MBartPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class MBartForCausalLM extends MBartPreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class BlenderbotPreTrainedModel extends PreTrainedModel{}class BlenderbotModel extends BlenderbotPreTrainedModel{}class BlenderbotForConditionalGeneration extends BlenderbotPreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class BlenderbotSmallPreTrainedModel extends PreTrainedModel{}class BlenderbotSmallModel extends BlenderbotSmallPreTrainedModel{}class BlenderbotSmallForConditionalGeneration extends BlenderbotSmallPreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class RobertaPreTrainedModel extends PreTrainedModel{}class RobertaModel extends RobertaPreTrainedModel{}class RobertaForMaskedLM extends RobertaPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class RobertaForSequenceClassification extends RobertaPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class RobertaForTokenClassification extends RobertaPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class RobertaForQuestionAnswering extends RobertaPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class XLMPreTrainedModel extends PreTrainedModel{}class XLMModel extends XLMPreTrainedModel{}class XLMWithLMHeadModel extends XLMPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class XLMForSequenceClassification extends XLMPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class XLMForTokenClassification extends XLMPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class XLMForQuestionAnswering extends XLMPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class XLMRobertaPreTrainedModel extends PreTrainedModel{}class XLMRobertaModel extends XLMRobertaPreTrainedModel{}class XLMRobertaForMaskedLM extends XLMRobertaPreTrainedModel{async _call(n){return new MaskedLMOutput(await super._call(n))}}class XLMRobertaForSequenceClassification extends XLMRobertaPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class XLMRobertaForTokenClassification extends XLMRobertaPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class XLMRobertaForQuestionAnswering extends XLMRobertaPreTrainedModel{async _call(n){return new QuestionAnsweringModelOutput(await super._call(n))}}class ASTPreTrainedModel extends PreTrainedModel{}class ASTModel extends ASTPreTrainedModel{}class ASTForAudioClassification extends ASTPreTrainedModel{}class WhisperPreTrainedModel extends PreTrainedModel{}class WhisperModel extends WhisperPreTrainedModel{}class WhisperForConditionalGeneration extends WhisperPreTrainedModel{constructor(o,s,l,f){super(o,s);J(this,"requires_attention_mask",!1);J(this,"main_input_name","input_features");this.decoder_merged_session=l,this.generation_config=f,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}async generate(o,s=null,l=null){if(s=this._get_generation_config(s),s.return_timestamps??(s.return_timestamps=!1),s.return_timestamps&&(l=[new WhisperTimeStampLogitsProcessor(s)]),s.return_token_timestamps&&(s.output_attentions=!0,s.return_dict_in_generate=!0,s.task==="translate"&&console.warn("Token-level timestamps may not be reliable for task 'translate'."),!s.alignment_heads))throw new Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");const f=await super.generate(o,s,l);return s.return_token_timestamps&&s.alignment_heads&&(f.token_timestamps=this._extract_token_timestamps(f,s.alignment_heads,s.num_frames)),f}_extract_token_timestamps(o,s,l=null,f=.02){if(!o.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");let u=this.config.median_filter_width;u===void 0&&(console.warn("Model config has no `median_filter_width`, using default value of 7."),u=7);const p=o.cross_attentions.map(a=>{let t=Array.from({length:this.config.decoder_layers},(_,b)=>cat(a.map(y=>y[b]),2)),e=stack(s.map(([_,b])=>l?t[_].slice(null,b,null,[0,l]):t[_].slice(null,b)));e=e.transpose(1,0,2,3);let[r,i]=std_mean(e,-2,0,!0),h=e.clone();for(let _=0;_<h.dims[0];++_){let b=h[_];for(let y=0;y<b.dims[0];++y){let T=b[y];const w=r[_][y][0],S=i[_][y][0];for(let E=0;E<T.dims[0];++E){let O=T[E];for(let v=0;v<O.data.length;++v)O.data[v]=(O.data[v]-S.data[v])/w.data[v];O.data.set(medianFilter(O.data,u))}}}return mean(h,1)}),g=[o.sequences.length,o.sequences[0].length],c=new Tensor("float32",new Float32Array(g[0]*g[1]),g);for(let a=0;a<g[0];++a){const t=p[a].neg().squeeze_(0);let[e,r]=dynamicTimeWarping(t),i=Array.from({length:e.length-1},(_,b)=>e[b+1]-e[b]),h=mergeArrays([1],i).map(_=>!!_),m=[];for(let _=0;_<h.length;++_)h[_]&&m.push(r[_]*f);c[a].data.set(m,1)}return c}}class VisionEncoderDecoderModel extends PreTrainedModel{constructor(o,s,l,f){super(o,s);J(this,"main_input_name","pixel_values");this.decoder_merged_session=l,this.generation_config=f;const u=this.config.encoder,p=this.config.decoder,g=u.model_type;(MODEL_MAPPING_NAMES_ENCODER_ONLY.get(g)??MODEL_MAPPING_NAMES_ENCODER_DECODER.get(g))||console.warn(`Model type for encoder '${g}' not found, assuming encoder-only architecture. Please report this at https://github.com/xenova/transformers.js/issues/new/choose.`);const a=MODEL_WITH_LM_HEAD_MAPPING_NAMES.get(p.model_type);if(!a)throw new Error(`Unable to construct \`VisionEncoderDecoder\` due to unsupported decoder: "${this.config.decoder.model_type}"`);const t=a[1],e=new t(p,l,f);this.add_encoder_pkv="num_decoder_layers"in e,this.add_encoder_pkv?(this.num_decoder_layers=e.num_decoder_layers,this.num_decoder_heads=e.num_decoder_heads,this.decoder_dim_kv=e.decoder_dim_kv,this.num_encoder_layers=e.num_encoder_layers,this.num_encoder_heads=e.num_encoder_heads,this.encoder_dim_kv=e.encoder_dim_kv):(this.num_layers=e.num_layers,this.num_heads=e.num_heads,this.dim_kv=e.dim_kv)}}class CLIPPreTrainedModel extends PreTrainedModel{}class CLIPModel extends CLIPPreTrainedModel{}class CLIPTextModelWithProjection extends CLIPPreTrainedModel{static async from_pretrained(n,o={}){return o.model_file_name??(o.model_file_name="text_model"),super.from_pretrained(n,o)}}class CLIPVisionModelWithProjection extends CLIPPreTrainedModel{static async from_pretrained(n,o={}){return o.model_file_name??(o.model_file_name="vision_model"),super.from_pretrained(n,o)}}class SiglipPreTrainedModel extends PreTrainedModel{}class SiglipModel extends SiglipPreTrainedModel{}class SiglipTextModel extends SiglipPreTrainedModel{static async from_pretrained(n,o={}){return o.model_file_name??(o.model_file_name="text_model"),super.from_pretrained(n,o)}}class SiglipVisionModel extends CLIPPreTrainedModel{static async from_pretrained(n,o={}){return o.model_file_name??(o.model_file_name="vision_model"),super.from_pretrained(n,o)}}class ChineseCLIPPreTrainedModel extends PreTrainedModel{}class ChineseCLIPModel extends ChineseCLIPPreTrainedModel{}class CLIPSegPreTrainedModel extends PreTrainedModel{}class CLIPSegModel extends CLIPSegPreTrainedModel{}class CLIPSegForImageSegmentation extends CLIPSegPreTrainedModel{}class GPT2PreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.n_head,this.num_layers=this.config.n_layer,this.dim_kv=this.config.n_embd/this.num_heads}}class GPT2Model extends GPT2PreTrainedModel{}class GPT2LMHeadModel extends GPT2PreTrainedModel{}class GPTNeoPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_heads,this.num_layers=this.config.num_layers,this.dim_kv=this.config.hidden_size/this.num_heads}}class GPTNeoModel extends GPTNeoPreTrainedModel{}class GPTNeoForCausalLM extends GPTNeoPreTrainedModel{}class GPTNeoXPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.num_heads}}class GPTNeoXModel extends GPTNeoXPreTrainedModel{}class GPTNeoXForCausalLM extends GPTNeoXPreTrainedModel{}class GPTJPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.n_head,this.num_layers=this.config.n_layer,this.dim_kv=this.config.n_embd/this.num_heads}}class GPTJModel extends GPTJPreTrainedModel{}class GPTJForCausalLM extends GPTJPreTrainedModel{}class GPTBigCodePreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.n_head,this.num_layers=this.config.n_layer,this.dim_kv=this.config.n_embd/this.num_heads}}class GPTBigCodeModel extends GPTBigCodePreTrainedModel{}class GPTBigCodeForCausalLM extends GPTBigCodePreTrainedModel{}class CodeGenPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.n_head,this.num_layers=this.config.n_layer,this.dim_kv=this.config.n_embd/this.num_heads}}class CodeGenModel extends CodeGenPreTrainedModel{}class CodeGenForCausalLM extends CodeGenPreTrainedModel{}class LlamaPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_key_value_heads??this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class LlamaModel extends LlamaPreTrainedModel{}class LlamaForCausalLM extends LlamaPreTrainedModel{}class Qwen2PreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_key_value_heads??this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class Qwen2Model extends Qwen2PreTrainedModel{}class Qwen2ForCausalLM extends Qwen2PreTrainedModel{}class PhiPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.num_heads}}class PhiModel extends PhiPreTrainedModel{}class PhiForCausalLM extends PhiPreTrainedModel{}class BloomPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.n_head,this.num_layers=this.config.n_layer,this.dim_kv=this.config.hidden_size/this.num_heads}}class BloomModel extends BloomPreTrainedModel{}class BloomForCausalLM extends BloomPreTrainedModel{}class MptPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.n_heads,this.num_layers=this.config.n_layers,this.dim_kv=this.config.d_model/this.num_heads}}class MptModel extends MptPreTrainedModel{}class MptForCausalLM extends MptPreTrainedModel{}class OPTPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.num_heads}}class OPTModel extends OPTPreTrainedModel{}class OPTForCausalLM extends OPTPreTrainedModel{}class ViTPreTrainedModel extends PreTrainedModel{}class ViTModel extends ViTPreTrainedModel{}class ViTForImageClassification extends ViTPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class VitMattePreTrainedModel extends PreTrainedModel{}class VitMatteForImageMatting extends VitMattePreTrainedModel{async _call(n){return new ImageMattingOutput(await super._call(n))}}class MobileViTPreTrainedModel extends PreTrainedModel{}class MobileViTModel extends MobileViTPreTrainedModel{}class MobileViTForImageClassification extends MobileViTPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class OwlViTPreTrainedModel extends PreTrainedModel{}class OwlViTModel extends OwlViTPreTrainedModel{}class OwlViTForObjectDetection extends OwlViTPreTrainedModel{}class Owlv2PreTrainedModel extends PreTrainedModel{}class Owlv2Model extends Owlv2PreTrainedModel{}class Owlv2ForObjectDetection extends Owlv2PreTrainedModel{}class BeitPreTrainedModel extends PreTrainedModel{}class BeitModel extends BeitPreTrainedModel{}class BeitForImageClassification extends BeitPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class DetrPreTrainedModel extends PreTrainedModel{}class DetrModel extends DetrPreTrainedModel{}class DetrForObjectDetection extends DetrPreTrainedModel{async _call(n){return new DetrObjectDetectionOutput(await super._call(n))}}class DetrForSegmentation extends DetrPreTrainedModel{async _call(n){return new DetrSegmentationOutput(await super._call(n))}}class DetrObjectDetectionOutput extends ModelOutput{constructor({logits:n,pred_boxes:o}){super(),this.logits=n,this.pred_boxes=o}}class DetrSegmentationOutput extends ModelOutput{constructor({logits:n,pred_boxes:o,pred_masks:s}){super(),this.logits=n,this.pred_boxes=o,this.pred_masks=s}}class TableTransformerPreTrainedModel extends PreTrainedModel{}class TableTransformerModel extends TableTransformerPreTrainedModel{}class TableTransformerForObjectDetection extends TableTransformerPreTrainedModel{async _call(n){return new TableTransformerObjectDetectionOutput(await super._call(n))}}class TableTransformerObjectDetectionOutput extends DetrObjectDetectionOutput{}class DeiTPreTrainedModel extends PreTrainedModel{}class DeiTModel extends DeiTPreTrainedModel{}class DeiTForImageClassification extends DeiTPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class ResNetPreTrainedModel extends PreTrainedModel{}class ResNetModel extends ResNetPreTrainedModel{}class ResNetForImageClassification extends ResNetPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class SwinPreTrainedModel extends PreTrainedModel{}class SwinModel extends SwinPreTrainedModel{}class SwinForImageClassification extends SwinPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class Swin2SRPreTrainedModel extends PreTrainedModel{}class Swin2SRModel extends Swin2SRPreTrainedModel{}class Swin2SRForImageSuperResolution extends Swin2SRPreTrainedModel{}class DPTPreTrainedModel extends PreTrainedModel{}class DPTModel extends DPTPreTrainedModel{}class DPTForDepthEstimation extends DPTPreTrainedModel{}class DepthAnythingPreTrainedModel extends PreTrainedModel{}class DepthAnythingForDepthEstimation extends DepthAnythingPreTrainedModel{}class GLPNPreTrainedModel extends PreTrainedModel{}class GLPNModel extends GLPNPreTrainedModel{}class GLPNForDepthEstimation extends GLPNPreTrainedModel{}class DonutSwinPreTrainedModel extends PreTrainedModel{}class DonutSwinModel extends DonutSwinPreTrainedModel{}class ConvNextPreTrainedModel extends PreTrainedModel{}class ConvNextModel extends ConvNextPreTrainedModel{}class ConvNextForImageClassification extends ConvNextPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class ConvNextV2PreTrainedModel extends PreTrainedModel{}class ConvNextV2Model extends ConvNextV2PreTrainedModel{}class ConvNextV2ForImageClassification extends ConvNextV2PreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class Dinov2PreTrainedModel extends PreTrainedModel{}class Dinov2Model extends Dinov2PreTrainedModel{}class Dinov2ForImageClassification extends Dinov2PreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class YolosPreTrainedModel extends PreTrainedModel{}class YolosModel extends YolosPreTrainedModel{}class YolosForObjectDetection extends YolosPreTrainedModel{async _call(n){return new YolosObjectDetectionOutput(await super._call(n))}}class YolosObjectDetectionOutput extends ModelOutput{constructor({logits:n,pred_boxes:o}){super(),this.logits=n,this.pred_boxes=o}}class SamPreTrainedModel extends PreTrainedModel{}class SamModel extends SamPreTrainedModel{constructor(n,o,s){super(n,o),this.prompt_encoder_mask_decoder=s}async get_image_embeddings({pixel_values:n}){return await encoderForward(this,{pixel_values:n})}async forward(n){if((!n.image_embeddings||!n.image_positional_embeddings)&&(n={...n,...await this.get_image_embeddings(n)}),!n.input_labels){const o=n.input_points.dims.slice(0,-1),s=o.reduce((l,f)=>l*f,1);n.input_labels=new Tensor("int64",new BigInt64Array(s).fill(1n),o)}return await sessionRun(this.prompt_encoder_mask_decoder,{input_points:n.input_points,input_labels:n.input_labels,image_embeddings:n.image_embeddings,image_positional_embeddings:n.image_positional_embeddings})}async _call(n){return new SamImageSegmentationOutput(await super._call(n))}}class SamImageSegmentationOutput extends ModelOutput{constructor({iou_scores:n,pred_masks:o}){super(),this.iou_scores=n,this.pred_masks=o}}class MarianPreTrainedModel extends PreTrainedModel{}class MarianModel extends MarianPreTrainedModel{}class MarianMTModel extends MarianPreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class M2M100PreTrainedModel extends PreTrainedModel{}class M2M100Model extends M2M100PreTrainedModel{}class M2M100ForConditionalGeneration extends M2M100PreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}class Wav2Vec2PreTrainedModel extends PreTrainedModel{}class Wav2Vec2Model extends Wav2Vec2PreTrainedModel{}class Wav2Vec2ForCTC extends Wav2Vec2PreTrainedModel{async _call(n){return new CausalLMOutput(await super._call(n))}}class Wav2Vec2ForSequenceClassification extends Wav2Vec2PreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class Wav2Vec2ForAudioFrameClassification extends Wav2Vec2PreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class UniSpeechPreTrainedModel extends PreTrainedModel{}class UniSpeechModel extends UniSpeechPreTrainedModel{}class UniSpeechForCTC extends UniSpeechPreTrainedModel{async _call(n){return new CausalLMOutput(await super._call(n))}}class UniSpeechForSequenceClassification extends UniSpeechPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class UniSpeechSatPreTrainedModel extends PreTrainedModel{}class UniSpeechSatModel extends UniSpeechSatPreTrainedModel{}class UniSpeechSatForCTC extends UniSpeechSatPreTrainedModel{async _call(n){return new CausalLMOutput(await super._call(n))}}class UniSpeechSatForSequenceClassification extends UniSpeechSatPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class UniSpeechSatForAudioFrameClassification extends UniSpeechSatPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class Wav2Vec2BertPreTrainedModel extends PreTrainedModel{}class Wav2Vec2BertModel extends Wav2Vec2BertPreTrainedModel{}class Wav2Vec2BertForCTC extends Wav2Vec2BertPreTrainedModel{async _call(n){return new CausalLMOutput(await super._call(n))}}class Wav2Vec2BertForSequenceClassification extends Wav2Vec2BertPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class HubertModel extends Wav2Vec2PreTrainedModel{}class HubertForCTC extends Wav2Vec2PreTrainedModel{async _call(n){return new CausalLMOutput(await super._call(n))}}class HubertForSequenceClassification extends Wav2Vec2PreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class WavLMPreTrainedModel extends PreTrainedModel{}class WavLMModel extends WavLMPreTrainedModel{}class WavLMForCTC extends WavLMPreTrainedModel{async _call(n){return new CausalLMOutput(await super._call(n))}}class WavLMForSequenceClassification extends WavLMPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class WavLMForXVector extends WavLMPreTrainedModel{async _call(n){return new XVectorOutput(await super._call(n))}}class WavLMForAudioFrameClassification extends WavLMPreTrainedModel{async _call(n){return new TokenClassifierOutput(await super._call(n))}}class SpeechT5PreTrainedModel extends PreTrainedModel{}class SpeechT5ForSpeechToText extends SpeechT5PreTrainedModel{}class SpeechT5ForTextToSpeech extends SpeechT5PreTrainedModel{constructor(n,o,s,l){super(n,o),this.decoder_merged_session=s,this.generation_config=l,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.hidden_size/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.hidden_size/this.num_encoder_heads}async generate_speech(n,o,{threshold:s=.5,minlenratio:l=0,maxlenratio:f=20,vocoder:u=null}={}){const p={input_ids:n},{encoder_outputs:g,encoder_attention_mask:c}=await encoderForward(this,p),a=g.dims[1]/this.config.reduction_factor,t=Math.floor(a*f),e=Math.floor(a*l),r=this.config.num_mel_bins;let i=[],h=null,m=null,_=0;for(;;){++_;const T=boolTensor(!!m);let w;m?w=m.output_sequence_out:w=new Tensor("float32",new Float32Array(r),[1,1,r]);let S={use_cache_branch:T,output_sequence:w,encoder_attention_mask:c,speaker_embeddings:o,encoder_hidden_states:g};this.addPastKeyValues(S,h),m=await sessionRun(this.decoder_merged_session,S),h=this.getPastKeyValues(m,h);const{prob:E,spectrum:O}=m;if(i.push(O),_>=e&&(Array.from(E.data).filter(v=>v>=s).length>0||_>=t))break}const b=cat(i),{waveform:y}=await sessionRun(u.session,{spectrogram:b});return{spectrogram:b,waveform:y}}}class SpeechT5HifiGan extends PreTrainedModel{constructor(){super(...arguments);J(this,"main_input_name","spectrogram")}}class TrOCRPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_encoder_layers=this.num_decoder_layers=this.config.decoder_layers,this.num_encoder_heads=this.num_decoder_heads=this.config.decoder_attention_heads,this.encoder_dim_kv=this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads}}class TrOCRForCausalLM extends TrOCRPreTrainedModel{}class MistralPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_key_value_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class MistralModel extends MistralPreTrainedModel{}class MistralForCausalLM extends MistralPreTrainedModel{}class Starcoder2PreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_key_value_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class Starcoder2Model extends Starcoder2PreTrainedModel{}class Starcoder2ForCausalLM extends Starcoder2PreTrainedModel{}class FalconPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class FalconModel extends FalconPreTrainedModel{}class FalconForCausalLM extends FalconPreTrainedModel{}class ClapPreTrainedModel extends PreTrainedModel{}class ClapModel extends ClapPreTrainedModel{}class ClapTextModelWithProjection extends ClapPreTrainedModel{static async from_pretrained(n,o={}){return o.model_file_name??(o.model_file_name="text_model"),super.from_pretrained(n,o)}}class ClapAudioModelWithProjection extends ClapPreTrainedModel{static async from_pretrained(n,o={}){return o.model_file_name??(o.model_file_name="audio_model"),super.from_pretrained(n,o)}}class VitsPreTrainedModel extends PreTrainedModel{}class VitsModel extends VitsPreTrainedModel{async _call(n){return new VitsModelOutput(await super._call(n))}}class SegformerPreTrainedModel extends PreTrainedModel{}class SegformerForImageClassification extends SegformerPreTrainedModel{}class SegformerForSemanticSegmentation extends SegformerPreTrainedModel{}class StableLmPreTrainedModel extends PreTrainedModel{constructor(n,o,s){super(n,o),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.num_heads}}class StableLmForCausalLM extends StableLmPreTrainedModel{}class EfficientNetPreTrainedModel extends PreTrainedModel{}class EfficientNetModel extends EfficientNetPreTrainedModel{}class EfficientNetForImageClassification extends EfficientNetPreTrainedModel{async _call(n){return new SequenceClassifierOutput(await super._call(n))}}class PretrainedMixin{static async from_pretrained(n,{quantized:o=!0,progress_callback:s=null,config:l=null,cache_dir:f=null,local_files_only:u=!1,revision:p="main",model_file_name:g=null}={}){let c={quantized:o,progress_callback:s,config:l,cache_dir:f,local_files_only:u,revision:p,model_file_name:g};if(l=await AutoConfig.from_pretrained(n,c),c.config||(c.config=l),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);for(let a of this.MODEL_CLASS_MAPPINGS){const t=a.get(l.model_type);if(t)return await t[1].from_pretrained(n,c)}if(this.BASE_IF_FAIL)return console.warn(`Unknown model class "${l.model_type}", attempting to construct from base class.`),await PreTrainedModel.from_pretrained(n,c);throw Error(`Unsupported model type: ${l.model_type}`)}}J(PretrainedMixin,"MODEL_CLASS_MAPPINGS",null),J(PretrainedMixin,"BASE_IF_FAIL",!1);const MODEL_MAPPING_NAMES_ENCODER_ONLY=new Map([["bert",["BertModel",BertModel]],["nomic_bert",["NomicBertModel",NomicBertModel]],["roformer",["RoFormerModel",RoFormerModel]],["electra",["ElectraModel",ElectraModel]],["esm",["EsmModel",EsmModel]],["convbert",["ConvBertModel",ConvBertModel]],["camembert",["CamembertModel",CamembertModel]],["deberta",["DebertaModel",DebertaModel]],["deberta-v2",["DebertaV2Model",DebertaV2Model]],["mpnet",["MPNetModel",MPNetModel]],["albert",["AlbertModel",AlbertModel]],["distilbert",["DistilBertModel",DistilBertModel]],["roberta",["RobertaModel",RobertaModel]],["xlm",["XLMModel",XLMModel]],["xlm-roberta",["XLMRobertaModel",XLMRobertaModel]],["clap",["ClapModel",ClapModel]],["clip",["CLIPModel",CLIPModel]],["clipseg",["CLIPSegModel",CLIPSegModel]],["chinese_clip",["ChineseCLIPModel",ChineseCLIPModel]],["siglip",["SiglipModel",SiglipModel]],["mobilebert",["MobileBertModel",MobileBertModel]],["squeezebert",["SqueezeBertModel",SqueezeBertModel]],["wav2vec2",["Wav2Vec2Model",Wav2Vec2Model]],["wav2vec2-bert",["Wav2Vec2BertModel",Wav2Vec2BertModel]],["unispeech",["UniSpeechModel",UniSpeechModel]],["unispeech-sat",["UniSpeechSatModel",UniSpeechSatModel]],["hubert",["HubertModel",HubertModel]],["wavlm",["WavLMModel",WavLMModel]],["audio-spectrogram-transformer",["ASTModel",ASTModel]],["vits",["VitsModel",VitsModel]],["detr",["DetrModel",DetrModel]],["table-transformer",["TableTransformerModel",TableTransformerModel]],["vit",["ViTModel",ViTModel]],["mobilevit",["MobileViTModel",MobileViTModel]],["owlvit",["OwlViTModel",OwlViTModel]],["owlv2",["Owlv2Model",Owlv2Model]],["beit",["BeitModel",BeitModel]],["deit",["DeiTModel",DeiTModel]],["convnext",["ConvNextModel",ConvNextModel]],["convnextv2",["ConvNextV2Model",ConvNextV2Model]],["dinov2",["Dinov2Model",Dinov2Model]],["resnet",["ResNetModel",ResNetModel]],["swin",["SwinModel",SwinModel]],["swin2sr",["Swin2SRModel",Swin2SRModel]],["donut-swin",["DonutSwinModel",DonutSwinModel]],["yolos",["YolosModel",YolosModel]],["dpt",["DPTModel",DPTModel]],["glpn",["GLPNModel",GLPNModel]],["hifigan",["SpeechT5HifiGan",SpeechT5HifiGan]],["efficientnet",["EfficientNetModel",EfficientNetModel]]]),MODEL_MAPPING_NAMES_ENCODER_DECODER=new Map([["t5",["T5Model",T5Model]],["longt5",["LongT5Model",LongT5Model]],["mt5",["MT5Model",MT5Model]],["bart",["BartModel",BartModel]],["mbart",["MBartModel",MBartModel]],["marian",["MarianModel",MarianModel]],["whisper",["WhisperModel",WhisperModel]],["m2m_100",["M2M100Model",M2M100Model]],["blenderbot",["BlenderbotModel",BlenderbotModel]],["blenderbot-small",["BlenderbotSmallModel",BlenderbotSmallModel]]]),MODEL_MAPPING_NAMES_DECODER_ONLY=new Map([["bloom",["BloomModel",BloomModel]],["gpt2",["GPT2Model",GPT2Model]],["gptj",["GPTJModel",GPTJModel]],["gpt_bigcode",["GPTBigCodeModel",GPTBigCodeModel]],["gpt_neo",["GPTNeoModel",GPTNeoModel]],["gpt_neox",["GPTNeoXModel",GPTNeoXModel]],["codegen",["CodeGenModel",CodeGenModel]],["llama",["LlamaModel",LlamaModel]],["qwen2",["Qwen2Model",Qwen2Model]],["phi",["PhiModel",PhiModel]],["mpt",["MptModel",MptModel]],["opt",["OPTModel",OPTModel]],["mistral",["MistralModel",MistralModel]],["starcoder2",["Starcoder2Model",Starcoder2Model]],["falcon",["FalconModel",FalconModel]]]),MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES=new Map([["speecht5",["SpeechT5ForSpeechToText",SpeechT5ForSpeechToText]],["whisper",["WhisperForConditionalGeneration",WhisperForConditionalGeneration]]]),MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES=new Map([["speecht5",["SpeechT5ForTextToSpeech",SpeechT5ForTextToSpeech]]]),MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES=new Map([["vits",["VitsModel",VitsModel]]]),MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES=new Map([["bert",["BertForSequenceClassification",BertForSequenceClassification]],["roformer",["RoFormerForSequenceClassification",RoFormerForSequenceClassification]],["electra",["ElectraForSequenceClassification",ElectraForSequenceClassification]],["esm",["EsmForSequenceClassification",EsmForSequenceClassification]],["convbert",["ConvBertForSequenceClassification",ConvBertForSequenceClassification]],["camembert",["CamembertForSequenceClassification",CamembertForSequenceClassification]],["deberta",["DebertaForSequenceClassification",DebertaForSequenceClassification]],["deberta-v2",["DebertaV2ForSequenceClassification",DebertaV2ForSequenceClassification]],["mpnet",["MPNetForSequenceClassification",MPNetForSequenceClassification]],["albert",["AlbertForSequenceClassification",AlbertForSequenceClassification]],["distilbert",["DistilBertForSequenceClassification",DistilBertForSequenceClassification]],["roberta",["RobertaForSequenceClassification",RobertaForSequenceClassification]],["xlm",["XLMForSequenceClassification",XLMForSequenceClassification]],["xlm-roberta",["XLMRobertaForSequenceClassification",XLMRobertaForSequenceClassification]],["bart",["BartForSequenceClassification",BartForSequenceClassification]],["mbart",["MBartForSequenceClassification",MBartForSequenceClassification]],["mobilebert",["MobileBertForSequenceClassification",MobileBertForSequenceClassification]],["squeezebert",["SqueezeBertForSequenceClassification",SqueezeBertForSequenceClassification]]]),MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES=new Map([["bert",["BertForTokenClassification",BertForTokenClassification]],["roformer",["RoFormerForTokenClassification",RoFormerForTokenClassification]],["electra",["ElectraForTokenClassification",ElectraForTokenClassification]],["esm",["EsmForTokenClassification",EsmForTokenClassification]],["convbert",["ConvBertForTokenClassification",ConvBertForTokenClassification]],["camembert",["CamembertForTokenClassification",CamembertForTokenClassification]],["deberta",["DebertaForTokenClassification",DebertaForTokenClassification]],["deberta-v2",["DebertaV2ForTokenClassification",DebertaV2ForTokenClassification]],["mpnet",["MPNetForTokenClassification",MPNetForTokenClassification]],["distilbert",["DistilBertForTokenClassification",DistilBertForTokenClassification]],["roberta",["RobertaForTokenClassification",RobertaForTokenClassification]],["xlm",["XLMForTokenClassification",XLMForTokenClassification]],["xlm-roberta",["XLMRobertaForTokenClassification",XLMRobertaForTokenClassification]]]),MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES=new Map([["t5",["T5ForConditionalGeneration",T5ForConditionalGeneration]],["longt5",["LongT5ForConditionalGeneration",LongT5ForConditionalGeneration]],["mt5",["MT5ForConditionalGeneration",MT5ForConditionalGeneration]],["bart",["BartForConditionalGeneration",BartForConditionalGeneration]],["mbart",["MBartForConditionalGeneration",MBartForConditionalGeneration]],["marian",["MarianMTModel",MarianMTModel]],["m2m_100",["M2M100ForConditionalGeneration",M2M100ForConditionalGeneration]],["blenderbot",["BlenderbotForConditionalGeneration",BlenderbotForConditionalGeneration]],["blenderbot-small",["BlenderbotSmallForConditionalGeneration",BlenderbotSmallForConditionalGeneration]]]),MODEL_WITH_LM_HEAD_MAPPING_NAMES=new Map([["bloom",["BloomForCausalLM",BloomForCausalLM]],["gpt2",["GPT2LMHeadModel",GPT2LMHeadModel]],["gptj",["GPTJForCausalLM",GPTJForCausalLM]],["gpt_bigcode",["GPTBigCodeForCausalLM",GPTBigCodeForCausalLM]],["gpt_neo",["GPTNeoForCausalLM",GPTNeoForCausalLM]],["gpt_neox",["GPTNeoXForCausalLM",GPTNeoXForCausalLM]],["codegen",["CodeGenForCausalLM",CodeGenForCausalLM]],["llama",["LlamaForCausalLM",LlamaForCausalLM]],["qwen2",["Qwen2ForCausalLM",Qwen2ForCausalLM]],["phi",["PhiForCausalLM",PhiForCausalLM]],["mpt",["MptForCausalLM",MptForCausalLM]],["opt",["OPTForCausalLM",OPTForCausalLM]],["mbart",["MBartForCausalLM",MBartForCausalLM]],["mistral",["MistralForCausalLM",MistralForCausalLM]],["starcoder2",["Starcoder2ForCausalLM",Starcoder2ForCausalLM]],["falcon",["FalconForCausalLM",FalconForCausalLM]],["trocr",["TrOCRForCausalLM",TrOCRForCausalLM]],["stablelm",["StableLmForCausalLM",StableLmForCausalLM]]]),MODEL_FOR_MASKED_LM_MAPPING_NAMES=new Map([["bert",["BertForMaskedLM",BertForMaskedLM]],["roformer",["RoFormerForMaskedLM",RoFormerForMaskedLM]],["electra",["ElectraForMaskedLM",ElectraForMaskedLM]],["esm",["EsmForMaskedLM",EsmForMaskedLM]],["convbert",["ConvBertForMaskedLM",ConvBertForMaskedLM]],["camembert",["CamembertForMaskedLM",CamembertForMaskedLM]],["deberta",["DebertaForMaskedLM",DebertaForMaskedLM]],["deberta-v2",["DebertaV2ForMaskedLM",DebertaV2ForMaskedLM]],["mpnet",["MPNetForMaskedLM",MPNetForMaskedLM]],["albert",["AlbertForMaskedLM",AlbertForMaskedLM]],["distilbert",["DistilBertForMaskedLM",DistilBertForMaskedLM]],["roberta",["RobertaForMaskedLM",RobertaForMaskedLM]],["xlm",["XLMWithLMHeadModel",XLMWithLMHeadModel]],["xlm-roberta",["XLMRobertaForMaskedLM",XLMRobertaForMaskedLM]],["mobilebert",["MobileBertForMaskedLM",MobileBertForMaskedLM]],["squeezebert",["SqueezeBertForMaskedLM",SqueezeBertForMaskedLM]]]),MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES=new Map([["bert",["BertForQuestionAnswering",BertForQuestionAnswering]],["roformer",["RoFormerForQuestionAnswering",RoFormerForQuestionAnswering]],["electra",["ElectraForQuestionAnswering",ElectraForQuestionAnswering]],["convbert",["ConvBertForQuestionAnswering",ConvBertForQuestionAnswering]],["camembert",["CamembertForQuestionAnswering",CamembertForQuestionAnswering]],["deberta",["DebertaForQuestionAnswering",DebertaForQuestionAnswering]],["deberta-v2",["DebertaV2ForQuestionAnswering",DebertaV2ForQuestionAnswering]],["mpnet",["MPNetForQuestionAnswering",MPNetForQuestionAnswering]],["albert",["AlbertForQuestionAnswering",AlbertForQuestionAnswering]],["distilbert",["DistilBertForQuestionAnswering",DistilBertForQuestionAnswering]],["roberta",["RobertaForQuestionAnswering",RobertaForQuestionAnswering]],["xlm",["XLMForQuestionAnswering",XLMForQuestionAnswering]],["xlm-roberta",["XLMRobertaForQuestionAnswering",XLMRobertaForQuestionAnswering]],["mobilebert",["MobileBertForQuestionAnswering",MobileBertForQuestionAnswering]],["squeezebert",["SqueezeBertForQuestionAnswering",SqueezeBertForQuestionAnswering]]]),MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES=new Map([["vit",["ViTForImageClassification",ViTForImageClassification]],["mobilevit",["MobileViTForImageClassification",MobileViTForImageClassification]],["beit",["BeitForImageClassification",BeitForImageClassification]],["deit",["DeiTForImageClassification",DeiTForImageClassification]],["convnext",["ConvNextForImageClassification",ConvNextForImageClassification]],["convnextv2",["ConvNextV2ForImageClassification",ConvNextV2ForImageClassification]],["dinov2",["Dinov2ForImageClassification",Dinov2ForImageClassification]],["resnet",["ResNetForImageClassification",ResNetForImageClassification]],["swin",["SwinForImageClassification",SwinForImageClassification]],["segformer",["SegformerForImageClassification",SegformerForImageClassification]],["efficientnet",["EfficientNetForImageClassification",EfficientNetForImageClassification]]]),MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES=new Map([["detr",["DetrForObjectDetection",DetrForObjectDetection]],["table-transformer",["TableTransformerForObjectDetection",TableTransformerForObjectDetection]],["yolos",["YolosForObjectDetection",YolosForObjectDetection]]]),MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES=new Map([["owlvit",["OwlViTForObjectDetection",OwlViTForObjectDetection]],["owlv2",["Owlv2ForObjectDetection",Owlv2ForObjectDetection]]]),MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES=new Map([["detr",["DetrForSegmentation",DetrForSegmentation]],["clipseg",["CLIPSegForImageSegmentation",CLIPSegForImageSegmentation]]]),MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES=new Map([["segformer",["SegformerForSemanticSegmentation",SegformerForSemanticSegmentation]]]),MODEL_FOR_MASK_GENERATION_MAPPING_NAMES=new Map([["sam",["SamModel",SamModel]]]),MODEL_FOR_CTC_MAPPING_NAMES=new Map([["wav2vec2",["Wav2Vec2ForCTC",Wav2Vec2ForCTC]],["wav2vec2-bert",["Wav2Vec2BertForCTC",Wav2Vec2BertForCTC]],["unispeech",["UniSpeechForCTC",UniSpeechForCTC]],["unispeech-sat",["UniSpeechSatForCTC",UniSpeechSatForCTC]],["wavlm",["WavLMForCTC",WavLMForCTC]],["hubert",["HubertForCTC",HubertForCTC]]]),MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES=new Map([["wav2vec2",["Wav2Vec2ForSequenceClassification",Wav2Vec2ForSequenceClassification]],["wav2vec2-bert",["Wav2Vec2BertForSequenceClassification",Wav2Vec2BertForSequenceClassification]],["unispeech",["UniSpeechForSequenceClassification",UniSpeechForSequenceClassification]],["unispeech-sat",["UniSpeechSatForSequenceClassification",UniSpeechSatForSequenceClassification]],["wavlm",["WavLMForSequenceClassification",WavLMForSequenceClassification]],["hubert",["HubertForSequenceClassification",HubertForSequenceClassification]],["audio-spectrogram-transformer",["ASTForAudioClassification",ASTForAudioClassification]]]),MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES=new Map([["wavlm",["WavLMForXVector",WavLMForXVector]]]),MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES=new Map([["unispeech-sat",["UniSpeechSatForAudioFrameClassification",UniSpeechSatForAudioFrameClassification]],["wavlm",["WavLMForAudioFrameClassification",WavLMForAudioFrameClassification]],["wav2vec2",["Wav2Vec2ForAudioFrameClassification",Wav2Vec2ForAudioFrameClassification]]]),MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES=new Map([["vitmatte",["VitMatteForImageMatting",VitMatteForImageMatting]]]),MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES=new Map([["swin2sr",["Swin2SRForImageSuperResolution",Swin2SRForImageSuperResolution]]]),MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES=new Map([["dpt",["DPTForDepthEstimation",DPTForDepthEstimation]],["depth_anything",["DepthAnythingForDepthEstimation",DepthAnythingForDepthEstimation]],["glpn",["GLPNForDepthEstimation",GLPNForDepthEstimation]]]),MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES=new Map([["clip",["CLIPVisionModelWithProjection",CLIPVisionModelWithProjection]],["siglip",["SiglipVisionModel",SiglipVisionModel]]]),MODEL_CLASS_TYPE_MAPPING=[[MODEL_MAPPING_NAMES_ENCODER_ONLY,MODEL_TYPES.EncoderOnly],[MODEL_MAPPING_NAMES_ENCODER_DECODER,MODEL_TYPES.EncoderDecoder],[MODEL_MAPPING_NAMES_DECODER_ONLY,MODEL_TYPES.DecoderOnly],[MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_WITH_LM_HEAD_MAPPING_NAMES,MODEL_TYPES.DecoderOnly],[MODEL_FOR_MASKED_LM_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,MODEL_TYPES.Vision2Seq],[MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_MASK_GENERATION_MAPPING_NAMES,MODEL_TYPES.MaskGeneration],[MODEL_FOR_CTC_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly]];for(const[d,n]of MODEL_CLASS_TYPE_MAPPING)for(const[o,s]of d.values())MODEL_TYPE_MAPPING.set(o,n),MODEL_CLASS_TO_NAME_MAPPING.set(s,o),MODEL_NAME_TO_CLASS_MAPPING.set(o,s);const CUSTOM_MAPPING=[["CLIPTextModelWithProjection",CLIPTextModelWithProjection,MODEL_TYPES.EncoderOnly],["SiglipTextModel",SiglipTextModel,MODEL_TYPES.EncoderOnly],["ClapTextModelWithProjection",ClapTextModelWithProjection,MODEL_TYPES.EncoderOnly],["ClapAudioModelWithProjection",ClapAudioModelWithProjection,MODEL_TYPES.EncoderOnly]];for(const[d,n,o]of CUSTOM_MAPPING)MODEL_TYPE_MAPPING.set(d,o),MODEL_CLASS_TO_NAME_MAPPING.set(n,d),MODEL_NAME_TO_CLASS_MAPPING.set(d,n);class AutoModel extends PretrainedMixin{}J(AutoModel,"MODEL_CLASS_MAPPINGS",MODEL_CLASS_TYPE_MAPPING.map(n=>n[0])),J(AutoModel,"BASE_IF_FAIL",!0);class Seq2SeqLMOutput extends ModelOutput{constructor({logits:n,past_key_values:o,encoder_outputs:s,decoder_attentions:l=null,cross_attentions:f=null}){super(),this.logits=n,this.past_key_values=o,this.encoder_outputs=s,this.decoder_attentions=l,this.cross_attentions=f}}class SequenceClassifierOutput extends ModelOutput{constructor({logits:n}){super(),this.logits=n}}class XVectorOutput extends ModelOutput{constructor({logits:n,embeddings:o}){super(),this.logits=n,this.embeddings=o}}class TokenClassifierOutput extends ModelOutput{constructor({logits:n}){super(),this.logits=n}}class MaskedLMOutput extends ModelOutput{constructor({logits:n}){super(),this.logits=n}}class QuestionAnsweringModelOutput extends ModelOutput{constructor({start_logits:n,end_logits:o}){super(),this.start_logits=n,this.end_logits=o}}class CausalLMOutput extends ModelOutput{constructor({logits:n}){super(),this.logits=n}}class ImageMattingOutput extends ModelOutput{constructor({alphas:n}){super(),this.alphas=n}}class VitsModelOutput extends ModelOutput{constructor({waveform:n,spectrogram:o}){super(),this.waveform=n,this.spectrogram=o}}const BROWSER_ENV=typeof self<"u";if(!BROWSER_ENV){if(!sharp)throw new Error("Unable to load image processing library.")}env$1.allowLocalModels=!1;const TOKENIZER_MAPPINGS=new Map;self.addEventListener("message",async d=>{let n=TOKENIZER_MAPPINGS.get(d.data.model_id);n||(n=AutoTokenizer.from_pretrained(d.data.model_id),TOKENIZER_MAPPINGS.set(d.data.model_id,new Promise(c=>{n.then(a=>{switch(a.constructor.name){case"LlamaTokenizer":case"Grok1Tokenizer":a.decoder.decoders.pop();break;case"T5Tokenizer":a.decoder.addPrefixSpace=!1;break}c(a)})})));const o=await n,s=d.data.text,l=performance.now(),f=o.encode(s),u=performance.now();console.log("[INFO]",`Tokenized ${s.length} characters in ${(u-l).toFixed(2)}ms`);let p=f.map(c=>o.decode([c])),g=[];switch(o.constructor.name){case"BertTokenizer":g=p.map((c,a)=>a===0||c.startsWith("##")?0:8),p=p.map(c=>c.replace("##",""));break;case"T5Tokenizer":p.length>0&&p.length!==" "&&(p[0]=p[0].replace(/^ /,""));break}self.postMessage({token_ids:f,decoded:p,margins:g})})})();