onnxruntime-web
Version:
A Javascript library for running ONNX models on browsers
14 lines • 406 kB
JavaScript
/*!
* ONNX Runtime Web v1.23.2
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var Ln=Object.defineProperty;var Gp=Object.getOwnPropertyDescriptor;var Hp=Object.getOwnPropertyNames;var Fp=Object.prototype.hasOwnProperty;var Wn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var L=(e,t)=>()=>(e&&(t=e(e=0)),t);var Wt=(e,t)=>{for(var n in t)Ln(e,n,{get:t[n],enumerable:!0})},qp=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hp(t))!Fp.call(e,o)&&o!==n&&Ln(e,o,{get:()=>t[o],enumerable:!(r=Gp(t,o))||r.enumerable});return e};var Xt=e=>qp(Ln({},"__esModule",{value:!0}),e);var wr,kt,Pt,jp,Qi,Gn=L(()=>{"use strict";wr=new Map,kt=[],Pt=(e,t,n)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let r=wr.get(e);if(r===void 0)wr.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let o=kt.indexOf(e);o!==-1&&kt.splice(o,1);for(let a=0;a<kt.length;a++)if(wr.get(kt[a]).priority<=n){kt.splice(a,0,e);return}kt.push(e)}return}throw new TypeError("not a valid backend")},jp=async e=>{let t=wr.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(r){return n||(t.error=`${r}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},Qi=async e=>{let t=e.executionProviders||[],n=t.map(d=>typeof d=="string"?d:d.name),r=n.length===0?kt:n,o,a=[],s=new Set;for(let d of r){let c=await jp(d);typeof c=="string"?a.push({name:d,err:c}):(o||(o=c),o===c&&s.add(d))}if(!o)throw new Error(`no available backend found. ERR: ${a.map(d=>`[${d.name}] ${d.err}`).join(", ")}`);for(let{name:d,err:c}of a)n.includes(d)&&console.warn(`removing requested execution provider "${d}" from session options because it is not available: ${c}`);let u=t.filter(d=>s.has(typeof d=="string"?d:d.name));return[o,new Proxy(e,{get:(d,c)=>c==="executionProviders"?u:Reflect.get(d,c)})]}});var Yi=L(()=>{"use strict";Gn()});var Xi,Ji=L(()=>{"use strict";Xi="1.23.2"});var ea,Ee,Hn=L(()=>{"use strict";Ji();ea="warning",Ee={wasm:{},webgl:{},webgpu:{},versions:{common:Xi},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);ea=e}},get logLevel(){return ea}};Object.defineProperty(Ee,"logLevel",{enumerable:!0})});var we,ta=L(()=>{"use strict";Hn();we=Ee});var ra,na,oa=L(()=>{"use strict";ra=(e,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext("2d");if(r!=null){let o,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=e.dims[2],a=e.dims[3]):(o=e.dims[3],a=e.dims[2]);let s=t?.format!==void 0?t.format:"RGB",u=t?.norm,d,c;u===void 0||u.mean===void 0?d=[255,255,255,255]:typeof u.mean=="number"?d=[u.mean,u.mean,u.mean,u.mean]:(d=[u.mean[0],u.mean[1],u.mean[2],0],u.mean[3]!==void 0&&(d[3]=u.mean[3])),u===void 0||u.bias===void 0?c=[0,0,0,0]:typeof u.bias=="number"?c=[u.bias,u.bias,u.bias,u.bias]:(c=[u.bias[0],u.bias[1],u.bias[2],0],u.bias[3]!==void 0&&(c[3]=u.bias[3]));let m=a*o,f=0,g=m,_=m*2,b=-1;s==="RGBA"?(f=0,g=m,_=m*2,b=m*3):s==="RGB"?(f=0,g=m,_=m*2):s==="RBG"&&(f=0,_=m,g=m*2);for(let w=0;w<a;w++)for(let x=0;x<o;x++){let v=(e.data[f++]-c[0])*d[0],$=(e.data[g++]-c[1])*d[1],T=(e.data[_++]-c[2])*d[2],C=b===-1?255:(e.data[b++]-c[3])*d[3];r.fillStyle="rgba("+v+","+$+","+T+","+C+")",r.fillRect(x,w,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},na=(e,t)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),r;if(n!=null){let o,a,s;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=e.dims[2],a=e.dims[1],s=e.dims[3]):(o=e.dims[3],a=e.dims[2],s=e.dims[1]);let u=t!==void 0&&t.format!==void 0?t.format:"RGB",d=t?.norm,c,m;d===void 0||d.mean===void 0?c=[255,255,255,255]:typeof d.mean=="number"?c=[d.mean,d.mean,d.mean,d.mean]:(c=[d.mean[0],d.mean[1],d.mean[2],255],d.mean[3]!==void 0&&(c[3]=d.mean[3])),d===void 0||d.bias===void 0?m=[0,0,0,0]:typeof d.bias=="number"?m=[d.bias,d.bias,d.bias,d.bias]:(m=[d.bias[0],d.bias[1],d.bias[2],0],d.bias[3]!==void 0&&(m[3]=d.bias[3]));let f=a*o;if(t!==void 0&&(t.format!==void 0&&s===4&&t.format!=="RGBA"||s===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let g=4,_=0,b=1,w=2,x=3,v=0,$=f,T=f*2,C=-1;u==="RGBA"?(v=0,$=f,T=f*2,C=f*3):u==="RGB"?(v=0,$=f,T=f*2):u==="RBG"&&(v=0,T=f,$=f*2),r=n.createImageData(o,a);for(let A=0;A<a*o;_+=g,b+=g,w+=g,x+=g,A++)r.data[_]=(e.data[v++]-m[0])*c[0],r.data[b]=(e.data[$++]-m[1])*c[1],r.data[w]=(e.data[T++]-m[2])*c[2],r.data[x]=C===-1?255:(e.data[C++]-m[3])*c[3]}else throw new Error("Can not access image data");return r}});var Fn,ia,aa,sa,ua,la,da=L(()=>{"use strict";vr();Fn=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:n,width:r}=t,o=t.norm??{mean:255,bias:0},a,s;typeof o.mean=="number"?a=[o.mean,o.mean,o.mean,o.mean]:a=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?s=[o.bias,o.bias,o.bias,o.bias]:s=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let u=t.format!==void 0?t.format:"RGBA",d=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",c=n*r,m=d==="RGBA"?new Float32Array(c*4):new Float32Array(c*3),f=4,g=0,_=1,b=2,w=3,x=0,v=c,$=c*2,T=-1;u==="RGB"&&(f=3,g=0,_=1,b=2,w=-1),d==="RGBA"?T=c*3:d==="RBG"?(x=0,$=c,v=c*2):d==="BGR"&&($=0,v=c,x=c*2);for(let A=0;A<c;A++,g+=f,b+=f,_+=f,w+=f)m[x++]=(e[g]+s[0])/a[0],m[v++]=(e[_]+s[1])/a[1],m[$++]=(e[b]+s[2])/a[2],T!==-1&&w!==-1&&(m[T++]=(e[w]+s[3])/a[3]);return d==="RGBA"?new De("float32",m,[1,4,n,r]):new De("float32",m,[1,3,n,r])},ia=async(e,t)=>{let n=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,r=typeof ImageData<"u"&&e instanceof ImageData,o=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,a=typeof e=="string",s,u=t??{},d=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},c=m=>typeof HTMLCanvasElement<"u"&&m instanceof HTMLCanvasElement||m instanceof OffscreenCanvas?m.getContext("2d"):null;if(n){let m=d();m.width=e.width,m.height=e.height;let f=c(m);if(f!=null){let g=e.height,_=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(g=t.resizedHeight,_=t.resizedWidth),t!==void 0){if(u=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");u.tensorFormat="RGBA",u.height=g,u.width=_}else u.tensorFormat="RGBA",u.height=g,u.width=_;f.drawImage(e,0,0),s=f.getImageData(0,0,_,g).data}else throw new Error("Can not access image data")}else if(r){let m,f;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(m=t.resizedHeight,f=t.resizedWidth):(m=e.height,f=e.width),t!==void 0&&(u=t),u.format="RGBA",u.height=m,u.width=f,t!==void 0){let g=d();g.width=f,g.height=m;let _=c(g);if(_!=null)_.putImageData(e,0,0),s=_.getImageData(0,0,f,m).data;else throw new Error("Can not access image data")}else s=e.data}else if(o){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let m=d();m.width=e.width,m.height=e.height;let f=c(m);if(f!=null){let g=e.height,_=e.width;return f.drawImage(e,0,0,_,g),s=f.getImageData(0,0,_,g).data,u.height=g,u.width=_,Fn(s,u)}else throw new Error("Can not access image data")}else{if(a)return new Promise((m,f)=>{let g=d(),_=c(g);if(!e||!_)return f();let b=new Image;b.crossOrigin="Anonymous",b.src=e,b.onload=()=>{g.width=b.width,g.height=b.height,_.drawImage(b,0,0,g.width,g.height);let w=_.getImageData(0,0,g.width,g.height);u.height=g.height,u.width=g.width,m(Fn(w.data,u))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Fn(s,u);throw new Error("Input data provided is not supported - aborted tensor creation")},aa=(e,t)=>{let{width:n,height:r,download:o,dispose:a}=t,s=[1,r,n,4];return new De({location:"texture",type:"float32",texture:e,dims:s,download:o,dispose:a})},sa=(e,t)=>{let{dataType:n,dims:r,download:o,dispose:a}=t;return new De({location:"gpu-buffer",type:n??"float32",gpuBuffer:e,dims:r,download:o,dispose:a})},ua=(e,t)=>{let{dataType:n,dims:r,download:o,dispose:a}=t;return new De({location:"ml-tensor",type:n??"float32",mlTensor:e,dims:r,download:o,dispose:a})},la=(e,t,n)=>new De({location:"cpu-pinned",type:e,data:t,dims:n??[t.length]})});var Ot,Jt,ca,pa,ma=L(()=>{"use strict";Ot=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Jt=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ca=!1,pa=()=>{if(!ca){ca=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<"u"&&n.from;e&&(Ot.set("int64",BigInt64Array),Jt.set(BigInt64Array,"int64")),t&&(Ot.set("uint64",BigUint64Array),Jt.set(BigUint64Array,"uint64")),r?(Ot.set("float16",n),Jt.set(n,"float16")):Ot.set("float16",Uint16Array)}}});var fa,ha,ga=L(()=>{"use strict";vr();fa=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!="number"||!Number.isSafeInteger(r))throw new TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},ha=(e,t)=>{switch(e.location){case"cpu":return new De(e.type,e.data,t);case"cpu-pinned":return new De({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new De({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new De({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case"ml-tensor":return new De({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}});var De,vr=L(()=>{"use strict";oa();da();ma();ga();De=class{constructor(t,n,r){pa();let o,a;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,o=t.type,a=t.dims,t.location){case"cpu-pinned":{let u=Ot.get(o);if(!u)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(t.data instanceof u))throw new TypeError(`buffer should be of type ${u.name}`);this.cpuData=t.data;break}case"texture":{if(o!=="float32")throw new TypeError(`unsupported type "${o}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint64"&&o!=="int8"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let u,d;if(typeof t=="string")if(o=t,d=r,t==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");u=n}else{let c=Ot.get(t);if(c===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(n)){if(t==="float16"&&c===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${c.name} as data.`);t==="uint64"||t==="int64"?u=c.from(n,BigInt):u=c.from(n)}else if(n instanceof c)u=n;else if(n instanceof Uint8ClampedArray)if(t==="uint8")u=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&n instanceof Uint16Array&&c!==Uint16Array)u=new globalThis.Float16Array(n.buffer,n.byteOffset,n.length);else throw new TypeError(`A ${o} tensor's data must be type of ${c}`)}else if(d=n,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let c=typeof t[0];if(c==="string")o="string",u=t;else if(c==="boolean")o="bool",u=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${c}.`)}else if(t instanceof Uint8ClampedArray)o="uint8",u=Uint8Array.from(t);else{let c=Jt.get(t.constructor);if(c===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);o=c,u=t}if(d===void 0)d=[u.length];else if(!Array.isArray(d))throw new TypeError("A tensor's dims must be a number array");a=d,this.cpuData=u,this.dataLocation="cpu"}let s=fa(a);if(this.cpuData&&s!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(s/2)===this.cpuData.length))throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=a,this.size=s}static async fromImage(t,n){return ia(t,n)}static fromTexture(t,n){return aa(t,n)}static fromGpuBuffer(t,n){return sa(t,n)}static fromMLTensor(t,n){return ua(t,n)}static fromPinnedBuffer(t,n,r){return la(t,n,r)}toDataURL(t){return ra(this,t)}toImageData(t){return na(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,t&&this.disposer&&(this.disposer(),this.disposer=void 0),n}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return ha(this,t)}}});var qe,qn=L(()=>{"use strict";vr();qe=De});var $r,ya,Ne,Me,wt,vt,jn=L(()=>{"use strict";Hn();$r=(e,t)=>{(typeof Ee.trace>"u"?!Ee.wasm.trace:!Ee.trace)||console.timeStamp(`${e}::ORT::${t}`)},ya=(e,t)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let o=0;o<n.length;o++){if(r&&!n[o].includes("TRACE_FUNC")){let a=`FUNC_${e}::${n[o].trim().split(" ")[1]}`;t&&(a+=`::${t}`),$r("CPU",a);return}n[o].includes("TRACE_FUNC")&&(r=!0)}},Ne=e=>{(typeof Ee.trace>"u"?!Ee.wasm.trace:!Ee.trace)||ya("BEGIN",e)},Me=e=>{(typeof Ee.trace>"u"?!Ee.wasm.trace:!Ee.trace)||ya("END",e)},wt=e=>{(typeof Ee.trace>"u"?!Ee.wasm.trace:!Ee.trace)||console.time(`ORT::${e}`)},vt=e=>{(typeof Ee.trace>"u"?!Ee.wasm.trace:!Ee.trace)||console.timeEnd(`ORT::${e}`)}});var xr,ba=L(()=>{"use strict";Gn();qn();jn();xr=class e{constructor(t){this.handler=t}async run(t,n,r){Ne(),wt("InferenceSession.run");let o={},a={};if(typeof t!="object"||t===null||t instanceof qe||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof qe)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(n.length===0)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let c of n){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}.`);o[c]=null}if(typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,m=Object.getOwnPropertyNames(n);for(let f of this.outputNames)if(m.indexOf(f)!==-1){let g=n[f];(g===null||g instanceof qe)&&(c=!0,s=!1,o[f]=g)}if(c){if(typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else a=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of this.inputNames)if(typeof t[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(s)for(let c of this.outputNames)o[c]=null;let u=await this.handler.run(t,o,a),d={};for(let c in u)if(Object.hasOwnProperty.call(u,c)){let m=u[c];m instanceof qe?d[c]=m:d[c]=new qe(m.type,m.data,m.dims)}return vt("InferenceSession.run"),Me(),d}async release(){return this.handler.dispose()}static async create(t,n,r,o){Ne(),wt("InferenceSession.create");let a,s={};if(typeof t=="string"){if(a=t,typeof n=="object"&&n!==null)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(a=t,typeof n=="object"&&n!==null)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let m=t,f=0,g=t.byteLength;if(typeof n=="object"&&n!==null)s=n;else if(typeof n=="number"){if(f=n,!Number.isSafeInteger(f))throw new RangeError("'byteOffset' must be an integer.");if(f<0||f>=m.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${m.byteLength}).`);if(g=t.byteLength-f,typeof r=="number"){if(g=r,!Number.isSafeInteger(g))throw new RangeError("'byteLength' must be an integer.");if(g<=0||f+g>m.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${m.byteLength-f}].`);if(typeof o=="object"&&o!==null)s=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof r<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");a=new Uint8Array(m,f,g)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[u,d]=await Qi(s),c=await u.createInferenceSessionHandler(a,d);return vt("InferenceSession.create"),Me(),new e(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}});var Kp,_a=L(()=>{"use strict";ba();Kp=xr});var wa=L(()=>{"use strict"});var va=L(()=>{"use strict"});var $a=L(()=>{"use strict"});var xa=L(()=>{"use strict"});var Kn={};Wt(Kn,{InferenceSession:()=>Kp,TRACE:()=>$r,TRACE_EVENT_BEGIN:()=>wt,TRACE_EVENT_END:()=>vt,TRACE_FUNC_BEGIN:()=>Ne,TRACE_FUNC_END:()=>Me,Tensor:()=>qe,env:()=>we,registerBackend:()=>Pt});var Ve=L(()=>{"use strict";Yi();ta();_a();qn();wa();va();jn();$a();xa()});var Sr=L(()=>{"use strict"});var Ia={};Wt(Ia,{default:()=>Zp});var Ta,Ca,Zp,Aa=L(()=>{"use strict";Zn();$t();Tr();Ta="ort-wasm-proxy-worker",Ca=globalThis.self?.name===Ta;Ca&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case"init-wasm":Cr(n.wasm).then(()=>{Ir(n).then(()=>{postMessage({type:t})},r=>{postMessage({type:t,err:r})})},r=>{postMessage({type:t,err:r})});break;case"init-ep":{let{epName:r,env:o}=n;Ar(o,r).then(()=>{postMessage({type:t})},a=>{postMessage({type:t,err:a})});break}case"copy-from":{let{buffer:r}=n,o=er(r);postMessage({type:t,out:o});break}case"create":{let{model:r,options:o}=n;Er(r,o).then(a=>{postMessage({type:t,out:a})},a=>{postMessage({type:t,err:a})});break}case"release":kr(n),postMessage({type:t});break;case"run":{let{sessionId:r,inputIndices:o,inputs:a,outputIndices:s,options:u}=n;Pr(r,o,a,s,new Array(s.length).fill(null),u).then(d=>{d.some(c=>c[3]!=="cpu")?postMessage({type:t,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:t,out:d},zr([...a,...d]))},d=>{postMessage({type:t,err:d})});break}case"end-profiling":Or(n),postMessage({type:t});break;default:}}catch(r){postMessage({type:t,err:r})}});Zp=Ca?null:e=>new Worker(e??Le,{type:"module",name:Ta})});var ka={};Wt(ka,{default:()=>Qp});var Ea,Qp,Yp,Pa=L(()=>{"use strict";Ea=async function(e={}){var t,n,r=e,o=new Promise((i,l)=>{t=i,n=l}),a=typeof window=="object",s=typeof WorkerGlobalScope<"u",u=s&&self.name?.startsWith("em-pthread");r.mountExternalData=(i,l)=>{i.startsWith("./")&&(i=i.substring(2)),(r.Fb||(r.Fb=new Map)).set(i,l)},r.unmountExternalData=()=>{delete r.Fb};var d=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,qc:!0}).buffer.constructor;let c=i=>async(...l)=>{try{if(r.Gb)throw Error("Session already started");let p=r.Gb={ec:l[0],errors:[]},h=await i(...l);if(r.Gb!==p)throw Error("Session mismatch");r.Kb?.flush();let y=p.errors;if(0<y.length){let S=await Promise.all(y);if(S=S.filter(k=>k),0<S.length)throw Error(S.join(`
`))}return h}finally{r.Gb=null}};r.jsepInit=(i,l)=>{if(i==="webgpu"){[r.Kb,r.Vb,r.Zb,r.Lb,r.Yb,r.Ab,r.$b,r.bc,r.Wb,r.Xb,r.ac]=l;let p=r.Kb;r.jsepRegisterBuffer=(h,y,S,k)=>p.registerBuffer(h,y,S,k),r.jsepGetBuffer=h=>p.getBuffer(h),r.jsepCreateDownloader=(h,y,S)=>p.createDownloader(h,y,S),r.jsepOnCreateSession=h=>{p.onCreateSession(h)},r.jsepOnReleaseSession=h=>{p.onReleaseSession(h)},r.jsepOnRunStart=h=>p.onRunStart(h),r.cc=(h,y)=>{p.upload(h,y)}}else if(i==="webnn"){let p=l[0];[r.oc,r.Ob,r.webnnEnsureTensor,r.Pb,r.webnnDownloadTensor,r.nc,r.webnnEnableTraceEvent]=l.slice(1),r.webnnReleaseTensorId=r.Ob,r.webnnUploadTensor=r.Pb,r.webnnRegisterMLContext=r.nc,r.webnnOnRunStart=h=>p.onRunStart(h),r.webnnOnRunEnd=p.onRunEnd.bind(p),r.webnnOnReleaseSession=h=>{p.onReleaseSession(h)},r.webnnCreateMLTensorDownloader=(h,y)=>p.createMLTensorDownloader(h,y),r.webnnRegisterMLTensor=(h,y,S,k)=>p.registerMLTensor(h,y,S,k),r.webnnCreateMLContext=h=>p.createMLContext(h),r.webnnRegisterMLConstant=(h,y,S,k,B,U)=>p.registerMLConstant(h,y,S,k,B,r.Fb,U),r.webnnRegisterGraphInput=p.registerGraphInput.bind(p),r.webnnIsGraphInput=p.isGraphInput.bind(p),r.webnnRegisterGraphOutput=p.registerGraphOutput.bind(p),r.webnnIsGraphOutput=p.isGraphOutput.bind(p),r.webnnCreateTemporaryTensor=p.createTemporaryTensor.bind(p),r.webnnIsGraphInputOutputTypeSupported=p.isGraphInputOutputTypeSupported.bind(p)}};let m=()=>{let i=(l,p,h)=>(...y)=>{let S=Xe,k=p?.();y=l(...y);let B=p?.();return k!==B&&(l=B,h(k),p=h=null),Xe!=S?new Promise((U,G)=>{kn={resolve:U,reject:G}}):y};(()=>{for(let l of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])r[l]=i(r[l],()=>r[l],p=>r[l]=p)})(),c!==void 0&&(r._OrtRun=c(r._OrtRun),r._OrtRunWithBinding=c(r._OrtRunWithBinding)),m=void 0};r.asyncInit=()=>{m?.()};var f,g,_=(i,l)=>{throw l},b=import.meta.url,w="";if(a||s){try{w=new URL(".",b).href}catch{}s&&(g=i=>{var l=new XMLHttpRequest;return l.open("GET",i,!1),l.responseType="arraybuffer",l.send(null),new Uint8Array(l.response)}),f=async i=>{if(ce(i))return new Promise((p,h)=>{var y=new XMLHttpRequest;y.open("GET",i,!0),y.responseType="arraybuffer",y.onload=()=>{y.status==200||y.status==0&&y.response?p(y.response):h(y.status)},y.onerror=h,y.send(null)});var l=await fetch(i,{credentials:"same-origin"});if(l.ok)return l.arrayBuffer();throw Error(l.status+" : "+l.url)}}var x,v,$,T,C,A,I,z,D,R,H,q,Y,ne,F,me=console.log.bind(console),oe=console.error.bind(console),j=me,ie=oe,Z=!1,ce=i=>i.startsWith("file://");function Te(){return v.buffer!=C.buffer&&fe(),C}function pe(){return v.buffer!=C.buffer&&fe(),A}function J(){return v.buffer!=C.buffer&&fe(),I}function V(){return v.buffer!=C.buffer&&fe(),z}function O(){return v.buffer!=C.buffer&&fe(),D}function X(){return v.buffer!=C.buffer&&fe(),R}function ze(){return v.buffer!=C.buffer&&fe(),H}function Oe(){return v.buffer!=C.buffer&&fe(),ne}if(u){let i=function(l){try{var p=l.data,h=p.Db;if(h==="load"){let y=[];self.onmessage=S=>y.push(S),self.startWorker=()=>{postMessage({Db:"loaded"});for(let S of y)i(S);self.onmessage=i};for(let S of p.Sb)r[S]&&!r[S].proxy||(r[S]=(...k)=>{postMessage({Db:"callHandler",Rb:S,args:k})},S=="print"&&(j=r[S]),S=="printErr"&&(ie=r[S]));v=p.kc,fe(),F(p.lc)}else if(h==="run"){vc(p.Bb),Mn(p.Bb,0,0,1,0,0),qo(),An(p.Bb),xe||(Ui(),xe=!0);try{$c(p.hc,p.Jb)}catch(y){if(y!="unwind")throw y}}else p.target!=="setimmediate"&&(h==="checkMailbox"?xe&&dr():h&&(ie(`worker: received unknown command ${h}`),ie(p)))}catch(y){throw Ni(),y}};var Tg=i,xe=!1;self.onunhandledrejection=l=>{throw l.reason||l},self.onmessage=i}function fe(){var i=v.buffer;r.HEAP8=C=new Int8Array(i),I=new Int16Array(i),r.HEAPU8=A=new Uint8Array(i),z=new Uint16Array(i),r.HEAP32=D=new Int32Array(i),r.HEAPU32=R=new Uint32Array(i),H=new Float32Array(i),ne=new Float64Array(i),q=new BigInt64Array(i),Y=new BigUint64Array(i)}function Fe(){u?startWorker(r):M.Da()}var mt,ft=0,Nt=null;function No(){if(--ft==0&&Nt){var i=Nt;Nt=null,i()}}function ht(i){throw ie(i="Aborted("+i+")"),Z=!0,i=new WebAssembly.RuntimeError(i+". Build with -sASSERTIONS for more info."),n(i),i}function Vo(){return{a:{L:Lp,Aa:Vp,b:Sc,$:Qo,A:Jo,pa:ei,X:ti,Z:ri,qa:ni,na:oi,ga:ii,ma:ai,J:si,Y:ui,V:li,oa:di,W:ci,va:Tc,E:Ic,Q:Ac,O:kc,D:Oc,v:zc,s:Dc,P:Bc,z:Wc,R:Gc,ja:Hc,T:Fc,aa:qc,M:jc,F:Kc,ia:An,sa:Zc,r:Qc,Ca:Yc,w:ep,o:tp,m:np,c:Sn,Ba:op,n:ip,j:up,u:lp,p:dp,f:cp,t:pp,l:mp,e:fp,k:hp,h:gp,g:yp,d:bp,da:_p,ea:wp,fa:vp,ba:Si,ca:Ti,N:Ci,xa:xp,ua:Cp,i:Ip,C:Ap,G:Ep,ta:Sp,x:kp,ra:Pp,U:Op,q:$p,y:zp,K:Dp,S:Bp,za:Mp,ya:Rp,ka:ki,la:Pi,_:wn,B:Oi,I:zi,ha:Di,H:Bi,a:v,wa:_n}}}class yn{name="ExitStatus";constructor(l){this.message=`Program terminated with exit(${l})`,this.status=l}}var Lo=i=>{i.terminate(),i.onmessage=()=>{}},bn=[],Wo=i=>{yt.length==0&&(Ko(),jo(yt[0]));var l=yt.pop();if(!l)return 6;Zt.push(l),It[i.Bb]=l,l.Bb=i.Bb;var p={Db:"run",hc:i.fc,Jb:i.Jb,Bb:i.Bb};return l.postMessage(p,i.Nb),0},gt=0,$e=(i,l,...p)=>{for(var h=2*p.length,y=Nn(),S=Un(8*h),k=S>>>3,B=0;B<p.length;B++){var U=p[B];typeof U=="bigint"?(q[k+2*B]=1n,q[k+2*B+1]=U):(q[k+2*B]=0n,Oe()[k+2*B+1>>>0]=U)}return i=Vi(i,0,h,S,l),_r(y),i};function _n(i){if(u)return $e(0,1,i);if(T=i,!(0<gt)){for(var l of Zt)Lo(l);for(l of yt)Lo(l);yt=[],Zt=[],It={},Z=!0}_(0,new yn(i))}function Go(i){if(u)return $e(1,0,i);wn(i)}var wn=i=>{if(T=i,u)throw Go(i),"unwind";_n(i)},yt=[],Zt=[],Ho=[],It={},Fo=i=>{var l=i.Bb;delete It[l],yt.push(i),Zt.splice(Zt.indexOf(i),1),i.Bb=0,Li(l)};function qo(){Ho.forEach(i=>i())}var jo=i=>new Promise(l=>{i.onmessage=y=>{var S=(y=y.data).Db;if(y.Hb&&y.Hb!=Bn()){var k=It[y.Hb];k?k.postMessage(y,y.Nb):ie(`Internal error! Worker sent a message "${S}" to target pthread ${y.Hb}, but that thread no longer exists!`)}else S==="checkMailbox"?dr():S==="spawnThread"?Wo(y):S==="cleanupThread"?Fo(It[y.ic]):S==="loaded"?(i.loaded=!0,l(i)):y.target==="setimmediate"?i.postMessage(y):S==="callHandler"?r[y.Rb](...y.args):S&&ie(`worker sent an unknown command ${S}`)},i.onerror=y=>{throw ie(`worker sent an error! ${y.filename}:${y.lineno}: ${y.message}`),y};var p,h=[];for(p of[])r.propertyIsEnumerable(p)&&h.push(p);i.postMessage({Db:"load",Sb:h,kc:v,lc:$})});function Ko(){var i=new Worker((()=>{let l=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new l("ort.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});yt.push(i)}var vc=i=>{fe();var l=X()[i+52>>>2>>>0];i=X()[i+56>>>2>>>0],Hi(l,l-i),_r(l)},$c=(i,l)=>{gt=0,i=Fi(i,l),0<gt?T=i:Rn(i)};class xc{constructor(l){this.Ib=l-24}}function Sc(i,l,p){var h=new xc(i>>>=0);throw l>>>=0,p>>>=0,X()[h.Ib+16>>>2>>>0]=0,X()[h.Ib+4>>>2>>>0]=l,X()[h.Ib+8>>>2>>>0]=p,i}function Zo(i,l,p,h){return u?$e(2,1,i,l,p,h):Qo(i,l,p,h)}function Qo(i,l,p,h){if(i>>>=0,p>>>=0,h>>>=0,d===void 0)return 6;var y=[];return u&&y.length===0?Zo(i,l>>>=0,p,h):(i={fc:p,Bb:i,Jb:h,Nb:y},u?(i.Db="spawnThread",postMessage(i,y),0):Wo(i))}var Yo=typeof TextDecoder<"u"?new TextDecoder:void 0,Xo=(i,l=0,p=NaN)=>{var h=(l>>>=0)+p;for(p=l;i[p]&&!(p>=h);)++p;if(16<p-l&&i.buffer&&Yo)return Yo.decode(i.buffer instanceof ArrayBuffer?i.subarray(l,p):i.slice(l,p));for(h="";l<p;){var y=i[l++];if(128&y){var S=63&i[l++];if((224&y)==192)h+=String.fromCharCode((31&y)<<6|S);else{var k=63&i[l++];65536>(y=(240&y)==224?(15&y)<<12|S<<6|k:(7&y)<<18|S<<12|k<<6|63&i[l++])?h+=String.fromCharCode(y):(y-=65536,h+=String.fromCharCode(55296|y>>10,56320|1023&y))}}else h+=String.fromCharCode(y)}return h},Ce=(i,l)=>(i>>>=0)?Xo(pe(),i,l):"";function Jo(i,l,p){return u?$e(3,1,i,l,p):0}function ei(i,l){if(u)return $e(4,1,i,l)}function ti(i,l){if(u)return $e(5,1,i,l)}function ri(i,l,p){if(u)return $e(6,1,i,l,p)}function ni(i,l,p){return u?$e(7,1,i,l,p):0}function oi(i,l){if(u)return $e(8,1,i,l)}function ii(i,l,p){if(u)return $e(9,1,i,l,p)}function ai(i,l,p,h){if(u)return $e(10,1,i,l,p,h)}function si(i,l,p,h){if(u)return $e(11,1,i,l,p,h)}function ui(i,l,p,h){if(u)return $e(12,1,i,l,p,h)}function li(i){if(u)return $e(13,1,i)}function di(i,l){if(u)return $e(14,1,i,l)}function ci(i,l,p){if(u)return $e(15,1,i,l,p)}var pi,Tc=()=>ht(""),Ye=i=>{for(var l="";pe()[i>>>0];)l+=pi[pe()[i++>>>0]];return l},vn={},$n={},Cc={},Vt=r.BindingError=class extends Error{constructor(i){super(i),this.name="BindingError"}};function st(i,l,p={}){return function(h,y,S={}){var k=y.name;if(!h)throw new Vt(`type "${k}" must have a positive integer typeid pointer`);if($n.hasOwnProperty(h)){if(S.Tb)return;throw new Vt(`Cannot register type '${k}' twice`)}$n[h]=y,delete Cc[h],vn.hasOwnProperty(h)&&(y=vn[h],delete vn[h],y.forEach(B=>B()))}(i,l,p)}var mi=(i,l,p)=>{switch(l){case 1:return p?h=>Te()[h>>>0]:h=>pe()[h>>>0];case 2:return p?h=>J()[h>>>1>>>0]:h=>V()[h>>>1>>>0];case 4:return p?h=>O()[h>>>2>>>0]:h=>X()[h>>>2>>>0];case 8:return p?h=>q[h>>>3]:h=>Y[h>>>3];default:throw new TypeError(`invalid integer width (${l}): ${i}`)}};function Ic(i,l,p){p>>>=0,st(i>>>=0,{name:l=Ye(l>>>0),fromWireType:h=>h,toWireType:function(h,y){if(typeof y!="bigint"&&typeof y!="number")throw y=y===null?"null":(h=typeof y)=="object"||h==="array"||h==="function"?y.toString():""+y,new TypeError(`Cannot convert "${y}" to ${this.name}`);return typeof y=="number"&&(y=BigInt(y)),y},Cb:bt,readValueFromPointer:mi(l,p,l.indexOf("u")==-1),Eb:null})}var bt=8;function Ac(i,l,p,h){st(i>>>=0,{name:l=Ye(l>>>0),fromWireType:function(y){return!!y},toWireType:function(y,S){return S?p:h},Cb:bt,readValueFromPointer:function(y){return this.fromWireType(pe()[y>>>0])},Eb:null})}var xn=[],ut=[];function Sn(i){9<(i>>>=0)&&--ut[i+1]==0&&(ut[i]=void 0,xn.push(i))}var Be=i=>{if(!i)throw new Vt(`Cannot use deleted val. handle = ${i}`);return ut[i]},Ge=i=>{switch(i){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let l=xn.pop()||ut.length;return ut[l]=i,ut[l+1]=1,l}};function Tn(i){return this.fromWireType(X()[i>>>2>>>0])}var Ec={name:"emscripten::val",fromWireType:i=>{var l=Be(i);return Sn(i),l},toWireType:(i,l)=>Ge(l),Cb:bt,readValueFromPointer:Tn,Eb:null};function kc(i){return st(i>>>0,Ec)}var Pc=(i,l)=>{switch(l){case 4:return function(p){return this.fromWireType(ze()[p>>>2>>>0])};case 8:return function(p){return this.fromWireType(Oe()[p>>>3>>>0])};default:throw new TypeError(`invalid float width (${l}): ${i}`)}};function Oc(i,l,p){p>>>=0,st(i>>>=0,{name:l=Ye(l>>>0),fromWireType:h=>h,toWireType:(h,y)=>y,Cb:bt,readValueFromPointer:Pc(l,p),Eb:null})}function zc(i,l,p,h,y){if(i>>>=0,p>>>=0,l=Ye(l>>>0),y===-1&&(y=4294967295),y=B=>B,h===0){var S=32-8*p;y=B=>B<<S>>>S}var k=l.includes("unsigned")?function(B,U){return U>>>0}:function(B,U){return U};st(i,{name:l,fromWireType:y,toWireType:k,Cb:bt,readValueFromPointer:mi(l,p,h!==0),Eb:null})}function Dc(i,l,p){function h(S){var k=X()[S>>>2>>>0];return S=X()[S+4>>>2>>>0],new y(Te().buffer,S,k)}var y=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][l];st(i>>>=0,{name:p=Ye(p>>>0),fromWireType:h,Cb:bt,readValueFromPointer:h},{Tb:!0})}var At=(i,l,p)=>{var h=pe();if(l>>>=0,0<p){var y=l;p=l+p-1;for(var S=0;S<i.length;++S){var k=i.charCodeAt(S);if(55296<=k&&57343>=k&&(k=65536+((1023&k)<<10)|1023&i.charCodeAt(++S)),127>=k){if(l>=p)break;h[l++>>>0]=k}else{if(2047>=k){if(l+1>=p)break;h[l++>>>0]=192|k>>6}else{if(65535>=k){if(l+2>=p)break;h[l++>>>0]=224|k>>12}else{if(l+3>=p)break;h[l++>>>0]=240|k>>18,h[l++>>>0]=128|k>>12&63}h[l++>>>0]=128|k>>6&63}h[l++>>>0]=128|63&k}}h[l>>>0]=0,i=l-y}else i=0;return i},Cn=i=>{for(var l=0,p=0;p<i.length;++p){var h=i.charCodeAt(p);127>=h?l++:2047>=h?l+=2:55296<=h&&57343>=h?(l+=4,++p):l+=3}return l};function Bc(i,l){st(i>>>=0,{name:l=Ye(l>>>0),fromWireType:function(p){for(var h,y=X()[p>>>2>>>0],S=p+4,k=S,B=0;B<=y;++B){var U=S+B;B!=y&&pe()[U>>>0]!=0||(k=Ce(k,U-k),h===void 0?h=k:(h+="\0",h+=k),k=U+1)}return lt(p),h},toWireType:function(p,h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));var y=typeof h=="string";if(!(y||ArrayBuffer.isView(h)&&h.BYTES_PER_ELEMENT==1))throw new Vt("Cannot pass non-string to std::string");var S=y?Cn(h):h.length,k=br(4+S+1),B=k+4;return X()[k>>>2>>>0]=S,y?At(h,B,S+1):pe().set(h,B>>>0),p!==null&&p.push(lt,k),k},Cb:bt,readValueFromPointer:Tn,Eb(p){lt(p)}})}var fi=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Mc=(i,l)=>{for(var p=i>>1,h=p+l/2;!(p>=h)&&V()[p>>>0];)++p;if(32<(p<<=1)-i&&fi)return fi.decode(pe().slice(i,p));for(p="",h=0;!(h>=l/2);++h){var y=J()[i+2*h>>>1>>>0];if(y==0)break;p+=String.fromCharCode(y)}return p},Rc=(i,l,p)=>{if(p??=2147483647,2>p)return 0;var h=l;p=(p-=2)<2*i.length?p/2:i.length;for(var y=0;y<p;++y){var S=i.charCodeAt(y);J()[l>>>1>>>0]=S,l+=2}return J()[l>>>1>>>0]=0,l-h},Uc=i=>2*i.length,Nc=(i,l)=>{for(var p=0,h="";!(p>=l/4);){var y=O()[i+4*p>>>2>>>0];if(y==0)break;++p,65536<=y?(y-=65536,h+=String.fromCharCode(55296|y>>10,56320|1023&y)):h+=String.fromCharCode(y)}return h},Vc=(i,l,p)=>{if(l>>>=0,p??=2147483647,4>p)return 0;var h=l;p=h+p-4;for(var y=0;y<i.length;++y){var S=i.charCodeAt(y);if(55296<=S&&57343>=S&&(S=65536+((1023&S)<<10)|1023&i.charCodeAt(++y)),O()[l>>>2>>>0]=S,(l+=4)+4>p)break}return O()[l>>>2>>>0]=0,l-h},Lc=i=>{for(var l=0,p=0;p<i.length;++p){var h=i.charCodeAt(p);55296<=h&&57343>=h&&++p,l+=4}return l};function Wc(i,l,p){if(i>>>=0,l>>>=0,p=Ye(p>>>=0),l===2)var h=Mc,y=Rc,S=Uc,k=B=>V()[B>>>1>>>0];else l===4&&(h=Nc,y=Vc,S=Lc,k=B=>X()[B>>>2>>>0]);st(i,{name:p,fromWireType:B=>{for(var U,G=X()[B>>>2>>>0],Q=B+4,re=0;re<=G;++re){var de=B+4+re*l;re!=G&&k(de)!=0||(Q=h(Q,de-Q),U===void 0?U=Q:(U+="\0",U+=Q),Q=de+l)}return lt(B),U},toWireType:(B,U)=>{if(typeof U!="string")throw new Vt(`Cannot pass non-string to C++ string type ${p}`);var G=S(U),Q=br(4+G+l);return X()[Q>>>2>>>0]=G/l,y(U,Q+4,G+l),B!==null&&B.push(lt,Q),Q},Cb:bt,readValueFromPointer:Tn,Eb(B){lt(B)}})}function Gc(i,l){st(i>>>=0,{Ub:!0,name:l=Ye(l>>>0),Cb:0,fromWireType:()=>{},toWireType:()=>{}})}function Hc(i){Mn(i>>>0,!s,1,!a,131072,!1),qo()}var In=i=>{if(!Z)try{if(i(),!(0<gt))try{u?Rn(T):wn(T)}catch(l){l instanceof yn||l=="unwind"||_(0,l)}}catch(l){l instanceof yn||l=="unwind"||_(0,l)}};function An(i){i>>>=0,typeof Atomics.jc=="function"&&(Atomics.jc(O(),i>>>2,i).value.then(dr),i+=128,Atomics.store(O(),i>>>2,1))}var dr=()=>{var i=Bn();i&&(An(i),In(Gi))};function Fc(i,l){(i>>>=0)==l>>>0?setTimeout(dr):u?postMessage({Hb:i,Db:"checkMailbox"}):(i=It[i])&&i.postMessage({Db:"checkMailbox"})}var En=[];function qc(i,l,p,h,y){for(l>>>=0,h/=2,En.length=h,p=y>>>0>>>3,y=0;y<h;y++)En[y]=q[p+2*y]?q[p+2*y+1]:Oe()[p+2*y+1>>>0];return(l?Dn[l]:Np[i])(...En)}var jc=()=>{gt=0};function Kc(i){i>>>=0,u?postMessage({Db:"cleanupThread",ic:i}):Fo(It[i])}function Zc(i){}var cr=(i,l)=>{var p=$n[i];if(p===void 0)throw i=Ri(i),p=Ye(i),lt(i),new Vt(`${l} has unknown type ${p}`);return p},hi=(i,l,p)=>{var h=[];return i=i.toWireType(h,p),h.length&&(X()[l>>>2>>>0]=Ge(h)),i};function Qc(i,l,p){return l>>>=0,p>>>=0,i=Be(i>>>0),l=cr(l,"emval::as"),hi(l,p,i)}function Yc(i,l){return l>>>=0,i=Be(i>>>0),(l=cr(l,"emval::as")).toWireType(null,i)}var pr=i=>{try{i()}catch(l){ht(l)}},_t=0,Xe=null,gi=0,mr=[],yi={},bi={},Xc=0,kn=null,Jc=[];function _i(i){return function(l){if(!Z){if(_t===0){var p=!1,h=!1;l((y=0)=>{if(!Z&&(gi=y,p=!0,h)){_t=2,pr(()=>Ki(Xe)),typeof MainLoop<"u"&&MainLoop.Qb&&MainLoop.resume(),y=!1;try{var S=function(){var U=O()[Xe+8>>>2>>>0];return U=M[bi[U]],--gt,U()}()}catch(U){S=U,y=!0}var k=!1;if(!Xe){var B=kn;B&&(kn=null,(y?B.reject:B.resolve)(S),k=!0)}if(y&&!k)throw S}}),h=!0,p||(_t=1,Xe=function(){var y=br(65548),S=y+12;X()[y>>>2>>>0]=S,X()[y+4>>>2>>>0]=S+65536,S=mr[0];var k=yi[S];return k===void 0&&(k=Xc++,yi[S]=k,bi[k]=S),S=k,O()[y+8>>>2>>>0]=S,y}(),typeof MainLoop<"u"&&MainLoop.Qb&&MainLoop.pause(),pr(()=>qi(Xe)))}else _t===2?(_t=0,pr(Zi),lt(Xe),Xe=null,Jc.forEach(In)):ht(`invalid state: ${_t}`);return gi}}(l=>{i().then(l)})}function ep(i){return i>>>=0,_i(async()=>{var l=await Be(i);return Ge(l)})}var fr=[];function tp(i,l,p,h){return p>>>=0,h>>>=0,(i=fr[i>>>0])(null,l=Be(l>>>0),p,h)}var rp={},hr=i=>{var l=rp[i];return l===void 0?Ye(i):l};function np(i,l,p,h,y){return p>>>=0,h>>>=0,y>>>=0,(i=fr[i>>>0])(l=Be(l>>>0),l[p=hr(p)],h,y)}function op(i,l){return l>>>=0,(i=Be(i>>>0))==Be(l)}var wi=()=>typeof globalThis=="object"?globalThis:Function("return this")();function ip(i){return(i>>>=0)==0?Ge(wi()):(i=hr(i),Ge(wi()[i]))}var ap=i=>{var l=fr.length;return fr.push(i),l},sp=(i,l)=>{for(var p=Array(i),h=0;h<i;++h)p[h]=cr(X()[l+4*h>>>2>>>0],`parameter ${h}`);return p};function up(i,l,p){var h=(l=sp(i,l>>>0)).shift();i--;var y=`return function (obj, func, destructorsRef, args) {
`,S=0,k=[];p===0&&k.push("obj");for(var B=["retType"],U=[h],G=0;G<i;++G)k.push(`arg${G}`),B.push(`argType${G}`),U.push(l[G]),y+=` var arg${G} = argType${G}.readValueFromPointer(args${S?"+"+S:""});
`,S+=l[G].Cb;return y+=` var rv = ${p===1?"new func":"func.call"}(${k.join(", ")});
`,h.Ub||(B.push("emval_returnValue"),U.push(hi),y+=` return emval_returnValue(retType, destructorsRef, rv);
`),i=new Function(...B,y+`};
`)(...U),p=`methodCaller<(${l.map(Q=>Q.name).join(", ")}) => ${h.name}>`,ap(Object.defineProperty(i,"name",{value:p}))}function lp(i){return i=hr(i>>>0),Ge(r[i])}function dp(i,l){return l>>>=0,i=Be(i>>>0),l=Be(l),Ge(i[l])}function cp(i){9<(i>>>=0)&&(ut[i+1]+=1)}function pp(){return Ge([])}function mp(i){i=Be(i>>>0);for(var l=Array(i.length),p=0;p<i.length;p++)l[p]=i[p];return Ge(l)}function fp(i){return Ge(hr(i>>>0))}function hp(){return Ge({})}function gp(i){for(var l=Be(i>>>=0);l.length;){var p=l.pop();l.pop()(p)}Sn(i)}function yp(i,l,p){l>>>=0,p>>>=0,i=Be(i>>>0),l=Be(l),p=Be(p),i[l]=p}function bp(i,l){return l>>>=0,i=(i=cr(i>>>0,"_emval_take_value")).readValueFromPointer(l),Ge(i)}function _p(i,l){i=-9007199254740992>i||9007199254740992<i?NaN:Number(i),l>>>=0,i=new Date(1e3*i),O()[l>>>2>>>0]=i.getUTCSeconds(),O()[l+4>>>2>>>0]=i.getUTCMinutes(),O()[l+8>>>2>>>0]=i.getUTCHours(),O()[l+12>>>2>>>0]=i.getUTCDate(),O()[l+16>>>2>>>0]=i.getUTCMonth(),O()[l+20>>>2>>>0]=i.getUTCFullYear()-1900,O()[l+24>>>2>>>0]=i.getUTCDay(),i=(i.getTime()-Date.UTC(i.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,O()[l+28>>>2>>>0]=i}var vi=i=>i%4==0&&(i%100!=0||i%400==0),$i=[0,31,60,91,121,152,182,213,244,274,305,335],xi=[0,31,59,90,120,151,181,212,243,273,304,334];function wp(i,l){i=-9007199254740992>i||9007199254740992<i?NaN:Number(i),l>>>=0,i=new Date(1e3*i),O()[l>>>2>>>0]=i.getSeconds(),O()[l+4>>>2>>>0]=i.getMinutes(),O()[l+8>>>2>>>0]=i.getHours(),O()[l+12>>>2>>>0]=i.getDate(),O()[l+16>>>2>>>0]=i.getMonth(),O()[l+20>>>2>>>0]=i.getFullYear()-1900,O()[l+24>>>2>>>0]=i.getDay();var p=(vi(i.getFullYear())?$i:xi)[i.getMonth()]+i.getDate()-1|0;O()[l+28>>>2>>>0]=p,O()[l+36>>>2>>>0]=-60*i.getTimezoneOffset(),p=new Date(i.getFullYear(),6,1).getTimezoneOffset();var h=new Date(i.getFullYear(),0,1).getTimezoneOffset();i=0|(p!=h&&i.getTimezoneOffset()==Math.min(h,p)),O()[l+32>>>2>>>0]=i}function vp(i){i>>>=0;var l=new Date(O()[i+20>>>2>>>0]+1900,O()[i+16>>>2>>>0],O()[i+12>>>2>>>0],O()[i+8>>>2>>>0],O()[i+4>>>2>>>0],O()[i>>>2>>>0],0),p=O()[i+32>>>2>>>0],h=l.getTimezoneOffset(),y=new Date(l.getFullYear(),6,1).getTimezoneOffset(),S=new Date(l.getFullYear(),0,1).getTimezoneOffset(),k=Math.min(S,y);return 0>p?O()[i+32>>>2>>>0]=+(y!=S&&k==h):0<p!=(k==h)&&(y=Math.max(S,y),l.setTime(l.getTime()+6e4*((0<p?k:y)-h))),O()[i+24>>>2>>>0]=l.getDay(),p=(vi(l.getFullYear())?$i:xi)[l.getMonth()]+l.getDate()-1|0,O()[i+28>>>2>>>0]=p,O()[i>>>2>>>0]=l.getSeconds(),O()[i+4>>>2>>>0]=l.getMinutes(),O()[i+8>>>2>>>0]=l.getHours(),O()[i+12>>>2>>>0]=l.getDate(),O()[i+16>>>2>>>0]=l.getMonth(),O()[i+20>>>2>>>0]=l.getYear(),i=l.getTime(),BigInt(isNaN(i)?-1:i/1e3)}function Si(i,l,p,h,y,S,k){return u?$e(16,1,i,l,p,h,y,S,k):-52}function Ti(i,l,p,h,y,S){if(u)return $e(17,1,i,l,p,h,y,S)}var Qt={},$p=()=>performance.timeOrigin+performance.now();function Ci(i,l){if(u)return $e(18,1,i,l);if(Qt[i]&&(clearTimeout(Qt[i].id),delete Qt[i]),!l)return 0;var p=setTimeout(()=>{delete Qt[i],In(()=>Wi(i,performance.timeOrigin+performance.now()))},l);return Qt[i]={id:p,rc:l},0}function xp(i,l,p,h){i>>>=0,l>>>=0,p>>>=0,h>>>=0;var y=new Date().getFullYear(),S=new Date(y,0,1).getTimezoneOffset();y=new Date(y,6,1).getTimezoneOffset();var k=Math.max(S,y);X()[i>>>2>>>0]=60*k,O()[l>>>2>>>0]=+(S!=y),i=(l=B=>{var U=Math.abs(B);return`UTC${0<=B?"-":"+"}${String(Math.floor(U/60)).padStart(2,"0")}${String(U%60).padStart(2,"0")}`})(S),l=l(y),y<S?(At(i,p,17),At(l,h,17)):(At(i,h,17),At(l,p,17))}var Sp=()=>Date.now(),Tp=1;function Cp(i,l,p){if(!(0<=i&&3>=i))return 28;if(i===0)i=Date.now();else{if(!Tp)return 52;i=performance.timeOrigin+performance.now()}return q[p>>>0>>>3]=BigInt(Math.round(1e6*i)),0}var Pn=[],Ii=(i,l)=>{Pn.length=0;for(var p;p=pe()[i++>>>0];){var h=p!=105;l+=(h&=p!=112)&&l%8?4:0,Pn.push(p==112?X()[l>>>2>>>0]:p==106?q[l>>>3]:p==105?O()[l>>>2>>>0]:Oe()[l>>>3>>>0]),l+=h?8:4}return Pn};function Ip(i,l,p){return i>>>=0,l=Ii(l>>>0,p>>>0),Dn[i](...l)}function Ap(i,l,p){return i>>>=0,l=Ii(l>>>0,p>>>0),Dn[i](...l)}var Ep=()=>{};function kp(i,l){return ie(Ce(i>>>0,l>>>0))}var Pp=()=>{throw gt+=1,"unwind"};function Op(){return 4294901760}var zp=()=>navigator.hardwareConcurrency;function Dp(){return ht("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function Bp(i){i>>>=0;var l=pe().length;if(i<=l||4294901760<i)return!1;for(var p=1;4>=p;p*=2){var h=l*(1+.2/p);h=Math.min(h,i+100663296);e:{h=(Math.min(4294901760,65536*Math.ceil(Math.max(i,h)/65536))-v.buffer.byteLength+65535)/65536|0;try{v.grow(h),fe();var y=1;break e}catch{}y=void 0}if(y)return!0}return!1}var gr=()=>(ht("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),Lt={},Ai=i=>{i.forEach(l=>{var p=gr();p&&(Lt[p]=l)})};function Mp(){var i=Error().stack.toString().split(`
`);return i[0]=="Error"&&i.shift(),Ai(i),Lt.Mb=gr(),Lt.dc=i,Lt.Mb}function Rp(i,l,p){if(i>>>=0,l>>>=0,Lt.Mb==i)var h=Lt.dc;else(h=Error().stack.toString().split(`
`))[0]=="Error"&&h.shift(),Ai(h);for(var y=3;h[y]&&gr()!=i;)++y;for(i=0;i<p&&h[i+y];++i)O()[l+4*i>>>2>>>0]=gr();return i}var On,zn={},Ei=()=>{if(!On){var i,l={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:"./this.program"};for(i in zn)zn[i]===void 0?delete l[i]:l[i]=zn[i];var p=[];for(i in l)p.push(`${i}=${l[i]}`);On=p}return On};function ki(i,l){if(u)return $e(19,1,i,l);i>>>=0,l>>>=0;var p,h=0,y=0;for(p of Ei()){var S=l+h;X()[i+y>>>2>>>0]=S,h+=At(p,S,1/0)+1,y+=4}return 0}function Pi(i,l){if(u)return $e(20,1,i,l);i>>>=0,l>>>=0;var p=Ei();for(var h of(X()[i>>>2>>>0]=p.length,i=0,p))i+=Cn(h)+1;return X()[l>>>2>>>0]=i,0}function Oi(i){return u?$e(21,1,i):52}function zi(i,l,p,h){return u?$e(22,1,i,l,p,h):52}function Di(i,l,p,h){return u?$e(23,1,i,l,p,h):70}var Up=[null,[],[]];function Bi(i,l,p,h){if(u)return $e(24,1,i,l,p,h);l>>>=0,p>>>=0,h>>>=0;for(var y=0,S=0;S<p;S++){var k=X()[l>>>2>>>0],B=X()[l+4>>>2>>>0];l+=8;for(var U=0;U<B;U++){var G=i,Q=pe()[k+U>>>0],re=Up[G];Q===0||Q===10?((G===1?j:ie)(Xo(re)),re.length=0):re.push(Q)}y+=B}return X()[h>>>2>>>0]=y,0}u||function(){for(var i=r.numThreads-1;i--;)Ko();bn.push(()=>{ft++,function(l){u?l():Promise.all(yt.map(jo)).then(l)}(()=>No())})}();for(var Mi=Array(256),yr=0;256>yr;++yr)Mi[yr]=String.fromCharCode(yr);pi=Mi,ut.push(0,1,void 0,1,null,1,!0,1,!1,1),r.count_emval_handles=()=>ut.length/2-5-xn.length,u||(v=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),fe()),r.wasmBinary&&(x=r.wasmBinary),r.stackSave=()=>Nn(),r.stackRestore=i=>_r(i),r.stackAlloc=i=>Un(i),r.setValue=function(i,l,p="i8"){switch(p.endsWith("*")&&(p="*"),p){case"i1":case"i8":Te()[i>>>0]=l;break;case"i16":J()[i>>>1>>>0]=l;break;case"i32":O()[i>>>2>>>0]=l;break;case"i64":q[i>>>3]=BigInt(l);break;case"float":ze()[i>>>2>>>0]=l;break;case"double":Oe()[i>>>3>>>0]=l;break;case"*":X()[i>>>2>>>0]=l;break;default:ht(`invalid type for setValue: ${p}`)}},r.getValue=function(i,l="i8"){switch(l.endsWith("*")&&(l="*"),l){case"i1":case"i8":return Te()[i>>>0];case"i16":return J()[i>>>1>>>0];case"i32":return O()[i>>>2>>>0];case"i64":return q[i>>>3];case"float":return ze()[i>>>2>>>0];case"double":return Oe()[i>>>3>>>0];case"*":return X()[i>>>2>>>0];default:ht(`invalid type for getValue: ${l}`)}},r.UTF8ToString=Ce,r.stringToUTF8=At,r.lengthBytesUTF8=Cn;var Np=[_n,Go,Zo,Jo,ei,ti,ri,ni,oi,ii,ai,si,ui,li,di,ci,Si,Ti,Ci,ki,Pi,Oi,zi,Di,Bi],Dn={893836:(i,l,p,h,y)=>{if(r===void 0||!r.Fb)return 1;if((i=Ce(Number(i>>>0))).startsWith("./")&&(i=i.substring(2)),!(i=r.Fb.get(i)))return 2;if(l=Number(l>>>0),p=Number(p>>>0),h=Number(h>>>0),l+p>i.byteLength)return 3;try{let S=i.subarray(l,l+p);switch(y){case 0:pe().set(S,h>>>0);break;case 1:r.mc?r.mc(h,S):r.cc(h,S);break;default:return 4}return 0}catch{return 4}},894660:(i,l,p)=>{r.Pb(i,pe().subarray(l>>>0,l+p>>>0))},894724:()=>r.oc(),894766:i=>{r.Ob(i)},894803:()=>{r.Wb()},894834:()=>{r.Xb()},894863:()=>{r.ac()},894888:i=>r.Vb(i),894921:i=>r.Zb(i),894953:(i,l,p)=>{r.Lb(Number(i),Number(l),Number(p),!0)},895016:(i,l,p)=>{r.Lb(Number(i),Number(l),Number(p))},895073:()=>typeof wasmOffsetConverter<"u",895130:i=>{r.Ab("Abs",i,void 0)},895181:i=>{r.Ab("Neg",i,void 0)},895232:i=>{r.Ab("Floor",i,void 0)},895285:i=>{r.Ab("Ceil",i,void 0)},895337:i=>{r.Ab("Reciprocal",i,void 0)},895395:i=>{r.Ab("Sqrt",i,void 0)},895447:i=>{r.Ab("Exp",i,void 0)},895498:i=>{r.Ab("Erf",i,void 0)},895549:i=>{r.Ab("Sigmoid",i,void 0)},895604:(i,l,p)=>{r.Ab("HardSigmoid",i,{alpha:l,beta:p})},895683:i=>{r.Ab("Log",i,void 0)},895734:i=>{r.Ab("Sin",i,void 0)},895785:i=>{r.Ab("Cos",i,void 0)},895836:i=>{r.Ab("Tan",i,void 0)},895887:i=>{r.Ab("Asin",i,void 0)},895939:i=>{r.Ab("Acos",i,void 0)},895991:i=>{r.Ab("Atan",i,void 0)},896043:i=>{r.Ab("Sinh",i,void 0)},896095:i=>{r.Ab("Cosh",i,void 0)},896147:i=>{r.Ab("Asinh",i,void 0)},896200:i=>{r.Ab("Acosh",i,void 0)},896253:i=>{r.Ab("Atanh",i,void 0)},896306:i=>{r.Ab("Tanh",i,void 0)},896358:i=>{r.Ab("Not",i,void 0)},896409:(i,l,p)=>{r.Ab("Clip",i,{min:l,max:p})},896478:i=>{r.Ab("Clip",i,void 0)},896530:(i,l)=>{r.Ab("Elu",i,{alpha:l})},896588:i=>{r.Ab("Gelu",i,void 0)},896640:i=>{r.Ab("Relu",i,void 0)},896692:(i,l)=>{r.Ab("LeakyRelu",i,{alpha:l})},896756:(i,l)=>{r.Ab("ThresholdedRelu",i,{alpha:l})},896826:(i,l)=>{r.Ab("Cast",i,{to:l})},896884:i=>{r.Ab("Add",i,void 0)},896935:i=>{r.Ab("Sub",i,void 0)},896986:i=>{r.Ab("Mul",i,void 0)},897037:i=>{r.Ab("Div",i,void 0)},897088:i=>{r.Ab("Pow",i,void 0)},897139:i=>{r.Ab("Equal",i,void 0)},897192:i=>{r.Ab("Greater",i,void 0)},897247:i=>{r.Ab("GreaterOrEqual",i,void 0)},897309:i=>{r.Ab("Less",i,void 0)},897361:i=>{r.Ab("LessOrEqual",i,void 0)},897420:(i,l,p,h,y)=>{r.Ab("ReduceMean",i,{keepDims:!!l,noopWithEmptyAxes:!!p,axes:h?Array.from(O().subarray(Number(h)>>>0,Number(y)>>>0)):[]})},897595:(i,l,p,h,y)=>{r.Ab("ReduceMax",i,{keepDims:!!l,noopWithEmptyAxes:!!p,axes:h?Array.from(O().subarray(Number(h)>>>0,Number(y)>>>0)):[]})},897769:(i,l,p,h,y)=>{r.Ab("ReduceMin",i,{keepDims:!!l,noopWithEmptyAxes:!!p,axes:h?Array.from(O().subarray(Number(h)>>>