UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

6 lines 472 kB
/*! * ONNX Runtime Web v1.27.0 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ "use strict";var ort=(()=>{var Bd=Object.create;var zn=Object.defineProperty;var zd=Object.getOwnPropertyDescriptor;var Ud=Object.getOwnPropertyNames;var jd=Object.getPrototypeOf,Wd=Object.prototype.hasOwnProperty;var Xr=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var _=(o,t)=>()=>(o&&(t=o(o=0)),t);var A=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),Zr=(o,t)=>{for(var n in t)zn(o,n,{get:t[n],enumerable:!0})},Ea=(o,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ud(t))!Wd.call(o,r)&&r!==n&&zn(o,r,{get:()=>t[r],enumerable:!(e=zd(t,r))||e.enumerable});return o};var F=(o,t,n)=>(n=o!=null?Bd(jd(o)):{},Ea(t||!o||!o.__esModule?zn(n,"default",{value:o,enumerable:!0}):n,o)),Da=o=>Ea(zn({},"__esModule",{value:!0}),o);var Un,Be,mn,Hd,La,Jr=_(()=>{"use strict";Un=new Map,Be=[],mn=(o,t,n)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let e=Un.get(o);if(e===void 0)Un.set(o,{backend:t,priority:n});else{if(e.priority>n)return;if(e.priority===n&&e.backend!==t)throw new Error(`cannot register backend "${o}" using priority ${n}`)}if(n>=0){let r=Be.indexOf(o);r!==-1&&Be.splice(r,1);for(let i=0;i<Be.length;i++)if(Un.get(Be[i]).priority<=n){Be.splice(i,0,o);return}Be.push(o)}return}throw new TypeError("not a valid backend")},Hd=async o=>{let t=Un.get(o);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(o)),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 o=>{let t=o.executionProviders||[],n=t.map(u=>typeof u=="string"?u:u.name),e=n.length===0?Be:n,r,i=[],a=new Set;for(let u of e){let l=await Hd(u);typeof l=="string"?i.push({name:u,err:l}):(r||(r=l),r===l&&a.add(u))}if(!r)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[r,new Proxy(o,{get:(u,l)=>l==="executionProviders"?s:Reflect.get(u,l)})]}});var Na=_(()=>{"use strict";Jr()});var $a,Fa=_(()=>{"use strict";$a="1.27.0"});var Ca,ut,Yr=_(()=>{"use strict";Fa();Ca="warning",ut={wasm:{},webgl:{},webgpu:{},versions:{common:$a},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}`);Ca=o}},get logLevel(){return Ca}};Object.defineProperty(ut,"logLevel",{enumerable:!0})});var nt,Ra=_(()=>{"use strict";Yr();nt=ut});var Ga,ka,Ma=_(()=>{"use strict";Ga=(o,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=o.dims[3],n.height=o.dims[2];let e=n.getContext("2d");if(e!=null){let r,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(r=o.dims[2],i=o.dims[3]):(r=o.dims[3],i=o.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*r,d=0,h=c,b=c*2,y=-1;a==="RGBA"?(d=0,h=c,b=c*2,y=c*3):a==="RGB"?(d=0,h=c,b=c*2):a==="RBG"&&(d=0,b=c,h=c*2);for(let g=0;g<i;g++)for(let O=0;O<r;O++){let w=(o.data[d++]-l[0])*u[0],$=(o.data[h++]-l[1])*u[1],N=(o.data[b++]-l[2])*u[2],j=y===-1?255:(o.data[y++]-l[3])*u[3];e.fillStyle="rgba("+w+","+$+","+N+","+j+")",e.fillRect(O,g,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")},ka=(o,t)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),e;if(n!=null){let r,i,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(r=o.dims[2],i=o.dims[1],a=o.dims[3]):(r=o.dims[3],i=o.dims[2],a=o.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*r;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 h=4,b=0,y=1,g=2,O=3,w=0,$=d,N=d*2,j=-1;s==="RGBA"?(w=0,$=d,N=d*2,j=d*3):s==="RGB"?(w=0,$=d,N=d*2):s==="RBG"&&(w=0,N=d,$=d*2),e=n.createImageData(r,i);for(let C=0;C<i*r;b+=h,y+=h,g+=h,O+=h,C++)e.data[b]=(o.data[w++]-c[0])*l[0],e.data[y]=(o.data[$++]-c[1])*l[1],e.data[g]=(o.data[N++]-c[2])*l[2],e.data[O]=j===-1?255:(o.data[j++]-c[3])*l[3]}else throw new Error("Can not access image data");return e}});var Qr,Va,Ba,za,Ua,ja,Wa=_(()=>{"use strict";jn();Qr=(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:n,width:e}=t,r=t.norm??{mean:255,bias:0},i,a;typeof r.mean=="number"?i=[r.mean,r.mean,r.mean,r.mean]:i=[r.mean[0],r.mean[1],r.mean[2],r.mean[3]??255],typeof r.bias=="number"?a=[r.bias,r.bias,r.bias,r.bias]:a=[r.bias[0],r.bias[1],r.bias[2],r.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,h=0,b=1,y=2,g=3,O=0,w=l,$=l*2,N=-1;s==="RGB"&&(d=3,h=0,b=1,y=2,g=-1),u==="RGBA"?N=l*3:u==="RBG"?(O=0,$=l,w=l*2):u==="BGR"&&($=0,w=l,O=l*2);for(let C=0;C<l;C++,h+=d,y+=d,b+=d,g+=d)c[O++]=(o[h]+a[0])/i[0],c[w++]=(o[b]+a[1])/i[1],c[$++]=(o[y]+a[2])/i[2],N!==-1&&g!==-1&&(c[N++]=(o[g]+a[3])/i[3]);return u==="RGBA"?new dt("float32",c,[1,4,n,e]):new dt("float32",c,[1,3,n,e])},Va=async(o,t)=>{let n=typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement,e=typeof ImageData<"u"&&o instanceof ImageData,r=typeof ImageBitmap<"u"&&o instanceof ImageBitmap,i=typeof o=="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=o.width,c.height=o.height;let d=l(c);if(d!=null){let h=o.height,b=o.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(h=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=h,s.width=b}else s.tensorFormat="RGBA",s.height=h,s.width=b;d.drawImage(o,0,0),a=d.getImageData(0,0,b,h).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=o.height,d=o.width),t!==void 0&&(s=t),s.format="RGBA",s.height=c,s.width=d,t!==void 0){let h=u();h.width=d,h.height=c;let b=l(h);if(b!=null)b.putImageData(o,0,0),a=b.getImageData(0,0,d,c).data;else throw new Error("Can not access image data")}else a=o.data}else if(r){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=u();c.width=o.width,c.height=o.height;let d=l(c);if(d!=null){let h=o.height,b=o.width;return d.drawImage(o,0,0,b,h),a=d.getImageData(0,0,b,h).data,s.height=h,s.width=b,Qr(a,s)}else throw new Error("Can not access image data")}else{if(i)return new Promise((c,d)=>{let h=u(),b=l(h);if(!o||!b)return d();let y=new Image;y.crossOrigin="Anonymous",y.src=o,y.onload=()=>{h.width=y.width,h.height=y.height,b.drawImage(y,0,0,h.width,h.height);let g=b.getImageData(0,0,h.width,h.height);s.height=h.height,s.width=h.width,c(Qr(g.data,s))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Qr(a,s);throw new Error("Input data provided is not supported - aborted tensor creation")},Ba=(o,t)=>{let{width:n,height:e,download:r,dispose:i}=t,a=[1,e,n,4];return new dt({location:"texture",type:"float32",texture:o,dims:a,download:r,dispose:i})},za=(o,t)=>{let{dataType:n,dims:e,download:r,dispose:i}=t;return new dt({location:"gpu-buffer",type:n??"float32",gpuBuffer:o,dims:e,download:r,dispose:i})},Ua=(o,t)=>{let{dataType:n,dims:e,download:r,dispose:i}=t;return new dt({location:"ml-tensor",type:n??"float32",mlTensor:o,dims:e,download:r,dispose:i})},ja=(o,t,n)=>new dt({location:"cpu-pinned",type:o,data:t,dims:n??[t.length]})});var ze,bn,Ha,qa,Ka=_(()=>{"use strict";ze=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),bn=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Ha=!1,qa=()=>{if(!Ha){Ha=!0;let o=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,n=globalThis.Float16Array,e=typeof n<"u"&&n.from;o&&(ze.set("int64",BigInt64Array),bn.set(BigInt64Array,"int64")),t&&(ze.set("uint64",BigUint64Array),bn.set(BigUint64Array,"uint64")),e?(ze.set("float16",n),bn.set(n,"float16")):ze.set("float16",Uint16Array)}}});var Xa,Za,Ja=_(()=>{"use strict";jn();Xa=o=>{let t=1;for(let n=0;n<o.length;n++){let e=o[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},Za=(o,t)=>{switch(o.location){case"cpu":return new dt(o.type,o.data,t);case"cpu-pinned":return new dt({location:"cpu-pinned",data:o.data,type:o.type,dims:t});case"texture":return new dt({location:"texture",texture:o.texture,type:o.type,dims:t});case"gpu-buffer":return new dt({location:"gpu-buffer",gpuBuffer:o.gpuBuffer,type:o.type,dims:t});case"ml-tensor":return new dt({location:"ml-tensor",mlTensor:o.mlTensor,type:o.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${o.location} is not supported`)}}});var dt,jn=_(()=>{"use strict";Ma();Wa();Ka();Ja();dt=class{constructor(t,n,e){qa();let r,i;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,r=t.type,i=t.dims,t.location){case"cpu-pinned":{let s=ze.get(r);if(!s)throw new TypeError(`unsupported type "${r}" 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(r!=="float32")throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint64"&&r!=="int8"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" 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(r=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=ze.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 ${r} 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")r="string",s=t;else if(l==="boolean")r="bool",s=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(t instanceof Uint8ClampedArray)r="uint8",s=Uint8Array.from(t);else{let l=bn.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);r=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=Xa(i);if(this.cpuData&&a!==this.cpuData.length&&!((r==="uint4"||r==="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=r,this.dims=i,this.size=a}static async fromImage(t,n){return Va(t,n)}static fromTexture(t,n){return Ba(t,n)}static fromGpuBuffer(t,n){return za(t,n)}static fromMLTensor(t,n){return Ua(t,n)}static fromPinnedBuffer(t,n,e){return ja(t,n,e)}toDataURL(t){return Ga(this,t)}toImageData(t){return ka(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 Za(this,t)}}});var Ht,to=_(()=>{"use strict";jn();Ht=dt});var eo,Ya,gn,yn,Tn,_n,no=_(()=>{"use strict";Yr();eo=(o,t)=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||console.timeStamp(`${o}::ORT::${t}`)},Ya=(o,t)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],e=!1;for(let r=0;r<n.length;r++){if(e&&!n[r].includes("TRACE_FUNC")){let i=`FUNC_${o}::${n[r].trim().split(" ")[1]}`;t&&(i+=`::${t}`),eo("CPU",i);return}n[r].includes("TRACE_FUNC")&&(e=!0)}},gn=o=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||Ya("BEGIN",o)},yn=o=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||Ya("END",o)},Tn=o=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||console.time(`ORT::${o}`)},_n=o=>{(typeof ut.trace>"u"?!ut.wasm.trace:!ut.trace)||console.timeEnd(`ORT::${o}`)}});var Wn,Qa=_(()=>{"use strict";Jr();to();no();Wn=class o{constructor(t){this.handler=t}async run(t,n,e){gn(),Tn("InferenceSession.run");let r={},i={};if(typeof t!="object"||t===null||t instanceof Ht||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 Ht)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}.`);r[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 h=n[d];(h===null||h instanceof Ht)&&(l=!0,a=!1,r[d]=h)}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)r[l]=null;let s=await this.handler.run(t,r,i),u={};for(let l in s)if(Object.hasOwnProperty.call(s,l)){let c=s[l];c instanceof Ht?u[l]=c:u[l]=new Ht(c.type,c.data,c.dims)}return _n("InferenceSession.run"),yn(),u}async release(){return this.handler.dispose()}static async create(t,n,e,r){gn(),Tn("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,h=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(h=t.byteLength-d,typeof e=="number"){if(h=e,!Number.isSafeInteger(h))throw new RangeError("'byteLength' must be an integer.");if(h<=0||d+h>c.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${c.byteLength-d}].`);if(typeof r=="object"&&r!==null)a=r;else if(typeof r<"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,h)}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 _n("InferenceSession.create"),yn(),new o(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 ts,es=_(()=>{"use strict";Qa();ts=Wn});var ns=_(()=>{"use strict"});var rs=_(()=>{"use strict"});var os=_(()=>{"use strict"});var is=_(()=>{"use strict"});var ro={};Zr(ro,{InferenceSession:()=>ts,TRACE:()=>eo,TRACE_EVENT_BEGIN:()=>Tn,TRACE_EVENT_END:()=>_n,TRACE_FUNC_BEGIN:()=>gn,TRACE_FUNC_END:()=>yn,Tensor:()=>Ht,env:()=>nt,registerBackend:()=>mn});var $e=_(()=>{"use strict";Na();Ra();es();to();ns();rs();no();os();is()});function Fe(o,t,n,e){if(t===void 0)return Kd(o);if(n===void 0)Hn(o,t,1);else if(typeof n=="number"&&e===void 0)Hn(o,t,n);else if(typeof n=="string"&&e===void 0)Hn(o,n,1,t);else if(typeof n=="string"&&typeof e=="number")Hn(o,n,e,t);else throw new TypeError("input is valid")}function Kd(o){return{verbose:Fe.verbose.bind(null,o),info:Fe.info.bind(null,o),warning:Fe.warning.bind(null,o),error:Fe.error.bind(null,o),fatal:Fe.fatal.bind(null,o)}}function Hn(o,t,n,e){let r=xn[e||""]||xn[""];ss[o]<ss[r.minimalSeverity]||(r.logDateTime&&(t=`${new Date().toISOString()}|${t}`),r.logSourceLocation,qd[r.provider].log(o,t,e))}var oo,io,ss,qd,us,xn,q,Kn,Xn,Zn,qn,Dt=_(()=>{"use strict";oo=class{log(t,n,e){}},io=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}`)}}},ss={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},qd={none:new oo,console:new io},us={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},xn={"":us};(u=>{function o(l,c){u("verbose",l,c)}u.verbose=o;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 r(l,c){u("fatal",l,c)}u.fatal=r;function i(l){xn={},a("",l||{})}u.reset=i;function a(l,c){if(l==="*")i(c);else{let d=xn[l]||us;xn[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})(Fe||={});q=Fe,Kn=class{constructor(t,n,e,r,i,a){this.category=t;this.name=n;this.startTime=e;this.endCallback=r;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)}},Xn=class{constructor(t,n,e,r){this.category=t;this.name=n;this.startTime=e;this.endTime=r}},Zn=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=qn(),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,r){let i=this._started?this.begin(t,n,r):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 r=qn();return this.flush(r),new Kn(t,n,r,i=>this.endSync(i))}else{let r=e.beginTimer();return new Kn(t,n,0,async i=>this.end(i),r,e)}}async end(t){let n=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Xn(t.category,t.name,t.startTime,n)),this.flush(n))}endSync(t){let n=qn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Xn(t.category,t.name,t.startTime,n)),this.flush(n))}logOneEvent(t){q.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=qn()}}get started(){return this._started}},qn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function ls(o,t,n){for(let e of n){let r=e[0],i=e[1],a=e[2],s=e[3],u=e[4];if(o.opType===r){for(let l of t)if((l.domain===i||l.domain==="ai.onnx"&&i==="")&&Xd(l.version,a))return{opImpl:s,opInit:u}}}throw new TypeError(`cannot resolve operator '${o.opType}' with opsets: ${t.map(e=>`${e.domain||"ai.onnx"} v${e.version}`).join(", ")}`)}function Xd(o,t){if(t.endsWith("+")){let n=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(n)&&n<=o}else if(t.split("-").length===2){let n=t.split("-"),e=Number.parseInt(n[0],10),r=Number.parseInt(n[1],10);return!isNaN(e)&&!isNaN(r)&&e<=o&&o<=r}else return Number.parseInt(t,10)===o}var cs=_(()=>{"use strict"});var fs=A(ao=>{"use strict";ao.__esModule=!0;var Zd=(function(){function o(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=o.EMPTY,t&&o.isGuid(t)&&(this.value=t)}return o.isGuid=function(t){var n=t.toString();return t&&(t instanceof o||o.validator.test(n))},o.create=function(){return new o([o.gen(2),o.gen(1),o.gen(1),o.gen(1),o.gen(3)].join("-"))},o.createEmpty=function(){return new o("emptyguid")},o.parse=function(t){return new o(t)},o.raw=function(){return[o.gen(2),o.gen(1),o.gen(1),o.gen(1),o.gen(3)].join("-")},o.gen=function(t){for(var n="",e=0;e<t;e++)n+=((1+Math.random())*65536|0).toString(16).substring(1);return n},o.prototype.equals=function(t){return o.isGuid(t)&&this.value===t.toString()},o.prototype.isEmpty=function(){return this.value===o.EMPTY},o.prototype.toString=function(){return this.value},o.prototype.toJSON=function(){return{value:this.value}},o.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),o.EMPTY="00000000-0000-0000-0000-000000000000",o})();ao.Guid=Zd});function K(o,t,n){this.low=o|0,this.high=t|0,this.unsigned=!!n}function mt(o){return(o&&o.__isLong__)===!0}function ds(o){var t=Math.clz32(o&-o);return o?31-t:t}function Ue(o,t){var n,e,r;return t?(o>>>=0,(r=0<=o&&o<256)&&(e=hs[o],e)?e:(n=B(o,0,!0),r&&(hs[o]=n),n)):(o|=0,(r=-128<=o&&o<128)&&(e=ps[o],e)?e:(n=B(o,o<0?-1:0,!1),r&&(ps[o]=n),n))}function Nt(o,t){if(isNaN(o))return t?Le:Bt;if(t){if(o<0)return Le;if(o>=ys)return xs}else{if(o<=-bs)return vt;if(o+1>=bs)return _s}return o<0?Nt(-o,t).neg():B(o%nn|0,o/nn|0,t)}function B(o,t,n){return new K(o,t,n)}function uo(o,t,n){if(o.length===0)throw Error("empty string");if(typeof t=="number"?(n=t,t=!1):t=!!t,o==="NaN"||o==="Infinity"||o==="+Infinity"||o==="-Infinity")return t?Le:Bt;if(n=n||10,n<2||36<n)throw RangeError("radix");var e;if((e=o.indexOf("-"))>0)throw Error("interior hyphen");if(e===0)return uo(o.substring(1),t,n).neg();for(var r=Nt(Jn(n,8)),i=Bt,a=0;a<o.length;a+=8){var s=Math.min(8,o.length-a),u=parseInt(o.substring(a,a+s),n);if(s<8){var l=Nt(Jn(n,s));i=i.mul(l).add(Nt(u))}else i=i.mul(r),i=i.add(Nt(u))}return i.unsigned=t,i}function $t(o,t){return typeof o=="number"?Nt(o,t):typeof o=="string"?uo(o,t):B(o.low,o.high,typeof t=="boolean"?t:o.unsigned)}var Lt,ps,hs,Jn,ms,Jd,nn,ys,bs,gs,Bt,Le,en,Ts,so,_s,xs,vt,v,Ce,lo=_(()=>{Lt=null;try{Lt=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{}K.prototype.__isLong__;Object.defineProperty(K.prototype,"__isLong__",{value:!0});K.isLong=mt;ps={},hs={};K.fromInt=Ue;K.fromNumber=Nt;K.fromBits=B;Jn=Math.pow;K.fromString=uo;K.fromValue=$t;ms=65536,Jd=1<<24,nn=ms*ms,ys=nn*nn,bs=ys/2,gs=Ue(Jd),Bt=Ue(0);K.ZERO=Bt;Le=Ue(0,!0);K.UZERO=Le;en=Ue(1);K.ONE=en;Ts=Ue(1,!0);K.UONE=Ts;so=Ue(-1);K.NEG_ONE=so;_s=B(-1,2147483647,!1);K.MAX_VALUE=_s;xs=B(-1,-1,!0);K.MAX_UNSIGNED_VALUE=xs;vt=B(0,-2147483648,!1);K.MIN_VALUE=vt;v=K.prototype;v.toInt=function(){return this.unsigned?this.low>>>0:this.low};v.toNumber=function(){return this.unsigned?(this.high>>>0)*nn+(this.low>>>0):this.high*nn+(this.low>>>0)};v.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(vt)){var n=Nt(t),e=this.div(n),r=e.mul(n).sub(this);return e.toString(t)+r.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var i=Nt(Jn(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}};v.getHighBits=function(){return this.high};v.getHighBitsUnsigned=function(){return this.high>>>0};v.getLowBits=function(){return this.low};v.getLowBitsUnsigned=function(){return this.low>>>0};v.getNumBitsAbs=function(){if(this.isNegative())return this.eq(vt)?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};v.isSafeInteger=function(){var t=this.high>>21;return t?this.unsigned?!1:t===-1&&!(this.low===0&&this.high===-2097152):!0};v.isZero=function(){return this.high===0&&this.low===0};v.eqz=v.isZero;v.isNegative=function(){return!this.unsigned&&this.high<0};v.isPositive=function(){return this.unsigned||this.high>=0};v.isOdd=function(){return(this.low&1)===1};v.isEven=function(){return(this.low&1)===0};v.equals=function(t){return mt(t)||(t=$t(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};v.eq=v.equals;v.notEquals=function(t){return!this.eq(t)};v.neq=v.notEquals;v.ne=v.notEquals;v.lessThan=function(t){return this.comp(t)<0};v.lt=v.lessThan;v.lessThanOrEqual=function(t){return this.comp(t)<=0};v.lte=v.lessThanOrEqual;v.le=v.lessThanOrEqual;v.greaterThan=function(t){return this.comp(t)>0};v.gt=v.greaterThan;v.greaterThanOrEqual=function(t){return this.comp(t)>=0};v.gte=v.greaterThanOrEqual;v.ge=v.greaterThanOrEqual;v.compare=function(t){if(mt(t)||(t=$t(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};v.comp=v.compare;v.negate=function(){return!this.unsigned&&this.eq(vt)?vt:this.not().add(en)};v.neg=v.negate;v.add=function(t){mt(t)||(t=$t(t));var n=this.high>>>16,e=this.high&65535,r=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,h=0,b=0;return b+=i+l,h+=b>>>16,b&=65535,h+=r+u,d+=h>>>16,h&=65535,d+=e+s,c+=d>>>16,d&=65535,c+=n+a,c&=65535,B(h<<16|b,c<<16|d,this.unsigned)};v.subtract=function(t){return mt(t)||(t=$t(t)),this.add(t.neg())};v.sub=v.subtract;v.multiply=function(t){if(this.isZero())return this;if(mt(t)||(t=$t(t)),Lt){var n=Lt.mul(this.low,this.high,t.low,t.high);return B(n,Lt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Le:Bt;if(this.eq(vt))return t.isOdd()?vt:Bt;if(t.eq(vt))return this.isOdd()?vt:Bt;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(gs)&&t.lt(gs))return Nt(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,r=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,h=0,b=0,y=0;return y+=a*c,b+=y>>>16,y&=65535,b+=i*c,h+=b>>>16,b&=65535,b+=a*l,h+=b>>>16,b&=65535,h+=r*c,d+=h>>>16,h&=65535,h+=i*l,d+=h>>>16,h&=65535,h+=a*u,d+=h>>>16,h&=65535,d+=e*c+r*l+i*u+a*s,d&=65535,B(b<<16|y,d<<16|h,this.unsigned)};v.mul=v.multiply;v.divide=function(t){if(mt(t)||(t=$t(t)),t.isZero())throw Error("division by zero");if(Lt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var n=(this.unsigned?Lt.div_u:Lt.div_s)(this.low,this.high,t.low,t.high);return B(n,Lt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Le:Bt;var e,r,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Le;if(t.gt(this.shru(1)))return Ts;i=Le}else{if(this.eq(vt)){if(t.eq(en)||t.eq(so))return vt;if(t.eq(vt))return en;var a=this.shr(1);return e=a.div(t).shl(1),e.eq(Bt)?t.isNegative()?en:so:(r=this.sub(t.mul(e)),i=e.add(r.div(t)),i)}else if(t.eq(vt))return this.unsigned?Le:Bt;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=Bt}for(r=this;r.gte(t);){e=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(e)/Math.LN2),u=s<=48?1:Jn(2,s-48),l=Nt(e),c=l.mul(t);c.isNegative()||c.gt(r);)e-=u,l=Nt(e,this.unsigned),c=l.mul(t);l.isZero()&&(l=en),i=i.add(l),r=r.sub(c)}return i};v.div=v.divide;v.modulo=function(t){if(mt(t)||(t=$t(t)),Lt){var n=(this.unsigned?Lt.rem_u:Lt.rem_s)(this.low,this.high,t.low,t.high);return B(n,Lt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};v.mod=v.modulo;v.rem=v.modulo;v.not=function(){return B(~this.low,~this.high,this.unsigned)};v.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};v.clz=v.countLeadingZeros;v.countTrailingZeros=function(){return this.low?ds(this.low):ds(this.high)+32};v.ctz=v.countTrailingZeros;v.and=function(t){return mt(t)||(t=$t(t)),B(this.low&t.low,this.high&t.high,this.unsigned)};v.or=function(t){return mt(t)||(t=$t(t)),B(this.low|t.low,this.high|t.high,this.unsigned)};v.xor=function(t){return mt(t)||(t=$t(t)),B(this.low^t.low,this.high^t.high,this.unsigned)};v.shiftLeft=function(t){return mt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):B(0,this.low<<t-32,this.unsigned)};v.shl=v.shiftLeft;v.shiftRight=function(t){return mt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):B(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};v.shr=v.shiftRight;v.shiftRightUnsigned=function(t){return mt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?B(this.high,0,this.unsigned):B(this.high>>>t-32,0,this.unsigned)};v.shru=v.shiftRightUnsigned;v.shr_u=v.shiftRightUnsigned;v.rotateLeft=function(t){var n;return mt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?B(this.high,this.low,this.unsigned):t<32?(n=32-t,B(this.low<<t|this.high>>>n,this.high<<t|this.low>>>n,this.unsigned)):(t-=32,n=32-t,B(this.high<<t|this.low>>>n,this.low<<t|this.high>>>n,this.unsigned))};v.rotl=v.rotateLeft;v.rotateRight=function(t){var n;return mt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?B(this.high,this.low,this.unsigned):t<32?(n=32-t,B(this.high<<n|this.low>>>t,this.low<<n|this.high>>>t,this.unsigned)):(t-=32,n=32-t,B(this.low<<n|this.high>>>t,this.high<<n|this.low>>>t,this.unsigned))};v.rotr=v.rotateRight;v.toSigned=function(){return this.unsigned?B(this.low,this.high,!1):this};v.toUnsigned=function(){return this.unsigned?this:B(this.low,this.high,!0)};v.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};v.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]};v.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]};K.fromBytes=function(t,n,e){return e?K.fromBytesLE(t,n):K.fromBytesBE(t,n)};K.fromBytesLE=function(t,n){return new K(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)};K.fromBytesBE=function(t,n){return new K(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)};typeof BigInt=="function"&&(K.fromBigInt=function(t,n){var e=Number(BigInt.asIntN(32,t)),r=Number(BigInt.asIntN(32,t>>BigInt(32)));return B(e,r,n)},K.fromValue=function(t,n){return typeof t=="bigint"?K.fromBigInt(t,n):$t(t,n)},v.toBigInt=function(){var t=BigInt(this.low>>>0),n=BigInt(this.unsigned?this.high>>>0:this.high);return n<<BigInt(32)|t});Ce=K});var co=A(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.ArgType=void 0;var vs;(function(o){o[o.INPUT=0]="INPUT",o[o.OUTPUT=1]="OUTPUT"})(vs||(Yn.ArgType=vs={}))});var Qn=A(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.SIZE_PREFIX_LENGTH=qt.FILE_IDENTIFIER_LENGTH=qt.SIZEOF_INT=qt.SIZEOF_SHORT=void 0;qt.SIZEOF_SHORT=2;qt.SIZEOF_INT=4;qt.FILE_IDENTIFIER_LENGTH=4;qt.SIZE_PREFIX_LENGTH=4});var fo=A(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.isLittleEndian=Ft.float64=Ft.float32=Ft.int32=void 0;Ft.int32=new Int32Array(2);Ft.float32=new Float32Array(Ft.int32.buffer);Ft.float64=new Float64Array(Ft.int32.buffer);Ft.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1});var po=A(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.Encoding=void 0;var ws;(function(o){o[o.UTF8_BYTES=1]="UTF8_BYTES",o[o.UTF16_STRING=2]="UTF16_STRING"})(ws||(tr.Encoding=ws={}))});var mo=A(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.ByteBuffer=void 0;var Kt=Qn(),Yd=po(),wt=fo(),ho=class o{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new o(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 wt.int32[0]=this.readInt32(t),wt.float32[0]}readFloat64(t){return wt.int32[wt.isLittleEndian?0:1]=this.readInt32(t),wt.int32[wt.isLittleEndian?1:0]=this.readInt32(t+4),wt.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){wt.float32[0]=n,this.writeInt32(t,wt.int32[0])}writeFloat64(t,n){wt.float64[0]=n,this.writeInt32(t,wt.int32[wt.isLittleEndian?0:1]),this.writeInt32(t+4,wt.int32[wt.isLittleEndian?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Kt.SIZEOF_INT+Kt.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<Kt.FILE_IDENTIFIER_LENGTH;n++)t+=String.fromCharCode(this.readInt8(this.position_+Kt.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+=Kt.SIZEOF_INT;let r=this.bytes_.subarray(t,t+e);return n===Yd.Encoding.UTF8_BYTES?r:this.text_decoder_.decode(r)}__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)+Kt.SIZEOF_INT}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=Kt.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+Kt.FILE_IDENTIFIER_LENGTH);for(let n=0;n<Kt.FILE_IDENTIFIER_LENGTH;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+Kt.SIZEOF_INT+n))return!1;return!0}createScalarList(t,n){let e=[];for(let r=0;r<n;++r){let i=t(r);i!==null&&e.push(i)}return e}createObjList(t,n){let e=[];for(let r=0;r<n;++r){let i=t(r);i!==null&&e.push(i.unpack())}return e}};er.ByteBuffer=ho});var Os=A(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.Builder=void 0;var Is=mo(),St=Qn(),bo=class o{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=Is.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 r=this.bb.capacity();this.bb=o.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}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,r=Is.ByteBuffer.allocate(e);return r.setPosition(e-n),r.bytes().set(t.bytes(),e-n),r}addOffset(t){this.prep(St.SIZEOF_INT,0),this.writeInt32(this.offset()-t+St.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 r=2;this.addInt16(t-this.object_start);let i=(e+r)*St.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=St.SIZEOF_SHORT;l<i;l+=St.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 r=e?St.SIZE_PREFIX_LENGTH:0;if(n){let i=n;if(this.prep(this.minalign,St.SIZEOF_INT+St.FILE_IDENTIFIER_LENGTH+r),i.length!=St.FILE_IDENTIFIER_LENGTH)throw new TypeError("FlatBuffers: file identifier must be length "+St.FILE_IDENTIFIER_LENGTH);for(let a=St.FILE_IDENTIFIER_LENGTH-1;a>=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,St.SIZEOF_INT+r),this.addOffset(t),r&&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,r=e-this.bb.readInt32(e);if(!(n<this.bb.readInt16(r)&&this.bb.readInt16(r+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,e){this.notNested(),this.vector_num_elems=n,this.prep(St.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 r=t[e];if(r!==null)n.push(this.createObjectOffset(r));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()}};nr.Builder=bo});var W=A(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.Encoding=Q.ByteBuffer=Q.Builder=Q.isLittleEndian=Q.int32=Q.float64=Q.float32=Q.SIZE_PREFIX_LENGTH=Q.SIZEOF_SHORT=Q.SIZEOF_INT=Q.FILE_IDENTIFIER_LENGTH=void 0;var rr=Qn();Object.defineProperty(Q,"FILE_IDENTIFIER_LENGTH",{enumerable:!0,get:function(){return rr.FILE_IDENTIFIER_LENGTH}});Object.defineProperty(Q,"SIZEOF_INT",{enumerable:!0,get:function(){return rr.SIZEOF_INT}});Object.defineProperty(Q,"SIZEOF_SHORT",{enumerable:!0,get:function(){return rr.SIZEOF_SHORT}});Object.defineProperty(Q,"SIZE_PREFIX_LENGTH",{enumerable:!0,get:function(){return rr.SIZE_PREFIX_LENGTH}});var or=fo();Object.defineProperty(Q,"float32",{enumerable:!0,get:function(){return or.float32}});Object.defineProperty(Q,"float64",{enumerable:!0,get:function(){return or.float64}});Object.defineProperty(Q,"int32",{enumerable:!0,get:function(){return or.int32}});Object.defineProperty(Q,"isLittleEndian",{enumerable:!0,get:function(){return or.isLittleEndian}});var Qd=Os();Object.defineProperty(Q,"Builder",{enumerable:!0,get:function(){return Qd.Builder}});var tp=mo();Object.defineProperty(Q,"ByteBuffer",{enumerable:!0,get:function(){return tp.ByteBuffer}});var ep=po();Object.defineProperty(Q,"Encoding",{enumerable:!0,get:function(){return ep.Encoding}})});var yo=A(Xt=>{"use strict";var np=Xt&&Xt.__createBinding||(Object.create?function(o,t,n,e){e===void 0&&(e=n);var r=Object.getOwnPropertyDescriptor(t,n);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(o,e,r)}:function(o,t,n,e){e===void 0&&(e=n),o[e]=t[n]}),rp=Xt&&Xt.__setModuleDefault||(Object.create?function(o,t){Object.defineProperty(o,"default",{enumerable:!0,value:t})}:function(o,t){o.default=t}),op=Xt&&Xt.__importStar||(function(){var o=function(t){return o=Object.getOwnPrope