UNPKG

dicomweb-proxy

Version:

A proxy to translate between dicomweb and dimse

2 lines 417 kB
/*! For license information please see ort.webgl.min.js.LICENSE.txt */ var _l=Object.create,$e=Object.defineProperty,Sl=Object.getOwnPropertyDescriptor,Ol=Object.getOwnPropertyNames,Al=Object.getPrototypeOf,Pl=Object.prototype.hasOwnProperty,x=(t,e)=>()=>(t&&(e=t(t=0)),e),Z=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wn=(t,e)=>{for(var n in e)$e(t,n,{get:e[n],enumerable:!0})},Hn=(t,e,n,r)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let i of Ol(e))!Pl.call(t,i)&&i!==n&&$e(t,i,{get:()=>e[i],enumerable:!(r=Sl(e,i))||r.enumerable});return t},re=(t,e,n)=>(n=null!=t?_l(Al(t)):{},Hn(!e&&t&&t.__esModule?n:$e(n,"default",{value:t,enumerable:!0}),t)),El=t=>Hn($e({},"__esModule",{value:!0}),t),ke,Mt,Be,Fe,Ne=x((()=>{"use strict";ke=new Map,Mt=[],Be=(t,e,n)=>{if(!e||"function"!=typeof e.init||"function"!=typeof e.createInferenceSessionHandler)throw new TypeError("not a valid backend");{let r=ke.get(t);if(void 0===r)ke.set(t,{backend:e,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){let e=Mt.indexOf(t);-1!==e&&Mt.splice(e,1);for(let e=0;e<Mt.length;e++)if(ke.get(Mt[e]).priority<=n)return void Mt.splice(e,0,t);Mt.push(t)}}},Fe=async t=>{let e=0===t.length?Mt:t,n=[];for(let t of e){let e=ke.get(t);if(e){if(e.initialized)return e.backend;if(e.aborted)continue;let r=!!e.initPromise;try{return r||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(i){r||n.push({name:t,err:i}),e.aborted=!0}finally{delete e.initPromise}}}throw new Error(`no available backend found. ERR: ${n.map((t=>`[${t.name}] ${t.err}`)).join(", ")}`)}})),qn=x((()=>{"use strict";Ne()})),jn,Kn=x((()=>{"use strict";jn="1.17.1"})),Xn,Ut,Br=x((()=>{"use strict";Kn(),Xn="warning",Ut={wasm:{},webgl:{},webgpu:{},versions:{common:jn},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}`);Xn=t}},get logLevel(){return Xn}},Object.defineProperty(Ut,"logLevel",{enumerable:!0})})),j,Jn=x((()=>{"use strict";Br(),j=Ut})),Zn,Yn,Qn=x((()=>{"use strict";Zn=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];let r=n.getContext("2d");if(null!=r){let i,o;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(i=t.dims[2],o=t.dims[3]):(i=t.dims[3],o=t.dims[2]);let s,a,u=void 0!==e?.format?e.format:"RGB",l=e?.norm;void 0===l||void 0===l.mean?s=[255,255,255,255]:"number"==typeof l.mean?s=[l.mean,l.mean,l.mean,l.mean]:(s=[l.mean[0],l.mean[1],l.mean[2],0],void 0!==l.mean[3]&&(s[3]=l.mean[3])),void 0===l||void 0===l.bias?a=[0,0,0,0]:"number"==typeof l.bias?a=[l.bias,l.bias,l.bias,l.bias]:(a=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(a[3]=l.bias[3]));let p=o*i,c=0,d=p,h=2*p,f=-1;"RGBA"===u?(c=0,d=p,h=2*p,f=3*p):"RGB"===u?(c=0,d=p,h=2*p):"RBG"===u&&(c=0,h=p,d=2*p);for(let e=0;e<o;e++)for(let n=0;n<i;n++){let i=(t.data[c++]-a[0])*s[0],o=(t.data[d++]-a[1])*s[1],u=(t.data[h++]-a[2])*s[2],l=-1===f?255:(t.data[f++]-a[3])*s[3];r.fillStyle="rgba("+i+","+o+","+u+","+l+")",r.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")},Yn=(t,e)=>{let n,r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");if(null==r)throw new Error("Can not access image data");{let i,o,s;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(i=t.dims[2],o=t.dims[1],s=t.dims[3]):(i=t.dims[3],o=t.dims[2],s=t.dims[1]);let a,u,l=void 0!==e&&void 0!==e.format?e.format:"RGB",p=e?.norm;void 0===p||void 0===p.mean?a=[255,255,255,255]:"number"==typeof p.mean?a=[p.mean,p.mean,p.mean,p.mean]:(a=[p.mean[0],p.mean[1],p.mean[2],255],void 0!==p.mean[3]&&(a[3]=p.mean[3])),void 0===p||void 0===p.bias?u=[0,0,0,0]:"number"==typeof p.bias?u=[p.bias,p.bias,p.bias,p.bias]:(u=[p.bias[0],p.bias[1],p.bias[2],0],void 0!==p.bias[3]&&(u[3]=p.bias[3]));let c=o*i;if(void 0!==e&&(void 0!==e.format&&4===s&&"RGBA"!==e.format||3===s&&"RGB"!==e.format&&"BGR"!==e.format))throw new Error("Tensor format doesn't match input tensor dims");let d=4,h=0,f=1,g=2,b=3,m=0,y=c,x=2*c,w=-1;"RGBA"===l?(m=0,y=c,x=2*c,w=3*c):"RGB"===l?(m=0,y=c,x=2*c):"RBG"===l&&(m=0,x=c,y=2*c),n=r.createImageData(i,o);for(let e=0;e<o*i;h+=d,f+=d,g+=d,b+=d,e++)n.data[h]=(t.data[m++]-u[0])*a[0],n.data[f]=(t.data[y++]-u[1])*a[1],n.data[g]=(t.data[x++]-u[2])*a[2],n.data[b]=-1===w?255:(t.data[w++]-u[3])*a[3]}return n}})),Fr,to,eo,ro,no,oo=x((()=>{"use strict";Ce(),Fr=(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");let n,r,{height:i,width:o}=e,s=e.norm??{mean:255,bias:0};n="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],r="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];let a=void 0!==e.format?e.format:"RGBA",u=void 0!==e.tensorFormat&&void 0!==e.tensorFormat?e.tensorFormat:"RGB",l=i*o,p="RGBA"===u?new Float32Array(4*l):new Float32Array(3*l),c=4,d=0,h=1,f=2,g=3,b=0,m=l,y=2*l,x=-1;"RGB"===a&&(c=3,d=0,h=1,f=2,g=-1),"RGBA"===u?x=3*l:"RBG"===u?(b=0,y=l,m=2*l):"BGR"===u&&(y=0,m=l,b=2*l);for(let e=0;e<l;e++,d+=c,f+=c,h+=c,g+=c)p[b++]=(t[d]+r[0])/n[0],p[m++]=(t[h]+r[1])/n[1],p[y++]=(t[f]+r[2])/n[2],-1!==x&&-1!==g&&(p[x++]=(t[g]+r[3])/n[3]);return new nt("float32",p,"RGBA"===u?[1,4,i,o]:[1,3,i,o])},to=async(t,e)=>{let n,r=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,i=typeof ImageData<"u"&&t instanceof ImageData,o=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,s="string"==typeof t,a=e??{},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=t=>t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas?t.getContext("2d"):null;if(r){let r=u();r.width=t.width,r.height=t.height;let i=l(r);if(null==i)throw new Error("Can not access image data");{let r=t.height,o=t.width;if(void 0!==e&&void 0!==e.resizedHeight&&void 0!==e.resizedWidth&&(r=e.resizedHeight,o=e.resizedWidth),void 0!==e){if(a=e,void 0!==e.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=r,a.width=o}else a.tensorFormat="RGBA",a.height=r,a.width=o;i.drawImage(t,0,0),n=i.getImageData(0,0,o,r).data}}else{if(!i){if(o){if(void 0===e)throw new Error("Please provide image config with format for Imagebitmap");let r=u();r.width=t.width,r.height=t.height;let i=l(r);if(null!=i){let e=t.height,r=t.width;return i.drawImage(t,0,0,r,e),n=i.getImageData(0,0,r,e).data,a.height=e,a.width=r,Fr(n,a)}throw new Error("Can not access image data")}if(s)return new Promise(((e,n)=>{let r=u(),i=l(r);if(!t||!i)return n();let o=new Image;o.crossOrigin="Anonymous",o.src=t,o.onload=()=>{r.width=o.width,r.height=o.height,i.drawImage(o,0,0,r.width,r.height);let t=i.getImageData(0,0,r.width,r.height);a.height=r.height,a.width=r.width,e(Fr(t.data,a))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let r,i;if(void 0!==e&&void 0!==e.resizedWidth&&void 0!==e.resizedHeight?(r=e.resizedHeight,i=e.resizedWidth):(r=t.height,i=t.width),void 0!==e&&(a=e),a.format="RGBA",a.height=r,a.width=i,void 0!==e){let e=u();e.width=i,e.height=r;let o=l(e);if(null==o)throw new Error("Can not access image data");o.putImageData(t,0,0),n=o.getImageData(0,0,i,r).data}else n=t.data}}if(void 0!==n)return Fr(n,a);throw new Error("Input data provided is not supported - aborted tensor creation")},eo=(t,e)=>{let{width:n,height:r,download:i,dispose:o}=e;return new nt({location:"texture",type:"float32",texture:t,dims:[1,r,n,4],download:i,dispose:o})},ro=(t,e)=>{let{dataType:n,dims:r,download:i,dispose:o}=e;return new nt({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:r,download:i,dispose:o})},no=(t,e,n)=>new nt({location:"cpu-pinned",type:t,data:e,dims:n??[e.length]})})),me,Ge,io,ao,so=x((()=>{"use strict";me=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),Ge=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),io=!1,ao=()=>{if(!io){io=!0;let t=typeof BigInt64Array<"u"&&"function"==typeof BigInt64Array.from,e=typeof BigUint64Array<"u"&&"function"==typeof BigUint64Array.from;t&&(me.set("int64",BigInt64Array),Ge.set(BigInt64Array,"int64")),e&&(me.set("uint64",BigUint64Array),Ge.set(BigUint64Array,"uint64"))}}})),uo,lo,fo=x((()=>{"use strict";Ce(),uo=t=>{let e=1;for(let n=0;n<t.length;n++){let r=t[n];if("number"!=typeof r||!Number.isSafeInteger(r))throw new TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);e*=r}return e},lo=(t,e)=>{switch(t.location){case"cpu":return new nt(t.type,t.data,e);case"cpu-pinned":return new nt({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new nt({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new nt({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}})),nt,Ce=x((()=>{"use strict";Qn(),oo(),so(),fo(),nt=class{constructor(t,e,n){let r,i;if(ao(),"object"==typeof t&&"location"in t)switch(this.dataLocation=t.location,r=t.type,i=t.dims,t.location){case"cpu-pinned":{let e=me.get(r);if(!e)throw new TypeError(`unsupported type "${r}" 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"!==r)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("float32"!==r&&"float16"!==r&&"int32"!==r&&"int64"!==r&&"uint32"!==r&&"bool"!==r)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 o,s;if("string"==typeof t)if(r=t,s=n,"string"===t){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");o=e}else{let n=me.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.");o="uint64"===t||"int64"===t?n.from(e,BigInt):n.from(e)}else{if(!(e instanceof n))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);o=e}}else if(s=e,Array.isArray(t)){if(0===t.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");let e=typeof t[0];if("string"===e)r="string",o=t;else{if("boolean"!==e)throw new TypeError(`Invalid element type of data array: ${e}.`);r="bool",o=Uint8Array.from(t)}}else{let e=Ge.get(t.constructor);if(void 0===e)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);r=e,o=t}if(void 0===s)s=[o.length];else if(!Array.isArray(s))throw new TypeError("A tensor's dims must be a number array");i=s,this.cpuData=o,this.dataLocation="cpu"}let o=uo(i);if(this.cpuData&&o!==this.cpuData.length)throw new Error(`Tensor's size(${o}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=o}static async fromImage(t,e){return to(t,e)}static fromTexture(t,e){return eo(t,e)}static fromGpuBuffer(t,e){return ro(t,e)}static fromPinnedBuffer(t,e,n){return no(t,e,n)}toDataURL(t){return Zn(this,t)}toImageData(t){return Yn(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 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 lo(this,t)}}})),ot,Re=x((()=>{"use strict";Ce(),ot=nt})),co,po,Ve,ze,Nr=x((()=>{"use strict";Br(),co=(t,e)=>{Ut.wasm.trace&&console.timeStamp(`${t}::ORT::${e}`)},po=(t,e)=>{let n=(new Error).stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes("TRACE_FUNC")){let r=`FUNC_${t}::${n[i].trim().split(" ")[1]}`;return e&&(r+=`::${e}`),void co("CPU",r)}n[i].includes("TRACE_FUNC")&&(r=!0)}},Ve=t=>{Ut.wasm.trace&&po("BEGIN",t)},ze=t=>{Ut.wasm.trace&&po("END",t)}})),Me,ho=x((()=>{"use strict";Ne(),Re(),Nr(),Me=class t{constructor(t){this.handler=t}async run(t,e,n){Ve();let r={},i={};if("object"!=typeof t||null===t||t instanceof ot||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let o=!0;if("object"==typeof e){if(null===e)throw new TypeError("Unexpected argument[1]: cannot be null.");if(e instanceof ot)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.");o=!1;for(let 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}.`);r[t]=null}if("object"==typeof n&&null!==n)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,s=Object.getOwnPropertyNames(e);for(let n of this.outputNames)if(-1!==s.indexOf(n)){let i=e[n];(null===i||i instanceof ot)&&(t=!0,o=!1,r[n]=i)}if(t){if("object"==typeof n&&null!==n)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else i=e}}else if(typeof e<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of this.inputNames)if(typeof t[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(o)for(let t of this.outputNames)r[t]=null;let s=await this.handler.run(t,r,i),a={};for(let t in s)if(Object.hasOwnProperty.call(s,t)){let e=s[t];a[t]=e instanceof ot?e:new ot(e.type,e.data,e.dims)}return ze(),a}async release(){return this.handler.dispose()}static async create(e,n,r,i){Ve();let o,s={};if("string"==typeof e){if(o=e,"object"==typeof n&&null!==n)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(o=e,"object"==typeof n&&null!==n)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{if(!(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{let t=e,a=0,u=e.byteLength;if("object"==typeof n&&null!==n)s=n;else if("number"==typeof n){if(a=n,!Number.isSafeInteger(a))throw new RangeError("'byteOffset' must be an integer.");if(a<0||a>=t.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(u=e.byteLength-a,"number"==typeof r){if(u=r,!Number.isSafeInteger(u))throw new RangeError("'byteLength' must be an integer.");if(u<=0||a+u>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-a}].`);if("object"==typeof i&&null!==i)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof r<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");o=new Uint8Array(t,a,u)}}let a=(s.executionProviders||[]).map((t=>"string"==typeof t?t:t.name)),u=await(await Fe(a)).createInferenceSessionHandler(o,s);return ze(),new t(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}})),Dl,mo=x((()=>{"use strict";ho(),Dl=Me})),bo=x((()=>{})),Ll,Ue,yo=x((()=>{"use strict";Ne(),Re(),Ll="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Ue=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){let r=e.evalModel||"",i=e.optimizerModel||"",o=n||{},s=(o.executionProviders||[]).map((t=>"string"==typeof t?t:t.name)),a=await Fe(s);if(a.createTrainingSessionHandler){let n=await a.createTrainingSessionHandler(e.checkpointState,e.trainModel,r,i,o);return new t(n,!!e.optimizerModel,!!e.evalModel)}throw new Error(Ll)}typeNarrowingForRunStep(t,e,n,r,i){let o={},s={};if("object"!=typeof n||null===n||n instanceof ot||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if("object"==typeof r){if(null===r)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof ot)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(0===r.length)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let t of r){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}.`);o[t]=null}if("object"==typeof i&&null!==i)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,n=Object.getOwnPropertyNames(r);for(let i of e)if(-1!==n.indexOf(i)){let e=r[i];(null===e||e instanceof ot)&&(t=!0,a=!1,o[i]=e)}if(t){if("object"==typeof i&&null!==i)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else s=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of t)if(typeof n[e]>"u")throw new Error(`input '${e}' is missing in 'feeds'.`);if(a)for(let t of e)o[t]=null;return[o,s]}convertHandlerReturnTypeToMapOfTensors(t){let e={};for(let n in t)if(Object.hasOwnProperty.call(t,n)){let r=t[n];e[n]=r instanceof ot?r:new ot(r.type,r.data,r.dims)}return e}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,e,n){let[r,i]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,e,n),o=await this.handler.runTrainStep(t,r,i);return this.convertHandlerReturnTypeToMapOfTensors(o)}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){let[r,i]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,e,n),o=await this.handler.runEvalStep(t,r,i);return this.convertHandlerReturnTypeToMapOfTensors(o)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,e=!0){let 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()}}})),$l,go=x((()=>{"use strict";yo(),$l=Ue})),Cr={};Wn(Cr,{InferenceSession:()=>Dl,TRACE:()=>co,TRACE_FUNC_BEGIN:()=>Ve,TRACE_FUNC_END:()=>ze,Tensor:()=>ot,TrainingSession:()=>$l,env:()=>j,registerBackend:()=>Be});var Bt=x((()=>{"use strict";qn(),Jn(),mo(),Re(),Nr(),bo(),go()}));function Ft(t,e,n,r){if(void 0===e)return Bl(t);if(void 0===n)We(t,e,1);else if("number"==typeof n&&void 0===r)We(t,e,n);else if("string"==typeof n&&void 0===r)We(t,n,1,e);else{if("string"!=typeof n||"number"!=typeof r)throw new TypeError("input is valid");We(t,n,r,e)}}function Bl(t){return{verbose:Ft.verbose.bind(null,t),info:Ft.info.bind(null,t),warning:Ft.warning.bind(null,t),error:Ft.error.bind(null,t),fatal:Ft.fatal.bind(null,t)}}function We(t,e,n,r){let i=be[r||""]||be[""];To[t]<To[i.minimalSeverity]||(i.logDateTime&&(e=`${(new Date).toISOString()}|${e}`),i.logSourceLocation,kl[i.provider].log(t,e,r))}var Gr,Rr,To,kl,vo,be,M,qe,je,Ke,He,ct=x((()=>{"use strict";Gr=class{log(t,e,n){}},Rr=class{log(t,e,n){console.log(`${this.color(t)} ${n?""+n+" ":""}${e}`)}color(t){switch(t){case"verbose":return"v";case"info":return"i";case"warning":return"w";case"error":return"e";case"fatal":return"f";default:throw new Error(`unsupported severity: ${t}`)}}},To={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},kl={none:new Gr,console:new Rr},be={"":vo={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(t=>{function e(t){be={},n("",t||{})}function n(t,n){if("*"===t)e(n);else{let e=be[t]||vo;be[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){let e={};t.logLevel&&(e.minimalSeverity=t.logLevel),n("",e)}})(Ft||={}),M=Ft,qe=class{constructor(t,e,n,r,i,o){this.category=t,this.name=e,this.startTime=n,this.endCallback=r,this.timer=i,this.ctx=o}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)}},je=class{constructor(t,e,n,r){this.category=t,this.name=e,this.startTime=n,this.endTime=r}},Ke=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=He(),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,r){let i=this._started?this.begin(t,e,r):void 0,o=!1,s=n();if(s&&"function"==typeof s.then)return o=!0,new Promise(((t,e)=>{s.then((async e=>{i&&await i.end(),t(e)}),(async t=>{i&&await i.end(),e(t)}))}));if(!o&&i){let t=i.end();if(t&&"function"==typeof t.then)return new Promise(((e,n)=>{t.then((()=>{e(s)}),(t=>{n(t)}))}))}return s}begin(t,e,n){if(!this._started)throw new Error("profiler is not started yet");if(void 0===n){let n=He();return this.flush(n),new qe(t,e,n,(t=>this.endSync(t)))}{let r=n.beginTimer();return new qe(t,e,0,(async t=>this.end(t)),r,n)}}async end(t){let e=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new je(t.category,t.name,t.startTime,e)),this.flush(e))}endSync(t){let e=He();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new je(t.category,t.name,t.startTime,e)),this.flush(e))}logOneEvent(t){M.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 t=this._flushPointer;this._flushPointer<t+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=He()}}get started(){return this._started}},He=typeof performance<"u"&&performance.now?()=>performance.now():Date.now}));function wo(t,e,n){for(let r of n){let n=r[0],i=r[1],o=r[2],s=r[3],a=r[4];if(t.opType===n)for(let t of e)if((t.domain===i||"ai.onnx"===t.domain&&""===i)&&Fl(t.version,o))return{opImpl:s,opInit:a}}throw new TypeError(`cannot resolve operator '${t.opType}' with opsets: ${e.map((t=>`${t.domain||"ai.onnx"} v${t.version}`)).join(", ")}`)}function Fl(t,e){if(e.endsWith("+")){let n=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(n)&&n<=t}if(2===e.split("-").length){let n=e.split("-"),r=Number.parseInt(n[0],10),i=Number.parseInt(n[1],10);return!isNaN(r)&&!isNaN(i)&&r<=t&&t<=i}return Number.parseInt(e,10)===t}var Io=x((()=>{})),_o=Z((t=>{"use strict";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}));function U(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function rt(t){return!0===(t&&t.__isLong__)}function So(t){var e=Math.clz32(t&-t);return t?31-e:e}function Wt(t,e){var n,r,i;return e?(i=0<=(t>>>=0)&&t<256)&&(r=Ao[t])?r:(n=V(t,0,!0),i&&(Ao[t]=n),n):(i=-128<=(t|=0)&&t<128)&&(r=Oo[t])?r:(n=V(t,t<0?-1:0,!1),i&&(Oo[t]=n),n)}function dt(t,e){if(isNaN(t))return e?Lt:xt;if(e){if(t<0)return Lt;if(t>=Lo)return Bo}else{if(t<=-Eo)return ut;if(t+1>=Eo)return ko}return t<0?dt(-t,e).neg():V(t%oe|0,t/oe|0,e)}function V(t,e,n){return new U(t,e,n)}function Mr(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?Lt:xt;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Mr(t.substring(1),e,n).neg();for(var i=dt(Xe(n,8)),o=xt,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),n);if(a<8){var l=dt(Xe(n,a));o=o.mul(l).add(dt(u))}else o=(o=o.mul(i)).add(dt(u))}return o.unsigned=e,o}function Tt(t,e){return"number"==typeof t?dt(t,e):"string"==typeof t?Mr(t,e):V(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}var pt,Oo,Ao,Xe,Po,Cl,oe,Lo,Eo,Do,xt,Lt,ne,$o,zr,ko,Bo,ut,T,$t,Ur=x((()=>{pt=null;try{pt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}U.prototype.__isLong__,Object.defineProperty(U.prototype,"__isLong__",{value:!0}),U.isLong=rt,Oo={},Ao={},U.fromInt=Wt,U.fromNumber=dt,U.fromBits=V,Xe=Math.pow,U.fromString=Mr,U.fromValue=Tt,Eo=(Lo=(oe=(Po=65536)*Po)*oe)/2,Do=Wt(Cl=1<<24),xt=Wt(0),U.ZERO=xt,Lt=Wt(0,!0),U.UZERO=Lt,ne=Wt(1),U.ONE=ne,$o=Wt(1,!0),U.UONE=$o,zr=Wt(-1),U.NEG_ONE=zr,ko=V(-1,2147483647,!1),U.MAX_VALUE=ko,Bo=V(-1,-1,!0),U.MAX_UNSIGNED_VALUE=Bo,ut=V(0,-2147483648,!1),U.MIN_VALUE=ut,(T=U.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},T.toNumber=function(){return this.unsigned?(this.high>>>0)*oe+(this.low>>>0):this.high*oe+(this.low>>>0)},T.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(ut)){var e=dt(t),n=this.div(e),r=n.mul(e).sub(this);return n.toString(t)+r.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var i=dt(Xe(t,6),this.unsigned),o=this,s="";;){var a=o.div(i),u=(o.sub(a.mul(i)).toInt()>>>0).toString(t);if((o=a).isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},T.getHighBits=function(){return this.high},T.getHighBitsUnsigned=function(){return this.high>>>0},T.getLowBits=function(){return this.low},T.getLowBitsUnsigned=function(){return this.low>>>0},T.getNumBitsAbs=function(){if(this.isNegative())return this.eq(ut)?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},T.isZero=function(){return 0===this.high&&0===this.low},T.eqz=T.isZero,T.isNegative=function(){return!this.unsigned&&this.high<0},T.isPositive=function(){return this.unsigned||this.high>=0},T.isOdd=function(){return!(1&~this.low)},T.isEven=function(){return!(1&this.low)},T.equals=function(t){return rt(t)||(t=Tt(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},T.eq=T.equals,T.notEquals=function(t){return!this.eq(t)},T.neq=T.notEquals,T.ne=T.notEquals,T.lessThan=function(t){return this.comp(t)<0},T.lt=T.lessThan,T.lessThanOrEqual=function(t){return this.comp(t)<=0},T.lte=T.lessThanOrEqual,T.le=T.lessThanOrEqual,T.greaterThan=function(t){return this.comp(t)>0},T.gt=T.greaterThan,T.greaterThanOrEqual=function(t){return this.comp(t)>=0},T.gte=T.greaterThanOrEqual,T.ge=T.greaterThanOrEqual,T.compare=function(t){if(rt(t)||(t=Tt(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},T.comp=T.compare,T.negate=function(){return!this.unsigned&&this.eq(ut)?ut:this.not().add(ne)},T.neg=T.negate,T.add=function(t){rt(t)||(t=Tt(t));var e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=t.high>>>16,s=65535&t.high,a=t.low>>>16,u=0,l=0,p=0,c=0;return p+=(c+=i+(65535&t.low))>>>16,l+=(p+=r+a)>>>16,u+=(l+=n+s)>>>16,u+=e+o,V((p&=65535)<<16|(c&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},T.subtract=function(t){return rt(t)||(t=Tt(t)),this.add(t.neg())},T.sub=T.subtract,T.multiply=function(t){if(this.isZero())return this;if(rt(t)||(t=Tt(t)),pt)return V(pt.mul(this.low,this.high,t.low,t.high),pt.get_high(),this.unsigned);if(t.isZero())return this.unsigned?Lt:xt;if(this.eq(ut))return t.isOdd()?ut:xt;if(t.eq(ut))return this.isOdd()?ut: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(Do)&&t.lt(Do))return dt(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=t.high>>>16,s=65535&t.high,a=t.low>>>16,u=65535&t.low,l=0,p=0,c=0,d=0;return c+=(d+=i*u)>>>16,p+=(c+=r*u)>>>16,c&=65535,p+=(c+=i*a)>>>16,l+=(p+=n*u)>>>16,p&=65535,l+=(p+=r*a)>>>16,p&=65535,l+=(p+=i*s)>>>16,l+=e*u+n*a+r*s+i*o,V((c&=65535)<<16|(d&=65535),(l&=65535)<<16|(p&=65535),this.unsigned)},T.mul=T.multiply,T.divide=function(t){if(rt(t)||(t=Tt(t)),t.isZero())throw Error("division by zero");var e,n,r;if(pt)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?V((this.unsigned?pt.div_u:pt.div_s)(this.low,this.high,t.low,t.high),pt.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Lt:xt;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Lt;if(t.gt(this.shru(1)))return $o;r=Lt}else{if(this.eq(ut))return t.eq(ne)||t.eq(zr)?ut:t.eq(ut)?ne:(e=this.shr(1).div(t).shl(1)).eq(xt)?t.isNegative()?ne:zr:(n=this.sub(t.mul(e)),r=e.add(n.div(t)));if(t.eq(ut))return this.unsigned?Lt: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();r=xt}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var i=Math.ceil(Math.log(e)/Math.LN2),o=i<=48?1:Xe(2,i-48),s=dt(e),a=s.mul(t);a.isNegative()||a.gt(n);)a=(s=dt(e-=o,this.unsigned)).mul(t);s.isZero()&&(s=ne),r=r.add(s),n=n.sub(a)}return r},T.div=T.divide,T.modulo=function(t){return rt(t)||(t=Tt(t)),pt?V((this.unsigned?pt.rem_u:pt.rem_s)(this.low,this.high,t.low,t.high),pt.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},T.mod=T.modulo,T.rem=T.modulo,T.not=function(){return V(~this.low,~this.high,this.unsigned)},T.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},T.clz=T.countLeadingZeros,T.countTrailingZeros=function(){return this.low?So(this.low):So(this.high)+32},T.ctz=T.countTrailingZeros,T.and=function(t){return rt(t)||(t=Tt(t)),V(this.low&t.low,this.high&t.high,this.unsigned)},T.or=function(t){return rt(t)||(t=Tt(t)),V(this.low|t.low,this.high|t.high,this.unsigned)},T.xor=function(t){return rt(t)||(t=Tt(t)),V(this.low^t.low,this.high^t.high,this.unsigned)},T.shiftLeft=function(t){return rt(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?V(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):V(0,this.low<<t-32,this.unsigned)},T.shl=T.shiftLeft,T.shiftRight=function(t){return rt(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?V(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):V(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},T.shr=T.shiftRight,T.shiftRightUnsigned=function(t){return rt(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?V(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):V(32===t?this.high:this.high>>>t-32,0,this.unsigned)},T.shru=T.shiftRightUnsigned,T.shr_u=T.shiftRightUnsigned,T.rotateLeft=function(t){var e;return rt(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?V(this.high,this.low,this.unsigned):t<32?(e=32-t,V(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)):(e=32-(t-=32),V(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned))},T.rotl=T.rotateLeft,T.rotateRight=function(t){var e;return rt(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?V(this.high,this.low,this.unsigned):t<32?(e=32-t,V(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned)):(e=32-(t-=32),V(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned))},T.rotr=T.rotateRight,T.toSigned=function(){return this.unsigned?V(this.low,this.high,!1):this},T.toUnsigned=function(){return this.unsigned?this:V(this.low,this.high,!0)},T.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},T.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]},T.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]},U.fromBytes=function(t,e,n){return n?U.fromBytesLE(t,e):U.fromBytesBE(t,e)},U.fromBytesLE=function(t,e){return new U(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},U.fromBytesBE=function(t,e){return new U(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)},$t=U})),b,Je=x((()=>{b={},b.Table,b.SIZEOF_SHORT=2,b.SIZEOF_INT=4,b.FILE_IDENTIFIER_LENGTH=4,b.SIZE_PREFIX_LENGTH=4,b.Encoding={UTF8_BYTES:1,UTF16_STRING:2},b.int32=new Int32Array(2),b.float32=new Float32Array(b.int32.buffer),b.float64=new Float64Array(b.int32.buffer),b.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],b.Long=function(t,e){this.low=0|t,this.high=0|e},b.Long.create=function(t,e){return 0==t&&0==e?b.Long.ZERO:new b.Long(t,e)},b.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},b.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},b.Long.ZERO=new b.Long(0,0),b.Builder=function(t){if(t)var e=t;else e=1024;this.bb=b.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},b.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},b.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},b.Builder.prototype.dataBuffer=function(){return this.bb},b.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},b.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 r=this.bb.capacity();this.bb=b.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(n)},b.Builder.prototype.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},b.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},b.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},b.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},b.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},b.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},b.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},b.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},b.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},b.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},b.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},b.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},b.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},b.Builder.prototype.addFieldInt8=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))},b.Builder.prototype.addFieldInt16=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))},b.Builder.prototype.addFieldInt32=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))},b.Builder.prototype.addFieldInt64=function(t,e,n){(this.force_defaults||!e.equals(n))&&(this.addInt64(e),this.slot(t))},b.Builder.prototype.addFieldFloat32=function(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))},b.Builder.prototype.addFieldFloat64=function(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))},b.Builder.prototype.addFieldOffset=function(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))},b.Builder.prototype.addFieldStruct=function(t,e,n){e!=n&&(this.nested(e),this.slot(t))},b.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},b.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},b.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},b.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},b.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,r=b.ByteBuffer.allocate(n);return r.setPosition(n-e),r.bytes().set(t.bytes(),n-e),r},b.Builder.prototype.addOffset=function(t){this.prep(b.SIZEOF_INT,0),this.writeInt32(this.offset()-t+b.SIZEOF_INT)},b.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()},b.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var n=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var r=(n+2)*b.SIZEOF_SHORT;this.addInt16(r);var i=0,o=this.space;t:for(e=0;e<this.vtables.length;e++){var s=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(s)){for(var a=b.SIZEOF_SHORT;a<r;a+=b.SIZEOF_SHORT)if(this.bb.readInt16(o+a)!=this.bb.readInt16(s+a))continue t;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,i-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},b.Builder.prototype.finish=function(t,e,n){var r=n?b.SIZE_PREFIX_LENGTH:0;if(e){var i=e;if(this.prep(this.minalign,b.SIZEOF_INT+b.FILE_IDENTIFIER_LENGTH+r),i.length!=b.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+b.FILE_IDENTIFIER_LENGTH);for(var o=b.FILE_IDENTIFIER_LENGTH-1;o>=0;o--)this.writeInt8(i.charCodeAt(o))}this.prep(this.minalign,b.SIZEOF_INT+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},b.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},b.Builder.prototype.requiredField=function(t,e){var n=this.bb.capacity()-t,r=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(r+e)))throw new Error("FlatBuffers: field "+e+" must be set")},b.Builder.prototype.startVector=function(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(b.SIZEOF_INT,t*e),this.prep(n,t*e)},b.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},b.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var n=0;n<t.length;){var r,i=t.charCodeAt(n++);if(i<55296||i>=56320)r=i;else r=(i<<10)+t.charCodeAt(n++)+-56613888;r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);n=0;for(var o=this.space,s=this.bb.bytes();n<e.length;n++)s[o++]=e[n];return this.endVector()},b.Builder.prototype.createLong=function(t,e){return b.Long.create(t,e)},b.ByteBuffer=function(t){this.bytes_=t,this.position_=0},b.ByteBuffer.allocate=function(t){return new b.ByteBuffer(new Uint8Array(t))},b.ByteBuffer.prototype.clear=function(){this.position_=0},b.ByteBuffer.prototype.bytes=function(){return this.bytes_},b.ByteBuffer.prototype.position=function(){return this.position_},b.ByteBuffer.prototype.setPosition=function(t){this.position_=t},b.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},b.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},b.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},b.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},b.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},b.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},b.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},b.ByteBuffer.prototype.readInt64=function(t){return new b.Long(this.readInt32(t),this.readInt32(t+4))},b.ByteBuffer.prototype.readUint64=function(t){return new b.Long(this.readUint32(t),this.readUint32(t+4))},b.ByteBuffer.prototype.readFloat32=function(t){return b.int32[0]=this.readInt32(t),b.float32[0]},b.ByteBuffer.prototype.readFloat64=function(t){return b.int32[b.isLittleEndian?0:1]=this.readInt32(t),b.int32[b.isLittleEndian?1:0]=this.readInt32(t+4),b.float64[0]},b.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},b.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},b.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},b.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},b.ByteBuffer.prototype.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},b.ByteBuffer.prototype.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},b.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},b.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},b.ByteBuffer.prototype.writeFloat32=function(t,e){b.float32[0]=e,this.writeInt32(t,b.int32[0])},b.ByteBuffer.prototype.writeFloat64=function(t,e){b.float64[0]=e,this.writeInt32(t,b.int32[b.isLittleEndian?0:1]),this.writeInt32(t+4,b.int32[b.isLittleEndian?1:0])},b.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+b.SIZEOF_INT+b.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<b.FILE_IDENTIFIER_LENGTH;e++)t+=String.fromCharCode(this.readInt8(this.position_+b.SIZEOF_INT+e));return t},b.ByteBuffer.prototype.__offset=function(t,e){var n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0},b.ByteBuffer.prototype.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},b.ByteBuffer.prototype.__string=function(t,e){t+=this.readInt32(t);var n=this.readInt32(t),r="",i=0;if(t+=b.SIZEOF_INT,e===b.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+n);for(;i<n;){var o,s=this.readUint8(t+i++);if(s<192)o=s;else{var a=this.readUint8(t+i++);if(s<224)o=(31&s)<<6|63&a;else{var u=this.readUint8(t+i++);if(s<240)o=(15&s)<<12|(63&a)<<6|63&u;else o=(7&s)<<18|(63&a)<<12|(63&u)<<6|63&this.readUint8(t+i++)}}o<65536?r+=String.fromCharCode(o):(o-=65536,r+=String.fromCharCode(55296+(o>>10),56320+(1023&o)))}return r},b.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},b.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+b.SIZEOF_INT},b.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},b.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=b.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+b.FILE_IDENTIFIER_LENGTH);for(var e=0;e<b.FILE_IDENTIFIER_LENGTH;e++)if(t.charCodeAt(e)!=this.readInt8(this.position_+b.SIZEOF_INT+e))return!1;return!0},b.ByteBuffer.prototype.createLong=function(t,e){return b.Long.create(t,e)}})),P,ye=x((()=>{"use strict";Je(),(t=>{let e;(t=>{let e;(t=>{let e;var n;(n=e=t.AttributeType||={})[n.UNDEFINED=0]="UNDEFINED",n[n.FLOAT=1]="FLOAT",n[n.INT=2]="INT",n[n.STRING=3]="STRING",n[n.TENSOR=4]="TENSOR",n[n.GRAPH=5]="GRAPH",n[n.FLOATS=6]="FLOATS",n[n.INTS=7]="INTS",n[n.STRINGS=8]="STRINGS",n[n.TENSORS=9]="TENSORS",n[n.GRAPHS=10]="GRAPHS",n[n.SPARSE_TENSOR=11]="SPARSE_TENSOR",n[n.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(e=t.fbs||={})})(e=t.experimental||={})})(P||={}),(t=>{let e;(t=>{let e;(t=>{let e;var n;(n=e=t.DimensionValueType||={})[n.UNKNOWN=0]="UNKNOWN",n[n.VALUE=1]="VALUE",n[n.PARAM=2]="PARAM"})(e=t.fbs||={})})(e=t.experimental||={})})(P||={}),(t=>{let e;(t=>{let e;(t=>{let e;var n;(n=e=t.TensorDataType||={})[n.UNDEFINED=0]="UNDEFINED",n[n.FLOAT=1]="FLOAT",n[n.UINT8=2]="UINT8",n[n.INT8=3]="INT8",n[n.UINT16=4]="UINT1