dicomweb-proxy
Version:
A proxy to translate between dicomweb and dimse
2 lines • 2.91 MB
JavaScript
/*! For license information please see ort.all.js.LICENSE.txt */
"use strict";var ort=(()=>{var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__esm=(t,e)=>function(){return t&&(e=(0,t[__getOwnPropNames(t)[0]])(t=0)),e},__commonJS=(t,e)=>function(){return e||(0,t[__getOwnPropNames(t)[0]])((e={exports:{}}).exports,e),e.exports},__export=(t,e)=>{for(var n in e)__defProp(t,n,{get:e[n],enumerable:!0})},__copyProps=(t,e,n,B)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let s of __getOwnPropNames(e))__hasOwnProp.call(t,s)||s===n||__defProp(t,s,{get:()=>e[s],enumerable:!(B=__getOwnPropDesc(e,s))||B.enumerable});return t},__toESM=(t,e,n)=>(n=null!=t?__create(__getProtoOf(t)):{},__copyProps(!e&&t&&t.__esModule?n:__defProp(n,"default",{value:t,enumerable:!0}),t)),__toCommonJS=t=>__copyProps(__defProp({},"__esModule",{value:!0}),t),backends,backendsSortedByPriority,registerBackend,resolveBackend,init_backend_impl=__esm({"common/dist/esm/backend-impl.js"(){backends=new Map,backendsSortedByPriority=[],registerBackend=(t,e,n)=>{if(!e||"function"!=typeof e.init||"function"!=typeof e.createInferenceSessionHandler)throw new TypeError("not a valid backend");{const B=backends.get(t);if(void 0===B)backends.set(t,{backend:e,priority:n});else{if(B.priority>n)return;if(B.priority===n&&B.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){const e=backendsSortedByPriority.indexOf(t);-1!==e&&backendsSortedByPriority.splice(e,1);for(let e=0;e<backendsSortedByPriority.length;e++)if(backends.get(backendsSortedByPriority[e]).priority<=n)return void backendsSortedByPriority.splice(e,0,t);backendsSortedByPriority.push(t)}}},resolveBackend=async t=>{const e=0===t.length?backendsSortedByPriority:t,n=[];for(const t of e){const e=backends.get(t);if(e){if(e.initialized)return e.backend;if(e.aborted)continue;const B=!!e.initPromise;try{return B||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(s){B||n.push({name:t,err:s}),e.aborted=!0}finally{delete e.initPromise}}}throw new Error(`no available backend found. ERR: ${n.map((t=>`[${t.name}] ${t.err}`)).join(", ")}`)}}}),init_backend=__esm({"common/dist/esm/backend.js"(){init_backend_impl()}}),version,init_version=__esm({"common/dist/esm/version.js"(){version="1.17.1"}}),logLevelValue,env,init_env_impl=__esm({"common/dist/esm/env-impl.js"(){init_version(),logLevelValue="warning",env={wasm:{},webgl:{},webgpu:{},versions:{common:version},set logLevel(t){if(void 0!==t){if("string"!=typeof t||-1===["verbose","info","warning","error","fatal"].indexOf(t))throw new Error(`Unsupported logging level: ${t}`);logLevelValue=t}},get logLevel(){return logLevelValue}},Object.defineProperty(env,"logLevel",{enumerable:!0})}}),env2,init_env=__esm({"common/dist/esm/env.js"(){init_env_impl(),env2=env}}),tensorToDataURL,tensorToImageData,init_tensor_conversion_impl=__esm({"common/dist/esm/tensor-conversion-impl.js"(){tensorToDataURL=(t,e)=>{const n="undefined"!=typeof document?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];const B=n.getContext("2d");if(null!=B){let s,F;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(s=t.dims[2],F=t.dims[3]):(s=t.dims[3],F=t.dims[2]);const Q=void 0!==e?.format?e.format:"RGB",U=e?.norm;let i,a;void 0===U||void 0===U.mean?i=[255,255,255,255]:"number"==typeof U.mean?i=[U.mean,U.mean,U.mean,U.mean]:(i=[U.mean[0],U.mean[1],U.mean[2],0],void 0!==U.mean[3]&&(i[3]=U.mean[3])),void 0===U||void 0===U.bias?a=[0,0,0,0]:"number"==typeof U.bias?a=[U.bias,U.bias,U.bias,U.bias]:(a=[U.bias[0],U.bias[1],U.bias[2],0],void 0!==U.bias[3]&&(a[3]=U.bias[3]));const l=F*s;let c=0,g=l,d=2*l,I=-1;"RGBA"===Q?(c=0,g=l,d=2*l,I=3*l):"RGB"===Q?(c=0,g=l,d=2*l):"RBG"===Q&&(c=0,d=l,g=2*l);for(let e=0;e<F;e++)for(let n=0;n<s;n++){const s=(t.data[c++]-a[0])*i[0],F=(t.data[g++]-a[1])*i[1],Q=(t.data[d++]-a[2])*i[2],U=-1===I?255:(t.data[I++]-a[3])*i[3];B.fillStyle="rgba("+s+","+F+","+Q+","+U+")",B.fillRect(n,e,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},tensorToImageData=(t,e)=>{const n="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");let B;if(null==n)throw new Error("Can not access image data");{let s,F,Q;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(s=t.dims[2],F=t.dims[1],Q=t.dims[3]):(s=t.dims[3],F=t.dims[2],Q=t.dims[1]);const U=void 0!==e&&void 0!==e.format?e.format:"RGB",i=e?.norm;let a,l;void 0===i||void 0===i.mean?a=[255,255,255,255]:"number"==typeof i.mean?a=[i.mean,i.mean,i.mean,i.mean]:(a=[i.mean[0],i.mean[1],i.mean[2],255],void 0!==i.mean[3]&&(a[3]=i.mean[3])),void 0===i||void 0===i.bias?l=[0,0,0,0]:"number"==typeof i.bias?l=[i.bias,i.bias,i.bias,i.bias]:(l=[i.bias[0],i.bias[1],i.bias[2],0],void 0!==i.bias[3]&&(l[3]=i.bias[3]));const c=F*s;if(void 0!==e&&(void 0!==e.format&&4===Q&&"RGBA"!==e.format||3===Q&&"RGB"!==e.format&&"BGR"!==e.format))throw new Error("Tensor format doesn't match input tensor dims");const g=4;let d=0,I=1,o=2,r=3,u=0,b=c,C=2*c,p=-1;"RGBA"===U?(u=0,b=c,C=2*c,p=3*c):"RGB"===U?(u=0,b=c,C=2*c):"RBG"===U&&(u=0,C=c,b=2*c),B=n.createImageData(s,F);for(let e=0;e<F*s;d+=g,I+=g,o+=g,r+=g,e++)B.data[d]=(t.data[u++]-l[0])*a[0],B.data[I]=(t.data[b++]-l[1])*a[1],B.data[o]=(t.data[C++]-l[2])*a[2],B.data[r]=-1===p?255:(t.data[p++]-l[3])*a[3]}return B}}}),bufferToTensor,tensorFromImage,tensorFromTexture,tensorFromGpuBuffer,tensorFromPinnedBuffer,init_tensor_factory_impl=__esm({"common/dist/esm/tensor-factory-impl.js"(){init_tensor_impl(),bufferToTensor=(t,e)=>{if(void 0===t)throw new Error("Image buffer must be defined");if(void 0===e.height||void 0===e.width)throw new Error("Image height and width must be defined");if("NHWC"===e.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");const{height:n,width:B}=e,s=e.norm??{mean:255,bias:0};let F,Q;F="number"==typeof s.mean?[s.mean,s.mean,s.mean,s.mean]:[s.mean[0],s.mean[1],s.mean[2],s.mean[3]??255],Q="number"==typeof s.bias?[s.bias,s.bias,s.bias,s.bias]:[s.bias[0],s.bias[1],s.bias[2],s.bias[3]??0];const U=void 0!==e.format?e.format:"RGBA",i=void 0!==e.tensorFormat&&void 0!==e.tensorFormat?e.tensorFormat:"RGB",a=n*B,l="RGBA"===i?new Float32Array(4*a):new Float32Array(3*a);let c=4,g=0,d=1,I=2,o=3,r=0,u=a,b=2*a,C=-1;"RGB"===U&&(c=3,g=0,d=1,I=2,o=-1),"RGBA"===i?C=3*a:"RBG"===i?(r=0,b=a,u=2*a):"BGR"===i&&(b=0,u=a,r=2*a);for(let e=0;e<a;e++,g+=c,I+=c,d+=c,o+=c)l[r++]=(t[g]+Q[0])/F[0],l[u++]=(t[d]+Q[1])/F[1],l[b++]=(t[I]+Q[2])/F[2],-1!==C&&-1!==o&&(l[C++]=(t[o]+Q[3])/F[3]);return new Tensor("float32",l,"RGBA"===i?[1,4,n,B]:[1,3,n,B])},tensorFromImage=async(t,e)=>{const n="undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement,B="undefined"!=typeof ImageData&&t instanceof ImageData,s="undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap,F="string"==typeof t;let Q,U=e??{};const i=()=>{if("undefined"!=typeof document)return document.createElement("canvas");if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},a=t=>t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas?t.getContext("2d"):null;if(n){const n=i();n.width=t.width,n.height=t.height;const B=a(n);if(null==B)throw new Error("Can not access image data");{let n=t.height,s=t.width;if(void 0!==e&&void 0!==e.resizedHeight&&void 0!==e.resizedWidth&&(n=e.resizedHeight,s=e.resizedWidth),void 0!==e){if(U=e,void 0!==e.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");U.tensorFormat="RGBA",U.height=n,U.width=s}else U.tensorFormat="RGBA",U.height=n,U.width=s;B.drawImage(t,0,0),Q=B.getImageData(0,0,s,n).data}}else{if(!B){if(s){if(void 0===e)throw new Error("Please provide image config with format for Imagebitmap");const n=i();n.width=t.width,n.height=t.height;const B=a(n);if(null!=B){const e=t.height,n=t.width;return B.drawImage(t,0,0,n,e),Q=B.getImageData(0,0,n,e).data,U.height=e,U.width=n,bufferToTensor(Q,U)}throw new Error("Can not access image data")}if(F)return new Promise(((e,n)=>{const B=i(),s=a(B);if(!t||!s)return n();const F=new Image;F.crossOrigin="Anonymous",F.src=t,F.onload=()=>{B.width=F.width,B.height=F.height,s.drawImage(F,0,0,B.width,B.height);const t=s.getImageData(0,0,B.width,B.height);U.height=B.height,U.width=B.width,e(bufferToTensor(t.data,U))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let n,B;if(void 0!==e&&void 0!==e.resizedWidth&&void 0!==e.resizedHeight?(n=e.resizedHeight,B=e.resizedWidth):(n=t.height,B=t.width),void 0!==e&&(U=e),U.format="RGBA",U.height=n,U.width=B,void 0!==e){const e=i();e.width=B,e.height=n;const s=a(e);if(null==s)throw new Error("Can not access image data");s.putImageData(t,0,0),Q=s.getImageData(0,0,B,n).data}else Q=t.data}}if(void 0!==Q)return bufferToTensor(Q,U);throw new Error("Input data provided is not supported - aborted tensor creation")},tensorFromTexture=(t,e)=>{const{width:n,height:B,download:s,dispose:F}=e;return new Tensor({location:"texture",type:"float32",texture:t,dims:[1,B,n,4],download:s,dispose:F})},tensorFromGpuBuffer=(t,e)=>{const{dataType:n,dims:B,download:s,dispose:F}=e;return new Tensor({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:B,download:s,dispose:F})},tensorFromPinnedBuffer=(t,e,n)=>new Tensor({location:"cpu-pinned",type:t,data:e,dims:n??[e.length]})}}),NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP,NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP,isBigIntChecked,checkBigInt,init_tensor_impl_type_mapping=__esm({"common/dist/esm/tensor-impl-type-mapping.js"(){NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),isBigIntChecked=!1,checkBigInt=()=>{if(!isBigIntChecked){isBigIntChecked=!0;const t="undefined"!=typeof BigInt64Array&&"function"==typeof BigInt64Array.from,e="undefined"!=typeof BigUint64Array&&"function"==typeof BigUint64Array.from;t&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64")),e&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64"))}}}}),calculateSize,tensorReshape,init_tensor_utils_impl=__esm({"common/dist/esm/tensor-utils-impl.js"(){init_tensor_impl(),calculateSize=t=>{let e=1;for(let n=0;n<t.length;n++){const B=t[n];if("number"!=typeof B||!Number.isSafeInteger(B))throw new TypeError(`dims[${n}] must be an integer, got: ${B}`);if(B<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${B}`);e*=B}return e},tensorReshape=(t,e)=>{switch(t.location){case"cpu":return new Tensor(t.type,t.data,e);case"cpu-pinned":return new Tensor({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new Tensor({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new Tensor({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}}),Tensor,init_tensor_impl=__esm({"common/dist/esm/tensor-impl.js"(){init_tensor_conversion_impl(),init_tensor_factory_impl(),init_tensor_impl_type_mapping(),init_tensor_utils_impl(),Tensor=class{constructor(t,e,n){let B,s;if(checkBigInt(),"object"==typeof t&&"location"in t)switch(this.dataLocation=t.location,B=t.type,s=t.dims,t.location){case"cpu-pinned":{const e=NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(B);if(!e)throw new TypeError(`unsupported type "${B}" to create tensor from pinned buffer`);if(!(t.data instanceof e))throw new TypeError(`buffer should be of type ${e.name}`);this.cpuData=t.data;break}case"texture":if("float32"!==B)throw new TypeError(`unsupported type "${B}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break;case"gpu-buffer":if("float32"!==B&&"float16"!==B&&"int32"!==B&&"int64"!==B&&"uint32"!==B&&"bool"!==B)throw new TypeError(`unsupported type "${B}" 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 F,Q;if("string"==typeof t)if(B=t,Q=n,"string"===t){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");F=e}else{const n=NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(t);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if("float16"===t)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");F="uint64"===t||"int64"===t?n.from(e,BigInt):n.from(e)}else{if(!(e instanceof n))throw new TypeError(`A ${B} tensor's data must be type of ${n}`);F=e}}else if(Q=e,Array.isArray(t)){if(0===t.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");const e=typeof t[0];if("string"===e)B="string",F=t;else{if("boolean"!==e)throw new TypeError(`Invalid element type of data array: ${e}.`);B="bool",F=Uint8Array.from(t)}}else{const e=NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(t.constructor);if(void 0===e)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);B=e,F=t}if(void 0===Q)Q=[F.length];else if(!Array.isArray(Q))throw new TypeError("A tensor's dims must be a number array");s=Q,this.cpuData=F,this.dataLocation="cpu"}const F=calculateSize(s);if(this.cpuData&&F!==this.cpuData.length)throw new Error(`Tensor's size(${F}) does not match data length(${this.cpuData.length}).`);this.type=B,this.dims=s,this.size=F}static async fromImage(t,e){return tensorFromImage(t,e)}static fromTexture(t,e){return tensorFromTexture(t,e)}static fromGpuBuffer(t,e){return tensorFromGpuBuffer(t,e)}static fromPinnedBuffer(t,e,n){return tensorFromPinnedBuffer(t,e,n)}toDataURL(t){return tensorToDataURL(this,t)}toImageData(t){return tensorToImageData(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;const e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}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("none"===this.dataLocation)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 tensorReshape(this,t)}}}}),Tensor2,init_tensor=__esm({"common/dist/esm/tensor.js"(){init_tensor_impl(),Tensor2=Tensor}}),TRACE,TRACE_FUNC,TRACE_FUNC_BEGIN,TRACE_FUNC_END,init_trace=__esm({"common/dist/esm/trace.js"(){init_env_impl(),TRACE=(t,e)=>{env.wasm.trace&&console.timeStamp(`${t}::ORT::${e}`)},TRACE_FUNC=(t,e)=>{const n=(new Error).stack?.split(/\r\n|\r|\n/g)||[];let B=!1;for(let s=0;s<n.length;s++){if(B&&!n[s].includes("TRACE_FUNC")){let B=`FUNC_${t}::${n[s].trim().split(" ")[1]}`;return e&&(B+=`::${e}`),void TRACE("CPU",B)}n[s].includes("TRACE_FUNC")&&(B=!0)}},TRACE_FUNC_BEGIN=t=>{env.wasm.trace&&TRACE_FUNC("BEGIN",t)},TRACE_FUNC_END=t=>{env.wasm.trace&&TRACE_FUNC("END",t)}}}),InferenceSession,init_inference_session_impl=__esm({"common/dist/esm/inference-session-impl.js"(){init_backend_impl(),init_tensor(),init_trace(),InferenceSession=class t{constructor(t){this.handler=t}async run(t,e,n){TRACE_FUNC_BEGIN();const B={};let s={};if("object"!=typeof t||null===t||t instanceof Tensor2||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let F=!0;if("object"==typeof e){if(null===e)throw new TypeError("Unexpected argument[1]: cannot be null.");if(e instanceof Tensor2)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(e)){if(0===e.length)throw new TypeError("'fetches' cannot be an empty array.");F=!1;for(const t of e){if("string"!=typeof t)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(t))throw new RangeError(`'fetches' contains invalid output name: ${t}.`);B[t]=null}if("object"==typeof n&&null!==n)s=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else{let t=!1;const Q=Object.getOwnPropertyNames(e);for(const n of this.outputNames)if(-1!==Q.indexOf(n)){const s=e[n];(null===s||s instanceof Tensor2)&&(t=!0,F=!1,B[n]=s)}if(t){if("object"==typeof n&&null!==n)s=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else s=e}}else if(void 0!==e)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const e of this.inputNames)if(void 0===t[e])throw new Error(`input '${e}' is missing in 'feeds'.`);if(F)for(const t of this.outputNames)B[t]=null;const Q=await this.handler.run(t,B,s),U={};for(const t in Q)if(Object.hasOwnProperty.call(Q,t)){const e=Q[t];U[t]=e instanceof Tensor2?e:new Tensor2(e.type,e.data,e.dims)}return TRACE_FUNC_END(),U}async release(){return this.handler.dispose()}static async create(e,n,B,s){let F;TRACE_FUNC_BEGIN();let Q={};if("string"==typeof e){if(F=e,"object"==typeof n&&null!==n)Q=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(F=e,"object"==typeof n&&null!==n)Q=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else{if(!(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{const t=e;let U=0,i=e.byteLength;if("object"==typeof n&&null!==n)Q=n;else if("number"==typeof n){if(U=n,!Number.isSafeInteger(U))throw new RangeError("'byteOffset' must be an integer.");if(U<0||U>=t.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(i=e.byteLength-U,"number"==typeof B){if(i=B,!Number.isSafeInteger(i))throw new RangeError("'byteLength' must be an integer.");if(i<=0||U+i>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-U}].`);if("object"==typeof s&&null!==s)Q=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else if(void 0!==B)throw new TypeError("'byteLength' must be a number.")}else if(void 0!==n)throw new TypeError("'options' must be an object.");F=new Uint8Array(t,U,i)}}const U=(Q.executionProviders||[]).map((t=>"string"==typeof t?t:t.name)),i=await resolveBackend(U),a=await i.createInferenceSessionHandler(F,Q);return TRACE_FUNC_END(),new t(a)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}}),InferenceSession2,init_inference_session=__esm({"common/dist/esm/inference-session.js"(){init_inference_session_impl(),InferenceSession2=InferenceSession}}),init_onnx_value=__esm({"common/dist/esm/onnx-value.js"(){}}),noBackendErrMsg,TrainingSession,init_training_session_impl=__esm({"common/dist/esm/training-session-impl.js"(){init_backend_impl(),init_tensor(),noBackendErrMsg="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",TrainingSession=class t{constructor(t,e,n){this.handler=t,this.hasOptimizerModel=e,this.hasEvalModel=n}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(e,n){const B=e.evalModel||"",s=e.optimizerModel||"",F=n||{},Q=(F.executionProviders||[]).map((t=>"string"==typeof t?t:t.name)),U=await resolveBackend(Q);if(U.createTrainingSessionHandler){const n=await U.createTrainingSessionHandler(e.checkpointState,e.trainModel,B,s,F);return new t(n,!!e.optimizerModel,!!e.evalModel)}throw new Error(noBackendErrMsg)}typeNarrowingForRunStep(t,e,n,B,s){const F={};let Q={};if("object"!=typeof n||null===n||n instanceof Tensor2||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let U=!0;if("object"==typeof B){if(null===B)throw new TypeError("Unexpected argument[1]: cannot be null.");if(B instanceof Tensor2)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(B)){if(0===B.length)throw new TypeError("'fetches' cannot be an empty array.");U=!1;for(const t of B){if("string"!=typeof t)throw new TypeError("'fetches' must be a string array or an object.");if(-1===e.indexOf(t))throw new RangeError(`'fetches' contains invalid output name: ${t}.`);F[t]=null}if("object"==typeof s&&null!==s)Q=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else{let t=!1;const n=Object.getOwnPropertyNames(B);for(const s of e)if(-1!==n.indexOf(s)){const e=B[s];(null===e||e instanceof Tensor2)&&(t=!0,U=!1,F[s]=e)}if(t){if("object"==typeof s&&null!==s)Q=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else Q=B}}else if(void 0!==B)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const e of t)if(void 0===n[e])throw new Error(`input '${e}' is missing in 'feeds'.`);if(U)for(const t of e)F[t]=null;return[F,Q]}convertHandlerReturnTypeToMapOfTensors(t){const e={};for(const n in t)if(Object.hasOwnProperty.call(t,n)){const B=t[n];e[n]=B instanceof Tensor2?B:new Tensor2(B.type,B.data,B.dims)}return e}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,e,n){const[B,s]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,e,n),F=await this.handler.runTrainStep(t,B,s);return this.convertHandlerReturnTypeToMapOfTensors(F)}async runOptimizerStep(t){if(!this.hasOptimizerModel)throw new Error("This TrainingSession has no OptimizerModel loaded.");await this.handler.runOptimizerStep(t||{})}async runEvalStep(t,e,n){if(this.hasEvalModel){const[B,s]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,e,n),F=await this.handler.runEvalStep(t,B,s);return this.convertHandlerReturnTypeToMapOfTensors(F)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,e=!0){const n=await this.getParametersSize(e);if(t.length!==4*n)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,e)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}}}),TrainingSession2,init_training_session=__esm({"common/dist/esm/training-session.js"(){init_training_session_impl(),TrainingSession2=TrainingSession}}),esm_exports={};__export(esm_exports,{InferenceSession:()=>InferenceSession2,TRACE:()=>TRACE,TRACE_FUNC_BEGIN:()=>TRACE_FUNC_BEGIN,TRACE_FUNC_END:()=>TRACE_FUNC_END,Tensor:()=>Tensor2,TrainingSession:()=>TrainingSession2,env:()=>env2,registerBackend:()=>registerBackend});var init_esm=__esm({"common/dist/esm/index.js"(){init_backend(),init_env(),init_inference_session(),init_tensor(),init_trace(),init_onnx_value(),init_training_session()}}),readFile,init_promises=__esm({"nodejs-ignore:node:fs/promises"(){readFile=void 0}}),NoOpLoggerProvider,ConsoleLoggerProvider,SEVERITY_VALUE,LOGGER_PROVIDER_MAP,LOGGER_DEFAULT_CONFIG,LOGGER_CONFIG_MAP,Logger,Event,EventRecord,Profiler,now;function log(t,e,n,B){if(void 0===e)return createCategorizedLogger(t);if(void 0===n)logInternal(t,e,1);else if("number"==typeof n&&void 0===B)logInternal(t,e,n);else if("string"==typeof n&&void 0===B)logInternal(t,n,1,e);else{if("string"!=typeof n||"number"!=typeof B)throw new TypeError("input is valid");logInternal(t,n,B,e)}}function createCategorizedLogger(t){return{verbose:log.verbose.bind(null,t),info:log.info.bind(null,t),warning:log.warning.bind(null,t),error:log.error.bind(null,t),fatal:log.fatal.bind(null,t)}}function logInternal(t,e,n,B){const s=LOGGER_CONFIG_MAP[B||""]||LOGGER_CONFIG_MAP[""];SEVERITY_VALUE[t]<SEVERITY_VALUE[s.minimalSeverity]||(s.logDateTime&&(e=`${(new Date).toISOString()}|${e}`),s.logSourceLocation,LOGGER_PROVIDER_MAP[s.provider].log(t,e,B))}var init_instrument=__esm({"web/lib/onnxjs/instrument.ts"(){NoOpLoggerProvider=class{log(t,e,n){}},ConsoleLoggerProvider=class{log(t,e,n){console.log(`${this.color(t)} ${n?"[35m"+n+"[0m ":""}${e}`)}color(t){switch(t){case"verbose":return"[34;40mv[0m";case"info":return"[32mi[0m";case"warning":return"[30;43mw[0m";case"error":return"[31;40me[0m";case"fatal":return"[101mf[0m";default:throw new Error(`unsupported severity: ${t}`)}}},SEVERITY_VALUE={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},LOGGER_PROVIDER_MAP={none:new NoOpLoggerProvider,console:new ConsoleLoggerProvider},LOGGER_CONFIG_MAP={"":LOGGER_DEFAULT_CONFIG={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(t=>{function e(t){LOGGER_CONFIG_MAP={},n("",t||{})}function n(t,n){if("*"===t)e(n);else{const e=LOGGER_CONFIG_MAP[t]||LOGGER_DEFAULT_CONFIG;LOGGER_CONFIG_MAP[t]={provider:n.provider||e.provider,minimalSeverity:n.minimalSeverity||e.minimalSeverity,logDateTime:void 0===n.logDateTime?e.logDateTime:n.logDateTime,logSourceLocation:void 0===n.logSourceLocation?e.logSourceLocation:n.logSourceLocation}}}t.verbose=function(e,n){t("verbose",e,n)},t.info=function(e,n){t("info",e,n)},t.warning=function(e,n){t("warning",e,n)},t.error=function(e,n){t("error",e,n)},t.fatal=function(e,n){t("fatal",e,n)},t.reset=e,t.set=n,t.setWithEnv=function(t){const e={};t.logLevel&&(e.minimalSeverity=t.logLevel),n("",e)}})(log||(log={})),Logger=log,Event=class{constructor(t,e,n,B,s,F){this.category=t,this.name=e,this.startTime=n,this.endCallback=B,this.timer=s,this.ctx=F}async end(){return this.endCallback(this)}async checkTimer(){if(void 0===this.ctx||void 0===this.timer)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},EventRecord=class{constructor(t,e,n,B){this.category=t,this.name=e,this.startTime=n,this.endTime=B}},Profiler=class{constructor(t,e,n){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=void 0===t?1e4:t,this._flushBatchSize=void 0===e?10:e,this._flushIntervalInMilliseconds=void 0===n?5e3:n}static create(t){return void 0===t?new this:new this(t.maxNumberEvents,t.flushBatchSize,t.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=now(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,e,n,B){const s=this._started?this.begin(t,e,B):void 0;let F=!1;const Q=n();if(Q&&"function"==typeof Q.then)return F=!0,new Promise(((t,e)=>{Q.then((async e=>{s&&await s.end(),t(e)}),(async t=>{s&&await s.end(),e(t)}))}));if(!F&&s){const t=s.end();if(t&&"function"==typeof t.then)return new Promise(((e,n)=>{t.then((()=>{e(Q)}),(t=>{n(t)}))}))}return Q}begin(t,e,n){if(!this._started)throw new Error("profiler is not started yet");if(void 0===n){const n=now();return this.flush(n),new Event(t,e,n,(t=>this.endSync(t)))}{const B=n.beginTimer();return new Event(t,e,0,(async t=>this.end(t)),B,n)}}async end(t){const e=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new EventRecord(t.category,t.name,t.startTime,e)),this.flush(e))}endSync(t){const e=now();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new EventRecord(t.category,t.name,t.startTime,e)),this.flush(e))}logOneEvent(t){Logger.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(const t=this._flushPointer;this._flushPointer<t+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=now()}}get started(){return this._started}},now="undefined"!=typeof performance&&performance.now?()=>performance.now():Date.now}});function resolveOperator(t,e,n){for(const B of n){const n=B[0],s=B[1],F=B[2],Q=B[3],U=B[4];if(t.opType===n)for(const t of e)if((t.domain===s||"ai.onnx"===t.domain&&""===s)&&matchSelector(t.version,F))return{opImpl:Q,opInit:U}}throw new TypeError(`cannot resolve operator '${t.opType}' with opsets: ${e.map((t=>`${t.domain||"ai.onnx"} v${t.version}`)).join(", ")}`)}function matchSelector(t,e){if(e.endsWith("+")){const n=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(n)&&n<=t}if(2===e.split("-").length){const n=e.split("-"),B=Number.parseInt(n[0],10),s=Number.parseInt(n[1],10);return!isNaN(B)&&!isNaN(s)&&B<=t&&t<=s}return Number.parseInt(e,10)===t}var init_opset=__esm({"web/lib/onnxjs/opset.ts"(){}}),require_guid=__commonJS({"web/node_modules/guid-typescript/dist/guid.js"(t){t.__esModule=!0;var e=function(){function t(e){if(!e)throw new TypeError("Invalid argument; `value` has no value.");this.value=t.EMPTY,e&&t.isGuid(e)&&(this.value=e)}return t.isGuid=function(e){var n=e.toString();return e&&(e instanceof t||t.validator.test(n))},t.create=function(){return new t([t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-"))},t.createEmpty=function(){return new t("emptyguid")},t.parse=function(e){return new t(e)},t.raw=function(){return[t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-")},t.gen=function(t){for(var e="",n=0;n<t;n++)e+=(65536*(1+Math.random())|0).toString(16).substring(1);return e},t.prototype.equals=function(e){return t.isGuid(e)&&this.value===e.toString()},t.prototype.isEmpty=function(){return this.value===t.EMPTY},t.prototype.toString=function(){return this.value},t.prototype.toJSON=function(){return{value:this.value}},t.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),t.EMPTY="00000000-0000-0000-0000-000000000000",t}();t.Guid=e}}),wasm,INT_CACHE,UINT_CACHE,pow_dbl,TWO_PWR_16_DBL,TWO_PWR_24_DBL,TWO_PWR_32_DBL,TWO_PWR_64_DBL,TWO_PWR_63_DBL,TWO_PWR_24,ZERO,UZERO,ONE,UONE,NEG_ONE,MAX_VALUE,MAX_UNSIGNED_VALUE,MIN_VALUE,LongPrototype,long_default;function Long(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function isLong(t){return!0===(t&&t.__isLong__)}function ctz32(t){var e=Math.clz32(t&-t);return t?31-e:e}function fromInt(t,e){var n,B,s;return e?(s=0<=(t>>>=0)&&t<256)&&(B=UINT_CACHE[t])?B:(n=fromBits(t,0,!0),s&&(UINT_CACHE[t]=n),n):(s=-128<=(t|=0)&&t<128)&&(B=INT_CACHE[t])?B:(n=fromBits(t,t<0?-1:0,!1),s&&(INT_CACHE[t]=n),n)}function fromNumber(t,e){if(isNaN(t))return e?UZERO:ZERO;if(e){if(t<0)return UZERO;if(t>=TWO_PWR_64_DBL)return MAX_UNSIGNED_VALUE}else{if(t<=-TWO_PWR_63_DBL)return MIN_VALUE;if(t+1>=TWO_PWR_63_DBL)return MAX_VALUE}return t<0?fromNumber(-t,e).neg():fromBits(t%TWO_PWR_32_DBL|0,t/TWO_PWR_32_DBL|0,e)}function fromBits(t,e,n){return new Long(t,e,n)}function fromString(t,e,n){if(0===t.length)throw Error("empty string");if("number"==typeof e?(n=e,e=!1):e=!!e,"NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e?UZERO:ZERO;if((n=n||10)<2||36<n)throw RangeError("radix");var B;if((B=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===B)return fromString(t.substring(1),e,n).neg();for(var s=fromNumber(pow_dbl(n,8)),F=ZERO,Q=0;Q<t.length;Q+=8){var U=Math.min(8,t.length-Q),i=parseInt(t.substring(Q,Q+U),n);if(U<8){var a=fromNumber(pow_dbl(n,U));F=F.mul(a).add(fromNumber(i))}else F=(F=F.mul(s)).add(fromNumber(i))}return F.unsigned=e,F}function fromValue(t,e){return"number"==typeof t?fromNumber(t,e):"string"==typeof t?fromString(t,e):fromBits(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}var init_long=__esm({"web/node_modules/long/index.js"(){wasm=null;try{wasm=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(t){}Long.prototype.__isLong__,Object.defineProperty(Long.prototype,"__isLong__",{value:!0}),Long.isLong=isLong,INT_CACHE={},UINT_CACHE={},Long.fromInt=fromInt,Long.fromNumber=fromNumber,Long.fromBits=fromBits,pow_dbl=Math.pow,Long.fromString=fromString,Long.fromValue=fromValue,TWO_PWR_63_DBL=(TWO_PWR_64_DBL=(TWO_PWR_32_DBL=(TWO_PWR_16_DBL=65536)*TWO_PWR_16_DBL)*TWO_PWR_32_DBL)/2,TWO_PWR_24=fromInt(TWO_PWR_24_DBL=1<<24),ZERO=fromInt(0),Long.ZERO=ZERO,UZERO=fromInt(0,!0),Long.UZERO=UZERO,ONE=fromInt(1),Long.ONE=ONE,UONE=fromInt(1,!0),Long.UONE=UONE,NEG_ONE=fromInt(-1),Long.NEG_ONE=NEG_ONE,MAX_VALUE=fromBits(-1,2147483647,!1),Long.MAX_VALUE=MAX_VALUE,MAX_UNSIGNED_VALUE=fromBits(-1,-1,!0),Long.MAX_UNSIGNED_VALUE=MAX_UNSIGNED_VALUE,MIN_VALUE=fromBits(0,-2147483648,!1),Long.MIN_VALUE=MIN_VALUE,(LongPrototype=Long.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},LongPrototype.toNumber=function(){return this.unsigned?(this.high>>>0)*TWO_PWR_32_DBL+(this.low>>>0):this.high*TWO_PWR_32_DBL+(this.low>>>0)},LongPrototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(MIN_VALUE)){var e=fromNumber(t),n=this.div(e),B=n.mul(e).sub(this);return n.toString(t)+B.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var s=fromNumber(pow_dbl(t,6),this.unsigned),F=this,Q="";;){var U=F.div(s),i=(F.sub(U.mul(s)).toInt()>>>0).toString(t);if((F=U).isZero())return i+Q;for(;i.length<6;)i="0"+i;Q=""+i+Q}},LongPrototype.getHighBits=function(){return this.high},LongPrototype.getHighBitsUnsigned=function(){return this.high>>>0},LongPrototype.getLowBits=function(){return this.low},LongPrototype.getLowBitsUnsigned=function(){return this.low>>>0},LongPrototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(MIN_VALUE)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&!(t&1<<e);e--);return 0!=this.high?e+33:e+1},LongPrototype.isZero=function(){return 0===this.high&&0===this.low},LongPrototype.eqz=LongPrototype.isZero,LongPrototype.isNegative=function(){return!this.unsigned&&this.high<0},LongPrototype.isPositive=function(){return this.unsigned||this.high>=0},LongPrototype.isOdd=function(){return!(1&~this.low)},LongPrototype.isEven=function(){return!(1&this.low)},LongPrototype.equals=function(t){return isLong(t)||(t=fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},LongPrototype.eq=LongPrototype.equals,LongPrototype.notEquals=function(t){return!this.eq(t)},LongPrototype.neq=LongPrototype.notEquals,LongPrototype.ne=LongPrototype.notEquals,LongPrototype.lessThan=function(t){return this.comp(t)<0},LongPrototype.lt=LongPrototype.lessThan,LongPrototype.lessThanOrEqual=function(t){return this.comp(t)<=0},LongPrototype.lte=LongPrototype.lessThanOrEqual,LongPrototype.le=LongPrototype.lessThanOrEqual,LongPrototype.greaterThan=function(t){return this.comp(t)>0},LongPrototype.gt=LongPrototype.greaterThan,LongPrototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},LongPrototype.gte=LongPrototype.greaterThanOrEqual,LongPrototype.ge=LongPrototype.greaterThanOrEqual,LongPrototype.compare=function(t){if(isLong(t)||(t=fromValue(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?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},LongPrototype.comp=LongPrototype.compare,LongPrototype.negate=function(){return!this.unsigned&&this.eq(MIN_VALUE)?MIN_VALUE:this.not().add(ONE)},LongPrototype.neg=LongPrototype.negate,LongPrototype.add=function(t){isLong(t)||(t=fromValue(t));var e=this.high>>>16,n=65535&this.high,B=this.low>>>16,s=65535&this.low,F=t.high>>>16,Q=65535&t.high,U=t.low>>>16,i=0,a=0,l=0,c=0;return l+=(c+=s+(65535&t.low))>>>16,a+=(l+=B+U)>>>16,i+=(a+=n+Q)>>>16,i+=e+F,fromBits((l&=65535)<<16|(c&=65535),(i&=65535)<<16|(a&=65535),this.unsigned)},LongPrototype.subtract=function(t){return isLong(t)||(t=fromValue(t)),this.add(t.neg())},LongPrototype.sub=LongPrototype.subtract,LongPrototype.multiply=function(t){if(this.isZero())return this;if(isLong(t)||(t=fromValue(t)),wasm)return fromBits(wasm.mul(this.low,this.high,t.low,t.high),wasm.get_high(),this.unsigned);if(t.isZero())return this.unsigned?UZERO:ZERO;if(this.eq(MIN_VALUE))return t.isOdd()?MIN_VALUE:ZERO;if(t.eq(MIN_VALUE))return this.isOdd()?MIN_VALUE:ZERO;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(TWO_PWR_24)&&t.lt(TWO_PWR_24))return fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,n=65535&this.high,B=this.low>>>16,s=65535&this.low,F=t.high>>>16,Q=65535&t.high,U=t.low>>>16,i=65535&t.low,a=0,l=0,c=0,g=0;return c+=(g+=s*i)>>>16,l+=(c+=B*i)>>>16,c&=65535,l+=(c+=s*U)>>>16,a+=(l+=n*i)>>>16,l&=65535,a+=(l+=B*U)>>>16,l&=65535,a+=(l+=s*Q)>>>16,a+=e*i+n*U+B*Q+s*F,fromBits((c&=65535)<<16|(g&=65535),(a&=65535)<<16|(l&=65535),this.unsigned)},LongPrototype.mul=LongPrototype.multiply,LongPrototype.divide=function(t){if(isLong(t)||(t=fromValue(t)),t.isZero())throw Error("division by zero");var e,n,B;if(wasm)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?fromBits((this.unsigned?wasm.div_u:wasm.div_s)(this.low,this.high,t.low,t.high),wasm.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?UZERO:ZERO;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return UZERO;if(t.gt(this.shru(1)))return UONE;B=UZERO}else{if(this.eq(MIN_VALUE))return t.eq(ONE)||t.eq(NEG_ONE)?MIN_VALUE:t.eq(MIN_VALUE)?ONE:(e=this.shr(1).div(t).shl(1)).eq(ZERO)?t.isNegative()?ONE:NEG_ONE:(n=this.sub(t.mul(e)),B=e.add(n.div(t)));if(t.eq(MIN_VALUE))return this.unsigned?UZERO:ZERO;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();B=ZERO}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(e)/Math.LN2),F=s<=48?1:pow_dbl(2,s-48),Q=fromNumber(e),U=Q.mul(t);U.isNegative()||U.gt(n);)U=(Q=fromNumber(e-=F,this.unsigned)).mul(t);Q.isZero()&&(Q=ONE),B=B.add(Q),n=n.sub(U)}return B},LongPrototype.div=LongPrototype.divide,LongPrototype.modulo=function(t){return isLong(t)||(t=fromValue(t)),wasm?fromBits((this.unsigned?wasm.rem_u:wasm.rem_s)(this.low,this.high,t.low,t.high),wasm.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},LongPrototype.mod=LongPrototype.modulo,LongPrototype.rem=LongPrototype.modulo,LongPrototype.not=function(){return fromBits(~this.low,~this.high,this.unsigned)},LongPrototype.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},LongPrototype.clz=LongPrototype.countLeadingZeros,LongPrototype.countTrailingZeros=function(){return this.low?ctz32(this.low):ctz32(this.high)+32},LongPrototype.ctz=LongPrototype.countTrailingZeros,LongPrototype.and=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low&t.low,this.high&t.high,this.unsigned)},LongPrototype.or=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low|t.low,this.high|t.high,this.unsigned)},LongPrototype.xor=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low^t.low,this.high^t.high,this.unsigned)},LongPrototype.shiftLeft=function(t){return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):fromBits(0,this.low<<t-32,this.unsigned)},LongPrototype.shl=LongPrototype.shiftLeft,LongPrototype.shiftRight=function(t){return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},LongPrototype.shr=LongPrototype.shiftRight,LongPrototype.shiftRightUnsigned=function(t){return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):fromBits(32===t?this.high:this.high>>>t-32,0,this.unsigned)},LongPrototype.shru=LongPrototype.shiftRightUnsigned,LongPrototype.shr_u=LongPrototype.shiftRightUnsigned,LongPrototype.rotateLeft=function(t){var e;return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?(e=32-t,fromBits(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)):(e=32-(t-=32),fromBits(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned))},LongPrototype.rotl=LongPrototype.rotateLeft,LongPrototype.rotateRight=function(t){var e;return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?(e=32-t,fromBits(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned)):(e=32-(t-=32),fromBits(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned))},LongPrototype.rotr=LongPrototype.rotateRight,LongPrototype.toSigned=function(){return this.unsigned?fromBits(this.low,this.high,!1):this},LongPrototype.toUnsigned=function(){return this.unsigned?this:fromBits(this.low,this.high,!0)},LongPrototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},LongPrototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},LongPrototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},Long.fromBytes=function(t,e,n){return n?Long.fromBytesLE(t,e):Long.fromBytesBE(t,e)},Long.fromBytesLE=function(t,e){return new Long(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},Long.fromBytesBE=function(t,e){return new Long(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)},long_default=Long}}),flatbuffers,init_flatbuffers=__esm({"web/node_modules/flatbuffers/js/flatbuffers.mjs"(){flatbuffers={},flatbuffers.Table,flatbuffers.SIZEOF_SHORT=2,flatbuffers.SIZEOF_INT=4,flatbuffers.FILE_IDENTIFIER_LENGTH=4,flatbuffers.SIZE_PREFIX_LENGTH=4,flatbuffers.Encoding={UTF8_BYTES:1,UTF16_STRING:2},flatbuffers.int32=new Int32Array(2),flatbuffers.float32=new Float32Array(flatbuffers.int32.buffer),flatbuffers.float64=new Float64Array(flatbuffers.int32.buffer),flatbuffers.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],flatbuffers.Long=function(t,e){this.low=0|t,this.high=0|e},flatbuffers.Long.create=function(t,e){return 0==t&&0==e?flatbuffers.Long.ZERO:new flatbuffers.Long(t,e)},flatbuffers.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},flatbuffers.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},flatbuffers.Long.ZERO=new flatbuffers.Long(0,0),flatbuffers.Builder=function(t){if(t)e=t;else var e=1024;this.bb=flatbuffers.ByteBuffer.allocate(e),this.space=e,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},flatbuffers.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},flatbuffers.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},flatbuffers.Builder.prototype.dataBuffer=function(){return this.bb},flatbuffers.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},flatbuffers.Builder.prototype.prep=function(t,e){t>this.minalign&&(this.minalign=t);for(var n=1+~(this.bb.capacity()-this.space+e)&t-1;this.space<n+t+e;){var B=this.bb.capacity();this.bb=flatbuffers.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-B}this.pad(n)},flatbuffers.Builder.prototype.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},flatbuffers.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},flatbuffers.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},flatbuffers.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},flatbuffers.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},flatbuffers.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},flatbuffers.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},flatbuffers.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},flatbuffers.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},flatbuffers.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},flatbuffers.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},flatbuffers.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},flatbuffers.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},flatbuffers.Builder.prototype.addFieldInt8=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldInt16=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldInt32=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldInt64=function(t,e,n){!this.force_defaults&&e.equals(n)||(this.addInt64(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldFloat32=function(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldFloat64=function(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldOffset=function(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))},flatbuffers.Builder.prototype.addFieldStruct=function(t,e,n){e!=n&&(this.nested(e),this.slot(t))},flatbuffers.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},flatbuffers.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},flatbuffers.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},flatbuffers.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},flatbuffers.Builder.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var n=e<<1,B=flatbuffers.ByteBuffer.allocate(n);return B.setPosition(n-e),B.bytes().set(t.bytes(),n-e),B},flatbuffers.Builder.prototype.addOffset=function(t){this.prep(flatbuffers.SIZEOF_INT,0),this.writeInt32(this.offset()-t+flatbuffers.SIZEOF_INT)},flatbuffers.Builder.prototype.startObject=function(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(var e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()},flatbuffers.Builder.prototype.endObject=function(){if(null=