UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

6 lines 543 kB
/*! * ONNX Runtime Web v1.17.3 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ var Od=Object.create;var Dn=Object.defineProperty;var Id=Object.getOwnPropertyDescriptor;var Sd=Object.getOwnPropertyNames;var Ad=Object.getPrototypeOf,Pd=Object.prototype.hasOwnProperty;var E=(a,t)=>()=>(a&&(t=a(a=0)),t);var me=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports),Pr=(a,t)=>{for(var o in t)Dn(a,o,{get:t[o],enumerable:!0})},Ha=(a,t,o,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Sd(t))!Pd.call(a,r)&&r!==o&&Dn(a,r,{get:()=>t[r],enumerable:!(e=Id(t,r))||e.enumerable});return a};var Er=(a,t,o)=>(o=a!=null?Od(Ad(a)):{},Ha(t||!a||!a.__esModule?Dn(o,"default",{value:a,enumerable:!0}):o,a)),or=a=>Ha(Dn({},"__esModule",{value:!0}),a);var Ln,ir,Dr,Ed,Fn,Cn=E(()=>{"use strict";Ln=new Map,ir=[],Dr=(a,t,o)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let e=Ln.get(a);if(e===void 0)Ln.set(a,{backend:t,priority:o});else{if(e.priority>o)return;if(e.priority===o&&e.backend!==t)throw new Error(`cannot register backend "${a}" using priority ${o}`)}if(o>=0){let r=ir.indexOf(a);r!==-1&&ir.splice(r,1);for(let n=0;n<ir.length;n++)if(Ln.get(ir[n]).priority<=o){ir.splice(n,0,a);return}ir.push(a)}return}throw new TypeError("not a valid backend")},Ed=async a=>{let t=Ln.get(a);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let o=!!t.initPromise;try{return o||(t.initPromise=t.backend.init(a)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return o||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},Fn=async a=>{let t=a.executionProviders||[],o=t.map(u=>typeof u=="string"?u:u.name),e=o.length===0?ir:o,r,n=[],s=new Set;for(let u of e){let l=await Ed(u);typeof l=="string"?n.push({name:u,err:l}):(r||(r=l),r===l&&s.add(u))}if(!r)throw new Error(`no available backend found. ERR: ${n.map(u=>`[${u.name}] ${u.err}`).join(", ")}`);for(let{name:u,err:l}of n)o.includes(u)&&console.warn(`removing requested execution provider "${u}" from session options because it is not available: ${l}`);let i=t.filter(u=>s.has(typeof u=="string"?u:u.name));return[r,new Proxy(a,{get:(u,l)=>l==="executionProviders"?i:Reflect.get(u,l)})]}});var qa=E(()=>{"use strict";Cn()});var ja,Ya=E(()=>{"use strict";ja="1.17.3"});var Xa,it,Ho=E(()=>{"use strict";Ya();Xa="warning",it={wasm:{},webgl:{},webgpu:{},versions:{common:ja},set logLevel(a){if(a!==void 0){if(typeof a!="string"||["verbose","info","warning","error","fatal"].indexOf(a)===-1)throw new Error(`Unsupported logging level: ${a}`);Xa=a}},get logLevel(){return Xa}};Object.defineProperty(it,"logLevel",{enumerable:!0})});var Z,Ka=E(()=>{"use strict";Ho();Z=it});var Ja,Za,Qa=E(()=>{"use strict";Ja=(a,t)=>{let o=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);o.width=a.dims[3],o.height=a.dims[2];let e=o.getContext("2d");if(e!=null){let r,n;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(r=a.dims[2],n=a.dims[3]):(r=a.dims[3],n=a.dims[2]);let s=t?.format!==void 0?t.format:"RGB",i=t?.norm,u,l;i===void 0||i.mean===void 0?u=[255,255,255,255]:typeof i.mean=="number"?u=[i.mean,i.mean,i.mean,i.mean]:(u=[i.mean[0],i.mean[1],i.mean[2],0],i.mean[3]!==void 0&&(u[3]=i.mean[3])),i===void 0||i.bias===void 0?l=[0,0,0,0]:typeof i.bias=="number"?l=[i.bias,i.bias,i.bias,i.bias]:(l=[i.bias[0],i.bias[1],i.bias[2],0],i.bias[3]!==void 0&&(l[3]=i.bias[3]));let f=n*r,p=0,d=f,T=f*2,v=-1;s==="RGBA"?(p=0,d=f,T=f*2,v=f*3):s==="RGB"?(p=0,d=f,T=f*2):s==="RBG"&&(p=0,T=f,d=f*2);for(let w=0;w<n;w++)for(let I=0;I<r;I++){let L=(a.data[p++]-l[0])*u[0],F=(a.data[d++]-l[1])*u[1],C=(a.data[T++]-l[2])*u[2],Y=v===-1?255:(a.data[v++]-l[3])*u[3];e.fillStyle="rgba("+L+","+F+","+C+","+Y+")",e.fillRect(I,w,1,1)}if("toDataURL"in o)return o.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},Za=(a,t)=>{let o=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),e;if(o!=null){let r,n,s;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(r=a.dims[2],n=a.dims[1],s=a.dims[3]):(r=a.dims[3],n=a.dims[2],s=a.dims[1]);let i=t!==void 0&&t.format!==void 0?t.format:"RGB",u=t?.norm,l,f;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?f=[0,0,0,0]:typeof u.bias=="number"?f=[u.bias,u.bias,u.bias,u.bias]:(f=[u.bias[0],u.bias[1],u.bias[2],0],u.bias[3]!==void 0&&(f[3]=u.bias[3]));let p=n*r;if(t!==void 0&&(t.format!==void 0&&s===4&&t.format!=="RGBA"||s===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,T=0,v=1,w=2,I=3,L=0,F=p,C=p*2,Y=-1;i==="RGBA"?(L=0,F=p,C=p*2,Y=p*3):i==="RGB"?(L=0,F=p,C=p*2):i==="RBG"&&(L=0,C=p,F=p*2),e=o.createImageData(r,n);for(let j=0;j<n*r;T+=d,v+=d,w+=d,I+=d,j++)e.data[T]=(a.data[L++]-f[0])*l[0],e.data[v]=(a.data[F++]-f[1])*l[1],e.data[w]=(a.data[C++]-f[2])*l[2],e.data[I]=Y===-1?255:(a.data[Y++]-f[3])*l[3]}else throw new Error("Can not access image data");return e}});var qo,es,ts,rs,ns,os=E(()=>{"use strict";$n();qo=(a,t)=>{if(a===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:o,width:e}=t,r=t.norm??{mean:255,bias:0},n,s;typeof r.mean=="number"?n=[r.mean,r.mean,r.mean,r.mean]:n=[r.mean[0],r.mean[1],r.mean[2],r.mean[3]??255],typeof r.bias=="number"?s=[r.bias,r.bias,r.bias,r.bias]:s=[r.bias[0],r.bias[1],r.bias[2],r.bias[3]??0];let i=t.format!==void 0?t.format:"RGBA",u=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",l=o*e,f=u==="RGBA"?new Float32Array(l*4):new Float32Array(l*3),p=4,d=0,T=1,v=2,w=3,I=0,L=l,F=l*2,C=-1;i==="RGB"&&(p=3,d=0,T=1,v=2,w=-1),u==="RGBA"?C=l*3:u==="RBG"?(I=0,F=l,L=l*2):u==="BGR"&&(F=0,L=l,I=l*2);for(let j=0;j<l;j++,d+=p,v+=p,T+=p,w+=p)f[I++]=(a[d]+s[0])/n[0],f[L++]=(a[T]+s[1])/n[1],f[F++]=(a[v]+s[2])/n[2],C!==-1&&w!==-1&&(f[C++]=(a[w]+s[3])/n[3]);return u==="RGBA"?new Xe("float32",f,[1,4,o,e]):new Xe("float32",f,[1,3,o,e])},es=async(a,t)=>{let o=typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement,e=typeof ImageData<"u"&&a instanceof ImageData,r=typeof ImageBitmap<"u"&&a instanceof ImageBitmap,n=typeof a=="string",s,i=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=f=>f instanceof HTMLCanvasElement||f instanceof OffscreenCanvas?f.getContext("2d"):null;if(o){let f=u();f.width=a.width,f.height=a.height;let p=l(f);if(p!=null){let d=a.height,T=a.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(d=t.resizedHeight,T=t.resizedWidth),t!==void 0){if(i=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");i.tensorFormat="RGBA",i.height=d,i.width=T}else i.tensorFormat="RGBA",i.height=d,i.width=T;p.drawImage(a,0,0),s=p.getImageData(0,0,T,d).data}else throw new Error("Can not access image data")}else if(e){let f,p;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(f=t.resizedHeight,p=t.resizedWidth):(f=a.height,p=a.width),t!==void 0&&(i=t),i.format="RGBA",i.height=f,i.width=p,t!==void 0){let d=u();d.width=p,d.height=f;let T=l(d);if(T!=null)T.putImageData(a,0,0),s=T.getImageData(0,0,p,f).data;else throw new Error("Can not access image data")}else s=a.data}else if(r){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let f=u();f.width=a.width,f.height=a.height;let p=l(f);if(p!=null){let d=a.height,T=a.width;return p.drawImage(a,0,0,T,d),s=p.getImageData(0,0,T,d).data,i.height=d,i.width=T,qo(s,i)}else throw new Error("Can not access image data")}else{if(n)return new Promise((f,p)=>{let d=u(),T=l(d);if(!a||!T)return p();let v=new Image;v.crossOrigin="Anonymous",v.src=a,v.onload=()=>{d.width=v.width,d.height=v.height,T.drawImage(v,0,0,d.width,d.height);let w=T.getImageData(0,0,d.width,d.height);i.height=d.height,i.width=d.width,f(qo(w.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return qo(s,i);throw new Error("Input data provided is not supported - aborted tensor creation")},ts=(a,t)=>{let{width:o,height:e,download:r,dispose:n}=t,s=[1,e,o,4];return new Xe({location:"texture",type:"float32",texture:a,dims:s,download:r,dispose:n})},rs=(a,t)=>{let{dataType:o,dims:e,download:r,dispose:n}=t;return new Xe({location:"gpu-buffer",type:o??"float32",gpuBuffer:a,dims:e,download:r,dispose:n})},ns=(a,t,o)=>new Xe({location:"cpu-pinned",type:a,data:t,dims:o??[t.length]})});var ar,tn,is,as,ss=E(()=>{"use strict";ar=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),tn=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),is=!1,as=()=>{if(!is){is=!0;let a=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,o=typeof Float16Array<"u"&&Float16Array.from;a&&(ar.set("int64",BigInt64Array),tn.set(BigInt64Array,"int64")),t&&(ar.set("uint64",BigUint64Array),tn.set(BigUint64Array,"uint64")),o?(ar.set("float16",Float16Array),tn.set(Float16Array,"float16")):ar.set("float16",Uint16Array)}}});var us,ls,fs=E(()=>{"use strict";$n();us=a=>{let t=1;for(let o=0;o<a.length;o++){let e=a[o];if(typeof e!="number"||!Number.isSafeInteger(e))throw new TypeError(`dims[${o}] must be an integer, got: ${e}`);if(e<0)throw new RangeError(`dims[${o}] must be a non-negative integer, got: ${e}`);t*=e}return t},ls=(a,t)=>{switch(a.location){case"cpu":return new Xe(a.type,a.data,t);case"cpu-pinned":return new Xe({location:"cpu-pinned",data:a.data,type:a.type,dims:t});case"texture":return new Xe({location:"texture",texture:a.texture,type:a.type,dims:t});case"gpu-buffer":return new Xe({location:"gpu-buffer",gpuBuffer:a.gpuBuffer,type:a.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${a.location} is not supported`)}}});var Xe,$n=E(()=>{"use strict";Qa();os();ss();fs();Xe=class{constructor(t,o,e){as();let r,n;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,r=t.type,n=t.dims,t.location){case"cpu-pinned":{let i=ar.get(r);if(!i)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(t.data instanceof i))throw new TypeError(`buffer should be of type ${i.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")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}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let i,u;if(typeof t=="string")if(r=t,u=e,t==="string"){if(!Array.isArray(o))throw new TypeError("A string tensor's data must be a string array.");i=o}else{let l=ar.get(t);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(o)){if(t==="float16"&&l===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");t==="uint64"||t==="int64"?i=l.from(o,BigInt):i=l.from(o)}else if(o instanceof l)i=o;else throw new TypeError(`A ${r} tensor's data must be type of ${l}`)}else if(u=o,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",i=t;else if(l==="boolean")r="bool",i=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else{let l=tn.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);r=l,i=t}if(u===void 0)u=[i.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");n=u,this.cpuData=i,this.dataLocation="cpu"}let s=us(n);if(this.cpuData&&s!==this.cpuData.length)throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=n,this.size=s}static async fromImage(t,o){return es(t,o)}static fromTexture(t,o){return ts(t,o)}static fromGpuBuffer(t,o){return rs(t,o)}static fromPinnedBuffer(t,o,e){return ns(t,o,e)}toDataURL(t){return Ja(this,t)}toImageData(t){return Za(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}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":{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 o=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=o,t&&this.disposer&&(this.disposer(),this.disposer=void 0),o}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.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 ls(this,t)}}});var Re,kn=E(()=>{"use strict";$n();Re=Xe});var cs,ps,sr,ur,jo=E(()=>{"use strict";Ho();cs=(a,t)=>{(typeof it.trace>"u"?!it.wasm.trace:!it.trace)||console.timeStamp(`${a}::ORT::${t}`)},ps=(a,t)=>{let o=new Error().stack?.split(/\r\n|\r|\n/g)||[],e=!1;for(let r=0;r<o.length;r++){if(e&&!o[r].includes("TRACE_FUNC")){let n=`FUNC_${a}::${o[r].trim().split(" ")[1]}`;t&&(n+=`::${t}`),cs("CPU",n);return}o[r].includes("TRACE_FUNC")&&(e=!0)}},sr=a=>{(typeof it.trace>"u"?!it.wasm.trace:!it.trace)||ps("BEGIN",a)},ur=a=>{(typeof it.trace>"u"?!it.wasm.trace:!it.trace)||ps("END",a)}});var Bn,ds=E(()=>{"use strict";Cn();kn();jo();Bn=class a{constructor(t){this.handler=t}async run(t,o,e){sr();let r={},n={};if(typeof t!="object"||t===null||t instanceof Re||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof o=="object"){if(o===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(o instanceof Re)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(o)){if(o.length===0)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let l of o){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)n=e;else if(typeof e<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,f=Object.getOwnPropertyNames(o);for(let p of this.outputNames)if(f.indexOf(p)!==-1){let d=o[p];(d===null||d instanceof Re)&&(l=!0,s=!1,r[p]=d)}if(l){if(typeof e=="object"&&e!==null)n=e;else if(typeof e<"u")throw new TypeError("'options' must be an object.")}else n=o}}else if(typeof o<"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(s)for(let l of this.outputNames)r[l]=null;let i=await this.handler.run(t,r,n),u={};for(let l in i)if(Object.hasOwnProperty.call(i,l)){let f=i[l];f instanceof Re?u[l]=f:u[l]=new Re(f.type,f.data,f.dims)}return ur(),u}async release(){return this.handler.dispose()}static async create(t,o,e,r){sr();let n,s={};if(typeof t=="string"){if(n=t,typeof o=="object"&&o!==null)s=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(n=t,typeof o=="object"&&o!==null)s=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let f=t,p=0,d=t.byteLength;if(typeof o=="object"&&o!==null)s=o;else if(typeof o=="number"){if(p=o,!Number.isSafeInteger(p))throw new RangeError("'byteOffset' must be an integer.");if(p<0||p>=f.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${f.byteLength}).`);if(d=t.byteLength-p,typeof e=="number"){if(d=e,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||p+d>f.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${f.byteLength-p}].`);if(typeof r=="object"&&r!==null)s=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 o<"u")throw new TypeError("'options' must be an object.");n=new Uint8Array(f,p,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[i,u]=await Fn(s),l=await i.createInferenceSessionHandler(n,u);return ur(),new a(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var Dd,hs=E(()=>{"use strict";ds();Dd=Bn});var ms=E(()=>{"use strict"});var bs=E(()=>{"use strict"});var gs=E(()=>{"use strict"});var ys=E(()=>{"use strict"});var Ld,Nn,Ts=E(()=>{"use strict";Cn();kn();Ld="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Nn=class a{constructor(t,o,e){this.handler=t,this.hasOptimizerModel=o,this.hasEvalModel=e}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(t,o){let e=t.evalModel||"",r=t.optimizerModel||"",n=o||{},[s,i]=await Fn(n);if(s.createTrainingSessionHandler){let u=await s.createTrainingSessionHandler(t.checkpointState,t.trainModel,e,r,i);return new a(u,!!t.optimizerModel,!!t.evalModel)}else throw new Error(Ld)}typeNarrowingForRunStep(t,o,e,r,n){let s={},i={};if(typeof e!="object"||e===null||e instanceof Re||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let u=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Re)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");u=!1;for(let l of r){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(o.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);s[l]=null}if(typeof n=="object"&&n!==null)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,f=Object.getOwnPropertyNames(r);for(let p of o)if(f.indexOf(p)!==-1){let d=r[p];(d===null||d instanceof Re)&&(l=!0,u=!1,s[p]=d)}if(l){if(typeof n=="object"&&n!==null)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else i=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let l of t)if(typeof e[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(u)for(let l of o)s[l]=null;return[s,i]}convertHandlerReturnTypeToMapOfTensors(t){let o={};for(let e in t)if(Object.hasOwnProperty.call(t,e)){let r=t[e];r instanceof Re?o[e]=r:o[e]=new Re(r.type,r.data,r.dims)}return o}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,o,e){let[r,n]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,o,e),s=await this.handler.runTrainStep(t,r,n);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(t){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(t||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(t,o,e){if(this.hasEvalModel){let[r,n]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,o,e),s=await this.handler.runEvalStep(t,r,n);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,o=!0){let e=await this.getParametersSize(o);if(t.length!==4*e)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(t,o)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}});var Fd,xs=E(()=>{"use strict";Ts();Fd=Nn});var Yo={};Pr(Yo,{InferenceSession:()=>Dd,TRACE:()=>cs,TRACE_FUNC_BEGIN:()=>sr,TRACE_FUNC_END:()=>ur,Tensor:()=>Re,TrainingSession:()=>Fd,env:()=>Z,registerBackend:()=>Dr});var Tt=E(()=>{"use strict";qa();Ka();hs();kn();ms();bs();jo();gs();ys();xs()});function jt(a,t,o,e){if(t===void 0)return $d(a);if(o===void 0)Rn(a,t,1);else if(typeof o=="number"&&e===void 0)Rn(a,t,o);else if(typeof o=="string"&&e===void 0)Rn(a,o,1,t);else if(typeof o=="string"&&typeof e=="number")Rn(a,o,e,t);else throw new TypeError("input is valid")}function $d(a){return{verbose:jt.verbose.bind(null,a),info:jt.info.bind(null,a),warning:jt.warning.bind(null,a),error:jt.error.bind(null,a),fatal:jt.fatal.bind(null,a)}}function Rn(a,t,o,e){let r=rn[e||""]||rn[""];vs[a]<vs[r.minimalSeverity]||(r.logDateTime&&(t=`${new Date().toISOString()}|${t}`),r.logSourceLocation,Cd[r.provider].log(a,t,e))}var Xo,Ko,vs,Cd,_s,rn,ce,Gn,Un,zn,Mn,at=E(()=>{"use strict";Xo=class{log(t,o,e){}},Ko=class{log(t,o,e){console.log(`${this.color(t)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${o}`)}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}`)}}},vs={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Cd={none:new Xo,console:new Ko},_s={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},rn={"":_s};(u=>{function a(l,f){u("verbose",l,f)}u.verbose=a;function t(l,f){u("info",l,f)}u.info=t;function o(l,f){u("warning",l,f)}u.warning=o;function e(l,f){u("error",l,f)}u.error=e;function r(l,f){u("fatal",l,f)}u.fatal=r;function n(l){rn={},s("",l||{})}u.reset=n;function s(l,f){if(l==="*")n(f);else{let p=rn[l]||_s;rn[l]={provider:f.provider||p.provider,minimalSeverity:f.minimalSeverity||p.minimalSeverity,logDateTime:f.logDateTime===void 0?p.logDateTime:f.logDateTime,logSourceLocation:f.logSourceLocation===void 0?p.logSourceLocation:f.logSourceLocation}}}u.set=s;function i(l){let f={};l.logLevel&&(f.minimalSeverity=l.logLevel),s("",f)}u.setWithEnv=i})(jt||={});ce=jt,Gn=class{constructor(t,o,e,r,n,s){this.category=t;this.name=o;this.startTime=e;this.endCallback=r;this.timer=n;this.ctx=s}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)}},Un=class{constructor(t,o,e,r){this.category=t;this.name=o;this.startTime=e;this.endTime=r}},zn=class{constructor(t,o,e){this._started=!1;this._flushPointer=0;this._started=!1,this._maxNumberEvents=t===void 0?1e4:t,this._flushBatchSize=o===void 0?10:o,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=Mn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,o,e,r){let n=this._started?this.begin(t,o,r):void 0,s=!1,i=e();if(i&&typeof i.then=="function")return s=!0,new Promise((u,l)=>{i.then(async f=>{n&&await n.end(),u(f)},async f=>{n&&await n.end(),l(f)})});if(!s&&n){let u=n.end();if(u&&typeof u.then=="function")return new Promise((l,f)=>{u.then(()=>{l(i)},p=>{f(p)})})}return i}begin(t,o,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){let r=Mn();return this.flush(r),new Gn(t,o,r,n=>this.endSync(n))}else{let r=e.beginTimer();return new Gn(t,o,0,async n=>this.end(n),r,e)}}async end(t){let o=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Un(t.category,t.name,t.startTime,o)),this.flush(o))}endSync(t){let o=Mn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Un(t.category,t.name,t.startTime,o)),this.flush(o))}logOneEvent(t){ce.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 o=this._flushPointer;this._flushPointer<o+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=Mn()}}get started(){return this._started}},Mn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Os(a,t,o){for(let e of o){let r=e[0],n=e[1],s=e[2],i=e[3],u=e[4];if(a.opType===r){for(let l of t)if((l.domain===n||l.domain==="ai.onnx"&&n==="")&&kd(l.version,s))return{opImpl:i,opInit:u}}}throw new TypeError(`cannot resolve operator '${a.opType}' with opsets: ${t.map(e=>`${e.domain||"ai.onnx"} v${e.version}`).join(", ")}`)}function kd(a,t){if(t.endsWith("+")){let o=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(o)&&o<=a}else if(t.split("-").length===2){let o=t.split("-"),e=Number.parseInt(o[0],10),r=Number.parseInt(o[1],10);return!isNaN(e)&&!isNaN(r)&&e<=a&&a<=r}else return Number.parseInt(t,10)===a}var Is=E(()=>{"use strict"});var Ss=me(Jo=>{"use strict";Jo.__esModule=!0;var Bd=function(){function a(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=a.EMPTY,t&&a.isGuid(t)&&(this.value=t)}return a.isGuid=function(t){var o=t.toString();return t&&(t instanceof a||a.validator.test(o))},a.create=function(){return new a([a.gen(2),a.gen(1),a.gen(1),a.gen(1),a.gen(3)].join("-"))},a.createEmpty=function(){return new a("emptyguid")},a.parse=function(t){return new a(t)},a.raw=function(){return[a.gen(2),a.gen(1),a.gen(1),a.gen(1),a.gen(3)].join("-")},a.gen=function(t){for(var o="",e=0;e<t;e++)o+=((1+Math.random())*65536|0).toString(16).substring(1);return o},a.prototype.equals=function(t){return a.isGuid(t)&&this.value===t.toString()},a.prototype.isEmpty=function(){return this.value===a.EMPTY},a.prototype.toString=function(){return this.value},a.prototype.toJSON=function(){return{value:this.value}},a.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),a.EMPTY="00000000-0000-0000-0000-000000000000",a}();Jo.Guid=Bd});function be(a,t,o){this.low=a|0,this.high=t|0,this.unsigned=!!o}function je(a){return(a&&a.__isLong__)===!0}function As(a){var t=Math.clz32(a&-a);return a?31-t:t}function lr(a,t){var o,e,r;return t?(a>>>=0,(r=0<=a&&a<256)&&(e=Es[a],e)?e:(o=le(a,0,!0),r&&(Es[a]=o),o)):(a|=0,(r=-128<=a&&a<128)&&(e=Ps[a],e)?e:(o=le(a,a<0?-1:0,!1),r&&(Ps[a]=o),o))}function ut(a,t){if(isNaN(a))return t?Vt:xt;if(t){if(a<0)return Vt;if(a>=Cs)return Bs}else{if(a<=-Ls)return tt;if(a+1>=Ls)return ks}return a<0?ut(-a,t).neg():le(a%Fr|0,a/Fr|0,t)}function le(a,t,o){return new be(a,t,o)}function Qo(a,t,o){if(a.length===0)throw Error("empty string");if(typeof t=="number"?(o=t,t=!1):t=!!t,a==="NaN"||a==="Infinity"||a==="+Infinity"||a==="-Infinity")return t?Vt:xt;if(o=o||10,o<2||36<o)throw RangeError("radix");var e;if((e=a.indexOf("-"))>0)throw Error("interior hyphen");if(e===0)return Qo(a.substring(1),t,o).neg();for(var r=ut(Vn(o,8)),n=xt,s=0;s<a.length;s+=8){var i=Math.min(8,a.length-s),u=parseInt(a.substring(s,s+i),o);if(i<8){var l=ut(Vn(o,i));n=n.mul(l).add(ut(u))}else n=n.mul(r),n=n.add(ut(u))}return n.unsigned=t,n}function wt(a,t){return typeof a=="number"?ut(a,t):typeof a=="string"?Qo(a,t):le(a.low,a.high,typeof t=="boolean"?t:a.unsigned)}var st,Ps,Es,Vn,Ds,Nd,Fr,Cs,Ls,Fs,xt,Vt,Lr,$s,Zo,ks,Bs,tt,$,Wt,ei=E(()=>{st=null;try{st=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{}be.prototype.__isLong__;Object.defineProperty(be.prototype,"__isLong__",{value:!0});be.isLong=je;Ps={},Es={};be.fromInt=lr;be.fromNumber=ut;be.fromBits=le;Vn=Math.pow;be.fromString=Qo;be.fromValue=wt;Ds=65536,Nd=1<<24,Fr=Ds*Ds,Cs=Fr*Fr,Ls=Cs/2,Fs=lr(Nd),xt=lr(0);be.ZERO=xt;Vt=lr(0,!0);be.UZERO=Vt;Lr=lr(1);be.ONE=Lr;$s=lr(1,!0);be.UONE=$s;Zo=lr(-1);be.NEG_ONE=Zo;ks=le(-1,2147483647,!1);be.MAX_VALUE=ks;Bs=le(-1,-1,!0);be.MAX_UNSIGNED_VALUE=Bs;tt=le(0,-2147483648,!1);be.MIN_VALUE=tt;$=be.prototype;$.toInt=function(){return this.unsigned?this.low>>>0:this.low};$.toNumber=function(){return this.unsigned?(this.high>>>0)*Fr+(this.low>>>0):this.high*Fr+(this.low>>>0)};$.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(tt)){var o=ut(t),e=this.div(o),r=e.mul(o).sub(this);return e.toString(t)+r.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var n=ut(Vn(t,6),this.unsigned),s=this,i="";;){var u=s.div(n),l=s.sub(u.mul(n)).toInt()>>>0,f=l.toString(t);if(s=u,s.isZero())return f+i;for(;f.length<6;)f="0"+f;i=""+f+i}};$.getHighBits=function(){return this.high};$.getHighBitsUnsigned=function(){return this.high>>>0};$.getLowBits=function(){return this.low};$.getLowBitsUnsigned=function(){return this.low>>>0};$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tt)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,o=31;o>0&&!(t&1<<o);o--);return this.high!=0?o+33:o+1};$.isZero=function(){return this.high===0&&this.low===0};$.eqz=$.isZero;$.isNegative=function(){return!this.unsigned&&this.high<0};$.isPositive=function(){return this.unsigned||this.high>=0};$.isOdd=function(){return(this.low&1)===1};$.isEven=function(){return(this.low&1)===0};$.equals=function(t){return je(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};$.eq=$.equals;$.notEquals=function(t){return!this.eq(t)};$.neq=$.notEquals;$.ne=$.notEquals;$.lessThan=function(t){return this.comp(t)<0};$.lt=$.lessThan;$.lessThanOrEqual=function(t){return this.comp(t)<=0};$.lte=$.lessThanOrEqual;$.le=$.lessThanOrEqual;$.greaterThan=function(t){return this.comp(t)>0};$.gt=$.greaterThan;$.greaterThanOrEqual=function(t){return this.comp(t)>=0};$.gte=$.greaterThanOrEqual;$.ge=$.greaterThanOrEqual;$.compare=function(t){if(je(t)||(t=wt(t)),this.eq(t))return 0;var o=this.isNegative(),e=t.isNegative();return o&&!e?-1:!o&&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};$.comp=$.compare;$.negate=function(){return!this.unsigned&&this.eq(tt)?tt:this.not().add(Lr)};$.neg=$.negate;$.add=function(t){je(t)||(t=wt(t));var o=this.high>>>16,e=this.high&65535,r=this.low>>>16,n=this.low&65535,s=t.high>>>16,i=t.high&65535,u=t.low>>>16,l=t.low&65535,f=0,p=0,d=0,T=0;return T+=n+l,d+=T>>>16,T&=65535,d+=r+u,p+=d>>>16,d&=65535,p+=e+i,f+=p>>>16,p&=65535,f+=o+s,f&=65535,le(d<<16|T,f<<16|p,this.unsigned)};$.subtract=function(t){return je(t)||(t=wt(t)),this.add(t.neg())};$.sub=$.subtract;$.multiply=function(t){if(this.isZero())return this;if(je(t)||(t=wt(t)),st){var o=st.mul(this.low,this.high,t.low,t.high);return le(o,st.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Vt:xt;if(this.eq(tt))return t.isOdd()?tt:xt;if(t.eq(tt))return this.isOdd()?tt:xt;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(Fs)&&t.lt(Fs))return ut(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,r=this.high&65535,n=this.low>>>16,s=this.low&65535,i=t.high>>>16,u=t.high&65535,l=t.low>>>16,f=t.low&65535,p=0,d=0,T=0,v=0;return v+=s*f,T+=v>>>16,v&=65535,T+=n*f,d+=T>>>16,T&=65535,T+=s*l,d+=T>>>16,T&=65535,d+=r*f,p+=d>>>16,d&=65535,d+=n*l,p+=d>>>16,d&=65535,d+=s*u,p+=d>>>16,d&=65535,p+=e*f+r*l+n*u+s*i,p&=65535,le(T<<16|v,p<<16|d,this.unsigned)};$.mul=$.multiply;$.divide=function(t){if(je(t)||(t=wt(t)),t.isZero())throw Error("division by zero");if(st){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var o=(this.unsigned?st.div_u:st.div_s)(this.low,this.high,t.low,t.high);return le(o,st.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Vt:xt;var e,r,n;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Vt;if(t.gt(this.shru(1)))return $s;n=Vt}else{if(this.eq(tt)){if(t.eq(Lr)||t.eq(Zo))return tt;if(t.eq(tt))return Lr;var s=this.shr(1);return e=s.div(t).shl(1),e.eq(xt)?t.isNegative()?Lr:Zo:(r=this.sub(t.mul(e)),n=e.add(r.div(t)),n)}else if(t.eq(tt))return this.unsigned?Vt:xt;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();n=xt}for(r=this;r.gte(t);){e=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var i=Math.ceil(Math.log(e)/Math.LN2),u=i<=48?1:Vn(2,i-48),l=ut(e),f=l.mul(t);f.isNegative()||f.gt(r);)e-=u,l=ut(e,this.unsigned),f=l.mul(t);l.isZero()&&(l=Lr),n=n.add(l),r=r.sub(f)}return n};$.div=$.divide;$.modulo=function(t){if(je(t)||(t=wt(t)),st){var o=(this.unsigned?st.rem_u:st.rem_s)(this.low,this.high,t.low,t.high);return le(o,st.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};$.mod=$.modulo;$.rem=$.modulo;$.not=function(){return le(~this.low,~this.high,this.unsigned)};$.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};$.clz=$.countLeadingZeros;$.countTrailingZeros=function(){return this.low?As(this.low):As(this.high)+32};$.ctz=$.countTrailingZeros;$.and=function(t){return je(t)||(t=wt(t)),le(this.low&t.low,this.high&t.high,this.unsigned)};$.or=function(t){return je(t)||(t=wt(t)),le(this.low|t.low,this.high|t.high,this.unsigned)};$.xor=function(t){return je(t)||(t=wt(t)),le(this.low^t.low,this.high^t.high,this.unsigned)};$.shiftLeft=function(t){return je(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?le(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):le(0,this.low<<t-32,this.unsigned)};$.shl=$.shiftLeft;$.shiftRight=function(t){return je(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?le(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):le(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};$.shr=$.shiftRight;$.shiftRightUnsigned=function(t){return je(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?le(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?le(this.high,0,this.unsigned):le(this.high>>>t-32,0,this.unsigned)};$.shru=$.shiftRightUnsigned;$.shr_u=$.shiftRightUnsigned;$.rotateLeft=function(t){var o;return je(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?le(this.high,this.low,this.unsigned):t<32?(o=32-t,le(this.low<<t|this.high>>>o,this.high<<t|this.low>>>o,this.unsigned)):(t-=32,o=32-t,le(this.high<<t|this.low>>>o,this.low<<t|this.high>>>o,this.unsigned))};$.rotl=$.rotateLeft;$.rotateRight=function(t){var o;return je(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?le(this.high,this.low,this.unsigned):t<32?(o=32-t,le(this.high<<o|this.low>>>t,this.low<<o|this.high>>>t,this.unsigned)):(t-=32,o=32-t,le(this.low<<o|this.high>>>t,this.high<<o|this.low>>>t,this.unsigned))};$.rotr=$.rotateRight;$.toSigned=function(){return this.unsigned?le(this.low,this.high,!1):this};$.toUnsigned=function(){return this.unsigned?this:le(this.low,this.high,!0)};$.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};$.toBytesLE=function(){var t=this.high,o=this.low;return[o&255,o>>>8&255,o>>>16&255,o>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};$.toBytesBE=function(){var t=this.high,o=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,o>>>24,o>>>16&255,o>>>8&255,o&255]};be.fromBytes=function(t,o,e){return e?be.fromBytesLE(t,o):be.fromBytesBE(t,o)};be.fromBytesLE=function(t,o){return new be(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,o)};be.fromBytesBE=function(t,o){return new be(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],o)};Wt=be});var O,Wn=E(()=>{O={};O.Offset;O.Table;O.SIZEOF_SHORT=2;O.SIZEOF_INT=4;O.FILE_IDENTIFIER_LENGTH=4;O.SIZE_PREFIX_LENGTH=4;O.Encoding={UTF8_BYTES:1,UTF16_STRING:2};O.int32=new Int32Array(2);O.float32=new Float32Array(O.int32.buffer);O.float64=new Float64Array(O.int32.buffer);O.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;O.Long=function(a,t){this.low=a|0,this.high=t|0};O.Long.create=function(a,t){return a==0&&t==0?O.Long.ZERO:new O.Long(a,t)};O.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296};O.Long.prototype.equals=function(a){return this.low==a.low&&this.high==a.high};O.Long.ZERO=new O.Long(0,0);O.Builder=function(a){if(a)var t=a;else var t=1024;this.bb=O.ByteBuffer.allocate(t),this.space=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};O.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1};O.Builder.prototype.forceDefaults=function(a){this.force_defaults=a};O.Builder.prototype.dataBuffer=function(){return this.bb};O.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())};O.Builder.prototype.prep=function(a,t){a>this.minalign&&(this.minalign=a);for(var o=~(this.bb.capacity()-this.space+t)+1&a-1;this.space<o+a+t;){var e=this.bb.capacity();this.bb=O.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-e}this.pad(o)};O.Builder.prototype.pad=function(a){for(var t=0;t<a;t++)this.bb.writeInt8(--this.space,0)};O.Builder.prototype.writeInt8=function(a){this.bb.writeInt8(this.space-=1,a)};O.Builder.prototype.writeInt16=function(a){this.bb.writeInt16(this.space-=2,a)};O.Builder.prototype.writeInt32=function(a){this.bb.writeInt32(this.space-=4,a)};O.Builder.prototype.writeInt64=function(a){this.bb.writeInt64(this.space-=8,a)};O.Builder.prototype.writeFloat32=function(a){this.bb.writeFloat32(this.space-=4,a)};O.Builder.prototype.writeFloat64=function(a){this.bb.writeFloat64(this.space-=8,a)};O.Builder.prototype.addInt8=function(a){this.prep(1,0),this.writeInt8(a)};O.Builder.prototype.addInt16=function(a){this.prep(2,0),this.writeInt16(a)};O.Builder.prototype.addInt32=function(a){this.prep(4,0),this.writeInt32(a)};O.Builder.prototype.addInt64=function(a){this.prep(8,0),this.writeInt64(a)};O.Builder.prototype.addFloat32=function(a){this.prep(4,0),this.writeFloat32(a)};O.Builder.prototype.addFloat64=function(a){this.prep(8,0),this.writeFloat64(a)};O.Builder.prototype.addFieldInt8=function(a,t,o){(this.force_defaults||t!=o)&&(this.addInt8(t),this.slot(a))};O.Builder.prototype.addFieldInt16=function(a,t,o){(this.force_defaults||t!=o)&&(this.addInt16(t),this.slot(a))};O.Builder.prototype.addFieldInt32=function(a,t,o){(this.force_defaults||t!=o)&&(this.addInt32(t),this.slot(a))};O.Builder.prototype.addFieldInt64=function(a,t,o){(this.force_defaults||!t.equals(o))&&(this.addInt64(t),this.slot(a))};O.Builder.prototype.addFieldFloat32=function(a,t,o){(this.force_defaults||t!=o)&&(this.addFloat32(t),this.slot(a))};O.Builder.prototype.addFieldFloat64=function(a,t,o){(this.force_defaults||t!=o)&&(this.addFloat64(t),this.slot(a))};O.Builder.prototype.addFieldOffset=function(a,t,o){(this.force_defaults||t!=o)&&(this.addOffset(t),this.slot(a))};O.Builder.prototype.addFieldStruct=function(a,t,o){t!=o&&(this.nested(t),this.slot(a))};O.Builder.prototype.nested=function(a){if(a!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")};O.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")};O.Builder.prototype.slot=function(a){this.vtable[a]=this.offset()};O.Builder.prototype.offset=function(){return this.bb.capacity()-this.space};O.Builder.growByteBuffer=function(a){var t=a.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var o=t<<1,e=O.ByteBuffer.allocate(o);return e.setPosition(o-t),e.bytes().set(a.bytes(),o-t),e};O.Builder.prototype.addOffset=function(a){this.prep(O.SIZEOF_INT,0),this.writeInt32(this.offset()-a+O.SIZEOF_INT)};O.Builder.prototype.startObject=function(a){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=a;for(var t=0;t<a;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()};O.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var a=this.offset(),t=this.vtable_in_use-1;t>=0&&this.vtable[t]==0;t--);for(var o=t+1;t>=0;t--)this.addInt16(this.vtable[t]!=0?a-this.vtable[t]:0);var e=2;this.addInt16(a-this.object_start);var r=(o+e)*O.SIZEOF_SHORT;this.addInt16(r);var n=0,s=this.space;e:for(t=0;t<this.vtables.length;t++){var i=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(i)){for(var u=O.SIZEOF_SHORT;u<r;u+=O.SIZEOF_SHORT)if(this.bb.readInt16(s+u)!=this.bb.readInt16(i+u))continue e;n=this.vtables[t];break}}return n?(this.space=this.bb.capacity()-a,this.bb.writeInt32(this.space,n-a)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-a,this.offset()-a)),this.isNested=!1,a};O.Builder.prototype.finish=function(a,t,o){var e=o?O.SIZE_PREFIX_LENGTH:0;if(t){var r=t;if(this.prep(this.minalign,O.SIZEOF_INT+O.FILE_IDENTIFIER_LENGTH+e),r.length!=O.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+O.FILE_IDENTIFIER_LENGTH);for(var n=O.FILE_IDENTIFIER_LENGTH-1;n>=0;n--)this.writeInt8(r.charCodeAt(n))}this.prep(this.minalign,O.SIZEOF_INT+e),this.addOffset(a),e&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)};O.Builder.prototype.finishSizePrefixed=function(a,t){this.finish(a,t,!0)};O.Builder.prototype.requiredField=function(a,t){var o=this.bb.capacity()-a,e=o-this.bb.readInt32(o),r=this.bb.readInt16(e+t)!=0;if(!r)throw new Error("FlatBuffers: field "+t+" must be set")};O.Builder.prototype.startVector=function(a,t,o){this.notNested(),this.vector_num_elems=t,this.prep(O.SIZEOF_INT,a*t),this.prep(o,a*t)};O.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()};O.Builder.prototype.createString=function(a){if(a instanceof Uint8Array)var t=a;else for(var t=[],o=0;o<a.length;){var e,r=a.charCodeAt(o++);if(r<55296||r>=56320)e=r;else{var n=a.charCodeAt(o++);e=(r<<10)+n+(65536-56623104-56320)}e<128?t.push(e):(e<2048?t.push(e>>6&31|192):(e<65536?t.push(e>>12&15|224):t.push(e>>18&7|240,e>>12&63|128),t.push(e>>6&63|128)),t.push(e&63|128))}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(var o=0,s=this.space,i=this.bb.bytes();o<t.length;o++)i[s++]=t[o];return this.endVector()};O.Builder.prototype.createLong=function(a,t){return O.Long.create(a,t)};O.ByteBuffer=function(a){this.bytes_=a,this.position_=0};O.ByteBuffer.allocate=function(a){return new O.ByteBuffer(new Uint8Array(a))};O.ByteBuffer.prototype.clear=function(){this.position_=0};O.ByteBuffer.prototype.bytes=function(){return this.bytes_};O.ByteBuffer.prototype.position=function(){return this.position_};O.ByteBuffer.prototype.setPosition=function(a){this.position_=a};O.ByteBuffer.prototype.capacity=function(){return this.bytes_.length};O.ByteBuffer.prototype.readInt8=function(a){return this.readUint8(a)<<24>>24};O.ByteBuffer.prototype.readUint8=function(a){return this.bytes_[a]};O.ByteBuffer.prototype.readInt16=function(a){return this.readUint16(a)<<16>>16};O.ByteBuffer.prototype.readUint16=function(a){return this.bytes_[a]|this.bytes_[a+1]<<8};O.ByteBuffer.prototype.readInt32=function(a){return this.bytes_[a]|this.bytes_[a+1]<<8|this.bytes_[a+2]<<16|this.bytes_[a+3]<<24};O.ByteBuffer.prototype.readUint32=function(a){return this.readInt32(a)>>>0};O.ByteBuffer.prototype.readInt64=function(a){return new O.Long(this.readInt32(a),this.readInt32(a+4))};O.ByteBuffer.prototype.readUint64=function(a){return new O.Long(this.readUint32(a),this.readUint32(a+4))};O.ByteBuffer.prototype.readFloat32=function(a){return O.int32[0]=this.readInt32(a),O.float32[0]};O.ByteBuffer.prototype.readFloat64=function(a){return O.int32[O.isLittleEndian?0:1]=this.readInt32(a),O.int32[O.isLittleEndian?1:0]=this.readInt32(a+4),O.float64[0]};O.ByteBuffer.prototype.writeInt8=function(a,t){this.bytes_[a]=t};O.ByteBuffer.prototype.writeUint8=function(a,t){this.bytes_[a]=t};O.ByteBuffer.prototype.writeInt16=function(a,t){this.bytes_[a]=t,this.bytes_[a+1]=t>>8};O.ByteBuffer.prototype.writeUint16=function(a,t){this.bytes_[a]=t,this.bytes_[a+1]=t>>8};O.ByteBuffer.prototype.writeInt32=function(a,t){this.bytes_[a]=t,this.bytes_[a+1]=t>>8,this.bytes_[a+2]=t>>16,this.bytes_[a+3]=t>>24};O.ByteBuffer.prototype.writeUint32=function(a,t){this.bytes_[a]=t,this.bytes_[a+1]=t>>8,this.bytes_[a+2]=t>>16,this.bytes_[a+3]=t>>24};O.ByteBuffer.prototype.writeInt64=function(a,t){this.writeInt32(a,t.low),this.writeInt32(a+4,t.high)};O.ByteBuffer.prototype.writeUint64=function(a,t){this.writeUint32(a,t.low),this.writeUint32(a+4,t.high)};O.ByteBuffer.prototype.writeFloat32=function(a,t){O.float32[0]=t,this.writeInt32(a,O.int32[0])};O.ByteBuffer.prototype.writeFloat64=function(a,t){O.float64[0]=t,this.writeInt32(a,O.int32[O.isLittleEndian?0:1]),this.writeInt32(a+4,O.int32[O.isLittleEndian?1:0])};O.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+O.SIZEOF_INT+O.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var a="",t=0;t<O.FILE_IDENTIFIER_LENGTH;t++)a+=String.fromCharCode(this.readInt8(this.position_+O.SIZEOF_INT+t));return a};O.ByteBuffer.prototype.__offset=function(a,t){var o=a-this.readInt32(a);return t<this.readInt16(o)?this.readInt16(o+t):0};O.ByteBuffer.prototype.__union=function(a,t){return a.bb_pos=t+this.readInt32(t),a.bb=this,a};O.ByteBuffer.prototype.__string=function(a,t){a+=this.readInt32(a);var o=this.readInt32(a),e="",r=0;if(a+=O.SIZEOF_INT,t===O.Encoding.UTF8_BYTES)return this.bytes_.subarray(a,a+o);for(;r<o;){var n,s=this.readUint8(a+r++);if(s<192)n=s;else{var i=this.readUint8(a+r++);if(s<224)n=(s&31)<<6|i&63;else{var u=this.readUint8(a+r++);if(s<240)n=(s&15)<<12|(i&63)<<6|u&63;else{var l=this.readUint8(a+r++);n=(s&7)<<18|(i&63)<<12|(u&63)<<6|l&63}}}n<65536?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode((n>>10)+55296,(n&1024-1)+56320))}return e};O.ByteBuffer.prototype.__indirect=function(a){return a+this.readInt32(a)};O.ByteBuffer.prototype.__vector=function(a){return a+this.readInt32(a)+O.SIZEOF_INT};O.ByteBuffer.prototype.__vector_len=function(a){