UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

10 lines 111 kB
/*! * ONNX Runtime Web v1.24.3 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ var Rr=Object.defineProperty;var Xi=Object.getOwnPropertyDescriptor;var Zi=Object.getOwnPropertyNames;var Qi=Object.prototype.hasOwnProperty;var kr=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var R=(o,t)=>()=>(o&&(t=o(o=0)),t);var bt=(o,t)=>{for(var a in t)Rr(o,a,{get:t[a],enumerable:!0})},Ki=(o,t,a,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Zi(t))!Qi.call(o,i)&&i!==a&&Rr(o,i,{get:()=>t[i],enumerable:!(u=Xi(t,i))||u.enumerable});return o};var Rt=o=>Ki(Rr({},"__esModule",{value:!0}),o);var kt,He,qe,eu,So,Nr=R(()=>{"use strict";kt=new Map,He=[],qe=(o,t,a)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let u=kt.get(o);if(u===void 0)kt.set(o,{backend:t,priority:a});else{if(u.priority>a)return;if(u.priority===a&&u.backend!==t)throw new Error(`cannot register backend "${o}" using priority ${a}`)}if(a>=0){let i=He.indexOf(o);i!==-1&&He.splice(i,1);for(let c=0;c<He.length;c++)if(kt.get(He[c]).priority<=a){He.splice(c,0,o);return}He.push(o)}return}throw new TypeError("not a valid backend")},eu=async o=>{let t=kt.get(o);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let a=!!t.initPromise;try{return a||(t.initPromise=t.backend.init(o)),await t.initPromise,t.initialized=!0,t.backend}catch(u){return a||(t.error=`${u}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},So=async o=>{let t=o.executionProviders||[],a=t.map(h=>typeof h=="string"?h:h.name),u=a.length===0?He:a,i,c=[],l=new Set;for(let h of u){let g=await eu(h);typeof g=="string"?c.push({name:h,err:g}):(i||(i=g),i===g&&l.add(h))}if(!i)throw new Error(`no available backend found. ERR: ${c.map(h=>`[${h.name}] ${h.err}`).join(", ")}`);for(let{name:h,err:g}of c)a.includes(h)&&console.warn(`removing requested execution provider "${h}" from session options because it is not available: ${g}`);let d=t.filter(h=>l.has(typeof h=="string"?h:h.name));return[i,new Proxy(o,{get:(h,g)=>g==="executionProviders"?d:Reflect.get(h,g)})]}});var Ao=R(()=>{"use strict";Nr()});var Io,xo=R(()=>{"use strict";Io="1.24.3"});var Oo,ee,Wr=R(()=>{"use strict";xo();Oo="warning",ee={wasm:{},webgl:{},webgpu:{},versions:{common:Io},set logLevel(o){if(o!==void 0){if(typeof o!="string"||["verbose","info","warning","error","fatal"].indexOf(o)===-1)throw new Error(`Unsupported logging level: ${o}`);Oo=o}},get logLevel(){return Oo}};Object.defineProperty(ee,"logLevel",{enumerable:!0})});var Z,Lo=R(()=>{"use strict";Wr();Z=ee});var Bo,Co,Mo=R(()=>{"use strict";Bo=(o,t)=>{let a=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);a.width=o.dims[3],a.height=o.dims[2];let u=a.getContext("2d");if(u!=null){let i,c;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(i=o.dims[2],c=o.dims[3]):(i=o.dims[3],c=o.dims[2]);let l=t?.format!==void 0?t.format:"RGB",d=t?.norm,h,g;d===void 0||d.mean===void 0?h=[255,255,255,255]:typeof d.mean=="number"?h=[d.mean,d.mean,d.mean,d.mean]:(h=[d.mean[0],d.mean[1],d.mean[2],0],d.mean[3]!==void 0&&(h[3]=d.mean[3])),d===void 0||d.bias===void 0?g=[0,0,0,0]:typeof d.bias=="number"?g=[d.bias,d.bias,d.bias,d.bias]:(g=[d.bias[0],d.bias[1],d.bias[2],0],d.bias[3]!==void 0&&(g[3]=d.bias[3]));let y=c*i,w=0,b=y,E=y*2,B=-1;l==="RGBA"?(w=0,b=y,E=y*2,B=y*3):l==="RGB"?(w=0,b=y,E=y*2):l==="RBG"&&(w=0,E=y,b=y*2);for(let P=0;P<c;P++)for(let V=0;V<i;V++){let C=(o.data[w++]-g[0])*h[0],O=(o.data[b++]-g[1])*h[1],U=(o.data[E++]-g[2])*h[2],D=B===-1?255:(o.data[B++]-g[3])*h[3];u.fillStyle="rgba("+C+","+O+","+U+","+D+")",u.fillRect(V,P,1,1)}if("toDataURL"in a)return a.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},Co=(o,t)=>{let a=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),u;if(a!=null){let i,c,l;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(i=o.dims[2],c=o.dims[1],l=o.dims[3]):(i=o.dims[3],c=o.dims[2],l=o.dims[1]);let d=t!==void 0&&t.format!==void 0?t.format:"RGB",h=t?.norm,g,y;h===void 0||h.mean===void 0?g=[255,255,255,255]:typeof h.mean=="number"?g=[h.mean,h.mean,h.mean,h.mean]:(g=[h.mean[0],h.mean[1],h.mean[2],255],h.mean[3]!==void 0&&(g[3]=h.mean[3])),h===void 0||h.bias===void 0?y=[0,0,0,0]:typeof h.bias=="number"?y=[h.bias,h.bias,h.bias,h.bias]:(y=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(y[3]=h.bias[3]));let w=c*i;if(t!==void 0&&(t.format!==void 0&&l===4&&t.format!=="RGBA"||l===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let b=4,E=0,B=1,P=2,V=3,C=0,O=w,U=w*2,D=-1;d==="RGBA"?(C=0,O=w,U=w*2,D=w*3):d==="RGB"?(C=0,O=w,U=w*2):d==="RBG"&&(C=0,U=w,O=w*2),u=a.createImageData(i,c);for(let $=0;$<c*i;E+=b,B+=b,P+=b,V+=b,$++)u.data[E]=(o.data[C++]-y[0])*g[0],u.data[B]=(o.data[O++]-y[1])*g[1],u.data[P]=(o.data[U++]-y[2])*g[2],u.data[V]=D===-1?255:(o.data[D++]-y[3])*g[3]}else throw new Error("Can not access image data");return u}});var Fr,Do,Po,Uo,Ro,ko,No=R(()=>{"use strict";Nt();Fr=(o,t)=>{if(o===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:a,width:u}=t,i=t.norm??{mean:255,bias:0},c,l;typeof i.mean=="number"?c=[i.mean,i.mean,i.mean,i.mean]:c=[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],typeof i.bias=="number"?l=[i.bias,i.bias,i.bias,i.bias]:l=[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let d=t.format!==void 0?t.format:"RGBA",h=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",g=a*u,y=h==="RGBA"?new Float32Array(g*4):new Float32Array(g*3),w=4,b=0,E=1,B=2,P=3,V=0,C=g,O=g*2,U=-1;d==="RGB"&&(w=3,b=0,E=1,B=2,P=-1),h==="RGBA"?U=g*3:h==="RBG"?(V=0,O=g,C=g*2):h==="BGR"&&(O=0,C=g,V=g*2);for(let $=0;$<g;$++,b+=w,B+=w,E+=w,P+=w)y[V++]=(o[b]+l[0])/c[0],y[C++]=(o[E]+l[1])/c[1],y[O++]=(o[B]+l[2])/c[2],U!==-1&&P!==-1&&(y[U++]=(o[P]+l[3])/c[3]);return h==="RGBA"?new oe("float32",y,[1,4,a,u]):new oe("float32",y,[1,3,a,u])},Do=async(o,t)=>{let a=typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement,u=typeof ImageData<"u"&&o instanceof ImageData,i=typeof ImageBitmap<"u"&&o instanceof ImageBitmap,c=typeof o=="string",l,d=t??{},h=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},g=y=>typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||y instanceof OffscreenCanvas?y.getContext("2d"):null;if(a){let y=h();y.width=o.width,y.height=o.height;let w=g(y);if(w!=null){let b=o.height,E=o.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(b=t.resizedHeight,E=t.resizedWidth),t!==void 0){if(d=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");d.tensorFormat="RGBA",d.height=b,d.width=E}else d.tensorFormat="RGBA",d.height=b,d.width=E;w.drawImage(o,0,0),l=w.getImageData(0,0,E,b).data}else throw new Error("Can not access image data")}else if(u){let y,w;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(y=t.resizedHeight,w=t.resizedWidth):(y=o.height,w=o.width),t!==void 0&&(d=t),d.format="RGBA",d.height=y,d.width=w,t!==void 0){let b=h();b.width=w,b.height=y;let E=g(b);if(E!=null)E.putImageData(o,0,0),l=E.getImageData(0,0,w,y).data;else throw new Error("Can not access image data")}else l=o.data}else if(i){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let y=h();y.width=o.width,y.height=o.height;let w=g(y);if(w!=null){let b=o.height,E=o.width;return w.drawImage(o,0,0,E,b),l=w.getImageData(0,0,E,b).data,d.height=b,d.width=E,Fr(l,d)}else throw new Error("Can not access image data")}else{if(c)return new Promise((y,w)=>{let b=h(),E=g(b);if(!o||!E)return w();let B=new Image;B.crossOrigin="Anonymous",B.src=o,B.onload=()=>{b.width=B.width,b.height=B.height,E.drawImage(B,0,0,b.width,b.height);let P=E.getImageData(0,0,b.width,b.height);d.height=b.height,d.width=b.width,y(Fr(P.data,d))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(l!==void 0)return Fr(l,d);throw new Error("Input data provided is not supported - aborted tensor creation")},Po=(o,t)=>{let{width:a,height:u,download:i,dispose:c}=t,l=[1,u,a,4];return new oe({location:"texture",type:"float32",texture:o,dims:l,download:i,dispose:c})},Uo=(o,t)=>{let{dataType:a,dims:u,download:i,dispose:c}=t;return new oe({location:"gpu-buffer",type:a??"float32",gpuBuffer:o,dims:u,download:i,dispose:c})},Ro=(o,t)=>{let{dataType:a,dims:u,download:i,dispose:c}=t;return new oe({location:"ml-tensor",type:a??"float32",mlTensor:o,dims:u,download:i,dispose:c})},ko=(o,t,a)=>new oe({location:"cpu-pinned",type:o,data:t,dims:a??[t.length]})});var Ye,Tt,Wo,Fo,Go=R(()=>{"use strict";Ye=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Tt=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Wo=!1,Fo=()=>{if(!Wo){Wo=!0;let o=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,a=globalThis.Float16Array,u=typeof a<"u"&&a.from;o&&(Ye.set("int64",BigInt64Array),Tt.set(BigInt64Array,"int64")),t&&(Ye.set("uint64",BigUint64Array),Tt.set(BigUint64Array,"uint64")),u?(Ye.set("float16",a),Tt.set(a,"float16")):Ye.set("float16",Uint16Array)}}});var $o,zo,jo=R(()=>{"use strict";Nt();$o=o=>{let t=1;for(let a=0;a<o.length;a++){let u=o[a];if(typeof u!="number"||!Number.isSafeInteger(u))throw new TypeError(`dims[${a}] must be an integer, got: ${u}`);if(u<0)throw new RangeError(`dims[${a}] must be a non-negative integer, got: ${u}`);t*=u}return t},zo=(o,t)=>{switch(o.location){case"cpu":return new oe(o.type,o.data,t);case"cpu-pinned":return new oe({location:"cpu-pinned",data:o.data,type:o.type,dims:t});case"texture":return new oe({location:"texture",texture:o.texture,type:o.type,dims:t});case"gpu-buffer":return new oe({location:"gpu-buffer",gpuBuffer:o.gpuBuffer,type:o.type,dims:t});case"ml-tensor":return new oe({location:"ml-tensor",mlTensor:o.mlTensor,type:o.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${o.location} is not supported`)}}});var oe,Nt=R(()=>{"use strict";Mo();No();Go();jo();oe=class{constructor(t,a,u){Fo();let i,c;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,i=t.type,c=t.dims,t.location){case"cpu-pinned":{let d=Ye.get(i);if(!d)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(t.data instanceof d))throw new TypeError(`buffer should be of type ${d.name}`);this.cpuData=t.data;break}case"texture":{if(i!=="float32")throw new TypeError(`unsupported type "${i}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint8"&&i!=="bool"&&i!=="uint4"&&i!=="int4")throw new TypeError(`unsupported type "${i}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint64"&&i!=="int8"&&i!=="uint8"&&i!=="bool"&&i!=="uint4"&&i!=="int4")throw new TypeError(`unsupported type "${i}" 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 d,h;if(typeof t=="string")if(i=t,h=u,t==="string"){if(!Array.isArray(a))throw new TypeError("A string tensor's data must be a string array.");d=a}else{let g=Ye.get(t);if(g===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(a)){if(t==="float16"&&g===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${g.name} as data.`);t==="uint64"||t==="int64"?d=g.from(a,BigInt):d=g.from(a)}else if(a instanceof g)d=a;else if(a instanceof Uint8ClampedArray)if(t==="uint8")d=Uint8Array.from(a);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&a instanceof Uint16Array&&g!==Uint16Array)d=new globalThis.Float16Array(a.buffer,a.byteOffset,a.length);else throw new TypeError(`A ${i} tensor's data must be type of ${g}`)}else if(h=a,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let g=typeof t[0];if(g==="string")i="string",d=t;else if(g==="boolean")i="bool",d=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${g}.`)}else if(t instanceof Uint8ClampedArray)i="uint8",d=Uint8Array.from(t);else{let g=Tt.get(t.constructor);if(g===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);i=g,d=t}if(h===void 0)h=[d.length];else if(!Array.isArray(h))throw new TypeError("A tensor's dims must be a number array");c=h,this.cpuData=d,this.dataLocation="cpu"}let l=$o(c);if(this.cpuData&&l!==this.cpuData.length&&!((i==="uint4"||i==="int4")&&Math.ceil(l/2)===this.cpuData.length))throw new Error(`Tensor's size(${l}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=c,this.size=l}static async fromImage(t,a){return Do(t,a)}static fromTexture(t,a){return Po(t,a)}static fromGpuBuffer(t,a){return Uo(t,a)}static fromMLTensor(t,a){return Ro(t,a)}static fromPinnedBuffer(t,a,u){return ko(t,a,u)}toDataURL(t){return Bo(this,t)}toImageData(t){return Co(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 a=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=a,t&&this.disposer&&(this.disposer(),this.disposer=void 0),a}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 zo(this,t)}}});var Te,Gr=R(()=>{"use strict";Nt();Te=oe});var Vo,Ho,Je,Xe,Ue,Re,$r=R(()=>{"use strict";Wr();Vo=(o,t)=>{(typeof ee.trace>"u"?!ee.wasm.trace:!ee.trace)||console.timeStamp(`${o}::ORT::${t}`)},Ho=(o,t)=>{let a=new Error().stack?.split(/\r\n|\r|\n/g)||[],u=!1;for(let i=0;i<a.length;i++){if(u&&!a[i].includes("TRACE_FUNC")){let c=`FUNC_${o}::${a[i].trim().split(" ")[1]}`;t&&(c+=`::${t}`),Vo("CPU",c);return}a[i].includes("TRACE_FUNC")&&(u=!0)}},Je=o=>{(typeof ee.trace>"u"?!ee.wasm.trace:!ee.trace)||Ho("BEGIN",o)},Xe=o=>{(typeof ee.trace>"u"?!ee.wasm.trace:!ee.trace)||Ho("END",o)},Ue=o=>{(typeof ee.trace>"u"?!ee.wasm.trace:!ee.trace)||console.time(`ORT::${o}`)},Re=o=>{(typeof ee.trace>"u"?!ee.wasm.trace:!ee.trace)||console.timeEnd(`ORT::${o}`)}});var Wt,qo=R(()=>{"use strict";Nr();Gr();$r();Wt=class o{constructor(t){this.handler=t}async run(t,a,u){Je(),Ue("InferenceSession.run");let i={},c={};if(typeof t!="object"||t===null||t instanceof Te||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let l=!0;if(typeof a=="object"){if(a===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(a instanceof Te)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(a)){if(a.length===0)throw new TypeError("'fetches' cannot be an empty array.");l=!1;for(let g of a){if(typeof g!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(g)===-1)throw new RangeError(`'fetches' contains invalid output name: ${g}.`);i[g]=null}if(typeof u=="object"&&u!==null)c=u;else if(typeof u<"u")throw new TypeError("'options' must be an object.")}else{let g=!1,y=Object.getOwnPropertyNames(a);for(let w of this.outputNames)if(y.indexOf(w)!==-1){let b=a[w];(b===null||b instanceof Te)&&(g=!0,l=!1,i[w]=b)}if(g){if(typeof u=="object"&&u!==null)c=u;else if(typeof u<"u")throw new TypeError("'options' must be an object.")}else c=a}}else if(typeof a<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let g of this.inputNames)if(typeof t[g]>"u")throw new Error(`input '${g}' is missing in 'feeds'.`);if(l)for(let g of this.outputNames)i[g]=null;let d=await this.handler.run(t,i,c),h={};for(let g in d)if(Object.hasOwnProperty.call(d,g)){let y=d[g];y instanceof Te?h[g]=y:h[g]=new Te(y.type,y.data,y.dims)}return Re("InferenceSession.run"),Xe(),h}async release(){return this.handler.dispose()}static async create(t,a,u,i){Je(),Ue("InferenceSession.create");let c,l={};if(typeof t=="string"){if(c=t,typeof a=="object"&&a!==null)l=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(c=t,typeof a=="object"&&a!==null)l=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let y=t,w=0,b=t.byteLength;if(typeof a=="object"&&a!==null)l=a;else if(typeof a=="number"){if(w=a,!Number.isSafeInteger(w))throw new RangeError("'byteOffset' must be an integer.");if(w<0||w>=y.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${y.byteLength}).`);if(b=t.byteLength-w,typeof u=="number"){if(b=u,!Number.isSafeInteger(b))throw new RangeError("'byteLength' must be an integer.");if(b<=0||w+b>y.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${y.byteLength-w}].`);if(typeof i=="object"&&i!==null)l=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof u<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof a<"u")throw new TypeError("'options' must be an object.");c=new Uint8Array(y,w,b)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[d,h]=await So(l),g=await d.createInferenceSessionHandler(c,h);return Re("InferenceSession.create"),Xe(),new o(g)}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 tu,Yo=R(()=>{"use strict";qo();tu=Wt});var Jo=R(()=>{"use strict"});var Xo=R(()=>{"use strict"});var Zo=R(()=>{"use strict"});var Qo=R(()=>{"use strict"});var zr={};bt(zr,{InferenceSession:()=>tu,TRACE:()=>Vo,TRACE_EVENT_BEGIN:()=>Ue,TRACE_EVENT_END:()=>Re,TRACE_FUNC_BEGIN:()=>Je,TRACE_FUNC_END:()=>Xe,Tensor:()=>Te,env:()=>Z,registerBackend:()=>qe});var ke=R(()=>{"use strict";Ao();Lo();Yo();Gr();Jo();Xo();$r();Zo();Qo()});var Ft=R(()=>{"use strict"});var ra={};bt(ra,{default:()=>ru});var ea,ta,ru,na=R(()=>{"use strict";jr();Ne();Gt();ea="ort-wasm-proxy-worker",ta=globalThis.self?.name===ea;ta&&(self.onmessage=o=>{let{type:t,in:a}=o.data;try{switch(t){case"init-wasm":$t(a.wasm).then(()=>{zt(a).then(()=>{postMessage({type:t})},u=>{postMessage({type:t,err:u})})},u=>{postMessage({type:t,err:u})});break;case"init-ep":{let{epName:u,env:i}=a;jt(i,u).then(()=>{postMessage({type:t})},c=>{postMessage({type:t,err:c})});break}case"copy-from":{let{buffer:u}=a,i=vt(u);postMessage({type:t,out:i});break}case"create":{let{model:u,options:i}=a;Vt(u,i).then(c=>{postMessage({type:t,out:c})},c=>{postMessage({type:t,err:c})});break}case"release":Ht(a),postMessage({type:t});break;case"run":{let{sessionId:u,inputIndices:i,inputs:c,outputIndices:l,options:d}=a;qt(u,i,c,l,new Array(l.length).fill(null),d).then(h=>{h.some(g=>g[3]!=="cpu")?postMessage({type:t,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:t,out:h},Jt([...c,...h]))},h=>{postMessage({type:t,err:h})});break}case"end-profiling":Yt(a),postMessage({type:t});break;default:}}catch(u){postMessage({type:t,err:u})}});ru=ta?null:o=>new Worker(o??me,{type:"module",name:ea})});var aa={};bt(aa,{default:()=>nu});async function oa(o={}){var t=o,a=!!globalThis.window,u=!!globalThis.WorkerGlobalScope,i=u&&self.name?.startsWith("em-pthread");t.mountExternalData=(e,r)=>{e.startsWith("./")&&(e=e.substring(2)),(t.o||(t.o=new Map)).set(e,r)},t.unmountExternalData=()=>{delete t.o},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,Z:!0}).buffer.constructor;var c,l,d=(e,r)=>{throw r},h=import.meta.url,g="";if(a||u){try{g=new URL(".",h).href}catch{}u&&(l=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),c=async e=>{if($(e))return new Promise((n,s)=>{var f=new XMLHttpRequest;f.open("GET",e,!0),f.responseType="arraybuffer",f.onload=()=>{f.status==200||f.status==0&&f.response?n(f.response):s(f.status)},f.onerror=s,f.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw Error(r.status+" : "+r.url)}}var y,w,b,E,B,P,V=console.log.bind(console),C=console.error.bind(console),O=V,U=C,D=!1,$=e=>e.startsWith("file://");function p(){Pe.buffer!=q.buffer&&J()}if(i){var re=!1;async function e(r){try{var n=r.data,s=n.i;if(s==="load"){let f=[];self.onmessage=m=>f.push(m),P=()=>{postMessage({i:"loaded"});for(let m of f)e(m);self.onmessage=e};for(let m of n.K)t[m]&&!t[m].proxy||(t[m]=(...v)=>{postMessage({i:"callHandler",J:m,args:v})},m=="print"&&(O=t[m]),m=="printErr"&&(U=t[m]));Pe=n.S,J(),w=n.T,Ge(),Ut()}else if(s==="run"){(function(f){var m=(p(),_)[f+52>>>2>>>0];f=(p(),_)[f+56>>>2>>>0],Eo(m,m-f),pe(m)})(n.h),Cr(n.h,0,0,1,0,0),un(),yr(n.h),re||(ro(),re=!0);try{await Ha(n.P,n.u)}catch(f){if(f!="unwind")throw f}}else n.target!=="setimmediate"&&(s==="checkMailbox"?re&&xt():s&&(U(`worker: received unknown command ${s}`),U(n)))}catch(f){throw go(),f}}self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var q,z,se,Me,S,_,Fe,M,Y,nt,H,le=!1;function J(){var e=Pe.buffer;t.HEAP8=q=new Int8Array(e),se=new Int16Array(e),t.HEAPU8=z=new Uint8Array(e),Me=new Uint16Array(e),t.HEAP32=S=new Int32Array(e),t.HEAPU32=_=new Uint32Array(e),Fe=new Float32Array(e),M=new Float64Array(e),Y=new BigInt64Array(e),nt=new BigUint64Array(e)}function K(){le=!0,i?P():Ce.__wasm_call_ctors()}function ot(e){throw U(e="Aborted("+e+")"),D=!0,e+=". Build with -sASSERTIONS for more info.",le&&vo(),e=new WebAssembly.RuntimeError(e),B?.(e),e}function at(){if(!(wt={HaveOffsetConverter:Yi,__pthread_create_js:pn,__syscall_fcntl64:gn,__syscall_fstat64:yn,__syscall_getcwd:wn,__syscall_getdents64:bn,__syscall_ioctl:Tn,__syscall_lstat64:vn,__syscall_mkdirat:En,__syscall_newfstatat:_n,__syscall_openat:Sn,__syscall_readlinkat:An,__syscall_rmdir:In,__syscall_stat64:xn,__syscall_unlinkat:On,_abort_js:qa,_embind_register_bigint:Ja,_embind_register_bool:Xa,_embind_register_emval:Qa,_embind_register_float:es,_embind_register_integer:ts,_embind_register_memory_view:rs,_embind_register_std_string:ns,_embind_register_std_wstring:cs,_embind_register_void:ls,_emscripten_init_main_thread_js:ps,_emscripten_notify_mailbox_postmessage:ms,_emscripten_receive_on_main_thread_js:hs,_emscripten_runtime_keepalive_clear:gs,_emscripten_thread_cleanup:ys,_emscripten_thread_mailbox_await:yr,_emscripten_thread_set_strongref:ws,_emval_await:Dn,_emval_create_invoker:Ss,_emval_decref:mr,_emval_equals:As,_emval_get_global:Is,_emval_get_module_property:xs,_emval_get_property:Os,_emval_incref:Ls,_emval_invoke:Pn,_emval_invoke_i64:Bs,_emval_new_array:Cs,_emval_new_array_from_memory_view:Ms,_emval_new_cstring:Ds,_emval_new_object:Ps,_emval_run_destructors:Us,_emval_set_property:Rs,_gmtime_js:ks,_localtime_js:Ns,_mktime_js:Ws,_mmap_js:Nn,_munmap_js:Wn,_setitimer_js:Fn,_tzset_js:Gs,clock_time_get:js,emscripten_asm_const_int:Vs,emscripten_asm_const_ptr:Hs,emscripten_check_blocking_allowed:qs,emscripten_date_now:$s,emscripten_errn:Ys,emscripten_exit_with_live_runtime:Js,emscripten_get_heap_max:Xs,emscripten_get_now:Fs,emscripten_has_asyncify:Zs,emscripten_num_logical_cores:Qs,emscripten_pc_get_function:Bt,emscripten_resize_heap:ei,emscripten_stack_snapshot:Ks,emscripten_stack_unwind_buffer:ti,emwgpuAdapterRequestDevice:ui,emwgpuBufferDestroy:fi,emwgpuBufferGetConstMappedRange:ci,emwgpuBufferGetMappedRange:li,emwgpuBufferMapAsync:pi,emwgpuBufferUnmap:di,emwgpuDelete:mi,emwgpuDeviceCreateBuffer:hi,emwgpuDeviceCreateComputePipelineAsync:gi,emwgpuDeviceCreateShaderModule:yi,emwgpuDeviceDestroy:wi,emwgpuDevicePopErrorScope:bi,emwgpuInstanceRequestAdapter:Ti,emwgpuWaitAny:qn,environ_get:Jn,environ_sizes_get:Xn,exit:cr,fd_close:Zn,fd_read:Qn,fd_seek:Kn,fd_write:eo,memory:Pe,proc_exit:$e,wgpuAdapterGetLimits:Ei,wgpuAdapterHasFeature:_i,wgpuBufferGetSize:Si,wgpuBufferGetUsage:Ai,wgpuCommandEncoderBeginComputePass:Ii,wgpuCommandEncoderCopyBufferToBuffer:xi,wgpuCommandEncoderFinish:Oi,wgpuCommandEncoderResolveQuerySet:Li,wgpuComputePassEncoderDispatchWorkgroups:Bi,wgpuComputePassEncoderDispatchWorkgroupsIndirect:Ci,wgpuComputePassEncoderEnd:Mi,wgpuComputePassEncoderSetBindGroup:Di,wgpuComputePassEncoderSetPipeline:Pi,wgpuComputePassEncoderWriteTimestamp:Ui,wgpuComputePipelineGetBindGroupLayout:Ri,wgpuDeviceCreateBindGroup:ki,wgpuDeviceCreateCommandEncoder:Ni,wgpuDeviceCreateQuerySet:Wi,wgpuDeviceGetAdapterInfo:Fi,wgpuDeviceGetFeatures:$i,wgpuDeviceGetLimits:zi,wgpuDevicePushErrorScope:ji,wgpuQueueSubmit:Vi,wgpuQueueWriteBuffer:Hi}).I){wt.I=!0;var e=wt,r=/^(invoke_.*|__asyncjs__.*)$/;for(let[n,s]of Object.entries(e))typeof s=="function"&&(s.A||r.test(n))&&(e[n]=s=new WebAssembly.Suspending(s))}return{env:wt,wasi_snapshot_preview1:wt}}async function Ge(){function e(s,f){s=Ce=s.exports;var m=/^(OrtAppendExecutionProvider|OrtCreateSession|OrtRun|OrtRunWithBinding|OrtBindInput|main|__main_argc_argv)$/;br=new Set;var v={};for(let[T,A]of Object.entries(s))typeof A=="function"?(m.test(T)&&(br.add(A),A=WebAssembly.promising(A)),v[T]=bs(A)):v[T]=A;return Ce=v,Ce=function(){var T=Ce,A=k=>N=>k(N)>>>0,I=k=>()=>k()>>>0;return(T=Object.assign({},T)).__getTypeName=A(T.__getTypeName),T.pthread_self=I(T.pthread_self),T.malloc=A(T.malloc),T.memalign=(k=>(N,te)=>k(N,te)>>>0)(T.memalign),T._emscripten_stack_alloc=A(T._emscripten_stack_alloc),T.emscripten_stack_get_current=I(T.emscripten_stack_get_current),T}(),an.push(Ce._emscripten_tls_init),to=(s=Ce).__getTypeName,ro=s._embind_initialize_bindings,t._OrtInit=s.OrtInit,t._OrtGetLastError=s.OrtGetLastError,t._OrtCreateSessionOptions=s.OrtCreateSessionOptions,t._OrtAppendExecutionProvider=s.OrtAppendExecutionProvider,t._OrtAddFreeDimensionOverride=s.OrtAddFreeDimensionOverride,t._OrtAddSessionConfigEntry=s.OrtAddSessionConfigEntry,t._OrtReleaseSessionOptions=s.OrtReleaseSessionOptions,t._OrtCreateSession=s.OrtCreateSession,t._OrtReleaseSession=s.OrtReleaseSession,t._OrtGetInputOutputCount=s.OrtGetInputOutputCount,t._OrtGetInputOutputMetadata=s.OrtGetInputOutputMetadata,t._OrtFree=s.OrtFree,t._OrtCreateTensor=s.OrtCreateTensor,t._OrtGetTensorData=s.OrtGetTensorData,t._OrtReleaseTensor=s.OrtReleaseTensor,t._OrtCreateRunOptions=s.OrtCreateRunOptions,t._OrtAddRunConfigEntry=s.OrtAddRunConfigEntry,t._OrtReleaseRunOptions=s.OrtReleaseRunOptions,t._OrtCreateBinding=s.OrtCreateBinding,t._OrtBindInput=s.OrtBindInput,t._OrtBindOutput=s.OrtBindOutput,t._OrtClearBoundOutputs=s.OrtClearBoundOutputs,t._OrtReleaseBinding=s.OrtReleaseBinding,t._OrtRunWithBinding=s.OrtRunWithBinding,t._OrtRun=s.OrtRun,t._OrtEndProfiling=s.OrtEndProfiling,Ar=t._OrtGetWebGpuDevice=s.OrtGetWebGpuDevice,Dt=s.pthread_self,be=t._free=s.free,gt=t._malloc=s.malloc,no=t._wgpuBufferRelease=s.wgpuBufferRelease,oo=t._wgpuCreateInstance=s.wgpuCreateInstance,ao=s.emwgpuCreateBindGroup,so=s.emwgpuCreateBindGroupLayout,io=s.emwgpuCreateCommandBuffer,uo=s.emwgpuCreateCommandEncoder,fo=s.emwgpuCreateComputePassEncoder,co=s.emwgpuCreateQuerySet,lo=s.emwgpuCreateBuffer,po=s.emwgpuCreateDevice,mo=s.emwgpuCreateQueue,Ir=s.emwgpuOnCreateComputePipelineCompleted,xr=s.emwgpuOnDeviceLostCompleted,Or=s.emwgpuOnMapAsyncCompleted,Lr=s.emwgpuOnPopErrorScopeCompleted,yt=s.emwgpuOnRequestAdapterCompleted,Br=s.emwgpuOnRequestDeviceCompleted,ho=s.emwgpuOnUncapturedError,Cr=s._emscripten_thread_init,go=s._emscripten_thread_crashed,yo=s._emscripten_run_js_on_main_thread,wo=s._emscripten_thread_free_data,Mr=s._emscripten_thread_exit,bo=s._emscripten_timeout,To=s._emscripten_check_mailbox,Dr=s.memalign,vo=s.__trap,Eo=s.emscripten_stack_set_limits,pe=s._emscripten_stack_restore,Pt=s._emscripten_stack_alloc,de=s.emscripten_stack_get_current,_o=s.__indirect_function_table,w=f,Ce}var r,n=at();return t.instantiateWasm?new Promise(s=>{t.instantiateWasm(n,(f,m)=>{s(e(f,m))})}):i?e(new WebAssembly.Instance(w,at()),w):(H??=t.locateFile?t.locateFile?t.locateFile("ort-wasm-simd-threaded.jspi.wasm",g):g+"ort-wasm-simd-threaded.jspi.wasm":new URL("ort-wasm-simd-threaded.jspi.wasm",import.meta.url).href,r=await async function(s){var f=H;if(!y&&!$(f))try{var m=fetch(f,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(m,s)}catch(v){U(`wasm streaming compile failed: ${v}`),U("falling back to ArrayBuffer instantiation")}return async function(v,T){try{var A=await async function(I){if(!y)try{var k=await c(I);return new Uint8Array(k)}catch{}if(I==H&&y)I=new Uint8Array(y);else{if(!l)throw"both async and sync fetching of the wasm failed";I=l(I)}return I}(v);return await WebAssembly.instantiate(A,T)}catch(I){U(`failed to asynchronously prepare wasm: ${I}`),ot(I)}}(f,s)}(n),e(r.instance,r.module))}class st{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var It=e=>{e.terminate(),e.onmessage=()=>{}},ve=()=>{for(var e=ye;0<e.length;)e.shift()(t)},ye=[],Ee=0,Q=null,X=e=>{De.length==0&&(cn(),fn(De[0]));var r=De.pop();if(!r)return 6;mt.push(r),ze[e.h]=r,r.h=e.h;var n={i:"run",P:e.O,u:e.u,h:e.h};return r.postMessage(n,e.D),0},W=0,j=(e,r,...n)=>{var s,f=16*n.length,m=de(),v=Pt(f),T=v>>>3;for(s of n)typeof s=="bigint"?((p(),Y)[T++>>>0]=1n,(p(),Y)[T++>>>0]=s):((p(),Y)[T++>>>0]=0n,(p(),M)[T++>>>0]=s);return e=yo(e,0,f,v,r),pe(m),e};function $e(e){if(i)return j(0,1,e);if(b=e,!(0<W)){for(var r of mt)It(r);for(r of De)It(r);De=[],mt=[],ze={},D=!0}d(0,new st(e))}function fr(e){if(i)return j(1,0,e);cr(e)}var cr=e=>{if(b=e,i)throw fr(e),"unwind";$e(e)},De=[],mt=[],an=[],ze={},sn=e=>{var r=e.h;delete ze[r],De.push(e),mt.splice(mt.indexOf(e),1),e.h=0,wo(r)};function un(){an.forEach(e=>e())}var fn=e=>new Promise(r=>{e.onmessage=f=>{var m=f.data;if(f=m.i,m.s&&m.s!=Dt()){var v=ze[m.s];v?v.postMessage(m,m.D):U(`Internal error! Worker sent a message "${f}" to target pthread ${m.s}, but that thread no longer exists!`)}else f==="checkMailbox"?xt():f==="spawnThread"?X(m):f==="cleanupThread"?gr(()=>{sn(ze[m.R])}):f==="loaded"?(e.loaded=!0,r(e)):m.target==="setimmediate"?e.postMessage(m):f==="uncaughtException"?e.onerror(m.error):f==="callHandler"?t[m.J](...m.args):f&&U(`worker sent an unknown command ${f}`)},e.onerror=f=>{throw U(`worker sent an error! ${f.filename}:${f.lineno}: ${f.message}`),f};var n,s=[];for(n of[])t.propertyIsEnumerable(n)&&s.push(n);e.postMessage({i:"load",K:s,S:Pe,T:w})});function cn(){var e=new Worker((()=>{let r=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new r("ort.jspi.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});De.push(e)}var Pe,lr=[],Ha=async(e,r)=>{W=0;var n=WebAssembly,s=n.promising,f=lr[e];f||(lr[e]=f=_o.get(e),br?.has(f)&&(lr[e]=f=WebAssembly.promising(f))),e=s.call(n,f)(r),e=await e,0<W?b=e:Mr(e)};function ln(e,r,n,s){return i?j(2,1,e,r,n,s):pn(e,r,n,s)}var ue=e=>-9007199254740992>e||9007199254740992<e?NaN:Number(e);function pn(e,r,n,s){if(e>>>=0,r>>>=0,n>>>=0,s>>>=0,!globalThis.SharedArrayBuffer)return 6;var f=[];return i&&f.length===0?ln(e,r,n,s):(e={O:n,h:e,u:s,D:f},i?(e.i="spawnThread",postMessage(e,f),0):X(e))}var dn=globalThis.TextDecoder&&new TextDecoder,mn=(e,r,n,s)=>{if(n=r+n,s)return n;for(;e[r]&&!(r>=n);)++r;return r},hn=(e,r=0,n,s)=>{if(16<(n=mn(e,r>>>=0,n,s))-r&&e.buffer&&dn)return dn.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,n):e.slice(r,n));for(s="";r<n;){var f=e[r++];if(128&f){var m=63&e[r++];if((224&f)==192)s+=String.fromCharCode((31&f)<<6|m);else{var v=63&e[r++];65536>(f=(240&f)==224?(15&f)<<12|m<<6|v:(7&f)<<18|m<<12|v<<6|63&e[r++])?s+=String.fromCharCode(f):(f-=65536,s+=String.fromCharCode(55296|f>>10,56320|1023&f))}}else s+=String.fromCharCode(f)}return s},it=(e,r,n)=>(e>>>=0)?hn((p(),z),e,r,n):"";function gn(e,r,n){return i?j(3,1,e,r,n):0}function yn(e,r){if(i)return j(4,1,e,r)}function wn(e,r){if(i)return j(5,1,e,r)}function bn(e,r,n){if(i)return j(6,1,e,r,n)}function Tn(e,r,n){return i?j(7,1,e,r,n):0}function vn(e,r){if(i)return j(8,1,e,r)}function En(e,r,n){if(i)return j(9,1,e,r,n)}function _n(e,r,n,s){if(i)return j(10,1,e,r,n,s)}function Sn(e,r,n,s){if(i)return j(11,1,e,r,n,s)}function An(e,r,n,s){if(i)return j(12,1,e,r,n,s)}function In(e){if(i)return j(13,1,e)}function xn(e,r){if(i)return j(14,1,e,r)}function On(e,r,n){if(i)return j(15,1,e,r,n)}var qa=()=>ot(""),_e=e=>{e>>>=0;for(var r="";;){var n=(p(),z)[e++>>>0];if(!n)return r;r+=String.fromCharCode(n)}},pr={},dr={},Ya={},ut=class extends Error{constructor(e){super(e),this.name="BindingError"}};function xe(e,r,n={}){return function(s,f,m={}){var v=f.name;if(!s)throw new ut(`type "${v}" must have a positive integer typeid pointer`);if(dr.hasOwnProperty(s)){if(m.L)return;throw new ut(`Cannot register type '${v}' twice`)}dr[s]=f,delete Ya[s],pr.hasOwnProperty(s)&&(f=pr[s],delete pr[s],f.forEach(T=>T()))}(e,r,n)}var Ln=(e,r,n)=>{switch(r){case 1:return n?s=>(p(),q)[s>>>0]:s=>(p(),z)[s>>>0];case 2:return n?s=>(p(),se)[s>>>1>>>0]:s=>(p(),Me)[s>>>1>>>0];case 4:return n?s=>(p(),S)[s>>>2>>>0]:s=>(p(),_)[s>>>2>>>0];case 8:return n?s=>(p(),Y)[s>>>3>>>0]:s=>(p(),nt)[s>>>3>>>0];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}};function Ja(e,r,n,s,f){e>>>=0,n>>>=0,r=_e(r>>>0);let m=v=>v;if(s=s===0n){let v=8*n;m=T=>BigInt.asUintN(v,T),f=m(f)}xe(e,{name:r,g:m,l:(v,T)=>(typeof T=="number"&&(T=BigInt(T)),T),j:Ln(r,n,!s),m:null})}function Xa(e,r,n,s){xe(e>>>=0,{name:r=_e(r>>>0),g:function(f){return!!f},l:function(f,m){return m?n:s},j:function(f){return this.g((p(),z)[f>>>0])},m:null})}var Bn=[],je=[0,1,,1,null,1,!0,1,!1,1];function mr(e){9<(e>>>=0)&&--je[e+1]==0&&(je[e]=void 0,Bn.push(e))}var he=e=>{if(!e)throw new ut(`Cannot use deleted val. handle = ${e}`);return je[e]},we=e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let r=Bn.pop()||je.length;return je[r]=e,je[r+1]=1,r}};function hr(e){return this.g((p(),_)[e>>>2>>>0])}var Za={name:"emscripten::val",g:e=>{var r=he(e);return mr(e),r},l:(e,r)=>we(r),j:hr,m:null};function Qa(e){return xe(e>>>0,Za)}var Ka=(e,r)=>{switch(r){case 4:return function(n){return this.g((p(),Fe)[n>>>2>>>0])};case 8:return function(n){return this.g((p(),M)[n>>>3>>>0])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}};function es(e,r,n){n>>>=0,xe(e>>>=0,{name:r=_e(r>>>0),g:s=>s,l:(s,f)=>f,j:Ka(r,n),m:null})}function ts(e,r,n,s,f){e>>>=0,n>>>=0,r=_e(r>>>0);let m=T=>T;if(s===0){var v=32-8*n;m=T=>T<<v>>>v,f=m(f)}xe(e,{name:r,g:m,l:(T,A)=>A,j:Ln(r,n,s!==0),m:null})}function rs(e,r,n){function s(m){var v=(p(),_)[m>>>2>>>0];return m=(p(),_)[m+4>>>2>>>0],new f((p(),q).buffer,m,v)}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][r];xe(e>>>=0,{name:n=_e(n>>>0),g:s,j:s},{L:!0})}var Oe=(e,r,n)=>{var s=(p(),z);if(r>>>=0,0<n){var f=r;n=r+n-1;for(var m=0;m<e.length;++m){var v=e.codePointAt(m);if(127>=v){if(r>=n)break;s[r++>>>0]=v}else if(2047>=v){if(r+1>=n)break;s[r++>>>0]=192|v>>6,s[r++>>>0]=128|63&v}else if(65535>=v){if(r+2>=n)break;s[r++>>>0]=224|v>>12,s[r++>>>0]=128|v>>6&63,s[r++>>>0]=128|63&v}else{if(r+3>=n)break;s[r++>>>0]=240|v>>18,s[r++>>>0]=128|v>>12&63,s[r++>>>0]=128|v>>6&63,s[r++>>>0]=128|63&v,m++}}s[r>>>0]=0,e=r-f}else e=0;return e},Le=e=>{for(var r=0,n=0;n<e.length;++n){var s=e.charCodeAt(n);127>=s?r++:2047>=s?r+=2:55296<=s&&57343>=s?(r+=4,++n):r+=3}return r};function ns(e,r){xe(e>>>=0,{name:r=_e(r>>>0),g(n){var s=(p(),_)[n>>>2>>>0];return s=it(n+4,s,!0),be(n),s},l(n,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var f=typeof s=="string";if(!(f||ArrayBuffer.isView(s)&&s.BYTES_PER_ELEMENT==1))throw new ut("Cannot pass non-string to std::string");var m=f?Le(s):s.length,v=gt(4+m+1),T=v+4;return(p(),_)[v>>>2>>>0]=m,f?Oe(s,T,m+1):(p(),z).set(s,T>>>0),n!==null&&n.push(be,v),v},j:hr,m(n){be(n)}})}var Cn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,os=(e,r,n)=>{if(e>>>=1,16<(r=mn((p(),Me),e,r/2,n))-e&&Cn)return Cn.decode((p(),Me).slice(e,r));for(n="";e<r;++e){var s=(p(),Me)[e>>>0];n+=String.fromCharCode(s)}return n},as=(e,r,n)=>{if(n??=2147483647,2>n)return 0;var s=r;n=(n-=2)<2*e.length?n/2:e.length;for(var f=0;f<n;++f){var m=e.charCodeAt(f);(p(),se)[r>>>1>>>0]=m,r+=2}return(p(),se)[r>>>1>>>0]=0,r-s},ss=e=>2*e.length,is=(e,r,n)=>{var s="";e>>>=2;for(var f=0;!(f>=r/4);f++){var m=(p(),_)[e+f>>>0];if(!m&&!n)break;s+=String.fromCodePoint(m)}return s},us=(e,r,n)=>{if(r>>>=0,n??=2147483647,4>n)return 0;var s=r;n=s+n-4;for(var f=0;f<e.length;++f){var m=e.codePointAt(f);if(65535<m&&f++,(p(),S)[r>>>2>>>0]=m,(r+=4)+4>n)break}return(p(),S)[r>>>2>>>0]=0,r-s},fs=e=>{for(var r=0,n=0;n<e.length;++n)65535<e.codePointAt(n)&&n++,r+=4;return r};function cs(e,r,n){if(e>>>=0,r>>>=0,n=_e(n>>>=0),r===2)var s=os,f=as,m=ss;else s=is,f=us,m=fs;xe(e,{name:n,g:v=>{var T=(p(),_)[v>>>2>>>0];return T=s(v+4,T*r,!0),be(v),T},l:(v,T)=>{if(typeof T!="string")throw new ut(`Cannot pass non-string to C++ string type ${n}`);var A=m(T),I=gt(4+A+r);return(p(),_)[I>>>2>>>0]=A/r,f(T,I+4,A+r),v!==null&&v.push(be,I),I},j:hr,m(v){be(v)}})}function ls(e,r){xe(e>>>=0,{M:!0,name:r=_e(r>>>0),g:()=>{},l:()=>{}})}function ps(e){Cr(e>>>0,!u,1,!a,131072,!1),un()}var gr=e=>{if(!D)try{if(e(),!(0<W))try{i?Dt()&&Mr(b):cr(b)}catch(r){r instanceof st||r=="unwind"||d(0,r)}}catch(r){r instanceof st||r=="unwind"||d(0,r)}},ds=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function yr(e){e>>>=0,ds||(Atomics.waitAsync((p(),S),e>>>2,e).value.then(xt),e+=128,Atomics.store((p(),S),e>>>2,1))}var xt=()=>gr(()=>{var e=Dt();e&&(yr(e),To())});function ms(e,r){(e>>>=0)==r>>>0?setTimeout(xt):i?postMessage({s:e,i:"checkMailbox"}):(e=ze[e])&&e.postMessage({i:"checkMailbox"})}var wr=[];function hs(e,r,n,s,f){for(r>>>=0,f>>>=0,wr.length=0,n=f>>>3,s=f+s>>>3;n<s;){var m;m=(p(),Y)[n++>>>0]?(p(),Y)[n++>>>0]:(p(),M)[n++>>>0],wr.push(m)}return(r?Pr[r]:qi[e])(...wr)}var gs=()=>{W=0};function ys(e){e>>>=0,i?postMessage({i:"cleanupThread",R:e}):sn(ze[e])}function ws(e){}function bs(e){return(...r)=>e(...r)}var br=null,Mn=async e=>{W+=1;try{return await e()}finally{--W}};function Dn(e){return e>>>=0,Mn(async()=>{var r=await he(e);return we(r)})}Dn.A=!0;var Tr=[],Ts=e=>{var r=Tr.length;return Tr.push(e),r},vs=(e,r)=>{for(var n=Array(e),s=0;s<e;++s){var f=s,m=(p(),_)[r+4*s>>>2>>>0],v=dr[m];if(v===void 0)throw e=`parameter ${s}`,m=to(m),r=_e(m),be(m),new ut(`${e} has unknown type ${r}`);n[f]=v}return n},Es=(e,r,n)=>{var s=[];return e=e(s,n),s.length&&((p(),_)[r>>>2>>>0]=we(s)),e},_s={},Ot=e=>{var r=_s[e];return r===void 0?_e(e):r};function Ss(e,r,n){var[s,...f]=vs(e,r>>>0);r=s.l.bind(s);var m=f.map(A=>A.j.bind(A));e--;var v={toValue:he};switch(e=m.map((A,I)=>{var k=`argFromPtr${I}`;return v[k]=A,`${k}(args${I?"+"+8*I:""})`}),n){case 0:var T="toValue(handle)";break;case 2:T="new (toValue(handle))";break;case 3:T="";break;case 1:v.getStringOrSymbol=Ot,T="toValue(handle)[getStringOrSymbol(methodName)]"}return T+=`(${e})`,s.M||(v.toReturnWire=r,v.emval_returnValue=Es,T=`return emval_returnValue(toReturnWire, destructorsRef, ${T})`),T=`return function (handle, methodName, destructorsRef, args) { ${T} }`,n=new Function(Object.keys(v),T)(...Object.values(v)),T=`methodCaller<(${f.map(A=>A.name)}) => ${s.name}>`,Ts(Object.defineProperty(n,"name",{value:T}))}function As(e,r){return r>>>=0,(e=he(e>>>0))==he(r)}function Is(e){return(e>>>=0)?(e=Ot(e),we(globalThis[e])):we(globalThis)}function xs(e){return e=Ot(e>>>0),we(t[e])}function Os(e,r){return r>>>=0,e=he(e>>>0),r=he(r),we(e[r])}function Ls(e){9<(e>>>=0)&&(je[e+1]+=1)}function Pn(e,r,n,s,f){return Tr[e>>>0](r>>>0,n>>>0,s>>>0,f>>>0)}function Bs(e,r,n,s,f){return Pn(e>>>0,r>>>0,n>>>0,s>>>0,f>>>0)}function Cs(){return we([])}function Ms(e){e=he(e>>>0);for(var r=Array(e.length),n=0;n<e.length;n++)r[n]=e[n];return we(r)}function Ds(e){return we(Ot(e>>>0))}function Ps(){return we({})}function Us(e){for(var r=he(e>>>=0);r.length;){var n=r.pop();r.pop()(n)}mr(e)}function Rs(e,r,n){r>>>=0,n>>>=0,e=he(e>>>0),r=he(r),n=he(n),e[r]=n}function ks(e,r){e=ue(e),r>>>=0,e=new Date(1e3*e),(p(),S)[r>>>2>>>0]=e.getUTCSeconds(),(p(),S)[r+4>>>2>>>0]=e.getUTCMinutes(),(p(),S)[r+8>>>2>>>0]=e.getUTCHours(),(p(),S)[r+12>>>2>>>0]=e.getUTCDate(),(p(),S)[r+16>>>2>>>0]=e.getUTCMonth(),(p(),S)[r+20>>>2>>>0]=e.getUTCFullYear()-1900,(p(),S)[r+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(p(),S)[r+28>>>2>>>0]=e}var Un=e=>e%4==0&&(e%100!=0||e%400==0),Rn=[0,31,60,91,121,152,182,213,244,274,305,335],kn=[0,31,59,90,120,151,181,212,243,273,304,334];function Ns(e,r){e=ue(e),r>>>=0,e=new Date(1e3*e),(p(),S)[r>>>2>>>0]=e.getSeconds(),(p(),S)[r+4>>>2>>>0]=e.getMinutes(),(p(),S)[r+8>>>2>>>0]=e.getHours(),(p(),S)[r+12>>>2>>>0]=e.getDate(),(p(),S)[r+16>>>2>>>0]=e.getMonth(),(p(),S)[r+20>>>2>>>0]=e.getFullYear()-1900,(p(),S)[r+24>>>2>>>0]=e.getDay();var n=(Un(e.getFullYear())?Rn:kn)[e.getMonth()]+e.getDate()-1|0;(p(),S)[r+28>>>2>>>0]=n,(p(),S)[r+36>>>2>>>0]=-60*e.getTimezoneOffset(),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var s=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(n!=s&&e.getTimezoneOffset()==Math.min(s,n)),(p(),S)[r+32>>>2>>>0]=e}function Ws(e){e>>>=0;var r=new Date((p(),S)[e+20>>>2>>>0]+1900,(p(),S)[e+16>>>2>>>0],(p(),S)[e+12>>>2>>>0],(p(),S)[e+8>>>2>>>0],(p(),S)[e+4>>>2>>>0],(p(),S)[e>>>2>>>0],0),n=(p(),S)[e+32>>>2>>>0],s=r.getTimezoneOffset(),f=new Date(r.getFullYear(),6,1).getTimezoneOffset(),m=new Date(r.getFullYear(),0,1).getTimezoneOffset(),v=Math.min(m,f);return 0>n?(p(),S)[e+32>>>2>>>0]=+(f!=m&&v==s):0<n!=(v==s)&&(f=Math.max(m,f),r.setTime(r.getTime()+6e4*((0<n?v:f)-s))),(p(),S)[e+24>>>2>>>0]=r.getDay(),n=(Un(r.getFullYear())?Rn:kn)[r.getMonth()]+r.getDate()-1|0,(p(),S)[e+28>>>2>>>0]=n,(p(),S)[e>>>2>>>0]=r.getSeconds(),(p(),S)[e+4>>>2>>>0]=r.getMinutes(),(p(),S)[e+8>>>2>>>0]=r.getHours(),(p(),S)[e+12>>>2>>>0]=r.getDate(),(p(),S)[e+16>>>2>>>0]=r.getMonth(),(p(),S)[e+20>>>2>>>0]=r.getYear(),e=r.getTime(),BigInt(isNaN(e)?-1:e/1e3)}function Nn(e,r,n,s,f,m,v){return i?j(16,1,e,r,n,s,f,m,v):-52}function Wn(e,r,n,s,f,m){if(i)return j(17,1,e,r,n,s,f,m)}var ht={},Fs=()=>performance.timeOrigin+performance.now();function Fn(e,r){if(i)return j(18,1,e,r);if(ht[e]&&(clearTimeout(ht[e].id),delete ht[e]),!r)return 0;var n=setTimeout(()=>{delete ht[e],gr(()=>bo(e,performance.timeOrigin+performance.now()))},r);return ht[e]={id:n,$:r},0}function Gs(e,r,n,s){e>>>=0,r>>>=0,n>>>=0,s>>>=0;var f=new Date().getFullYear(),m=new Date(f,0,1).getTimezoneOffset();f=new Date(f,6,1).getTimezoneOffset();var v=Math.max(m,f);(p(),_)[e>>>2>>>0]=60*v,(p(),S)[r>>>2>>>0]=+(m!=f),e=(r=T=>{var A=Math.abs(T);return`UTC${0<=T?"-":"+"}${String(Math.floor(A/60)).padStart(2,"0")}${String(A%60).padStart(2,"0")}`})(m),r=r(f),f<m?(Oe(e,n,17),Oe(r,s,17)):(Oe(e,s,17),Oe(r,n,17))}var $s=()=>Date.now(),zs=1;function js(e,r,n){if(n>>>=0,!(0<=e&&3>=e))return 28;if(e===0)e=Date.now();else{if(!zs)return 52;e=performance.timeOrigin+performance.now()}return e=Math.round(1e6*e),(p(),Y)[n>>>3>>>0]=BigInt(e),0}var vr=[],Gn=(e,r)=>{vr.length=0;for(var n;n=(p(),z)[e++>>>0];){var s=n!=105;r+=(s&=n!=112)&&r%8?4:0,vr.push(n==112?(p(),_)[r>>>2>>>0]:n==106?(p(),Y)[r>>>3>>>0]:n==105?(p(),S)[r>>>2>>>0]:(p(),M)[r>>>3>>>0]),r+=s?8:4}return vr};function Vs(e,r,n){return e>>>=0,r=Gn(r>>>0,n>>>0),Pr[e](...r)}function Hs(e,r,n){return e>>>=0,r=Gn(r>>>0,n>>>0),Pr[e](...r)}var qs=()=>{};function Ys(e,r){return U(it(e>>>0,r>>>0))}var Js=()=>{throw W+=1,"unwind"};function Xs(){return 4294901760}var Zs=()=>2,Qs=()=>navigator.hardwareConcurrency,Ve={},$n=e=>{var r=Le(e)+1,n=gt(r);return n&&Oe(e,n,r),n},Lt=e=>{var r;return(r=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(e))?+r[1]:(r=/:(\d+):\d+(?:\)|$)/.exec(e))?2147483648|+r[1]:0},zn=e=>{for(var r of e)(e=Lt(r))&&(Ve[e]=r)};function Ks(){var e=Error().stack.toString().split(` `);return e[0]=="Error"&&e.shift(),zn(e),Ve.B=Lt(e[3]),Ve.N=e,Ve.B}function Bt(e){if(!(e=Ve[e>>>0]))return 0;var r;if(r=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(e))e=r[1];else if(r=/^\s+at (.*) \(.*\)$/.exec(e))e=r[1];else{if(!(r=/^(.+?)@/.exec(e)))return 0;e=r[1]}return be(Bt.C??0),Bt.C=$n(e),Bt.C}function ei(e){e>>>=0;var r=(p(),z).length;if(e<=r||4294901760<e)return!1;for(var n=1;4>=n;n*=2){var s=r*(1+.2/n);s=Math.min(s,e+100663296);e:{s=(Math.min(4294901760,65536*Math.ceil(Math.max(e,s)/65536))-Pe.buffer.byteLength+65535)/65536|0;try{Pe.grow(s),J();var f=1;break e}catch{}f=void 0}if(f)return!0}return!1}function ti(e,r,n){if(e>>>=0,r>>>=0,Ve.B==e)var s=Ve.N;else(s=Error().stack.toString().split(` `))[0]=="Error"&&s.shift(),zn(s);for(var f=3;s[f]&&Lt(s[f])!=e;)++f;for(e=0;e<n&&s[e+f];++e)(p(),S)[r+4*e>>>2>>>0]=Lt(s[e+f]);return e}var Se=e=>{var r=Le(e)+1,n=Pt(r);return Oe(e,n,r),n},Er=[],fe=(e,r)=>{Er[e>>>=0]=r},Ae=[],Ct=[],ft=(e,r)=>{Ct[e]=new Promise(n=>r.finally(()=>n(e)))},x=e=>{if(e)return Er[e>>>0]},Mt=(e,r,n)=>{(p(),_)[e>>>2>>>0]=r,(p(),_)[e+4>>>2>>>0]=n},jn=e=>{var r=(p(),_)[e>>>2>>>0];return e=(p(),_)[e+4>>>2>>>0],it(r,e)},Be=e=>{var r=(p(),_)[e>>>2>>>0];return e=(p(),_)[e+4>>>2>>>0],r?it(r,e):e===0?"":void 0},ri=e=>{var r=Be(e+4),n=(n=(p(),_)[e+12>>>2>>>0])?x(n):"auto";if(e+=16){var s=x((p(),_)[e+4>>>2>>>0]),f=(p(),_)[e+16>>>2>>>0],m=(p(),_)[e+20>>>2>>>0];if(f){for(var v={},T=0;T<f;++T){var A=m+24*T;v[jn(A+4)]=(p(),M)[A+16>>>3>>>0]}f=v}else f=void 0;e={module:s,constants:f,entryPoint:Be(e+8)}}else e=void 0;return{label:r,layout:n,compute:e}},Vn=(e,r)=>{function n(f,m){f=e[f],(p(),S)[r+m>>>2>>>0]=f}function s(f,m){f=e[f],(p(),Y)[r+m>>>3>>>0]=BigInt(f)}n("maxTextureDimension1D",4),n("maxTextureDimension2D",8),n("maxTextureDimension3D",12),n("maxTextureArrayLayers",16),n("maxBindGroups",20),n("maxBindGroupsPlusVertexBuffers",24),n("maxBindingsPerBindGroup",28),n("maxDynamicUniformBuffersPerPipelineLayout",32),n("maxDynamicStorageBuffersPerPipelineLayout",36),n("maxSampledTexturesPerShaderStage",40),n("maxSamplersPerShaderStage",44),n("maxStorageBuffersPerShaderStage",48),n("maxStorageTexturesPerShaderStage",52),n("maxUniformBuffersPerShaderStage",56),n("minUniformBufferOffsetAlignment",80),n("minStorageBufferOffsetAlignment",84),s("maxUniformBufferBindingSize",64),s("maxStorageBufferBindingSize",72),n("maxVertexBuffers",88),s("maxBufferSize",96),n("maxVertexAttributes",104),n("maxVertexBufferArrayStride",108),n("maxInterStageShaderVariables",112),n("maxColorAttachments",116),n("maxColorAttachmentBytesPerSample",120),n("maxComputeWorkgroupStorageSize",124),n("maxComputeInvocationsPerWorkgroup",128),n("maxComputeWorkgroupSizeX",132),n("maxComputeWorkgroupSizeY",136),n("maxComputeWorkgroupSizeZ",140),n("maxComputeWorkgroupsPerDimension",144),e.Y!==void 0&&n("maxImmediateSize",148)},ni=[,"validation","out-of-memory","internal"],oi=[,"compatibility","core"],Hn={1:"core-features-and-limits",2:"depth-clip-control",3:"depth32float-stencil8",4:"texture-compression-bc",5:"texture-compression-bc-sliced-3d",6:"texture-compression-etc2",7:"texture-compression-astc",8:"texture-compression-astc-sliced-3d",9:"timestamp-query",10:"indirect-first-instance",11:"shader-f16",1