onnxruntime-web
Version:
A Javascript library for running ONNX models on browsers
6 lines • 454 kB
JavaScript
/*!
* ONNX Runtime Web v1.23.2
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
"use strict";var ort=(()=>{var gd=Object.create;var On=Object.defineProperty;var yd=Object.getOwnPropertyDescriptor;var Td=Object.getOwnPropertyNames;var _d=Object.getPrototypeOf,xd=Object.prototype.hasOwnProperty;var y=(r,t)=>()=>(r&&(t=r(r=0)),t);var O=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Dr=(r,t)=>{for(var n in t)On(r,n,{get:t[n],enumerable:!0})},sa=(r,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Td(t))!xd.call(r,o)&&o!==n&&On(r,o,{get:()=>t[o],enumerable:!(e=yd(t,o))||e.enumerable});return r};var E=(r,t,n)=>(n=r!=null?gd(_d(r)):{},sa(t||!r||!r.__esModule?On(n,"default",{value:r,enumerable:!0}):n,r)),ua=r=>sa(On({},"__esModule",{value:!0}),r);var Pn,Oe,Qe,vd,la,Lr=y(()=>{"use strict";Pn=new Map,Oe=[],Qe=(r,t,n)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let e=Pn.get(r);if(e===void 0)Pn.set(r,{backend:t,priority:n});else{if(e.priority>n)return;if(e.priority===n&&e.backend!==t)throw new Error(`cannot register backend "${r}" using priority ${n}`)}if(n>=0){let o=Oe.indexOf(r);o!==-1&&Oe.splice(o,1);for(let i=0;i<Oe.length;i++)if(Pn.get(Oe[i]).priority<=n){Oe.splice(i,0,r);return}Oe.push(r)}return}throw new TypeError("not a valid backend")},vd=async r=>{let t=Pn.get(r);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(r)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},la=async r=>{let t=r.executionProviders||[],n=t.map(u=>typeof u=="string"?u:u.name),e=n.length===0?Oe:n,o,i=[],a=new Set;for(let u of e){let l=await vd(u);typeof l=="string"?i.push({name:u,err:l}):(o||(o=l),o===l&&a.add(u))}if(!o)throw new Error(`no available backend found. ERR: ${i.map(u=>`[${u.name}] ${u.err}`).join(", ")}`);for(let{name:u,err:l}of i)n.includes(u)&&console.warn(`removing requested execution provider "${u}" from session options because it is not available: ${l}`);let s=t.filter(u=>a.has(typeof u=="string"?u:u.name));return[o,new Proxy(r,{get:(u,l)=>l==="executionProviders"?s:Reflect.get(u,l)})]}});var ca=y(()=>{"use strict";Lr()});var fa,da=y(()=>{"use strict";fa="1.23.2"});var pa,Q,$r=y(()=>{"use strict";da();pa="warning",Q={wasm:{},webgl:{},webgpu:{},versions:{common:fa},set logLevel(r){if(r!==void 0){if(typeof r!="string"||["verbose","info","warning","error","fatal"].indexOf(r)===-1)throw new Error(`Unsupported logging level: ${r}`);pa=r}},get logLevel(){return pa}};Object.defineProperty(Q,"logLevel",{enumerable:!0})});var K,ha=y(()=>{"use strict";$r();K=Q});var ba,ma,ga=y(()=>{"use strict";ba=(r,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=r.dims[3],n.height=r.dims[2];let e=n.getContext("2d");if(e!=null){let o,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=r.dims[2],i=r.dims[3]):(o=r.dims[3],i=r.dims[2]);let a=t?.format!==void 0?t.format:"RGB",s=t?.norm,u,l;s===void 0||s.mean===void 0?u=[255,255,255,255]:typeof s.mean=="number"?u=[s.mean,s.mean,s.mean,s.mean]:(u=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(u[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias=="number"?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let c=i*o,d=0,p=c,b=c*2,g=-1;a==="RGBA"?(d=0,p=c,b=c*2,g=c*3):a==="RGB"?(d=0,p=c,b=c*2):a==="RBG"&&(d=0,b=c,p=c*2);for(let m=0;m<i;m++)for(let w=0;w<o;w++){let x=(r.data[d++]-l[0])*u[0],A=(r.data[p++]-l[1])*u[1],D=(r.data[b++]-l[2])*u[2],q=g===-1?255:(r.data[g++]-l[3])*u[3];e.fillStyle="rgba("+x+","+A+","+D+","+q+")",e.fillRect(w,m,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")},ma=(r,t)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),e;if(n!=null){let o,i,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=r.dims[2],i=r.dims[1],a=r.dims[3]):(o=r.dims[3],i=r.dims[2],a=r.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:"RGB",u=t?.norm,l,c;u===void 0||u.mean===void 0?l=[255,255,255,255]:typeof u.mean=="number"?l=[u.mean,u.mean,u.mean,u.mean]:(l=[u.mean[0],u.mean[1],u.mean[2],255],u.mean[3]!==void 0&&(l[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 d=i*o;if(t!==void 0&&(t.format!==void 0&&a===4&&t.format!=="RGBA"||a===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let p=4,b=0,g=1,m=2,w=3,x=0,A=d,D=d*2,q=-1;s==="RGBA"?(x=0,A=d,D=d*2,q=d*3):s==="RGB"?(x=0,A=d,D=d*2):s==="RBG"&&(x=0,D=d,A=d*2),e=n.createImageData(o,i);for(let F=0;F<i*o;b+=p,g+=p,m+=p,w+=p,F++)e.data[b]=(r.data[x++]-c[0])*l[0],e.data[g]=(r.data[A++]-c[1])*l[1],e.data[m]=(r.data[D++]-c[2])*l[2],e.data[w]=q===-1?255:(r.data[q++]-c[3])*l[3]}else throw new Error("Can not access image data");return e}});var Nr,ya,Ta,_a,xa,va,wa=y(()=>{"use strict";Sn();Nr=(r,t)=>{if(r===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:e}=t,o=t.norm??{mean:255,bias:0},i,a;typeof o.mean=="number"?i=[o.mean,o.mean,o.mean,o.mean]:i=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?a=[o.bias,o.bias,o.bias,o.bias]:a=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let s=t.format!==void 0?t.format:"RGBA",u=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",l=n*e,c=u==="RGBA"?new Float32Array(l*4):new Float32Array(l*3),d=4,p=0,b=1,g=2,m=3,w=0,x=l,A=l*2,D=-1;s==="RGB"&&(d=3,p=0,b=1,g=2,m=-1),u==="RGBA"?D=l*3:u==="RBG"?(w=0,A=l,x=l*2):u==="BGR"&&(A=0,x=l,w=l*2);for(let F=0;F<l;F++,p+=d,g+=d,b+=d,m+=d)c[w++]=(r[p]+a[0])/i[0],c[x++]=(r[b]+a[1])/i[1],c[A++]=(r[g]+a[2])/i[2],D!==-1&&m!==-1&&(c[D++]=(r[m]+a[3])/i[3]);return u==="RGBA"?new nt("float32",c,[1,4,n,e]):new nt("float32",c,[1,3,n,e])},ya=async(r,t)=>{let n=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,e=typeof ImageData<"u"&&r instanceof ImageData,o=typeof ImageBitmap<"u"&&r instanceof ImageBitmap,i=typeof r=="string",a,s=t??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=c=>typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||c instanceof OffscreenCanvas?c.getContext("2d"):null;if(n){let c=u();c.width=r.width,c.height=r.height;let d=l(c);if(d!=null){let p=r.height,b=r.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(p=t.resizedHeight,b=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");s.tensorFormat="RGBA",s.height=p,s.width=b}else s.tensorFormat="RGBA",s.height=p,s.width=b;d.drawImage(r,0,0),a=d.getImageData(0,0,b,p).data}else throw new Error("Can not access image data")}else if(e){let c,d;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(c=t.resizedHeight,d=t.resizedWidth):(c=r.height,d=r.width),t!==void 0&&(s=t),s.format="RGBA",s.height=c,s.width=d,t!==void 0){let p=u();p.width=d,p.height=c;let b=l(p);if(b!=null)b.putImageData(r,0,0),a=b.getImageData(0,0,d,c).data;else throw new Error("Can not access image data")}else a=r.data}else if(o){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=u();c.width=r.width,c.height=r.height;let d=l(c);if(d!=null){let p=r.height,b=r.width;return d.drawImage(r,0,0,b,p),a=d.getImageData(0,0,b,p).data,s.height=p,s.width=b,Nr(a,s)}else throw new Error("Can not access image data")}else{if(i)return new Promise((c,d)=>{let p=u(),b=l(p);if(!r||!b)return d();let g=new Image;g.crossOrigin="Anonymous",g.src=r,g.onload=()=>{p.width=g.width,p.height=g.height,b.drawImage(g,0,0,p.width,p.height);let m=b.getImageData(0,0,p.width,p.height);s.height=p.height,s.width=p.width,c(Nr(m.data,s))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Nr(a,s);throw new Error("Input data provided is not supported - aborted tensor creation")},Ta=(r,t)=>{let{width:n,height:e,download:o,dispose:i}=t,a=[1,e,n,4];return new nt({location:"texture",type:"float32",texture:r,dims:a,download:o,dispose:i})},_a=(r,t)=>{let{dataType:n,dims:e,download:o,dispose:i}=t;return new nt({location:"gpu-buffer",type:n??"float32",gpuBuffer:r,dims:e,download:o,dispose:i})},xa=(r,t)=>{let{dataType:n,dims:e,download:o,dispose:i}=t;return new nt({location:"ml-tensor",type:n??"float32",mlTensor:r,dims:e,download:o,dispose:i})},va=(r,t,n)=>new nt({location:"cpu-pinned",type:r,data:t,dims:n??[t.length]})});var Pe,tn,Ia,Oa,Pa=y(()=>{"use strict";Pe=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),tn=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Ia=!1,Oa=()=>{if(!Ia){Ia=!0;let r=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,n=globalThis.Float16Array,e=typeof n<"u"&&n.from;r&&(Pe.set("int64",BigInt64Array),tn.set(BigInt64Array,"int64")),t&&(Pe.set("uint64",BigUint64Array),tn.set(BigUint64Array,"uint64")),e?(Pe.set("float16",n),tn.set(n,"float16")):Pe.set("float16",Uint16Array)}}});var Sa,Aa,Ea=y(()=>{"use strict";Sn();Sa=r=>{let t=1;for(let n=0;n<r.length;n++){let e=r[n];if(typeof e!="number"||!Number.isSafeInteger(e))throw new TypeError(`dims[${n}] must be an integer, got: ${e}`);if(e<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${e}`);t*=e}return t},Aa=(r,t)=>{switch(r.location){case"cpu":return new nt(r.type,r.data,t);case"cpu-pinned":return new nt({location:"cpu-pinned",data:r.data,type:r.type,dims:t});case"texture":return new nt({location:"texture",texture:r.texture,type:r.type,dims:t});case"gpu-buffer":return new nt({location:"gpu-buffer",gpuBuffer:r.gpuBuffer,type:r.type,dims:t});case"ml-tensor":return new nt({location:"ml-tensor",mlTensor:r.mlTensor,type:r.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${r.location} is not supported`)}}});var nt,Sn=y(()=>{"use strict";ga();wa();Pa();Ea();nt=class{constructor(t,n,e){Oa();let o,i;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,o=t.type,i=t.dims,t.location){case"cpu-pinned":{let s=Pe.get(o);if(!s)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(t.data instanceof s))throw new TypeError(`buffer should be of type ${s.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 s,u;if(typeof t=="string")if(o=t,u=e,t==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");s=n}else{let l=Pe.get(t);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(n)){if(t==="float16"&&l===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${l.name} as data.`);t==="uint64"||t==="int64"?s=l.from(n,BigInt):s=l.from(n)}else if(n instanceof l)s=n;else if(n instanceof Uint8ClampedArray)if(t==="uint8")s=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&n instanceof Uint16Array&&l!==Uint16Array)s=new globalThis.Float16Array(n.buffer,n.byteOffset,n.length);else throw new TypeError(`A ${o} tensor's data must be type of ${l}`)}else if(u=n,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof t[0];if(l==="string")o="string",s=t;else if(l==="boolean")o="bool",s=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(t instanceof Uint8ClampedArray)o="uint8",s=Uint8Array.from(t);else{let l=tn.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);o=l,s=t}if(u===void 0)u=[s.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");i=u,this.cpuData=s,this.dataLocation="cpu"}let a=Sa(i);if(this.cpuData&&a!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(a/2)===this.cpuData.length))throw new Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=i,this.size=a}static async fromImage(t,n){return ya(t,n)}static fromTexture(t,n){return Ta(t,n)}static fromGpuBuffer(t,n){return _a(t,n)}static fromMLTensor(t,n){return xa(t,n)}static fromPinnedBuffer(t,n,e){return va(t,n,e)}toDataURL(t){return ba(this,t)}toImageData(t){return ma(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 Aa(this,t)}}});var Et,Fr=y(()=>{"use strict";Sn();Et=nt});var Cr,Da,en,nn,rn,on,Rr=y(()=>{"use strict";$r();Cr=(r,t)=>{(typeof Q.trace>"u"?!Q.wasm.trace:!Q.trace)||console.timeStamp(`${r}::ORT::${t}`)},Da=(r,t)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],e=!1;for(let o=0;o<n.length;o++){if(e&&!n[o].includes("TRACE_FUNC")){let i=`FUNC_${r}::${n[o].trim().split(" ")[1]}`;t&&(i+=`::${t}`),Cr("CPU",i);return}n[o].includes("TRACE_FUNC")&&(e=!0)}},en=r=>{(typeof Q.trace>"u"?!Q.wasm.trace:!Q.trace)||Da("BEGIN",r)},nn=r=>{(typeof Q.trace>"u"?!Q.wasm.trace:!Q.trace)||Da("END",r)},rn=r=>{(typeof Q.trace>"u"?!Q.wasm.trace:!Q.trace)||console.time(`ORT::${r}`)},on=r=>{(typeof Q.trace>"u"?!Q.wasm.trace:!Q.trace)||console.timeEnd(`ORT::${r}`)}});var An,La=y(()=>{"use strict";Lr();Fr();Rr();An=class r{constructor(t){this.handler=t}async run(t,n,e){en(),rn("InferenceSession.run");let o={},i={};if(typeof t!="object"||t===null||t instanceof Et||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof Et)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.");a=!1;for(let l of n){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);o[l]=null}if(typeof e=="object"&&e!==null)i=e;else if(typeof e<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,c=Object.getOwnPropertyNames(n);for(let d of this.outputNames)if(c.indexOf(d)!==-1){let p=n[d];(p===null||p instanceof Et)&&(l=!0,a=!1,o[d]=p)}if(l){if(typeof e=="object"&&e!==null)i=e;else if(typeof e<"u")throw new TypeError("'options' must be an object.")}else i=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let l of this.inputNames)if(typeof t[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(a)for(let l of this.outputNames)o[l]=null;let s=await this.handler.run(t,o,i),u={};for(let l in s)if(Object.hasOwnProperty.call(s,l)){let c=s[l];c instanceof Et?u[l]=c:u[l]=new Et(c.type,c.data,c.dims)}return on("InferenceSession.run"),nn(),u}async release(){return this.handler.dispose()}static async create(t,n,e,o){en(),rn("InferenceSession.create");let i,a={};if(typeof t=="string"){if(i=t,typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(i=t,typeof n=="object"&&n!==null)a=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 c=t,d=0,p=t.byteLength;if(typeof n=="object"&&n!==null)a=n;else if(typeof n=="number"){if(d=n,!Number.isSafeInteger(d))throw new RangeError("'byteOffset' must be an integer.");if(d<0||d>=c.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${c.byteLength}).`);if(p=t.byteLength-d,typeof e=="number"){if(p=e,!Number.isSafeInteger(p))throw new RangeError("'byteLength' must be an integer.");if(p<=0||d+p>c.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${c.byteLength-d}].`);if(typeof o=="object"&&o!==null)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof e<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");i=new Uint8Array(c,d,p)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[s,u]=await la(a),l=await s.createInferenceSessionHandler(i,u);return on("InferenceSession.create"),nn(),new r(l)}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 $a,Na=y(()=>{"use strict";La();$a=An});var Fa=y(()=>{"use strict"});var Ca=y(()=>{"use strict"});var Ra=y(()=>{"use strict"});var Ga=y(()=>{"use strict"});var Gr={};Dr(Gr,{InferenceSession:()=>$a,TRACE:()=>Cr,TRACE_EVENT_BEGIN:()=>rn,TRACE_EVENT_END:()=>on,TRACE_FUNC_BEGIN:()=>en,TRACE_FUNC_END:()=>nn,Tensor:()=>Et,env:()=>K,registerBackend:()=>Qe});var be=y(()=>{"use strict";ca();ha();Na();Fr();Fa();Ca();Rr();Ra();Ga()});function me(r,t,n,e){if(t===void 0)return Id(r);if(n===void 0)En(r,t,1);else if(typeof n=="number"&&e===void 0)En(r,t,n);else if(typeof n=="string"&&e===void 0)En(r,n,1,t);else if(typeof n=="string"&&typeof e=="number")En(r,n,e,t);else throw new TypeError("input is valid")}function Id(r){return{verbose:me.verbose.bind(null,r),info:me.info.bind(null,r),warning:me.warning.bind(null,r),error:me.error.bind(null,r),fatal:me.fatal.bind(null,r)}}function En(r,t,n,e){let o=an[e||""]||an[""];Ma[r]<Ma[o.minimalSeverity]||(o.logDateTime&&(t=`${new Date().toISOString()}|${t}`),o.logSourceLocation,wd[o.provider].log(r,t,e))}var kr,Mr,Ma,wd,Va,an,B,Ln,$n,Nn,Dn,dt=y(()=>{"use strict";kr=class{log(t,n,e){}},Mr=class{log(t,n,e){console.log(`${this.color(t)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${n}`)}color(t){switch(t){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${t}`)}}},Ma={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},wd={none:new kr,console:new Mr},Va={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},an={"":Va};(u=>{function r(l,c){u("verbose",l,c)}u.verbose=r;function t(l,c){u("info",l,c)}u.info=t;function n(l,c){u("warning",l,c)}u.warning=n;function e(l,c){u("error",l,c)}u.error=e;function o(l,c){u("fatal",l,c)}u.fatal=o;function i(l){an={},a("",l||{})}u.reset=i;function a(l,c){if(l==="*")i(c);else{let d=an[l]||Va;an[l]={provider:c.provider||d.provider,minimalSeverity:c.minimalSeverity||d.minimalSeverity,logDateTime:c.logDateTime===void 0?d.logDateTime:c.logDateTime,logSourceLocation:c.logSourceLocation===void 0?d.logSourceLocation:c.logSourceLocation}}}u.set=a;function s(l){let c={};l.logLevel&&(c.minimalSeverity=l.logLevel),a("",c)}u.setWithEnv=s})(me||={});B=me,Ln=class{constructor(t,n,e,o,i,a){this.category=t;this.name=n;this.startTime=e;this.endCallback=o;this.timer=i;this.ctx=a}async end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},$n=class{constructor(t,n,e,o){this.category=t;this.name=n;this.startTime=e;this.endTime=o}},Nn=class{constructor(t,n,e){this._started=!1;this._flushPointer=0;this._started=!1,this._maxNumberEvents=t===void 0?1e4:t,this._flushBatchSize=n===void 0?10:n,this._flushIntervalInMilliseconds=e===void 0?5e3:e}static create(t){return t===void 0?new this:new this(t.maxNumberEvents,t.flushBatchSize,t.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=Dn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,n,e,o){let i=this._started?this.begin(t,n,o):void 0,a=!1,s=e();if(s&&typeof s.then=="function")return a=!0,new Promise((u,l)=>{s.then(async c=>{i&&await i.end(),u(c)},async c=>{i&&await i.end(),l(c)})});if(!a&&i){let u=i.end();if(u&&typeof u.then=="function")return new Promise((l,c)=>{u.then(()=>{l(s)},d=>{c(d)})})}return s}begin(t,n,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){let o=Dn();return this.flush(o),new Ln(t,n,o,i=>this.endSync(i))}else{let o=e.beginTimer();return new Ln(t,n,0,async i=>this.end(i),o,e)}}async end(t){let n=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new $n(t.category,t.name,t.startTime,n)),this.flush(n))}endSync(t){let n=Dn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new $n(t.category,t.name,t.startTime,n)),this.flush(n))}logOneEvent(t){B.verbose(`Profiler.${t.category}`,`${(t.endTime-t.startTime).toFixed(2)}ms on event '${t.name}' at ${t.endTime.toFixed(2)}`)}flush(t){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||t-this._flushTime>=this._flushIntervalInMilliseconds){for(let n=this._flushPointer;this._flushPointer<n+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=Dn()}}get started(){return this._started}},Dn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Ba(r,t,n){for(let e of n){let o=e[0],i=e[1],a=e[2],s=e[3],u=e[4];if(r.opType===o){for(let l of t)if((l.domain===i||l.domain==="ai.onnx"&&i==="")&&Od(l.version,a))return{opImpl:s,opInit:u}}}throw new TypeError(`cannot resolve operator '${r.opType}' with opsets: ${t.map(e=>`${e.domain||"ai.onnx"} v${e.version}`).join(", ")}`)}function Od(r,t){if(t.endsWith("+")){let n=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(n)&&n<=r}else if(t.split("-").length===2){let n=t.split("-"),e=Number.parseInt(n[0],10),o=Number.parseInt(n[1],10);return!isNaN(e)&&!isNaN(o)&&e<=r&&r<=o}else return Number.parseInt(t,10)===r}var za=y(()=>{"use strict"});var Ua=O(Vr=>{"use strict";Vr.__esModule=!0;var Pd=function(){function r(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=r.EMPTY,t&&r.isGuid(t)&&(this.value=t)}return r.isGuid=function(t){var n=t.toString();return t&&(t instanceof r||r.validator.test(n))},r.create=function(){return new r([r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-"))},r.createEmpty=function(){return new r("emptyguid")},r.parse=function(t){return new r(t)},r.raw=function(){return[r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-")},r.gen=function(t){for(var n="",e=0;e<t;e++)n+=((1+Math.random())*65536|0).toString(16).substring(1);return n},r.prototype.equals=function(t){return r.isGuid(t)&&this.value===t.toString()},r.prototype.isEmpty=function(){return this.value===r.EMPTY},r.prototype.toString=function(){return this.value},r.prototype.toJSON=function(){return{value:this.value}},r.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),r.EMPTY="00000000-0000-0000-0000-000000000000",r}();Vr.Guid=Pd});function z(r,t,n){this.low=r|0,this.high=t|0,this.unsigned=!!n}function ot(r){return(r&&r.__isLong__)===!0}function Wa(r){var t=Math.clz32(r&-r);return r?31-t:t}function Se(r,t){var n,e,o;return t?(r>>>=0,(o=0<=r&&r<256)&&(e=Ha[r],e)?e:(n=k(r,0,!0),o&&(Ha[r]=n),n)):(r|=0,(o=-128<=r&&r<128)&&(e=ja[r],e)?e:(n=k(r,r<0?-1:0,!1),o&&(ja[r]=n),n))}function ht(r,t){if(isNaN(r))return t?pe:vt;if(t){if(r<0)return pe;if(r>=Za)return Qa}else{if(r<=-Ka)return st;if(r+1>=Ka)return Ya}return r<0?ht(-r,t).neg():k(r%ze|0,r/ze|0,t)}function k(r,t,n){return new z(r,t,n)}function zr(r,t,n){if(r.length===0)throw Error("empty string");if(typeof t=="number"?(n=t,t=!1):t=!!t,r==="NaN"||r==="Infinity"||r==="+Infinity"||r==="-Infinity")return t?pe:vt;if(n=n||10,n<2||36<n)throw RangeError("radix");var e;if((e=r.indexOf("-"))>0)throw Error("interior hyphen");if(e===0)return zr(r.substring(1),t,n).neg();for(var o=ht(Fn(n,8)),i=vt,a=0;a<r.length;a+=8){var s=Math.min(8,r.length-a),u=parseInt(r.substring(a,a+s),n);if(s<8){var l=ht(Fn(n,s));i=i.mul(l).add(ht(u))}else i=i.mul(o),i=i.add(ht(u))}return i.unsigned=t,i}function wt(r,t){return typeof r=="number"?ht(r,t):typeof r=="string"?zr(r,t):k(r.low,r.high,typeof t=="boolean"?t:r.unsigned)}var pt,ja,Ha,Fn,qa,Sd,ze,Za,Ka,Xa,vt,pe,Be,Ja,Br,Ya,Qa,st,T,ge,Ur=y(()=>{pt=null;try{pt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}z.prototype.__isLong__;Object.defineProperty(z.prototype,"__isLong__",{value:!0});z.isLong=ot;ja={},Ha={};z.fromInt=Se;z.fromNumber=ht;z.fromBits=k;Fn=Math.pow;z.fromString=zr;z.fromValue=wt;qa=65536,Sd=1<<24,ze=qa*qa,Za=ze*ze,Ka=Za/2,Xa=Se(Sd),vt=Se(0);z.ZERO=vt;pe=Se(0,!0);z.UZERO=pe;Be=Se(1);z.ONE=Be;Ja=Se(1,!0);z.UONE=Ja;Br=Se(-1);z.NEG_ONE=Br;Ya=k(-1,2147483647,!1);z.MAX_VALUE=Ya;Qa=k(-1,-1,!0);z.MAX_UNSIGNED_VALUE=Qa;st=k(0,-2147483648,!1);z.MIN_VALUE=st;T=z.prototype;T.toInt=function(){return this.unsigned?this.low>>>0:this.low};T.toNumber=function(){return this.unsigned?(this.high>>>0)*ze+(this.low>>>0):this.high*ze+(this.low>>>0)};T.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(st)){var n=ht(t),e=this.div(n),o=e.mul(n).sub(this);return e.toString(t)+o.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var i=ht(Fn(t,6),this.unsigned),a=this,s="";;){var u=a.div(i),l=a.sub(u.mul(i)).toInt()>>>0,c=l.toString(t);if(a=u,a.isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}};T.getHighBits=function(){return this.high};T.getHighBitsUnsigned=function(){return this.high>>>0};T.getLowBits=function(){return this.low};T.getLowBitsUnsigned=function(){return this.low>>>0};T.getNumBitsAbs=function(){if(this.isNegative())return this.eq(st)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,n=31;n>0&&(t&1<<n)==0;n--);return this.high!=0?n+33:n+1};T.isZero=function(){return this.high===0&&this.low===0};T.eqz=T.isZero;T.isNegative=function(){return!this.unsigned&&this.high<0};T.isPositive=function(){return this.unsigned||this.high>=0};T.isOdd=function(){return(this.low&1)===1};T.isEven=function(){return(this.low&1)===0};T.equals=function(t){return ot(t)||(t=wt(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};T.eq=T.equals;T.notEquals=function(t){return!this.eq(t)};T.neq=T.notEquals;T.ne=T.notEquals;T.lessThan=function(t){return this.comp(t)<0};T.lt=T.lessThan;T.lessThanOrEqual=function(t){return this.comp(t)<=0};T.lte=T.lessThanOrEqual;T.le=T.lessThanOrEqual;T.greaterThan=function(t){return this.comp(t)>0};T.gt=T.greaterThan;T.greaterThanOrEqual=function(t){return this.comp(t)>=0};T.gte=T.greaterThanOrEqual;T.ge=T.greaterThanOrEqual;T.compare=function(t){if(ot(t)||(t=wt(t)),this.eq(t))return 0;var n=this.isNegative(),e=t.isNegative();return n&&!e?-1:!n&&e?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};T.comp=T.compare;T.negate=function(){return!this.unsigned&&this.eq(st)?st:this.not().add(Be)};T.neg=T.negate;T.add=function(t){ot(t)||(t=wt(t));var n=this.high>>>16,e=this.high&65535,o=this.low>>>16,i=this.low&65535,a=t.high>>>16,s=t.high&65535,u=t.low>>>16,l=t.low&65535,c=0,d=0,p=0,b=0;return b+=i+l,p+=b>>>16,b&=65535,p+=o+u,d+=p>>>16,p&=65535,d+=e+s,c+=d>>>16,d&=65535,c+=n+a,c&=65535,k(p<<16|b,c<<16|d,this.unsigned)};T.subtract=function(t){return ot(t)||(t=wt(t)),this.add(t.neg())};T.sub=T.subtract;T.multiply=function(t){if(this.isZero())return this;if(ot(t)||(t=wt(t)),pt){var n=pt.mul(this.low,this.high,t.low,t.high);return k(n,pt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?pe:vt;if(this.eq(st))return t.isOdd()?st:vt;if(t.eq(st))return this.isOdd()?st:vt;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Xa)&&t.lt(Xa))return ht(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,o=this.high&65535,i=this.low>>>16,a=this.low&65535,s=t.high>>>16,u=t.high&65535,l=t.low>>>16,c=t.low&65535,d=0,p=0,b=0,g=0;return g+=a*c,b+=g>>>16,g&=65535,b+=i*c,p+=b>>>16,b&=65535,b+=a*l,p+=b>>>16,b&=65535,p+=o*c,d+=p>>>16,p&=65535,p+=i*l,d+=p>>>16,p&=65535,p+=a*u,d+=p>>>16,p&=65535,d+=e*c+o*l+i*u+a*s,d&=65535,k(b<<16|g,d<<16|p,this.unsigned)};T.mul=T.multiply;T.divide=function(t){if(ot(t)||(t=wt(t)),t.isZero())throw Error("division by zero");if(pt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var n=(this.unsigned?pt.div_u:pt.div_s)(this.low,this.high,t.low,t.high);return k(n,pt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?pe:vt;var e,o,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return pe;if(t.gt(this.shru(1)))return Ja;i=pe}else{if(this.eq(st)){if(t.eq(Be)||t.eq(Br))return st;if(t.eq(st))return Be;var a=this.shr(1);return e=a.div(t).shl(1),e.eq(vt)?t.isNegative()?Be:Br:(o=this.sub(t.mul(e)),i=e.add(o.div(t)),i)}else if(t.eq(st))return this.unsigned?pe:vt;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=vt}for(o=this;o.gte(t);){e=Math.max(1,Math.floor(o.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(e)/Math.LN2),u=s<=48?1:Fn(2,s-48),l=ht(e),c=l.mul(t);c.isNegative()||c.gt(o);)e-=u,l=ht(e,this.unsigned),c=l.mul(t);l.isZero()&&(l=Be),i=i.add(l),o=o.sub(c)}return i};T.div=T.divide;T.modulo=function(t){if(ot(t)||(t=wt(t)),pt){var n=(this.unsigned?pt.rem_u:pt.rem_s)(this.low,this.high,t.low,t.high);return k(n,pt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};T.mod=T.modulo;T.rem=T.modulo;T.not=function(){return k(~this.low,~this.high,this.unsigned)};T.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};T.clz=T.countLeadingZeros;T.countTrailingZeros=function(){return this.low?Wa(this.low):Wa(this.high)+32};T.ctz=T.countTrailingZeros;T.and=function(t){return ot(t)||(t=wt(t)),k(this.low&t.low,this.high&t.high,this.unsigned)};T.or=function(t){return ot(t)||(t=wt(t)),k(this.low|t.low,this.high|t.high,this.unsigned)};T.xor=function(t){return ot(t)||(t=wt(t)),k(this.low^t.low,this.high^t.high,this.unsigned)};T.shiftLeft=function(t){return ot(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?k(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):k(0,this.low<<t-32,this.unsigned)};T.shl=T.shiftLeft;T.shiftRight=function(t){return ot(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?k(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):k(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};T.shr=T.shiftRight;T.shiftRightUnsigned=function(t){return ot(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?k(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?k(this.high,0,this.unsigned):k(this.high>>>t-32,0,this.unsigned)};T.shru=T.shiftRightUnsigned;T.shr_u=T.shiftRightUnsigned;T.rotateLeft=function(t){var n;return ot(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?k(this.high,this.low,this.unsigned):t<32?(n=32-t,k(this.low<<t|this.high>>>n,this.high<<t|this.low>>>n,this.unsigned)):(t-=32,n=32-t,k(this.high<<t|this.low>>>n,this.low<<t|this.high>>>n,this.unsigned))};T.rotl=T.rotateLeft;T.rotateRight=function(t){var n;return ot(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?k(this.high,this.low,this.unsigned):t<32?(n=32-t,k(this.high<<n|this.low>>>t,this.low<<n|this.high>>>t,this.unsigned)):(t-=32,n=32-t,k(this.low<<n|this.high>>>t,this.high<<n|this.low>>>t,this.unsigned))};T.rotr=T.rotateRight;T.toSigned=function(){return this.unsigned?k(this.low,this.high,!1):this};T.toUnsigned=function(){return this.unsigned?this:k(this.low,this.high,!0)};T.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};T.toBytesLE=function(){var t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};T.toBytesBE=function(){var t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};z.fromBytes=function(t,n,e){return e?z.fromBytesLE(t,n):z.fromBytesBE(t,n)};z.fromBytesLE=function(t,n){return new z(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)};z.fromBytesBE=function(t,n){return new z(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)};ge=z});var Wr=O(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.ArgType=void 0;var ts;(function(r){r[r.INPUT=0]="INPUT",r[r.OUTPUT=1]="OUTPUT"})(ts||(Cn.ArgType=ts={}))});var Ae=O(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.SIZE_PREFIX_LENGTH=Dt.FILE_IDENTIFIER_LENGTH=Dt.SIZEOF_INT=Dt.SIZEOF_SHORT=void 0;Dt.SIZEOF_SHORT=2;Dt.SIZEOF_INT=4;Dt.FILE_IDENTIFIER_LENGTH=4;Dt.SIZE_PREFIX_LENGTH=4});var jr=O(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.isLittleEndian=bt.float64=bt.float32=bt.int32=void 0;bt.int32=new Int32Array(2);bt.float32=new Float32Array(bt.int32.buffer);bt.float64=new Float64Array(bt.int32.buffer);bt.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1});var Hr=O(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.Encoding=void 0;var es;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(es||(Rn.Encoding=es={}))});var Kr=O(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.ByteBuffer=void 0;var Lt=Ae(),ut=jr(),Ad=Hr(),qr=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return ut.int32[0]=this.readInt32(t),ut.float32[0]}readFloat64(t){return ut.int32[ut.isLittleEndian?0:1]=this.readInt32(t),ut.int32[ut.isLittleEndian?1:0]=this.readInt32(t+4),ut.float64[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){ut.float32[0]=n,this.writeInt32(t,ut.int32[0])}writeFloat64(t,n){ut.float64[0]=n,this.writeInt32(t,ut.int32[ut.isLittleEndian?0:1]),this.writeInt32(t+4,ut.int32[ut.isLittleEndian?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Lt.SIZEOF_INT+Lt.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<Lt.FILE_IDENTIFIER_LENGTH;n++)t+=String.fromCharCode(this.readInt8(this.position_+Lt.SIZEOF_INT+n));return t}__offset(t,n){let e=t-this.readInt32(t);return n<this.readInt16(e)?this.readInt16(e+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);let e=this.readInt32(t);t+=Lt.SIZEOF_INT;let o=this.bytes_.subarray(t,t+e);return n===Ad.Encoding.UTF8_BYTES?o:this.text_decoder_.decode(o)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+Lt.SIZEOF_INT}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=Lt.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+Lt.FILE_IDENTIFIER_LENGTH);for(let n=0;n<Lt.FILE_IDENTIFIER_LENGTH;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+Lt.SIZEOF_INT+n))return!1;return!0}createScalarList(t,n){let e=[];for(let o=0;o<n;++o){let i=t(o);i!==null&&e.push(i)}return e}createObjList(t,n){let e=[];for(let o=0;o<n;++o){let i=t(o);i!==null&&e.push(i.unpack())}return e}};Gn.ByteBuffer=qr});var rs=O(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.Builder=void 0;var ns=Kr(),ft=Ae(),Xr=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=ns.ByteBuffer.allocate(n),this.space=n}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);let e=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<e+t+n;){let o=this.bb.capacity();this.bb=r.growByteBuffer(this.bb),this.space+=this.bb.capacity()-o}this.pad(e)}pad(t){for(let n=0;n<t;n++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,n,e){(this.force_defaults||n!=e)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,e){(this.force_defaults||n!=e)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,e){(this.force_defaults||n!=e)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,e){(this.force_defaults||n!==e)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,e){(this.force_defaults||n!=e)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,e){(this.force_defaults||n!=e)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,e){(this.force_defaults||n!=e)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,e){n!=e&&(this.nested(n),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let e=n<<1,o=ns.ByteBuffer.allocate(e);return o.setPosition(e-n),o.bytes().set(t.bytes(),e-n),o}addOffset(t){this.prep(ft.SIZEOF_INT,0),this.writeInt32(this.offset()-t+ft.SIZEOF_INT)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);let e=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);let o=2;this.addInt16(t-this.object_start);let i=(e+o)*ft.SIZEOF_SHORT;this.addInt16(i);let a=0,s=this.space;t:for(n=0;n<this.vtables.length;n++){let u=this.bb.capacity()-this.vtables[n];if(i==this.bb.readInt16(u)){for(let l=ft.SIZEOF_SHORT;l<i;l+=ft.SIZEOF_SHORT)if(this.bb.readInt16(s+l)!=this.bb.readInt16(u+l))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,e){let o=e?ft.SIZE_PREFIX_LENGTH:0;if(n){let i=n;if(this.prep(this.minalign,ft.SIZEOF_INT+ft.FILE_IDENTIFIER_LENGTH+o),i.length!=ft.FILE_IDENTIFIER_LENGTH)throw new TypeError("FlatBuffers: file identifier must be length "+ft.FILE_IDENTIFIER_LENGTH);for(let a=ft.FILE_IDENTIFIER_LENGTH-1;a>=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,ft.SIZEOF_INT+o),this.addOffset(t),o&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){let e=this.bb.capacity()-t,o=e-this.bb.readInt32(e);if(!(n<this.bb.readInt16(o)&&this.bb.readInt16(o+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,e){this.notNested(),this.vector_num_elems=n,this.prep(ft.SIZEOF_INT,t*n),this.prep(e,t*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let n=[];for(let e=0;e<t.length;++e){let o=t[e];if(o!==null)n.push(this.createObjectOffset(o));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};kn.Builder=Xr});var M=O(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.ByteBuffer=j.Builder=j.Encoding=j.isLittleEndian=j.float64=j.float32=j.int32=j.SIZE_PREFIX_LENGTH=j.FILE_IDENTIFIER_LENGTH=j.SIZEOF_INT=j.SIZEOF_SHORT=void 0;var Ed=Ae();Object.defineProperty(j,"SIZEOF_SHORT",{enumerable:!0,get:function(){return Ed.SIZEOF_SHORT}});var Dd=Ae();Object.defineProperty(j,"SIZEOF_INT",{enumerable:!0,get:function(){return Dd.SIZEOF_INT}});var Ld=Ae();Object.defineProperty(j,"FILE_IDENTIFIER_LENGTH",{enumerable:!0,get:function(){return Ld.FILE_IDENTIFIER_LENGTH}});var $d=Ae();Object.defineProperty(j,"SIZE_PREFIX_LENGTH",{enumerable:!0,get:function(){return $d.SIZE_PREFIX_LENGTH}});var Mn=jr();Object.defineProperty(j,"int32",{enumerable:!0,get:function(){return Mn.int32}});Object.defineProperty(j,"float32",{enumerable:!0,get:function(){return Mn.float32}});Object.defineProperty(j,"float64",{enumerable:!0,get:function(){return Mn.float64}});Object.defineProperty(j,"isLittleEndian",{enumerable:!0,get:function(){return Mn.isLittleEndian}});var Nd=Hr();Object.defineProperty(j,"Encoding",{enumerable:!0,get:function(){return Nd.Encoding}});var Fd=rs();Object.defineProperty(j,"Builder",{enumerable:!0,get:function(){return Fd.Builder}});var Cd=Kr();Object.defineProperty(j,"ByteBuffer",{enumerable:!0,get:function(){return Cd.ByteBuffer}})});var Jr=O($t=>{"use strict";var Rd=$t&&$t.__createBinding||(Object.create?function(r,t,n,e){e===void 0&&(e=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(r,e,o)}:function(r,t,n,e){e===void 0&&(e=n),r[e]=t[n]}),Gd=$t&&$t.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),kd=$t&&$t.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&Rd(t,r,n);return Gd(t,r),t};Object.defineProperty($t,"__esModule",{value:!0});$t.ArgTypeAndIndex=void 0;var Md=kd(M()),os=Wr(),Zr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsArgTypeAndIndex(t,n){return(n||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsArgTypeAndIndex(t,n){return t.setPosition(t.position()+Md.SIZE_PREFIX_LENGTH),(n||new r).__init(t.readInt32(t.position())+t.position(),t)}argType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):os.ArgType.INPUT}index(){let t=this.bb.__offset(t