UNPKG

dicomweb-pacs

Version:

A self contained easy to use PACS with DICOMWEB and DIMSE service support

2 lines 536 kB
/*! For license information please see ort.min.js.LICENSE.txt */
"use strict";var ort=(()=>{var _d=Object.create,En=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,Id=Object.getOwnPropertyNames,Sd=Object.getPrototypeOf,Ad=Object.prototype.hasOwnProperty,L=(e,t)=>()=>(e&&(t=e(e=0)),t),me=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ar=(e,t)=>{for(var n in t)En(e,n,{get:t[n],enumerable:!0})},qa=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of Id(t))!Ad.call(e,o)&&o!==n&&En(e,o,{get:()=>t[o],enumerable:!(r=Od(t,o))||r.enumerable});return e},Er=(e,t,n)=>(n=null!=e?_d(Sd(e)):{},qa(!t&&e&&e.__esModule?n:En(n,"default",{value:e,enumerable:!0}),e)),jt=e=>qa(En({},"__esModule",{value:!0}),e),Dn,sr,Yt,Ln,Fn=L((()=>{Dn=new Map,sr=[],Yt=(e,t,n)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createInferenceSessionHandler)throw new TypeError("not a valid backend");{let r=Dn.get(e);if(void 0===r)Dn.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=sr.indexOf(e);-1!==t&&sr.splice(t,1);for(let t=0;t<sr.length;t++)if(Dn.get(sr[t]).priority<=n)return void sr.splice(t,0,e);sr.push(e)}}},Ln=async e=>{let t=0===e.length?sr:e,n=[];for(let e of t){let t=Dn.get(e);if(t){if(t.initialized)return t.backend;if(t.aborted)continue;let r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(o){r||n.push({name:e,err:o}),t.aborted=!0}finally{delete t.initPromise}}}throw new Error(`no available backend found. ERR: ${n.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`)}})),ja=L((()=>{Fn()})),Ya,Xa=L((()=>{Ya="1.17.1"})),Ka,ur,Ho=L((()=>{Xa(),Ka="warning",ur={wasm:{},webgl:{},webgpu:{},versions:{common:Ya},set logLevel(e){if(void 0!==e){if("string"!=typeof e||-1===["verbose","info","warning","error","fatal"].indexOf(e))throw new Error(`Unsupported logging level: ${e}`);Ka=e}},get logLevel(){return Ka}},Object.defineProperty(ur,"logLevel",{enumerable:!0})})),Z,Ja=L((()=>{Ho(),Z=ur})),Za,Qa,es=L((()=>{Za=(e,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext("2d");if(null!=r){let o,i;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(o=e.dims[2],i=e.dims[3]):(o=e.dims[3],i=e.dims[2]);let a,s,u=void 0!==t?.format?t.format:"RGB",l=t?.norm;void 0===l||void 0===l.mean?a=[255,255,255,255]:"number"==typeof l.mean?a=[l.mean,l.mean,l.mean,l.mean]:(a=[l.mean[0],l.mean[1],l.mean[2],0],void 0!==l.mean[3]&&(a[3]=l.mean[3])),void 0===l||void 0===l.bias?s=[0,0,0,0]:"number"==typeof l.bias?s=[l.bias,l.bias,l.bias,l.bias]:(s=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(s[3]=l.bias[3]));let c=i*o,p=0,d=c,f=2*c,h=-1;"RGBA"===u?(p=0,d=c,f=2*c,h=3*c):"RGB"===u?(p=0,d=c,f=2*c):"RBG"===u&&(p=0,f=c,d=2*c);for(let t=0;t<i;t++)for(let n=0;n<o;n++){let o=(e.data[p++]-s[0])*a[0],i=(e.data[d++]-s[1])*a[1],u=(e.data[f++]-s[2])*a[2],l=-1===h?255:(e.data[h++]-s[3])*a[3];r.fillStyle="rgba("+o+","+i+","+u+","+l+")",r.fillRect(n,t,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},Qa=(e,t)=>{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 o,i,a;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(o=e.dims[2],i=e.dims[1],a=e.dims[3]):(o=e.dims[3],i=e.dims[2],a=e.dims[1]);let s,u,l=void 0!==t&&void 0!==t.format?t.format:"RGB",c=t?.norm;void 0===c||void 0===c.mean?s=[255,255,255,255]:"number"==typeof c.mean?s=[c.mean,c.mean,c.mean,c.mean]:(s=[c.mean[0],c.mean[1],c.mean[2],255],void 0!==c.mean[3]&&(s[3]=c.mean[3])),void 0===c||void 0===c.bias?u=[0,0,0,0]:"number"==typeof c.bias?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],void 0!==c.bias[3]&&(u[3]=c.bias[3]));let p=i*o;if(void 0!==t&&(void 0!==t.format&&4===a&&"RGBA"!==t.format||3===a&&"RGB"!==t.format&&"BGR"!==t.format))throw new Error("Tensor format doesn't match input tensor dims");let d=4,f=0,h=1,g=2,m=3,b=0,y=p,w=2*p,_=-1;"RGBA"===l?(b=0,y=p,w=2*p,_=3*p):"RGB"===l?(b=0,y=p,w=2*p):"RBG"===l&&(b=0,w=p,y=2*p),n=r.createImageData(o,i);for(let t=0;t<i*o;f+=d,h+=d,g+=d,m+=d,t++)n.data[f]=(e.data[b++]-u[0])*s[0],n.data[h]=(e.data[y++]-u[1])*s[1],n.data[g]=(e.data[w++]-u[2])*s[2],n.data[m]=-1===_?255:(e.data[_++]-u[3])*s[3]}return n}})),qo,ts,rs,ns,os,is=L((()=>{$n(),qo=(e,t)=>{if(void 0===e)throw new Error("Image buffer must be defined");if(void 0===t.height||void 0===t.width)throw new Error("Image height and width must be defined");if("NHWC"===t.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");let n,r,{height:o,width:i}=t,a=t.norm??{mean:255,bias:0};n="number"==typeof a.mean?[a.mean,a.mean,a.mean,a.mean]:[a.mean[0],a.mean[1],a.mean[2],a.mean[3]??255],r="number"==typeof a.bias?[a.bias,a.bias,a.bias,a.bias]:[a.bias[0],a.bias[1],a.bias[2],a.bias[3]??0];let s=void 0!==t.format?t.format:"RGBA",u=void 0!==t.tensorFormat&&void 0!==t.tensorFormat?t.tensorFormat:"RGB",l=o*i,c="RGBA"===u?new Float32Array(4*l):new Float32Array(3*l),p=4,d=0,f=1,h=2,g=3,m=0,b=l,y=2*l,w=-1;"RGB"===s&&(p=3,d=0,f=1,h=2,g=-1),"RGBA"===u?w=3*l:"RBG"===u?(m=0,y=l,b=2*l):"BGR"===u&&(y=0,b=l,m=2*l);for(let t=0;t<l;t++,d+=p,h+=p,f+=p,g+=p)c[m++]=(e[d]+r[0])/n[0],c[b++]=(e[f]+r[1])/n[1],c[y++]=(e[h]+r[2])/n[2],-1!==w&&-1!==g&&(c[w++]=(e[g]+r[3])/n[3]);return new Ye("float32",c,"RGBA"===u?[1,4,o,i]:[1,3,o,i])},ts=async(e,t)=>{let n,r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,o=typeof ImageData<"u"&&e instanceof ImageData,i=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,a="string"==typeof e,s=t??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=e=>e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext("2d"):null;if(r){let r=u();r.width=e.width,r.height=e.height;let o=l(r);if(null==o)throw new Error("Can not access image data");{let r=e.height,i=e.width;if(void 0!==t&&void 0!==t.resizedHeight&&void 0!==t.resizedWidth&&(r=t.resizedHeight,i=t.resizedWidth),void 0!==t){if(s=t,void 0!==t.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");s.tensorFormat="RGBA",s.height=r,s.width=i}else s.tensorFormat="RGBA",s.height=r,s.width=i;o.drawImage(e,0,0),n=o.getImageData(0,0,i,r).data}}else{if(!o){if(i){if(void 0===t)throw new Error("Please provide image config with format for Imagebitmap");let r=u();r.width=e.width,r.height=e.height;let o=l(r);if(null!=o){let t=e.height,r=e.width;return o.drawImage(e,0,0,r,t),n=o.getImageData(0,0,r,t).data,s.height=t,s.width=r,qo(n,s)}throw new Error("Can not access image data")}if(a)return new Promise(((t,n)=>{let r=u(),o=l(r);if(!e||!o)return n();let i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>{r.width=i.width,r.height=i.height,o.drawImage(i,0,0,r.width,r.height);let e=o.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(qo(e.data,s))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let r,o;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(r=t.resizedHeight,o=t.resizedWidth):(r=e.height,o=e.width),void 0!==t&&(s=t),s.format="RGBA",s.height=r,s.width=o,void 0!==t){let t=u();t.width=o,t.height=r;let i=l(t);if(null==i)throw new Error("Can not access image data");i.putImageData(e,0,0),n=i.getImageData(0,0,o,r).data}else n=e.data}}if(void 0!==n)return qo(n,s);throw new Error("Input data provided is not supported - aborted tensor creation")},rs=(e,t)=>{let{width:n,height:r,download:o,dispose:i}=t;return new Ye({location:"texture",type:"float32",texture:e,dims:[1,r,n,4],download:o,dispose:i})},ns=(e,t)=>{let{dataType:n,dims:r,download:o,dispose:i}=t;return new Ye({location:"gpu-buffer",type:n??"float32",gpuBuffer:e,dims:r,download:o,dispose:i})},os=(e,t,n)=>new Ye({location:"cpu-pinned",type:e,data:t,dims:n??[t.length]})})),Qr,Cn,as,ss,us=L((()=>{Qr=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),Cn=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),as=!1,ss=()=>{if(!as){as=!0;let e=typeof BigInt64Array<"u"&&"function"==typeof BigInt64Array.from,t=typeof BigUint64Array<"u"&&"function"==typeof BigUint64Array.from;e&&(Qr.set("int64",BigInt64Array),Cn.set(BigInt64Array,"int64")),t&&(Qr.set("uint64",BigUint64Array),Cn.set(BigUint64Array,"uint64"))}}})),ls,fs,cs=L((()=>{$n(),ls=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[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}`);t*=r}return t},fs=(e,t)=>{switch(e.location){case"cpu":return new Ye(e.type,e.data,t);case"cpu-pinned":return new Ye({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new Ye({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new Ye({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}})),Ye,$n=L((()=>{es(),is(),us(),cs(),Ye=class{constructor(e,t,n){let r,o;if(ss(),"object"==typeof e&&"location"in e)switch(this.dataLocation=e.location,r=e.type,o=e.dims,e.location){case"cpu-pinned":{let t=Qr.get(r);if(!t)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw new TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case"texture":if("float32"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.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=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let i,a;if("string"==typeof e)if(r=e,a=n,"string"===e){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");i=t}else{let n=Qr.get(e);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if("float16"===e)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");i="uint64"===e||"int64"===e?n.from(t,BigInt):n.from(t)}else{if(!(t instanceof n))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);i=t}}else if(a=t,Array.isArray(e)){if(0===e.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");let t=typeof e[0];if("string"===t)r="string",i=e;else{if("boolean"!==t)throw new TypeError(`Invalid element type of data array: ${t}.`);r="bool",i=Uint8Array.from(e)}}else{let t=Cn.get(e.constructor);if(void 0===t)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,i=e}if(void 0===a)a=[i.length];else if(!Array.isArray(a))throw new TypeError("A tensor's dims must be a number array");o=a,this.cpuData=i,this.dataLocation="cpu"}let i=ls(o);if(this.cpuData&&i!==this.cpuData.length)throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=o,this.size=i}static async fromImage(e,t){return ts(e,t)}static fromTexture(e,t){return rs(e,t)}static fromGpuBuffer(e,t){return ns(e,t)}static fromPinnedBuffer(e,t,n){return os(e,t,n)}toDataURL(e){return Za(this,e)}toImageData(e){return Qa(this,e)}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(e){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 t=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}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(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return fs(this,e)}}})),ke,kn=L((()=>{$n(),ke=Ye})),jo,ps,Xt,Kt,Yo=L((()=>{Ho(),jo=(e,t)=>{ur.wasm.trace&&console.timeStamp(`${e}::ORT::${t}`)},ps=(e,t)=>{let n=(new Error).stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let o=0;o<n.length;o++){if(r&&!n[o].includes("TRACE_FUNC")){let r=`FUNC_${e}::${n[o].trim().split(" ")[1]}`;return t&&(r+=`::${t}`),void jo("CPU",r)}n[o].includes("TRACE_FUNC")&&(r=!0)}},Xt=e=>{ur.wasm.trace&&ps("BEGIN",e)},Kt=e=>{ur.wasm.trace&&ps("END",e)}})),Bn,ds=L((()=>{Fn(),kn(),Yo(),Bn=class e{constructor(e){this.handler=e}async run(e,t,n){Xt();let r={},o={};if("object"!=typeof e||null===e||e instanceof ke||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if("object"==typeof t){if(null===t)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof ke)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(0===t.length)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(let e of t){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if("object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,a=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(-1!==a.indexOf(n)){let o=t[n];(null===o||o instanceof ke)&&(e=!0,i=!1,r[n]=o)}if(e){if("object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else o=t}}else if(typeof t<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of this.inputNames)if(typeof e[t]>"u")throw new Error(`input '${t}' is missing in 'feeds'.`);if(i)for(let e of this.outputNames)r[e]=null;let a=await this.handler.run(e,r,o),s={};for(let e in a)if(Object.hasOwnProperty.call(a,e)){let t=a[e];s[e]=t instanceof ke?t:new ke(t.type,t.data,t.dims)}return Kt(),s}async release(){return this.handler.dispose()}static async create(t,n,r,o){Xt();let i,a={};if("string"==typeof t){if(i=t,"object"==typeof n&&null!==n)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(i=t,"object"==typeof n&&null!==n)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{if(!(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{let e=t,s=0,u=t.byteLength;if("object"==typeof n&&null!==n)a=n;else if("number"==typeof n){if(s=n,!Number.isSafeInteger(s))throw new RangeError("'byteOffset' must be an integer.");if(s<0||s>=e.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(u=t.byteLength-s,"number"==typeof r){if(u=r,!Number.isSafeInteger(u))throw new RangeError("'byteLength' must be an integer.");if(u<=0||s+u>e.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if("object"==typeof o&&null!==o)a=o;else if(typeof o<"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.");i=new Uint8Array(e,s,u)}}let s=(a.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),u=await(await Ln(s)).createInferenceSessionHandler(i,a);return Kt(),new e(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}})),hs,ms=L((()=>{ds(),hs=Bn})),bs=L((()=>{})),Pd,Nn,gs=L((()=>{Fn(),kn(),Pd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Nn=class e{constructor(e,t,n){this.handler=e,this.hasOptimizerModel=t,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(t,n){let r=t.evalModel||"",o=t.optimizerModel||"",i=n||{},a=(i.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),s=await Ln(a);if(s.createTrainingSessionHandler){let n=await s.createTrainingSessionHandler(t.checkpointState,t.trainModel,r,o,i);return new e(n,!!t.optimizerModel,!!t.evalModel)}throw new Error(Pd)}typeNarrowingForRunStep(e,t,n,r,o){let i={},a={};if("object"!=typeof n||null===n||n instanceof ke||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if("object"==typeof r){if(null===r)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof ke)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.");s=!1;for(let e of r){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===t.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);i[e]=null}if("object"==typeof o&&null!==o)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,n=Object.getOwnPropertyNames(r);for(let o of t)if(-1!==n.indexOf(o)){let t=r[o];(null===t||t instanceof ke)&&(e=!0,s=!1,i[o]=t)}if(e){if("object"==typeof o&&null!==o)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else a=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of e)if(typeof n[t]>"u")throw new Error(`input '${t}' is missing in 'feeds'.`);if(s)for(let e of t)i[e]=null;return[i,a]}convertHandlerReturnTypeToMapOfTensors(e){let t={};for(let n in e)if(Object.hasOwnProperty.call(e,n)){let r=e[n];t[n]=r instanceof ke?r:new ke(r.type,r.data,r.dims)}return t}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,t,n){let[r,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,t,n),i=await this.handler.runTrainStep(e,r,o);return this.convertHandlerReturnTypeToMapOfTensors(i)}async runOptimizerStep(e){if(!this.hasOptimizerModel)throw new Error("This TrainingSession has no OptimizerModel loaded.");await this.handler.runOptimizerStep(e||{})}async runEvalStep(e,t,n){if(this.hasEvalModel){let[r,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,t,n),i=await this.handler.runEvalStep(e,r,o);return this.convertHandlerReturnTypeToMapOfTensors(i)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(e=!0){return this.handler.getParametersSize(e)}async loadParametersBuffer(e,t=!0){let n=await this.getParametersSize(t);if(e.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(e,t)}async getContiguousParameters(e=!0){return this.handler.getContiguousParameters(e)}async release(){return this.handler.dispose()}}})),ys,Ts=L((()=>{gs(),ys=Nn})),Xo={};ar(Xo,{InferenceSession:()=>hs,TRACE:()=>jo,TRACE_FUNC_BEGIN:()=>Xt,TRACE_FUNC_END:()=>Kt,Tensor:()=>ke,TrainingSession:()=>ys,env:()=>Z,registerBackend:()=>Yt});var vt=L((()=>{ja(),Ja(),ms(),kn(),Yo(),bs(),Ts()}));function Jt(e,t,n,r){if(void 0===t)return Dd(e);if(void 0===n)Rn(e,t,1);else if("number"==typeof n&&void 0===r)Rn(e,t,n);else if("string"==typeof n&&void 0===r)Rn(e,n,1,t);else{if("string"!=typeof n||"number"!=typeof r)throw new TypeError("input is valid");Rn(e,n,r,t)}}function Dd(e){return{verbose:Jt.verbose.bind(null,e),info:Jt.info.bind(null,e),warning:Jt.warning.bind(null,e),error:Jt.error.bind(null,e),fatal:Jt.fatal.bind(null,e)}}function Rn(e,t,n,r){let o=en[r||""]||en[""];vs[e]<vs[o.minimalSeverity]||(o.logDateTime&&(t=`${(new Date).toISOString()}|${t}`),o.logSourceLocation,Ed[o.provider].log(e,t,r))}var Ko,Jo,vs,Ed,ws,en,ce,Gn,Un,zn,Mn,ut=L((()=>{Ko=class{log(e,t,n){}},Jo=class{log(e,t,n){console.log(`${this.color(e)} ${n?""+n+" ":""}${t}`)}color(e){switch(e){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: ${e}`)}}},vs={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Ed={none:new Ko,console:new Jo},en={"":ws={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(e=>{function t(e){en={},n("",e||{})}function n(e,n){if("*"===e)t(n);else{let t=en[e]||ws;en[e]={provider:n.provider||t.provider,minimalSeverity:n.minimalSeverity||t.minimalSeverity,logDateTime:void 0===n.logDateTime?t.logDateTime:n.logDateTime,logSourceLocation:void 0===n.logSourceLocation?t.logSourceLocation:n.logSourceLocation}}}e.verbose=function(t,n){e("verbose",t,n)},e.info=function(t,n){e("info",t,n)},e.warning=function(t,n){e("warning",t,n)},e.error=function(t,n){e("error",t,n)},e.fatal=function(t,n){e("fatal",t,n)},e.reset=t,e.set=n,e.setWithEnv=function(e){let t={};e.logLevel&&(t.minimalSeverity=e.logLevel),n("",t)}})(Jt||={}),ce=Jt,Gn=class{constructor(e,t,n,r,o,i){this.category=e,this.name=t,this.startTime=n,this.endCallback=r,this.timer=o,this.ctx=i}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)}},Un=class{constructor(e,t,n,r){this.category=e,this.name=t,this.startTime=n,this.endTime=r}},zn=class{constructor(e,t,n){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=void 0===e?1e4:e,this._flushBatchSize=void 0===t?10:t,this._flushIntervalInMilliseconds=void 0===n?5e3:n}static create(e){return void 0===e?new this:new this(e.maxNumberEvents,e.flushBatchSize,e.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=Mn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,t,n,r){let o=this._started?this.begin(e,t,r):void 0,i=!1,a=n();if(a&&"function"==typeof a.then)return i=!0,new Promise(((e,t)=>{a.then((async t=>{o&&await o.end(),e(t)}),(async e=>{o&&await o.end(),t(e)}))}));if(!i&&o){let e=o.end();if(e&&"function"==typeof e.then)return new Promise(((t,n)=>{e.then((()=>{t(a)}),(e=>{n(e)}))}))}return a}begin(e,t,n){if(!this._started)throw new Error("profiler is not started yet");if(void 0===n){let n=Mn();return this.flush(n),new Gn(e,t,n,(e=>this.endSync(e)))}{let r=n.beginTimer();return new Gn(e,t,0,(async e=>this.end(e)),r,n)}}async end(e){let t=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Un(e.category,e.name,e.startTime,t)),this.flush(t))}endSync(e){let t=Mn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Un(e.category,e.name,e.startTime,t)),this.flush(t))}logOneEvent(e){ce.verbose(`Profiler.${e.category}`,`${(e.endTime-e.startTime).toFixed(2)}ms on event '${e.name}' at ${e.endTime.toFixed(2)}`)}flush(e){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||e-this._flushTime>=this._flushIntervalInMilliseconds){for(let e=this._flushPointer;this._flushPointer<e+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=Mn()}}get started(){return this._started}},Mn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now}));function _s(e,t,n){for(let r of n){let n=r[0],o=r[1],i=r[2],a=r[3],s=r[4];if(e.opType===n)for(let e of t)if((e.domain===o||"ai.onnx"===e.domain&&""===o)&&Ld(e.version,i))return{opImpl:a,opInit:s}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${t.map((e=>`${e.domain||"ai.onnx"} v${e.version}`)).join(", ")}`)}function Ld(e,t){if(t.endsWith("+")){let n=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(n)&&n<=e}if(2===t.split("-").length){let n=t.split("-"),r=Number.parseInt(n[0],10),o=Number.parseInt(n[1],10);return!isNaN(r)&&!isNaN(o)&&r<=e&&e<=o}return Number.parseInt(t,10)===e}var Os=L((()=>{})),Is=me((e=>{e.__esModule=!0;var t=function(){function e(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=e.EMPTY,t&&e.isGuid(t)&&(this.value=t)}return e.isGuid=function(t){var n=t.toString();return t&&(t instanceof e||e.validator.test(n))},e.create=function(){return new e([e.gen(2),e.gen(1),e.gen(1),e.gen(1),e.gen(3)].join("-"))},e.createEmpty=function(){return new e("emptyguid")},e.parse=function(t){return new e(t)},e.raw=function(){return[e.gen(2),e.gen(1),e.gen(1),e.gen(1),e.gen(3)].join("-")},e.gen=function(e){for(var t="",n=0;n<e;n++)t+=(65536*(1+Math.random())|0).toString(16).substring(1);return t},e.prototype.equals=function(t){return e.isGuid(t)&&this.value===t.toString()},e.prototype.isEmpty=function(){return this.value===e.EMPTY},e.prototype.toString=function(){return this.value},e.prototype.toJSON=function(){return{value:this.value}},e.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),e.EMPTY="00000000-0000-0000-0000-000000000000",e}();e.Guid=t}));function be(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function We(e){return!0===(e&&e.__isLong__)}function Ss(e){var t=Math.clz32(e&-e);return e?31-t:t}function lr(e,t){var n,r,o;return t?(o=0<=(e>>>=0)&&e<256)&&(r=Ps[e])?r:(n=le(e,0,!0),o&&(Ps[e]=n),n):(o=-128<=(e|=0)&&e<128)&&(r=As[e])?r:(n=le(e,e<0?-1:0,!1),o&&(As[e]=n),n)}function ft(e,t){if(isNaN(e))return t?Ut:wt;if(t){if(e<0)return Ut;if(e>=Fs)return ks}else{if(e<=-Ds)return tt;if(e+1>=Ds)return Cs}return e<0?ft(-e,t).neg():le(e%Lr|0,e/Lr|0,t)}function le(e,t,n){return new be(e,t,n)}function ei(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?Ut:wt;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return ei(e.substring(1),t,n).neg();for(var o=ft(Vn(n,8)),i=wt,a=0;a<e.length;a+=8){var s=Math.min(8,e.length-a),u=parseInt(e.substring(a,a+s),n);if(s<8){var l=ft(Vn(n,s));i=i.mul(l).add(ft(u))}else i=(i=i.mul(o)).add(ft(u))}return i.unsigned=t,i}function _t(e,t){return"number"==typeof e?ft(e,t):"string"==typeof e?ei(e,t):le(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}var lt,As,Ps,Vn,Es,$d,Lr,Fs,Ds,Ls,wt,Ut,Dr,$s,Qo,Cs,ks,tt,$,zt,ti=L((()=>{lt=null;try{lt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}be.prototype.__isLong__,Object.defineProperty(be.prototype,"__isLong__",{value:!0}),be.isLong=We,As={},Ps={},be.fromInt=lr,be.fromNumber=ft,be.fromBits=le,Vn=Math.pow,be.fromString=ei,be.fromValue=_t,Ds=(Fs=(Lr=(Es=65536)*Es)*Lr)/2,Ls=lr($d=1<<24),wt=lr(0),be.ZERO=wt,Ut=lr(0,!0),be.UZERO=Ut,Dr=lr(1),be.ONE=Dr,$s=lr(1,!0),be.UONE=$s,Qo=lr(-1),be.NEG_ONE=Qo,Cs=le(-1,2147483647,!1),be.MAX_VALUE=Cs,ks=le(-1,-1,!0),be.MAX_UNSIGNED_VALUE=ks,tt=le(0,-2147483648,!1),be.MIN_VALUE=tt,($=be.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*Lr+(this.low>>>0):this.high*Lr+(this.low>>>0)},$.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(tt)){var t=ft(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=ft(Vn(e,6),this.unsigned),i=this,a="";;){var s=i.div(o),u=(i.sub(s.mul(o)).toInt()>>>0).toString(e);if((i=s).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tt)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},$.isZero=function(){return 0===this.high&&0===this.low},$.eqz=$.isZero,$.isNegative=function(){return!this.unsigned&&this.high<0},$.isPositive=function(){return this.unsigned||this.high>=0},$.isOdd=function(){return!(1&~this.low)},$.isEven=function(){return!(1&this.low)},$.equals=function(e){return We(e)||(e=_t(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},$.eq=$.equals,$.notEquals=function(e){return!this.eq(e)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(e){return this.comp(e)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(e){return this.comp(e)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(e){return this.comp(e)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(e){return this.comp(e)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(e){if(We(e)||(e=_t(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(tt)?tt:this.not().add(Dr)},$.neg=$.negate,$.add=function(e){We(e)||(e=_t(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,i=e.high>>>16,a=65535&e.high,s=e.low>>>16,u=0,l=0,c=0,p=0;return c+=(p+=o+(65535&e.low))>>>16,l+=(c+=r+s)>>>16,u+=(l+=n+a)>>>16,u+=t+i,le((c&=65535)<<16|(p&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},$.subtract=function(e){return We(e)||(e=_t(e)),this.add(e.neg())},$.sub=$.subtract,$.multiply=function(e){if(this.isZero())return this;if(We(e)||(e=_t(e)),lt)return le(lt.mul(this.low,this.high,e.low,e.high),lt.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Ut:wt;if(this.eq(tt))return e.isOdd()?tt:wt;if(e.eq(tt))return this.isOdd()?tt:wt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Ls)&&e.lt(Ls))return ft(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,i=e.high>>>16,a=65535&e.high,s=e.low>>>16,u=65535&e.low,l=0,c=0,p=0,d=0;return p+=(d+=o*u)>>>16,c+=(p+=r*u)>>>16,p&=65535,c+=(p+=o*s)>>>16,l+=(c+=n*u)>>>16,c&=65535,l+=(c+=r*s)>>>16,c&=65535,l+=(c+=o*a)>>>16,l+=t*u+n*s+r*a+o*i,le((p&=65535)<<16|(d&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},$.mul=$.multiply,$.divide=function(e){if(We(e)||(e=_t(e)),e.isZero())throw Error("division by zero");var t,n,r;if(lt)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?le((this.unsigned?lt.div_u:lt.div_s)(this.low,this.high,e.low,e.high),lt.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Ut:wt;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Ut;if(e.gt(this.shru(1)))return $s;r=Ut}else{if(this.eq(tt))return e.eq(Dr)||e.eq(Qo)?tt:e.eq(tt)?Dr:(t=this.shr(1).div(e).shl(1)).eq(wt)?e.isNegative()?Dr:Qo:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(tt))return this.unsigned?Ut:wt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=wt}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:Vn(2,o-48),a=ft(t),s=a.mul(e);s.isNegative()||s.gt(n);)s=(a=ft(t-=i,this.unsigned)).mul(e);a.isZero()&&(a=Dr),r=r.add(a),n=n.sub(s)}return r},$.div=$.divide,$.modulo=function(e){return We(e)||(e=_t(e)),lt?le((this.unsigned?lt.rem_u:lt.rem_s)(this.low,this.high,e.low,e.high),lt.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return le(~this.low,~this.high,this.unsigned)},$.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},$.clz=$.countLeadingZeros,$.countTrailingZeros=function(){return this.low?Ss(this.low):Ss(this.high)+32},$.ctz=$.countTrailingZeros,$.and=function(e){return We(e)||(e=_t(e)),le(this.low&e.low,this.high&e.high,this.unsigned)},$.or=function(e){return We(e)||(e=_t(e)),le(this.low|e.low,this.high|e.high,this.unsigned)},$.xor=function(e){return We(e)||(e=_t(e)),le(this.low^e.low,this.high^e.high,this.unsigned)},$.shiftLeft=function(e){return We(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?le(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):le(0,this.low<<e-32,this.unsigned)},$.shl=$.shiftLeft,$.shiftRight=function(e){return We(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?le(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):le(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(e){return We(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?le(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):le(32===e?this.high:this.high>>>e-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.rotateLeft=function(e){var t;return We(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?le(this.high,this.low,this.unsigned):e<32?(t=32-e,le(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),le(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},$.rotl=$.rotateLeft,$.rotateRight=function(e){var t;return We(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?le(this.high,this.low,this.unsigned):e<32?(t=32-e,le(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),le(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},$.rotr=$.rotateRight,$.toSigned=function(){return this.unsigned?le(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:le(this.low,this.high,!0)},$.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},$.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},$.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},be.fromBytes=function(e,t,n){return n?be.fromBytesLE(e,t):be.fromBytesBE(e,t)},be.fromBytesLE=function(e,t){return new be(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},be.fromBytesBE=function(e,t){return new be(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},zt=be})),_,Wn=L((()=>{_={},_.Table,_.SIZEOF_SHORT=2,_.SIZEOF_INT=4,_.FILE_IDENTIFIER_LENGTH=4,_.SIZE_PREFIX_LENGTH=4,_.Encoding={UTF8_BYTES:1,UTF16_STRING:2},_.int32=new Int32Array(2),_.float32=new Float32Array(_.int32.buffer),_.float64=new Float64Array(_.int32.buffer),_.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],_.Long=function(e,t){this.low=0|e,this.high=0|t},_.Long.create=function(e,t){return 0==e&&0==t?_.Long.ZERO:new _.Long(e,t)},_.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},_.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},_.Long.ZERO=new _.Long(0,0),_.Builder=function(e){if(e)var t=e;else t=1024;this.bb=_.ByteBuffer.allocate(t),this.space=t,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},_.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},_.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},_.Builder.prototype.dataBuffer=function(){return this.bb},_.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},_.Builder.prototype.prep=function(e,t){e>this.minalign&&(this.minalign=e);for(var n=1+~(this.bb.capacity()-this.space+t)&e-1;this.space<n+e+t;){var r=this.bb.capacity();this.bb=_.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(n)},_.Builder.prototype.pad=function(e){for(var t=0;t<e;t++)this.bb.writeInt8(--this.space,0)},_.Builder.prototype.writeInt8=function(e){this.bb.writeInt8(this.space-=1,e)},_.Builder.prototype.writeInt16=function(e){this.bb.writeInt16(this.space-=2,e)},_.Builder.prototype.writeInt32=function(e){this.bb.writeInt32(this.space-=4,e)},_.Builder.prototype.writeInt64=function(e){this.bb.writeInt64(this.space-=8,e)},_.Builder.prototype.writeFloat32=function(e){this.bb.writeFloat32(this.space-=4,e)},_.Builder.prototype.writeFloat64=function(e){this.bb.writeFloat64(this.space-=8,e)},_.Builder.prototype.addInt8=function(e){this.prep(1,0),this.writeInt8(e)},_.Builder.prototype.addInt16=function(e){this.prep(2,0),this.writeInt16(e)},_.Builder.prototype.addInt32=function(e){this.prep(4,0),this.writeInt32(e)},_.Builder.prototype.addInt64=function(e){this.prep(8,0),this.writeInt64(e)},_.Builder.prototype.addFloat32=function(e){this.prep(4,0),this.writeFloat32(e)},_.Builder.prototype.addFloat64=function(e){this.prep(8,0),this.writeFloat64(e)},_.Builder.prototype.addFieldInt8=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))},_.Builder.prototype.addFieldInt16=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))},_.Builder.prototype.addFieldInt32=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))},_.Builder.prototype.addFieldInt64=function(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))},_.Builder.prototype.addFieldFloat32=function(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))},_.Builder.prototype.addFieldFloat64=function(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))},_.Builder.prototype.addFieldOffset=function(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))},_.Builder.prototype.addFieldStruct=function(e,t,n){t!=n&&(this.nested(t),this.slot(e))},_.Builder.prototype.nested=function(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},_.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},_.Builder.prototype.slot=function(e){this.vtable[e]=this.offset()},_.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},_.Builder.growByteBuffer=function(e){var t=e.capacity();if(3221225472&t)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var n=t<<1,r=_.ByteBuffer.allocate(n);return r.setPosition(n-t),r.bytes().set(e.bytes(),n-t),r},_.Builder.prototype.addOffset=function(e){this.prep(_.SIZEOF_INT,0),this.writeInt32(this.offset()-e+_.SIZEOF_INT)},_.Builder.prototype.startObject=function(e){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=e;for(var t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()},_.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var e=this.offset(),t=this.vtable_in_use-1;t>=0&&0==this.vtable[t];t--);for(var n=t+1;t>=0;t--)this.addInt16(0!=this.vtable[t]?e-this.vtable[t]:0);this.addInt16(e-this.object_start);var r=(n+2)*_.SIZEOF_SHORT;this.addInt16(r);var o=0,i=this.space;e:for(t=0;t<this.vtables.length;t++){var a=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(a)){for(var s=_.SIZEOF_SHORT;s<r;s+=_.SIZEOF_SHORT)if(this.bb.readInt16(i+s)!=this.bb.readInt16(a+s))continue e;o=this.vtables[t];break}}return o?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,o-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e},_.Builder.prototype.finish=function(e,t,n){var r=n?_.SIZE_PREFIX_LENGTH:0;if(t){var o=t;if(this.prep(this.minalign,_.SIZEOF_INT+_.FILE_IDENTIFIER_LENGTH+r),o.length!=_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+_.FILE_IDENTIFIER_LENGTH);for(var i=_.FILE_IDENTIFIER_LENGTH-1;i>=0;i--)this.writeInt8(o.charCodeAt(i))}this.prep(this.minalign,_.SIZEOF_INT+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},_.Builder.prototype.finishSizePrefixed=function(e,t){this.finish(e,t,!0)},_.Builder.prototype.requiredField=function(e,t){var n=this.bb.capacity()-e,r=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(r+t)))throw new Error("FlatBuffers: field "+t+" must be set")},_.Builder.prototype.startVector=function(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(_.SIZEOF_INT,e*t),this.prep(n,e*t)},_.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},_.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var t=e;else{t=[];for(var n=0;n<e.length;){var r,o=e.charCodeAt(n++);if(o<55296||o>=56320)r=o;else r=(o<<10)+e.charCodeAt(n++)+-56613888;r<128?t.push(r):(r<2048?t.push(r>>6&31|192):(r<65536?t.push(r>>12&15|224):t.push(r>>18&7|240,r>>12&63|128),t.push(r>>6&63|128)),t.push(63&r|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);n=0;for(var i=this.space,a=this.bb.bytes();n<t.length;n++)a[i++]=t[n];return this.endVector()},_.Builder.prototype.createLong=function(e,t){return _.Long.create(e,t)},_.ByteBuffer=function(e){this.bytes_=e,this.position_=0},_.ByteBuffer.allocate=function(e){return new _.ByteBuffer(new Uint8Array(e))},_.ByteBuffer.prototype.clear=function(){this.position_=0},_.ByteBuffer.prototype.bytes=function(){return this.bytes_},_.ByteBuffer.prototype.position=function(){return this.position_},_.ByteBuffer.prototype.setPosition=function(e){this.position_=e},_.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},_.ByteBuffer.prototype.readInt8=function(e){return this.readUint8(e)<<24>>24},_.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},_.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},_.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},_.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},_.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},_.ByteBuffer.prototype.readInt64=function(e){return new _.Long(this.readInt32(e),this.readInt32(e+4))},_.ByteBuffer.prototype.readUint64=function(e){return new _.Long(this.readUint32(e),this.readUint32(e+4))},_.ByteBuffer.prototype.readFloat32=function(e){return _.int32[0]=this.readInt32(e),_.float32[0]},_.ByteBuffer.prototype.readFloat64=function(e){return _.int32[_.isLittleEndian?0:1]=this.readInt32(e),_.int32[_.isLittleEndian?1:0]=this.readInt32(e+4),_.float64[0]},_.ByteBuffer.prototype.writeInt8=function(e,t){this.bytes_[e]=t},_.ByteBuffer.prototype.writeUint8=function(e,t){this.bytes_[e]=t},_.ByteBuffer.prototype.writeInt16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},_.ByteBuffer.prototype.writeUint16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},_.ByteBuffer.prototype.writeInt32=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24},_.ByteBuffer.prototype.writeUint32=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24},_.ByteBuffer.prototype.writeInt64=function(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)},_.ByteBuffer.prototype.writeUint64=function(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)},_.ByteBuffer.prototype.writeFloat32=function(e,t){_.float32[0]=t,this.writeInt32(e,_.int32[0])},_.ByteBuffer.prototype.writeFloat64=function(e,t){_.float64[0]=t,this.writeInt32(e,_.int32[_.isLittleEndian?0:1]),this.writeInt32(e+4,_.int32[_.isLittleEndian?1:0])},_.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+_.SIZEOF_INT+_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var e="",t=0;t<_.FILE_IDENTIFIER_LENGTH;t++)e+=String.fromCharCode(this.readInt8(this.position_+_.SIZEOF_INT+t));return e},_.ByteBuffer.prototype.__offset=function(e,t){var n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0},_.ByteBuffer.prototype.__union=function(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e},_.ByteBuffer.prototype.__string=function(e,t){e+=this.readInt32(e);var n=this.readInt32(e),r="",o=0;if(e+=_.SIZEOF_INT,t===_.Encoding.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;o<n;){var i,a=this.readUint8(e+o++);if(a<192)i=a;else{var s=this.readUint8(e+o++);if(a<224)i=(31&a)<<6|63&s;else{var u=this.readUint8(e+o++);if(a<240)i=(15&a)<<12|(63&s)<<6|63&u;else i=(7&a)<<18|(63&s)<<12|(63&u)<<6|63&this.readUint8(e+o++)}}i<65536?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296+(i>>10),56320+(1023&i)))}return r},_.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},_.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+_.SIZEOF_INT},_.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},_.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+_.FILE_IDENTIFIER_LENGTH);for(var t=0;t<_.FILE_IDENTIFIER_LENGTH;t++)if(e.charCodeAt(t)!=this.readInt8(this.position_+_.SIZEOF_INT+t))return!1;return!0},_.ByteBuffer.prototype.createLong=function(e,t){return _.Long.create(e,t)}})),W,tn=L((()=>{Wn(),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.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"})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.DimensionValueType||={})[n.UNKNOWN=0]="UNKNOWN",n[n.VALUE=1]="VALUE",n[n.PARAM=2]="PARAM"})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.TensorDataType||={})[n.UNDEFINED=0]="UNDEFINED",n[n.FLOAT=1]="FLOAT",n[n.UINT8=2]="UINT8",n[n.INT8=3]="INT8",n[n.UINT16=4]="UINT16",n[n.INT16=5]="INT16",n[n.INT32=6]="INT32",n[n.INT64=7]="INT64",n[n.STRING=8]="STRING",n[n.BOOL=9]="BOOL",n[n.FLOAT16=10]="FLOAT16",n[n.DOUBLE=11]="DOUBLE",n[n.UINT32=12]="UINT32",n[n.UINT64=13]="UINT64",n[n.COMPLEX64=14]="COMPLEX64",n[n.COMPLEX128=15]="COMPLEX128",n[n.BFLOAT16=16]="BFLOAT16",n[n.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",n[n.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",n[n.FLOAT8E5M2=19]="FLOAT8E5M2",n[n.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.NodeType||={})[n.Primitive=0]="Primitive",n[n.Fused=1]="Fused"})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.TypeInfoValue||={})[n.NONE=0]="NONE",n[n.tensor_type=1]="tensor_type",n[n.sequence_type=2]="sequence_type",n[n.map_type=3]="map_type"})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsShape(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsShape(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}dim(t,n){let r=this.bb.__offset(this.bb_pos,4);return r?(n||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}dimLength(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__vector_len(this.bb_pos+e):0}static startShape(e){e.startObject(1)}static addDim(e,t){e.addFieldOffset(0,t,0)}static createDimVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startDimVector(e,t){e.startVector(4,t,4)}static endShape(e){return e.endObject()}static createShape(e,t){return n.startShape(e),n.addDim(e,t),n.endShape(e)}}t.Shape=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDimension(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDimension(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}value(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}denotation(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startDimension(e){e.startObject(2)}static addValue(e,t){e.addFieldOffset(0,t,0)}static addDenotation(e,t){e.addFieldOffset(1,t,0)}static endDimension(e){return e.endObject()}static createDimension(e,t,r){return n.startDimension(e),n.addValue(e,t),n.addDenotation(e,r),n.endDimension(e)}}t.Dimension=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDimensionValue(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDimensionValue(e,n){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}dimType(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):0}dimValue(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}dimParam(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}static startDimensionValue(e){e.startObject(3)}static addDimType(e,t){e.addFieldInt8(0,t,0)}static addDimValue(e,t){e.addFieldInt64(1,t,e.createLong(0,0))}static addDimParam(e,t){e.addFieldOffset(2,t,0)}static endDimensionValue(e){return e.endObject()}static createDimensionValue(e,n,r,o){return t.startDimensionValue(e),t.addDimType(e,n),t.addDimValue(e,r),t.addDimParam(e,o),t.endDimensionValue(e)}}e.DimensionValue=t})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTensorTypeAndShape(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTensorTypeAndShape(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}elemType(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}shape(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startTensorTypeAndShape(e){e.startObject(2)}static addElemType(e,t){e.addFieldInt32(0,t,0)}static addShape(e,t){e.addFieldOffset(1,t,0)}static endTensorTypeAndShape(e){return e.endObject()}static createTensorTypeAndShape(e,t,r){return n.startTensorTypeAndShape(e),n.addElemType(e,t),n.addShape(e,r),n.endTensorTypeAndShape(e)}}t.TensorTypeAndShape=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMapType(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMapType(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}keyType(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}valueType(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startMapType(e){e.startObject(2)}static addKeyType(e,t){e.addFieldInt32(0,t,0)}static addValueType(e,t){e.addFieldOffset(1,t,0)}static endMapType(e){return e.endObject()}static createMapType(e,t,r){return n.startMapType(e),n.addKeyType(e,t),n.addValueType(e,r),n.endMapType(e)}}t.MapType=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSequenceType(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSequenceType(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}elemType(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startSequenceType(e){e.startObject(1)}static addElemType(e,t){e.addFieldOffset(0,t,0)}static endSequenceType(e){return e.endObject()}static createSequenceType(e,t){return n.startSequenceType(e),n.addElemType(e,t),n.endSequenceType(e)}}t.SequenceType=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(t=e.fbs||={}).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(e,t,n,r){return e.prep(4,12),e.writeInt32(r),e.writeInt32(n),e.writeInt32(t),e.offset()}}})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNodeEdge(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsNodeEdge(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}nodeIndex(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb_pos+e):0}inputEdges(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*t,this.bb):null}inputEdgesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}outputEdges(t,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*t,this.bb):null}outputEdgesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}static startNodeEdge(e){e.startObject(3)}static addNodeIndex(e,t){e.addFieldInt32(0,t,0)}static addInputEdges(e,t){e.addFieldOffset(1,t,0)}static startInputEdgesVector(e,t){e.startVector(12,t,4)}static addOutputEdges(e,t){e.addFieldOffset(2,t,0)}static startOutputEdgesVector(e,t){e.startVector(12,t,4)}static endNodeEdge(e){return e.endObject()}static createNodeEdge(e,t,r,o){return n.startNodeEdge(e),n.addNodeIndex(e,t),n.addInputEdges(e,r),n.addOutputEdges(e,o),n.endNodeEdge(e)}}t.NodeEdge=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNode(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsNode(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}domain(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}sinceVersion(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt32(this.bb_pos+e):0}index(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint32(this.bb_pos+e):0}opType(e){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__string(this.bb_pos+t,e):null}type(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.readInt32(this.bb_pos+e):0}executionProviderType(e){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__string(this.bb_pos+t,e):null}inputs(e,t){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}inputsLength(){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__vector_len(this.bb_pos+e):0}outputs(e,t){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}outputsLength(){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__vector_len(this.bb_pos+e):0}attributes(t,n){let r=this.bb.__offset(this.bb_pos,24);return r?(n||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}attributesLength(){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__vector_len(this.bb_pos+e):0}inputArgCounts(e){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.readInt32(this.bb.__vector(this.bb_pos+t)+4*e):0}inputArgCountsLength(){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__vector_len(this.bb_pos+e):0}inputArgCountsArray(){let e=this.bb.__offset(this.bb_pos,26);return e?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}implicitInputs(e,t){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}implicitInputsLength(){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__vector_len(this.bb_pos+e):0}static startNode(e){e.startObject(13)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addDomain(e,t){e.addFieldOffset(2,t,0)}static addSinceVersion(e,t){e.addFieldInt32(3,t,0)}static addIndex(e,t){e.addFieldInt32(4,t,0)}static addOpType(e,t){e.addFieldOffset(5,t,0)}static addType(e,t){e.addFieldInt32(6,t,0)}static addExecutionProviderType(e,t){e.addFieldOffset(7,t,0)}static addInputs(e,t){e.addFieldOffset(8,t,0)}static createInputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startInputsVector(e,t){e.startVector(4,t,4)}static addOutputs(e,t){e.addFieldOffset(9,t,0)}static createOutputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startOutputsVector(e,t){e.startVector(4,t,4)}static addAttributes(e,t){e.addFieldOffset(10,t,0)}static createAttributesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startAttributesVector(e,t){e.startVector(4,t,4)}static addInputArgCounts(e,t){e.addFieldOffset(11,t,0)}static createInputArgCountsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startInputArgCountsVector(e,t){e.startVector(4,t,4)}static addImplicitInputs(e,t){e.addFieldOffset(12,t,0)}static createImplicitInputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startImplicitInputsVector(e,t){e.startVector(4,t,4)}static endNode(e){return e.endObject()}static createNode(e,t,r,o,i,a,s,u,l,c,p,d,f,h){return n.startNode(e),n.addName(e,t),n.addDocString(e,r),n.addDomain(e,o),n.addSinceVersion(e,i),n.addIndex(e,a),n.addOpType(e,s),n.addType(e,u),n.addExecutionProviderType(e,l),n.addInputs(e,c),n.addOutputs(e,p),n.addAttributes(e,d),n.addInputArgCounts(e,f),n.addImplicitInputs(e,h),n.endNode(e)}}t.Node=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsValueInfo(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsValueInfo(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}type(t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startValueInfo(e){e.startObject(3)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addType(e,t){e.addFieldOffset(2,t,0)}static endValueInfo(e){return e.endObject()}static createValueInfo(e,t,r,o){return n.startValueInfo(e),n.addName(e,t),n.addDocString(e,r),n.addType(e,o),n.endValueInfo(e)}}t.ValueInfo=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTypeInfo(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTypeInfo(e,n){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}denotation(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}valueType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):0}value(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}static startTypeInfo(e){e.startObject(3)}static addDenotation(e,t){e.addFieldOffset(0,t,0)}static addValueType(e,t){e.addFieldInt8(1,t,0)}static addValue(e,t){e.addFieldOffset(2,t,0)}static endTypeInfo(e){return e.endObject()}static createTypeInfo(e,n,r,o){return t.startTypeInfo(e),t.addDenotation(e,n),t.addValueType(e,r),t.addValue(e,o),t.endTypeInfo(e)}}e.TypeInfo=t})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsOperatorSetId(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsOperatorSetId(e,n){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}domain(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}version(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}static startOperatorSetId(e){e.startObject(2)}static addDomain(e,t){e.addFieldOffset(0,t,0)}static addVersion(e,t){e.addFieldInt64(1,t,e.createLong(0,0))}static endOperatorSetId(e){return e.endObject()}static createOperatorSetId(e,n,r){return t.startOperatorSetId(e),t.addDomain(e,n),t.addVersion(e,r),t.endOperatorSetId(e)}}e.OperatorSetId=t})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTensor(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTensor(e,n){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}dims(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}dimsLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}dataType(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt32(this.bb_pos+e):0}rawData(e){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint8(this.bb.__vector(this.bb_pos+t)+e):0}rawDataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}rawDataArray(){let e=this.bb.__offset(this.bb_pos,12);return e?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}stringData(e,t){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}stringDataLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}static startTensor(e){e.startObject(6)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addDims(e,t){e.addFieldOffset(2,t,0)}static createDimsVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startDimsVector(e,t){e.startVector(8,t,8)}static addDataType(e,t){e.addFieldInt32(3,t,0)}static addRawData(e,t){e.addFieldOffset(4,t,0)}static createRawDataVector(e,t){e.startVector(1,t.length,1);for(let n=t.length-1;n>=0;n--)e.addInt8(t[n]);return e.endVector()}static startRawDataVector(e,t){e.startVector(1,t,1)}static addStringData(e,t){e.addFieldOffset(5,t,0)}static createStringDataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startStringDataVector(e,t){e.startVector(4,t,4)}static endTensor(e){return e.endObject()}static createTensor(e,n,r,o,i,a,s){return t.startTensor(e),t.addName(e,n),t.addDocString(e,r),t.addDims(e,o),t.addDataType(e,i),t.addRawData(e,a),t.addStringData(e,s),t.endTensor(e)}}e.Tensor=t})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSparseTensor(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSparseTensor(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}values(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}indices(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dims(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}dimsLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSparseTensor(e){e.startObject(3)}static addValues(e,t){e.addFieldOffset(0,t,0)}static addIndices(e,t){e.addFieldOffset(1,t,0)}static addDims(e,t){e.addFieldOffset(2,t,0)}static createDimsVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startDimsVector(e,t){e.startVector(8,t,8)}static endSparseTensor(e){return e.endObject()}static createSparseTensor(e,t,r,o){return n.startSparseTensor(e),n.addValues(e,t),n.addIndices(e,r),n.addDims(e,o),n.endSparseTensor(e)}}t.SparseTensor=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsAttribute(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsAttribute(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}type(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt32(this.bb_pos+e):0}f(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat32(this.bb_pos+e):0}i(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}s(e){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__string(this.bb_pos+t,e):null}t(t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}g(t){let n=this.bb.__offset(this.bb_pos,18);return n?(t||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}floats(e){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readFloat32(this.bb.__vector(this.bb_pos+t)+4*e):0}floatsLength(){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__vector_len(this.bb_pos+e):0}floatsArray(){let e=this.bb.__offset(this.bb_pos,20);return e?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}ints(e){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}intsLength(){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__vector_len(this.bb_pos+e):0}strings(e,t){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}stringsLength(){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__vector_len(this.bb_pos+e):0}tensors(t,n){let r=this.bb.__offset(this.bb_pos,26);return r?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}tensorsLength(){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__vector_len(this.bb_pos+e):0}graphs(t,n){let r=this.bb.__offset(this.bb_pos,28);return r?(n||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}graphsLength(){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__vector_len(this.bb_pos+e):0}static startAttribute(e){e.startObject(13)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addType(e,t){e.addFieldInt32(2,t,0)}static addF(e,t){e.addFieldFloat32(3,t,0)}static addI(e,t){e.addFieldInt64(4,t,e.createLong(0,0))}static addS(e,t){e.addFieldOffset(5,t,0)}static addT(e,t){e.addFieldOffset(6,t,0)}static addG(e,t){e.addFieldOffset(7,t,0)}static addFloats(e,t){e.addFieldOffset(8,t,0)}static createFloatsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addFloat32(t[n]);return e.endVector()}static startFloatsVector(e,t){e.startVector(4,t,4)}static addInts(e,t){e.addFieldOffset(9,t,0)}static createIntsVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startIntsVector(e,t){e.startVector(8,t,8)}static addStrings(e,t){e.addFieldOffset(10,t,0)}static createStringsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startStringsVector(e,t){e.startVector(4,t,4)}static addTensors(e,t){e.addFieldOffset(11,t,0)}static createTensorsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startTensorsVector(e,t){e.startVector(4,t,4)}static addGraphs(e,t){e.addFieldOffset(12,t,0)}static createGraphsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startGraphsVector(e,t){e.startVector(4,t,4)}static endAttribute(e){return e.endObject()}static createAttribute(e,t,r,o,i,a,s,u,l,c,p,d,f,h){return n.startAttribute(e),n.addName(e,t),n.addDocString(e,r),n.addType(e,o),n.addF(e,i),n.addI(e,a),n.addS(e,s),n.addT(e,u),n.addG(e,l),n.addFloats(e,c),n.addInts(e,p),n.addStrings(e,d),n.addTensors(e,f),n.addGraphs(e,h),n.endAttribute(e)}}t.Attribute=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsGraph(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsGraph(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}initializers(t,n){let r=this.bb.__offset(this.bb_pos,4);return r?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}initializersLength(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__vector_len(this.bb_pos+e):0}nodeArgs(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}nodeArgsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}nodes(t,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}nodesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}maxNodeIndex(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint32(this.bb_pos+e):0}nodeEdges(t,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}nodeEdgesLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}inputs(e,t){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}inputsLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}outputs(e,t){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}outputsLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}sparseInitializers(t,n){let r=this.bb.__offset(this.bb_pos,18);return r?(n||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}sparseInitializersLength(){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__vector_len(this.bb_pos+e):0}static startGraph(e){e.startObject(8)}static addInitializers(e,t){e.addFieldOffset(0,t,0)}static createInitializersVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startInitializersVector(e,t){e.startVector(4,t,4)}static addNodeArgs(e,t){e.addFieldOffset(1,t,0)}static createNodeArgsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startNodeArgsVector(e,t){e.startVector(4,t,4)}static addNodes(e,t){e.addFieldOffset(2,t,0)}static createNodesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startNodesVector(e,t){e.startVector(4,t,4)}static addMaxNodeIndex(e,t){e.addFieldInt32(3,t,0)}static addNodeEdges(e,t){e.addFieldOffset(4,t,0)}static createNodeEdgesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startNodeEdgesVector(e,t){e.startVector(4,t,4)}static addInputs(e,t){e.addFieldOffset(5,t,0)}static createInputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startInputsVector(e,t){e.startVector(4,t,4)}static addOutputs(e,t){e.addFieldOffset(6,t,0)}static createOutputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startOutputsVector(e,t){e.startVector(4,t,4)}static addSparseInitializers(e,t){e.addFieldOffset(7,t,0)}static createSparseInitializersVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startSparseInitializersVector(e,t){e.startVector(4,t,4)}static endGraph(e){return e.endObject()}static createGraph(e,t,r,o,i,a,s,u,l){return n.startGraph(e),n.addInitializers(e,t),n.addNodeArgs(e,r),n.addNodes(e,o),n.addMaxNodeIndex(e,i),n.addNodeEdges(e,a),n.addInputs(e,s),n.addOutputs(e,u),n.addSparseInitializers(e,l),n.endGraph(e)}}t.Graph=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsModel(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsModel(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}irVersion(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}opsetImport(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}opsetImportLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}producerName(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}producerVersion(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__string(this.bb_pos+t,e):null}domain(e){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__string(this.bb_pos+t,e):null}modelVersion(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}docString(e){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__string(this.bb_pos+t,e):null}graph(t){let n=this.bb.__offset(this.bb_pos,18);return n?(t||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}graphDocString(e){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__string(this.bb_pos+t,e):null}static startModel(e){e.startObject(9)}static addIrVersion(e,t){e.addFieldInt64(0,t,e.createLong(0,0))}static addOpsetImport(e,t){e.addFieldOffset(1,t,0)}static createOpsetImportVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startOpsetImportVector(e,t){e.startVector(4,t,4)}static addProducerName(e,t){e.addFieldOffset(2,t,0)}static addProducerVersion(e,t){e.addFieldOffset(3,t,0)}static addDomain(e,t){e.addFieldOffset(4,t,0)}static addModelVersion(e,t){e.addFieldInt64(5,t,e.createLong(0,0))}static addDocString(e,t){e.addFieldOffset(6,t,0)}static addGraph(e,t){e.addFieldOffset(7,t,0)}static addGraphDocString(e,t){e.addFieldOffset(8,t,0)}static endModel(e){return e.endObject()}static createModel(e,t,r,o,i,a,s,u,l,c){return n.startModel(e),n.addIrVersion(e,t),n.addOpsetImport(e,r),n.addProducerName(e,o),n.addProducerVersion(e,i),n.addDomain(e,a),n.addModelVersion(e,s),n.addDocString(e,u),n.addGraph(e,l),n.addGraphDocString(e,c),n.endModel(e)}}t.Model=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsKernelCreateInfos(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsKernelCreateInfos(e,n){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}nodeIndices(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb.__vector(this.bb_pos+t)+4*e):0}nodeIndicesLength(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__vector_len(this.bb_pos+e):0}nodeIndicesArray(){let e=this.bb.__offset(this.bb_pos,4);return e?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}kernelDefHashes(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}kernelDefHashesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}static startKernelCreateInfos(e){e.startObject(2)}static addNodeIndices(e,t){e.addFieldOffset(0,t,0)}static createNodeIndicesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startNodeIndicesVector(e,t){e.startVector(4,t,4)}static addKernelDefHashes(e,t){e.addFieldOffset(1,t,0)}static createKernelDefHashesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startKernelDefHashesVector(e,t){e.startVector(8,t,8)}static endKernelCreateInfos(e){return e.endObject()}static createKernelCreateInfos(e,n,r){return t.startKernelCreateInfos(e),t.addNodeIndices(e,n),t.addKernelDefHashes(e,r),t.endKernelCreateInfos(e)}}e.KernelCreateInfos=t})(t=e.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSubGraphSessionState(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSubGraphSessionState(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}graphId(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}sessionState(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startSubGraphSessionState(e){e.startObject(2)}static addGraphId(e,t){e.addFieldOffset(0,t,0)}static addSessionState(e,t){e.addFieldOffset(1,t,0)}static endSubGraphSessionState(e){let t=e.endObject();return e.requiredField(t,4),t}static createSubGraphSessionState(e,t,r){return n.startSubGraphSessionState(e),n.addGraphId(e,t),n.addSessionState(e,r),n.endSubGraphSessionState(e)}}t.SubGraphSessionState=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSessionState(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSessionState(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}kernels(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}subGraphSessionStates(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}subGraphSessionStatesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSessionState(e){e.startObject(2)}static addKernels(e,t){e.addFieldOffset(0,t,0)}static addSubGraphSessionStates(e,t){e.addFieldOffset(1,t,0)}static createSubGraphSessionStatesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startSubGraphSessionStatesVector(e,t){e.startVector(4,t,4)}static endSessionState(e){return e.endObject()}static createSessionState(e,t,r){return n.startSessionState(e),n.addKernels(e,t),n.addSubGraphSessionStates(e,r),n.endSessionState(e)}}t.SessionState=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={}),(e=>{let t;(t=>{let n;(t=>{class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInferenceSession(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsInferenceSession(e,t){return e.setPosition(e.position()+_.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static bufferHasIdentifier(e){return e.__has_identifier("ORTM")}ortVersion(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}model(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}sessionState(t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startInferenceSession(e){e.startObject(3)}static addOrtVersion(e,t){e.addFieldOffset(0,t,0)}static addModel(e,t){e.addFieldOffset(1,t,0)}static addSessionState(e,t){e.addFieldOffset(2,t,0)}static endInferenceSession(e){return e.endObject()}static finishInferenceSessionBuffer(e,t){e.finish(t,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(e,t){e.finish(t,"ORTM",!0)}static createInferenceSession(e,t,r,o){return n.startInferenceSession(e),n.addOrtVersion(e,t),n.addModel(e,r),n.addSessionState(e,o),n.endInferenceSession(e)}}t.InferenceSession=n})(n=t.fbs||={})})(t=e.experimental||={})})(W||={})})),Ns=me(((e,t)=>{t.exports=function(e,t){for(var n=new Array(arguments.length-1),r=0,o=2,i=!0;o<arguments.length;)n[r++]=arguments[o++];return new Promise((function(o,a){n[r]=function(e){if(i)if(i=!1,e)a(e);else{for(var t=new Array(arguments.length-1),n=0;n<t.length;)t[n++]=arguments[n];o.apply(null,t)}};try{e.apply(t||null,n)}catch(e){i&&(i=!1,a(e))}}))}})),Us=me((e=>{var t=e;t.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};var n,r=new Array(64),o=new Array(123);for(n=0;n<64;)o[r[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;t.encode=function(e,t,n){for(var o,i=null,a=[],s=0,u=0;t<n;){var l=e[t++];switch(u){case 0:a[s++]=r[l>>2],o=(3&l)<<4,u=1;break;case 1:a[s++]=r[o|l>>4],o=(15&l)<<2,u=2;break;case 2:a[s++]=r[o|l>>6],a[s++]=r[63&l],u=0}s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),s=0)}return u&&(a[s++]=r[o],a[s++]=61,1===u&&(a[s++]=61)),i?(s&&i.push(String.fromCharCode.apply(String,a.slice(0,s))),i.join("")):String.fromCharCode.apply(String,a.slice(0,s))};var i="invalid encoding";t.decode=function(e,t,n){for(var r,a=n,s=0,u=0;u<e.length;){var l=e.charCodeAt(u++);if(61===l&&s>1)break;if(void 0===(l=o[l]))throw Error(i);switch(s){case 0:r=l,s=1;break;case 1:t[n++]=r<<2|(48&l)>>4,r=l,s=2;break;case 2:t[n++]=(15&r)<<4|(60&l)>>2,r=l,s=3;break;case 3:t[n++]=(3&r)<<6|l,s=0}}if(1===s)throw Error(i);return n-a},t.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}})),Vs=me(((e,t)=>{function n(){this._listeners={}}t.exports=n,n.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},n.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r<n.length;)n[r].fn===t?n.splice(r,1):++r;return this},n.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,n)}return this}})),Ks=me(((e,t)=>{function n(e){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function o(e,r,o){t[0]=e,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3]}function i(e,r,o){t[0]=e,r[o]=n[3],r[o+1]=n[2],r[o+2]=n[1],r[o+3]=n[0]}function a(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function s(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?o:i,e.writeFloatBE=r?i:o,e.readFloatLE=r?a:s,e.readFloatBE=r?s:a}():function(){function t(e,t,n,r){var o=t<0?1:0;if(o&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((o<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((o<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var i=Math.floor(Math.log(t)/Math.LN2);e((o<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,n,r)}}function n(e,t,n){var r=e(t,n),o=2*(r>>31)+1,i=r>>>23&255,a=8388607&r;return 255===i?a?NaN:o*(1/0):0===i?1401298464324817e-60*o*a:o*Math.pow(2,i-150)*(a+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,o),e.readFloatLE=n.bind(null,i),e.readFloatBE=n.bind(null,a)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function o(e,r,o){t[0]=e,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3],r[o+4]=n[4],r[o+5]=n[5],r[o+6]=n[6],r[o+7]=n[7]}function i(e,r,o){t[0]=e,r[o]=n[7],r[o+1]=n[6],r[o+2]=n[5],r[o+3]=n[4],r[o+4]=n[3],r[o+5]=n[2],r[o+6]=n[1],r[o+7]=n[0]}function a(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function s(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?o:i,e.writeDoubleBE=r?i:o,e.readDoubleLE=r?a:s,e.readDoubleBE=r?s:a}():function(){function t(e,t,n,r,o,i){var a=r<0?1:0;if(a&&(r=-r),0===r)e(0,o,i+t),e(1/r>0?0:2147483648,o,i+n);else if(isNaN(r))e(0,o,i+t),e(2146959360,o,i+n);else if(r>17976931348623157e292)e(0,o,i+t),e((a<<31|2146435072)>>>0,o,i+n);else{var s;if(r<22250738585072014e-324)e((s=r/5e-324)>>>0,o,i+t),e((a<<31|s/4294967296)>>>0,o,i+n);else{var u=Math.floor(Math.log(r)/Math.LN2);1024===u&&(u=1023),e(4503599627370496*(s=r*Math.pow(2,-u))>>>0,o,i+t),e((a<<31|u+1023<<20|1048576*s&1048575)>>>0,o,i+n)}}}function n(e,t,n,r,o){var i=e(r,o+t),a=e(r,o+n),s=2*(a>>31)+1,u=a>>>20&2047,l=4294967296*(1048575&a)+i;return 2047===u?l?NaN:s*(1/0):0===u?5e-324*s*l:s*Math.pow(2,u-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,o,4,0),e.readDoubleLE=n.bind(null,i,0,4),e.readDoubleBE=n.bind(null,a,4,0)}(),e}function r(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function o(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}t.exports=n(n)})),Js=me(((exports,module)=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire})),Qs=me((e=>{var t=e;t.length=function(e){for(var t=0,n=0,r=0;r<e.length;++r)(n=e.charCodeAt(r))<128?t+=1:n<2048?t+=2:55296==(64512&n)&&56320==(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t},t.read=function(e,t,n){if(n-t<1)return"";for(var r,o=null,i=[],a=0;t<n;)(r=e[t++])<128?i[a++]=r:r>191&&r<224?i[a++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[a++]=55296+(r>>10),i[a++]=56320+(1023&r)):i[a++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),a=0);return o?(a&&o.push(String.fromCharCode.apply(String,i.slice(0,a))),o.join("")):String.fromCharCode.apply(String,i.slice(0,a))},t.write=function(e,t,n){for(var r,o,i=n,a=0;a<e.length;++a)(r=e.charCodeAt(a))<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(o=e.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&o),++a,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-i}})),tu=me(((e,t)=>{t.exports=function(e,t,n){var r=n||8192,o=r>>>1,i=null,a=r;return function(n){if(n<1||n>o)return e(n);a+n>r&&(i=e(r),a=0);var s=t.call(i,a,a+=n);return 7&a&&(a=1+(7|a)),s}}})),nu=me(((e,t)=>{t.exports=r;var n=Qt();function r(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=r.zero=new r(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var i=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)},r.from=function(e){if("number"==typeof e)return r.fromNumber(e);if(n.isString(e)){if(!n.Long)return r.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new r(e.low>>>0,e.high>>>0):o},r.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},r.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,!!e):{low:0|this.lo,high:0|this.hi,unsigned:!!e}};var a=String.prototype.charCodeAt;r.fromHash=function(e){return e===i?o:new r((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},r.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},r.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}})),Qt=me((e=>{var t=e;function n(e,t,n){for(var r=Object.keys(t),o=0;o<r.length;++o)(void 0===e[r[o]]||!n)&&(e[r[o]]=t[r[o]]);return e}function r(e){function t(e,r){if(!(this instanceof t))return new t(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&n(this,r)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=Ns(),t.base64=Us(),t.EventEmitter=Vs(),t.float=Ks(),t.inquire=Js(),t.utf8=Qs(),t.pool=tu(),t.LongBits=nu(),t.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),t.global=t.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||e,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var n=e[t];return!(null==n||!e.hasOwnProperty(t))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},t.Buffer=function(){try{var e=t.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch{return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(e){return"number"==typeof e?t.Buffer?t._Buffer_allocUnsafe(e):new t.Array(e):t.Buffer?t._Buffer_from(e):typeof Uint8Array>"u"?e:new Uint8Array(e)},t.Array=typeof Uint8Array<"u"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,n){var r=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(r.lo,r.hi,n):r.toNumber(!!n)},t.merge=n,t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},t.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var e=t.Buffer;e?(t._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,n){return new e(t,n)},t._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):t._Buffer_from=t._Buffer_allocUnsafe=null}})),fi=me(((e,t)=>{t.exports=c;var n,r=Qt(),o=r.LongBits,i=r.base64,a=r.utf8;function s(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function u(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function c(){this.len=0,this.head=new s(u,0,0),this.tail=this.head,this.states=null}var p=function(){return r.Buffer?function(){return(c.create=function(){return new n})()}:function(){return new c}};function d(e,t,n){t[n]=255&e}function f(e,t){this.len=e,this.next=void 0,this.val=t}function h(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function g(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}c.create=p(),c.alloc=function(e){return new r.Array(e)},r.Array!==Array&&(c.alloc=r.pool(c.alloc,r.Array.prototype.subarray)),c.prototype._push=function(e,t,n){return this.tail=this.tail.next=new s(e,t,n),this.len+=t,this},f.prototype=Object.create(s.prototype),f.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},c.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new f((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},c.prototype.int32=function(e){return e<0?this._push(h,10,o.fromNumber(e)):this.uint32(e)},c.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},c.prototype.uint64=function(e){var t=o.from(e);return this._push(h,t.length(),t)},c.prototype.int64=c.prototype.uint64,c.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(h,t.length(),t)},c.prototype.bool=function(e){return this._push(d,1,e?1:0)},c.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},c.prototype.sfixed32=c.prototype.fixed32,c.prototype.fixed64=function(e){var t=o.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},c.prototype.sfixed64=c.prototype.fixed64,c.prototype.float=function(e){return this._push(r.float.writeFloatLE,4,e)},c.prototype.double=function(e){return this._push(r.float.writeDoubleLE,8,e)};var m=r.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r<e.length;++r)t[n+r]=e[r]};c.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(d,1,0);if(r.isString(e)){var n=c.alloc(t=i.length(e));i.decode(e,n,0),e=n}return this.uint32(t)._push(m,t,e)},c.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(d,1,0)},c.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new s(u,0,0),this.len=0,this},c.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new s(u,0,0),this.len=0),this},c.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},c.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},c._configure=function(e){n=e,c.create=p(),n._configure()}})),pu=me(((e,t)=>{t.exports=o;var n=fi();(o.prototype=Object.create(n.prototype)).constructor=o;var r=Qt();function o(){n.call(this)}function i(e,t,n){e.length<40?r.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}o._configure=function(){o.alloc=r._Buffer_allocUnsafe,o.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&"set"===r.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r<e.length;)t[n++]=e[r++]}},o.prototype.bytes=function(e){r.isString(e)&&(e=r._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=r.Buffer.byteLength(e);return this.uint32(t),t&&this._push(i,t,e),this},o._configure()})),di=me(((e,t)=>{t.exports=s;var n,r=Qt(),o=r.LongBits,i=r.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function s(e){this.buf=e,this.pos=0,this.len=e.length}var u,l=typeof Uint8Array<"u"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new s(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new s(e);throw Error("illegal buffer")},c=function(){return r.Buffer?function(e){return(s.create=function(e){return r.Buffer.isBuffer(e)?new n(e):l(e)})(e)}:l};function p(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}s.create=c(),s.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice,s.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return u;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return u}),s.prototype.int32=function(){return 0|this.uint32()},s.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},s.prototype.bool=function(){return 0!==this.uint32()},s.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},s.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},s.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},s.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},s.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},s.prototype.string=function(){var e=this.bytes();return i.read(e,0,e.length)},s.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},s.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},s._configure=function(e){n=e,s.create=c(),n._configure();var t=r.Long?"toLong":"toNumber";r.merge(s.prototype,{int64:function(){return p.call(this)[t](!1)},uint64:function(){return p.call(this)[t](!0)},sint64:function(){return p.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}})),vu=me(((e,t)=>{t.exports=o;var n=di();(o.prototype=Object.create(n.prototype)).constructor=o;var r=Qt();function o(e){n.call(this,e)}o._configure=function(){r.Buffer&&(o.prototype._slice=r.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()})),_u=me(((e,t)=>{t.exports=r;var n=Qt();function r(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!r}(r.prototype=Object.create(n.EventEmitter.prototype)).constructor=r,r.prototype.rpcCall=function e(t,r,o,i,a){if(!i)throw TypeError("request must be specified");var s=this;if(!a)return n.asPromise(e,s,t,r,o,i);if(s.rpcImpl)try{return s.rpcImpl(t,r[s.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,n){if(e)return s.emit("error",e,t),a(e);if(null!==n){if(!(n instanceof o))try{n=o[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return s.emit("error",e,t),a(e)}return s.emit("data",n,t),a(null,n)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){a(e)}),0)}else setTimeout((function(){a(Error("already ended"))}),0)},r.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}})),Iu=me((e=>{e.Service=_u()})),Au=me(((e,t)=>{t.exports={}})),Du=me((e=>{var t=e;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=fi(),t.BufferWriter=pu(),t.Reader=di(),t.BufferReader=vu(),t.util=Qt(),t.rpc=Iu(),t.roots=Au(),t.configure=n,n()})),Fu=me(((e,t)=>{t.exports=Du()})),$r=me(((e,t)=>{var n,r,o,i=Fu(),a=i.Reader,s=i.Writer,u=i.util,l=i.roots.default||(i.roots.default={});l.onnx=((o={}).Version=(n={},(r=Object.create(n))[n[0]="_START_VERSION"]=0,r[n[1]="IR_VERSION_2017_10_10"]=1,r[n[2]="IR_VERSION_2017_10_30"]=2,r[n[3]="IR_VERSION_2017_11_3"]=3,r[n[4]="IR_VERSION_2019_1_22"]=4,r[n[5]="IR_VERSION_2019_3_18"]=5,r[n[6]="IR_VERSION_2019_9_19"]=6,r[n[7]="IR_VERSION_2020_5_8"]=7,r[n[8]="IR_VERSION_2021_7_30"]=8,r[n[9]="IR_VERSION"]=9,r),o.AttributeProto=function(){function e(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.name="",e.prototype.refAttrName="",e.prototype.docString="",e.prototype.type=0,e.prototype.f=0,e.prototype.i=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.s=u.newBuffer([]),e.prototype.t=null,e.prototype.g=null,e.prototype.sparseTensor=null,e.prototype.tp=null,e.prototype.floats=u.emptyArray,e.prototype.ints=u.emptyArray,e.prototype.strings=u.emptyArray,e.prototype.tensors=u.emptyArray,e.prototype.graphs=u.emptyArray,e.prototype.sparseTensors=u.emptyArray,e.prototype.typeProtos=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.name&&Object.hasOwnProperty.call(e,"name")&&t.uint32(10).string(e.name),null!=e.f&&Object.hasOwnProperty.call(e,"f")&&t.uint32(21).float(e.f),null!=e.i&&Object.hasOwnProperty.call(e,"i")&&t.uint32(24).int64(e.i),null!=e.s&&Object.hasOwnProperty.call(e,"s")&&t.uint32(34).bytes(e.s),null!=e.t&&Object.hasOwnProperty.call(e,"t")&&l.onnx.TensorProto.encode(e.t,t.uint32(42).fork()).ldelim(),null!=e.g&&Object.hasOwnProperty.call(e,"g")&&l.onnx.GraphProto.encode(e.g,t.uint32(50).fork()).ldelim(),null!=e.floats&&e.floats.length){t.uint32(58).fork();for(var n=0;n<e.floats.length;++n)t.float(e.floats[n]);t.ldelim()}if(null!=e.ints&&e.ints.length){for(t.uint32(66).fork(),n=0;n<e.ints.length;++n)t.int64(e.ints[n]);t.ldelim()}if(null!=e.strings&&e.strings.length)for(n=0;n<e.strings.length;++n)t.uint32(74).bytes(e.strings[n]);if(null!=e.tensors&&e.tensors.length)for(n=0;n<e.tensors.length;++n)l.onnx.TensorProto.encode(e.tensors[n],t.uint32(82).fork()).ldelim();if(null!=e.graphs&&e.graphs.length)for(n=0;n<e.graphs.length;++n)l.onnx.GraphProto.encode(e.graphs[n],t.uint32(90).fork()).ldelim();if(null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(106).string(e.docString),null!=e.tp&&Object.hasOwnProperty.call(e,"tp")&&l.onnx.TypeProto.encode(e.tp,t.uint32(114).fork()).ldelim(),null!=e.typeProtos&&e.typeProtos.length)for(n=0;n<e.typeProtos.length;++n)l.onnx.TypeProto.encode(e.typeProtos[n],t.uint32(122).fork()).ldelim();if(null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(160).int32(e.type),null!=e.refAttrName&&Object.hasOwnProperty.call(e,"refAttrName")&&t.uint32(170).string(e.refAttrName),null!=e.sparseTensor&&Object.hasOwnProperty.call(e,"sparseTensor")&&l.onnx.SparseTensorProto.encode(e.sparseTensor,t.uint32(178).fork()).ldelim(),null!=e.sparseTensors&&e.sparseTensors.length)for(n=0;n<e.sparseTensors.length;++n)l.onnx.SparseTensorProto.encode(e.sparseTensors[n],t.uint32(186).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.AttributeProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.name=e.string();break;case 21:r.refAttrName=e.string();break;case 13:r.docString=e.string();break;case 20:r.type=e.int32();break;case 2:r.f=e.float();break;case 3:r.i=e.int64();break;case 4:r.s=e.bytes();break;case 5:r.t=l.onnx.TensorProto.decode(e,e.uint32());break;case 6:r.g=l.onnx.GraphProto.decode(e,e.uint32());break;case 22:r.sparseTensor=l.onnx.SparseTensorProto.decode(e,e.uint32());break;case 14:r.tp=l.onnx.TypeProto.decode(e,e.uint32());break;case 7:if(r.floats&&r.floats.length||(r.floats=[]),2==(7&o))for(var i=e.uint32()+e.pos;e.pos<i;)r.floats.push(e.float());else r.floats.push(e.float());break;case 8:if(r.ints&&r.ints.length||(r.ints=[]),2==(7&o))for(i=e.uint32()+e.pos;e.pos<i;)r.ints.push(e.int64());else r.ints.push(e.int64());break;case 9:r.strings&&r.strings.length||(r.strings=[]),r.strings.push(e.bytes());break;case 10:r.tensors&&r.tensors.length||(r.tensors=[]),r.tensors.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 11:r.graphs&&r.graphs.length||(r.graphs=[]),r.graphs.push(l.onnx.GraphProto.decode(e,e.uint32()));break;case 23:r.sparseTensors&&r.sparseTensors.length||(r.sparseTensors=[]),r.sparseTensors.push(l.onnx.SparseTensorProto.decode(e,e.uint32()));break;case 15:r.typeProtos&&r.typeProtos.length||(r.typeProtos=[]),r.typeProtos.push(l.onnx.TypeProto.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.name&&e.hasOwnProperty("name")&&!u.isString(e.name))return"name: string expected";if(null!=e.refAttrName&&e.hasOwnProperty("refAttrName")&&!u.isString(e.refAttrName))return"refAttrName: string expected";if(null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString))return"docString: string expected";if(null!=e.type&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 11:case 13:case 6:case 7:case 8:case 9:case 10:case 12:case 14:}if(null!=e.f&&e.hasOwnProperty("f")&&"number"!=typeof e.f)return"f: number expected";if(null!=e.i&&e.hasOwnProperty("i")&&!u.isInteger(e.i)&&!(e.i&&u.isInteger(e.i.low)&&u.isInteger(e.i.high)))return"i: integer|Long expected";if(null!=e.s&&e.hasOwnProperty("s")&&!(e.s&&"number"==typeof e.s.length||u.isString(e.s)))return"s: buffer expected";if(null!=e.t&&e.hasOwnProperty("t")&&(n=l.onnx.TensorProto.verify(e.t)))return"t."+n;if(null!=e.g&&e.hasOwnProperty("g")&&(n=l.onnx.GraphProto.verify(e.g)))return"g."+n;if(null!=e.sparseTensor&&e.hasOwnProperty("sparseTensor")&&(n=l.onnx.SparseTensorProto.verify(e.sparseTensor)))return"sparseTensor."+n;if(null!=e.tp&&e.hasOwnProperty("tp")&&(n=l.onnx.TypeProto.verify(e.tp)))return"tp."+n;if(null!=e.floats&&e.hasOwnProperty("floats")){if(!Array.isArray(e.floats))return"floats: array expected";for(var t=0;t<e.floats.length;++t)if("number"!=typeof e.floats[t])return"floats: number[] expected"}if(null!=e.ints&&e.hasOwnProperty("ints")){if(!Array.isArray(e.ints))return"ints: array expected";for(t=0;t<e.ints.length;++t)if(!(u.isInteger(e.ints[t])||e.ints[t]&&u.isInteger(e.ints[t].low)&&u.isInteger(e.ints[t].high)))return"ints: integer|Long[] expected"}if(null!=e.strings&&e.hasOwnProperty("strings")){if(!Array.isArray(e.strings))return"strings: array expected";for(t=0;t<e.strings.length;++t)if(!(e.strings[t]&&"number"==typeof e.strings[t].length||u.isString(e.strings[t])))return"strings: buffer[] expected"}if(null!=e.tensors&&e.hasOwnProperty("tensors")){if(!Array.isArray(e.tensors))return"tensors: array expected";for(t=0;t<e.tensors.length;++t)if(n=l.onnx.TensorProto.verify(e.tensors[t]))return"tensors."+n}if(null!=e.graphs&&e.hasOwnProperty("graphs")){if(!Array.isArray(e.graphs))return"graphs: array expected";for(t=0;t<e.graphs.length;++t)if(n=l.onnx.GraphProto.verify(e.graphs[t]))return"graphs."+n}if(null!=e.sparseTensors&&e.hasOwnProperty("sparseTensors")){if(!Array.isArray(e.sparseTensors))return"sparseTensors: array expected";for(t=0;t<e.sparseTensors.length;++t)if(n=l.onnx.SparseTensorProto.verify(e.sparseTensors[t]))return"sparseTensors."+n}if(null!=e.typeProtos&&e.hasOwnProperty("typeProtos")){if(!Array.isArray(e.typeProtos))return"typeProtos: array expected";for(t=0;t<e.typeProtos.length;++t){var n;if(n=l.onnx.TypeProto.verify(e.typeProtos[t]))return"typeProtos."+n}}return null},e.fromObject=function(e){if(e instanceof l.onnx.AttributeProto)return e;var t=new l.onnx.AttributeProto;switch(null!=e.name&&(t.name=String(e.name)),null!=e.refAttrName&&(t.refAttrName=String(e.refAttrName)),null!=e.docString&&(t.docString=String(e.docString)),e.type){default:if("number"==typeof e.type){t.type=e.type;break}break;case"UNDEFINED":case 0:t.type=0;break;case"FLOAT":case 1:t.type=1;break;case"INT":case 2:t.type=2;break;case"STRING":case 3:t.type=3;break;case"TENSOR":case 4:t.type=4;break;case"GRAPH":case 5:t.type=5;break;case"SPARSE_TENSOR":case 11:t.type=11;break;case"TYPE_PROTO":case 13:t.type=13;break;case"FLOATS":case 6:t.type=6;break;case"INTS":case 7:t.type=7;break;case"STRINGS":case 8:t.type=8;break;case"TENSORS":case 9:t.type=9;break;case"GRAPHS":case 10:t.type=10;break;case"SPARSE_TENSORS":case 12:t.type=12;break;case"TYPE_PROTOS":case 14:t.type=14}if(null!=e.f&&(t.f=Number(e.f)),null!=e.i&&(u.Long?(t.i=u.Long.fromValue(e.i)).unsigned=!1:"string"==typeof e.i?t.i=parseInt(e.i,10):"number"==typeof e.i?t.i=e.i:"object"==typeof e.i&&(t.i=new u.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber())),null!=e.s&&("string"==typeof e.s?u.base64.decode(e.s,t.s=u.newBuffer(u.base64.length(e.s)),0):e.s.length>=0&&(t.s=e.s)),null!=e.t){if("object"!=typeof e.t)throw TypeError(".onnx.AttributeProto.t: object expected");t.t=l.onnx.TensorProto.fromObject(e.t)}if(null!=e.g){if("object"!=typeof e.g)throw TypeError(".onnx.AttributeProto.g: object expected");t.g=l.onnx.GraphProto.fromObject(e.g)}if(null!=e.sparseTensor){if("object"!=typeof e.sparseTensor)throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");t.sparseTensor=l.onnx.SparseTensorProto.fromObject(e.sparseTensor)}if(null!=e.tp){if("object"!=typeof e.tp)throw TypeError(".onnx.AttributeProto.tp: object expected");t.tp=l.onnx.TypeProto.fromObject(e.tp)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");t.floats=[];for(var n=0;n<e.floats.length;++n)t.floats[n]=Number(e.floats[n])}if(e.ints){if(!Array.isArray(e.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");for(t.ints=[],n=0;n<e.ints.length;++n)u.Long?(t.ints[n]=u.Long.fromValue(e.ints[n])).unsigned=!1:"string"==typeof e.ints[n]?t.ints[n]=parseInt(e.ints[n],10):"number"==typeof e.ints[n]?t.ints[n]=e.ints[n]:"object"==typeof e.ints[n]&&(t.ints[n]=new u.LongBits(e.ints[n].low>>>0,e.ints[n].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(t.strings=[],n=0;n<e.strings.length;++n)"string"==typeof e.strings[n]?u.base64.decode(e.strings[n],t.strings[n]=u.newBuffer(u.base64.length(e.strings[n])),0):e.strings[n].length>=0&&(t.strings[n]=e.strings[n])}if(e.tensors){if(!Array.isArray(e.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");for(t.tensors=[],n=0;n<e.tensors.length;++n){if("object"!=typeof e.tensors[n])throw TypeError(".onnx.AttributeProto.tensors: object expected");t.tensors[n]=l.onnx.TensorProto.fromObject(e.tensors[n])}}if(e.graphs){if(!Array.isArray(e.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");for(t.graphs=[],n=0;n<e.graphs.length;++n){if("object"!=typeof e.graphs[n])throw TypeError(".onnx.AttributeProto.graphs: object expected");t.graphs[n]=l.onnx.GraphProto.fromObject(e.graphs[n])}}if(e.sparseTensors){if(!Array.isArray(e.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");for(t.sparseTensors=[],n=0;n<e.sparseTensors.length;++n){if("object"!=typeof e.sparseTensors[n])throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");t.sparseTensors[n]=l.onnx.SparseTensorProto.fromObject(e.sparseTensors[n])}}if(e.typeProtos){if(!Array.isArray(e.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");for(t.typeProtos=[],n=0;n<e.typeProtos.length;++n){if("object"!=typeof e.typeProtos[n])throw TypeError(".onnx.AttributeProto.typeProtos: object expected");t.typeProtos[n]=l.onnx.TypeProto.fromObject(e.typeProtos[n])}}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.floats=[],n.ints=[],n.strings=[],n.tensors=[],n.graphs=[],n.typeProtos=[],n.sparseTensors=[]),t.defaults){if(n.name="",n.f=0,u.Long){var r=new u.Long(0,0,!1);n.i=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.i=t.longs===String?"0":0;t.bytes===String?n.s="":(n.s=[],t.bytes!==Array&&(n.s=u.newBuffer(n.s))),n.t=null,n.g=null,n.docString="",n.tp=null,n.type=t.enums===String?"UNDEFINED":0,n.refAttrName="",n.sparseTensor=null}if(null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),null!=e.f&&e.hasOwnProperty("f")&&(n.f=t.json&&!isFinite(e.f)?String(e.f):e.f),null!=e.i&&e.hasOwnProperty("i")&&("number"==typeof e.i?n.i=t.longs===String?String(e.i):e.i:n.i=t.longs===String?u.Long.prototype.toString.call(e.i):t.longs===Number?new u.LongBits(e.i.low>>>0,e.i.high>>>0).toNumber():e.i),null!=e.s&&e.hasOwnProperty("s")&&(n.s=t.bytes===String?u.base64.encode(e.s,0,e.s.length):t.bytes===Array?Array.prototype.slice.call(e.s):e.s),null!=e.t&&e.hasOwnProperty("t")&&(n.t=l.onnx.TensorProto.toObject(e.t,t)),null!=e.g&&e.hasOwnProperty("g")&&(n.g=l.onnx.GraphProto.toObject(e.g,t)),e.floats&&e.floats.length){n.floats=[];for(var o=0;o<e.floats.length;++o)n.floats[o]=t.json&&!isFinite(e.floats[o])?String(e.floats[o]):e.floats[o]}if(e.ints&&e.ints.length)for(n.ints=[],o=0;o<e.ints.length;++o)"number"==typeof e.ints[o]?n.ints[o]=t.longs===String?String(e.ints[o]):e.ints[o]:n.ints[o]=t.longs===String?u.Long.prototype.toString.call(e.ints[o]):t.longs===Number?new u.LongBits(e.ints[o].low>>>0,e.ints[o].high>>>0).toNumber():e.ints[o];if(e.strings&&e.strings.length)for(n.strings=[],o=0;o<e.strings.length;++o)n.strings[o]=t.bytes===String?u.base64.encode(e.strings[o],0,e.strings[o].length):t.bytes===Array?Array.prototype.slice.call(e.strings[o]):e.strings[o];if(e.tensors&&e.tensors.length)for(n.tensors=[],o=0;o<e.tensors.length;++o)n.tensors[o]=l.onnx.TensorProto.toObject(e.tensors[o],t);if(e.graphs&&e.graphs.length)for(n.graphs=[],o=0;o<e.graphs.length;++o)n.graphs[o]=l.onnx.GraphProto.toObject(e.graphs[o],t);if(null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),null!=e.tp&&e.hasOwnProperty("tp")&&(n.tp=l.onnx.TypeProto.toObject(e.tp,t)),e.typeProtos&&e.typeProtos.length)for(n.typeProtos=[],o=0;o<e.typeProtos.length;++o)n.typeProtos[o]=l.onnx.TypeProto.toObject(e.typeProtos[o],t);if(null!=e.type&&e.hasOwnProperty("type")&&(n.type=t.enums===String?void 0===l.onnx.AttributeProto.AttributeType[e.type]?e.type:l.onnx.AttributeProto.AttributeType[e.type]:e.type),null!=e.refAttrName&&e.hasOwnProperty("refAttrName")&&(n.refAttrName=e.refAttrName),null!=e.sparseTensor&&e.hasOwnProperty("sparseTensor")&&(n.sparseTensor=l.onnx.SparseTensorProto.toObject(e.sparseTensor,t)),e.sparseTensors&&e.sparseTensors.length)for(n.sparseTensors=[],o=0;o<e.sparseTensors.length;++o)n.sparseTensors[o]=l.onnx.SparseTensorProto.toObject(e.sparseTensors[o],t);return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.AttributeProto"},e.AttributeType=function(){var e={},t=Object.create(e);return t[e[0]="UNDEFINED"]=0,t[e[1]="FLOAT"]=1,t[e[2]="INT"]=2,t[e[3]="STRING"]=3,t[e[4]="TENSOR"]=4,t[e[5]="GRAPH"]=5,t[e[11]="SPARSE_TENSOR"]=11,t[e[13]="TYPE_PROTO"]=13,t[e[6]="FLOATS"]=6,t[e[7]="INTS"]=7,t[e[8]="STRINGS"]=8,t[e[9]="TENSORS"]=9,t[e[10]="GRAPHS"]=10,t[e[12]="SPARSE_TENSORS"]=12,t[e[14]="TYPE_PROTOS"]=14,t}(),e}(),o.ValueInfoProto=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.name="",e.prototype.type=null,e.prototype.docString="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.name&&Object.hasOwnProperty.call(e,"name")&&t.uint32(10).string(e.name),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&l.onnx.TypeProto.encode(e.type,t.uint32(18).fork()).ldelim(),null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(26).string(e.docString),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.ValueInfoProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.name=e.string();break;case 2:r.type=l.onnx.TypeProto.decode(e,e.uint32());break;case 3:r.docString=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.name&&e.hasOwnProperty("name")&&!u.isString(e.name))return"name: string expected";if(null!=e.type&&e.hasOwnProperty("type")){var t=l.onnx.TypeProto.verify(e.type);if(t)return"type."+t}return null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString)?"docString: string expected":null},e.fromObject=function(e){if(e instanceof l.onnx.ValueInfoProto)return e;var t=new l.onnx.ValueInfoProto;if(null!=e.name&&(t.name=String(e.name)),null!=e.type){if("object"!=typeof e.type)throw TypeError(".onnx.ValueInfoProto.type: object expected");t.type=l.onnx.TypeProto.fromObject(e.type)}return null!=e.docString&&(t.docString=String(e.docString)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.name="",n.type=null,n.docString=""),null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),null!=e.type&&e.hasOwnProperty("type")&&(n.type=l.onnx.TypeProto.toObject(e.type,t)),null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.ValueInfoProto"},e}(),o.NodeProto=function(){function e(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.input=u.emptyArray,e.prototype.output=u.emptyArray,e.prototype.name="",e.prototype.opType="",e.prototype.domain="",e.prototype.attribute=u.emptyArray,e.prototype.docString="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.input&&e.input.length)for(var n=0;n<e.input.length;++n)t.uint32(10).string(e.input[n]);if(null!=e.output&&e.output.length)for(n=0;n<e.output.length;++n)t.uint32(18).string(e.output[n]);if(null!=e.name&&Object.hasOwnProperty.call(e,"name")&&t.uint32(26).string(e.name),null!=e.opType&&Object.hasOwnProperty.call(e,"opType")&&t.uint32(34).string(e.opType),null!=e.attribute&&e.attribute.length)for(n=0;n<e.attribute.length;++n)l.onnx.AttributeProto.encode(e.attribute[n],t.uint32(42).fork()).ldelim();return null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(50).string(e.docString),null!=e.domain&&Object.hasOwnProperty.call(e,"domain")&&t.uint32(58).string(e.domain),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.NodeProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.input&&r.input.length||(r.input=[]),r.input.push(e.string());break;case 2:r.output&&r.output.length||(r.output=[]),r.output.push(e.string());break;case 3:r.name=e.string();break;case 4:r.opType=e.string();break;case 7:r.domain=e.string();break;case 5:r.attribute&&r.attribute.length||(r.attribute=[]),r.attribute.push(l.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:r.docString=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.input&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var t=0;t<e.input.length;++t)if(!u.isString(e.input[t]))return"input: string[] expected"}if(null!=e.output&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(t=0;t<e.output.length;++t)if(!u.isString(e.output[t]))return"output: string[] expected"}if(null!=e.name&&e.hasOwnProperty("name")&&!u.isString(e.name))return"name: string expected";if(null!=e.opType&&e.hasOwnProperty("opType")&&!u.isString(e.opType))return"opType: string expected";if(null!=e.domain&&e.hasOwnProperty("domain")&&!u.isString(e.domain))return"domain: string expected";if(null!=e.attribute&&e.hasOwnProperty("attribute")){if(!Array.isArray(e.attribute))return"attribute: array expected";for(t=0;t<e.attribute.length;++t){var n=l.onnx.AttributeProto.verify(e.attribute[t]);if(n)return"attribute."+n}}return null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString)?"docString: string expected":null},e.fromObject=function(e){if(e instanceof l.onnx.NodeProto)return e;var t=new l.onnx.NodeProto;if(e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.NodeProto.input: array expected");t.input=[];for(var n=0;n<e.input.length;++n)t.input[n]=String(e.input[n])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.NodeProto.output: array expected");for(t.output=[],n=0;n<e.output.length;++n)t.output[n]=String(e.output[n])}if(null!=e.name&&(t.name=String(e.name)),null!=e.opType&&(t.opType=String(e.opType)),null!=e.domain&&(t.domain=String(e.domain)),e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");for(t.attribute=[],n=0;n<e.attribute.length;++n){if("object"!=typeof e.attribute[n])throw TypeError(".onnx.NodeProto.attribute: object expected");t.attribute[n]=l.onnx.AttributeProto.fromObject(e.attribute[n])}}return null!=e.docString&&(t.docString=String(e.docString)),t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.input=[],n.output=[],n.attribute=[]),t.defaults&&(n.name="",n.opType="",n.docString="",n.domain=""),e.input&&e.input.length){n.input=[];for(var r=0;r<e.input.length;++r)n.input[r]=e.input[r]}if(e.output&&e.output.length)for(n.output=[],r=0;r<e.output.length;++r)n.output[r]=e.output[r];if(null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),null!=e.opType&&e.hasOwnProperty("opType")&&(n.opType=e.opType),e.attribute&&e.attribute.length)for(n.attribute=[],r=0;r<e.attribute.length;++r)n.attribute[r]=l.onnx.AttributeProto.toObject(e.attribute[r],t);return null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),null!=e.domain&&e.hasOwnProperty("domain")&&(n.domain=e.domain),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.NodeProto"},e}(),o.TrainingInfoProto=function(){function e(e){if(this.initializationBinding=[],this.updateBinding=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.initialization=null,e.prototype.algorithm=null,e.prototype.initializationBinding=u.emptyArray,e.prototype.updateBinding=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.initialization&&Object.hasOwnProperty.call(e,"initialization")&&l.onnx.GraphProto.encode(e.initialization,t.uint32(10).fork()).ldelim(),null!=e.algorithm&&Object.hasOwnProperty.call(e,"algorithm")&&l.onnx.GraphProto.encode(e.algorithm,t.uint32(18).fork()).ldelim(),null!=e.initializationBinding&&e.initializationBinding.length)for(var n=0;n<e.initializationBinding.length;++n)l.onnx.StringStringEntryProto.encode(e.initializationBinding[n],t.uint32(26).fork()).ldelim();if(null!=e.updateBinding&&e.updateBinding.length)for(n=0;n<e.updateBinding.length;++n)l.onnx.StringStringEntryProto.encode(e.updateBinding[n],t.uint32(34).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TrainingInfoProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.initialization=l.onnx.GraphProto.decode(e,e.uint32());break;case 2:r.algorithm=l.onnx.GraphProto.decode(e,e.uint32());break;case 3:r.initializationBinding&&r.initializationBinding.length||(r.initializationBinding=[]),r.initializationBinding.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;case 4:r.updateBinding&&r.updateBinding.length||(r.updateBinding=[]),r.updateBinding.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.initialization&&e.hasOwnProperty("initialization")&&(n=l.onnx.GraphProto.verify(e.initialization)))return"initialization."+n;if(null!=e.algorithm&&e.hasOwnProperty("algorithm")&&(n=l.onnx.GraphProto.verify(e.algorithm)))return"algorithm."+n;if(null!=e.initializationBinding&&e.hasOwnProperty("initializationBinding")){if(!Array.isArray(e.initializationBinding))return"initializationBinding: array expected";for(var t=0;t<e.initializationBinding.length;++t)if(n=l.onnx.StringStringEntryProto.verify(e.initializationBinding[t]))return"initializationBinding."+n}if(null!=e.updateBinding&&e.hasOwnProperty("updateBinding")){if(!Array.isArray(e.updateBinding))return"updateBinding: array expected";for(t=0;t<e.updateBinding.length;++t){var n;if(n=l.onnx.StringStringEntryProto.verify(e.updateBinding[t]))return"updateBinding."+n}}return null},e.fromObject=function(e){if(e instanceof l.onnx.TrainingInfoProto)return e;var t=new l.onnx.TrainingInfoProto;if(null!=e.initialization){if("object"!=typeof e.initialization)throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");t.initialization=l.onnx.GraphProto.fromObject(e.initialization)}if(null!=e.algorithm){if("object"!=typeof e.algorithm)throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");t.algorithm=l.onnx.GraphProto.fromObject(e.algorithm)}if(e.initializationBinding){if(!Array.isArray(e.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");t.initializationBinding=[];for(var n=0;n<e.initializationBinding.length;++n){if("object"!=typeof e.initializationBinding[n])throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");t.initializationBinding[n]=l.onnx.StringStringEntryProto.fromObject(e.initializationBinding[n])}}if(e.updateBinding){if(!Array.isArray(e.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");for(t.updateBinding=[],n=0;n<e.updateBinding.length;++n){if("object"!=typeof e.updateBinding[n])throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");t.updateBinding[n]=l.onnx.StringStringEntryProto.fromObject(e.updateBinding[n])}}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.initializationBinding=[],n.updateBinding=[]),t.defaults&&(n.initialization=null,n.algorithm=null),null!=e.initialization&&e.hasOwnProperty("initialization")&&(n.initialization=l.onnx.GraphProto.toObject(e.initialization,t)),null!=e.algorithm&&e.hasOwnProperty("algorithm")&&(n.algorithm=l.onnx.GraphProto.toObject(e.algorithm,t)),e.initializationBinding&&e.initializationBinding.length){n.initializationBinding=[];for(var r=0;r<e.initializationBinding.length;++r)n.initializationBinding[r]=l.onnx.StringStringEntryProto.toObject(e.initializationBinding[r],t)}if(e.updateBinding&&e.updateBinding.length)for(n.updateBinding=[],r=0;r<e.updateBinding.length;++r)n.updateBinding[r]=l.onnx.StringStringEntryProto.toObject(e.updateBinding[r],t);return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TrainingInfoProto"},e}(),o.ModelProto=function(){function e(e){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.irVersion=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.opsetImport=u.emptyArray,e.prototype.producerName="",e.prototype.producerVersion="",e.prototype.domain="",e.prototype.modelVersion=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.docString="",e.prototype.graph=null,e.prototype.metadataProps=u.emptyArray,e.prototype.trainingInfo=u.emptyArray,e.prototype.functions=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.irVersion&&Object.hasOwnProperty.call(e,"irVersion")&&t.uint32(8).int64(e.irVersion),null!=e.producerName&&Object.hasOwnProperty.call(e,"producerName")&&t.uint32(18).string(e.producerName),null!=e.producerVersion&&Object.hasOwnProperty.call(e,"producerVersion")&&t.uint32(26).string(e.producerVersion),null!=e.domain&&Object.hasOwnProperty.call(e,"domain")&&t.uint32(34).string(e.domain),null!=e.modelVersion&&Object.hasOwnProperty.call(e,"modelVersion")&&t.uint32(40).int64(e.modelVersion),null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(50).string(e.docString),null!=e.graph&&Object.hasOwnProperty.call(e,"graph")&&l.onnx.GraphProto.encode(e.graph,t.uint32(58).fork()).ldelim(),null!=e.opsetImport&&e.opsetImport.length)for(var n=0;n<e.opsetImport.length;++n)l.onnx.OperatorSetIdProto.encode(e.opsetImport[n],t.uint32(66).fork()).ldelim();if(null!=e.metadataProps&&e.metadataProps.length)for(n=0;n<e.metadataProps.length;++n)l.onnx.StringStringEntryProto.encode(e.metadataProps[n],t.uint32(114).fork()).ldelim();if(null!=e.trainingInfo&&e.trainingInfo.length)for(n=0;n<e.trainingInfo.length;++n)l.onnx.TrainingInfoProto.encode(e.trainingInfo[n],t.uint32(162).fork()).ldelim();if(null!=e.functions&&e.functions.length)for(n=0;n<e.functions.length;++n)l.onnx.FunctionProto.encode(e.functions[n],t.uint32(202).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.ModelProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.irVersion=e.int64();break;case 8:r.opsetImport&&r.opsetImport.length||(r.opsetImport=[]),r.opsetImport.push(l.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:r.producerName=e.string();break;case 3:r.producerVersion=e.string();break;case 4:r.domain=e.string();break;case 5:r.modelVersion=e.int64();break;case 6:r.docString=e.string();break;case 7:r.graph=l.onnx.GraphProto.decode(e,e.uint32());break;case 14:r.metadataProps&&r.metadataProps.length||(r.metadataProps=[]),r.metadataProps.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;case 20:r.trainingInfo&&r.trainingInfo.length||(r.trainingInfo=[]),r.trainingInfo.push(l.onnx.TrainingInfoProto.decode(e,e.uint32()));break;case 25:r.functions&&r.functions.length||(r.functions=[]),r.functions.push(l.onnx.FunctionProto.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.irVersion&&e.hasOwnProperty("irVersion")&&!u.isInteger(e.irVersion)&&!(e.irVersion&&u.isInteger(e.irVersion.low)&&u.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(null!=e.opsetImport&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var t=0;t<e.opsetImport.length;++t)if(n=l.onnx.OperatorSetIdProto.verify(e.opsetImport[t]))return"opsetImport."+n}if(null!=e.producerName&&e.hasOwnProperty("producerName")&&!u.isString(e.producerName))return"producerName: string expected";if(null!=e.producerVersion&&e.hasOwnProperty("producerVersion")&&!u.isString(e.producerVersion))return"producerVersion: string expected";if(null!=e.domain&&e.hasOwnProperty("domain")&&!u.isString(e.domain))return"domain: string expected";if(null!=e.modelVersion&&e.hasOwnProperty("modelVersion")&&!u.isInteger(e.modelVersion)&&!(e.modelVersion&&u.isInteger(e.modelVersion.low)&&u.isInteger(e.modelVersion.high)))return"modelVersion: integer|Long expected";if(null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString))return"docString: string expected";if(null!=e.graph&&e.hasOwnProperty("graph")&&(n=l.onnx.GraphProto.verify(e.graph)))return"graph."+n;if(null!=e.metadataProps&&e.hasOwnProperty("metadataProps")){if(!Array.isArray(e.metadataProps))return"metadataProps: array expected";for(t=0;t<e.metadataProps.length;++t)if(n=l.onnx.StringStringEntryProto.verify(e.metadataProps[t]))return"metadataProps."+n}if(null!=e.trainingInfo&&e.hasOwnProperty("trainingInfo")){if(!Array.isArray(e.trainingInfo))return"trainingInfo: array expected";for(t=0;t<e.trainingInfo.length;++t)if(n=l.onnx.TrainingInfoProto.verify(e.trainingInfo[t]))return"trainingInfo."+n}if(null!=e.functions&&e.hasOwnProperty("functions")){if(!Array.isArray(e.functions))return"functions: array expected";for(t=0;t<e.functions.length;++t){var n;if(n=l.onnx.FunctionProto.verify(e.functions[t]))return"functions."+n}}return null},e.fromObject=function(e){if(e instanceof l.onnx.ModelProto)return e;var t=new l.onnx.ModelProto;if(null!=e.irVersion&&(u.Long?(t.irVersion=u.Long.fromValue(e.irVersion)).unsigned=!1:"string"==typeof e.irVersion?t.irVersion=parseInt(e.irVersion,10):"number"==typeof e.irVersion?t.irVersion=e.irVersion:"object"==typeof e.irVersion&&(t.irVersion=new u.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");t.opsetImport=[];for(var n=0;n<e.opsetImport.length;++n){if("object"!=typeof e.opsetImport[n])throw TypeError(".onnx.ModelProto.opsetImport: object expected");t.opsetImport[n]=l.onnx.OperatorSetIdProto.fromObject(e.opsetImport[n])}}if(null!=e.producerName&&(t.producerName=String(e.producerName)),null!=e.producerVersion&&(t.producerVersion=String(e.producerVersion)),null!=e.domain&&(t.domain=String(e.domain)),null!=e.modelVersion&&(u.Long?(t.modelVersion=u.Long.fromValue(e.modelVersion)).unsigned=!1:"string"==typeof e.modelVersion?t.modelVersion=parseInt(e.modelVersion,10):"number"==typeof e.modelVersion?t.modelVersion=e.modelVersion:"object"==typeof e.modelVersion&&(t.modelVersion=new u.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber())),null!=e.docString&&(t.docString=String(e.docString)),null!=e.graph){if("object"!=typeof e.graph)throw TypeError(".onnx.ModelProto.graph: object expected");t.graph=l.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(t.metadataProps=[],n=0;n<e.metadataProps.length;++n){if("object"!=typeof e.metadataProps[n])throw TypeError(".onnx.ModelProto.metadataProps: object expected");t.metadataProps[n]=l.onnx.StringStringEntryProto.fromObject(e.metadataProps[n])}}if(e.trainingInfo){if(!Array.isArray(e.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");for(t.trainingInfo=[],n=0;n<e.trainingInfo.length;++n){if("object"!=typeof e.trainingInfo[n])throw TypeError(".onnx.ModelProto.trainingInfo: object expected");t.trainingInfo[n]=l.onnx.TrainingInfoProto.fromObject(e.trainingInfo[n])}}if(e.functions){if(!Array.isArray(e.functions))throw TypeError(".onnx.ModelProto.functions: array expected");for(t.functions=[],n=0;n<e.functions.length;++n){if("object"!=typeof e.functions[n])throw TypeError(".onnx.ModelProto.functions: object expected");t.functions[n]=l.onnx.FunctionProto.fromObject(e.functions[n])}}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.opsetImport=[],n.metadataProps=[],n.trainingInfo=[],n.functions=[]),t.defaults){if(u.Long){var r=new u.Long(0,0,!1);n.irVersion=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.irVersion=t.longs===String?"0":0;n.producerName="",n.producerVersion="",n.domain="",u.Long?(r=new u.Long(0,0,!1),n.modelVersion=t.longs===String?r.toString():t.longs===Number?r.toNumber():r):n.modelVersion=t.longs===String?"0":0,n.docString="",n.graph=null}if(null!=e.irVersion&&e.hasOwnProperty("irVersion")&&("number"==typeof e.irVersion?n.irVersion=t.longs===String?String(e.irVersion):e.irVersion:n.irVersion=t.longs===String?u.Long.prototype.toString.call(e.irVersion):t.longs===Number?new u.LongBits(e.irVersion.low>>>0,e.irVersion.high>>>0).toNumber():e.irVersion),null!=e.producerName&&e.hasOwnProperty("producerName")&&(n.producerName=e.producerName),null!=e.producerVersion&&e.hasOwnProperty("producerVersion")&&(n.producerVersion=e.producerVersion),null!=e.domain&&e.hasOwnProperty("domain")&&(n.domain=e.domain),null!=e.modelVersion&&e.hasOwnProperty("modelVersion")&&("number"==typeof e.modelVersion?n.modelVersion=t.longs===String?String(e.modelVersion):e.modelVersion:n.modelVersion=t.longs===String?u.Long.prototype.toString.call(e.modelVersion):t.longs===Number?new u.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),null!=e.graph&&e.hasOwnProperty("graph")&&(n.graph=l.onnx.GraphProto.toObject(e.graph,t)),e.opsetImport&&e.opsetImport.length){n.opsetImport=[];for(var o=0;o<e.opsetImport.length;++o)n.opsetImport[o]=l.onnx.OperatorSetIdProto.toObject(e.opsetImport[o],t)}if(e.metadataProps&&e.metadataProps.length)for(n.metadataProps=[],o=0;o<e.metadataProps.length;++o)n.metadataProps[o]=l.onnx.StringStringEntryProto.toObject(e.metadataProps[o],t);if(e.trainingInfo&&e.trainingInfo.length)for(n.trainingInfo=[],o=0;o<e.trainingInfo.length;++o)n.trainingInfo[o]=l.onnx.TrainingInfoProto.toObject(e.trainingInfo[o],t);if(e.functions&&e.functions.length)for(n.functions=[],o=0;o<e.functions.length;++o)n.functions[o]=l.onnx.FunctionProto.toObject(e.functions[o],t);return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.ModelProto"},e}(),o.StringStringEntryProto=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.key="",e.prototype.value="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.key&&Object.hasOwnProperty.call(e,"key")&&t.uint32(10).string(e.key),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(18).string(e.value),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.StringStringEntryProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.key=e.string();break;case 2:r.value=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.key&&e.hasOwnProperty("key")&&!u.isString(e.key)?"key: string expected":null!=e.value&&e.hasOwnProperty("value")&&!u.isString(e.value)?"value: string expected":null},e.fromObject=function(e){if(e instanceof l.onnx.StringStringEntryProto)return e;var t=new l.onnx.StringStringEntryProto;return null!=e.key&&(t.key=String(e.key)),null!=e.value&&(t.value=String(e.value)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.key="",n.value=""),null!=e.key&&e.hasOwnProperty("key")&&(n.key=e.key),null!=e.value&&e.hasOwnProperty("value")&&(n.value=e.value),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.StringStringEntryProto"},e}(),o.TensorAnnotation=function(){function e(e){if(this.quantParameterTensorNames=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.tensorName="",e.prototype.quantParameterTensorNames=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.tensorName&&Object.hasOwnProperty.call(e,"tensorName")&&t.uint32(10).string(e.tensorName),null!=e.quantParameterTensorNames&&e.quantParameterTensorNames.length)for(var n=0;n<e.quantParameterTensorNames.length;++n)l.onnx.StringStringEntryProto.encode(e.quantParameterTensorNames[n],t.uint32(18).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TensorAnnotation;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.tensorName=e.string();break;case 2:r.quantParameterTensorNames&&r.quantParameterTensorNames.length||(r.quantParameterTensorNames=[]),r.quantParameterTensorNames.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.tensorName&&e.hasOwnProperty("tensorName")&&!u.isString(e.tensorName))return"tensorName: string expected";if(null!=e.quantParameterTensorNames&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var t=0;t<e.quantParameterTensorNames.length;++t){var n=l.onnx.StringStringEntryProto.verify(e.quantParameterTensorNames[t]);if(n)return"quantParameterTensorNames."+n}}return null},e.fromObject=function(e){if(e instanceof l.onnx.TensorAnnotation)return e;var t=new l.onnx.TensorAnnotation;if(null!=e.tensorName&&(t.tensorName=String(e.tensorName)),e.quantParameterTensorNames){if(!Array.isArray(e.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");t.quantParameterTensorNames=[];for(var n=0;n<e.quantParameterTensorNames.length;++n){if("object"!=typeof e.quantParameterTensorNames[n])throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");t.quantParameterTensorNames[n]=l.onnx.StringStringEntryProto.fromObject(e.quantParameterTensorNames[n])}}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.quantParameterTensorNames=[]),t.defaults&&(n.tensorName=""),null!=e.tensorName&&e.hasOwnProperty("tensorName")&&(n.tensorName=e.tensorName),e.quantParameterTensorNames&&e.quantParameterTensorNames.length){n.quantParameterTensorNames=[];for(var r=0;r<e.quantParameterTensorNames.length;++r)n.quantParameterTensorNames[r]=l.onnx.StringStringEntryProto.toObject(e.quantParameterTensorNames[r],t)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TensorAnnotation"},e}(),o.GraphProto=function(){function e(e){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.node=u.emptyArray,e.prototype.name="",e.prototype.initializer=u.emptyArray,e.prototype.sparseInitializer=u.emptyArray,e.prototype.docString="",e.prototype.input=u.emptyArray,e.prototype.output=u.emptyArray,e.prototype.valueInfo=u.emptyArray,e.prototype.quantizationAnnotation=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.node&&e.node.length)for(var n=0;n<e.node.length;++n)l.onnx.NodeProto.encode(e.node[n],t.uint32(10).fork()).ldelim();if(null!=e.name&&Object.hasOwnProperty.call(e,"name")&&t.uint32(18).string(e.name),null!=e.initializer&&e.initializer.length)for(n=0;n<e.initializer.length;++n)l.onnx.TensorProto.encode(e.initializer[n],t.uint32(42).fork()).ldelim();if(null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(82).string(e.docString),null!=e.input&&e.input.length)for(n=0;n<e.input.length;++n)l.onnx.ValueInfoProto.encode(e.input[n],t.uint32(90).fork()).ldelim();if(null!=e.output&&e.output.length)for(n=0;n<e.output.length;++n)l.onnx.ValueInfoProto.encode(e.output[n],t.uint32(98).fork()).ldelim();if(null!=e.valueInfo&&e.valueInfo.length)for(n=0;n<e.valueInfo.length;++n)l.onnx.ValueInfoProto.encode(e.valueInfo[n],t.uint32(106).fork()).ldelim();if(null!=e.quantizationAnnotation&&e.quantizationAnnotation.length)for(n=0;n<e.quantizationAnnotation.length;++n)l.onnx.TensorAnnotation.encode(e.quantizationAnnotation[n],t.uint32(114).fork()).ldelim();if(null!=e.sparseInitializer&&e.sparseInitializer.length)for(n=0;n<e.sparseInitializer.length;++n)l.onnx.SparseTensorProto.encode(e.sparseInitializer[n],t.uint32(122).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.GraphProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.node&&r.node.length||(r.node=[]),r.node.push(l.onnx.NodeProto.decode(e,e.uint32()));break;case 2:r.name=e.string();break;case 5:r.initializer&&r.initializer.length||(r.initializer=[]),r.initializer.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 15:r.sparseInitializer&&r.sparseInitializer.length||(r.sparseInitializer=[]),r.sparseInitializer.push(l.onnx.SparseTensorProto.decode(e,e.uint32()));break;case 10:r.docString=e.string();break;case 11:r.input&&r.input.length||(r.input=[]),r.input.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:r.output&&r.output.length||(r.output=[]),r.output.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:r.valueInfo&&r.valueInfo.length||(r.valueInfo=[]),r.valueInfo.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:r.quantizationAnnotation&&r.quantizationAnnotation.length||(r.quantizationAnnotation=[]),r.quantizationAnnotation.push(l.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.node&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var t=0;t<e.node.length;++t)if(n=l.onnx.NodeProto.verify(e.node[t]))return"node."+n}if(null!=e.name&&e.hasOwnProperty("name")&&!u.isString(e.name))return"name: string expected";if(null!=e.initializer&&e.hasOwnProperty("initializer")){if(!Array.isArray(e.initializer))return"initializer: array expected";for(t=0;t<e.initializer.length;++t)if(n=l.onnx.TensorProto.verify(e.initializer[t]))return"initializer."+n}if(null!=e.sparseInitializer&&e.hasOwnProperty("sparseInitializer")){if(!Array.isArray(e.sparseInitializer))return"sparseInitializer: array expected";for(t=0;t<e.sparseInitializer.length;++t)if(n=l.onnx.SparseTensorProto.verify(e.sparseInitializer[t]))return"sparseInitializer."+n}if(null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString))return"docString: string expected";if(null!=e.input&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(t=0;t<e.input.length;++t)if(n=l.onnx.ValueInfoProto.verify(e.input[t]))return"input."+n}if(null!=e.output&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(t=0;t<e.output.length;++t)if(n=l.onnx.ValueInfoProto.verify(e.output[t]))return"output."+n}if(null!=e.valueInfo&&e.hasOwnProperty("valueInfo")){if(!Array.isArray(e.valueInfo))return"valueInfo: array expected";for(t=0;t<e.valueInfo.length;++t)if(n=l.onnx.ValueInfoProto.verify(e.valueInfo[t]))return"valueInfo."+n}if(null!=e.quantizationAnnotation&&e.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(e.quantizationAnnotation))return"quantizationAnnotation: array expected";for(t=0;t<e.quantizationAnnotation.length;++t){var n;if(n=l.onnx.TensorAnnotation.verify(e.quantizationAnnotation[t]))return"quantizationAnnotation."+n}}return null},e.fromObject=function(e){if(e instanceof l.onnx.GraphProto)return e;var t=new l.onnx.GraphProto;if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.GraphProto.node: array expected");t.node=[];for(var n=0;n<e.node.length;++n){if("object"!=typeof e.node[n])throw TypeError(".onnx.GraphProto.node: object expected");t.node[n]=l.onnx.NodeProto.fromObject(e.node[n])}}if(null!=e.name&&(t.name=String(e.name)),e.initializer){if(!Array.isArray(e.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");for(t.initializer=[],n=0;n<e.initializer.length;++n){if("object"!=typeof e.initializer[n])throw TypeError(".onnx.GraphProto.initializer: object expected");t.initializer[n]=l.onnx.TensorProto.fromObject(e.initializer[n])}}if(e.sparseInitializer){if(!Array.isArray(e.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");for(t.sparseInitializer=[],n=0;n<e.sparseInitializer.length;++n){if("object"!=typeof e.sparseInitializer[n])throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");t.sparseInitializer[n]=l.onnx.SparseTensorProto.fromObject(e.sparseInitializer[n])}}if(null!=e.docString&&(t.docString=String(e.docString)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.GraphProto.input: array expected");for(t.input=[],n=0;n<e.input.length;++n){if("object"!=typeof e.input[n])throw TypeError(".onnx.GraphProto.input: object expected");t.input[n]=l.onnx.ValueInfoProto.fromObject(e.input[n])}}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.GraphProto.output: array expected");for(t.output=[],n=0;n<e.output.length;++n){if("object"!=typeof e.output[n])throw TypeError(".onnx.GraphProto.output: object expected");t.output[n]=l.onnx.ValueInfoProto.fromObject(e.output[n])}}if(e.valueInfo){if(!Array.isArray(e.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");for(t.valueInfo=[],n=0;n<e.valueInfo.length;++n){if("object"!=typeof e.valueInfo[n])throw TypeError(".onnx.GraphProto.valueInfo: object expected");t.valueInfo[n]=l.onnx.ValueInfoProto.fromObject(e.valueInfo[n])}}if(e.quantizationAnnotation){if(!Array.isArray(e.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");for(t.quantizationAnnotation=[],n=0;n<e.quantizationAnnotation.length;++n){if("object"!=typeof e.quantizationAnnotation[n])throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");t.quantizationAnnotation[n]=l.onnx.TensorAnnotation.fromObject(e.quantizationAnnotation[n])}}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.node=[],n.initializer=[],n.input=[],n.output=[],n.valueInfo=[],n.quantizationAnnotation=[],n.sparseInitializer=[]),t.defaults&&(n.name="",n.docString=""),e.node&&e.node.length){n.node=[];for(var r=0;r<e.node.length;++r)n.node[r]=l.onnx.NodeProto.toObject(e.node[r],t)}if(null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),e.initializer&&e.initializer.length)for(n.initializer=[],r=0;r<e.initializer.length;++r)n.initializer[r]=l.onnx.TensorProto.toObject(e.initializer[r],t);if(null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),e.input&&e.input.length)for(n.input=[],r=0;r<e.input.length;++r)n.input[r]=l.onnx.ValueInfoProto.toObject(e.input[r],t);if(e.output&&e.output.length)for(n.output=[],r=0;r<e.output.length;++r)n.output[r]=l.onnx.ValueInfoProto.toObject(e.output[r],t);if(e.valueInfo&&e.valueInfo.length)for(n.valueInfo=[],r=0;r<e.valueInfo.length;++r)n.valueInfo[r]=l.onnx.ValueInfoProto.toObject(e.valueInfo[r],t);if(e.quantizationAnnotation&&e.quantizationAnnotation.length)for(n.quantizationAnnotation=[],r=0;r<e.quantizationAnnotation.length;++r)n.quantizationAnnotation[r]=l.onnx.TensorAnnotation.toObject(e.quantizationAnnotation[r],t);if(e.sparseInitializer&&e.sparseInitializer.length)for(n.sparseInitializer=[],r=0;r<e.sparseInitializer.length;++r)n.sparseInitializer[r]=l.onnx.SparseTensorProto.toObject(e.sparseInitializer[r],t);return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.GraphProto"},e}(),o.TensorProto=function(){function e(e){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dims=u.emptyArray,e.prototype.dataType=0,e.prototype.segment=null,e.prototype.floatData=u.emptyArray,e.prototype.int32Data=u.emptyArray,e.prototype.stringData=u.emptyArray,e.prototype.int64Data=u.emptyArray,e.prototype.name="",e.prototype.docString="",e.prototype.rawData=u.newBuffer([]),e.prototype.externalData=u.emptyArray,e.prototype.dataLocation=0,e.prototype.doubleData=u.emptyArray,e.prototype.uint64Data=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.dims&&e.dims.length){t.uint32(10).fork();for(var n=0;n<e.dims.length;++n)t.int64(e.dims[n]);t.ldelim()}if(null!=e.dataType&&Object.hasOwnProperty.call(e,"dataType")&&t.uint32(16).int32(e.dataType),null!=e.segment&&Object.hasOwnProperty.call(e,"segment")&&l.onnx.TensorProto.Segment.encode(e.segment,t.uint32(26).fork()).ldelim(),null!=e.floatData&&e.floatData.length){for(t.uint32(34).fork(),n=0;n<e.floatData.length;++n)t.float(e.floatData[n]);t.ldelim()}if(null!=e.int32Data&&e.int32Data.length){for(t.uint32(42).fork(),n=0;n<e.int32Data.length;++n)t.int32(e.int32Data[n]);t.ldelim()}if(null!=e.stringData&&e.stringData.length)for(n=0;n<e.stringData.length;++n)t.uint32(50).bytes(e.stringData[n]);if(null!=e.int64Data&&e.int64Data.length){for(t.uint32(58).fork(),n=0;n<e.int64Data.length;++n)t.int64(e.int64Data[n]);t.ldelim()}if(null!=e.name&&Object.hasOwnProperty.call(e,"name")&&t.uint32(66).string(e.name),null!=e.rawData&&Object.hasOwnProperty.call(e,"rawData")&&t.uint32(74).bytes(e.rawData),null!=e.doubleData&&e.doubleData.length){for(t.uint32(82).fork(),n=0;n<e.doubleData.length;++n)t.double(e.doubleData[n]);t.ldelim()}if(null!=e.uint64Data&&e.uint64Data.length){for(t.uint32(90).fork(),n=0;n<e.uint64Data.length;++n)t.uint64(e.uint64Data[n]);t.ldelim()}if(null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(98).string(e.docString),null!=e.externalData&&e.externalData.length)for(n=0;n<e.externalData.length;++n)l.onnx.StringStringEntryProto.encode(e.externalData[n],t.uint32(106).fork()).ldelim();return null!=e.dataLocation&&Object.hasOwnProperty.call(e,"dataLocation")&&t.uint32(112).int32(e.dataLocation),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TensorProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:if(r.dims&&r.dims.length||(r.dims=[]),2==(7&o))for(var i=e.uint32()+e.pos;e.pos<i;)r.dims.push(e.int64());else r.dims.push(e.int64());break;case 2:r.dataType=e.int32();break;case 3:r.segment=l.onnx.TensorProto.Segment.decode(e,e.uint32());break;case 4:if(r.floatData&&r.floatData.length||(r.floatData=[]),2==(7&o))for(i=e.uint32()+e.pos;e.pos<i;)r.floatData.push(e.float());else r.floatData.push(e.float());break;case 5:if(r.int32Data&&r.int32Data.length||(r.int32Data=[]),2==(7&o))for(i=e.uint32()+e.pos;e.pos<i;)r.int32Data.push(e.int32());else r.int32Data.push(e.int32());break;case 6:r.stringData&&r.stringData.length||(r.stringData=[]),r.stringData.push(e.bytes());break;case 7:if(r.int64Data&&r.int64Data.length||(r.int64Data=[]),2==(7&o))for(i=e.uint32()+e.pos;e.pos<i;)r.int64Data.push(e.int64());else r.int64Data.push(e.int64());break;case 8:r.name=e.string();break;case 12:r.docString=e.string();break;case 9:r.rawData=e.bytes();break;case 13:r.externalData&&r.externalData.length||(r.externalData=[]),r.externalData.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;case 14:r.dataLocation=e.int32();break;case 10:if(r.doubleData&&r.doubleData.length||(r.doubleData=[]),2==(7&o))for(i=e.uint32()+e.pos;e.pos<i;)r.doubleData.push(e.double());else r.doubleData.push(e.double());break;case 11:if(r.uint64Data&&r.uint64Data.length||(r.uint64Data=[]),2==(7&o))for(i=e.uint32()+e.pos;e.pos<i;)r.uint64Data.push(e.uint64());else r.uint64Data.push(e.uint64());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.dims&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var t=0;t<e.dims.length;++t)if(!(u.isInteger(e.dims[t])||e.dims[t]&&u.isInteger(e.dims[t].low)&&u.isInteger(e.dims[t].high)))return"dims: integer|Long[] expected"}if(null!=e.dataType&&e.hasOwnProperty("dataType")&&!u.isInteger(e.dataType))return"dataType: integer expected";if(null!=e.segment&&e.hasOwnProperty("segment")&&(n=l.onnx.TensorProto.Segment.verify(e.segment)))return"segment."+n;if(null!=e.floatData&&e.hasOwnProperty("floatData")){if(!Array.isArray(e.floatData))return"floatData: array expected";for(t=0;t<e.floatData.length;++t)if("number"!=typeof e.floatData[t])return"floatData: number[] expected"}if(null!=e.int32Data&&e.hasOwnProperty("int32Data")){if(!Array.isArray(e.int32Data))return"int32Data: array expected";for(t=0;t<e.int32Data.length;++t)if(!u.isInteger(e.int32Data[t]))return"int32Data: integer[] expected"}if(null!=e.stringData&&e.hasOwnProperty("stringData")){if(!Array.isArray(e.stringData))return"stringData: array expected";for(t=0;t<e.stringData.length;++t)if(!(e.stringData[t]&&"number"==typeof e.stringData[t].length||u.isString(e.stringData[t])))return"stringData: buffer[] expected"}if(null!=e.int64Data&&e.hasOwnProperty("int64Data")){if(!Array.isArray(e.int64Data))return"int64Data: array expected";for(t=0;t<e.int64Data.length;++t)if(!(u.isInteger(e.int64Data[t])||e.int64Data[t]&&u.isInteger(e.int64Data[t].low)&&u.isInteger(e.int64Data[t].high)))return"int64Data: integer|Long[] expected"}if(null!=e.name&&e.hasOwnProperty("name")&&!u.isString(e.name))return"name: string expected";if(null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString))return"docString: string expected";if(null!=e.rawData&&e.hasOwnProperty("rawData")&&!(e.rawData&&"number"==typeof e.rawData.length||u.isString(e.rawData)))return"rawData: buffer expected";if(null!=e.externalData&&e.hasOwnProperty("externalData")){if(!Array.isArray(e.externalData))return"externalData: array expected";for(t=0;t<e.externalData.length;++t){var n;if(n=l.onnx.StringStringEntryProto.verify(e.externalData[t]))return"externalData."+n}}if(null!=e.dataLocation&&e.hasOwnProperty("dataLocation"))switch(e.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:}if(null!=e.doubleData&&e.hasOwnProperty("doubleData")){if(!Array.isArray(e.doubleData))return"doubleData: array expected";for(t=0;t<e.doubleData.length;++t)if("number"!=typeof e.doubleData[t])return"doubleData: number[] expected"}if(null!=e.uint64Data&&e.hasOwnProperty("uint64Data")){if(!Array.isArray(e.uint64Data))return"uint64Data: array expected";for(t=0;t<e.uint64Data.length;++t)if(!(u.isInteger(e.uint64Data[t])||e.uint64Data[t]&&u.isInteger(e.uint64Data[t].low)&&u.isInteger(e.uint64Data[t].high)))return"uint64Data: integer|Long[] expected"}return null},e.fromObject=function(e){if(e instanceof l.onnx.TensorProto)return e;var t=new l.onnx.TensorProto;if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.TensorProto.dims: array expected");t.dims=[];for(var n=0;n<e.dims.length;++n)u.Long?(t.dims[n]=u.Long.fromValue(e.dims[n])).unsigned=!1:"string"==typeof e.dims[n]?t.dims[n]=parseInt(e.dims[n],10):"number"==typeof e.dims[n]?t.dims[n]=e.dims[n]:"object"==typeof e.dims[n]&&(t.dims[n]=new u.LongBits(e.dims[n].low>>>0,e.dims[n].high>>>0).toNumber())}if(null!=e.dataType&&(t.dataType=0|e.dataType),null!=e.segment){if("object"!=typeof e.segment)throw TypeError(".onnx.TensorProto.segment: object expected");t.segment=l.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(t.floatData=[],n=0;n<e.floatData.length;++n)t.floatData[n]=Number(e.floatData[n])}if(e.int32Data){if(!Array.isArray(e.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");for(t.int32Data=[],n=0;n<e.int32Data.length;++n)t.int32Data[n]=0|e.int32Data[n]}if(e.stringData){if(!Array.isArray(e.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");for(t.stringData=[],n=0;n<e.stringData.length;++n)"string"==typeof e.stringData[n]?u.base64.decode(e.stringData[n],t.stringData[n]=u.newBuffer(u.base64.length(e.stringData[n])),0):e.stringData[n].length>=0&&(t.stringData[n]=e.stringData[n])}if(e.int64Data){if(!Array.isArray(e.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");for(t.int64Data=[],n=0;n<e.int64Data.length;++n)u.Long?(t.int64Data[n]=u.Long.fromValue(e.int64Data[n])).unsigned=!1:"string"==typeof e.int64Data[n]?t.int64Data[n]=parseInt(e.int64Data[n],10):"number"==typeof e.int64Data[n]?t.int64Data[n]=e.int64Data[n]:"object"==typeof e.int64Data[n]&&(t.int64Data[n]=new u.LongBits(e.int64Data[n].low>>>0,e.int64Data[n].high>>>0).toNumber())}if(null!=e.name&&(t.name=String(e.name)),null!=e.docString&&(t.docString=String(e.docString)),null!=e.rawData&&("string"==typeof e.rawData?u.base64.decode(e.rawData,t.rawData=u.newBuffer(u.base64.length(e.rawData)),0):e.rawData.length>=0&&(t.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(t.externalData=[],n=0;n<e.externalData.length;++n){if("object"!=typeof e.externalData[n])throw TypeError(".onnx.TensorProto.externalData: object expected");t.externalData[n]=l.onnx.StringStringEntryProto.fromObject(e.externalData[n])}}switch(e.dataLocation){default:if("number"==typeof e.dataLocation){t.dataLocation=e.dataLocation;break}break;case"DEFAULT":case 0:t.dataLocation=0;break;case"EXTERNAL":case 1:t.dataLocation=1}if(e.doubleData){if(!Array.isArray(e.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");for(t.doubleData=[],n=0;n<e.doubleData.length;++n)t.doubleData[n]=Number(e.doubleData[n])}if(e.uint64Data){if(!Array.isArray(e.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");for(t.uint64Data=[],n=0;n<e.uint64Data.length;++n)u.Long?(t.uint64Data[n]=u.Long.fromValue(e.uint64Data[n])).unsigned=!0:"string"==typeof e.uint64Data[n]?t.uint64Data[n]=parseInt(e.uint64Data[n],10):"number"==typeof e.uint64Data[n]?t.uint64Data[n]=e.uint64Data[n]:"object"==typeof e.uint64Data[n]&&(t.uint64Data[n]=new u.LongBits(e.uint64Data[n].low>>>0,e.uint64Data[n].high>>>0).toNumber(!0))}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.dims=[],n.floatData=[],n.int32Data=[],n.stringData=[],n.int64Data=[],n.doubleData=[],n.uint64Data=[],n.externalData=[]),t.defaults&&(n.dataType=0,n.segment=null,n.name="",t.bytes===String?n.rawData="":(n.rawData=[],t.bytes!==Array&&(n.rawData=u.newBuffer(n.rawData))),n.docString="",n.dataLocation=t.enums===String?"DEFAULT":0),e.dims&&e.dims.length){n.dims=[];for(var r=0;r<e.dims.length;++r)"number"==typeof e.dims[r]?n.dims[r]=t.longs===String?String(e.dims[r]):e.dims[r]:n.dims[r]=t.longs===String?u.Long.prototype.toString.call(e.dims[r]):t.longs===Number?new u.LongBits(e.dims[r].low>>>0,e.dims[r].high>>>0).toNumber():e.dims[r]}if(null!=e.dataType&&e.hasOwnProperty("dataType")&&(n.dataType=e.dataType),null!=e.segment&&e.hasOwnProperty("segment")&&(n.segment=l.onnx.TensorProto.Segment.toObject(e.segment,t)),e.floatData&&e.floatData.length)for(n.floatData=[],r=0;r<e.floatData.length;++r)n.floatData[r]=t.json&&!isFinite(e.floatData[r])?String(e.floatData[r]):e.floatData[r];if(e.int32Data&&e.int32Data.length)for(n.int32Data=[],r=0;r<e.int32Data.length;++r)n.int32Data[r]=e.int32Data[r];if(e.stringData&&e.stringData.length)for(n.stringData=[],r=0;r<e.stringData.length;++r)n.stringData[r]=t.bytes===String?u.base64.encode(e.stringData[r],0,e.stringData[r].length):t.bytes===Array?Array.prototype.slice.call(e.stringData[r]):e.stringData[r];if(e.int64Data&&e.int64Data.length)for(n.int64Data=[],r=0;r<e.int64Data.length;++r)"number"==typeof e.int64Data[r]?n.int64Data[r]=t.longs===String?String(e.int64Data[r]):e.int64Data[r]:n.int64Data[r]=t.longs===String?u.Long.prototype.toString.call(e.int64Data[r]):t.longs===Number?new u.LongBits(e.int64Data[r].low>>>0,e.int64Data[r].high>>>0).toNumber():e.int64Data[r];if(null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),null!=e.rawData&&e.hasOwnProperty("rawData")&&(n.rawData=t.bytes===String?u.base64.encode(e.rawData,0,e.rawData.length):t.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(n.doubleData=[],r=0;r<e.doubleData.length;++r)n.doubleData[r]=t.json&&!isFinite(e.doubleData[r])?String(e.doubleData[r]):e.doubleData[r];if(e.uint64Data&&e.uint64Data.length)for(n.uint64Data=[],r=0;r<e.uint64Data.length;++r)"number"==typeof e.uint64Data[r]?n.uint64Data[r]=t.longs===String?String(e.uint64Data[r]):e.uint64Data[r]:n.uint64Data[r]=t.longs===String?u.Long.prototype.toString.call(e.uint64Data[r]):t.longs===Number?new u.LongBits(e.uint64Data[r].low>>>0,e.uint64Data[r].high>>>0).toNumber(!0):e.uint64Data[r];if(null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),e.externalData&&e.externalData.length)for(n.externalData=[],r=0;r<e.externalData.length;++r)n.externalData[r]=l.onnx.StringStringEntryProto.toObject(e.externalData[r],t);return null!=e.dataLocation&&e.hasOwnProperty("dataLocation")&&(n.dataLocation=t.enums===String?void 0===l.onnx.TensorProto.DataLocation[e.dataLocation]?e.dataLocation:l.onnx.TensorProto.DataLocation[e.dataLocation]:e.dataLocation),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TensorProto"},e.DataType=function(){var e={},t=Object.create(e);return t[e[0]="UNDEFINED"]=0,t[e[1]="FLOAT"]=1,t[e[2]="UINT8"]=2,t[e[3]="INT8"]=3,t[e[4]="UINT16"]=4,t[e[5]="INT16"]=5,t[e[6]="INT32"]=6,t[e[7]="INT64"]=7,t[e[8]="STRING"]=8,t[e[9]="BOOL"]=9,t[e[10]="FLOAT16"]=10,t[e[11]="DOUBLE"]=11,t[e[12]="UINT32"]=12,t[e[13]="UINT64"]=13,t[e[14]="COMPLEX64"]=14,t[e[15]="COMPLEX128"]=15,t[e[16]="BFLOAT16"]=16,t[e[17]="FLOAT8E4M3FN"]=17,t[e[18]="FLOAT8E4M3FNUZ"]=18,t[e[19]="FLOAT8E5M2"]=19,t[e[20]="FLOAT8E5M2FNUZ"]=20,t}(),e.Segment=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.begin=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.end=u.Long?u.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.begin&&Object.hasOwnProperty.call(e,"begin")&&t.uint32(8).int64(e.begin),null!=e.end&&Object.hasOwnProperty.call(e,"end")&&t.uint32(16).int64(e.end),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TensorProto.Segment;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.begin=e.int64();break;case 2:r.end=e.int64();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null==e.begin||!e.hasOwnProperty("begin")||u.isInteger(e.begin)||e.begin&&u.isInteger(e.begin.low)&&u.isInteger(e.begin.high)?null==e.end||!e.hasOwnProperty("end")||u.isInteger(e.end)||e.end&&u.isInteger(e.end.low)&&u.isInteger(e.end.high)?null:"end: integer|Long expected":"begin: integer|Long expected"},e.fromObject=function(e){if(e instanceof l.onnx.TensorProto.Segment)return e;var t=new l.onnx.TensorProto.Segment;return null!=e.begin&&(u.Long?(t.begin=u.Long.fromValue(e.begin)).unsigned=!1:"string"==typeof e.begin?t.begin=parseInt(e.begin,10):"number"==typeof e.begin?t.begin=e.begin:"object"==typeof e.begin&&(t.begin=new u.LongBits(e.begin.low>>>0,e.begin.high>>>0).toNumber())),null!=e.end&&(u.Long?(t.end=u.Long.fromValue(e.end)).unsigned=!1:"string"==typeof e.end?t.end=parseInt(e.end,10):"number"==typeof e.end?t.end=e.end:"object"==typeof e.end&&(t.end=new u.LongBits(e.end.low>>>0,e.end.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(u.Long){var r=new u.Long(0,0,!1);n.begin=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.begin=t.longs===String?"0":0;u.Long?(r=new u.Long(0,0,!1),n.end=t.longs===String?r.toString():t.longs===Number?r.toNumber():r):n.end=t.longs===String?"0":0}return null!=e.begin&&e.hasOwnProperty("begin")&&("number"==typeof e.begin?n.begin=t.longs===String?String(e.begin):e.begin:n.begin=t.longs===String?u.Long.prototype.toString.call(e.begin):t.longs===Number?new u.LongBits(e.begin.low>>>0,e.begin.high>>>0).toNumber():e.begin),null!=e.end&&e.hasOwnProperty("end")&&("number"==typeof e.end?n.end=t.longs===String?String(e.end):e.end:n.end=t.longs===String?u.Long.prototype.toString.call(e.end):t.longs===Number?new u.LongBits(e.end.low>>>0,e.end.high>>>0).toNumber():e.end),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TensorProto.Segment"},e}(),e.DataLocation=function(){var e={},t=Object.create(e);return t[e[0]="DEFAULT"]=0,t[e[1]="EXTERNAL"]=1,t}(),e}(),o.SparseTensorProto=function(){function e(e){if(this.dims=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.values=null,e.prototype.indices=null,e.prototype.dims=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.values&&Object.hasOwnProperty.call(e,"values")&&l.onnx.TensorProto.encode(e.values,t.uint32(10).fork()).ldelim(),null!=e.indices&&Object.hasOwnProperty.call(e,"indices")&&l.onnx.TensorProto.encode(e.indices,t.uint32(18).fork()).ldelim(),null!=e.dims&&e.dims.length){t.uint32(26).fork();for(var n=0;n<e.dims.length;++n)t.int64(e.dims[n]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.SparseTensorProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.values=l.onnx.TensorProto.decode(e,e.uint32());break;case 2:r.indices=l.onnx.TensorProto.decode(e,e.uint32());break;case 3:if(r.dims&&r.dims.length||(r.dims=[]),2==(7&o))for(var i=e.uint32()+e.pos;e.pos<i;)r.dims.push(e.int64());else r.dims.push(e.int64());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t;if(null!=e.values&&e.hasOwnProperty("values")&&(t=l.onnx.TensorProto.verify(e.values)))return"values."+t;if(null!=e.indices&&e.hasOwnProperty("indices")&&(t=l.onnx.TensorProto.verify(e.indices)))return"indices."+t;if(null!=e.dims&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var n=0;n<e.dims.length;++n)if(!(u.isInteger(e.dims[n])||e.dims[n]&&u.isInteger(e.dims[n].low)&&u.isInteger(e.dims[n].high)))return"dims: integer|Long[] expected"}return null},e.fromObject=function(e){if(e instanceof l.onnx.SparseTensorProto)return e;var t=new l.onnx.SparseTensorProto;if(null!=e.values){if("object"!=typeof e.values)throw TypeError(".onnx.SparseTensorProto.values: object expected");t.values=l.onnx.TensorProto.fromObject(e.values)}if(null!=e.indices){if("object"!=typeof e.indices)throw TypeError(".onnx.SparseTensorProto.indices: object expected");t.indices=l.onnx.TensorProto.fromObject(e.indices)}if(e.dims){if(!Array.isArray(e.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");t.dims=[];for(var n=0;n<e.dims.length;++n)u.Long?(t.dims[n]=u.Long.fromValue(e.dims[n])).unsigned=!1:"string"==typeof e.dims[n]?t.dims[n]=parseInt(e.dims[n],10):"number"==typeof e.dims[n]?t.dims[n]=e.dims[n]:"object"==typeof e.dims[n]&&(t.dims[n]=new u.LongBits(e.dims[n].low>>>0,e.dims[n].high>>>0).toNumber())}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.dims=[]),t.defaults&&(n.values=null,n.indices=null),null!=e.values&&e.hasOwnProperty("values")&&(n.values=l.onnx.TensorProto.toObject(e.values,t)),null!=e.indices&&e.hasOwnProperty("indices")&&(n.indices=l.onnx.TensorProto.toObject(e.indices,t)),e.dims&&e.dims.length){n.dims=[];for(var r=0;r<e.dims.length;++r)"number"==typeof e.dims[r]?n.dims[r]=t.longs===String?String(e.dims[r]):e.dims[r]:n.dims[r]=t.longs===String?u.Long.prototype.toString.call(e.dims[r]):t.longs===Number?new u.LongBits(e.dims[r].low>>>0,e.dims[r].high>>>0).toNumber():e.dims[r]}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.SparseTensorProto"},e}(),o.TensorShapeProto=function(){function e(e){if(this.dim=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dim=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.dim&&e.dim.length)for(var n=0;n<e.dim.length;++n)l.onnx.TensorShapeProto.Dimension.encode(e.dim[n],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TensorShapeProto;e.pos<n;){var o=e.uint32();o>>>3==1?(r.dim&&r.dim.length||(r.dim=[]),r.dim.push(l.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&o)}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.dim&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var t=0;t<e.dim.length;++t){var n=l.onnx.TensorShapeProto.Dimension.verify(e.dim[t]);if(n)return"dim."+n}}return null},e.fromObject=function(e){if(e instanceof l.onnx.TensorShapeProto)return e;var t=new l.onnx.TensorShapeProto;if(e.dim){if(!Array.isArray(e.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");t.dim=[];for(var n=0;n<e.dim.length;++n){if("object"!=typeof e.dim[n])throw TypeError(".onnx.TensorShapeProto.dim: object expected");t.dim[n]=l.onnx.TensorShapeProto.Dimension.fromObject(e.dim[n])}}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.dim=[]),e.dim&&e.dim.length){n.dim=[];for(var r=0;r<e.dim.length;++r)n.dim[r]=l.onnx.TensorShapeProto.Dimension.toObject(e.dim[r],t)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TensorShapeProto"},e.Dimension=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}var t;return e.prototype.dimValue=null,e.prototype.dimParam=null,e.prototype.denotation="",Object.defineProperty(e.prototype,"value",{get:u.oneOfGetter(t=["dimValue","dimParam"]),set:u.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.dimValue&&Object.hasOwnProperty.call(e,"dimValue")&&t.uint32(8).int64(e.dimValue),null!=e.dimParam&&Object.hasOwnProperty.call(e,"dimParam")&&t.uint32(18).string(e.dimParam),null!=e.denotation&&Object.hasOwnProperty.call(e,"denotation")&&t.uint32(26).string(e.denotation),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TensorShapeProto.Dimension;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.dimValue=e.int64();break;case 2:r.dimParam=e.string();break;case 3:r.denotation=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.dimValue&&e.hasOwnProperty("dimValue")&&(t.value=1,!(u.isInteger(e.dimValue)||e.dimValue&&u.isInteger(e.dimValue.low)&&u.isInteger(e.dimValue.high))))return"dimValue: integer|Long expected";if(null!=e.dimParam&&e.hasOwnProperty("dimParam")){if(1===t.value)return"value: multiple values";if(t.value=1,!u.isString(e.dimParam))return"dimParam: string expected"}return null!=e.denotation&&e.hasOwnProperty("denotation")&&!u.isString(e.denotation)?"denotation: string expected":null},e.fromObject=function(e){if(e instanceof l.onnx.TensorShapeProto.Dimension)return e;var t=new l.onnx.TensorShapeProto.Dimension;return null!=e.dimValue&&(u.Long?(t.dimValue=u.Long.fromValue(e.dimValue)).unsigned=!1:"string"==typeof e.dimValue?t.dimValue=parseInt(e.dimValue,10):"number"==typeof e.dimValue?t.dimValue=e.dimValue:"object"==typeof e.dimValue&&(t.dimValue=new u.LongBits(e.dimValue.low>>>0,e.dimValue.high>>>0).toNumber())),null!=e.dimParam&&(t.dimParam=String(e.dimParam)),null!=e.denotation&&(t.denotation=String(e.denotation)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.denotation=""),null!=e.dimValue&&e.hasOwnProperty("dimValue")&&("number"==typeof e.dimValue?n.dimValue=t.longs===String?String(e.dimValue):e.dimValue:n.dimValue=t.longs===String?u.Long.prototype.toString.call(e.dimValue):t.longs===Number?new u.LongBits(e.dimValue.low>>>0,e.dimValue.high>>>0).toNumber():e.dimValue,t.oneofs&&(n.value="dimValue")),null!=e.dimParam&&e.hasOwnProperty("dimParam")&&(n.dimParam=e.dimParam,t.oneofs&&(n.value="dimParam")),null!=e.denotation&&e.hasOwnProperty("denotation")&&(n.denotation=e.denotation),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TensorShapeProto.Dimension"},e}(),e}(),o.TypeProto=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}var t;return e.prototype.tensorType=null,e.prototype.sequenceType=null,e.prototype.mapType=null,e.prototype.optionalType=null,e.prototype.sparseTensorType=null,e.prototype.denotation="",Object.defineProperty(e.prototype,"value",{get:u.oneOfGetter(t=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:u.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.tensorType&&Object.hasOwnProperty.call(e,"tensorType")&&l.onnx.TypeProto.Tensor.encode(e.tensorType,t.uint32(10).fork()).ldelim(),null!=e.sequenceType&&Object.hasOwnProperty.call(e,"sequenceType")&&l.onnx.TypeProto.Sequence.encode(e.sequenceType,t.uint32(34).fork()).ldelim(),null!=e.mapType&&Object.hasOwnProperty.call(e,"mapType")&&l.onnx.TypeProto.Map.encode(e.mapType,t.uint32(42).fork()).ldelim(),null!=e.denotation&&Object.hasOwnProperty.call(e,"denotation")&&t.uint32(50).string(e.denotation),null!=e.sparseTensorType&&Object.hasOwnProperty.call(e,"sparseTensorType")&&l.onnx.TypeProto.SparseTensor.encode(e.sparseTensorType,t.uint32(66).fork()).ldelim(),null!=e.optionalType&&Object.hasOwnProperty.call(e,"optionalType")&&l.onnx.TypeProto.Optional.encode(e.optionalType,t.uint32(74).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TypeProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.tensorType=l.onnx.TypeProto.Tensor.decode(e,e.uint32());break;case 4:r.sequenceType=l.onnx.TypeProto.Sequence.decode(e,e.uint32());break;case 5:r.mapType=l.onnx.TypeProto.Map.decode(e,e.uint32());break;case 9:r.optionalType=l.onnx.TypeProto.Optional.decode(e,e.uint32());break;case 8:r.sparseTensorType=l.onnx.TypeProto.SparseTensor.decode(e,e.uint32());break;case 6:r.denotation=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.tensorType&&e.hasOwnProperty("tensorType")&&(t.value=1,n=l.onnx.TypeProto.Tensor.verify(e.tensorType)))return"tensorType."+n;if(null!=e.sequenceType&&e.hasOwnProperty("sequenceType")){if(1===t.value)return"value: multiple values";if(t.value=1,n=l.onnx.TypeProto.Sequence.verify(e.sequenceType))return"sequenceType."+n}if(null!=e.mapType&&e.hasOwnProperty("mapType")){if(1===t.value)return"value: multiple values";if(t.value=1,n=l.onnx.TypeProto.Map.verify(e.mapType))return"mapType."+n}if(null!=e.optionalType&&e.hasOwnProperty("optionalType")){if(1===t.value)return"value: multiple values";if(t.value=1,n=l.onnx.TypeProto.Optional.verify(e.optionalType))return"optionalType."+n}if(null!=e.sparseTensorType&&e.hasOwnProperty("sparseTensorType")){if(1===t.value)return"value: multiple values";var n;if(t.value=1,n=l.onnx.TypeProto.SparseTensor.verify(e.sparseTensorType))return"sparseTensorType."+n}return null!=e.denotation&&e.hasOwnProperty("denotation")&&!u.isString(e.denotation)?"denotation: string expected":null},e.fromObject=function(e){if(e instanceof l.onnx.TypeProto)return e;var t=new l.onnx.TypeProto;if(null!=e.tensorType){if("object"!=typeof e.tensorType)throw TypeError(".onnx.TypeProto.tensorType: object expected");t.tensorType=l.onnx.TypeProto.Tensor.fromObject(e.tensorType)}if(null!=e.sequenceType){if("object"!=typeof e.sequenceType)throw TypeError(".onnx.TypeProto.sequenceType: object expected");t.sequenceType=l.onnx.TypeProto.Sequence.fromObject(e.sequenceType)}if(null!=e.mapType){if("object"!=typeof e.mapType)throw TypeError(".onnx.TypeProto.mapType: object expected");t.mapType=l.onnx.TypeProto.Map.fromObject(e.mapType)}if(null!=e.optionalType){if("object"!=typeof e.optionalType)throw TypeError(".onnx.TypeProto.optionalType: object expected");t.optionalType=l.onnx.TypeProto.Optional.fromObject(e.optionalType)}if(null!=e.sparseTensorType){if("object"!=typeof e.sparseTensorType)throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");t.sparseTensorType=l.onnx.TypeProto.SparseTensor.fromObject(e.sparseTensorType)}return null!=e.denotation&&(t.denotation=String(e.denotation)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.denotation=""),null!=e.tensorType&&e.hasOwnProperty("tensorType")&&(n.tensorType=l.onnx.TypeProto.Tensor.toObject(e.tensorType,t),t.oneofs&&(n.value="tensorType")),null!=e.sequenceType&&e.hasOwnProperty("sequenceType")&&(n.sequenceType=l.onnx.TypeProto.Sequence.toObject(e.sequenceType,t),t.oneofs&&(n.value="sequenceType")),null!=e.mapType&&e.hasOwnProperty("mapType")&&(n.mapType=l.onnx.TypeProto.Map.toObject(e.mapType,t),t.oneofs&&(n.value="mapType")),null!=e.denotation&&e.hasOwnProperty("denotation")&&(n.denotation=e.denotation),null!=e.sparseTensorType&&e.hasOwnProperty("sparseTensorType")&&(n.sparseTensorType=l.onnx.TypeProto.SparseTensor.toObject(e.sparseTensorType,t),t.oneofs&&(n.value="sparseTensorType")),null!=e.optionalType&&e.hasOwnProperty("optionalType")&&(n.optionalType=l.onnx.TypeProto.Optional.toObject(e.optionalType,t),t.oneofs&&(n.value="optionalType")),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TypeProto"},e.Tensor=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.elemType=0,e.prototype.shape=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.elemType&&Object.hasOwnProperty.call(e,"elemType")&&t.uint32(8).int32(e.elemType),null!=e.shape&&Object.hasOwnProperty.call(e,"shape")&&l.onnx.TensorShapeProto.encode(e.shape,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TypeProto.Tensor;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.elemType=e.int32();break;case 2:r.shape=l.onnx.TensorShapeProto.decode(e,e.uint32());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elemType&&e.hasOwnProperty("elemType")&&!u.isInteger(e.elemType))return"elemType: integer expected";if(null!=e.shape&&e.hasOwnProperty("shape")){var t=l.onnx.TensorShapeProto.verify(e.shape);if(t)return"shape."+t}return null},e.fromObject=function(e){if(e instanceof l.onnx.TypeProto.Tensor)return e;var t=new l.onnx.TypeProto.Tensor;if(null!=e.elemType&&(t.elemType=0|e.elemType),null!=e.shape){if("object"!=typeof e.shape)throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");t.shape=l.onnx.TensorShapeProto.fromObject(e.shape)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.elemType=0,n.shape=null),null!=e.elemType&&e.hasOwnProperty("elemType")&&(n.elemType=e.elemType),null!=e.shape&&e.hasOwnProperty("shape")&&(n.shape=l.onnx.TensorShapeProto.toObject(e.shape,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TypeProto.Tensor"},e}(),e.Sequence=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.elemType=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.elemType&&Object.hasOwnProperty.call(e,"elemType")&&l.onnx.TypeProto.encode(e.elemType,t.uint32(10).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TypeProto.Sequence;e.pos<n;){var o=e.uint32();o>>>3==1?r.elemType=l.onnx.TypeProto.decode(e,e.uint32()):e.skipType(7&o)}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elemType&&e.hasOwnProperty("elemType")){var t=l.onnx.TypeProto.verify(e.elemType);if(t)return"elemType."+t}return null},e.fromObject=function(e){if(e instanceof l.onnx.TypeProto.Sequence)return e;var t=new l.onnx.TypeProto.Sequence;if(null!=e.elemType){if("object"!=typeof e.elemType)throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");t.elemType=l.onnx.TypeProto.fromObject(e.elemType)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.elemType=null),null!=e.elemType&&e.hasOwnProperty("elemType")&&(n.elemType=l.onnx.TypeProto.toObject(e.elemType,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TypeProto.Sequence"},e}(),e.Map=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.keyType=0,e.prototype.valueType=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.keyType&&Object.hasOwnProperty.call(e,"keyType")&&t.uint32(8).int32(e.keyType),null!=e.valueType&&Object.hasOwnProperty.call(e,"valueType")&&l.onnx.TypeProto.encode(e.valueType,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TypeProto.Map;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.keyType=e.int32();break;case 2:r.valueType=l.onnx.TypeProto.decode(e,e.uint32());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.keyType&&e.hasOwnProperty("keyType")&&!u.isInteger(e.keyType))return"keyType: integer expected";if(null!=e.valueType&&e.hasOwnProperty("valueType")){var t=l.onnx.TypeProto.verify(e.valueType);if(t)return"valueType."+t}return null},e.fromObject=function(e){if(e instanceof l.onnx.TypeProto.Map)return e;var t=new l.onnx.TypeProto.Map;if(null!=e.keyType&&(t.keyType=0|e.keyType),null!=e.valueType){if("object"!=typeof e.valueType)throw TypeError(".onnx.TypeProto.Map.valueType: object expected");t.valueType=l.onnx.TypeProto.fromObject(e.valueType)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.keyType=0,n.valueType=null),null!=e.keyType&&e.hasOwnProperty("keyType")&&(n.keyType=e.keyType),null!=e.valueType&&e.hasOwnProperty("valueType")&&(n.valueType=l.onnx.TypeProto.toObject(e.valueType,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TypeProto.Map"},e}(),e.Optional=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.elemType=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.elemType&&Object.hasOwnProperty.call(e,"elemType")&&l.onnx.TypeProto.encode(e.elemType,t.uint32(10).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TypeProto.Optional;e.pos<n;){var o=e.uint32();o>>>3==1?r.elemType=l.onnx.TypeProto.decode(e,e.uint32()):e.skipType(7&o)}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elemType&&e.hasOwnProperty("elemType")){var t=l.onnx.TypeProto.verify(e.elemType);if(t)return"elemType."+t}return null},e.fromObject=function(e){if(e instanceof l.onnx.TypeProto.Optional)return e;var t=new l.onnx.TypeProto.Optional;if(null!=e.elemType){if("object"!=typeof e.elemType)throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");t.elemType=l.onnx.TypeProto.fromObject(e.elemType)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.elemType=null),null!=e.elemType&&e.hasOwnProperty("elemType")&&(n.elemType=l.onnx.TypeProto.toObject(e.elemType,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TypeProto.Optional"},e}(),e.SparseTensor=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.elemType=0,e.prototype.shape=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.elemType&&Object.hasOwnProperty.call(e,"elemType")&&t.uint32(8).int32(e.elemType),null!=e.shape&&Object.hasOwnProperty.call(e,"shape")&&l.onnx.TensorShapeProto.encode(e.shape,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.TypeProto.SparseTensor;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.elemType=e.int32();break;case 2:r.shape=l.onnx.TensorShapeProto.decode(e,e.uint32());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elemType&&e.hasOwnProperty("elemType")&&!u.isInteger(e.elemType))return"elemType: integer expected";if(null!=e.shape&&e.hasOwnProperty("shape")){var t=l.onnx.TensorShapeProto.verify(e.shape);if(t)return"shape."+t}return null},e.fromObject=function(e){if(e instanceof l.onnx.TypeProto.SparseTensor)return e;var t=new l.onnx.TypeProto.SparseTensor;if(null!=e.elemType&&(t.elemType=0|e.elemType),null!=e.shape){if("object"!=typeof e.shape)throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");t.shape=l.onnx.TensorShapeProto.fromObject(e.shape)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.elemType=0,n.shape=null),null!=e.elemType&&e.hasOwnProperty("elemType")&&(n.elemType=e.elemType),null!=e.shape&&e.hasOwnProperty("shape")&&(n.shape=l.onnx.TensorShapeProto.toObject(e.shape,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.TypeProto.SparseTensor"},e}(),e}(),o.OperatorSetIdProto=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.domain="",e.prototype.version=u.Long?u.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.domain&&Object.hasOwnProperty.call(e,"domain")&&t.uint32(10).string(e.domain),null!=e.version&&Object.hasOwnProperty.call(e,"version")&&t.uint32(16).int64(e.version),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.OperatorSetIdProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.domain=e.string();break;case 2:r.version=e.int64();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.domain&&e.hasOwnProperty("domain")&&!u.isString(e.domain)?"domain: string expected":null==e.version||!e.hasOwnProperty("version")||u.isInteger(e.version)||e.version&&u.isInteger(e.version.low)&&u.isInteger(e.version.high)?null:"version: integer|Long expected"},e.fromObject=function(e){if(e instanceof l.onnx.OperatorSetIdProto)return e;var t=new l.onnx.OperatorSetIdProto;return null!=e.domain&&(t.domain=String(e.domain)),null!=e.version&&(u.Long?(t.version=u.Long.fromValue(e.version)).unsigned=!1:"string"==typeof e.version?t.version=parseInt(e.version,10):"number"==typeof e.version?t.version=e.version:"object"==typeof e.version&&(t.version=new u.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults)if(n.domain="",u.Long){var r=new u.Long(0,0,!1);n.version=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.version=t.longs===String?"0":0;return null!=e.domain&&e.hasOwnProperty("domain")&&(n.domain=e.domain),null!=e.version&&e.hasOwnProperty("version")&&("number"==typeof e.version?n.version=t.longs===String?String(e.version):e.version:n.version=t.longs===String?u.Long.prototype.toString.call(e.version):t.longs===Number?new u.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.OperatorSetIdProto"},e}(),o.OperatorStatus=function(){var e={},t=Object.create(e);return t[e[0]="EXPERIMENTAL"]=0,t[e[1]="STABLE"]=1,t}(),o.FunctionProto=function(){function e(e){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.name="",e.prototype.input=u.emptyArray,e.prototype.output=u.emptyArray,e.prototype.attribute=u.emptyArray,e.prototype.attributeProto=u.emptyArray,e.prototype.node=u.emptyArray,e.prototype.docString="",e.prototype.opsetImport=u.emptyArray,e.prototype.domain="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.name&&Object.hasOwnProperty.call(e,"name")&&t.uint32(10).string(e.name),null!=e.input&&e.input.length)for(var n=0;n<e.input.length;++n)t.uint32(34).string(e.input[n]);if(null!=e.output&&e.output.length)for(n=0;n<e.output.length;++n)t.uint32(42).string(e.output[n]);if(null!=e.attribute&&e.attribute.length)for(n=0;n<e.attribute.length;++n)t.uint32(50).string(e.attribute[n]);if(null!=e.node&&e.node.length)for(n=0;n<e.node.length;++n)l.onnx.NodeProto.encode(e.node[n],t.uint32(58).fork()).ldelim();if(null!=e.docString&&Object.hasOwnProperty.call(e,"docString")&&t.uint32(66).string(e.docString),null!=e.opsetImport&&e.opsetImport.length)for(n=0;n<e.opsetImport.length;++n)l.onnx.OperatorSetIdProto.encode(e.opsetImport[n],t.uint32(74).fork()).ldelim();if(null!=e.domain&&Object.hasOwnProperty.call(e,"domain")&&t.uint32(82).string(e.domain),null!=e.attributeProto&&e.attributeProto.length)for(n=0;n<e.attributeProto.length;++n)l.onnx.AttributeProto.encode(e.attributeProto[n],t.uint32(90).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new l.onnx.FunctionProto;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.name=e.string();break;case 4:r.input&&r.input.length||(r.input=[]),r.input.push(e.string());break;case 5:r.output&&r.output.length||(r.output=[]),r.output.push(e.string());break;case 6:r.attribute&&r.attribute.length||(r.attribute=[]),r.attribute.push(e.string());break;case 11:r.attributeProto&&r.attributeProto.length||(r.attributeProto=[]),r.attributeProto.push(l.onnx.AttributeProto.decode(e,e.uint32()));break;case 7:r.node&&r.node.length||(r.node=[]),r.node.push(l.onnx.NodeProto.decode(e,e.uint32()));break;case 8:r.docString=e.string();break;case 9:r.opsetImport&&r.opsetImport.length||(r.opsetImport=[]),r.opsetImport.push(l.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 10:r.domain=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.name&&e.hasOwnProperty("name")&&!u.isString(e.name))return"name: string expected";if(null!=e.input&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var t=0;t<e.input.length;++t)if(!u.isString(e.input[t]))return"input: string[] expected"}if(null!=e.output&&e.hasOwnProperty("output")){if(!Array.isArray(e.output))return"output: array expected";for(t=0;t<e.output.length;++t)if(!u.isString(e.output[t]))return"output: string[] expected"}if(null!=e.attribute&&e.hasOwnProperty("attribute")){if(!Array.isArray(e.attribute))return"attribute: array expected";for(t=0;t<e.attribute.length;++t)if(!u.isString(e.attribute[t]))return"attribute: string[] expected"}if(null!=e.attributeProto&&e.hasOwnProperty("attributeProto")){if(!Array.isArray(e.attributeProto))return"attributeProto: array expected";for(t=0;t<e.attributeProto.length;++t)if(n=l.onnx.AttributeProto.verify(e.attributeProto[t]))return"attributeProto."+n}if(null!=e.node&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(t=0;t<e.node.length;++t)if(n=l.onnx.NodeProto.verify(e.node[t]))return"node."+n}if(null!=e.docString&&e.hasOwnProperty("docString")&&!u.isString(e.docString))return"docString: string expected";if(null!=e.opsetImport&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(t=0;t<e.opsetImport.length;++t){var n;if(n=l.onnx.OperatorSetIdProto.verify(e.opsetImport[t]))return"opsetImport."+n}}return null!=e.domain&&e.hasOwnProperty("domain")&&!u.isString(e.domain)?"domain: string expected":null},e.fromObject=function(e){if(e instanceof l.onnx.FunctionProto)return e;var t=new l.onnx.FunctionProto;if(null!=e.name&&(t.name=String(e.name)),e.input){if(!Array.isArray(e.input))throw TypeError(".onnx.FunctionProto.input: array expected");t.input=[];for(var n=0;n<e.input.length;++n)t.input[n]=String(e.input[n])}if(e.output){if(!Array.isArray(e.output))throw TypeError(".onnx.FunctionProto.output: array expected");for(t.output=[],n=0;n<e.output.length;++n)t.output[n]=String(e.output[n])}if(e.attribute){if(!Array.isArray(e.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");for(t.attribute=[],n=0;n<e.attribute.length;++n)t.attribute[n]=String(e.attribute[n])}if(e.attributeProto){if(!Array.isArray(e.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");for(t.attributeProto=[],n=0;n<e.attributeProto.length;++n){if("object"!=typeof e.attributeProto[n])throw TypeError(".onnx.FunctionProto.attributeProto: object expected");t.attributeProto[n]=l.onnx.AttributeProto.fromObject(e.attributeProto[n])}}if(e.node){if(!Array.isArray(e.node))throw TypeError(".onnx.FunctionProto.node: array expected");for(t.node=[],n=0;n<e.node.length;++n){if("object"!=typeof e.node[n])throw TypeError(".onnx.FunctionProto.node: object expected");t.node[n]=l.onnx.NodeProto.fromObject(e.node[n])}}if(null!=e.docString&&(t.docString=String(e.docString)),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");for(t.opsetImport=[],n=0;n<e.opsetImport.length;++n){if("object"!=typeof e.opsetImport[n])throw TypeError(".onnx.FunctionProto.opsetImport: object expected");t.opsetImport[n]=l.onnx.OperatorSetIdProto.fromObject(e.opsetImport[n])}}return null!=e.domain&&(t.domain=String(e.domain)),t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.input=[],n.output=[],n.attribute=[],n.node=[],n.opsetImport=[],n.attributeProto=[]),t.defaults&&(n.name="",n.docString="",n.domain=""),null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),e.input&&e.input.length){n.input=[];for(var r=0;r<e.input.length;++r)n.input[r]=e.input[r]}if(e.output&&e.output.length)for(n.output=[],r=0;r<e.output.length;++r)n.output[r]=e.output[r];if(e.attribute&&e.attribute.length)for(n.attribute=[],r=0;r<e.attribute.length;++r)n.attribute[r]=e.attribute[r];if(e.node&&e.node.length)for(n.node=[],r=0;r<e.node.length;++r)n.node[r]=l.onnx.NodeProto.toObject(e.node[r],t);if(null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),e.opsetImport&&e.opsetImport.length)for(n.opsetImport=[],r=0;r<e.opsetImport.length;++r)n.opsetImport[r]=l.onnx.OperatorSetIdProto.toObject(e.opsetImport[r],t);if(null!=e.domain&&e.hasOwnProperty("domain")&&(n.domain=e.domain),e.attributeProto&&e.attributeProto.length)for(n.attributeProto=[],r=0;r<e.attributeProto.length;++r)n.attributeProto[r]=l.onnx.AttributeProto.toObject(e.attributeProto[r],t);return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/onnx.FunctionProto"},e}(),o),t.exports=l}));function Cr(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function sn(e){return(new TextDecoder).decode(e)}var ye,pr,mi,Xe,Xn,Ve,nt,U,an,dr,hr,mr,fe=L((()=>{Wn(),ti(),ye=Er($r()),br(),pr=class{static arraysEqual(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}},mi=class{static preprocessInputShapes(e,t){return[1===e.length?[1,e[0]]:e,1===t.length?[t[0],1]:t]}static postprocessOutputShape(e,t,n){1===t&&e.splice(e.length-2,1),1===n&&e.pop()}static calcMatMulShape(e,t){return e[1]!==t[0]?void 0:[e[0],t[1]]}},Xe=class e{static calcShape(e,t,n=!1){let r=e.length,o=t.length;if(0===r)return t;if(0===o)return e;let i=Math.max(e.length,t.length),a=new Array(i);if(n){if(r<2||o<2)return;let n=mi.calcMatMulShape([e[r-2],e[r-1]],[t[o-2],t[o-1]]);if(void 0===n)return;[a[i-2],a[i-1]]=n}for(let s=n?3:1;s<=i;s++){let n=r-s<0?1:e[r-s],u=o-s<0?1:t[o-s];if(n!==u&&n>1&&u>1)return;a[i-s]=Math.max(n,u)}return a}static index(t,n){let r=new Array(n.length);return e.fillIndex(t,n,r),r}static fillIndex(e,t,n){let r=e.length-t.length;for(let o=0;o<t.length;o++)n[o]=e[r+o]%t[o]}static calc(t,n,r,o,i){let a=e.calcShape(t.dims,n.dims);if(a){if(o&&!U.areEqual(a,t.dims))return;let s=U.size(a),u=o?t:new Fe(a,i||t.type);if(0===a.length)u.set([],r(t.get([]),n.get([])));else{let o,i=new Array(a.length),l=new Array(t.dims.length),c=new Array(n.dims.length),p=0,d=0,f=!1,h=!1;0===t.dims.length&&(p=t.get([]),f=!0),0===n.dims.length&&(d=n.get([]),h=!0);for(let g=0;g<s;g++){o=g;for(let e=a.length-1;e>=0;e--)i[e]=o%a[e],o=Math.floor(o/a[e]);f||(e.fillIndex(i,t.dims,l),p=t.get(l)),h||(e.fillIndex(i,n.dims,c),d=n.get(c)),u.set(i,r(p,d))}}return u}}static isValidBroadcast(e,t){let n=e.length,r=t.length;if(n>r)return!1;for(let o=1;o<=n;o++)if(1!==e[n-o]&&e[n-o]!==t[r-o])return!1;return!0}static getBroadcastDims(e,t){let n=e.length,r=[];for(let o=0;o<n;o++){let i=n-1-o,a=e[i]||1;(t[t.length-1-o]||1)>1&&1===a&&r.unshift(i)}return r}},Xn=class{static getShapeOfGemmResult(e,t,n,r,o){if(2!==e.length||2!==n.length)throw new Error("shape need to be of size 2");let i,a,s;t?(i=e[1],a=e[0]):(i=e[0],a=e[1]);let u=-1;if(r?(s=n[0],u=1):(s=n[1],u=0),n[u]!==a)throw new Error("dimension mismatch");if(i<=0||s<=0||a<=0)throw new Error("invalid shape specified");if(o&&!Xe.isValidBroadcast(o,[i,s]))throw new Error("gemm: invalid bias shape for broadcast");return[i,s,a]}},Ve=class e{static tensorDataTypeFromProto(e){switch(e){case ye.onnx.TensorProto.DataType.INT8:return"int8";case ye.onnx.TensorProto.DataType.UINT8:return"uint8";case ye.onnx.TensorProto.DataType.BOOL:return"bool";case ye.onnx.TensorProto.DataType.INT16:return"int16";case ye.onnx.TensorProto.DataType.UINT16:return"uint16";case ye.onnx.TensorProto.DataType.INT32:return"int32";case ye.onnx.TensorProto.DataType.UINT32:return"uint32";case ye.onnx.TensorProto.DataType.FLOAT:return"float32";case ye.onnx.TensorProto.DataType.DOUBLE:return"float64";case ye.onnx.TensorProto.DataType.STRING:return"string";case ye.onnx.TensorProto.DataType.INT64:return"int32";case ye.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${ye.onnx.TensorProto.DataType[e]}`)}}static tensorDataTypeStringToEnum(e){switch(e){case"int8":return ye.onnx.TensorProto.DataType.INT8;case"uint8":return ye.onnx.TensorProto.DataType.UINT8;case"bool":return ye.onnx.TensorProto.DataType.BOOL;case"int16":return ye.onnx.TensorProto.DataType.INT16;case"uint16":return ye.onnx.TensorProto.DataType.UINT16;case"int32":return ye.onnx.TensorProto.DataType.INT32;case"uint32":return ye.onnx.TensorProto.DataType.UINT32;case"float32":return ye.onnx.TensorProto.DataType.FLOAT;case"float64":return ye.onnx.TensorProto.DataType.DOUBLE;case"string":return ye.onnx.TensorProto.DataType.STRING;case"int64":return ye.onnx.TensorProto.DataType.INT64;case"uint64":return ye.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${e}`)}}static tensorDimsFromProto(e){return e.map((e=>zt.isLong(e)?e.toNumber():e))}static tensorValueTypeFromProto(t){return{tensorType:e.tensorDataTypeFromProto(t.elemType),shape:{dims:e.tensorDimsFromProto(t.shape.dim.map((e=>e.dimValue)))}}}static tensorDimsFromORTFormat(e){let t=[];for(let n=0;n<e.dimsLength();n++)t.push(nt.longToNumber(e.dims(n)));return t}static tensorAttributesFromORTFormat(e){let t=[];for(let n=0;n<e.attributesLength();n++)t.push(e.attributes(n));return t}},nt=class{static longToNumber(e,t){return zt.isLong(e)?e.toNumber():e instanceof _.Long?zt.fromValue({low:e.low,high:e.high,unsigned:t??!1}).toNumber():e}static isLong(e){return zt.isLong(e)||e instanceof _.Long}},U=class e{static size(t){return e.getSizeFromDimensionRange(t,0,t.length)}static sizeFromDimension(t,n){if(n<0||n>t.length)throw new Error(`invalid dimension of ${n} for sizeFromDimension as Tensor has ${t.length} dimensions.`);return e.getSizeFromDimensionRange(t,n,t.length)}static sizeToDimension(t,n){if(n<0||n>t.length)throw new Error(`invalid dimension of ${n} for sizeToDimension as Tensor has ${t.length} dimensions.`);return e.getSizeFromDimensionRange(t,0,n)}static getSizeFromDimensionRange(e,t,n){let r=1;for(let o=t;o<n;o++){if(e[o]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");r*=e[o]}return r}static computeStrides(e){let t=e.length;if(0===t)return[];if(1===t)return[1];let n=new Array(t);n[t-1]=1,n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}static transpose(e){return e.slice().reverse()}static indicesToOffset(e,t,n){void 0===n&&(n=e.length);let r=0;for(let o=0;o<n;++o)r+=t[o]*e[o];return r}static offsetToIndices(e,t){let n=t.length;if(0===n)return[];if(1===n)return[e*t[0]];let r=new Array(t.length);for(let n=0;n<r.length-1;++n)r[n]=Math.floor(e/t[n]),e-=r[n]*t[n];return r[r.length-1]=e,r}static normalizeAxis(e,t){if(e<-t&&e>=t)throw new Error("unsupported axis for this operation.");return e<0?e+t:e}static normalizeAxes(e,t){return e.map((e=>this.normalizeAxis(e,t)))}static incrementIndex(e,t,n){if(0===t.length||0===e.length)throw new Error("Index incrementing unsupported for scalar Tensor");if(void 0===n)n=t.length;else if(n<=0||n>t.length)throw new Error("Incorrect axis to increment on");for(let r=n-1;r>=0&&(e[r]++,!(e[r]<t[r]));--r)e[r]=0}static calculateReshapedDims(t,n){if(0===n.length){if(0===t.length||1===e.size(t))return[];throw new Error("cannot reshape to a scalar Tensor")}let r=n.length,o=new Array(r),i=-1,a=1;for(let e=0;e<r;e++){if(n[e]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(-1===n[e]){if(-1!==i)throw new Error("at most one dimension in shape hints can be -1");i=e}else{if(0===n[e]){if(e>=t.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");o[e]=t[e]}else o[e]=n[e];a*=o[e]}}let s=e.size(t);if(-1!==i){if(s%a!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${t}] Output shape: [${n}]`);o[i]=s/a}else if(a!==s)throw new Error("reshapedDims and originalDims don't have matching sizes");return o}static sortBasedOnPerm(e,t){return t?t.map((t=>e[t])):e.slice().reverse()}static padShape(e,t){let n=e.length;return e.map(((e,r)=>e+t[r]+t[r+n]))}static areEqual(e,t){return e.length===t.length&&e.every(((e,n)=>e===t[n]))}static validateDimsAndCalcSize(e){if(e.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let t=1;for(let n of e){if(!Number.isInteger(n))throw new TypeError(`Invalid shape: ${n} is not an integer`);if(n<0||n>2147483647)throw new TypeError(`Invalid shape: length ${n} is not allowed`);t*=n}return t}static flattenShape(e,t){t<0&&(t+=e.length);let n=e.reduce(((e,t)=>e*t),1),r=e.slice(t).reduce(((e,t)=>e*t),1);return[n/r,r]}static squeezeShape(t,n){let r=new Array;n=e.normalizeAxes(n,t.length);for(let e=0;e<t.length;e++){let o=n.indexOf(e)>=0;if(o&&1!==t[e])throw new Error("squeeze an axis of size different than 1");(0===n.length&&t[e]>1||n.length>0&&!o)&&r.push(t[e])}return r}static unsqueezeShape(t,n){let r=new Array(t.length+n.length);r.fill(0);for(let t=0;t<n.length;t++){let o=e.normalizeAxis(n[t],r.length);if(o>=r.length)throw new Error("'axes' has an out of range axis");if(0!==r[o])throw new Error("'axes' has a duplicate axis");r[o]=1}let o=0;for(let e=0;e<r.length;e++)0===r[e]&&(r[e]=t[o++]);if(o!==t.length)throw new Error("the unsqueezed dimension could not be established");return r}},an=class e{static splitShape(t,n,r,o){if(0===r.length){if(!o)throw new Error("need to know number of outputs when the 'split' attribute is not specified");e.determineSplit(t[n],o,r)}let i=[],a=[0];for(let e=0;e<r.length;++e){0!==e&&a.push(a[e-1]+r[e-1]);let o=t.slice();o[n]=r[e],i.push(o)}return[i,a]}static determineSplit(e,t,n){if(e%t!=0)throw new Error("cannot split tensor to equal sized parts");for(let r=0;r<t;++r)n.push(e/t)}},dr=class e{static adjustPoolAttributes(e,t,n,r,o,i){if(!e&&n.length!==t.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let e=0;e<t.length-2;e++)e>=n.length?n.push(t[e+2]):n[e]=t[e+2];for(let e=0;e<n.length;e++)if(e<r.length){if(r[e]<0)throw new Error("strides should be greater than or equal to 1")}else r.push(1);for(let e=0;e<n.length;e++)if(e<o.length){if(o[e]<0)throw new Error("dilations should be greater than or equal to 1")}else o.push(1);for(let e=0;e<2*n.length;e++)if(e<i.length){if(i[e]<0)throw new Error("pad should be greater than or equal to 1")}else i.push(0);for(let e=0;e<n.length;e++){if(n[e]<=0)throw new Error("kernel shapes need to be greater than 0");if(i[e]>=n[e]||i[e+n.length]>=n[e])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(t,n,r,o,i,a){if(a){if(i.length!==2*(t.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==t.length-2)throw new Error("length of strides should be the length of data dimensions");if(o.length!==t.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let s=0;s<t.length-2;s++)e.adjustPadAndReturnShape(t[s+2],n[s],r[s],o[s],i,s,s+t.length-2,a)}}static computePoolOutputShape(t,n,r,o,i,a,s){if(n.length<=0)throw new Error("input shape must be of size greater than 0");let u=[n[0],n[1]];return e.computeShapeHelper(t,n,u,r,o,i,a,s),u}static computeConvOutputShape(t,n,r,o,i,a,s){if(t.length<=0||n.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let u=[t[0],n[0]];return e.computeShapeHelper(!1,t,u,r,o,i,a,s),u}static computeShapeHelper(t,n,r,o,i,a,s,u){if(t)for(let e=0;e<n.length-2;e++)r.push(1);else for(let t=0;t<n.length-2;t++)r.push(e.adjustPadAndReturnShape(n[t+2],o[t],i[t],a[t],s,t,t+n.length-2,u))}static adjustPadAndReturnShape(e,t,n,r,o,i,a,s){let u=n*(r-1)+1;if(!s||"NOTSET"===s)return Math.floor((e+o[i]+o[a]-u)/t+1);switch(s){case"VALID":return o[i]=0,o[a]=0,Math.floor((e-u)/t+1);case"SAME_LOWER":case"SAME_UPPER":if(1!==n)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let n=((e+t-1)/t-1)*t+r-e;return o[i]=Math.floor("SAME_LOWER"===s?(n+1)/2:n/2),o[a]=n-o[i],Math.floor((e+n-r)/t+1)}default:throw new Error("Unsupported AutoPad type")}}},hr=-34028234663852886e22,mr=34028234663852886e22}));function Vd(e){switch(e){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${e}`)}}function Cu(e){switch(e){case te.onnx.TensorProto.DataType.UINT8:case te.onnx.TensorProto.DataType.INT8:case te.onnx.TensorProto.DataType.BOOL:return 1;case te.onnx.TensorProto.DataType.UINT16:case te.onnx.TensorProto.DataType.INT16:return 2;case te.onnx.TensorProto.DataType.FLOAT:case te.onnx.TensorProto.DataType.INT32:case te.onnx.TensorProto.DataType.UINT32:return 4;case te.onnx.TensorProto.DataType.INT64:case te.onnx.TensorProto.DataType.DOUBLE:case te.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${te.onnx.TensorProto.DataType[e]}`)}}function Wd(e,t){return new(Nu(t))(e)}function Nu(e){switch(e){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function gi(e,t){if(t===te.onnx.TensorProto.DataType.INT64||t===bi.TensorDataType.INT64){if(e.greaterThanOrEqual(2147483648)||e.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else{if(t!==te.onnx.TensorProto.DataType.UINT32&&t!==bi.TensorDataType.UINT32&&t!==te.onnx.TensorProto.DataType.UINT64&&t!==bi.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${te.onnx.TensorProto.DataType[t]}`);if(e.greaterThanOrEqual(4294967296)||e.lessThan(0))throw new TypeError("uint64 is not supported")}return e.toNumber()}function ku(e,t,n){switch(t){case te.onnx.TensorProto.DataType.BOOL:case te.onnx.TensorProto.DataType.UINT8:return e.getUint8(n);case te.onnx.TensorProto.DataType.INT8:return e.getInt8(n);case te.onnx.TensorProto.DataType.UINT16:return e.getUint16(n,!0);case te.onnx.TensorProto.DataType.INT16:return e.getInt16(n,!0);case te.onnx.TensorProto.DataType.FLOAT:return e.getFloat32(n,!0);case te.onnx.TensorProto.DataType.INT32:return e.getInt32(n,!0);case te.onnx.TensorProto.DataType.UINT32:return e.getUint32(n,!0);case te.onnx.TensorProto.DataType.INT64:return gi(zt.fromBits(e.getUint32(n,!0),e.getUint32(n+4,!0),!1),t);case te.onnx.TensorProto.DataType.DOUBLE:return e.getFloat64(n,!0);case te.onnx.TensorProto.DataType.UINT64:return gi(zt.fromBits(e.getUint32(n,!0),e.getUint32(n+4,!0),!0),t);default:throw new Error(`cannot read from DataView for type ${te.onnx.TensorProto.DataType[t]}`)}}var Bu,te,bi,Fe,br=L((()=>{Bu=Er(Is()),ti(),tn(),te=Er($r()),fe(),bi=W.experimental.fbs,Fe=class e{constructor(e,t,n,r,o,i=Bu.Guid.create()){this.dims=e,this.type=t,this.dataProvider=n,this.asyncDataProvider=r,this.cache=o,this.dataId=i,this.size=U.validateDimsAndCalcSize(e);let a=this.size,s=void 0===n&&void 0===r&&void 0===o;if(void 0!==o&&o.length!==a)throw new RangeError("Input dims doesn't match data length.");if("string"===t){if(!(void 0===o||Array.isArray(o)&&o.every((e=>"string"==typeof e))))throw new TypeError("cache should be a string array");s&&(this.cache=new Array(a))}else{if(void 0!==o){let e=Nu(t);if(!(o instanceof e))throw new TypeError(`cache should be type ${e.name}`)}if(s){let e=new ArrayBuffer(a*Vd(t));this.cache=Wd(e,t)}}}get data(){if(void 0===this.cache){let e=this.dataProvider(this.dataId);if(e.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=e}return this.cache}get stringData(){if("string"!==this.type)throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if("string"!==this.type)return this.data;throw new TypeError("type cannot be non-number (string)")}get(e){return this.data[U.indicesToOffset(e,this.strides)]}set(e,t){this.data[U.indicesToOffset(e,this.strides)]=t}async getData(){return void 0===this.cache&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=U.computeStrides(this.dims)),this._strides}static fromProto(t){if(!t)throw new Error("cannot construct Value from an empty tensor");let n=Ve.tensorDataTypeFromProto(t.dataType),r=Ve.tensorDimsFromProto(t.dims),o=new e(r,n);if("string"===n)t.stringData.forEach(((e,t)=>{o.data[t]=sn(e)}));else if(t.rawData&&"number"==typeof t.rawData.byteLength&&t.rawData.byteLength>0){let e=o.data,n=new DataView(t.rawData.buffer,t.rawData.byteOffset,t.rawData.byteLength),r=Cu(t.dataType),i=t.rawData.byteLength/r;if(t.rawData.byteLength%r!=0)throw new Error("invalid buffer length");if(e.length!==i)throw new Error("buffer length mismatch");for(let o=0;o<i;o++){let i=ku(n,t.dataType,o*r);e[o]=i}}else{let e;switch(t.dataType){case te.onnx.TensorProto.DataType.FLOAT:e=t.floatData;break;case te.onnx.TensorProto.DataType.INT32:case te.onnx.TensorProto.DataType.INT16:case te.onnx.TensorProto.DataType.UINT16:case te.onnx.TensorProto.DataType.INT8:case te.onnx.TensorProto.DataType.UINT8:case te.onnx.TensorProto.DataType.BOOL:e=t.int32Data;break;case te.onnx.TensorProto.DataType.INT64:e=t.int64Data;break;case te.onnx.TensorProto.DataType.DOUBLE:e=t.doubleData;break;case te.onnx.TensorProto.DataType.UINT32:case te.onnx.TensorProto.DataType.UINT64:e=t.uint64Data;break;default:throw new Error("unspecific error")}if(null==e)throw new Error("failed to populate data from a tensorproto value");let n=o.data;if(n.length!==e.length)throw new Error("array length mismatch");for(let r=0;r<e.length;r++){let o=e[r];zt.isLong(o)?n[r]=gi(o,t.dataType):n[r]=o}}return o}static fromData(t,n,r){return new e(n,r,void 0,void 0,t)}static fromOrtTensor(t){if(!t)throw new Error("cannot construct Value from an empty tensor");let n=Ve.tensorDimsFromORTFormat(t),r=Ve.tensorDataTypeFromProto(t.dataType()),o=new e(n,r);if("string"===r)for(let e=0;e<t.stringDataLength();e++)o.data[e]=t.stringData(e);else if(t.rawDataArray()&&"number"==typeof t.rawDataLength()&&t.rawDataLength()>0){let e=o.data,n=new DataView(t.rawDataArray().buffer,t.rawDataArray().byteOffset,t.rawDataLength()),r=Cu(t.dataType()),i=t.rawDataLength()/r;if(t.rawDataLength()%r!=0)throw new Error("invalid buffer length");if(e.length!==i)throw new Error("buffer length mismatch");for(let o=0;o<i;o++){let i=ku(n,t.dataType(),o*r);e[o]=i}}return o}}}));function q(e){return 1===e?Hd:qd}function Ru(e){let t=q(e);return`${t.version}\n      precision highp float;\n      ${t.attribute} vec3 position;\n      ${t.attribute} vec2 textureCoord;\n\n      ${t.varyingVertex} vec2 TexCoords;\n\n      void main()\n      {\n          gl_Position = vec4(position, 1.0);\n          TexCoords = textureCoord;\n      }`}function Mu(e){let t=q(e);return`${t.version}\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    ${t.varyingFrag} vec2 TexCoords;\n    ${t.outputDeclaration}\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    // Custom vector types to handle higher dimenalities.\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    int imod(int x, int y) {\n      return x - y * (x / y);\n    }\n\n    `}function Gu(e,t){return`\n  void main() {\n    int indices[${t}];\n    toVec(TexCoords, indices);\n    vec4 result = vec4(process(indices));\n    ${q(e).output} = result;\n  }\n  `}var Hd,qd,xe=L((()=>{Hd={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},qd={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}})),ae=L((()=>{}));async function yi(e,t=(e=>0),n){return new Promise(((r,o)=>{let i=0,a=()=>{if(e())return void r();i++;let s=t(i);null!=n&&i>=n?o():setTimeout(a,s)};a()}))}function Kn(e){return Cr(typeof e<"u"&&0!==e.length,(()=>"empty string found for sampler name")),"get"+e.charAt(0).toUpperCase()+e.slice(1)}function Uu(e){return Cr(typeof e<"u"&&0!==e.length,(()=>"empty string found for sampler name")),"get"+e.charAt(0).toUpperCase()+e.slice(1)+"AtOutCoords"}function kr(e,t){let n=JSON.parse(JSON.stringify(e));return n=t,n}function Br(e,t){return t.map((t=>e[t])).join(", ")}function Ke(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function St(e=6){return["x","y","z","w","u","v"].slice(0,e)}var Ft=L((()=>{fe()}));function jd(e,t){return St(t).map((t=>`${e}.${t}`))}function Nr(e,t){return 1===t?[e]:jd(e,t)}function $t(){return"\n    float getChannel(vec4 frag, int dim) {\n      int modCoord = imod(dim, 2);\n      return modCoord == 0 ? frag.r : frag.g;\n    }\n\n    float getChannel(vec4 frag, vec2 innerDims) {\n      vec2 modCoord = mod(innerDims, 2.);\n      return modCoord.x == 0. ?\n        (modCoord.y == 0. ? frag.r : frag.g) :\n        (modCoord.y == 0. ? frag.b : frag.a);\n    }\n  "}var gr=L((()=>{Ft()}));function Xd(e,t,n){if(0===e)return"false";if(1===e)return`rc > ${t[0]}`;let r="";for(let o=e-2;o<e;o++)r+=`${n[o]} >= ${t[o-e+2]}`,o<e-1&&(r+="||");return r}function Kd(e,t){let n=e.length;if(0===n)return"getA(), 0, 0, 0";if(1===n)return`getA(rc),\n            rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),\n            0, 0`;let r="";if(n>2)for(let e=0;e<n-2;++e)r+=`${t[e]},`;return`getA(${r}r, c),\n          rEdge ? 0. : getA(${r}rp1, c),\n          cEdge ? 0. : getA(${r}r, cp1),\n          rEdge || cEdge ? 0. : getA(${r}rp1, cp1)`}function Jd(e,t,n,r){return 0===e||1===e?"":`\n    int r = ${t[e-2]};\n    int c = ${t[e-1]};\n    int rp1 = ${t[e-2]} + 1;\n    int cp1 = ${t[e-1]} + 1;\n    bool rEdge = rp1 >= ${r};\n    bool cEdge = cp1 >= ${n};\n    `}var zu,Yd,Vu,Wu=L((()=>{xe(),ae(),Ft(),gr(),zu={name:"pack",inputNames:["A"],inputTypes:[1]},Yd=(e,t)=>{let n,r=q(e.session.backend.glContext.version),o=t.dims,i=o.length,a=t.dims.length,s=Ke(a),u=Nr("rc",a),l=Jd(a,u,o[o.length-2],o[o.length-1]);n=0===i?[1,1]:1===i?[o[0],1]:[o[a-1],o[a-2]];let c=Xd(a,n,u),p=Kd(o,u),d=`\n        void main() {\n          ${s} rc = getOutputCoords();\n\n          if(${c}) {\n            ${r.output} = vec4(0);\n          } else {\n            ${l}\n\n            ${r.output} = vec4(${p});\n          }\n        }\n      `;return{...zu,hasMain:!0,output:{dims:t.dims,type:t.type,textureType:2},shaderSource:d}},Vu=(e,t)=>({...zu,get:()=>Yd(e,t)})}));function Ti(e){if(0===e.length)return[1,1,1];let t=1;for(let n=0;n<e.length-2;++n)t*=e[n];return[t,e.length>1?e[e.length-2]:1,e[e.length-1]]}function qu(e,t){let n=!1;return n=0===e.length||0===t.length||(e.length<2||t.length<2?e[e.length-1]===t[t.length-1]:e[e.length-1]===t[t.length-1]&&e[e.length-2]===t[t.length-2]),n}function eh(e){let t=U.computeStrides(e),n=["b","r","c"],r="index";return`\n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      ${t.map(((e,o)=>`${`int ${n[o]} = ${r} / ${e}`}; ${o===t.length-1?`int ${n[o+1]} = ${r} - ${n[o]} * ${e}`:`index -= ${n[o]} * ${e}`};`)).join("")}\n      return ivec3(b, r, c);\n    }\n  `}function th(e){let t=U.computeStrides(e);return`\n  int getFlattenedIndex(ivec3 coords) {\n    // reverse y, z order\n    return coords.x * ${t[0]} + coords.z * ${t[1]} + coords.y;\n  }\n`}var Zd,Qd,Hu,ju=L((()=>{fe(),xe(),ae(),gr(),Zd=e=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${e}`}),Qd=(e,t,n,r)=>{let o=t.dims,i=r,a="";for(let e=0;e<4;e++){let t="";switch(e){case 0:t="outputCoords = rc;";break;case 1:t="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:t="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:t="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}a+=`\n        ${t}\n        ${e>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}\n          int flattenedIndex = getFlattenedIndex(outputCoords);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);\n          vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result[${e}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);\n\n        ${e>0?"}":""}\n      `}let s=q(e.session.backend.glContext.version),u=`\n      ${eh(o)}\n      ${th(i)}\n      ${$t()}\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.0);\n\n        ivec3 outputCoords;\n        int rows = ${i[2]};\n        int cols = ${i[1]};\n\n        ${a}\n        ${s.output} = result;\n      }\n    `;return{...n,output:{dims:i,type:t.type,textureType:2},shaderSource:u,hasMain:!0}},Hu=(e,t,n)=>{let r=Zd(n);return{...r,get:()=>Qd(e,t,r,n)}}})),xi,Yu=L((()=>{xe(),ae(),xi=(e,t)=>{let n=t.shape,r=q(e.session.backend.glContext.version),o=`\n    const float FLOAT_MAX = 1.70141184e38;\n    const float FLOAT_MIN = 1.17549435e-38;\n\n    bool isNaN(float val) {\n      return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;\n    }\n\n    highp vec4 encodeAsUint8(highp float v) {\n      if (isNaN(v)) {\n        return vec4(255, 255, 255, 255);\n      }\n\n      highp float av = abs(v);\n\n      if(av < FLOAT_MIN) {\n        return vec4(0.0, 0.0, 0.0, 0.0);\n      } else if(v > FLOAT_MAX) {\n        return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n      } else if(v < -FLOAT_MAX) {\n        return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n      }\n\n      highp vec4 c = vec4(0,0,0,0);\n\n      highp float e = floor(log2(av));\n      highp float m = exp2(fract(log2(av))) - 1.0;\n\n      c[2] = floor(128.0 * m);\n      m -= c[2] / 128.0;\n      c[1] = floor(32768.0 * m);\n      m -= c[1] / 32768.0;\n      c[0] = floor(8388608.0 * m);\n\n      highp float ebias = e + 127.0;\n      c[3] = floor(ebias / 2.0);\n      ebias -= c[3] * 2.0;\n      c[2] += floor(ebias) * 128.0;\n\n      c[3] += 128.0 * step(0.0, -v);\n\n      return c / 255.0;\n    }\n\n    void main() {\n      float value = ${r.texture2D}(X,TexCoords).r;\n      ${r.output} = encodeAsUint8(value);\n    }`,i={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:n,type:t.tensor.type,textureType:3},shaderSource:o,hasMain:!0};return e.executeProgram(i,[t.tensor])}}));function nh(e,t){if(1===e)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}var Xu,rh,Ku,Ju=L((()=>{xe(),ae(),Ft(),gr(),Xu={name:"unpack",inputNames:["A"],inputTypes:[2]},rh=(e,t)=>{let n=t.dims.length,r=Nr("rc",n),o=r.slice(-2),i=Ke(n),a=$t(),s=0===t.dims.length?"":nh(n,r),u=n<=1?"rc":`vec2(${o.join(",")})`,l=`\n    ${a}\n    void main() {\n      ${i} rc = getOutputCoords();\n\n       // Sample the texture with the coords to get the rgba channel value.\n       vec4 packedInput = getA(${s});\n\n       ${q(e.session.backend.glContext.version).output} = vec4(getChannel(packedInput, ${u}), 0, 0, 0);\n     }\n   `;return{...Xu,hasMain:!0,output:{dims:t.dims,type:t.type,textureType:0},shaderSource:l}},Ku=(e,t)=>({...Xu,get:()=>rh(e,t)})})),Jn,un,Zn,ln=L((()=>{ut(),Jn=class{constructor(e,t=1){if(1===t)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=t;else{if(4!==t)throw new Error(`Invalid number of channels: ${t}`);this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=t}}encode(e,t){let n,r;return e.constructor!==Float32Array&&(ce.warning("Encoder","data was not of type Float32; creating new Float32Array"),r=new Float32Array(e)),t*this.channelSize>e.length?(ce.warning("Encoder","Source data too small. Allocating larger array"),r=e,n=this.allocate(t*this.channelSize),r.forEach(((e,t)=>n[t]=e))):(r=e,n=r),n}allocate(e){return new Float32Array(4*e)}decode(e,t){return 1===this.channelSize?e.filter(((e,t)=>t%4==0)).subarray(0,t):e.subarray(0,t)}},un=class{constructor(e,t=1,n){if(1!==t&&4!==t)throw new Error(`Invalid number of channels: ${t}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=t,this.textureType=n||e.FLOAT}encode(e,t){let n=e;return 1===this.channelSize&&(ce.verbose("Encoder","Exploding into a larger array"),n=this.allocate(t),e.forEach(((e,t)=>n[4*t]=e))),n}allocate(e){return new Float32Array(4*e)}decode(e,t){return 1===this.channelSize?e.filter(((e,t)=>t%4==0)).subarray(0,t):e.subarray(0,t)}},Zn=class{constructor(e,t=1){if(this.channelSize=4,1===t)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=t;else{if(4!==t)throw new Error(`Invalid number of channels: ${t}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=t}}encode(e,t){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,t){if(e instanceof Uint8Array)return e.subarray(0,t);throw new Error(`Invalid array type: ${e.constructor}`)}}})),fn,Zu,vi,Qu=L((()=>{fe(),ae(),fn=(e,t,n)=>{let r=0===n||1===n?1:4,o=2===n,i=1===n||2===n,a=4===n?t.length-1:void 0,s=4===n?t.map(((e,n)=>n===t.length-1?4*e:e)):void 0;return vi(e,t,r,s,{isPacked:o,reverseWH:i,breakAxis:a})},Zu=(e,t,n)=>{let r=fn(e,t,n);return[r.width,r.height]},vi=(e,t,n=1,r,o)=>{let i=!(!o||!o.isPacked),[a,s]=e.computeTextureWH(i&&r||t,o),u=t.length,l=t.slice(0);if(0===u&&(l=[1]),1===n)r=t;else if(i){if(4!==n)throw new Error("a packed texture must be 4-channel");r=t,u>0&&(l[u-1]=Math.ceil(l[u-1]/2)),u>1&&(l[u-2]=Math.ceil(l[u-2]/2))}else if(!r)throw new Error("Unpacked shape is needed when using channels > 1");return{width:a,height:s,channels:n,isPacked:i,shape:l,strides:U.computeStrides(l),unpackedShape:r,reversedWH:o&&o.reverseWH}}})),ih,Qn,tl=L((()=>{ut(),br(),fe(),Wu(),ju(),Yu(),Ju(),ln(),Qu(),ae(),ih=(e,t)=>{let n=t.map((e=>`${e.unpackedShape.join(",")};${e.width}x${e.height}`)).join("_"),r=e.name;return e.cacheHint&&(r+="["+e.cacheHint+"]"),r+=":"+n,r},Qn=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,t){return Zu(this.session.layoutStrategy,e,t)}executeProgram(e,t){if(t.length<e.inputNames.length)throw new Error(`Input size mustn't be less than ${e.inputNames.length}.`);if(e.inputNames.length!==e.inputTypes.length)throw new Error("input names size does not match input types");let n=[];for(let r=0;r<e.inputNames.length;++r)n[r]=this.getOrCreateTextureData(t[r],e.inputTypes[r]);let r=ih(e,n),o=this.session.programManager.getArtifact(r),i=o?o.programInfo:"function"==typeof e.get?e.get():e,a=fn(this.session.layoutStrategy,i.output.dims,i.output.textureType),s=this.createTextureData(a,i.output.type);return o||(o=this.session.programManager.build(i,n,s),this.session.programManager.setArtifact(r,o)),this.runProgram(o,n,s),s}run(e,t){return this.executeProgram(e,t).tensor}runProgram(e,t,n){for(let n=0;n<t.length;++n)if(!!t[n].isPacked!=(2===e.programInfo.inputTypes[n]))throw new Error(`input[${n}] property packed inconsistent`);if(!!n.isPacked!=(2===e.programInfo.output.textureType))throw new Error("output property packed inconsistent");this.session.programManager.run(e,t,n)}getOrCreateTextureData(e,t){let n=this.getTextureData(e.dataId,2===t);if(!n&&(n=this.getTextureData(e.dataId,2!==t),n))return 2===t?this.pack(n):this.unpack(n);if(!n){let r=fn(this.session.layoutStrategy,e.dims,t);if(4===t){let n=e.dims;if(4===n.length){let r=[n[0],Math.ceil(n[1]*n[2]*n[3]/4)],o=fn(this.session.layoutStrategy,r,t),i=e.numberData;if(n[1]*n[2]*n[3]%4!=0){let t=n[0],r=n[1]*n[2]*n[3],o=4*Math.ceil(1*r/4);i=new Float32Array(t*o);for(let n=0;n<t;++n){let t=n*r,a=n*o+n%1*r;i.set(e.numberData.subarray(t,t+r),a)}}return this.createTextureData(o,e.type,i,e,1)}}if(2===t){let t=vi(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),r=this.createTextureData(t,e.type,e.numberData,e,1);n=this.pack(r)}else n=this.createTextureData(r,e.type,e.numberData,e,1)}return n}createTextureDataFromLayoutBindTensor(e,t,n,r){return this.createTextureData(e,t,n,r,1)}createTextureData(e,t,n,r,o){ce.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);let i=this.session.textureManager.createTextureFromLayout(t,e,n,o);return this.createTextureDataFromTexture(e,t,i,r)}reshapeUnpacked(e,t){let n=this.getOrCreateTextureData(e,0),r={channels:n.channels,height:n.height,width:n.width,shape:0!==t.length?t:[1],strides:U.computeStrides(t),unpackedShape:t};return this.createTextureDataFromTexture(r,e.type,n.texture).tensor}reshapePacked(e,t){let n=this.getOrCreateTextureData(e,2);if(qu(e.dims,t)){let r={channels:n.channels,height:n.height,width:n.width,shape:0!==t.length?t:[1],strides:U.computeStrides(t),unpackedShape:t,isPacked:!0};return this.createTextureDataFromTexture(r,e.type,n.texture).tensor}let r=Ti(e.dims),o=Ti(t),i=this.reshapePacked(e,r),a=this.run(Hu(this,i,o),[i]);return this.reshapePacked(a,t)}cast(e,t){let n=this.getOrCreateTextureData(e,0);return this.createTextureDataFromTexture(n,t,n.texture).tensor}createTextureDataFromTexture(e,t,n,r,o){let i={...e,tensor:r||new Fe(e.unpackedShape,t,(e=>this.readTexture(i)),(async e=>this.readTextureAsync(i)),void 0,o),texture:n};return this.setTextureData(i.tensor.dataId,i,e.isPacked),i}getTextureData(e,t=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,t):t?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,t,n=!1){this.session.isInitializer(e)?this.session.setTextureData(e,t,n):(n?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,t)}isTextureLayoutCached(e,t=!1){return!!this.getTextureData(e.dataId,t)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach((e=>this.session.textureManager.releaseTexture(e))),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach((e=>this.session.textureManager.releaseTexture(e))),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat(xi(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat(xi(this,e))}pack(e){return this.executeProgram(Vu(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(Ku(this,e.tensor),[e.tensor])}}})),wi,ee,Ge=L((()=>{wi=class{constructor(e){Object.assign(this,e)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map((e=>`${this[e]}`)).join(";")),this.key}},ee=e=>new wi(e)})),rl,nl,ol,ah,sh,il=L((()=>{Ge(),xe(),ae(),rl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},nl=(e,t,n)=>(sh(t),[e.run({...rl,cacheHint:n.cacheKey,get:()=>ah(e,t,n)},t)]),ol=e=>{let t=e.attributes.getFloat("epsilon",1e-5),n=e.attributes.getFloat("momentum",.9),r=e.attributes.getInt("spatial",1);return ee({epsilon:t,momentum:n,spatial:r})},ah=(e,t,n)=>{let r=q(e.session.backend.glContext.version),o=t[0].dims.length,[i,a]=e.calculateTextureWidthAndHeight(t[1].dims,0),s=`\n  float process(int[${o}] indices) {\n    vec2 position = offsetToCoords(indices[1], ${i}, ${a});\n    float scale = getColorAsFloat(${r.texture2D}(Scale, position));\n    float mean = getColorAsFloat(${r.texture2D}(Mean, position));\n    float variance = getColorAsFloat(${r.texture2D}(Variance, position));\n    float b = getColorAsFloat(${r.texture2D}(B, position));\n\n    return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b;\n  }`;return{...rl,output:{dims:t[0].dims,type:t[0].type,textureType:0},shaderSource:s}},sh=e=>{if(!e||5!==e.length)throw new Error("BatchNormalization requires 5 inputs.");let t=e[0],n=e[1],r=e[2],o=e[3],i=e[4];if(t.dims.length<3||1!==n.dims.length||1!==r.dims.length||1!==o.dims.length||1!==i.dims.length)throw new Error("invalid input shape.");if(n.dims[0]!==t.dims[1]||r.dims[0]!==t.dims[1]||o.dims[0]!==t.dims[1]||i.dims[0]!==t.dims[1])throw new Error("invalid input shape.");if("float32"!==t.type&&"float64"!==t.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type||"float32"!==o.type&&"float64"!==o.type||"float32"!==i.type&&"float64"!==i.type)throw new Error("invalid input tensor types.")}})),eo,pt,R,cn,to,Vt=L((()=>{eo=class{constructor(e,t,n,r){this.glContext=e,this.programInfo=t,this.inputTextureLayouts=n,this.outputTextureLayout=r}},pt=class{constructor(e){this.context=e}},R=class{constructor(e,t){this.routineBody=e,this.dependencies=t}},cn=class{constructor(e,t,n){this.name=e,this.dependencies=n||[],t&&(this.routineBody=t)}addDependency(e){e&&this.dependencies.push(e)}},to=class{static returnOrderedNodes(e){if(!e||0===e.length)return[];if(1===e.length)return e;let t=new Set,n=new Set,r=new Array;return this.createOrderedNodes(e,t,n,r),r}static createOrderedNodes(e,t,n,r){for(let o=0;o<e.length;++o)this.dfsTraverse(e[o],t,n,r)}static dfsTraverse(e,t,n,r){if(!e||n.has(e.name))return;if(t.has(e.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");t.add(e.name);let o=e.dependencies;if(o&&o.length>0)for(let e=0;e<o.length;++e)this.dfsTraverse(o[e],t,n,r);r.push(e),n.add(e.name),t.delete(e.name)}}}));function lh(){let e="add_";return{body:`\n  float ${e}(float a, float b) {\n    return a + b;\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return v1 + v2;\n  }\n  `,name:e,type:0}}function fh(){let e="div_";return{body:`\n  float ${e}(float a, float b) {\n    return a / b;\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return v1 / v2;\n  }\n  `,name:e,type:0}}function ch(){let e="mul_";return{body:`\n  float ${e}(float a, float b) {\n    return a * b;\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return v1 * v2;\n  }\n  `,name:e,type:0}}function ph(){let e="sub_";return{body:`\n  float ${e}(float a, float b) {\n    return a - b;\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return v1 - v2;\n  }\n  `,name:e,type:0}}function dh(){let e="equal_";return{body:`\n  float ${e}(float a, float b) {\n    return float(a == b);\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return vec4(equal(v1, v2));\n  }\n  `,name:e,type:0}}function hh(){let e="greater_";return{body:`\n  float ${e}(float a, float b) {\n    return float(a > b);\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return vec4( v1.r > v2.r ,\n      v1.g > v2.g,\n      v1.b > v2.b,\n      v1.a > v2.a );\n  }\n  `,name:e,type:0}}function mh(){let e="less_";return{body:`\n  float ${e}(float a, float b) {\n    return float(a < b);\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return vec4( v1.r < v2.r ,\n                v1.g < v2.g,\n                v1.b < v2.b,\n                v1.a < v2.a );\n  }\n  `,name:e,type:0}}function bh(){let e="and_";return{body:`\n  float ${e}(float a, float b) {\n    return float( bool(a) && bool(b) );\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    bvec4 b1 = bvec4(v1);\n    bvec4 b2 = bvec4(v2);\n    return vec4( b1.r && b2.r ,\n                b1.g && b2.g,\n                b1.b && b2.b,\n                b1.a && b2.a );\n  }\n  `,name:e,type:0}}function gh(){let e="or_";return{body:`\n  float ${e}(float a, float b) {\n    return float( bool(a) || bool(b) );\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    bvec4 b1 = bvec4(v1);\n    bvec4 b2 = bvec4(v2);\n    return vec4( b1.r || b2.r ,\n                b1.g || b2.g,\n                b1.b || b2.b,\n                b1.a || b2.a );\n  }\n  `,name:e,type:0}}function yh(){let e="xor_";return{body:`\n  float ${e}(float a, float b) {\n    return float( bool(a) ^^ bool(b) );\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    bvec4 b1 = bvec4(v1);\n    bvec4 b2 = bvec4(v2);\n    return vec4( b1.r ^^ b2.r ,\n                b1.g ^^ b2.g,\n                b1.b ^^ b2.b,\n                b1.a ^^ b2.a );\n  }\n  `,name:e,type:0}}function Th(){return vh("pow")}function xh(){let e="prelu_";return{body:`\n  float ${e}(float a, float b) {\n    return a < 0.0 ? a * b: a;\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return vec4(\n      v1.r < 0.0 ? v1.r * v2.r: v1.r,\n      v1.g < 0.0 ? v1.g * v2.g: v1.g,\n      v1.b < 0.0 ? v1.b * v2.b: v1.b,\n      v1.a < 0.0 ? v1.a * v2.a: v1.a\n      );\n  }\n  `,name:e,type:0}}function vh(e){let t=`${e}_`;return{body:`\n  float ${t}(float a, float b) {\n    return ${e}(a, b);\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return ${e}(v1, v2);\n  }\n  `,name:t,type:0}}var dt,wh,al,sl,ul,ll,fl,cl,pl,dl,hl,ml,bl,gl,yl=L((()=>{fe(),Vt(),xe(),ae(),dt=(e,t,n,r=t[0].type,o)=>{let i=e.session.pack?2:0;return{name:n.name,inputNames:["A","B"],inputTypes:[i,i],cacheHint:o,get:()=>wh(e,t,n,r)}},wh=(e,t,n,r=t[0].type)=>{let o=e.session.pack?2:0,i=!U.areEqual(t[0].dims,t[1].dims),a=t[0].dims,s=e.session.pack;if(i){let i=Xe.calcShape(t[0].dims,t[1].dims,!1);if(!i)throw new Error("Can't perform binary op on the given tensors");a=i;let u=a.length,l=0!==t[0].dims.length?t[0].dims.length:1,c=0!==t[1].dims.length?t[1].dims.length:1,p=0!==t[0].dims.length?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",d=0!==t[1].dims.length?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",f=q(e.session.backend.glContext.version),h=s?`\n      ${n.body}\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n        vec4 result = ${n.name}(a, b);\n        ${f.output} = result;\n      }`:`\n      ${n.body}\n      float process(int indices[${u}]) {\n        int aindices[${l}];\n        int bindices[${c}];\n        ${p}\n        ${d}\n        return ${n.name}(_A(aindices), _B(bindices));\n      }`;return{name:n.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:a,type:r,textureType:o},shaderSource:h,hasMain:s}}let u=q(e.session.backend.glContext.version),l=`\n    ${n.body}\n    void main() {\n      vec4 v1 = ${u.texture2D}(A, TexCoords);\n      vec4 v2 = ${u.texture2D}(B, TexCoords);\n      vec4 result = ${n.name}(v1, v2);\n      ${u.output} = result;\n    }\n    `;return{name:n.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:t[0].dims,type:r,textureType:o},shaderSource:l,hasMain:!0}},al=(e,t)=>[e.run(dt(e,t,lh()),t)],sl=(e,t)=>[e.run(dt(e,t,bh(),"bool"),t)],ul=(e,t)=>[e.run(dt(e,t,fh()),t)],ll=(e,t)=>[e.run(dt(e,t,dh(),"bool"),t)],fl=(e,t)=>[e.run(dt(e,t,hh(),"bool"),t)],cl=(e,t)=>[e.run(dt(e,t,mh(),"bool"),t)],pl=(e,t)=>[e.run(dt(e,t,ch()),t)],dl=(e,t)=>[e.run(dt(e,t,gh(),"bool"),t)],hl=(e,t)=>[e.run(dt(e,t,Th()),t)],ml=(e,t)=>[e.run(dt(e,t,xh()),t)],bl=(e,t)=>[e.run(dt(e,t,ph()),t)],gl=(e,t)=>[e.run(dt(e,t,yh(),"bool"),t)]})),Tl,xl,Oh,vl=L((()=>{fe(),Tl=(e,t,n)=>(Oh(t),[e.cast(t[0],n)]),xl=e=>Ve.tensorDataTypeFromProto(e.attributes.getInt("to")),Oh=e=>{if(!e||1!==e.length)throw new Error("Cast requires 1 input.");if("string"===e[0].type)throw new Error("Invalid input type.")}})),Ih,Sh,wl,ro,_l=L((()=>{xe(),ae(),Ft(),gr(),Ih=(e,t)=>({name:"Concat (packed)",inputNames:Array.from({length:e},((e,t)=>`X${t}`)),inputTypes:Array(e).fill(2),cacheHint:t}),Sh=(e,t,n,r)=>{let o=n[0].dims.slice();if(r>=o.length||r<-1*o.length)throw new Error("axis specified for concat doesn't match input dimensionality");r<0&&(r=o.length+r);let i=o.slice(0);for(let e=1;e<n.length;e++){let t=n[e].dims.slice();for(let e=0;e<o.length;e++)if(e===r)i[r]+=t[e];else if(o[e]!==t[e])throw new Error("non concat dimensions must match")}let a=i.length,s=Nr("coords",a),u=Ke(a),l=$t(),c=n.map((e=>e.dims)),p=St(a),d=new Array(c.length-1);d[0]=c[0][r];for(let e=1;e<d.length;e++)d[e]=d[e-1]+c[e][r];let f=p[r],h=p.slice(-2),g=p.join(),m=`if (${f} < ${d[0]}) {\n        return getChannel(\n            getX0(${g}), vec2(${h.join()}));\n        }`;for(let e=1;e<d.length;e++){let t=d[e-1];m+=`\n            if (${f} < ${d[e]}  && ${f} >= ${d[e-1]}) {\n              return getChannel(\n                getX${e}(${ro(p,f,t)}),\n                vec2(${ro(h,f,t)}));\n            }`}let b=d.length,y=d[d.length-1];m+=`\n            return getChannel(\n              getX${b}(${ro(p,f,y)}),\n              vec2(${ro(h,f,y)}));`;let w=q(e.session.backend.glContext.version),_=`\n          ${l}\n          float getValue(${p.map((e=>"int "+e))}) {\n            ${m}\n          }\n\n          void main() {\n            ${u} coords = getOutputCoords();\n            int lastDim = coords.${p[a-1]};\n            coords.${p[a-1]} = coords.${p[a-2]};\n            coords.${p[a-2]} = lastDim;\n\n            vec4 result = vec4(getValue(${s}), 0., 0., 0.);\n\n            ${s[a-1]} = ${s[a-1]} + 1;\n            if (${s[a-1]} < ${i[a-1]}) {\n              result.g = getValue(${s});\n            }\n\n            ${s[a-2]} = ${s[a-2]} + 1;\n            if (${s[a-2]} < ${i[a-2]}) {\n              result.a = getValue(${s});\n            }\n\n            ${s[a-1]} = ${s[a-1]} - 1;\n            if (${s[a-2]} < ${i[a-2]} &&\n                ${s[a-1]} < ${i[a-1]}) {\n              result.b = getValue(${s});\n            }\n            ${w.output} = result;\n          }\n        `;return{...t,output:{dims:i,type:n[0].type,textureType:2},shaderSource:_,hasMain:!0}},wl=(e,t,n)=>{let r=Ih(t.length,n.cacheKey);return{...r,get:()=>Sh(e,r,t,n.axis)}},ro=(e,t,n)=>{let r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}})),Ol,Ah,Ph,Eh,Il,Dh,Lh,Fh,Sl,$h,Al=L((()=>{Ge(),ae(),_l(),Ol=(e,t,n)=>($h(t),e.session.pack&&t[0].dims.length>1?[e.run(wl(e,t,n),t)]:[e.run(Eh(e,t,n),t)]),Ah=(e,t)=>({name:"Concat",inputNames:Array.from({length:e},((e,t)=>`X${t}`)),inputTypes:Array(e).fill(0),cacheHint:t}),Ph=(e,t,n,r)=>{let o=n[0].dims.slice();if(r>=o.length||r<-1*o.length)throw new Error("axis specified for concat doesn't match input dimensionality");r<0&&(r=o.length+r);let i=o.slice(0);for(let e=1;e<n.length;e++){let t=n[e].dims.slice();for(let e=0;e<o.length;e++)if(e===r)i[r]+=t[e];else if(o[e]!==t[e])throw new Error("non concat dimensions must match")}let a=i.length,s=new Array(n.length),u=0;for(let e=0;e<s.length;++e)u+=n[e].dims[r],s[e]=u;let l="";l=n.length<5?Il(s):Dh(s);let c=`\n        ${Lh(n.length,a)}\n        ${Fh(s)}\n        ${l}\n        float process(int indices[${a}]) {\n          int textureIndex = getTextureWhereDataResides (indices[${r}]);\n\n          if(textureIndex != 0) {\n            indices[${r}] = indices[${r}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));\n          }\n\n          return fetchDataFromCorrectTexture(textureIndex, indices);\n        }`;return{...t,output:{dims:i,type:n[0].type,textureType:0},shaderSource:c}},Eh=(e,t,n)=>{let r=Ah(t.length,n.cacheKey);return{...r,get:()=>Ph(e,r,t,n.axis)}},Il=e=>`int getTextureWhereDataResides(int index) {\n      ${e.map(((e,t)=>`if(index<${e}) {return ${t};}\n`)).join("")}\n    }`,Dh=e=>Il(e),Lh=(e,t)=>{let n=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${t}]) {`];for(let t=0;t<e;++t)0===t?n.push(`\tif (textureIndex == ${t}) { return _X${t}(indices); }`):t===e-1?n.push(`\telse { return _X${t}(indices); }`):n.push(`\telse if (textureIndex == ${t}) { return _X${t}(indices); }`);return n.push("\t}"),n.join("\n")},Fh=e=>{let t=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let n=0;n<e.length;++n)0===n?t.push(`\tif (index == ${n}) { return ${e[n]}; }`):n===e.length-1?t.push(`\telse { return ${e[n]}; }`):t.push(`\telse if (index == ${n}) { return ${e[n]}; }`);return t.push("\t}"),t.join("\n")},Sl=e=>ee({axis:e.attributes.getInt("axis")}),$h=e=>{if(!e||e.length<1)throw new Error("too few inputs");let t=e[0].type,n=e[0].dims.length;if("string"===t)throw new Error("string tensor is not supported yet");for(let r of e){if(r.type!==t)throw new Error("input tensors should be one type");if(r.dims.length!==n)throw new Error("input tensors should have the same shape")}}}));function Ch(){return ht("abs")}function kh(){return ht("acos")}function Bh(){return ht("asin")}function Nh(){return ht("atan")}function Rh(){return ht("ceil")}function Mh(){return ht("cos")}function Gh(e){let t="elu";return{body:`\n  const float alpha = float(${e});\n\n  float ${t}_(float a) {\n    return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;\n  }\n  vec4 ${t}_(vec4 v) {\n    return vec4(${t}_(v.x), ${t}_(v.y), ${t}_(v.z), ${t}_(v.w));\n  }\n  `,name:t,type:0}}function Uh(){return ht("exp")}function zh(){return ht("floor")}function _i(e,t){let n="clip";return{body:`\n  const float min = float(${e});\n  const float max = float(${t});\n\n  float ${n}_(float a) {\n    return clamp(a, min, max);\n  }\n  vec4 ${n}_(vec4 v) {\n    return clamp(v, min, max);\n  }\n  `,name:n,type:0}}function Vh(){let e="indentity";return{body:`\n  float ${e}_(float a) {\n    return a;\n  }\n  vec4 ${e}_(vec4 v) {\n    return v;\n  }\n  `,name:e,type:0}}function Wh(e){let t="leakyRelu";return{body:`\n  const float alpha = float(${e});\n\n  float ${t}_(float a) {\n    return a < 0.0 ? a * alpha : a;\n  }\n  vec4 ${t}_(vec4 v) {\n    return vec4(${t}_(v.x), ${t}_(v.y), ${t}_(v.z), ${t}_(v.w));\n  }\n  `,name:t,type:0}}function Hh(){return ht("log")}function qh(){let e="neg";return{body:`\n  float ${e}_(float a) {\n    return -a;\n  }\n  vec4 ${e}_(vec4 v) {\n    return -v;\n  }\n  `,name:e,type:0}}function jh(){let e="not";return{body:`\n  float ${e}_(float a) {\n    return float( ! bool(a) );\n  }\n  bool ${e}_(bool a) {\n    return !a;\n  }\n  vec4 ${e}_(vec4 v) {\n    return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));\n  }\n  bvec4 ${e}_(bvec4 v) {\n    return bvec4(!v.x, !v.y, !v.z, !v.w);\n  }\n  `,name:e,type:0}}function Yh(){return ht("sin")}function Oi(){let e="relu";return{body:`\n  float ${e}_(float a) {\n    return max( a, 0.0 );\n  }\n  vec4 ${e}_(vec4 v) {\n    return max( v, 0.0 );\n  }\n  `,name:e,type:0}}function Ii(){let e="sigmoid";return{body:`\n  float ${e}_(float a) {\n    return 1.0 / (1.0 + exp(-a));\n  }\n  vec4 ${e}_(vec4 v) {\n    return 1.0 / (1.0 + exp(-v));\n  }\n  `,name:e,type:0}}function Xh(){return ht("sqrt")}function Kh(){return ht("tan")}function Jh(){let e="tanh";return{body:`\n  float ${e}_(float a) {\n    a = clamp(a, -10., 10.);\n    a = exp(2.*a);\n    return (a - 1.) / (a + 1.);\n  }\n  vec4 ${e}_(vec4 v) {\n    v = clamp(v, -10., 10.);\n    v = exp(2.*v);\n    return (v - 1.) / (v + 1.);\n  }\n  `,name:e,type:0}}function ht(e){return{body:`\n  float ${e}_(float a) {\n    return ${e}(a);\n  }\n  vec4 ${e}_(vec4 v) {\n    return ${e}(v);\n  }\n  `,name:e,type:0}}var Zh,Pe,Pl,El,Dl,Ll,Si,Fl,$l,Qh,Cl,kl,Bl,Nl,Rl,Ml,Ai,Gl,Ul,zl,Vl,Wl,Hl,ql,jl,Yl,Xl,Kl,Pi=L((()=>{Ge(),fe(),Vt(),xe(),ae(),Zh=(e,t,n,r)=>{let o=e.session.pack?2:0,i=q(e.session.backend.glContext.version);return{...t,output:{dims:n.dims,type:n.type,textureType:o},shaderSource:`\n     ${r.body}\n     void main() {\n       vec4 v = ${i.texture2D}(A, TexCoords);\n       v = ${r.name}_(v);\n       ${i.output} = v;\n     }\n     `,hasMain:!0}},Pe=(e,t,n,r)=>{let o=e.session.pack?2:0,i={name:n.name,inputTypes:[o],inputNames:["A"],cacheHint:r};return{...i,get:()=>Zh(e,i,t,n)}},Pl=(e,t)=>[e.run(Pe(e,t[0],Ch()),t)],El=(e,t)=>[e.run(Pe(e,t[0],kh()),t)],Dl=(e,t)=>[e.run(Pe(e,t[0],Bh()),t)],Ll=(e,t)=>[e.run(Pe(e,t[0],Nh()),t)],Si=(e,t,n)=>[e.run(Pe(e,t[0],_i(n.min,n.max),n.cacheKey),t)],Fl=e=>ee({min:e.attributes.getFloat("min",hr),max:e.attributes.getFloat("max",mr)}),$l=(e,t)=>{let n=Qh(e,t);return Si(e,[t[0]],n)},Qh=(e,t)=>{if(t.length>=3&&(!e.session.isInitializer(t[1].dataId)||!e.session.isInitializer(t[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let n=t.length>=3?t[1].numberData[0]:hr,r=t.length>=3?t[2].numberData[0]:mr;return ee({min:n,max:r})},Cl=(e,t)=>[e.run(Pe(e,t[0],Rh()),t)],kl=(e,t)=>[e.run(Pe(e,t[0],Mh()),t)],Bl=(e,t,n)=>[e.run(Pe(e,t[0],Gh(n.alpha),n.cacheKey),t)],Nl=e=>ee({alpha:e.attributes.getFloat("alpha",1)}),Rl=(e,t)=>[e.run(Pe(e,t[0],Uh()),t)],Ml=(e,t)=>[e.run(Pe(e,t[0],zh()),t)],Ai=(e,t)=>[e.run(Pe(e,t[0],Vh()),t)],Gl=(e,t,n)=>[e.run(Pe(e,t[0],Wh(n.alpha),n.cacheKey),t)],Ul=e=>ee({alpha:e.attributes.getFloat("alpha",.01)}),zl=(e,t)=>[e.run(Pe(e,t[0],Hh()),t)],Vl=(e,t)=>[e.run(Pe(e,t[0],qh()),t)],Wl=(e,t)=>[e.run(Pe(e,t[0],jh()),t)],Hl=(e,t)=>[e.run(Pe(e,t[0],Oi()),t)],ql=(e,t)=>[e.run(Pe(e,t[0],Ii()),t)],jl=(e,t)=>[e.run(Pe(e,t[0],Yh()),t)],Yl=(e,t)=>[e.run(Pe(e,t[0],Xh()),t)],Xl=(e,t)=>[e.run(Pe(e,t[0],Kh()),t)],Kl=(e,t)=>[e.run(Pe(e,t[0],Jh()),t)]}));function Ct(e){let t;switch(e.activation){case"Relu":t=Oi();break;case"Sigmoid":t=Ii();break;case"Clip":t=_i(e.clipMin,e.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let n=t.name;return{activationFunction:t.body,applyActivation:`value = ${n}_(value);`}}var Rr,yr=L((()=>{fe(),Pi(),Rr=e=>{let t=e.getString("activation","");if("Clip"===t){let[n,r]=e.getFloats("activation_params",[hr,mr]);return{activation:t,clipMax:r,clipMin:n,activationCacheKey:`${t}:${n},${r}`}}return{activation:t,activationCacheKey:t}}})),tm,rm,Jl,Zl=L((()=>{ut(),xe(),ae(),no(),yr(),tm=(e,t)=>({name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:t}),rm=(e,t,n,r)=>{let o=t.length>2?"value += getBias(output_channel);":"",i=t[0].dims.slice(),a=t[1].dims.slice(),s=a[0]/r.group;ce.verbose("GroupedConv",`autpPad:${r.autoPad}, dilations:${r.dilations}, group:${r.group}, kernelShape:${r.kernelShape}, pads:${r.pads}, strides:${r.strides}`);let u=Mr(i,a,r.dilations,r.pads,r.strides),l=q(e.session.backend.glContext.version),{activationFunction:c,applyActivation:p}=Ct(r),d=`\n  const ivec2 strides = ivec2(${r.strides[0]}, ${r.strides[1]});\n  const ivec2 pads = ivec2(${r.pads[0]}, ${r.pads[1]});\n  ${c}\n  void main() {\n    ivec4 coords = getOutputCoords();\n    int batch = coords.x;\n    int output_channel = coords.y;\n    ivec2 xRCCorner = coords.zw * strides - pads;\n    int group_id = output_channel / ${s};\n\n    float value = 0.0;\n    for (int wInChannel = 0; wInChannel < ${a[1]}; wInChannel++) {\n      int input_channel = group_id * ${a[1]} + wInChannel;\n      for (int wHeight = 0; wHeight < ${a[2]}; wHeight++) {\n        int xHeight = xRCCorner.x + wHeight * ${r.dilations[0]};\n\n        if (xHeight < 0 || xHeight >= ${i[2]}) {\n          continue;\n        }\n\n        for (int wWidth = 0; wWidth < ${a[3]}; wWidth++) {\n          int xWidth = xRCCorner.y + wWidth * ${r.dilations[1]};\n          if (xWidth < 0 || xWidth >= ${i[3]}) {\n            continue;\n          }\n\n          float xVal = getX(batch, input_channel, xWidth, xHeight);\n          float wVal = getW(output_channel, wInChannel, wWidth, wHeight);\n          value += xVal*wVal;\n        }\n      }\n    }\n    ${o}\n    ${p}\n    ${l.output} = vec4(value, .0, .0, .0);\n  }\n`;return{...n,output:{dims:u,type:t[0].type,textureType:0},shaderSource:d,hasMain:!0}},Jl=(e,t,n)=>{let r=tm(t.length>2,n.cacheKey);return{...r,get:()=>rm(e,t,r,n)}}})),nm,om,Ql,ef=L((()=>{xe(),ae(),gr(),nm=e=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:e}),om=(e,t,n,r,o,i)=>{let a=n.dims,s=r.dims,u=o.length,l=[s[1]*s[2]*s[3],o[2]*o[3]],c=s[2]*s[3],p=$t(),d=q(e.session.backend.glContext.version),f="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)f+=`\n            blockIndex = rc.x + ${t};\n            pos = rc.y + ${e};\n\n            if(blockIndex < ${l[1]} && pos < ${l[0]}) {\n              offsetY = int(blockIndex / (${o[u-1]})) * ${i.strides[0]} -\n                ${i.pads[0]};\n              d0 = offsetY + ${i.dilations[0]} * (imod(pos, ${c}) / ${s[2]});\n\n              if(d0 < ${a[2]} && d0 >= 0) {\n                offsetX = imod(blockIndex, ${o[u-1]}) * ${i.strides[1]} -\n                  ${i.pads[1]};\n                d1 = offsetX + ${i.dilations[1]} * imod(imod(pos, ${c}), ${s[2]});\n\n                if(d1 < ${a[3]} && d1 >= 0) {\n\n                  ch = int(float(pos)/ ${c}.);\n                    innerDims = vec2(d0, d1);\n                    result[${2*e+t}] = getChannel(\n                      getA(0, ch, int(innerDims.x),\n                      int(innerDims.y)), innerDims);\n                }\n              }\n            }\n\n          `;let h=`\n      ${p}\n\n      void main() {\n        ivec2 rc = getOutputCoords();\n          vec4 result = vec4(0.0);\n          int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n          vec2 innerDims;\n          ${f}\n          ${d.output} = result;\n      }\n            `;return{...t,output:{dims:l,type:n.type,textureType:2},shaderSource:h,hasMain:!0}},Ql=(e,t,n,r,o)=>{let i=nm(o.cacheKey);return{...i,get:()=>om(e,i,t,n,r,o)}}}));function am(e,t,n){let r=t[0].dims,o=t[1].dims,i=Xe.calcShape(r,o,!0);if(!i)throw new Error("Can't use matmul on the given tensors");let a=Ke(i.length),s=St(),{activationFunction:u,applyActivation:l}=Ct(n),c=t.length>2,p=c?"value += getBiasForMatmul();":"",d=c?`${Di(a,s,t[2].dims,i,!1)}`:"",f=i.length,h=r.length,g=o.length,m=`\n    ${u}\n    ${d}\n    float process(int indices[${f}]) {\n        int a[${h}];\n        int b[${g}];\n        bcastMatmulIndices_A(indices, a);\n        bcastMatmulIndices_B(indices, b);\n\n        float value;\n        for (int k=0; k<${r[r.length-1]}; ++k) {\n            a[${h-1}] = k;\n            b[${g-2}] = k;\n            value += _A(a) * _B(b);\n        }\n        ${p}\n        ${l}\n        return value;\n    }`;return{...e,output:{dims:i,type:t[0].type,textureType:0},shaderSource:m}}function Ei(e,t){let n=im(e.length>2,t.activationCacheKey);return{...n,get:()=>am(n,e,t)}}function Di(e,t,n,r,o){let i="",a=n.length,s=r.length,u=s-a;i=s<2&&a>0?"coords":n.map(((e,n)=>`coords.${t[n+u]}`)).join(", ");let l=Xe.getBroadcastDims(n,r).map((e=>`coords.${t[e+u]} = 0;`)).join("\n"),c="vec4(outputValue.xx, outputValue.yy)";return 1===U.size(n)&&(c="vec4(outputValue.x)"),o?`\nvec4 getBiasForMatmul() {\n  ${e} coords = getOutputCoords();\n  ${l}\n  vec4 outputValue = getBias(${i});\n  return ${c};\n}`:`\nfloat getBiasForMatmul() {\n  ${e} coords = getOutputCoords();\n  ${l}\n  return getBias(coords.x);\n}`}var tf,rf,im,sm,oo=L((()=>{fe(),ae(),Ft(),yr(),Li(),tf=(e,t,n)=>(sm(t),e.session.pack?[e.run(io(e,t,n),t)]:[e.run(Ei(t,n),t)]),rf=e=>Rr(e.attributes),im=(e,t)=>({name:"MatMul",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[0,0,0]:[0,0],cacheHint:t}),sm=e=>{if(!e||2!==e.length)throw new Error("MatMul requires 2 inputs.");if(e[0].dims[e[0].dims.length-1]!==e[1].dims[e[1].dims.length-2])throw new Error("shared dimension does not match.");if("float32"!==e[0].type&&"float64"!==e[0].type||"float32"!==e[1].type&&"float64"!==e[1].type)throw new Error("inputs should be float type");if(e[0].type!==e[1].type)throw new Error("inputs types should match")}}));function fm(e,t,n,r){let o=[],i=[],a=n[0].dims,s=n[1].dims,u=a.length,l=s.length,c=r.length,p=c-u,d=c-l;o=a.map(((e,n)=>`coords.${t[n+p]}`)),o[u-1]="i*2",o.join(", "),i=s.map(((e,n)=>`coords.${t[n+d]}`)),i[l-2]="i*2",i.join(", ");let f=Xe.getBroadcastDims(a,r),h=Xe.getBroadcastDims(s,r),g=f.map((e=>`coords.${t[e+p]} = 0;`)).join("\n"),m=h.map((e=>`coords.${t[e+d]} = 0;`)).join("\n"),b=`int lastDim = coords.${t[c-1]};\n  coords.${t[c-1]} = coords.${t[c-2]};\n  coords.${t[c-2]} = lastDim;`;return`\nvec4 getAAtOutCoordsMatmul(int i) {\n  ${e} coords = getOutputCoords();\n  ${b}\n  ${g}\n  vec4 outputValue = getA(${o});\n  return outputValue;\n}\n\nvec4 getBAtOutCoordsMatmul(int i) {\n  ${e} coords = getOutputCoords();\n  ${b}\n  ${m}\n  vec4 outputValue = getB(${i});\n  return outputValue;\n}`}function cm(e,t){let n="";for(let r=0;r<t-2;r++)n+=`rc.${e[r]}, `;return n+=`rc.${e[t-2]}, i*2`,n}function pm(e,t){let n="";for(let r=0;r<t-2;r++)n+=`rc.${e[r]}, `;return n+=`i*2, rc.${e[t-1]}`,n}var um,lm,io,Li=L((()=>{fe(),xe(),ae(),Ft(),yr(),oo(),um=(e,t)=>({name:"MatMul (packed)",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[2,2,2]:[2,2],cacheHint:t}),lm=(e,t,n,r)=>{let o=n.length>2,i=o?"value += getBiasForMatmul();":"",a=n[0].dims,s=n[1].dims,u=Xe.calcShape(a,s,!0),l=!U.areEqual(n[0].dims,n[1].dims);if(!u)throw new Error("Can't use matmul on the given tensors");let c=a[a.length-1],p=Math.ceil(c/2),d=a.length,f=s.length,h=q(e.session.backend.glContext.version),g=Ke(u.length),m=u.length,b=St(),{activationFunction:y,applyActivation:w}=Ct(r),_=o?`${Di(g,b,n[2].dims,u,!0)}`:"",v=l?`${fm(g,b,n,u)}`:"",x=l?"getAAtOutCoordsMatmul(i)":`getA(${cm(b,d)})`,T=l?"getBAtOutCoordsMatmul(i)":`getB(${pm(b,f)})`,O=`\n            ${v}\n            ${_}\n            ${y}\n            void main() {\n              ${l?"":`${g} rc =\n          getOutputCoords(); int lastDim = rc.${b[m-1]}; rc.${b[m-1]} =\n          rc.${b[m-2]}; rc.${b[m-2]} = lastDim;\n      `}\n\n              vec4 value = vec4(0);\n              for (int i = 0; i < ${p}; i++) {\n                vec4 a = ${x};\n                vec4 b = ${T};\n\n                value += (a.rrbb * b.rgrg);\n                value += (a.ggaa * b.baba);\n              }\n              ${i}\n              ${w}\n              ${h.output} = value;\n            }`;return{...t,output:{dims:u,type:n[0].type,textureType:2},shaderSource:O,hasMain:!0}},io=(e,t,n)=>{let r=um(t.length>2,n.activationCacheKey);return{...r,get:()=>lm(e,r,t,n)}}})),nf,of=L((()=>{no(),ef(),Li(),nf=(e,t,n)=>{let r=t[0].dims,o=t[1].dims,i=Mr(r,o,n.dilations,n.pads,n.strides),a=e.run(Ql(e,t[0],t[1],i,n),[t[0]]),s=e.reshapePacked(t[1],[o[0],o[1]*o[2]*o[3]]),u=3===t.length?[s,a,t[2]]:[s,a],l=e.run(io(e,u,n),u);return e.reshapePacked(l,i)}})),dm,hm,af,Fi,$i=L((()=>{ae(),dm=e=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:e}),hm=(e,t,n,r,o,i)=>{let a=n.dims,s=r.dims,u=o.length,l=Fi(a,s,o,4),c=`\n        const int XC = ${a[1]};\n        const int XH = ${a[2]};\n        const int XW = ${a[3]};\n        const int KH = ${i.kernelShape[0]};\n        const int KW = ${i.kernelShape[1]};\n        const int dilationH = ${i.dilations[0]};\n        const int dilationW = ${i.dilations[1]};\n        const int strideH = ${i.strides[0]};\n        const int strideW = ${i.strides[1]};\n        const int padH = ${i.pads[0]};\n        const int padW = ${i.pads[1]};\n        const int KHKW = KH*KW;\n        const int XCKHKW = XC * KHKW;\n        const int outputChannels = 4;\n        vec4 process(int indices[${u}]) {\n          int b  = indices[0]; // batch size\n          int oh = indices[1] * strideH - padH; //output height\n          int ow = indices[2] * strideW - padW; //output width\n          int p = indices[3] * outputChannels; //patch\n          vec4 value = vec4(0.0);\n          for(int i=0; i < outputChannels; ++i) {\n            if(p < XCKHKW) {\n              int patchC = p / KHKW;\n              int patchH = (p - patchC*KHKW) / KW;\n              int patchW = (p - patchC*KHKW) - patchH * KW;\n              int xh2 = oh + patchH * dilationH;\n              int xw2 = ow + patchW * dilationW;\n              int x[${a.length}];\n              x[0] = b;\n              x[1] = patchC;\n              x[2] = xh2;\n              x[3] = xw2;\n              if(xh2 >= 0 &&\n                  xh2 < XH &&\n                  xw2 >= 0 &&\n                  xw2 < XW) {\n                value[i] = _X(x);\n              }\n            }\n            ++p;\n          }\n          return value;\n        }\n        `;return{...t,output:{dims:l,type:n.type,textureType:4},shaderSource:c}},af=(e,t,n,r,o)=>{let i=dm(o.cacheKey);return{...i,get:()=>hm(e,i,t,n,r,o)}},Fi=(e,t,n,r=4)=>[n[0],n[2],n[3],Math.ceil(e[1]*t[2]*t[3]/r)]})),mm,bm,sf,uf=L((()=>{fe(),xe(),ae(),yr(),$i(),mm=(e,t)=>({name:"ConvDotProduct",inputNames:e?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:e?[0,4,0]:[0,4],cacheKey:t.activationCacheKey}),bm=(e,t,n,r,o)=>{let i=n[0].dims,a=n[1].dims,s=[a[0],Math.ceil(i[1]*a[2]*a[3]/4)],u=Fi(i,a,r),[l,c]=e.calculateTextureWidthAndHeight(s,4),p=U.computeStrides(u),[d,f]=e.calculateTextureWidthAndHeight(u,4),h=r.length,g=n.length<3?"0.0":"_B(b)",m=Math.ceil(i[1]*a[2]*a[3]/4),{activationFunction:b,applyActivation:y}=Ct(o),w=q(e.session.backend.glContext.version),_=`\n${b}\nfloat process(int indices[${h}]) {\n  int b[1];\n  b[0] = indices[1];\n  int im2col[4];\n  im2col[0] = indices[0];\n  im2col[1] = indices[2];\n  im2col[2] = indices[3];\n  int im2colOffset = im2col[0] * ${p[0]} + im2col[1] * ${p[1]} + im2col[2] * ${p[2]};\n  int kernelOffset = indices[1] * ${s[1]};\n  float value = ${g};\n  for (int i = 0; i < ${m}; ++i) {\n    vec2 im2colCoords = offsetToCoords(im2colOffset, ${d}, ${f});\n    vec2 kernelCoords = offsetToCoords(kernelOffset, ${l}, ${c});\n    value += dot(${w.texture2D}(Im2Col, im2colCoords), ${w.texture2D}(K, kernelCoords));\n    ++im2colOffset;\n    ++kernelOffset;\n  }\n  ${y}\n  return value;\n}`;return{...t,output:{dims:r,type:n[0].type,textureType:0},shaderSource:_}},sf=(e,t,n,r)=>{let o=mm(t.length>2,r);return{...o,get:()=>bm(e,o,t,n,r)}}})),Mr,Ci,gm,ym,Tm,xm,ki,vm,no=L((()=>{Ge(),fe(),Zl(),of(),uf(),yr(),$i(),oo(),Mr=(e,t,n,r,o)=>{let i=e[0],a=e.slice(2),s=a.length,u=t[0],l=t.slice(2).map(((e,t)=>e+(e-1)*(n[t]-1))),c=a.map(((e,t)=>e+r[t]+r[t+s])).map(((e,t)=>Math.floor((e-l[t]+o[t])/o[t])));return[i,u].concat(...c)},Ci=(e,t,n)=>(vm(t,n),gm(e,t,n)),gm=(e,t,n)=>{let r=xm(n,t),o=e.session.pack,i=1===r.kernelShape[0]&&1===r.kernelShape[1];return r.group>1?[e.run(Jl(e,t,r),t)]:i&&o?[ym(e,t,r)]:o&&4===t[0].dims.length&&1===t[0].dims[0]&&!i?[nf(e,t,r)]:[Tm(e,t,r)]},ym=(e,t,n)=>{let r=t[0].dims,o=t[1].dims,i=Mr(r,o,n.dilations,n.pads,n.strides),a=e.reshapeUnpacked(t[0],[r[1],r[2]*r[3]]),s=e.reshapeUnpacked(t[1],[o[0],o[1]]),u=t.length>2?[s,a,t[2]]:[s,a],l=e.run(Ei(u,n),u);return e.reshapeUnpacked(l,i)},Tm=(e,t,n)=>{let r=t[0].dims,o=t[1].dims,i=Mr(r,o,n.dilations,n.pads,n.strides),a=e.run(af(e,t[0],t[1],i,n),[t[0]]),s=3===t.length?[a,t[1],t[2]]:[a,t[1]];return e.run(sf(e,t,i,n),s)},xm=(e,t)=>{let n=e.kernelShape.slice();if(0===e.kernelShape.length)for(let e=2;e<t[1].dims.length;++e)n.push(t[1].dims[e]);let r=e.pads.slice();dr.adjustPadsBasedOnAutoPad(t[0].dims,e.strides,e.dilations,n,r,e.autoPad);let o=Object.assign({},e);return Object.assign(o,{kernelShape:n,pads:r,cacheKey:e.cacheKey}),o},ki=e=>{let t=e.attributes,n=Rr(t),r=t.getString("auto_pad","NOTSET"),o=t.getInts("dilations",[1,1]),i=t.getInt("group",1),a=t.getInts("kernel_shape",[]),s=t.getInts("pads",[0,0,0,0]),u=t.getInts("strides",[1,1]);return ee({autoPad:r,dilations:o,group:i,kernelShape:a,pads:s,strides:u,...n})},vm=(e,t)=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==e[0].dims.length||4!==e[1].dims.length)throw new Error("currently only support 2-dimensional conv");if(e[0].dims[1]!==e[1].dims[1]*t.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(3===e.length&&(1!==e[2].dims.length||e[1].dims[0]!==e[2].dims[0]))throw new Error("invalid bias");let n=e[0].dims.length-2;if(t.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(t.strides.length!==n)throw new Error(`strides should be ${n}D`);if(t.pads.length!==2*n)throw new Error(`pads should be ${2*n}D`);if(0!==t.kernelShape.length&&t.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if("float32"!==e[0].type||"float32"!==e[1].type)throw new Error("Conv input(X,W) should be float tensor");if(3===e.length&&"float32"!==e[2].type)throw new Error("Conv input(bias) should be float tensor")}})),wm,_m,Om,lf,Im,Sm,Am,Pm,Em,Dm,ff,Lm,cf=L((()=>{Ge(),xe(),ae(),yr(),wm=(e,t,n,r,o,i)=>(e-1)*t+n+(r-1)*o+1-i,_m=(e,t,n,r,o)=>{let i=Math.floor(e/2);"SAME_UPPER"===t?(n[r]=i,n[o]=e-i):"SAME_LOWER"===t&&(n[r]=e-i,n[o]=i)},Om=(e,t,n,r,o,i,a,s)=>{let u=e.length-2,l=0===s.length;for(let c=0;c<u;++c){let p=l?e[c+2]*i[c]:s[c],d=wm(e[c+2],i[c],o[c],t[c],n[c],p);_m(d,r,o,c,c+u),l&&s.push(i[c]*(e[c+2]-1)+a[c]+(t[c]-1)*n[c]+1-o[c]-o[c+u])}},lf=(e,t,n)=>(Lm(t,n),Im(e,t,n)),Im=(e,t,n)=>{let r=Dm(n,t);return[Em(e,t,r)]},Sm=(e,t)=>({name:"ConvTranspose",inputNames:e?["X","W","B"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:t}),Am=(e,t,n,r)=>{let o=t.length>2?"getB(output_channel)":"0.0",i=t[0].dims,a=t[1].dims,s=a[1],u=a[0]/r.group,l=[t[0].dims[0],t[1].dims[1]*r.group,...r.outputShape],c=q(e.session.backend.glContext.version),{activationFunction:p,applyActivation:d}=Ct(r),f=`\n  const ivec2 strides = ivec2(${r.strides[0]}, ${r.strides[1]});\n  const ivec2 pads = ivec2(${r.pads[0]}, ${r.pads[1]});\n  ${p}\n  void main() {\n    ivec4 coords = getOutputCoords();\n    int batch = coords.x;\n    int output_channel = coords.y;\n\n    ivec2 loc = coords.zw + pads;\n\n    int group_id = output_channel / ${s};\n    int wOutChannel = output_channel - group_id * ${s};\n\n    float value = ${o};\n    for (int inChannelOffset = 0; inChannelOffset < ${u}; inChannelOffset++) {\n      int input_channel = group_id * ${u} + inChannelOffset;\n      for (int wWOff = 0; wWOff < ${a[2]}; wWOff++) {\n        for (int wHOff = 0; wHOff < ${a[3]}; wHOff++) {\n          ivec2 wOff = ivec2(wWOff * ${r.dilations[0]}, wHOff * ${r.dilations[1]});\n          ivec2 wLoc = loc - wOff;\n          ivec2 wLocIn = wLoc / strides;\n          if (\n            wLocIn * strides == wLoc &&\n            wLocIn.x >= 0 && wLocIn.x < ${i[2]} &&\n            wLocIn.y >= 0 && wLocIn.y < ${i[3]}\n          ) {\n            float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);\n            float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);\n            value += xVal * wVal;\n          }\n        }\n      }\n    }\n    ${d}\n    ${c.output} = vec4(value, .0, .0, .0);\n  }\n`;return{...n,output:{dims:l,type:t[0].type,textureType:0},shaderSource:f,hasMain:!0}},Pm=(e,t,n)=>{let r=Sm(t.length>2,n.cacheKey);return{...r,get:()=>Am(e,t,r,n)}},Em=(e,t,n)=>e.run(Pm(e,t,n),t),Dm=(e,t)=>{let n=e.kernelShape.slice();if(0===e.kernelShape.length)for(let e=2;e<t[1].dims.length;++e)n.push(t[1].dims[e]);let r=e.pads.slice(),o=e.outputShape.slice(),i=t[0].dims;Om(i,n,e.dilations,e.autoPad,r,e.strides,e.outputPadding,o);let a=Object.assign({},e);return Object.assign(a,{kernelShape:n,pads:r,outputShape:o,cacheKey:e.cacheKey}),a},ff=e=>{let t=e.attributes,n=Rr(t),r=t.getString("auto_pad","NOTSET"),o=t.getInts("dilations",[1,1]),i=t.getInt("group",1),a=t.getInts("kernel_shape",[]),s=t.getInts("output_padding",[0,0]),u=t.getInts("output_shape",[]),l=t.getInts("pads",[0,0,0,0]),c=t.getInts("strides",[1,1]);return ee({autoPad:r,dilations:o,group:i,kernelShape:a,outputPadding:s,outputShape:u,pads:l,strides:c,...n})},Lm=(e,t)=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==e[0].dims.length||4!==e[1].dims.length)throw new Error("currently only support 2-dimensional conv");if(e[0].dims[1]!==e[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let n=e[1].dims[1]*t.group;if(3===e.length&&(1!==e[2].dims.length||e[2].dims[0]!==n))throw new Error("invalid bias");let r=e[0].dims.length-2;if(t.dilations.length!==r)throw new Error(`dilations should be ${r}D`);if(t.strides.length!==r)throw new Error(`strides should be ${r}D`);if(t.pads.length!==2*r)throw new Error(`pads should be ${2*r}D`);if(t.outputPadding.length!==r)throw new Error(`output_padding should be ${r}D`);if(0!==t.kernelShape.length&&t.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(0!==t.outputShape.length&&t.outputShape.length!==e[0].dims.length-2)throw new Error("invalid output shape");if("float32"!==e[0].type||"float32"!==e[1].type)throw new Error("ConvTranspose input(X,W) should be float tensor");if(3===e.length&&"float32"!==e[2].type)throw new Error("ConvTranspose input(bias) should be float tensor")}})),pf,Tr,df,Fm,hf,$m,Cm,km,ao=L((()=>{Ge(),fe(),ae(),pf={name:"Transpose",inputNames:["A"],inputTypes:[0]},Tr=(e,t,n)=>(km(t),[e.run({...pf,cacheHint:n.cacheKey,get:()=>Fm(e,t[0],n.perm)},t)]),df=e=>ee({perm:e.attributes.getInts("perm",[])}),Fm=(e,t,n)=>{let r=t.dims;n=hf(r,n);let o=$m(r,n),i=r.length,a=`\n      ${Cm("perm",n,i)}\n      float process(int indices[${i}]) {\n        int a[${i}];\n        perm(a, indices);\n        return _A(a);\n      }`;return{...pf,output:{dims:o,type:t.type,textureType:0},shaderSource:a}},hf=(e,t)=>(t&&t.length!==e.length&&(t=[...e.keys()].reverse()),t),$m=(e,t)=>(t=hf(e,t),U.sortBasedOnPerm(e,t)),Cm=(e,t,n)=>{let r=[];r.push(`void ${e}(out int a[${n}], int src[${n}]) {`);for(let e=0;e<n;++e)r.push(`\ta[${t[e]}]=src[${e}];`);return r.push("\t}"),r.join("\n")},km=e=>{if(!e||1!==e.length)throw new Error("Transpose requires 1 input.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("input should be float tensor")}})),mf,bf,Bm,gf=L((()=>{ao(),mf=(e,t,n)=>{Bm(t);let r=n.blocksize,o=r*r,i="DCR"===n.mode?[0,3,4,1,5,2]:[0,1,4,2,5,3],a="DCR"===n.mode?[t[0].dims[0],r,r,t[0].dims[1]/o,t[0].dims[2],t[0].dims[3]]:[t[0].dims[0],t[0].dims[1]/o,r,r,t[0].dims[2],t[0].dims[3]],s=e.reshapeUnpacked(t[0],a),u={perm:i,cacheKey:`${i}`},[l]=Tr(e,[s],u),c=[t[0].dims[0],t[0].dims[1]/o,t[0].dims[2]*r,t[0].dims[3]*r];return[e.reshapeUnpacked(l,c)]},bf=e=>{let t=e.attributes.getInt("blocksize");if(t<1)throw new Error(`blocksize must be >= 1, but got : ${t} for DepthToSpace`);let n=e.attributes.getString("mode","DCR");if("DCR"!==n&&"CRD"!==n)throw new Error(`unrecognized mode: ${n} for DepthToSpace`);return{mode:n,blocksize:t}},Bm=e=>{if(1!==e.length)throw new Error(`DepthToSpace expect 1 inputs, but got ${e.length}`);if("string"===e[0].type||4!==e[0].dims.length)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}})),yf,Tf,Nm,xf=L((()=>{fe(),yf=(e,t,n)=>{Nm(t,n);let r=U.flattenShape(t[0].dims,n);return[e.reshapeUnpacked(t[0],r)]},Tf=e=>e.attributes.getInt("axis",1),Nm=(e,t)=>{if(!e||1!==e.length)throw new Error("Flatten requires 1 input.");let n=e[0].dims.length;if(0===n)throw new Error("scalar tensor is not supported.");if(t<-n||t>n)throw new Error("Invalid axis");if("string"===e[0].type)throw new Error("string tensor is not supported.")}})),tr,pn=L((()=>{tr=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]})),vf,wf,Rm,Mm,Gm,Um,_f=L((()=>{Ge(),pn(),fe(),ae(),vf=(e,t,n)=>(Um(t,n.axis),[e.run(Gm(e,t,n),t)]),wf=e=>ee({axis:e.attributes.getInt("axis",0)}),Rm={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},Mm=(e,t,n,r)=>{let o=n[0].dims.slice(),i=n[1].dims.slice(),a=new Array(o.length+i.length-1);r=U.normalizeAxis(r,o.length);let s=[];for(let e=0;e<a.length;e++)e<r?(a[e]=o[e],s.push(`inputIdx[${e}] = outputIdx[${e}];`)):e<r+i.length?(a[e]=i[e-r],s.push(`indexDataIdx[${e-r}] = outputIdx[${e}];`)):(a[e]=o[e-i.length+1],s.push(`inputIdx[${e-i.length+1}] = outputIdx[${e}];`));let u=`\n      float process(int outputIdx[${a.length||1}]) {\n        int inputIdx[${o.length}];\n        int indexDataIdx[${i.length||1}];\n        indexDataIdx[0] = 0;\n        ${s.join("\n        ")}\n        int idx = int(_B(indexDataIdx));\n        inputIdx[${r}] = idx < 0 ? idx + ${o[r]} : idx;\n        return _A(inputIdx);\n      }`;return{...t,output:{dims:a,type:n[0].type,textureType:0},shaderSource:u}},Gm=(e,t,n)=>{let r={...Rm,cacheHint:n.cacheKey};return{...r,get:()=>Mm(e,r,t,n.axis)}},Um=(e,t)=>{if(!e||2!==e.length)throw new Error("Gather requires 2 inputs.");let n=e[0].dims.length;if(n<1)throw new Error("Invalid input shape.");if(t<-n||t>n-1)throw new Error("Invalid axis.");if(-1===tr.indexOf(e[0].type))throw new Error("Invaid input type.");if("int32"!==e[1].type&&"int16"!==e[1].type)throw new Error("Invaid input type.")}})),Bi,Of,If,Sf,zm,Vm,Wm,Af=L((()=>{Ge(),fe(),ae(),Bi=(e,t,n)=>(Wm(t,n),[e.run(zm(t,n),t)]),Of=(e,t)=>{let n=0!==e.attributes.getInt("transA",0),r=0!==e.attributes.getInt("transB",0),o=e.attributes.getFloat("alpha",1),i=e.attributes.getFloat("beta",1);return ee({transA:n,transB:r,alpha:o,beta:i,isOptionalC:t})},If=e=>Of(e,!1),Sf=e=>Of(e,!0),zm=(e,t)=>{let n={name:"Gemm",inputNames:3===e.length?["A","B","C"]:["A","B"],inputTypes:3===e.length?[0,0,0]:[0,0],key:t.cacheKey};return{...n,get:()=>Vm(n,e,t)}},Vm=(e,t,n)=>{let r=t[0].dims.slice(),o=t[1].dims.slice(),[i,a]=Xn.getShapeOfGemmResult(r,n.transA,o,n.transB,3===t.length?t[2].dims:void 0),s=[i,a];if(!s)throw new Error("Can't use gemm on the given tensors");let u=r[r.length-1],l="";n.transA&&(u=r[0]),n.transA&&n.transB?l="value += _A_T(a) * _B_T(b);":n.transA&&!n.transB?l="value += _A_T(a) * _B(b);":!n.transA&&n.transB?l="value += _A(a) * _B_T(b);":!n.transA&&!n.transB&&(l="value += _A(a) * _B(b);");let c=s.length,p=`\n      float process(int indices[${c}]) {\n          int a[${c}];\n          int b[${c}];\n          ${3===t.length?`int c[${t[2].dims.length}];`:""}\n\n          copyVec(indices, a);\n          copyVec(indices, b);\n          ${3===t.length?"bcastIndices_C(indices, c);":""}\n\n          float value = 0.0;\n          for (int k=0; k<${u}; ++k) {\n              a[${c-1}] = k;\n              b[${c-2}] = k;\n              ${l}\n          }\n\n          value = value * alpha;\n          ${3===t.length?"value += beta * _C(c);":""}\n          return value;\n      }`;return{...e,output:{dims:s,type:t[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:n.alpha},{name:"beta",type:"float",data:n.beta}],shaderSource:p}},Wm=(e,t)=>{if(!e)throw new Error("Input is missing");if(t.isOptionalC&&(e.length<2||e.length>3))throw new Error("Invaid input shape.");if(!t.isOptionalC&&3!==e.length)throw new Error("Gemm requires 3 inputs");if(3===e.length&&1!==e[2].dims.length&&2!==e[2].dims.length)throw new Error("Invalid input shape of C");if("float32"!==e[0].type&&"float64"!==e[0].type||"float32"!==e[1].type&&"float64"!==e[1].type||3===e.length&&"float32"!==e[2].type&&"float64"!==e[2].type)throw new Error("Invalid input type.");if(e[0].type!==e[1].type||3===e.length&&e[0].type!==e[2].type)throw new Error("Input types are mismatched")}})),Pf,Ef,Hm,qm,jm,Ym,Xm,Df=L((()=>{Ge(),ae(),Pf=(e,t,n)=>(Xm(t),[e.run(jm(e,t,n),t)]),Ef=e=>{let t=e.attributes.getFloat("scale"),n=e.attributes.getFloats("bias");return ee({scale:t,bias:n})},Hm={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},qm=(e,t,n,r)=>{let o=n[0].dims.slice(),i=o.length,a=`\n      ${Ym(r.bias.length)}\n      float process(int indices[${i}]) {\n        return _X(indices) * scale + getBias(bias, indices[1]);\n      }`;return{...t,output:{dims:o,type:n[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:r.bias.length,data:r.bias},{name:"scale",type:"float",data:r.scale}],shaderSource:a}},jm=(e,t,n)=>{let r={...Hm,cacheHint:n.cacheKey};return{...r,get:()=>qm(e,r,t,n)}},Ym=e=>{let t=[`float getBias(float bias[${e}], int channel) {`];for(let n=0;n<e;++n)0===n?t.push(`\tif (channel == ${n}) { return bias[${n}]; }`):n===e-1?t.push(`\telse { return bias[${n}]; }`):t.push(`\telse if (channel == ${n}) { return bias[${n}]; }`);return t.push("\t}"),t.join("\n")},Xm=e=>{if(!e||1!==e.length)throw new Error("ImageScaler requires 1 input.");if(4!==e[0].dims.length)throw new Error("Invalid input shape.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.")}})),Ff,$f,Lf,Km,Jm,Zm,Qm,eb,tb,Cf=L((()=>{xe(),ae(),Ff=(e,t,n)=>{tb(t);let r=e.run(Jm(t[0]),t);return[e.run(eb(e,t[0],n,r.dims),[t[0],r,t[1],t[2]])]},$f=e=>e.attributes.getFloat("epsilon",1e-5),Lf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},Km=(e,t)=>{let n=t.dims.slice(),r=n[1],o=n[2]*n[3],i=[n[0],r],a=`\n      vec4 process(int[2] indices) {\n        vec4 v = vec4(0.0);\n        int a[4];\n        a[0] = indices[0];\n        a[1] = indices[1];\n        float temp = 0.0;\n        for(int a2=0; a2<${n[2]}; a2++) {\n          a[2] = a2;\n          for(int a3=0; a3<${n[3]}; a3++) {\n            a[3] = a3;\n            float x = _X(a);\n            temp += x;\n          }\n        }\n        float mean = temp / float(${o});\n        temp = 0.0;\n        for(int a2=0; a2<${n[2]}; a2++) {\n          a[2] = a2;\n          for(int a3=0; a3<${n[3]}; a3++) {\n            a[3] = a3;\n            float x = _X(a);\n            temp += (x - mean) * (x - mean);\n          }\n        }\n        v.r = mean;\n        v.g = temp / float(${o});\n\n        return v;\n      }`;return{...e,output:{dims:i,type:t.type,textureType:4},shaderSource:a}},Jm=e=>({...Lf,get:()=>Km(Lf,e)}),Zm={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},Qm=(e,t,n,r,o)=>{let i=q(e.session.backend.glContext.version),[a,s]=e.calculateTextureWidthAndHeight(o,4),[u,l]=[a/4,s],c=`\n      vec4 get_MeanAndVariance(int[2] mv) {\n        int offset = indicesToOffset_MeanAndVariance(mv);\n        vec2 coords = offsetToCoords(offset, ${u}, ${l});\n        return ${i.texture2D}(MeanAndVariance, coords);\n      }\n\n      float process(int[4] indices) {\n        int mv[2];\n        mv[0] = indices[0];\n        mv[1] = indices[1];\n        vec4 mean_and_variance = get_MeanAndVariance(mv);\n        float mean = mean_and_variance.r;\n        float variance = mean_and_variance.g;\n\n        int sb[1];\n        sb[0] = indices[1];\n        float scale = _Scale(sb);\n        float b = _B(sb);\n\n        return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;\n      }`;return{...t,output:{dims:n.dims,type:n.type,textureType:0},variables:[{name:"epsilon",type:"float",data:r}],shaderSource:c}},eb=(e,t,n,r)=>{let o={...Zm,cacheHint:`${n}`};return{...o,get:()=>Qm(e,o,t,n,r)}},tb=e=>{if(!e||3!==e.length)throw new Error("InstanceNormalization requires 3 inputs.");let t=e[0],n=e[1],r=e[2];if(t.dims.length<3||1!==n.dims.length||1!==r.dims.length)throw new Error("Invalid input shape.");if(n.dims[0]!==t.dims[1]||r.dims[0]!==t.dims[1])throw new Error("Input shapes are mismatched.");if("float32"!==t.type&&"float64"!==t.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type)throw new Error("Invalid input type.");if(4!==e[0].dims.length)throw new Error("Only support 4-D input shape.")}}));function rb(e,t){let n=e[0].dims[1],r=e[0].dims.length,o=-Math.floor((t.size-1)/2),i=Math.ceil((t.size-1)/2),a=`float(${t.alpha}) / float(${t.size})`,s=`\n    float process(int indices[${r}]) {\n        int c = indices[1];\n        float x = _X(indices);\n        float square_sum = 0.0;\n\n        for (int i = ${o}; i <= ${i}; i++) {\n          int idx = c + i;\n          if (c >= 0 && c < ${n}) {\n            indices[1] = idx;\n            float j = _X(indices);\n            square_sum += j * j;\n          }\n        }\n        return x / pow(${`float(${t.bias})`} + ${a} * square_sum, ${`float(${t.beta})`});\n    }`;return{...Nf,cacheHint:t.cacheKey,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:s}}function nb(e,t){return{...Nf,cacheHint:t.cacheKey,get:()=>rb(e,t)}}var kf,Bf,Nf,ob,Rf=L((()=>{Ge(),ae(),kf=(e,t,n)=>(ob(t),[e.run(nb(t,n),t)]),Bf=e=>{let t=e.attributes.getFloat("alpha",1e-4),n=e.attributes.getFloat("beta",.75),r=e.attributes.getFloat("bias",1),o=e.attributes.getInt("size");return ee({alpha:t,beta:n,bias:r,size:o})},Nf={name:"LRN",inputNames:["X"],inputTypes:[0]},ob=e=>{if(!e||1!==e.length)throw new Error("LRN requires 1 input.");if(4!==e[0].dims.length)throw new Error('currently only support LRN for input with "NCHW" format');if("float32"!==e[0].type)throw new Error("input should be float type")}})),ib,Ni,Mf,Gf,Uf,ab,sb,ub,lb,fb,cb,pb,db,zf=L((()=>{Ge(),fe(),xe(),ae(),ib={name:"Pad",inputNames:["A"],inputTypes:[0]},Ni=(e,t,n)=>(ub(t),[e.run({...ib,cacheHint:n.cacheKey,get:()=>sb(e,t[0],n)},t)]),Mf=e=>{let t=e.attributes.getString("mode","constant"),n=e.attributes.getFloat("value",0),r=e.attributes.getInts("pads");return ee({mode:t,value:n,pads:r})},Gf=(e,t,n)=>{lb(t);let r=ab(e,t,n);return Ni(e,[t[0]],r)},Uf=e=>e.attributes.getString("mode","constant"),ab=(e,t,n)=>{if(!e.session.isInitializer(t[1].dataId)||t.length>=3&&!e.session.isInitializer(t[2].dataId))throw new Error("dynamic pad attributes are not allowed");let r=Array.from(t[1].integerData),o=t.length>=3?t[2].floatData[0]:0;return ee({mode:n,pads:r,value:o})},sb=(e,t,n)=>{let r=U.padShape(t.dims.slice(),n.pads),o=r.length,i=`\n      ${fb(e,t,n)}\n      float process(int[${o}] indices) {\n          return padA(indices);\n      }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:r,type:t.type,textureType:0},shaderSource:i}},ub=e=>{if(!e||1!==e.length)throw new Error("Pad requires 1 input");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.")},lb=e=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Pad requires 2 or 3 inputs");if("int32"!==e[1].type)throw new Error("Invalid input type.");if(e.length>=3&&"string"===e[2].type)throw new Error("Invalid input type.")},fb=(e,t,n)=>{let r=q(e.session.backend.glContext.version),[o,i]=e.calculateTextureWidthAndHeight(t.dims,0),a=U.computeStrides(t.dims);switch(n.mode){case"constant":return cb(r,t.dims,a,o,i,n.pads,n.value);case"reflect":return pb(r,t.dims,a,o,i,n.pads);case"edge":return db(r,t.dims,a,o,i,n.pads);default:throw new Error("Invalid mode")}},cb=(e,t,n,r,o,i,a)=>{let s=t.length,u="";for(let e=s-1;e>=0;--e)u+=`\n        k = m[${e}] - ${i[e]};\n        if (k < 0)  return constant;\n        if (k >= ${t[e]}) return constant;\n        offset += k * ${n[e]};\n        `;return`\n      float padA(int m[${s}]) {\n        const float constant = float(${a});\n        int offset = 0;\n        int k = 0;\n        ${u}\n        vec2 coords = offsetToCoords(offset, ${r}, ${o});\n        float value = getColorAsFloat(${e.texture2D}(A, coords));\n        return value;\n      }\n      `},pb=(e,t,n,r,o,i)=>{let a=t.length,s="";for(let e=a-1;e>=0;--e)s+=`\n        k = m[${e}] - ${i[e]};\n        if (k < 0) { k = -k; }\n        {\n          const int _2n_1 = ${2*(t[e]-1)};\n          k = int( mod( float(k), float(_2n_1) ) ) ;\n          if(k >= ${t[e]}) { k = _2n_1 - k; }\n        }\n        offset += k * ${n[e]};\n        `;return`\n      float padA(int m[${a}]) {\n        int offset = 0;\n        int k = 0;\n        ${s}\n        vec2 coords = offsetToCoords(offset, ${r}, ${o});\n        float value = getColorAsFloat(${e.texture2D}(A, coords));\n        return value;\n      }\n      `},db=(e,t,n,r,o,i)=>{let a=t.length,s="";for(let e=a-1;e>=0;--e)s+=`\n        k = m[${e}] - ${i[e]};\n        if (k < 0)  k = 0;\n        if (k >= ${t[e]}) k = ${t[e]-1};\n        offset += k * ${n[e]};\n      `;return`\n      float padA(int m[${a}]) {\n        int offset = 0;\n        int k = 0;\n        ${s}\n        vec2 coords = offsetToCoords(offset, ${r}, ${o});\n        float value = getColorAsFloat(${e.texture2D}(A, coords));\n        return value;\n      }\n      `}})),Wf,Hf,qf,jf,Yf,Xf,Kf,Jf,Zf,hb,Vf,Qf,uo,ec,so,mb,tc=L((()=>{Ge(),fe(),ae(),Wf=(e,t,n)=>{uo(t);let r={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[e.run({...r,get:()=>qf(t,r,!1,n)},t)]},Hf=e=>{let t=e.attributes.getString("auto_pad","NOTSET"),n=e.attributes.getInt("ceil_mode",0),r=0!==e.attributes.getInt("count_include_pad",0),o=e.attributes.getInts("kernel_shape"),i=e.attributes.getInts("strides",[]),a=e.attributes.getInts("pads",[]);if(0!==n)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return ee({autoPad:t,ceilMode:n,countIncludePad:r,kernelShape:o,strides:i,pads:a})},qf=(e,t,n,r)=>{let[o,i]=Zf(e,r,n),a=U.size(o.kernelShape),s="";o.countIncludePad?s+=`value /= float(${a});`:s+=`value /= float(${a} - pad);`;let u=`\n        ${ec(e[0].dims,o,"value += _X(x);",s,"0.0")}\n      `;return{...t,output:{dims:i,type:e[0].type,textureType:0},shaderSource:u}},jf=(e,t,n)=>{uo(t);let r={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${n.countIncludePad}`};return[e.run({...r,get:()=>qf(t,r,!0,n)},t)]},Yf=e=>{let t=0!==e.attributes.getInt("count_include_pad",0);return ee({autoPad:"",ceilMode:0,countIncludePad:t,kernelShape:[],strides:[],pads:[]})},Xf=(e,t,n)=>{uo(t);let r={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[e.run({...r,get:()=>Jf(t,r,!1,n)},t)]},Kf=e=>{let t=e.attributes.getString("auto_pad","NOTSET"),n=e.attributes.getInt("ceil_mode",0),r=e.attributes.getInts("kernel_shape"),o=e.attributes.getInts("strides",[]),i=e.attributes.getInts("pads",[]),a=e.attributes.getInt("storage_order",0),s=e.attributes.getInts("dilations",[]);if(0!==a)throw new Error("column major storage order is not yet supported for MaxPool");if(0!==n)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return ee({autoPad:t,ceilMode:n,countIncludePad:!1,kernelShape:r,strides:o,pads:i,storageOrder:a,dilations:s})},Jf=(e,t,n,r)=>{let[o,i]=Zf(e,r,n),a=`\n      ${ec(e[0].dims,o,"\n      value = max(_X(x), value);\n    ","","-1e5")}\n    `;return{...t,output:{dims:i,type:e[0].type,textureType:0},shaderSource:a}},Zf=(e,t,n)=>{let r=e[0].dims.slice(),o=Object.hasOwnProperty.call(t,"dilations"),i=t.kernelShape.slice(),a=t.strides.slice(),s=o?t.dilations.slice():[],u=t.pads.slice();dr.adjustPoolAttributes(n,r,i,a,s,u);let l=dr.computePoolOutputShape(n,r,a,s,i,u,t.autoPad),c=Object.assign({},t);return o?Object.assign(c,{kernelShape:i,strides:a,pads:u,dilations:s,cacheKey:t.cacheKey}):Object.assign(c,{kernelShape:i,strides:a,pads:u,cacheKey:t.cacheKey}),[c,l]},hb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Vf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},Qf=(e,t)=>(uo(t),[e.run({...Vf,get:()=>Jf(t,Vf,!0,hb)},t)]),uo=e=>{if(!e||1!==e.length)throw new Error("Pool ops requires 1 input.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.")},ec=(e,t,n,r,o)=>{let i=e.length;if(t.kernelShape.length<=2){let a=t.kernelShape[t.kernelShape.length-1],s=t.strides[t.strides.length-1],u=t.pads[t.pads.length/2-1],l=t.pads[t.pads.length-1],c=e[i-1],p="",d="",f="";if(p=u+l!==0?`\n          for (int i = 0; i < ${a}; i++) {\n            x[${i} - 1] = indices[${i} - 1] * ${s} - ${u} + i;\n            if (x[${i} - 1] < 0 || x[${i} - 1] >= ${c}) {\n              pad++;\n              continue;\n            }\n            ${n}\n          }`:`\n          for (int i = 0; i < ${a}; i++) {\n            x[${i} - 1] = indices[${i} - 1] * ${s} - ${u} + i;\n            ${n}\n          }`,2===t.kernelShape.length){let n=t.kernelShape[t.kernelShape.length-2],r=t.strides[t.strides.length-2],o=t.pads[t.pads.length/2-2],s=t.pads[t.pads.length-2],u=e[i-2];d=o+s!==0?`\n            for (int j = 0; j < ${n}; j++) {\n              x[${i} - 2] = indices[${i} - 2] * ${r} - ${o} + j;\n              if (x[${i} - 2] < 0 || x[${i} - 2] >= ${u}) {\n                pad+= ${a};\n                continue;\n              }\n          `:`\n            for (int j = 0; j < ${n}; j++) {\n              x[${i} - 2] = indices[${i} - 2] * ${r} - ${o} + j;\n            `,f="\n          }\n        "}return`\n        float process(int indices[${i}]) {\n          int x[${i}];\n          copyVec(indices, x);\n\n          float value = ${o};\n          int pad = 0;\n          ${d}\n          ${p}\n          ${f}\n          ${r}\n          return value;\n        }\n      `}{let a=U.size(t.kernelShape),s=U.computeStrides(t.kernelShape),u=s.length,l=t.pads.length,c=mb(u),p=so(e,"inputDims"),d=so(t.pads,"pads"),f=so(s,"kernelStrides"),h=so(t.strides,"strides"),g="";return g=t.pads.reduce(((e,t)=>e+t))?`\n            if (x[j] >= inputDims[j] || x[j] < 0) {\n              pad++;\n              isPad = true;\n              break;\n            }\n          }\n          if (!isPad) {\n            ${n}\n          }`:`\n          }\n          ${n}\n        `,`\n        ${c}\n        float process(int indices[${i}]) {\n          int x[${i}];\n          copyVec(indices, x);\n          int offset[${u}];\n          int pads[${l}];\n          int inputDims[${i}];\n          int kernelStrides[${u}];\n          int strides[${u}];\n          ${d}\n          ${p}\n          ${h}\n          ${f}\n\n          float value = ${o};\n          int pad = 0;\n          bool isPad = false;\n          for (int i = 0; i < ${a}; i++) {\n            offsetToIndices(i, kernelStrides, offset);\n            isPad = false;\n            for (int j = ${i} - ${u}; j < ${i}; j++) {\n              x[j] = indices[j] * strides[j - ${i} + ${u}]\n                + offset[j - ${i} + ${u}] - pads[j - 2];\n              ${g}\n          }\n          ${r}\n\n          return value;\n        }\n      `}},so=(e,t)=>{let n="";for(let r=0;r<e.length;r++)n+=`\n      ${t}[${r}] = ${e[r]};\n    `;return n},mb=e=>`\n  void offsetToIndices(int offset, int[${e}] strides, out int[${e}] indices) {\n    if (${e} == 0) {\n      return;\n    }\n    for (int i = 0; i < ${e} - 1; ++i) {\n      indices[i] = offset / strides[i];\n      offset -= indices[i] * strides[i];\n    }\n    indices[${e} - 1] = offset;\n  }`})),xr,rr,bb,gb,rc,nc,oc,ic,ac,sc,uc,lc=L((()=>{Ge(),pn(),fe(),ae(),xr=(e,t,n,r,o)=>{gb(t);let i={name:r,inputNames:["A"],inputTypes:[0]};return[e.run({...i,cacheHint:n.cacheKey,get:()=>bb(e,t,n,r,o,i)},t)]},rr=e=>{let t=e.attributes.getInts("axes",[]),n=1===e.attributes.getInt("keepdims",1);return ee({axes:t,keepDims:n})},bb=(e,t,n,r,o,i)=>{let a=[],s=t[0].dims.length||1,u=[],l=U.normalizeAxes(n.axes,t[0].dims.length),c=o(t,l),p=c[1];for(let e=0;e<t[0].dims.length;e++)l.indexOf(e)>=0||0===l.length?(n.keepDims&&a.push(1),p=`\n          for(int j${e} = 0; j${e} < ${t[0].dims[e]}; j${e}++) {\n            inputIdx[${e}] = j${e};\n            ${p}\n          }`):(u.push(`inputIdx[${e}] = outputIdx[${a.length}];`),a.push(t[0].dims[e]));let d=`\n      float process(int outputIdx[${a.length||1}]) {\n        float value;                 // final result\n        int inputIdx[${s}];      // addressing input data\n        ${u.join("\n")}\n        ${c[0]}       // init ops for reduce max/min\n        ${p}\n        ${c[2]}       // final computation for reduce mean\n        return value;\n      }`;return{...i,output:{dims:a,type:t[0].type,textureType:0},shaderSource:d}},gb=e=>{if(!e||1!==e.length)throw new Error("Reduce op requires 1 input.");if(-1===tr.indexOf(e[0].type))throw new Error("Invalid input type.")},rc=(e,t,n)=>xr(e,t,n,"ReduceSum",(()=>["value = 0.0;","value += _A(inputIdx);",""])),nc=(e,t,n)=>xr(e,t,n,"ReduceMean",((e,t)=>{let n=1;for(let r=0;r<e[0].dims.length;r++)(t.indexOf(r)>=0||0===t.length)&&(n*=e[0].dims[r]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${n}.;`]})),oc=(e,t,n)=>xr(e,t,n,"ReduceMax",((e,t)=>{let n=[];for(let r=0;r<e[0].dims.length;r++)(t.indexOf(r)>=0||0===t.length)&&n.push(`inputIdx[${r}] = 0;`);return[`${n.join("\n")}\nvalue = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]})),ic=(e,t,n)=>xr(e,t,n,"ReduceMin",((e,t)=>{let n=[];for(let r=0;r<e[0].dims.length;r++)(t.indexOf(r)>=0||0===t.length)&&n.push(`inputIdx[${r}] = 0;`);return[`${n.join("\n")}\nvalue = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]})),ac=(e,t,n)=>xr(e,t,n,"ReduceProd",(()=>["value = 1.0;","value *= _A(inputIdx);",""])),sc=(e,t,n)=>xr(e,t,n,"ReduceLogSum",(()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"])),uc=(e,t,n)=>xr(e,t,n,"ReduceLogSumSquare",(()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""]))})),fc,cc=L((()=>{fe(),fc=(e,t)=>{let n=U.calculateReshapedDims(t[0].dims,t[1].integerData);return e.session.pack?[e.reshapePacked(t[0],n)]:[e.reshapeUnpacked(t[0],n)]}})),pc,Ri,dc,hc,dn,yb,Mi,lo,Gi=L((()=>{Ge(),xe(),ae(),pc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Ri=(e,t,n)=>(Mi(t,n),[e.run({...pc,cacheHint:n.cacheKey,get:()=>yb(e,t,n)},t)]),dc=e=>dn(e,7),hc=e=>dn(e,9),dn=(e,t)=>{let n=t>=10,r=e.attributes.getString("mode","nearest");if("nearest"!==r&&"linear"!==r&&(t<11||"cubic"!==r))throw new Error(`unrecognized mode: ${r}`);let o=[];t<9&&(o=e.attributes.getFloats("scales"),lo(o,r,n));let i=e.attributes.getFloat("extrapolation_value",0),a=t>10?e.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(-1===["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(a))throw new Error(`coordinate_transform_mode '${a}' is not supported`);let s="tf_crop_and_resize"===a,u=s,l="nearest"===r&&t>=11?e.attributes.getString("nearest_mode","round_prefer_floor"):"";if(-1===["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(l))throw new Error(`nearest_mode '${l}' is not supported`);let c=e.attributes.getFloat("cubic_coeff_a",-.75),p=0!==e.attributes.getInt("exclude_outside",0);if(p&&"cubic"!==r)throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let d=t<11||"nearest"===r&&"asymmetric"===a&&"floor"===l,f=0,h=0,g=0;return t>10?e.inputs.length>2?(f=1,h=2,g=3):(h=1,g=2):9===t&&(h=1),ee({opset:t,isResize:n,mode:r,scales:o,extrapolationValue:i,coordinateTransformMode:a,useExtrapolation:u,needRoiInput:s,nearestMode:l,cubicCoefficientA:c,excludeOutside:p,useNearest2xOptimization:d,roiInputIdx:f,scalesInputIdx:h,sizesInputIdx:g})},yb=(e,t,n)=>{let r=q(e.session.backend.glContext.version),[o,i]=e.calculateTextureWidthAndHeight(t[0].dims,0),a=t[0].dims.map(((e,t)=>Math.floor(e*n.scales[t]))),[s,u]=e.calculateTextureWidthAndHeight(a,0),l=a.length,c=new Array(l),p=new Array(l),d=`\n      int output_pitches[${l}];\n      int input_pitches[${l}];\n      `;for(let e=l-1;e>=0;e--)c[e]=e===l-1?1:c[e+1]*a[e+1],p[e]=e===l-1?1:p[e+1]*t[0].dims[e+1],d+=`\n        output_pitches[${e}] = ${c[e]};\n        input_pitches[${e}] = ${p[e]};\n        `;let f=`\n      float getInputFloat(int index) {\n        vec2 coords = offsetToCoords(index, ${o}, ${i});\n        float value = getColorAsFloat(${r.texture2D}(X, coords));\n        return value;\n      }\n      `,h="nearest"===n.mode?`\n    ${f}\n    float process(int indices[${l}]) {\n      int input_index = 0;\n      int output_index = coordsToOffset(TexCoords, ${s}, ${u});\n\n      ${d}\n\n      int d, m;\n      for (int dim = 0; dim < ${l}; ++dim) {\n        d = output_index / output_pitches[dim];\n        m = output_index - d * output_pitches[dim];\n        output_index = m;\n\n        if (scales[dim] != 1 && d > 0) {\n          int d2 = d / scales[dim];\n          m = d - d2 * scales[dim];\n          d = d2;\n        }\n        input_index += input_pitches[dim] * d;\n      }\n\n      return getInputFloat(input_index);\n    }`:4===l?`\n    ${f}\n    float process(int indices[4]) {\n      int input_index = 0;\n      int output_index = coordsToOffset(TexCoords, ${s}, ${u});\n\n      ${d}\n\n      int m;\n      int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;\n      index_of_dim0 = output_index / output_pitches[0];\n      m = output_index - index_of_dim0 * output_pitches[0];\n      index_of_dim1 = m / output_pitches[1];\n      m = m - index_of_dim1 * output_pitches[1];\n      index_of_dim2 = m / output_pitches[2];\n      m = m - index_of_dim2 * output_pitches[2];\n      index_of_dim3 = m;\n\n      int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;\n      index_of_input_dim2 = index_of_dim2 / scales[2];\n      y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];\n      index_of_input_dim3 = index_of_dim3 / scales[3];\n      x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];\n\n      input_index = index_of_dim0 * input_pitches[0] +\n            index_of_dim1 * input_pitches[1] +\n            index_of_input_dim2 * input_pitches[2] +\n            index_of_input_dim3;\n\n      float x00 = getInputFloat(input_index);\n      float x10, x01, x11;\n\n      bool end_of_dim2 = false;\n      if (index_of_input_dim2 == (${t[0].dims[2]} - 1)) {\n        // It's the end in dimension 2\n        x01 = x00;\n        end_of_dim2 = true;\n      } else {\n        x01 = getInputFloat(input_index + input_pitches[2]);\n      }\n\n      if (index_of_input_dim3 == (input_pitches[2] - 1)) {\n        // It's the end in dimension 3\n        x10 = x00;\n        x11 = x01;\n      }\n      else {\n        x10 = getInputFloat(input_index + 1);\n        x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);\n      }\n\n      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);\n      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);\n      return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);\n    }`:`\n    ${f}\n    float process(int indices[2]) {\n      int input_index = 0;\n      int output_index = coordsToOffset(TexCoords, ${s}, ${u});\n\n      ${d}\n\n      int m;\n      int index_of_dim0, index_of_dim1;\n      index_of_dim0 = output_index / output_pitches[0];\n      m = output_index - index_of_dim0 * output_pitches[0];\n      index_of_dim1 = m;\n\n      int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;\n      index_of_input_dim0 = index_of_dim0 / scales[0];\n      y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];\n      index_of_input_dim1 = index_of_dim1 / scales[1];\n      x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];\n\n      input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;\n\n      float x00 = getInputFloat(input_index);\n      float x10, x01, x11;\n\n      bool end_of_dim0 = false;\n      if (index_of_input_dim0 == (${t[0].dims[0]} - 1)) {\n        // It's the end in dimension 0\n        x01 = x00;\n        end_of_dim0 = true;\n      } else {\n        x01 = getInputFloat(input_index + input_pitches[0]);\n      }\n\n      if (index_of_input_dim1 == (input_pitches[0] - 1)) {\n        // It's the end in dimension 1\n        x10 = x00;\n        x11 = x01;\n      }\n      else {\n        x10 = getInputFloat(input_index + 1);\n        x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);\n      }\n\n      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);\n      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);\n      return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);\n    }`;return{...pc,output:{dims:a,type:t[0].type,textureType:0},shaderSource:h,variables:[{name:"scales",type:"int",arrayLength:n.scales.length,data:n.scales.map((e=>Math.ceil(e)))}]}},Mi=(e,t)=>{if(!e||t.opset<9&&1!==e.length||t.opset>=9&&t.opset<11&&2!==e.length||t.opset>=11&&e.length<2)throw new Error("invalid inputs.");if(t.scales.length>0&&e[0].dims.length!==t.scales.length)throw new Error("Invalid input shape.");if("string"===e[0].type)throw new Error("Invalid input tensor types.")},lo=(e,t,n)=>{if(n){for(let t of e)if(t<=0)throw new Error("Scale value should be greater than 0.")}else for(let t of e)if(t<1)throw new Error("Scale value should be greater than or equal to 1.");if(!("linear"!==t&&"cubic"!==t||2===e.length||4===e.length&&1===e[0]&&1===e[1]))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic')         or 4-D inputs with the corresponding outermost 2 scale values being 1         in the ${n?"Resize":"Upsample"} opeartor.`)}})),Ui,zi,mc,bc,Tb,xb,vb,wb,gc=L((()=>{xe(),ae(),Ft(),gr(),Gi(),Ui={name:"Resize",inputNames:["A"],inputTypes:[2]},zi=(e,t,n)=>(Mi(t,n),[e.run({...Ui,cacheHint:n.cacheKey,get:()=>Tb(e,t,n)},t)]),mc=e=>dn(e,10),bc=e=>dn(e,11),Tb=(e,t,n)=>{let r=q(e.session.backend.glContext.version),[o,i]=xb(t,n);if(o.every((e=>1===e))&&"tf_crop_and_resize"!==n.coordinateTransformMode)return{...Ui,output:{dims:i,type:t[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {\n                    vec4 v = ${r.texture2D}(X, TexCoords);\n                    ${r.output} = v;\n                }`};let a=i.length;if(a<2)throw new Error(`output dimension should be at least 2, but got ${a}`);let s=i[a-2],u=i[a-1],l=t[0].dims;if(a!==l.length)throw new Error(`output dimension should match input ${l.length}, but got ${a}`);let c=l[a-2],p=l[a-1],d=o[a-2],f=o[a-1],h="";if("linear"!==n.mode)throw new Error(`resize (packed) does not support mode: '${n.mode}'`);switch(n.coordinateTransformMode){case"asymmetric":h="\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        return vec4(coords) / scaleWHWH;\n                    }\n                ";break;case"half_pixel":h="\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;\n                    }\n                ";break;case"pytorch_half_pixel":h=`\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        vec4 fcoords = vec4(coords);\n                        return vec4(\n                            ${u}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,\n                            ${s}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,\n                            ${u}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,\n                            ${s}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0\n                          );\n                    }\n                `;break;case"align_corners":h=`\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        vec4 resized = vec4(${u}.0 - 1.0, ${s}.0 - 1.0, ${u}.0 - 1.0,\n                            ${s}.0 - 1.0);\n                        vec4 original = vec4(${p}.0 - 1.0, ${c}.0 - 1.0, ${p}.0 - 1.0,\n                            ${c}.0 - 1.0);\n                        vec4 new_scale = original / resized;\n                        return vec4(coords) * new_scale;\n                    }\n                `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode:                                 '${n.coordinateTransformMode}'`)}let g=Ke(a),m=`\n            const vec2 inputWH = vec2(${c}.0, ${p}.0);\n            const vec4 scaleWHWH = vec4(float(${d}), float(${f}), float(${d}), float(${f}));\n            ${$t()}\n            ${h}\n            float getAValue(int x10, int r, int c, int d) {\n                return getChannel(getA(x10, r, c, d), vec2(c, d));\n            }\n            void main() {\n                ${g} rc = getOutputCoords();\n\n                int batch = rc[0];\n                int depth = rc[1];\n\n                // retrieve the 4 coordinates that is used in the 4 packed output values.\n                ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);\n\n                // calculate the source index in fraction\n                vec4 sourceFrac = getSourceFracIndex(coords);\n\n                // get the lower and upper bound of the 4 values that will be packed into one texel.\n                ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));\n                ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));\n                ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));\n                ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));\n\n                bool hasNextRow = rc.w < ${s-1};\n                bool hasNextCol = rc.z < ${u-1};\n\n                // pack x00, x01, x10, x11's top-left corner into one vec4 structure\n                vec4 topLeft = vec4(\n                    getAValue(batch, depth, x00.x, x00.y),\n                    hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);\n\n                // pack x00, x01, x10, x11's top-right corner into one vec4 structure\n                vec4 topRight = vec4(\n                    getAValue(batch, depth, x00.x, x00.w),\n                    hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);\n\n                // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure\n                vec4 bottomLeft = vec4(\n                    getAValue(batch, depth, x00.z, x00.y),\n                    hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);\n\n                // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure\n                vec4 bottomRight = vec4(\n                    getAValue(batch, depth, x00.z, x00.w),\n                    hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);\n\n                // calculate the interpolation fraction on u and v direction\n                vec4 frac = vec4(sourceFrac) - floor(sourceFrac);\n                vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));\n\n                vec4 top = mix(topLeft, topRight, clampFrac.ywyw);\n                vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);\n                vec4 newValue = mix(top, bottom, clampFrac.xxzz);\n\n                ${r.output} = vec4(newValue);\n            }\n        `;return{...Ui,output:{dims:i,type:t[0].type,textureType:2},hasMain:!0,shaderSource:m}},xb=(e,t)=>{let n,r=e[0].dims,o=t.scales;if(0===o.length){let i=e[t.scalesInputIdx];if(i&&0!==i.size){if(e[t.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");o=vb(i,t.mode,t.isResize)}else{let i=e[t.sizesInputIdx];if(!i||0===i.size)throw new Error("Either scales or sizes MUST be provided as input.");n=Array.from(i.integerData),o=wb(n,r,t.mode,t.isResize)}}else if(e[t.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let i=n||r.map(((e,t)=>Math.floor(e*o[t])));return[o,i]},vb=(e,t,n)=>{let r=Array.from(e.floatData);return lo(r,t,n),r},wb=(e,t,n,r)=>{let o=t.length,i=new Array(o);for(let n=0,r=o;n<r;n++)if(0===t[n]){if(0!==e[n])throw new Error("Input dim is zero but required output dim is non-zero.");i[n]=1}else i[n]=e[n]/t[n];return lo(i,n,r),i}})),yc,_b,Tc=L((()=>{br(),yc=(e,t)=>(_b(t),[new Fe([t[0].dims.length],"int32",void 0,void 0,new Int32Array(t[0].dims))]),_b=e=>{if(!e||1!==e.length)throw new Error("Shape requires 1 input.")}})),Vi,xc,vc,wc,Ob,_c,Ib,Sb,Oc=L((()=>{Ge(),pn(),fe(),ae(),Vi={name:"Slice",inputNames:["A"],inputTypes:[0]},xc=(e,t,n)=>(Ob(t),[e.run({...Vi,cacheHint:n.cacheKey,get:()=>wc(e,t[0],n)},t)]),vc=e=>{let t=e.attributes.getInts("starts"),n=e.attributes.getInts("ends"),r=e.attributes.getInts("axes",[]);return ee({starts:t,ends:n,axes:r})},wc=(e,t,n)=>{let r=0===n.axes.length?t.dims.slice(0).map(((e,t)=>t)):n.axes,o=U.normalizeAxes(r,t.dims.length),i=n.starts.map(((e,n)=>e>t.dims[o[n]]-1?t.dims[o[n]]:U.normalizeAxis(e,t.dims[o[n]]))),a=n.ends.map(((e,n)=>e>t.dims[o[n]]-1?t.dims[o[n]]:U.normalizeAxis(e,t.dims[o[n]]))),s=t.dims.slice(),u=[];for(let e=0;e<o.length;e++)s[o[e]]=a[e]-i[e],i[e]>0&&u.push(`outputIdx[${o[e]}] += ${i[e]};`);let l=`\n      float process(int outputIdx[${s.length}]) {\n        ${u.join("\n      ")}\n        return _A(outputIdx);\n      }`;return{...Vi,output:{dims:s,type:t.type,textureType:0},shaderSource:l}},Ob=e=>{if(!e||1!==e.length)throw new Error("Slice requires 1 input.");if(-1===tr.indexOf(e[0].type))throw new Error("Invalid input type.")},_c=(e,t)=>{Sb(t);let n=Ib(e,t);return[e.run({...Vi,cacheHint:n.cacheKey,get:()=>wc(e,t[0],n)},[t[0]])]},Ib=(e,t)=>{if(!e.session.isInitializer(t[1].dataId)||!e.session.isInitializer(t[2].dataId)||t.length>=4&&!e.session.isInitializer(t[3].dataId)||t.length>=5&&!e.session.isInitializer(t[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(t.length>=5&&t[4].integerData.some((e=>1!==e)))throw new Error("currently non-1 steps is not supported for Slice");let n=Array.from(t[1].integerData),r=Array.from(t[2].integerData),o=t.length>=4?Array.from(t[3].integerData):[];return{starts:n,ends:r,axes:o,cacheKey:`${o};${n};${r}`}},Sb=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if("int32"!==e[1].type||1!==e[1].dims.length)throw new Error("Invalid input type.");if("int32"!==e[2].type||1!==e[2].dims.length)throw new Error("Invalid input type.");if(e.length>=4&&("int32"!==e[3].type||1!==e[3].dims.length))throw new Error("Invalid input type.");if(e.length>=5&&("int32"!==e[4].type||1!==e[4].dims.length))throw new Error("Invalid input type.")}})),Ic,Sc,Ac,Pc,Ec,Dc,Lc,Fc,Ab,Pb,Eb,$c,Cc=L((()=>{Ge(),fe(),xe(),ae(),ao(),Ic={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Sc={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Ac={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Pc=(e,t,n)=>{$c(t);let r=t[0].dims.slice(),o=U.normalizeAxis(n.axis,r.length),i=U.sizeToDimension(r,o),a=U.sizeFromDimension(r,o);return Fc(e,t,n,i,a)},Ec=e=>ee({axis:e.attributes.getInt("axis",1)}),Dc=e=>ee({axis:e.attributes.getInt("axis",-1)}),Lc=(e,t,n)=>{$c(t);let r,o=t[0].dims.slice(),i=U.normalizeAxis(n.axis,o.length),a=o.length,s=i!==a-1,u=[],l=[],c=[];s&&(l=Array.from({length:a}).map(((e,t)=>t)),l[i]=a-1,l[a-1]=i,l.map((e=>u.push(o[e]))),r=ee({perm:l}),c=Tr(e,t,r));let p=s?U.sizeToDimension(u,a-1):U.sizeToDimension(o,a-1),d=s?U.sizeFromDimension(u,a-1):U.sizeFromDimension(o,a-1),f=Fc(e,s?c:t,n,p,d);return s?Tr(e,f,r):f},Fc=(e,t,n,r,o)=>{let i=Ab(e,t[0],r,o,[r]),a=e.run({...Ic,cacheHint:n.cacheKey,get:()=>i},t),s=Pb(e,t[0],r,o,i.output.dims,[r]),u=e.run({...Sc,cacheHint:n.cacheKey,get:()=>s},[t[0],a]),l=Eb(e,t[0],r,o,i.output.dims,s.output.dims);return[e.run({...Ac,cacheHint:n.cacheKey,get:()=>l},[t[0],a,u])]},Ab=(e,t,n,r,o)=>{let[i,a]=e.calculateTextureWidthAndHeight(t.dims,0),s=o.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length)throw new Error("Dimensionality of the output should be 1");if(o[0]!==n)throw new Error("Shape of the output should be equal to logical row count");let u=q(e.session.backend.glContext.version),l=`\n      float process(int[${s}] indices) {\n        int logical_row_start_offset = indices[0] * ${r};\n\n        float max = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset, ${i},\n        ${a} )));\n        for(int i=1; i<${r}; ++i)\n        {\n          float current = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset + i,\n            ${i}, ${a})));\n          if(current > max)\n          max = current;\n        }\n\n        return max;\n      }`;return{...Ic,output:{dims:o,type:t.type,textureType:0},shaderSource:l}},Pb=(e,t,n,r,o,i)=>{let[a,s]=e.calculateTextureWidthAndHeight(t.dims,0),u=i.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==i.length)throw new Error("Dimensionality of the output should be 1");if(i[0]!==n)throw new Error("Shape of the output should be equal to logical row count");if(1!==o.length)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=`\n      float process(int[${u}] indices) {\n        int logical_row_start_offset = indices[0] * ${r};\n\n        float norm_factor = 0.0;\n        float max = _Max(indices);\n        for(int i=0; i<${r}; ++i)\n        {\n          norm_factor += exp(getColorAsFloat(${q(e.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i,\n            ${a}, ${s}))) - max);\n        }\n\n        return norm_factor;\n      }`;return{...Sc,output:{dims:i,type:t.type,textureType:0},shaderSource:l}},Eb=(e,t,n,r,o,i)=>{let[a,s]=e.calculateTextureWidthAndHeight(t.dims,0),u=t.dims.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length||1!==i.length)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==n||i[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=`\n      float process(int[${u}] indices) {\n\n      // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)\n      int offset = coordsToOffset(TexCoords, ${a}, ${s});\n\n      //determine the logical row for this index\n      int logical_row_index[1];\n      logical_row_index[0] = offset / ${r};\n\n      float norm_factor = _Norm(logical_row_index);\n\n      // avoid possible division by 0\n      // if norm_facor is 0, all elements are zero\n      // if so, return 0\n      if(norm_factor == 0.0)\n        return 0.0;\n\n      return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;\n    }`;return{...Ac,output:{dims:t.dims,type:t.type,textureType:0},shaderSource:l}},$c=e=>{if(!e||1!==e.length)throw new Error("Softmax requires 1 input.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type")}})),kc,Bc,Nc,Db,Lb,Fb,Rc=L((()=>{Ge(),fe(),ae(),kc={name:"Split",inputNames:["A"],inputTypes:[0]},Bc=(e,t,n)=>{Fb(t);let r=U.normalizeAxis(n.axis,t[0].dims.length),o=Db(e,t,r,n),i=[];for(let a=0;a<o;++a)i.push(e.run({...kc,cacheHint:`${n.cacheKey};${a}`,get:()=>Lb(e,t[0],n,r,a)},t));return i},Nc=e=>{let t=e.attributes.getInt("axis",0),n=e.attributes.getInts("split",[]),r=e.outputs.length;return ee({axis:t,split:n,numOutputs:r})},Db=(e,t,n,r)=>{let[,o]=an.splitShape(t[0].dims,n,r.split,r.numOutputs);return o.length},Lb=(e,t,n,r,o)=>{let[i,a]=an.splitShape(t.dims,r,n.split,n.numOutputs),s=a[o],u=i[o],l=`\n      float process(int indices[${u.length}]) {\n        indices[${r}] += ${s};\n        return _A(indices);\n      }\n    `;return{...kc,cacheHint:`${n.cacheKey}:${o}`,output:{dims:u,type:t.type,textureType:0},shaderSource:l}},Fb=e=>{if(!e||1!==e.length)throw new Error("Split requires one input.");if("int8"!==e[0].type&&"uint8"!==e[0].type&&"int16"!==e[0].type&&"uint16"!==e[0].type&&"int32"!==e[0].type&&"uint32"!==e[0].type&&"float32"!==e[0].type&&"float64"!==e[0].type&&"bool"!==e[0].type)throw new Error("Invalid input type.")}})),Wi,Mc,Gc,$b,Cb,Uc=L((()=>{fe(),Wi=(e,t,n)=>{$b(t);let r=U.squeezeShape(t[0].dims,n);return[e.reshapeUnpacked(t[0],r)]},Mc=(e,t)=>(Cb(t),Wi(e,[t[0]],Array.from(t[1].integerData))),Gc=e=>e.attributes.getInts("axes"),$b=e=>{if(!e||1!==e.length)throw new Error("Squeeze requires 1 input.");if("string"===e[0].type)throw new Error("invalid input tensor types.")},Cb=e=>{if(!e||2!==e.length)throw new Error("Squeeze requires 2 inputs.");if("int32"!==e[1].type)throw new Error("Invalid input type.")}})),zc,kb,Bb,Vc=L((()=>{xe(),ae(),zc=(e,t)=>{Bb(t);let n={name:"Sum",inputNames:t.map(((e,t)=>`X${t}`)),inputTypes:new Array(t.length).fill(0)};return[e.run({...n,get:()=>kb(e,t,n)},t)]},kb=(e,t,n)=>{let r=q(e.session.backend.glContext.version),o=t[0].dims.slice(),i=`\n      void main() {\n        vec4 result = ${t.map(((e,t)=>`${r.texture2D}(X${t},TexCoords)`)).join(" + ")};\n        ${r.output} = result;\n      }\n    `;return{...n,output:{dims:o,type:t[0].type,textureType:0},hasMain:!0,shaderSource:i}},Bb=e=>{if(!e||0===e.length)throw new Error("Sum requires inputs.");let t=e[0].dims.length;for(let n=1;n<e.length;n++){if(t!==e[n].dims.length)throw new Error("Input shapes are mismatched.");for(let r=0;r<t;r++)if(e[0].dims[r]!==e[n].dims[r])throw new Error("Input shapes are not matched.")}if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.");for(let t=1;t<e.length;t++)if(e[0].type!==e[t].type)throw new Error("Input types are not matched.")}})),Wc,Nb,Rb,Hc=L((()=>{pn(),ae(),Wc=(e,t)=>{Rb(t);let n={name:"Tile",inputNames:["A"],inputTypes:[0]};return[e.run({...n,get:()=>Nb(e,t,n)},t)]},Nb=(e,t,n)=>{let r=t[0].dims.slice(),o=new Array(r.length),i=[];for(let e=0;e<r.length;e++)o[e]=r[e]*t[1].numberData[e],i.push(`inputIdx[${e}] = int(mod(float(outputIdx[${e}]), ${r[e]}.));`);let a=o.length,s=`\n      float process(int outputIdx[${a}]) {\n        int inputIdx[${a}];\n        ${i.join("\n")}\n        return _A(inputIdx);\n      }\n    `;return{...n,output:{dims:o,type:t[0].type,textureType:0},shaderSource:s}},Rb=e=>{if(!e||2!==e.length)throw new Error("Tile requires 2 input.");if(1!==e[1].dims.length)throw new Error("The second input shape must 1 dimension.");if(e[1].dims[0]!==e[0].dims.length)throw new Error("Invalid input shape.");if(-1===tr.indexOf(e[0].type))throw new Error("Invalid input type.");if("int32"!==e[1].type&&"int16"!==e[1].type)throw new Error("Invalid repeat type.")}})),Hi,qc,jc,Mb,Gb,Yc=L((()=>{fe(),Hi=(e,t,n)=>{Mb(t);let r=U.unsqueezeShape(t[0].dims,n);return[e.reshapeUnpacked(t[0],r)]},qc=(e,t)=>(Gb(t),Hi(e,[t[0]],Array.from(t[1].integerData))),jc=e=>e.attributes.getInts("axes"),Mb=e=>{if(!e||1!==e.length)throw new Error("Unsqueeze requires 1 input.");if("string"===e[0].type)throw new Error("invalid input tensor types.")},Gb=e=>{if(!e||2!==e.length)throw new Error("Unsqueeze requires 2 inputs.");if("int32"!==e[1].type)throw new Error("Invalid input type.")}})),Xc,Kc=L((()=>{il(),yl(),vl(),Al(),no(),cf(),gf(),xf(),_f(),Af(),Df(),Cf(),Rf(),oo(),zf(),tc(),lc(),cc(),gc(),Tc(),Oc(),Cc(),Rc(),Uc(),Vc(),Hc(),ao(),Pi(),Yc(),Gi(),Xc=[["Abs","","6+",Pl],["Acos","","7+",El],["Add","","7+",al],["And","","7+",sl],["Asin","","7+",Dl],["Atan","","7+",Ll],["AveragePool","","7+",Wf,Hf],["BatchNormalization","","7+",nl,ol],["Cast","","6+",Tl,xl],["Ceil","","6+",Cl],["Clip","","6-10",Si,Fl],["Clip","","11+",$l],["Concat","","4+",Ol,Sl],["Conv","","1+",Ci,ki],["ConvTranspose","","1+",lf,ff],["Cos","","7+",kl],["Div","","7+",ul],["Dropout","","7+",Ai],["DepthToSpace","","1+",mf,bf],["Equal","","7+",ll],["Elu","","6+",Bl,Nl],["Exp","","6+",Rl],["Flatten","","1+",yf,Tf],["Floor","","6+",Ml],["FusedConv","com.microsoft","1+",Ci,ki],["Gather","","1+",vf,wf],["Gemm","","7-10",Bi,If],["Gemm","","11+",Bi,Sf],["GlobalAveragePool","","1+",jf,Yf],["GlobalMaxPool","","1+",Qf],["Greater","","7+",fl],["Identity","","1+",Ai],["ImageScaler","","1+",Pf,Ef],["InstanceNormalization","","6+",Ff,$f],["LeakyRelu","","6+",Gl,Ul],["Less","","7+",cl],["LRN","","1+",kf,Bf],["Log","","6+",zl],["MatMul","","1+",tf,rf],["MaxPool","","1+",Xf,Kf],["Mul","","7+",pl],["Neg","","6+",Vl],["Not","","1+",Wl],["Or","","7+",dl],["Pad","","2-10",Ni,Mf],["Pad","","11+",Gf,Uf],["Pow","","7+",hl],["PRelu","","7+",ml],["ReduceLogSum","","1+",sc,rr],["ReduceMax","","1+",oc,rr],["ReduceMean","","1+",nc,rr],["ReduceMin","","1+",ic,rr],["ReduceProd","","1+",ac,rr],["ReduceSum","","1-12",rc,rr],["ReduceSumSquare","","1+",uc,rr],["Relu","","6+",Hl],["Reshape","","5+",fc],["Resize","","10",zi,mc],["Resize","","11+",zi,bc],["Shape","","1+",yc],["Sigmoid","","6+",ql],["Sin","","7+",jl],["Slice","","10+",_c],["Slice","","1-9",xc,vc],["Softmax","","1-12",Pc,Ec],["Softmax","","13+",Lc,Dc],["Split","","2-12",Bc,Nc],["Sqrt","","6+",Yl],["Squeeze","","1-12",Wi,Gc],["Squeeze","","13+",Mc],["Sub","","7+",bl],["Sum","","6+",zc],["Tan","","7+",Xl],["Tanh","","6+",Kl],["Tile","","6+",Wc],["Transpose","","1+",Tr,df],["Upsample","","7-8",Ri,dc],["Upsample","","9",Ri,hc],["Unsqueeze","","1-12",Hi,jc],["Unsqueeze","","13+",qc],["Xor","","7+",gl]]}));function Zc(e){let t,n={};for(;null!==(t=Jc.exec(e));){let e=t[3].split(",").map((e=>{let t=e.trim().split(" ");return t&&2===t.length?{type:t[0],name:t[1]}:null})).filter((e=>null!==e));n[t[2]]={params:e,body:t[4]}}for(let r in n){let o=Ub.replace("__FUNC__",r),i=new RegExp(o,"gm");for(;null!==(t=i.exec(e));){let o=t[1],i=t[2],a=t[3].split(","),s=o?`${o} ${i};`:"",u=n[r].body,l="";n[r].params.forEach(((e,t)=>{e&&(l+=`${e.type} ${e.name} = ${a[t]};\n`)})),u=`${l}\n ${u}`,u=u.replace("return",`${i} = `);let c=`\n      ${s}\n      {\n        ${u}\n      }\n      `;e=e.replace(t[0],c)}}return e=e.replace(Jc,"")}var Jc,Ub,Qc=L((()=>{Jc=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,Ub="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"}));function Gr(e,t){let n=[],r=[],o=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||o?null:zb(t,e).sort(),a=0;for(let t=0;t<e.length;++t){if(null!=i){if(i[a]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==i[a]||i[a]>t)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[a]<=t&&a++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function zb(e,t){let n=t.length;return Cr((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),Cr(e.every(Vb),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function Vb(e){return e%1==0}function Wb(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function ep(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}var fo,qi=L((()=>{ut(),fe(),fo=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,t){let n=this.computeTexture(e,t);return t&&t.isPacked&&(n[0]/=2,n[1]/=2),t&&t.reverseWH?[n[1],n[0]]:n}computeTexture(e,t){let n=t&&t.isPacked;if(0===e.length)return n?[2,2]:[1,1];let r=this.maxTextureSize;if(t&&void 0!==t.breakAxis){let n=t.breakAxis>=e.length?1:e.slice(t.breakAxis).reduce(((e,t)=>e*t)),o=t.breakAxis<=0?1:e.slice(0,t.breakAxis).reduce(((e,t)=>e*t));if(!(n>r||o>r))return[n,o];ce.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${t.breakAxis}`)}let o=e.slice(0);n&&(r*=2,o=o.map(((e,t)=>t>=o.length-2?o[t]%2==0?o[t]:o[t]+1:o[t])),1===o.length&&(o=[2,o[0]])),2!==o.length&&(o=Gr(o).newShape);let i=Wb(o);return o.length<=1&&i<=r?[1,i]:2===o.length&&o[0]<=r&&o[1]<=r?o:3===o.length&&o[0]*o[1]<=r&&o[2]<=r?[o[0]*o[1],o[2]]:3===o.length&&o[0]<=r&&o[1]*o[2]<=r?[o[0],o[1]*o[2]]:4===o.length&&o[0]*o[1]*o[2]<=r&&o[3]<=r?[o[0]*o[1]*o[2],o[3]]:4===o.length&&o[0]<=r&&o[1]*o[2]*o[3]<=r?[o[0],o[1]*o[2]*o[3]]:n?ep(i/4).map((e=>2*e)):ep(i)}}})),co,tp=L((()=>{fe(),Vt(),xe(),qi(),Ft(),co=class extends pt{constructor(e){super(e)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSamplingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new R("\n      vec2 offsetToCoords(int offset, int width, int height) {\n        int t = offset / width;\n        int s = offset - t*width;\n        vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);\n        return coords;\n      }\n      ")}}coordsToOffset(){return{coordsToOffset:new R("\n      int coordsToOffset(vec2 coords, int width, int height) {\n        float s = coords.s * float(width);\n        float t = coords.t * float(height);\n        int offset = int(t) * width + int(s);\n        return offset;\n      }\n      ")}}getOutputSamplingSnippet(){let e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){let t=e.unpackedShape,n=[e.width,e.height],r={},o="getOutputCoords";switch(t.length){case 0:r[o]=this.getOutputScalarCoords();break;case 1:r[o]=this.getOutputPacked1DCoords(t,n);break;case 2:r[o]=this.getOutputPacked2DCoords(t,n);break;case 3:r[o]=this.getOutputPacked3DCoords(t,n);break;default:r[o]=this.getOutputPackedNDCoords(t,n)}let i=`\n      void setOutput(vec4 val) {\n        ${q(this.context.glContext.version).output} = val;\n      }\n    `;return r.floatTextureSetRGBA=new R(i),r}getUnpackedOutputSamplingSnippet(e){let t=e.unpackedShape,n=[e.width,e.height],r={},o="getOutputCoords";switch(t.length){case 0:r[o]=this.getOutputScalarCoords();break;case 1:r[o]=this.getOutputUnpacked1DCoords(t,n);break;case 2:r[o]=this.getOutputUnpacked2DCoords(t,n);break;case 3:r[o]=this.getOutputUnpacked3DCoords(t,n);break;case 4:r[o]=this.getOutputUnpacked4DCoords(t,n);break;case 5:r[o]=this.getOutputUnpacked5DCoords(t,n);break;case 6:r[o]=this.getOutputUnpacked6DCoords(t,n);break;default:throw new Error(`Unsupported output dimensionality: ${t.length}`)}let i=`\n        void setOutput(float val) {\n          ${q(this.context.glContext.version).output} = vec4(val, 0, 0, 0);\n        }\n    `;return r.floatTextureSetR=new R(i),r}getOutputScalarCoords(){return new R("\n      int getOutputCoords() {\n        return 0;\n      }\n    ")}getOutputPacked1DCoords(e,t){let n=t,r="";return 1===n[0]?(r=`\n          int getOutputCoords() {\n            return 2 * int(TexCoords.y * ${n[1]}.0);\n          }\n        `,new R(r)):1===n[1]?(r=`\n          int getOutputCoords() {\n            return 2 * int(TexCoords.x * ${n[0]}.0);\n          }\n        `,new R(r)):(r=`\n        int getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                 vec2(${n[0]}, ${n[1]}));\n          return 2 * (resTexRC.y * ${n[0]} + resTexRC.x);\n        }\n      `,new R(r))}getOutputPacked2DCoords(e,t){let n="";if(pr.arraysEqual(e,t))return n=`\n        ivec2 getOutputCoords() {\n          return 2 * ivec2(TexCoords.xy * vec2(${t[0]}, ${t[1]}));\n        }\n      `,new R(n);let r=t,o=Math.ceil(e[1]/2);return n=`\n        ivec2 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${r[0]}, ${r[1]}));\n\n          int index = resTexRC.y * ${r[0]} + resTexRC.x;\n\n          // reverse r and c order for packed texture\n          int r = imod(index, ${o}) * 2;\n          int c = 2 * (index / ${o});\n\n          return ivec2(r, c);\n        }\n      `,new R(n)}getOutputPacked3DCoords(e,t){let n=[t[0],t[1]],r=Math.ceil(e[2]/2),o=r*Math.ceil(e[1]/2);return new R(`\n        ivec3 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${n[0]}, ${n[1]}));\n          int index = resTexRC.y * ${n[0]} + resTexRC.x;\n\n          int b = index / ${o};\n          index -= b * ${o};\n\n          // reverse r and c order for packed texture\n          int r = imod(index, ${r}) * 2;\n          int c = 2 * (index / ${r});\n\n          return ivec3(b, r, c);\n        }\n      `)}getOutputPackedNDCoords(e,t){let n=[t[0],t[1]],r=Math.ceil(e[e.length-1]/2),o=r*Math.ceil(e[e.length-2]/2),i=o,a="",s="b, r, c";for(let t=2;t<e.length-1;t++)i*=e[e.length-t-1],a=`\n      int b${t} = index / ${i};\n      index -= b${t} * ${i};\n    `+a,s=`b${t}, `+s;let u=`\n      ivec${e.length} getOutputCoords() {\n        ivec2 resTexRC = ivec2(TexCoords.xy *\n                              vec2(${n[0]}, ${n[1]}));\n        int index = resTexRC.y * ${n[0]} + resTexRC.x;\n\n        ${a}\n\n        int b = index / ${o};\n        index -= b * ${o};\n\n        // reverse r and c order for packed texture\n        int r = imod(index, ${r}) * 2;\n        int c = 2 * (index / ${r});\n\n        return ivec${e.length}(${s});\n      }\n    `;return new R(u)}getOutputUnpacked1DCoords(e,t){let n=`\n        int getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${t[0]}, ${t[1]}));\n          return resTexRC.y * ${t[0]} + resTexRC.x;\n        }\n      `;return new R(n)}getOutputUnpacked2DCoords(e,t){let n=`\n        ivec2 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${t[0]}, ${t[1]}));\n          int index = resTexRC.y * ${t[0]} + resTexRC.x;\n          int r = index / ${e[1]};\n          int c = index - r * ${e[1]};\n          return ivec2(r, c);\n        }\n      `;return new R(n)}getOutputUnpacked3DCoords(e,t){let n="",r=e.length,o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=e[r-1];for(let t=r-3;t>=0;--t)o[t]=o[t+1]*e[t+1];let i=["r","c","d"],a=o.map(((e,t)=>`${`int ${i[t]} = index / ${e}`}; ${t===o.length-1?`int ${i[t+1]} = index - ${i[t]} * ${e}`:`index -= ${i[t]} * ${e}`};`)).join("");return n=`\n        ivec3 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${t[0]}, ${t[1]}));\n          int index = resTexRC.y * ${t[0]} + resTexRC.x;\n          ${a}\n          return ivec3(r, c, d);\n        }\n      `,new R(n)}getOutputUnpacked4DCoords(e,t){let n="",r=e.length,o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=e[r-1];for(let t=r-3;t>=0;--t)o[t]=o[t+1]*e[t+1];let i=["r","c","d","d2"],a=o.map(((e,t)=>`${`int ${i[t]} = index / ${e}`}; ${t===o.length-1?`int ${i[t+1]} = index - ${i[t]} * ${e}`:`index -= ${i[t]} * ${e}`};`)).join("");return n=`\n      ivec4 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${t[0]}, ${t[1]}));\n          int index = resTexRC.y * ${t[0]} + resTexRC.x;\n          ${a}\n          return ivec4(r, c, d, d2);\n        }\n      `,new R(n)}getOutputUnpacked5DCoords(e,t){let n="",r=e.length,o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=e[r-1];for(let t=r-3;t>=0;--t)o[t]=o[t+1]*e[t+1];let i=["r","c","d","d2","d3"],a=o.map(((e,t)=>`${`int ${i[t]} = index / ${e}`}; ${t===o.length-1?`int ${i[t+1]} = index - ${i[t]} * ${e}`:`index -= ${i[t]} * ${e}`};`)).join("");return n=`\n      ivec5 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${t[0]}, ${t[1]}));\n          int index = resTexRC.y * ${t[0]} + resTexRC.x;\n          ${a}\n          return ivec5(r, c, d, d2, d3);\n        }\n      `,new R(n)}getOutputUnpacked6DCoords(e,t){let n="",r=e.length,o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=e[r-1];for(let t=r-3;t>=0;--t)o[t]=o[t+1]*e[t+1];let i=["r","c","d","d2","d3","d4"],a=o.map(((e,t)=>`${`int ${i[t]} = index / ${e}`}; ${t===o.length-1?`int ${i[t+1]} = index - ${i[t]} * ${e}`:`index -= ${i[t]} * ${e}`};`)).join("");return n=`\n     ivec6 getOutputCoords() {\n         ivec2 resTexRC = ivec2(TexCoords.xy *\n                               vec2(${t[0]}, ${t[1]}));\n         int index = resTexRC.y * ${t[0]} + resTexRC.x;\n         ${a}\n         return ivec6(r, c, d, d2, d3, d4);\n       }\n     `,new R(n)}getCommonUtilFuncs(){let e={},t="uvFromFlat";e[t]=new R("\n    vec2 uvFromFlat(int texNumR, int texNumC, int index) {\n      int texC = index / texNumR;\n      int texR = index - texC * texNumR;\n      // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to\n      //       v.\n      return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);\n    }\n    "),t="packedUVfrom1D",e[t]=new R("\n      vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n        int texelIndex = index / 2;\n        int texR = texelIndex / texNumC;\n        int texC = texelIndex - texR * texNumC;\n        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n      }\n      "),t="packedUVfrom2D",e[t]=new R("\n      vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {\n        int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n        int texR = texelIndex / texNumC;\n        int texC = texelIndex - texR * texNumC;\n        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n      }\n      "),t="packedUVfrom3D",e[t]=new R("\n      vec2 packedUVfrom3D(int texNumR, int texNumC,\n          int texelsInBatch, int texelsInLogicalRow, int b,\n          int row, int col) {\n        int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n        int texR = index / texNumC;\n        int texC = index - texR * texNumC;\n        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n      }\n      "),t="sampleTexture";let n=q(this.context.glContext.version);return e[t]=new R(`\n        float sampleTexture(sampler2D textureSampler, vec2 uv) {\n            return ${n.texture2D}(textureSampler, uv).r;\n        }`),e}getInputsSamplingSnippets(){let e={},t=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach(((n,r)=>{let o=this.context.inputTextureLayouts[r],i=Kn(n);o.isPacked?e[i]=this.getPackedSamplerFromInput(i,n,o):e[i]=this.getUnpackedSamplerFromInput(i,n,o);let a=Uu(n);o.unpackedShape.length<=t.unpackedShape.length&&(o.isPacked?e[a]=this.getPackedSamplerAtOutputCoords(a,o,t,n):e[a]=this.getUnpackedSamplerAtOutputCoords(a,o,t,n))})),e}getPackedSamplerAtOutputCoords(e,t,n,r){let o,i=t.unpackedShape,a=n.unpackedShape,s=Kn(r),u=i.length,l=a.length,c=Xe.getBroadcastDims(i,a),p=Ke(l),d=l-u,f=St();o=0===u?"":l<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${f[e+d]} = 0;`)).join("\n");let h="";h=l<2&&u>0?"coords":i.map(((e,t)=>`coords.${f[t+d]}`)).join(", ");let g="return outputValue;",m=1===U.size(i),b=1===U.size(a);if(1!==u||m||b){if(m&&!b)g=1===l?"\n          return vec4(outputValue.x, outputValue.x, 0., 0.);\n        ":"\n          return vec4(outputValue.x);\n        ";else if(c.length){let e=u-2,t=u-1;c.indexOf(e)>-1&&c.indexOf(t)>-1?g="return vec4(outputValue.x);":c.indexOf(e)>-1?g="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":c.indexOf(t)>-1&&(g="return vec4(outputValue.xx, outputValue.zz);")}}else g="\n        return vec4(outputValue.xy, outputValue.xy);\n      ";let y=`\n        int lastDim = coords.${f[l-1]};\n        coords.${f[l-1]} = coords.${f[l-2]};\n        coords.${f[l-2]} = lastDim;\n      `;return new R(`\n      vec4 ${e}() {\n        ${p} coords = getOutputCoords();\n        ${y}\n        ${o}\n        vec4 outputValue = ${s}(${h});\n        ${g}\n      }\n    `,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,t,n,r){let o=[n.width,n.height],i=[t.width,t.height],a=t.unpackedShape.length,s=n.unpackedShape.length,u=t.unpackedShape,l=n.unpackedShape,c=Kn(r);if(a===s&&pr.arraysEqual(i,o)){return new R(`\n          float ${e}() {\n            return sampleTexture(${r}, TexCoords);\n          }\n        `,["coordinates.sampleTexture"])}let p,d=Ke(s),f=Xe.getBroadcastDims(u,l),h=s-a,g=St();p=0===a?"":s<2&&f.length>=1?"coords = 0;":f.map((e=>`coords.${g[e+h]} = 0;`)).join("\n");let m="";return m=s<2&&a>0?"coords":t.unpackedShape.map(((e,t)=>`coords.${g[t+h]}`)).join(", "),new R(`\n        float ${e}() {\n          ${d} coords = getOutputCoords();\n          ${p}\n          return ${c}(${m});\n        }\n      `,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,t,n){switch(n.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,t);case 1:return this.getPackedSampler1D(e,t,n);case 2:return this.getPackedSampler2D(e,t,n);case 3:return this.getPackedSampler3D(e,t,n);default:return this.getPackedSamplerND(e,t,n)}}getUnpackedSamplerFromInput(e,t,n){let r=n.unpackedShape;switch(r.length){case 0:return this.getUnpackedSamplerScalar(e,t,n);case 1:return this.getUnpackedSampler1D(e,t,n);case 2:return this.getUnpackedSampler2D(e,t,n);case 3:return this.getUnpackedSampler3D(e,t,n);case 4:return this.getUnpackedSampler4D(e,t,n);case 5:return this.getUnpackedSampler5D(e,t,n);case 6:return this.getUnpackedSampler6D(e,t,n);default:throw new Error(`Unsupported dimension ${r.length}-D`)}}getPackedSamplerScalar(e,t){let n=`\n          vec4 ${e}() {\n            return ${q(this.context.glContext.version).texture2D}(${t}, halfCR);\n          }\n        `;return new R(n)}getPackedSampler1D(e,t,n){let r=[n.width,n.height],o=[r[1],r[0]],i=q(this.context.glContext.version),a=`vec4 ${e}(int index) {\n      vec2 uv = packedUVfrom1D(\n      ${o[0]}, ${o[1]}, index);\n      return ${i.texture2D}(${t}, uv);\n    }`;return new R(a,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,t,n){let r=n.unpackedShape,o=[n.width,n.height],i=q(this.context.glContext.version),a=o[0],s=o[1];if(null!=o&&pr.arraysEqual(r,o)){let n=`vec4 ${e}(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}.0, ${a}.0);\n        return ${i.texture2D}(${t}, uv);\n      }`;return new R(n)}let u=o,l=Math.ceil(r[1]/2),c=`vec4 ${e}(int row, int col) {\n      vec2 uv = packedUVfrom2D(${u[1]}, ${u[0]}, ${l}, row, col);\n      return ${i.texture2D}(${t}, uv);\n    }`;return new R(c,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,t,n){let r=n.unpackedShape,o=[n.width,n.height],i=[o[0],o[1]],a=q(this.context.glContext.version);if(1===r[0]){let o=r.slice(1),i=[1,2],a=kr(r,o),s=["b","row","col"],u=JSON.parse(JSON.stringify(n));u.unpackedShape=a;let l=this.getPackedSamplerFromInput(e,t,u),c=`${l.routineBody}\n      vec4 ${e}(int b, int row, int col) {\n        return ${e}(${Br(s,i)});\n      } `;return new R(c,l.dependencies)}let s=i[0],u=i[1],l=Math.ceil(r[2]/2),c=`vec4 ${e}(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        ${u}, ${s}, ${l*Math.ceil(r[1]/2)}, ${l}, b, row, col);\n      return ${a.texture2D}(${t}, uv);}`;return new R(c,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,t,n){let r=n.unpackedShape,o=r.length,i=[n.width,n.height],a=q(this.context.glContext.version),s=[i[0],i[1]],u=s[1],l=s[0],c=Math.ceil(r[o-1]/2),p=c*Math.ceil(r[o-2]/2),d="int b, int row, int col",f=`b * ${p} + (row / 2) * ${c} + (col / 2)`;for(let e=2;e<o-1;e++)d=`int b${e}, `+d,p*=r[o-e-1],f=`b${e} * ${p} + `+f;let h=`vec4 ${e}(${d}) {\n      int index = ${f};\n      int texR = index / ${l};\n      int texC = index - texR * ${l};\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${u});\n      return ${a.texture2D}(${t}, uv);\n    }`;return new R(h)}getUnpackedSamplerScalar(e,t,n){let[r,o]=[n.width,n.height];if(1===r&&1===o){return new R(`\n          float ${e}() {\n            return sampleTexture(${t}, halfCR);\n          }\n        `,["coordinates.sampleTexture"])}return new R(`\n        float ${e}() {\n          int offset_${t} = coordsToOffset(TexCoords, ${r}, ${o});\n          vec2 uv = uvFromFlat(${r}, ${o}, offset_${t});\n          return sampleTexture(${t}, uv);\n        }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(e,t,n){let r=n.width,o=n.height;if(1===o&&1===r){return new R(`\n        float ${e}(int index) {\n          return sampleTexture(${t}, halfCR);\n        }\n      `,["coordinates.sampleTexture"])}if(1===o){return new R(`\n          float ${e}(int index) {\n            vec2 uv = vec2((float(index) + 0.5) / ${r}.0, 0.5);\n            return sampleTexture(${t}, uv);\n          }\n        `,["coordinates.sampleTexture"])}if(1===r){return new R(`\n          float ${e}(int index) {\n            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${o}.0);\n            return sampleTexture(${t}, uv);\n          }\n        `,["coordinates.sampleTexture"])}return new R(`\n        float ${e}(int index) {\n          vec2 uv = uvFromFlat(${r}, ${o}, index);\n          return sampleTexture(${t}, uv);\n        }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(e,t,n){let r=n.unpackedShape,o=[n.height,n.width];if(null!=o&&pr.arraysEqual(r,o)){return new R(`\n          float ${e}(int row, int col) {\n            vec2 uv = (vec2(row, col) + halfCR) / vec2(${o[1]}.0, ${o[0]}.0);\n            return sampleTexture(${t}, uv);\n          }\n        `,["coordinates.sampleTexture"])}let{newShape:i,keptDims:a}=Gr(r),s=i;if(s.length<r.length){let o=kr(r,s),i=JSON.parse(JSON.stringify(n));i.unpackedShape=o;let u=["col","row"],l=`\n          ${this.getUnpackedSamplerFromInput(e,t,i).routineBody}\n          float ${e}(int row, int col) {\n            return ${e}(${Br(u,a)});\n          }\n        `;return new R(l,["coordinates.sampleTexture"])}let u=o[1],l=o[0];if(1===l){let n=`\n          float ${e}(int row, int col) {\n            int offset_${t} = coordsToOffset(TexCoords, ${u}, ${l});\n            float index = dot(vec3(row, col, offset_${t}), vec3(${r[1]}, 1, 1));\n            vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);\n            return sampleTexture(${t}, uv);\n          }\n        `;return new R(n,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(1===u){let n=`\n          float ${e}(int row, int col) {\n            int offset_${t} = coordsToOffset(TexCoords, ${u}, ${l});\n            float index = dot(vec3(row, col, offset_${t}), vec3(${r[1]}, 1, 1));\n            vec2 uv = vec2((index + 0.5) / ${l}.0, 0.5);\n            return sampleTexture(${t}, uv);\n          }\n        `;return new R(n,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let c=`\n        float ${e}(int row, int col) {\n          int index = col * ${r[1]} + row;\n          vec2 uv = uvFromFlat(${u}, ${l}, index);\n          return sampleTexture(${t}, uv);\n        }\n      `;return new R(c,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(e,t,n){let r=n.unpackedShape,o=r[1]*r[2],i=r[2],{newShape:a,keptDims:s}=Gr(r),u=a;if(u.length<r.length){let o=kr(r,u),i=["batch","col","row"],a=JSON.parse(JSON.stringify(n));a.unpackedShape=o;let l=this.getUnpackedSamplerFromInput(e,t,a),c=s.reverse(),p=`\n          ${l.routineBody}\n          float ${e}(int batch, int row, int col) {\n            return ${e}(${Br(i,c)});\n          }\n        `;return new R(p,l.dependencies)}let l=n.width,c=n.height;return new R(`\n          float ${e}(int depth, int row, int col) {\n            // Explicitly use integer operations as dot() only works on floats.\n            int index = depth * ${o} + col * ${i} + row;\n            vec2 uv = uvFromFlat(${l}, ${c}, index);\n            return sampleTexture(${t}, uv);\n          }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(e,t,n){let r=n.unpackedShape,o=r[3],i=r[2]*o,a=r[1]*i,s=n.width,u=n.height;return new R(`\n        float ${e}(int row, int col, int depth, int depth2) {\n          int index = row * ${a} + col * ${i} +\n              depth2 * ${o} + depth;\n          vec2 uv = uvFromFlat(${s}, ${u}, index);\n          return sampleTexture(${t}, uv);\n        }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(e,t,n){let r=n.unpackedShape,o=r[4],i=r[3]*o,a=r[2]*i,s=r[1]*a,{newShape:u,keptDims:l}=Gr(r);if(u.length<r.length){let o=kr(r,u),i=["row","col","depth","depth2","depth3"],a=JSON.parse(JSON.stringify(n));a.unpackedShape=o;let s=`\n          ${this.getUnpackedSamplerFromInput(e,t,a).routineBody}\n          float ${e}(int row, int col, int depth, int depth2, int depth3) {\n            return ${e}(${Br(i,l)});\n          }\n        `;return new R(s,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let c=n.width,p=n.height;return new R(`\n        float ${e}(int row, int col, int depth, int depth2, int depth3) {\n          int index = row * ${s} + col * ${a} + depth * ${i} +\n          depth3 * ${o} + depth2;\n          vec2 uv = uvFromFlat(${c}, ${p}, index);\n          return sampleTexture(${t}, uv);\n        }\n      `,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(e,t,n){let r=n.unpackedShape,o=r[5],i=r[4]*o,a=r[3]*i,s=r[2]*a,u=r[1]*s,{newShape:l,keptDims:c}=Gr(r);if(l.length<r.length){let o=kr(r,l),i=["row","col","depth","depth2","depth3","depth4"],a=JSON.parse(JSON.stringify(n));a.unpackedShape=o;let s=`\n            ${this.getUnpackedSamplerFromInput(e,t,a).routineBody}\n            float ${e}(int row, int col, int depth,\n              int depth2, int depth3, int depth4) {\n              return ${e}(${Br(i,c)});\n            }\n          `;return new R(s,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let p=n.width,d=n.height;return new R(`\n          float ${e}(int row, int col, int depth,\n            int depth2, int depth3, int depth4) {\n            int index = row * ${u} + col * ${s} + depth * ${a} +\n            depth2 * ${i} + depth3 * ${o} + depth4;\n            vec2 uv = uvFromFlat(${p}, ${d}, index);\n            return sampleTexture(${t}, uv);\n          }\n        `,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let e=this.context.outputTextureLayout,t=e.shape.length,n=e.strides,r=e.width,o=e.height,i=[];for(let e=0;e<t-1;++e)i.push(`\n        c[${e}] = offset / ${n[e]};`),i.push(`\n        offset -= c[${e}] * ${n[e]};`);i.push(`\n        c[${t-1}] = offset;`);let a=`\n      void toVec(vec2 texCoords, out int c[${t}]) {\n        int offset = coordsToOffset(texCoords, ${r}, ${o});\n        ${i.join("")}\n      }\n      void toVec(int offset, out int c[${t}]) {\n        ${i.join("")}\n      }\n    `;return{toVec:new R(a,["coordinates.coordsToOffset"])}}valueFrom(){let e={};return this.context.programInfo.inputNames.forEach(((t,n)=>{let r=this.context.inputTextureLayouts[n],o=(r.unpackedShape.length>0?r.unpackedShape:r.shape).length,i=`_${t}`;e[i]=new R(this.getValueFromSingle(t,o,r.width,r.height,!1),[`shapeUtils.indicesToOffset${i}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),i+="_T",e[i]=new R(this.getValueFromSingle(t,o,r.width,r.height,!0),[`shapeUtils.indicesToOffset${i}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])})),e}getValueFromSingle(e,t,n,r,o){let i=`_${e}`;return o&&(i+="_T"),`\n        float ${i}(int m[${t}]) {\n          int offset = indicesToOffset${i}(m);\n          vec2 coords = offsetToCoords(offset, ${n}, ${r});\n          float value = getColorAsFloat(${q(this.context.glContext.version).texture2D}(${e}, coords));\n          return value;\n        }\n        `}getPackedValueFrom(e,t,n,r,o){let i=`_${e}_Pack`;return o&&(i+="_T"),`\n        vec4 ${i}(int m[${t}]) {\n          int offset = indicesToOffset_${e}(m);\n          vec2 coords = offsetToCoords(offset, ${n}, ${r});\n          return ${q(this.context.glContext.version).texture2D}(${e}, coords);\n        }\n        `}}})),po,rp=L((()=>{Vt(),po=class e extends pt{constructor(e){super(e)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new R("highp vec4 encode(highp float f) {\n        return vec4(f, 0.0, 0.0, 0.0);\n      }\n        ")}}decodeFloat32(){return{decode:new R("highp float decode(highp vec4 rgba) {\n        return rgba.r;\n      }\n        ")}}encodeUint8(){let t=e.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new R(`\n      highp vec4 encode(highp float f) {\n        highp float F = abs(f);\n        highp float Sign = step(0.0,-f);\n        highp float Exponent = floor(log2(F));\n        highp float Mantissa = (exp2(- Exponent) * F);\n        Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));\n        highp vec4 rgba;\n        rgba[0] = 128.0 * Sign  + floor(Exponent*exp2(-1.0));\n        rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);\n        rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));\n        rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));\n        ${t}\n        rgba = rgba / 255.0; // values need to be normalized to [0,1]\n        return rgba;\n    }\n        `)}}decodeUint8(){let t=e.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new R(`\n        highp float decode(highp vec4 rgba) {\n          rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]\n          ${t}\n          highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;\n          highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;\n          highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);\n          highp float Result =  Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));\n          return Result;\n      }\n        `)}}static isLittleEndian(){let e=new ArrayBuffer(4),t=new Uint32Array(e),n=new Uint8Array(e);if(t[0]=3735928559,239===n[0])return!0;if(222===n[0])return!1;throw new Error("unknown endianness")}}})),ho,np=L((()=>{Vt(),xe(),ho=class extends pt{constructor(e){super(e)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let e=q(this.context.glContext.version);return{setFragColor:new R(`\n        void setFragColor(float value) {\n            ${e.output} = encode(value);\n        }\n        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new R("\n        float getColorAsFloat(vec4 color) {\n            return decode(color);\n        }\n        ",["encoding.decode"])}}}})),mo,op=L((()=>{Vt(),mo=class e extends pt{constructor(e){super(e)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let e=this.context.outputTextureLayout.shape.length,t={};return this.context.programInfo.inputNames.forEach(((n,r)=>{let o=this.context.inputTextureLayouts[r].unpackedShape;if(o.length<=e){let r=o.length,i=e-r,a=`bcastIndices_${n}`,s="";for(let e=0;e<r;++e)s+=`\n          realIndices[${e}] = int( mod(float(bcastedIndices[${i+e}]), ${o[e]}.0) );\n          `;let u=`\n        void ${a} (int bcastedIndices[${e}], out int realIndices[${r}]) {\n          ${s}\n        }\n        `;t[a]=new R(u)}})),t}bcastMatmulIndex(){let e=this.context.outputTextureLayout.shape.length,t={};return this.context.programInfo.inputNames.forEach(((n,r)=>{let o=this.context.inputTextureLayouts[r].shape;if(!(o.length<2||o.length>e)){let r=o.length,i=e-r,a=`bcastMatmulIndices_${n}`,s="";for(let e=0;e<r-2;++e)s+=`\n          realIndices[${e}] = int( mod(float(bcastedIndices[${i+e}]), ${o[e]}.0) );\n          `;let u=`\n        void ${a}(int bcastedIndices[${e}], out int realIndices[${r}]) {\n          ${s}\n          realIndices[${r-1}] = bcastedIndices[${e-1}];\n          realIndices[${r-2}] = bcastedIndices[${e-2}];\n        }\n        `;t[a]=new R(u)}})),t}indicesToOffset(){let t={};return this.context.programInfo.inputNames.forEach(((n,r)=>{let o=this.context.inputTextureLayouts[r].shape,i=this.context.inputTextureLayouts[r].strides,a=o.length,s=`indicesToOffset_${n}`;t[s]=new R(e.indexToOffsetSingle(s,a,i)),s=`indicesToOffset_${n}_T`,t[s]=new R(e.indexToOffsetSingle(s,a,i.slice().reverse()))})),t}static indexToOffsetSingle(e,t,n){let r="";for(let e=t-1;e>=0;--e)r+=`\n        offset += indices[${e}] * ${n[e]};\n        `;return`\n      int ${e}(int indices[${t}]) {\n        int offset = 0;\n        ${r}\n        return offset;\n      }\n      `}offsetToIndices(){let t={};return this.context.programInfo.inputNames.forEach(((n,r)=>{let o=this.context.inputTextureLayouts[r].shape,i=this.context.inputTextureLayouts[r].strides,a=o.length,s=`offsetToIndices_${n}`;t[s]=new R(e.offsetToIndicesSingle(s,a,i)),s=`offsetToIndices_${n}_T`,t[s]=new R(e.offsetToIndicesSingle(s,a,i.slice().reverse()))})),t}static offsetToIndicesSingle(e,t,n){let r=[];for(let e=0;e<t-1;++e)r.push(`\n      indices[${e}] = offset / ${n[e]};`),r.push(`\n        offset -= indices[${e}] * ${n[e]};`);return r.push(`\n      indices[${t-1}] = offset;`),`\n      void ${e}(int offset, out int indices[${t}]) {\n        ${r.join("")}\n      }\n      `}incrementIndices(){let e={};return this.context.programInfo.inputNames.forEach(((t,n)=>{let r=this.context.inputTextureLayouts[n].shape,o=r.length,i=`incrementIndices_${t}`,a="";for(let e=0;e<o;++e)a+=`\n        shape[${e}] = ${r[e]};`;let s=`\n        void ${i}(int axis, out int indices[${o}]) {\n          int shape[${o}];\n          ${a};\n          for(int i = ${o} -1 ; i >= 0; --i) {\n            if(i > axis) continue;\n            indices[i] += 1;\n            if(indices[i] < shape[i]) {\n              break;\n            }\n            indices[i] = 0;\n          }\n        }\n        `;e[i]=new R(s)})),e}}})),bo,ip=L((()=>{Vt(),bo=class extends pt{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let e=this.context.outputTextureLayout.shape.length,t={add:"+=",sub:"-=",mul:"*=",div:"/="},n={};for(let r in t){let o=`${r}Vec`,i="";for(let n=0;n<e;++n)i+=`\n          dest[${n}] ${t[r]} src[${n}];\n          `;let a=`\n        void ${o}(int src[${e}], out int dest[${e}]) {\n          ${i}\n        }\n        `;n[o]=new R(a)}return n}copyVec(){let e=this.context.outputTextureLayout.shape.length,t="";for(let n=0;n<e;++n)t+=`\n        dest[${n}] = src[${n}];\n        `;return{copyVec:new R(`\n      void copyVec(int src[${e}], out int dest[${e}]) {\n        ${t}\n      }\n      `)}}setVecItem(){let e=this.context.outputTextureLayout.shape.length,t=`\n        if(index < 0)\n            index =${e} + index;\n        if (index == 0)\n            m[0] = value;\n        `;for(let n=1;n<e-1;++n)t+=`\n        else if (index == ${n})\n            m[${n}] = value;\n            `;return t+=`\n        else\n            m[${e-1}] = value;\n        `,{setVecItem:new R(`\n      void setVecItem(out int m[${e}], int index, int value) {\n        ${t}\n      }\n        `)}}getVecItem(){let e=this.context.outputTextureLayout.shape.length,t=`\n        if(index < 0)\n            index = ${e} + index;\n        if (index == 0)\n            return m[0];\n      `;for(let n=1;n<e-1;++n)t+=`\n        else if (index == ${n})\n            return m[${n}];\n      `;return t+=`\n        else\n            return m[${e-1}];\n        `,{getVecItem:new R(`\n      int getVecItem(int m[${e}], int index) {\n        ${t}\n      }\n    `)}}}})),ji,ap=L((()=>{tp(),rp(),np(),op(),ip(),ji={encoding:po,fragcolor:ho,vec:bo,shapeUtils:mo,coordinates:co}})),go,sp=L((()=>{Vt(),Qc(),ap(),xe(),go=class{constructor(e,t,n,r){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new eo(e,t,n,r),Object.keys(ji).forEach((e=>{let t=new ji[e](this.context);this.libs[e]=t}));let o=this.glslLibRoutineDependencyGraph;for(let e in this.libs){let t=this.libs[e].getFunctions();for(let n in t){let r,i=e+"."+n;o[i]?(r=o[i],r.routineBody=t[n].routineBody):(r=new cn(i,t[n].routineBody),o[i]=r);let a=t[n].dependencies;if(a)for(let e=0;e<a.length;++e)if(o[a[e]])r.addDependency(o[a[e]]);else{let t=new cn(a[e]);o[a[e]]=t,r.addDependency(t)}}}}preprocess(){let e=this.context.programInfo,t=e.shaderSource;return this.context.programInfo.hasMain||(t=`${t}\n      ${Gu(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),t=Zc(t),`${Mu(this.context.glContext.version)}\n    ${this.getUniforms(e.inputNames,e.variables)}\n    ${this.getImports(t)}\n    ${t}`}getImports(e){let t=this.selectGlslLibRoutinesToBeIncluded(e);if(0===t.length)return"";let n="";for(let e=0;e<t.length;++e){if(!t[e].routineBody)throw new Error(`Missing body for the Glsl Library routine: ${t[e].name}`);n+=t[e].routineBody+"\n"}return n}selectGlslLibRoutinesToBeIncluded(e){let t=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach((n=>{let r=n.split(".")[1];-1!==e.indexOf(r)&&t.push(this.glslLibRoutineDependencyGraph[n])})),to.returnOrderedNodes(t)}getUniforms(e,t){let n=[];if(e)for(let t of e)n.push(`uniform sampler2D ${t};`);if(t)for(let e of t)n.push(`uniform ${e.type} ${e.name}${e.arrayLength?`[${e.arrayLength}]`:""};`);return n.join("\n")}}})),yo,up=L((()=>{vt(),ut(),sp(),xe(),yo=class{constructor(e,t,n){this.profiler=e,this.glContext=t,this.textureLayoutStrategy=n,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,t){this.repo.set(e,t)}run(e,t,n){this.profiler.event("op",`ProgramManager.run ${e.programInfo.name??"unknown kernel"}`,(()=>{let r=this.glContext.gl,o=e.program;r.useProgram(o);try{this.bindOutput(n),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,e.programInfo.variables??[],t)}catch(t){throw ce.error("ProgramManager",e.programInfo.shaderSource),t}this.profiler.event("backend","GlContext.draw()",(()=>{this.glContext.draw()}))}),this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach((e=>this.glContext.deleteProgram(e.program)))}build(e,t,n){return this.profiler.event("backend","ProgramManager.build",(()=>{let r=new go(this.glContext,e,t,n),o=r.preprocess(),i=this.compile(o);return{programInfo:e,program:i,uniformLocations:this.getUniformLocations(i,r.context.programInfo.inputNames,r.context.programInfo.variables),attribLocations:this.getAttribLocations(i)}}))}compile(e){if(!this.vertexShader){ce.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let e=Ru(this.glContext.version);this.vertexShader=this.glContext.compileShader(e,this.glContext.gl.VERTEX_SHADER)}Z.debug&&ce.verbose("ProrgramManager",`FragShader:\n${e}\n`);let t=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),n=this.glContext.createProgram(this.vertexShader,t);return this.glContext.deleteShader(t),n}bindOutput(e){let t=e.width,n=e.height;ce.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${t}/${n}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,t,n)}bindAttributes(e){let t=e.position,n=e.textureCoord;this.glContext.setVertexAttributes(t,n),this.attributesBound=!0}bindUniforms(e,t,n){let r=this.glContext.gl,o=0;for(let{name:i,type:a,location:s,arrayLength:u}of e){let e=t.find((e=>e.name===i))?.data;if("sampler2D"!==a&&!e)throw new Error(`variable '${i}' does not have data defined in program info`);switch(a){case"sampler2D":this.bindTexture(n[o],s,o),o++;break;case"float":u?r.uniform1fv(s,e):r.uniform1f(s,e);break;case"int":u?r.uniform1iv(s,e):r.uniform1i(s,e);break;default:throw new Error(`Uniform not implemented: ${a}`)}}}bindTexture(e,t,n){this.glContext.bindTextureToUniform(e.texture,n,t)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,t,n){let r=[];if(t)for(let n of t)r.push({name:n,type:"sampler2D",location:this.getUniformLocation(e,n)});if(n)for(let t of n)r.push({...t,location:this.getUniformLocation(e,t.name)});return r}getUniformLocation(e,t){let n=this.glContext.gl.getUniformLocation(e,t);if(null===n)throw new Error(`Uniform ${t} not found.`);return n}getAttribLocation(e,t){return this.glContext.gl.getAttribLocation(e,t)}}})),To,lp=L((()=>{ut(),ln(),To=class{constructor(e,t,n,r){this.glContext=e,this.layoutStrategy=t,this.profiler=n,this.config=r,this.pendingRead=new Map,r.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,t,n,r){let o=this.toEncoderType(e),i=this.glContext.getEncoder(o,t.channels||1,r);if(t.isPacked&&1===r)throw new Error("not implemented");let a,s,u=t.width,l=t.height;if(this.config.reuseTextures){a=`${u}x${l}_${i.format}_${i.internalFormat}_${i.textureType}`,s=this.inUseTextures.get(a),s||(s=[],this.inUseTextures.set(a,s));let t=this.idleTextures.get(a);if(t&&t.length>0){let o=t.pop();return s.push(o),1===r&&this.glContext.updateTexture(o,u,l,i,this.toTextureData(e,n)),o}}ce.verbose("TextureManager",`Creating new texture of size ${t.width}x${t.height}`);let c=this.glContext.allocateTexture(u,l,i,this.toTextureData(e,n));return this.config.reuseTextures&&(s.push(c),this.textureLookup.set(c,a)),c}readTexture(e,t,n){return n||(n=1),this.profiler.event("backend","TextureManager.readTexture",(()=>{let r=e.shape.reduce(((e,t)=>e*t))*n,o=this.glContext.readTexture(e.texture,e.width,e.height,r,this.toEncoderType(t),n);return this.toTensorData(t,o)}))}async readTextureAsync(e,t,n){let r=e.tensor.dataId;if(n||(n=1),this.pendingRead.has(r)){let e=this.pendingRead.get(r);return new Promise((t=>e?.push(t)))}return this.profiler.event("backend","TextureManager.readTextureAsync",(async()=>{this.pendingRead.set(r,[]);let o=e.shape.reduce(((e,t)=>e*t))*n;await this.glContext.createAndWaitForFence();let i=this.glContext.readTexture(e.texture,e.width,e.height,o,this.toEncoderType(t),n),a=this.toTensorData(t,i),s=this.pendingRead.get(r);return this.pendingRead.delete(r),s?.forEach((e=>e(a))),a}))}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",(()=>{let t=e.shape.reduce(((e,t)=>e*t)),n=this.glContext.readTexture(e.texture,e.width,e.height,4*t,"byte",4);return new Float32Array(n.buffer,n.byteOffset,t)}))}releaseTexture(e,t){let n;if(this.config.reuseTextures&&(n=this.textureLookup.get(e.texture),n)){t&&this.textureLookup.delete(n);let r=this.inUseTextures.get(n);if(r){let t=r.indexOf(e.texture);if(-1!==t){r.splice(t,1);let o=this.idleTextures.get(n);o||(o=[],this.idleTextures.set(n,o)),o.push(e.texture)}}}(!n||t)&&(ce.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,t){switch(e){case"int16":return t instanceof Int16Array?t:Int16Array.from(t);case"int32":return t instanceof Int32Array?t:Int32Array.from(t);case"int8":return t instanceof Int8Array?t:Int8Array.from(t);case"uint16":return t instanceof Uint16Array?t:Uint16Array.from(t);case"uint32":return t instanceof Uint32Array?t:Uint32Array.from(t);case"uint8":case"bool":return t instanceof Uint8Array?t:Uint8Array.from(t);case"float32":return t instanceof Float32Array?t:Float32Array.from(t);case"float64":return t instanceof Float64Array?t:Float64Array.from(t);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,t){if(t)return t instanceof Float32Array?t:new Float32Array(t)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}})),xo,fp=L((()=>{ut(),Os(),tl(),Kc(),up(),qi(),lp(),xo=class{constructor(e,t){this.backend=e,this.context=t,this.layoutStrategy=new fo(e.glContext.maxTextureSize),this.programManager=new yo(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new To(e.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:"full"===e.textureCacheMode}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=e.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new Qn(this)}onGraphInitialized(e){let t=e.getValues().filter((e=>-1===e.from&&e.tensor)).map((e=>e.tensor.dataId));this.initializers=new Set(t)}isInitializer(e){return!!this.initializers&&this.initializers.has(e)}addInitializer(e){this.initializers.add(e)}getTextureData(e,t){return t?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,t,n=!1){ce.verbose("WebGLSessionHandler","Storing Texture data in cache"),n?this.packedTextureDataCache.set(e,t):this.unpackedTextureDataCache.set(e,t)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach((e=>this.textureManager.releaseTexture(e,!0))),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach((e=>this.textureManager.releaseTexture(e,!0))),this.unpackedTextureDataCache=new Map}resolve(e,t,n){let r=_s(e,t,Xc);return{impl:r.opImpl,context:r.opInit?r.opInit(e,n):e}}}}));function Hb(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}var hn,cp=L((()=>{vt(),ln(),ln(),Ft(),hn=class{constructor(e,t){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=e,this.version=t,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,t,n,r){let o=this.gl,i=o.createTexture();o.bindTexture(o.TEXTURE_2D,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);let a=r?n.encode(r,e*t):null;return o.texImage2D(o.TEXTURE_2D,0,n.internalFormat,e,t,0,n.format,n.textureType,a),this.checkError(),i}updateTexture(e,t,n,r,o){let i=this.gl;i.bindTexture(i.TEXTURE_2D,e);let a=r.encode(o,t*n);i.texSubImage2D(i.TEXTURE_2D,0,0,0,t,n,r.format,r.textureType,a),this.checkError()}attachFramebuffer(e,t,n){let r=this.gl;r.bindTexture(r.TEXTURE_2D,e),r.bindFramebuffer(r.FRAMEBUFFER,this.framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),this.checkError(),r.viewport(0,0,t,n),r.scissor(0,0,t,n)}readTexture(e,t,n,r,o,i){let a=this.gl;i||(i=1),this.frameBufferBound||this.attachFramebuffer(e,t,n);let s=this.getEncoder(o,i),u=s.allocate(t*n);return a.bindTexture(a.TEXTURE_2D,e),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e,0),a.readPixels(0,0,t,n,a.RGBA,s.textureType,u),this.checkError(),s.decode(u,r)}isFramebufferReady(){return!0}getActiveTexture(){let e=this.gl;return"TEXTURE"+(e.getParameter(this.gl.ACTIVE_TEXTURE)-e.TEXTURE0)}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(e,t){let n=this.gl;n.vertexAttribPointer(e,3,n.FLOAT,!1,20,0),n.enableVertexAttribArray(e),-1!==t&&(n.vertexAttribPointer(t,2,n.FLOAT,!1,20,12),n.enableVertexAttribArray(t)),this.checkError()}createProgram(e,t){let n=this.gl,r=n.createProgram();return n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),r}compileShader(e,t){let n=this.gl,r=n.createShader(t);if(!r)throw new Error(`createShader() returned null with type ${t}`);if(n.shaderSource(r,e),n.compileShader(r),!1===n.getShaderParameter(r,n.COMPILE_STATUS))throw new Error(`Failed to compile shader: ${n.getShaderInfoLog(r)}\nShader source:\n${e}`);return r}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,t,n){let r=this.gl;r.activeTexture(r.TEXTURE0+t),this.checkError(),r.bindTexture(r.TEXTURE_2D,e),this.checkError(),r.uniform1i(n,t),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(Z.debug){let e=this.gl,t=e.getError(),n="";switch(t){case e.NO_ERROR:return;case e.INVALID_ENUM:n="INVALID_ENUM";break;case e.INVALID_VALUE:n="INVALID_VALUE";break;case e.INVALID_OPERATION:n="INVALID_OPERATION";break;case e.INVALID_FRAMEBUFFER_OPERATION:n="INVALID_FRAMEBUFFER_OPERATION";break;case e.OUT_OF_MEMORY:n="OUT_OF_MEMORY";break;case e.CONTEXT_LOST_WEBGL:n="CONTEXT_LOST_WEBGL";break;default:n=`Unknown WebGL Error: ${t.toString(16)}`}throw new Error(n)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,t,n=0){if(2===this.version)return new Jn(this.gl,t);switch(e){case"float":return 1===n||this.isRenderFloat32Supported?new un(this.gl,t):new un(this.gl,t,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new Zn(this.gl,t);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){let e=this.gl;for(let t=0;t<this.maxTextureImageUnits;++t)e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,null)}dispose(){if(this.disposed)return;let e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(this.framebuffer),e.bindBuffer(e.ARRAY_BUFFER,null),e.deleteBuffer(this.vertexbuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){let e=this.gl,t=e.createBuffer();if(!t)throw new Error("createBuffer() returned null");let n=this.createDefaultGeometry();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),this.checkError(),t}createFramebuffer(){let e=this.gl.createFramebuffer();if(!e)throw new Error("createFramebuffer returned null");return e}queryVitalParameters(){let e=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),1===this.version&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){2===this.version?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){let e=this.gl,t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);let n=2===this.version?e.RGBA32F:e.RGBA;e.texImage2D(e.TEXTURE_2D,0,n,1,1,0,e.RGBA,e.FLOAT,null);let r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0);let o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(t),e.deleteFramebuffer(r),o}checkRenderFloat32(){if(2===this.version){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(2===this.version){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){let e,t,n,r,o,i=this.gl;try{e=i.createTexture(),t=i.createFramebuffer(),i.bindTexture(i.TEXTURE_2D,e);let a=2===this.version?i.RGBA32F:i.RGBA;return i.texImage2D(i.TEXTURE_2D,0,a,1,1,0,i.RGBA,i.FLOAT,null),i.bindFramebuffer(i.FRAMEBUFFER,t),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.enable(i.BLEND),n=i.createShader(i.VERTEX_SHADER),!!(n&&(i.shaderSource(n,"void main(){}"),i.compileShader(n),r=i.createShader(i.FRAGMENT_SHADER),r)&&(i.shaderSource(r,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),i.compileShader(r),o=i.createProgram(),o))&&(i.attachShader(o,n),i.attachShader(o,r),i.linkProgram(o),i.useProgram(o),i.drawArrays(i.POINTS,0,1),i.getError()===i.NO_ERROR)}finally{i.disable(i.BLEND),o&&i.deleteProgram(o),n&&i.deleteShader(n),r&&i.deleteShader(r),t&&(i.bindFramebuffer(i.FRAMEBUFFER,null),i.deleteFramebuffer(t)),e&&(i.bindTexture(i.TEXTURE_2D,null),i.deleteTexture(e))}}beginTimer(){if(2===this.version&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,t=this.disjointTimerQueryWebgl2Extension,n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(2!==this.version||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{let e=this.gl,t=this.disjointTimerQueryWebgl2Extension;e.endQuery(t.TIME_ELAPSED_EXT)}}isTimerResultAvailable(e){let t=!1,n=!1;if(2!==this.version||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{let r=this.gl,o=this.disjointTimerQueryWebgl2Extension;t=r.getQueryParameter(e,r.QUERY_RESULT_AVAILABLE),n=r.getParameter(o.GPU_DISJOINT_EXT)}return t&&!n}getTimerResult(e){let t=0;if(2!==this.version)throw new Error("WebGL1 profiling currently not supported");{let n=this.gl;t=n.getQueryParameter(e,n.QUERY_RESULT),n.deleteQuery(e)}return t/1e6}async waitForQueryAndGetTime(e){return await yi((()=>this.isTimerResultAvailable(e))),this.getTimerResult(e)}async createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n=e,r=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),t=null===r?()=>!0:()=>{let e=n.clientWaitSync(r,0,0);return e===n.ALREADY_SIGNALED||e===n.CONDITION_SATISFIED},{query:r,isFencePassed:t}}async pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){let e=Hb(this.itemsToPoll.map((e=>e.isDoneFn)));for(let t=0;t<=e;++t){let{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),!(this.itemsToPoll.length>1)&&await yi((()=>(this.pollItems(),0===this.itemsToPoll.length)))}}}));function Yi(e){let t;if(e&&"webgl2"!==e||!("webgl2"in Ur)?(!e||"webgl"===e)&&"webgl"in Ur&&(t=Ur.webgl):t=Ur.webgl2,!t)try{t=pp(jb(),e)}catch{t=pp(qb(),e)}e=e||1===t.version?"webgl":"webgl2";let n=t.gl;return Ur[e]=t,n.isContextLost()?(delete Ur[e],Yi(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),t)}function pp(e,t){let n,r={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!t||"webgl2"===t)&&(n=e.getContext("webgl2",r),n))try{return new hn(n,2)}catch(e){ce.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${e}`)}if((!t||"webgl"===t)&&(n=e.getContext("webgl",r)||e.getContext("experimental-webgl",r),n))try{return new hn(n,1)}catch(e){ce.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${e}`)}throw new Error("WebGL is not supported")}function qb(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let e=document.createElement("canvas");return e.width=1,e.height=1,e}function jb(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var Ur,dp=L((()=>{ut(),cp(),Ur={}})),vo,hp=L((()=>{vt(),ut(),fp(),dp(),vo=class{get contextId(){return Z.webgl.contextId}set contextId(e){Z.webgl.contextId=e}get matmulMaxBatchSize(){return Z.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){Z.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return Z.webgl.textureCacheMode}set textureCacheMode(e){Z.webgl.textureCacheMode=e}get pack(){return Z.webgl.pack}set pack(e){Z.webgl.pack=e}get async(){return Z.webgl.async}set async(e){Z.webgl.async=e}initialize(){try{return this.glContext=Yi(this.contextId),"number"!=typeof this.matmulMaxBatchSize&&(this.matmulMaxBatchSize=16),"string"!=typeof this.textureCacheMode&&(this.textureCacheMode="full"),"boolean"!=typeof this.pack&&(this.pack=!1),"boolean"!=typeof this.async&&(this.async=!1),ce.setWithEnv(Z),Z.webgl.context||Object.defineProperty(Z.webgl,"context",{value:this.glContext.gl}),ce.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return ce.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new xo(this,e)}dispose(){this.glContext.dispose()}}}));async function Xi(e){if(!e)return Xi(["webgl"]);{let t="string"==typeof e?[e]:e;for(let e of t){let t=mp.get(e);if(t)return t;let n=await Xb(e);if(n)return n}}throw new Error("no available backend to use")}async function Xb(e){let t=Yb;if(typeof t[e]<"u"&&Kb(t[e])){let n=t[e],r=n.initialize();if("object"==typeof r&&"then"in r&&(r=await r),r)return mp.set(e,n),n}}function Kb(e){let t=e;return"initialize"in t&&"function"==typeof t.initialize&&"createSessionHandler"in t&&"function"==typeof t.createSessionHandler&&"dispose"in t&&"function"==typeof t.dispose}var mp,Yb,bp=L((()=>{hp(),mp=new Map,Yb={webgl:new vo}})),Ki,wo,gp=L((()=>{ut(),Ki=class{constructor(e,t){this.op=e,this.node=t}},wo=class{constructor(e,t,n){this.graph=e,this.profiler=n,this.initialize(t)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",(()=>{let t=this.graph.getNodes();if(t.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map(((e,n)=>new Ki(e,t[n]))),this.reset(),this._starter=[],this._ops.forEach(((e,t)=>{let n=!0;for(let t of e.node.inputs)if(!this._values[t]&&-1===this.graph.getInputIndices().indexOf(t)){n=!1;break}n&&this._starter.push(t)}))}))}reset(){this._values=this.graph.getValues().map((e=>e.tensor))}async execute(e,t){return this.profiler.event("session","ExecutionPlan.execute",(async()=>{this.reset();let n=e.createInferenceHandler(),r=this.graph.getInputIndices();if(t.length!==r.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${t.length} expected: ${r.length}`);t.forEach(((e,t)=>{let n=r[t];this._values[n]=e}));let o=this._starter.slice(0),i=this.graph.getValues(),a=this.graph.getNodes(),s=0;for(;s<o.length;){let e=o[s++],t=this._ops[e],r=t.node.inputs.map((e=>this._values[e]));if(-1!==r.indexOf(void 0))throw new Error(`unresolved input detected: op: ${t.node}`);let u=r;ce.verbose("ExecPlan",`Runing op:${t.node.name} (${u.map(((e,n)=>`'${t.node.inputs[n]}': ${e.type}[${e.dims.join(",")}]`)).join(", ")})`);let l=await this.profiler.event("node",t.node.name,(async()=>t.op.impl(n,u,t.op.context)));if(l.length!==t.node.outputs.length)throw new Error("the size of output does not match model definition.");l.forEach(((e,n)=>{let r=t.node.outputs[n];if(this._values[r])throw new Error(`output [${r}] already has value: op:${t.node.name}`);this._values[r]=e}));let c=new Set;l.forEach(((e,n)=>{let r=t.node.outputs[n];for(let e of i[r].to){let t=a[e],n=!0;for(let e of t.inputs)if(!this._values[e]){n=!1;break}n&&c.add(e)}})),o.push(...c)}let u=[];for(let e=0;e<this.graph.getOutputIndices().length;e++){let t=this.graph.getOutputIndices()[e],n=this._values[t];if(void 0===n)throw new Error(`required output [${t}] does not have value`);0===t?await n.getData():n.data,u.push(n)}return ce.verbose("ExecPlan","disposing of inferenceHandler"),n.dispose(),u}))}}})),oe,mt,mn,yp=L((()=>{tn(),oe=Er($r()),br(),fe(),mt=W.experimental.fbs,mn=class e{constructor(t){if(this._attributes=new Map,null!=t){for(let n of t)n instanceof oe.onnx.AttributeProto?this._attributes.set(n.name,[e.getValue(n),e.getType(n)]):n instanceof mt.Attribute&&this._attributes.set(n.name(),[e.getValue(n),e.getType(n)]);if(this._attributes.size<t.length)throw new Error("duplicated attribute names")}}set(e,t,n){this._attributes.set(e,[n,t])}delete(e){this._attributes.delete(e)}getFloat(e,t){return this.get(e,"float",t)}getInt(e,t){return this.get(e,"int",t)}getString(e,t){return this.get(e,"string",t)}getTensor(e,t){return this.get(e,"tensor",t)}getFloats(e,t){return this.get(e,"floats",t)}getInts(e,t){return this.get(e,"ints",t)}getStrings(e,t){return this.get(e,"strings",t)}getTensors(e,t){return this.get(e,"tensors",t)}get(e,t,n){let r=this._attributes.get(e);if(void 0===r){if(void 0!==n)return n;throw new Error(`required attribute not found: ${e}`)}if(r[1]!==t)throw new Error(`type mismatch: expected ${t} but got ${r[1]}`);return r[0]}static getType(e){let t=e instanceof oe.onnx.AttributeProto?e.type:e.type();switch(t){case oe.onnx.AttributeProto.AttributeType.FLOAT:return"float";case oe.onnx.AttributeProto.AttributeType.INT:return"int";case oe.onnx.AttributeProto.AttributeType.STRING:return"string";case oe.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case oe.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case oe.onnx.AttributeProto.AttributeType.INTS:return"ints";case oe.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case oe.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${oe.onnx.AttributeProto.AttributeType[t]}`)}}static getValue(e){let t=e instanceof oe.onnx.AttributeProto?e.type:e.type();if(t===oe.onnx.AttributeProto.AttributeType.GRAPH||t===oe.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let n=this.getValueNoCheck(e);if(t===oe.onnx.AttributeProto.AttributeType.INT&&nt.isLong(n))return nt.longToNumber(n);if(t===oe.onnx.AttributeProto.AttributeType.INTS){let e=n,t=new Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=nt.longToNumber(r)}return t}if(t===oe.onnx.AttributeProto.AttributeType.TENSOR)return e instanceof oe.onnx.AttributeProto?Fe.fromProto(n):Fe.fromOrtTensor(n);if(t===oe.onnx.AttributeProto.AttributeType.TENSORS){if(e instanceof oe.onnx.AttributeProto)return n.map((e=>Fe.fromProto(e)));if(e instanceof mt.Attribute)return n.map((e=>Fe.fromOrtTensor(e)))}return t===oe.onnx.AttributeProto.AttributeType.STRING&&e instanceof oe.onnx.AttributeProto?sn(n):t===oe.onnx.AttributeProto.AttributeType.STRINGS&&e instanceof oe.onnx.AttributeProto?n.map(sn):n}static getValueNoCheck(e){return e instanceof oe.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(e):this.getValueNoCheckFromOrtFormat(e)}static getValueNoCheckFromOnnxFormat(e){switch(e.type){case oe.onnx.AttributeProto.AttributeType.FLOAT:return e.f;case oe.onnx.AttributeProto.AttributeType.INT:return e.i;case oe.onnx.AttributeProto.AttributeType.STRING:return e.s;case oe.onnx.AttributeProto.AttributeType.TENSOR:return e.t;case oe.onnx.AttributeProto.AttributeType.GRAPH:return e.g;case oe.onnx.AttributeProto.AttributeType.FLOATS:return e.floats;case oe.onnx.AttributeProto.AttributeType.INTS:return e.ints;case oe.onnx.AttributeProto.AttributeType.STRINGS:return e.strings;case oe.onnx.AttributeProto.AttributeType.TENSORS:return e.tensors;case oe.onnx.AttributeProto.AttributeType.GRAPHS:return e.graphs;default:throw new Error(`unsupported attribute type: ${oe.onnx.AttributeProto.AttributeType[e.type]}`)}}static getValueNoCheckFromOrtFormat(e){switch(e.type()){case mt.AttributeType.FLOAT:return e.f();case mt.AttributeType.INT:return e.i();case mt.AttributeType.STRING:return e.s();case mt.AttributeType.TENSOR:return e.t();case mt.AttributeType.GRAPH:return e.g();case mt.AttributeType.FLOATS:return e.floatsArray();case mt.AttributeType.INTS:{let t=[];for(let n=0;n<e.intsLength();n++)t.push(e.ints(n));return t}case mt.AttributeType.STRINGS:{let t=[];for(let n=0;n<e.stringsLength();n++)t.push(e.strings(n));return t}case mt.AttributeType.TENSORS:{let t=[];for(let n=0;n<e.tensorsLength();n++)t.push(e.tensors(n));return t}default:throw new Error(`unsupported attribute type: ${mt.AttributeType[e.type()]}`)}}}})),Zi,_o,Qi,kt,Oo,Ji,Tp=L((()=>{yp(),tn(),Zi=Er($r()),br(),fe(),_o=W.experimental.fbs,Qi={from:(e,t)=>new Ji(e,t)},kt=class{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=Ve.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}},Oo=class{constructor(e,t){e instanceof Zi.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new mn(e.attribute)):e instanceof _o.Node&&(this.name=t??e.name(),this.opType=e.opType(),this.attributes=new mn(Ve.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Ji=class{constructor(e,t){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(t),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(e){if(e instanceof Zi.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else{if(!(e instanceof _o.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(e)}}buildGraphFromOnnxFormat(e){let t=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let n=new Map;if(!e.input)throw new Error("missing information in graph: input");let r=[];for(let n of e.input){if(t.has(n.name))throw new Error(`duplicated input name: ${n.name}`);let e=this._allData.push(new kt(n))-1;t.set(n.name,e),r.push(n.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(let n of e.initializer){let e=t.get(n.name);if(void 0===e){let r=new kt;r.type={shape:{dims:Ve.tensorDimsFromProto(n.dims)},tensorType:Ve.tensorDataTypeFromProto(n.dataType)},e=this._allData.push(r)-1,t.set(n.name,e)}this._allData[e]._from=-1,this._allData[e].tensor=Fe.fromProto(n)}for(let e=0;e<this._allData.length;e++)this._allData[e].tensor||(this._allInputIndices.push(e),this._allInputNames.push(r[e]));if(!e.output)throw new Error("missing information in graph: output");for(let n of e.output){if(t.has(n.name))throw new Error(`duplicated output name: ${n.name}`);let e=this._allData.push(new kt(n))-1;t.set(n.name,e),this._allOutputIndices.push(e),this._allOutputNames.push(n.name)}if(!e.node)throw new Error("missing information in graph: node");for(let t of e.node){if(!t.name)for(let e=0;;e++){let r=`unnamed_${t.opType}_${e}`;if(!n.has(r)){t.name=r;break}}if(n.has(t.name))throw new Error(`duplicated node name: ${t.name}`);let e=this._nodes.push(new Oo(t))-1;n.set(t.name,e)}for(let n=0;n<this._nodes.length;n++){let r=this._nodes[n],o=e.node[n];if(!o.output)throw new Error(`missing output for node: ${o.name}`);for(let e of o.output){let i=t.get(e);if(typeof i>"u"&&(i=this._allData.push(new kt)-1,t.set(e,i)),r.outputs.push(i),void 0!==this._allData[i]._from)throw new Error(`multiple nodes output to one data value: ${i}`);if(this._allData[i]._from=n,"Constant"===o.opType){if(!o.attribute||1!==o.attribute.length||!o.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!o.output||1!==o.output.length)throw new Error("missing output or incorrect number of outputs for this Constant operator");r.outputs.pop(),r.executeNode=!1,this._allData[i]._from=-1,this._allData[i].tensor=Fe.fromProto(o.attribute[0].t)}}}for(let n=0;n<this._nodes.length;n++){let r=this._nodes[n],o=e.node[n];if(!o.input)throw new Error(`missing input for node: ${o.name}`);for(let e of o.input){let i=t.get(e);if(typeof i>"u"){if(""===e&&(3===o.input.length||4===o.input.length)&&"Resize"===o.opType)continue;throw new Error(`unrecognized input '${e}' for node: ${o.name}`)}r.inputs.push(i),this._allData[i]._to.push(n)}}return!0}buildGraphFromOrtFormat(e){let t=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let n=new Map,r=[];for(let n=0;n<e.inputsLength();n++){let o=e.inputs(n);if(t.has(o))throw new Error(`duplicated input name: ${o}`);for(let n=0;n<e.nodeArgsLength();n++)if(e.nodeArgs(n)?.name()===o){let i=new kt;if(e.nodeArgs(n)?.type()?.valueType()!==_o.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let a=e.nodeArgs(n).type().value(new _o.TensorTypeAndShape),s=Ve.tensorDataTypeFromProto(a.elemType()),u=a.shape(),l=[];for(let e=0;e<u.dimLength();e++)l.push(nt.longToNumber(u.dim(e).value().dimValue()));i.type={shape:{dims:l},tensorType:s};let c=this._allData.push(i)-1;t.set(o,c),r.push(o)}}for(let n=0;n<e.initializersLength();n++){let r=e.initializers(n),o=t.get(r.name());if(void 0===o){let e=new kt,n=Ve.tensorDimsFromORTFormat(r),i=Ve.tensorDataTypeFromProto(r.dataType());e.type={shape:{dims:n},tensorType:i},o=this._allData.push(e)-1,t.set(r.name(),o)}this._allData[o]._from=-1,this._allData[o].tensor=Fe.fromOrtTensor(r)}for(let e=0;e<this._allData.length;e++)this._allData[e].tensor||(this._allInputIndices.push(e),this._allInputNames.push(r[e]));for(let n=0;n<e.outputsLength();n++){let r=e.outputs(n);if(t.has(r))throw new Error(`duplicated output name: ${r}`);let o=this._allData.push(new kt)-1;t.set(r,o),this._allOutputIndices.push(o),this._allOutputNames.push(r)}if(!e.nodes)throw new Error("missing information in graph: node");for(let t=0;t<e.nodesLength();t++){let r=e.nodes(t),o=r.name();if(!o)for(let e=0;o=`unnamed_${r.opType()}_${e}`,n.has(o);e++);if(n.has(o))throw new Error(`duplicated node name: ${o}`);let i=this._nodes.push(new Oo(r,o))-1;n.set(o,i)}for(let n=0;n<this._nodes.length;n++){let r=this._nodes[n],o=e.nodes(n);if(null==o)throw new Error(`No node exists at index ${n}`);if(0===o?.outputsLength())throw new Error(`missing output for node: ${o.name}`);for(let e=0;e<o?.outputsLength();e++){let i=o?.outputs(e),a=t.get(i);if(typeof a>"u"&&(a=this._allData.push(new kt)-1,t.set(i,a)),r.outputs.push(a),void 0!==this._allData[a]._from)throw new Error(`multiple nodes output to one data value: ${a}`);if(this._allData[a]._from=n,"Constant"===o.opType()){if(1!==o.attributesLength()||!o.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(1!==o.outputsLength())throw new Error("missing output or incorrect number of outputs for this Constant operator");r.outputs.pop(),r.executeNode=!1,this._allData[a]._from=-1,this._allData[a].tensor=Fe.fromOrtTensor(o.attributes(0).t())}}}for(let n=0;n<this._nodes.length;n++){let r=this._nodes[n],o=e.nodes(n);if(0===o.inputsLength())throw new Error(`missing input for node: ${o.name}`);for(let e=0;e<o.inputsLength();e++){let i=o.inputs(e),a=t.get(i);if(typeof a>"u")throw new Error(`unrecognized input '${i}' for node: ${o.name()}`);r.inputs.push(a),this._allData[a]._to.push(n)}}}checkIsAcyclic(){let e=new Set;this._allInputIndices.forEach((t=>{this._allData[t]._to.forEach((t=>{e.add(t)}))}));let t=Array.from(e),n=new Array(this._nodes.length).fill("white");for(;t.length>0;){let e=t.pop();"gray"===n[e]?n[e]="black":(t.push(e),n[e]="gray",this._nodes[e].outputs.forEach((r=>{let o=this._allData[r];if(typeof o.tensor<"u")throw new Error("node outputs should not be initialized");if(o._from!==e)throw new Error("from property of the Value object doesn't match index of Node being processed");o._to.forEach((e=>{if("gray"===n[e])throw new Error("model graph is cyclic");"white"===n[e]&&t.push(e)}))})))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0,t=new Array(this._nodes.length,0),n=0;for(let e=0;e<this._nodes.length;e++)t[e]=n,this._nodes[e].executeNode?(n!==e&&(this._nodes[n]=this._nodes[e]),n++):this._nodes[e].outputs.forEach((e=>{this._allData[e]._from=-2}));this._nodes.splice(n,this._nodes.length-n);for(let e=0;e<this._allData.length;e++){let n=this._allData[e];void 0!==n._from&&-1!==n._from&&-2!==n._from&&(n._from=t[n._from]);for(let e=0;e<n._to.length;e++){if(!(n._to[e]>=0))throw new Error("Trying to update a removed node");n._to[e]=t[n._to[e]]}}e=0;for(let t=0;t<this._allData.length;t++)if(-2!==this._allData[t].from||-1!==this._allOutputIndices.indexOf(t+e)){if(e>0){let n=-1;void 0!==this._allData[t].from&&-1!==this._allData[t].from?(n=this._nodes[this._allData[t].from].outputs.indexOf(t+e),-1!==n&&(this._nodes[this._allData[t].from].outputs[n]=t)):(n=this._allInputIndices.indexOf(t+e),-1!==n&&(this._allInputIndices[n]=t)),this._allData[t].to.forEach((r=>{n=this._nodes[r].inputs.indexOf(t+e),-1!==n&&(this._nodes[r].inputs[n]=t)})),0===this._allData[t].to.length&&(n=this._allOutputIndices.indexOf(t+e),-1!==n&&(this._allOutputIndices[n]=t))}}else e++,this._allData.splice(t,1),t--}deleteNode(e){let t=this._nodes[e];if(t.outputs.length>1)for(let e=1;e<t.outputs.length;e++)if(this._allData[t.outputs[e]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ");t.executeNode=!1;let n=t.inputs[0],r=t.outputs[0],o=this._allData[r].to;for(let n=0;n<t.inputs.length;n++){let r=this._allData[t.inputs[n]].to.indexOf(e);if(-1===r)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[t.inputs[n]].to.splice(r,1)}this._allData[r]._to=[];let i=this._allOutputIndices.indexOf(r);if(-1!==i&&(this._allOutputIndices[i]=n),o&&o.length>0)for(let e of o){let t=this._nodes[e].inputs.indexOf(r);if(-1===t)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[e].inputs[t]=n,this._allData[n].to.push(e)}}removeAllDropoutNodes(){let e=0;for(let t of this._nodes){if("Dropout"===t.opType){if(1!==t.inputs.length)throw new Error("Dropout nodes should only contain one input. ");if(1!==t.outputs.length&&2!==t.outputs.length)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(2===t.outputs.length&&0!==this._allData[t.outputs[1]]._to.length)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(e)}e++}}removeAllIdentityNodes(){let e=0;for(let t of this._nodes)"Identity"===t.opType&&this.deleteNode(e),e++}isActivation(e){switch(e.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(let e of this._nodes)if("Conv"===e.opType){let t=this._allData[e.outputs[0]]._to;if(1===t.length&&this.isActivation(this._nodes[t[0]])){let n=this._nodes[t[0]];if("Clip"===n.opType)if(1===n.inputs.length)try{e.attributes.set("activation_params","floats",[n.attributes.getFloat("min"),n.attributes.getFloat("max")])}catch{e.attributes.set("activation_params","floats",[hr,mr])}else{if(!(n.inputs.length>=3&&void 0!==this._allData[n.inputs[1]].tensor&&void 0!==this._allData[n.inputs[2]].tensor))continue;e.attributes.set("activation_params","floats",[this._allData[n.inputs[1]].tensor.floatData[0],this._allData[n.inputs[2]].tensor.floatData[0]])}e.attributes.set("activation","string",n.opType),this.deleteNode(t[0])}}}}})),xp,Jb,Io,vp=L((()=>{Wn(),Tp(),tn(),xp=Er($r()),fe(),Jb=W.experimental.fbs,Io=class{constructor(){}load(e,t,n){if(!n)try{return void this.loadFromOnnxFormat(e,t)}catch(e){if(void 0!==n)throw e}this.loadFromOrtFormat(e,t)}loadFromOnnxFormat(e,t){let n=xp.onnx.ModelProto.decode(e);if(nt.longToNumber(n.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=n.opsetImport.map((e=>({domain:e.domain,version:nt.longToNumber(e.version)}))),this._graph=Qi.from(n.graph,t)}loadFromOrtFormat(e,t){let n=new _.ByteBuffer(e),r=Jb.InferenceSession.getRootAsInferenceSession(n).model();if(nt.longToNumber(r.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let e=0;e<r.opsetImportLength();e++){let t=r.opsetImport(e);this._opsets.push({domain:t?.domain(),version:nt.longToNumber(t.version())})}this._graph=Qi.from(r.graph(),t)}get graph(){return this._graph}get opsets(){return this._opsets}}})),So,wp=L((()=>{bp(),gp(),ut(),vp(),So=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=zn.create(e.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(e,t,n){await this.profiler.event("session","Session.loadModel",(async()=>{let r=await Xi(this.backendHint);if(this.sessionHandler=r.createSessionHandler(this.context),this._model=new Io,"string"==typeof e){let t=e.endsWith(".ort");if(typeof process<"u"&&process.versions&&process.versions.node){let n=await(void 0)(e);this.initialize(n,t)}else{let n=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(n),t)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{let r=new Uint8Array(e,t||0,n||e.byteLength);this.initialize(r)}}))}initialize(e,t){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",(()=>{let n=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,n,t),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new wo(this._model.graph,this._ops,this.profiler)})),this._initialized=!0}async run(e){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",(async()=>{let t=this.normalizeAndValidateInputs(e),n=await this._executionPlan.execute(this.sessionHandler,t);return this.createOutput(n)}))}normalizeAndValidateInputs(e){let t=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==t.length)throw new Error(`incorrect input array length: expected ${t.length} but got ${e.length}`)}else{if(e.size!==t.length)throw new Error(`incorrect input map size: expected ${t.length} but got ${e.size}`);let n=new Array(e.size),r=0;for(let o=0;o<t.length;++o){let i=e.get(t[o]);if(!i)throw new Error(`missing input tensor for: '${name}'`);n[r++]=i}e=n}if(this.context.graphInputTypes&&0!==this.context.graphInputTypes.length&&this.context.graphInputDims&&0!==this.context.graphInputDims.length)this.validateInputTensorDims(this.context.graphInputDims,e,!1);else{let t=this._model.graph.getInputIndices(),n=this._model.graph.getValues(),r=new Array(t.length);for(let o=0;o<t.length;++o){let i=n[t[o]];r[o]=i.type.shape.dims,this.context.graphInputTypes.push(i.type.tensorType),this.context.graphInputDims.push(e[o].dims)}this.validateInputTensorDims(r,e,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,e),e}validateInputTensorTypes(e,t){for(let n=0;n<t.length;n++){let r=e[n],o=t[n].type;if(r!==o)throw new Error(`input tensor[${n}] check failed: expected type '${r}' but got ${o}`)}}validateInputTensorDims(e,t,n){for(let r=0;r<t.length;r++){let o=e[r],i=t[r].dims;if(!this.compareTensorDims(o,i,n))throw new Error(`input tensor[${r}] check failed: expected shape '[${o.join(",")}]' but got [${i.join(",")}]`)}}compareTensorDims(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r]&&(!n||0!==e[r]))return!1;return!0}createOutput(e){let t=this._model.graph.getOutputNames();if(e.length!==t.length)throw new Error("expected number of outputs do not match number of generated outputs");let n=new Map;for(let r=0;r<t.length;++r)n.set(t[r],e[r]);return n}initializeOps(e){let t=e.getNodes();this._ops=new Array(t.length);for(let n=0;n<t.length;n++)this._ops[n]=this.sessionHandler.resolve(t[n],this._model.opsets,e)}}})),Ao,_p=L((()=>{vt(),br(),Ao=class{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,t,n){let r=new Map;for(let t in e)if(Object.hasOwnProperty.call(e,t)){let n=e[t];r.set(t,new Fe(n.dims,n.type,void 0,void 0,n.data))}let o=await this.session.run(r),i={};return o.forEach(((e,t)=>{i[t]=new ke(e.type,e.data,e.dims)})),i}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}})),Op={};ar(Op,{onnxjsBackend:()=>Qb});var ea,Qb,Ip=L((()=>{wp(),_p(),Qb=new(ea=class{async init(){}async createInferenceSessionHandler(e,t){let n=new So(t);return await n.loadModel(e),new Ao(n)}})})),ta={};ar(ta,{createReadStream:()=>Sp,readFile:()=>eg,readFileSync:()=>tg});var eg,tg,Sp,ra=L((()=>{eg=void 0,tg=void 0,Sp=void 0})),na={};ar(na,{join:()=>rg});var rg,oa=L((()=>{rg=void 0})),Ep=me(((e,t)=>{var n,r=(n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(n=n||__filename),function(e={}){var t,r,o=e;o.ready=new Promise(((e,n)=>{t=e,r=n}));var i,a,s,u=Object.assign({},o),l="./this.program",c="object"==typeof window,p="function"==typeof importScripts,d="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="";if(d){var h=(ra(),jt(ta)),g=(oa(),jt(na));f=p?g.dirname(f)+"/":__dirname+"/",i=(e,t)=>(e=C(e)?new URL(e):g.normalize(e),h.readFileSync(e,t?void 0:"utf8")),s=e=>((e=i(e,!0)).buffer||(e=new Uint8Array(e)),e),a=(e,t,n,r=!0)=>{e=C(e)?new URL(e):g.normalize(e),h.readFile(e,r?void 0:"utf8",((e,o)=>{e?n(e):t(r?o.buffer:o)}))},!o.thisProgram&&1<process.argv.length&&(l=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),o.inspect=()=>"[Emscripten Module object]"}else(c||p)&&(p?f=self.location.href:typeof document<"u"&&document.currentScript&&(f=document.currentScript.src),n&&(f=n),f=0!==f.indexOf("blob:")?f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},p&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),a=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var m=console.log.bind(console),b=console.error.bind(console);Object.assign(o,u),u=null,"object"!=typeof WebAssembly&&N("no native wasm support detected");var y,w,_,v,x,T,O=!1;function S(){var e=y.buffer;o.HEAP8=w=new Int8Array(e),o.HEAP16=new Int16Array(e),o.HEAPU8=_=new Uint8Array(e),o.HEAPU16=new Uint16Array(e),o.HEAP32=v=new Int32Array(e),o.HEAPU32=x=new Uint32Array(e),o.HEAPF32=new Float32Array(e),o.HEAPF64=T=new Float64Array(e)}var E=[],A=[],I=[],P=0,$=null,D=null;function N(e){throw b(e="Aborted("+e+")"),O=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),r(e),e}var F,k=e=>e.startsWith("data:application/octet-stream;base64,"),C=e=>e.startsWith("file://");if(!k(F="ort-wasm.wasm")){var R=F;F=o.locateFile?o.locateFile(R,f):f+R}function L(e){if(s)return s(e);throw"both async and sync fetching of the wasm failed"}function M(e,t,n){return function(e){if(c||p){if("function"==typeof fetch&&!C(e))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>L(e)));if(a)return new Promise(((t,n)=>{a(e,(e=>t(new Uint8Array(e))),n)}))}return Promise.resolve().then((()=>L(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(n,(e=>{b(`failed to asynchronously prepare wasm: ${e}`),N(e)}))}var j,B={919888:(e,t,n,r)=>{if(typeof o>"u"||!o.za)return 1;if((e=H(e>>>0)).startsWith("./")&&(e=e.substring(2)),!(e=o.za.get(e)))return 2;if((t>>>=0)+(n>>>=0)>e.byteLength)return 3;try{return _.set(e.subarray(t,t+n),r>>>0>>>0),0}catch{return 4}}};function U(e){this.xa=e-24,this.Ha=function(e){x[this.xa+4>>>2>>>0]=e},this.Ga=function(e){x[this.xa+8>>>2>>>0]=e},this.Aa=function(e,t){this.Fa(),this.Ha(e),this.Ga(t)},this.Fa=function(){x[this.xa+16>>>2>>>0]=0}}var V,z=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,G=(e,t,n)=>{var r=(t>>>=0)+n;for(n=t;e[n]&&!(n>=r);)++n;if(16<n-t&&e.buffer&&z)return z.decode(e.subarray(t,n));for(r="";t<n;){var o=e[t++];if(128&o){var i=63&e[t++];if(192==(224&o))r+=String.fromCharCode((31&o)<<6|i);else{var a=63&e[t++];65536>(o=224==(240&o)?(15&o)<<12|i<<6|a:(7&o)<<18|i<<12|a<<6|63&e[t++])?r+=String.fromCharCode(o):(o-=65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else r+=String.fromCharCode(o)}return r},H=(e,t)=>(e>>>=0)?G(_,e,t):"",W=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t},q=(e,t,n,r)=>{if(!(0<r))return 0;var o=n>>>=0;r=n+r-1;for(var i=0;i<e.length;++i){var a=e.charCodeAt(i);if(55296<=a&&57343>=a&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i)),127>=a){if(n>=r)break;t[n++>>>0]=a}else{if(2047>=a){if(n+1>=r)break;t[n++>>>0]=192|a>>6}else{if(65535>=a){if(n+2>=r)break;t[n++>>>0]=224|a>>12}else{if(n+3>=r)break;t[n++>>>0]=240|a>>18,t[n++>>>0]=128|a>>12&63}t[n++>>>0]=128|a>>6&63}t[n++>>>0]=128|63&a}}return t[n>>>0]=0,n-o},X=e=>e%4==0&&(e%100!=0||e%400==0),Y=[0,31,60,91,121,152,182,213,244,274,305,335],Z=[0,31,59,90,120,151,181,212,243,273,304,334],K=e=>{var t=W(e)+1,n=ue(t);return n&&q(e,_,n,t),n},J=[],Q={},ee=()=>{if(!V){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(e in Q)void 0===Q[e]?delete t[e]:t[e]=Q[e];var n=[];for(e in t)n.push(`${e}=${t[e]}`);V=n}return V},te=[null,[],[]],ne=[31,29,31,30,31,30,31,31,30,31,30,31],re=[31,28,31,30,31,30,31,31,30,31,30,31];function oe(e,t,n,r){function o(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function i(e,t){return o(e,t,"0")}function a(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function s(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){var t=e.ta;for(e=new Date(new Date(e.ua+1900,0,1).getTime());0<t;){var n=e.getMonth(),r=(X(e.getFullYear())?ne:re)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return n=new Date(e.getFullYear()+1,0,4),t=s(new Date(e.getFullYear(),0,4)),n=s(n),0>=a(t,e)?0>=a(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}e>>>=0,t>>>=0,n>>>=0;var l=x[40+(r>>>=0)>>>2>>>0];for(var c in r={Da:v[r>>>2>>>0],Ca:v[r+4>>>2>>>0],va:v[r+8>>>2>>>0],ya:v[r+12>>>2>>>0],wa:v[r+16>>>2>>>0],ua:v[r+20>>>2>>>0],oa:v[r+24>>>2>>>0],ta:v[r+28>>>2>>>0],Ia:v[r+32>>>2>>>0],Ba:v[r+36>>>2>>>0],Ea:l?H(l):""},n=H(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(c,"g"),l[c]);var p="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(c in l={"%a":e=>p[e.oa].substring(0,3),"%A":e=>p[e.oa],"%b":e=>d[e.wa].substring(0,3),"%B":e=>d[e.wa],"%C":e=>i((e.ua+1900)/100|0,2),"%d":e=>i(e.ya,2),"%e":e=>o(e.ya,2," "),"%g":e=>u(e).toString().substring(2),"%G":e=>u(e),"%H":e=>i(e.va,2),"%I":e=>(0==(e=e.va)?e=12:12<e&&(e-=12),i(e,2)),"%j":e=>{for(var t=0,n=0;n<=e.wa-1;t+=(X(e.ua+1900)?ne:re)[n++]);return i(e.ya+t,3)},"%m":e=>i(e.wa+1,2),"%M":e=>i(e.Ca,2),"%n":()=>"\n","%p":e=>0<=e.va&&12>e.va?"AM":"PM","%S":e=>i(e.Da,2),"%t":()=>"\t","%u":e=>e.oa||7,"%U":e=>i(Math.floor((e.ta+7-e.oa)/7),2),"%V":e=>{var t=Math.floor((e.ta+7-(e.oa+6)%7)/7);if(2>=(e.oa+371-e.ta-2)%7&&t++,t)53==t&&(4==(n=(e.oa+371-e.ta)%7)||3==n&&X(e.ua)||(t=1));else{t=52;var n=(e.oa+7-e.ta-1)%7;(4==n||5==n&&X(e.ua%400-1))&&t++}return i(t,2)},"%w":e=>e.oa,"%W":e=>i(Math.floor((e.ta+7-(e.oa+6)%7)/7),2),"%y":e=>(e.ua+1900).toString().substring(2),"%Y":e=>e.ua+1900,"%z":e=>(0<=(e=e.Ba)?"+":"-")+("0000"+((e=Math.abs(e)/60)/60*100+e%60)).slice(-4),"%Z":e=>e.Ea,"%%":()=>"%"},n=n.replace(/%%/g,"\0\0"),l)n.includes(c)&&(n=n.replace(new RegExp(c,"g"),l[c](r)));return c=function(e){var t=Array(W(e)+1);return q(e,t,0,t.length),t}(n=n.replace(/\0\0/g,"%")),c.length>t?0:(w.set(c,e>>>0),c.length-1)}var ie={a:function(e,t,n){throw new U(e>>>=0).Aa(t>>>0,n>>>0),e},e:function(){return 0},H:function(){},x:function(){},z:function(){},J:function(){return 0},F:function(){},A:function(){},E:function(){},g:function(){},y:function(){},v:function(){},G:function(){},w:function(){},k:()=>1,n:function(e,t,n){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,n>>>=0,e=new Date(1e3*e),v[n>>>2>>>0]=e.getUTCSeconds(),v[n+4>>>2>>>0]=e.getUTCMinutes(),v[n+8>>>2>>>0]=e.getUTCHours(),v[n+12>>>2>>>0]=e.getUTCDate(),v[n+16>>>2>>>0]=e.getUTCMonth(),v[n+20>>>2>>>0]=e.getUTCFullYear()-1900,v[n+24>>>2>>>0]=e.getUTCDay(),v[n+28>>>2>>>0]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(e,t,n){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,n>>>=0,e=new Date(1e3*e),v[n>>>2>>>0]=e.getSeconds(),v[n+4>>>2>>>0]=e.getMinutes(),v[n+8>>>2>>>0]=e.getHours(),v[n+12>>>2>>>0]=e.getDate(),v[n+16>>>2>>>0]=e.getMonth(),v[n+20>>>2>>>0]=e.getFullYear()-1900,v[n+24>>>2>>>0]=e.getDay(),v[n+28>>>2>>>0]=(X(e.getFullYear())?Y:Z)[e.getMonth()]+e.getDate()-1|0,v[n+36>>>2>>>0]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();v[n+32>>>2>>>0]=0|(t!=r&&e.getTimezoneOffset()==Math.min(r,t))},p:function(e){e>>>=0;var t=new Date(v[e+20>>>2>>>0]+1900,v[e+16>>>2>>>0],v[e+12>>>2>>>0],v[e+8>>>2>>>0],v[e+4>>>2>>>0],v[e>>>2>>>0],0),n=v[e+32>>>2>>>0],r=t.getTimezoneOffset(),o=new Date(t.getFullYear(),6,1).getTimezoneOffset(),i=new Date(t.getFullYear(),0,1).getTimezoneOffset(),a=Math.min(i,o);return 0>n?v[e+32>>>2>>>0]=+(o!=i&&a==r):0<n!=(a==r)&&(o=Math.max(i,o),t.setTime(t.getTime()+6e4*((0<n?a:o)-r))),v[e+24>>>2>>>0]=t.getDay(),v[e+28>>>2>>>0]=(X(t.getFullYear())?Y:Z)[t.getMonth()]+t.getDate()-1|0,v[e>>>2>>>0]=t.getSeconds(),v[e+4>>>2>>>0]=t.getMinutes(),v[e+8>>>2>>>0]=t.getHours(),v[e+12>>>2>>>0]=t.getDate(),v[e+16>>>2>>>0]=t.getMonth(),v[e+20>>>2>>>0]=t.getYear(),e=t.getTime(),isNaN(e)?(v[se()>>>2>>>0]=61,e=-1):e/=1e3,ce((j=e,1<=+Math.abs(j)?0<j?+Math.floor(j/4294967296)>>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)),e>>>0},l:function(){return-52},m:function(){},t:function(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}n>>>=0;var o=(new Date).getFullYear(),i=new Date(o,0,1),a=new Date(o,6,1);o=i.getTimezoneOffset();var s=a.getTimezoneOffset();x[e>>>0>>>2>>>0]=60*Math.max(o,s),v[t>>>0>>>2>>>0]=+(o!=s),e=r(i),t=r(a),e=K(e),t=K(t),s<o?(x[n>>>2>>>0]=e,x[n+4>>>2>>>0]=t):(x[n>>>2>>>0]=t,x[n+4>>>2>>>0]=e)},d:()=>{N("")},B:function(e,t,n){e>>>=0,t>>>=0,n>>>=0,J.length=0;for(var r;r=_[t++>>>0];){var o=105!=r;n+=(o&=112!=r)&&n%8?4:0,J.push(112==r?x[n>>>2>>>0]:105==r?v[n>>>2>>>0]:T[n>>>3>>>0]),n+=o?8:4}return B[e].apply(null,J)},h:()=>Date.now(),u:function(){return 4294901760},b:()=>performance.now(),I:function(e,t,n){return t>>>=0,_.copyWithin(e>>>0>>>0,t>>>0,t+(n>>>0)>>>0)},s:function(e){e>>>=0;var t=_.length;if(4294901760<e)return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var o=Math;r=Math.max(e,r);e:{o=(o.min.call(o,4294901760,r+(65536-r%65536)%65536)-y.buffer.byteLength+65535)/65536;try{y.grow(o),S();var i=1;break e}catch{}i=void 0}if(i)return!0}return!1},C:function(e,t){e>>>=0,t>>>=0;var n=0;return ee().forEach(((r,o)=>{var i=t+n;for(o=x[e+4*o>>>2>>>0]=i,i=0;i<r.length;++i)w[o++>>>0>>>0]=r.charCodeAt(i);w[o>>>0>>>0]=0,n+=r.length+1})),0},D:function(e,t){e>>>=0,t>>>=0;var n=ee();x[e>>>2>>>0]=n.length;var r=0;return n.forEach((e=>r+=e.length+1)),x[t>>>2>>>0]=r,0},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(e,t,n,r){t>>>=0,n>>>=0,r>>>=0;for(var o=0,i=0;i<n;i++){var a=x[t>>>2>>>0],s=x[t+4>>>2>>>0];t+=8;for(var u=0;u<s;u++){var l=_[a+u>>>0],c=te[e];0===l||10===l?((1===e?m:b)(G(c,0)),c.length=0):c.push(l)}o+=s}return x[r>>>2>>>0]=o,0},r:oe,c:function(e,t,n,r){return oe(e>>>0,t>>>0,n>>>0,r>>>0)}},ae=function(){function e(e){return ae=e.exports,ae=function(){var e=ae;e=Object.assign({},e);var t=e=>()=>e()>>>0,n=e=>t=>e(t)>>>0;return e.la=t(e.la),e.ma=n(e.ma),e.qa=t(e.qa),e.sa=n(e.sa),e}(),y=ae.K,S(),A.unshift(ae.L),0==--P&&(null!==$&&(clearInterval($),$=null),D&&(e=D,D=null,e())),ae}var t={a:ie};if(P++,o.instantiateWasm)try{return o.instantiateWasm(t,e)}catch(e){b(`Module.instantiateWasm callback failed with error: ${e}`),r(e)}return function(e,t){var n=F;return"function"!=typeof WebAssembly.instantiateStreaming||k(n)||C(n)||d||"function"!=typeof fetch?M(n,e,t):fetch(n,{credentials:"same-origin"}).then((r=>WebAssembly.instantiateStreaming(r,e).then(t,(function(r){return b(`wasm streaming compile failed: ${r}`),b("falling back to ArrayBuffer instantiation"),M(n,e,t)}))))}(t,(function(t){e(t.instance)})).catch(r),{}}();o._OrtInit=(e,t)=>(o._OrtInit=ae.M)(e,t),o._OrtGetLastError=(e,t)=>(o._OrtGetLastError=ae.N)(e,t),o._OrtCreateSessionOptions=(e,t,n,r,i,a,s,u,l,c)=>(o._OrtCreateSessionOptions=ae.O)(e,t,n,r,i,a,s,u,l,c),o._OrtAppendExecutionProvider=(e,t)=>(o._OrtAppendExecutionProvider=ae.P)(e,t),o._OrtAddFreeDimensionOverride=(e,t,n)=>(o._OrtAddFreeDimensionOverride=ae.Q)(e,t,n),o._OrtAddSessionConfigEntry=(e,t,n)=>(o._OrtAddSessionConfigEntry=ae.R)(e,t,n),o._OrtReleaseSessionOptions=e=>(o._OrtReleaseSessionOptions=ae.S)(e),o._OrtCreateSession=(e,t,n)=>(o._OrtCreateSession=ae.T)(e,t,n),o._OrtReleaseSession=e=>(o._OrtReleaseSession=ae.U)(e),o._OrtGetInputOutputCount=(e,t,n)=>(o._OrtGetInputOutputCount=ae.V)(e,t,n),o._OrtGetInputName=(e,t)=>(o._OrtGetInputName=ae.W)(e,t),o._OrtGetOutputName=(e,t)=>(o._OrtGetOutputName=ae.X)(e,t),o._OrtFree=e=>(o._OrtFree=ae.Y)(e),o._OrtCreateTensor=(e,t,n,r,i,a)=>(o._OrtCreateTensor=ae.Z)(e,t,n,r,i,a),o._OrtGetTensorData=(e,t,n,r,i)=>(o._OrtGetTensorData=ae._)(e,t,n,r,i),o._OrtReleaseTensor=e=>(o._OrtReleaseTensor=ae.$)(e),o._OrtCreateRunOptions=(e,t,n,r)=>(o._OrtCreateRunOptions=ae.aa)(e,t,n,r),o._OrtAddRunConfigEntry=(e,t,n)=>(o._OrtAddRunConfigEntry=ae.ba)(e,t,n),o._OrtReleaseRunOptions=e=>(o._OrtReleaseRunOptions=ae.ca)(e),o._OrtCreateBinding=e=>(o._OrtCreateBinding=ae.da)(e),o._OrtBindInput=(e,t,n)=>(o._OrtBindInput=ae.ea)(e,t,n),o._OrtBindOutput=(e,t,n,r)=>(o._OrtBindOutput=ae.fa)(e,t,n,r),o._OrtClearBoundOutputs=e=>(o._OrtClearBoundOutputs=ae.ga)(e),o._OrtReleaseBinding=e=>(o._OrtReleaseBinding=ae.ha)(e),o._OrtRunWithBinding=(e,t,n,r,i)=>(o._OrtRunWithBinding=ae.ia)(e,t,n,r,i),o._OrtRun=(e,t,n,r,i,a,s,u)=>(o._OrtRun=ae.ja)(e,t,n,r,i,a,s,u),o._OrtEndProfiling=e=>(o._OrtEndProfiling=ae.ka)(e);var se=()=>(se=ae.la)(),ue=o._malloc=e=>(ue=o._malloc=ae.ma)(e);o._free=e=>(o._free=ae.na)(e);var le,ce=e=>(ce=ae.pa)(e),pe=()=>(pe=ae.qa)(),de=e=>(de=ae.ra)(e),fe=e=>(fe=ae.sa)(e);function he(){if(!(0<P)){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;){var e=o.preRun.shift();E.unshift(e)}for(;0<E.length;)E.shift()(o);if(!(0<P||le||(le=!0,o.calledRun=!0,O))){for(;0<A.length;)A.shift()(o);for(t(o);0<I.length;)I.shift()(o)}}}return o.stackAlloc=fe,o.stackSave=pe,o.stackRestore=de,o.UTF8ToString=H,o.stringToUTF8=(e,t,n)=>q(e,_,t,n),o.lengthBytesUTF8=W,D=function e(){le||he(),le||(D=e)},he(),e.ready});"object"==typeof e&&"object"==typeof t?t.exports=r:"function"==typeof define&&define.amd&&define([],(()=>r))})),Dp=me((()=>{})),Lp=me((()=>{})),Fp={};ar(Fp,{cpus:()=>ng});var ng,$p=L((()=>{ng=void 0})),Bp=me(((e,t)=>{var n,r=(n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(n=n||__filename),function(e={}){function t(){return I.buffer!=D.buffer&&L(),D}function r(){return I.buffer!=D.buffer&&L(),N}function o(){return I.buffer!=D.buffer&&L(),F}function i(){return I.buffer!=D.buffer&&L(),k}function a(){return I.buffer!=D.buffer&&L(),C}var s,u,l=e;l.ready=new Promise(((e,t)=>{s=e,u=t}));var c,p,d,f=Object.assign({},l),h="./this.program",g=(e,t)=>{throw t},m="object"==typeof window,b="function"==typeof importScripts,y="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,w=l.ENVIRONMENT_IS_PTHREAD||!1,_="";function v(e){return l.locateFile?l.locateFile(e,_):_+e}if(y){var x=(ra(),jt(ta)),T=(oa(),jt(na));let e;_=b?T.dirname(_)+"/":__dirname+"/",c=(e,t)=>(e=Y(e)?new URL(e):T.normalize(e),x.readFileSync(e,t?void 0:"utf8")),d=e=>((e=c(e,!0)).buffer||(e=new Uint8Array(e)),e),p=(e,t,n,r=!0)=>{e=Y(e)?new URL(e):T.normalize(e),x.readFile(e,r?void 0:"utf8",((e,o)=>{e?n(e):t(r?o.buffer:o)}))},!l.thisProgram&&1<process.argv.length&&(h=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),g=(e,t)=>{throw process.exitCode=e,t},l.inspect=()=>"[Emscripten Module object]";try{e=Dp()}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}global.Worker=e.Worker}else(m||b)&&(b?_=self.location.href:typeof document<"u"&&document.currentScript&&(_=document.currentScript.src),typeof n<"u"&&n&&(_=n),_=0!==_.indexOf("blob:")?_.substr(0,_.replace(/[?#].*/,"").lastIndexOf("/")+1):"",y||(c=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},b&&(d=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),p=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)}));y&&typeof performance>"u"&&(global.performance=Lp().performance);var O=console.log.bind(console),S=console.error.bind(console);y&&(O=(...e)=>x.writeSync(1,e.join(" ")+"\n"),S=(...e)=>x.writeSync(2,e.join(" ")+"\n"));var E=O,A=S;Object.assign(l,f),f=null,"object"!=typeof WebAssembly&&W("no native wasm support detected");var I,P,$,D,N,F,k,C,R=!1;function L(){var e=I.buffer;l.HEAP8=D=new Int8Array(e),l.HEAP16=new Int16Array(e),l.HEAPU8=N=new Uint8Array(e),l.HEAPU16=new Uint16Array(e),l.HEAP32=F=new Int32Array(e),l.HEAPU32=k=new Uint32Array(e),l.HEAPF32=new Float32Array(e),l.HEAPF64=C=new Float64Array(e)}var M=16777216;if(w)I=l.wasmMemory;else if(l.wasmMemory)I=l.wasmMemory;else if(!((I=new WebAssembly.Memory({initial:M/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw A("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),y&&A("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");L(),M=I.buffer.byteLength;var j=[],B=[],U=[],V=0,z=null,G=null;function H(){if(0==--V&&(null!==z&&(clearInterval(z),z=null),G)){var e=G;G=null,e()}}function W(e){throw A(e="Aborted("+e+")"),R=!0,$=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),u(e),e}var q,X=e=>e.startsWith("data:application/octet-stream;base64,"),Y=e=>e.startsWith("file://");function Z(e){if(d)return d(e);throw"both async and sync fetching of the wasm failed"}function K(e,t,n){return function(e){if(m||b){if("function"==typeof fetch&&!Y(e))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>Z(e)));if(p)return new Promise(((t,n)=>{p(e,(e=>t(new Uint8Array(e))),n)}))}return Promise.resolve().then((()=>Z(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(n,(e=>{A(`failed to asynchronously prepare wasm: ${e}`),W(e)}))}X(q="ort-wasm-threaded.wasm")||(q=v(q));var J,Q={921276:(e,t,n,o)=>{if(typeof l>"u"||!l.cb)return 1;if((e=ae(e>>>0)).startsWith("./")&&(e=e.substring(2)),!(e=l.cb.get(e)))return 2;if(o>>>=0,(t>>>=0)+(n>>>=0)>e.byteLength)return 3;try{return r().set(e.subarray(t,t+n),o>>>0),0}catch{return 4}}};function ee(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var te=e=>{e.terminate(),e.onmessage=()=>{}},ne=e=>{0==fe.Pa.length&&(de(),fe.Ya(fe.Pa[0]));var t=fe.Pa.pop();if(!t)return 6;fe.Qa.push(t),fe.Ma[e.Oa]=t,t.Oa=e.Oa;var n={cmd:"run",start_routine:e.kb,arg:e.hb,pthread_ptr:e.Oa};return y&&t.unref(),t.postMessage(n,e.qb),0},re=0,oe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ie=(e,t,n)=>{var r=(t>>>=0)+n;for(n=t;e[n]&&!(n>=r);)++n;if(16<n-t&&e.buffer&&oe)return oe.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,n):e.subarray(t,n));for(r="";t<n;){var o=e[t++];if(128&o){var i=63&e[t++];if(192==(224&o))r+=String.fromCharCode((31&o)<<6|i);else{var a=63&e[t++];65536>(o=224==(240&o)?(15&o)<<12|i<<6|a:(7&o)<<18|i<<12|a<<6|63&e[t++])?r+=String.fromCharCode(o):(o-=65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else r+=String.fromCharCode(o)}return r},ae=(e,t)=>(e>>>=0)?ie(r(),e,t):"",se=e=>{var t=_t();return e=e(),vt(t),e};function ue(e,t){var n=arguments.length-2,r=arguments;return se((()=>{for(var o=xt(8*n),i=o>>>3,s=0;s<n;s++){var u=r[2+s];a()[i+s>>>0]=u}return ht(e,n,o,t)}))}function le(e){if(w)return ue(0,1,e);$=e,0<re||(fe.lb(),l.onExit?.(e),R=!0),g(e,new ee(e))}var ce=e=>{if($=e,w)throw ge(e),"unwind";le(e)};function pe(){for(var e=l.numThreads;e--;)de();j.unshift((()=>{V++,function(e){w?e():Promise.all(fe.Pa.map(fe.Ya)).then(e)}((()=>H()))}))}function de(){var e=v("ort-wasm-threaded.worker.js");e=new Worker(e),fe.Pa.push(e)}var fe={Pa:[],Qa:[],bb:[],Ma:{},Wa(){w?(fe.receiveObjectTransfer=fe.jb,fe.threadInitTLS=fe.ab,fe.setExitStatus=fe.$a):pe()},$a:e=>$=e,tb:["$terminateWorker"],lb:()=>{for(var e of fe.Qa)te(e);for(e of fe.Pa)te(e);fe.Pa=[],fe.Qa=[],fe.Ma=[]},Za:e=>{var t=e.Oa;delete fe.Ma[t],fe.Pa.push(e),fe.Qa.splice(fe.Qa.indexOf(e),1),e.Oa=0,gt(t)},jb(){},ab(){fe.bb.forEach((e=>e()))},Ya:e=>new Promise((t=>{e.onmessage=n=>{var r=(n=n.data).cmd;if(n.targetThread&&n.targetThread!=ct()){var o=fe.Ma[n.targetThread];o?o.postMessage(n,n.transferList):A(`Internal error! Worker sent a message "${r}" to target pthread ${n.targetThread}, but that thread no longer exists!`)}else"checkMailbox"===r?Me():"spawnThread"===r?ne(n):"cleanupThread"===r?fe.Za(fe.Ma[n.thread]):"killThread"===r?(n=n.thread,r=fe.Ma[n],delete fe.Ma[n],te(r),gt(n),fe.Qa.splice(fe.Qa.indexOf(r),1),r.Oa=0):"cancelThread"===r?fe.Ma[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(e.loaded=!0,y&&!e.Oa&&e.unref(),t(e)):"alert"===r?alert(`Thread ${n.threadId}: ${n.text}`):"setimmediate"===n.target?e.postMessage(n):"callHandler"===r?l[n.handler](...n.args):r&&A(`worker sent an unknown command ${r}`)},e.onerror=e=>{throw A(`worker sent an error! ${e.filename}:${e.lineno}: ${e.message}`),e},y&&(e.on("message",(t=>e.onmessage({data:t}))),e.on("error",(t=>e.onerror(t))));var r,o=[];for(r of["onExit"])l.hasOwnProperty(r)&&o.push(r);e.postMessage({cmd:"load",handlers:o,urlOrBlob:l.mainScriptUrlOrBlob||n,wasmMemory:I,wasmModule:P})}))};l.PThread=fe;var he=e=>{for(;0<e.length;)e.shift()(l)};function ge(e){if(w)return ue(1,0,e);ce(e)}l.establishStackSpace=()=>{var e=ct(),t=i()[e+52>>>2>>>0];e=i()[e+56>>>2>>>0],wt(t,t-e),vt(t)};var me,be=[];function ye(e){this.Va=e-24,this.gb=function(e){i()[this.Va+4>>>2>>>0]=e},this.fb=function(e){i()[this.Va+8>>>2>>>0]=e},this.Wa=function(e,t){this.eb(),this.gb(e),this.fb(t)},this.eb=function(){i()[this.Va+16>>>2>>>0]=0}}function we(e,t,n,r){return w?ue(2,1,e,t,n,r):_e(e,t,n,r)}function _e(e,t,n,r){if(e>>>=0,t>>>=0,n>>>=0,r>>>=0,typeof SharedArrayBuffer>"u")return A("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var o=[];return w&&0===o.length?we(e,t,n,r):(e={kb:n,Oa:e,hb:r,qb:o},w?(e.sb="spawnThread",postMessage(e,o),0):ne(e))}function ve(e,t,n){return w?ue(3,1,e,t,n):0}function xe(e,t){if(w)return ue(4,1,e,t)}l.invokeEntryPoint=(e,t)=>{var n=be[e];n||(e>=be.length&&(be.length=e+1),be[e]=n=me.get(e)),e=n(t),0<re?fe.$a(e):mt(e)};var Te=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t},Oe=(e,t,n,r)=>{if(!(0<r))return 0;var o=n>>>=0;r=n+r-1;for(var i=0;i<e.length;++i){var a=e.charCodeAt(i);if(55296<=a&&57343>=a&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i)),127>=a){if(n>=r)break;t[n++>>>0]=a}else{if(2047>=a){if(n+1>=r)break;t[n++>>>0]=192|a>>6}else{if(65535>=a){if(n+2>=r)break;t[n++>>>0]=224|a>>12}else{if(n+3>=r)break;t[n++>>>0]=240|a>>18,t[n++>>>0]=128|a>>12&63}t[n++>>>0]=128|a>>6&63}t[n++>>>0]=128|63&a}}return t[n>>>0]=0,n-o},Se=(e,t,n)=>Oe(e,r(),t,n);function Ee(e,t){if(w)return ue(5,1,e,t)}function Ae(e,t,n){if(w)return ue(6,1,e,t,n)}function Ie(e,t,n){return w?ue(7,1,e,t,n):0}function Pe(e,t){if(w)return ue(8,1,e,t)}function $e(e,t,n){if(w)return ue(9,1,e,t,n)}function De(e,t,n,r){if(w)return ue(10,1,e,t,n,r)}function Ne(e,t,n,r){if(w)return ue(11,1,e,t,n,r)}function Fe(e,t,n,r){if(w)return ue(12,1,e,t,n,r)}function ke(e){if(w)return ue(13,1,e)}function Ce(e,t){if(w)return ue(14,1,e,t)}function Re(e,t,n){if(w)return ue(15,1,e,t,n)}function Le(e){e>>>=0,"function"==typeof Atomics.rb&&(Atomics.rb(o(),e>>>2,e).value.then(Me),e+=128,Atomics.store(o(),e>>>2,1))}l.__emscripten_thread_mailbox_await=Le;var Me=()=>{var e=ct();if(e&&(Le(e),e=bt,!R))try{if(e(),!(0<re))try{w?mt($):ce($)}catch(e){e instanceof ee||"unwind"==e||g(1,e)}}catch(e){e instanceof ee||"unwind"==e||g(1,e)}};l.checkMailbox=Me;var je=[],Be=e=>e%4==0&&(e%100!=0||e%400==0),Ue=[0,31,60,91,121,152,182,213,244,274,305,335],Ve=[0,31,59,90,120,151,181,212,243,273,304,334];function ze(e,t,n,r,o,i,a,s){return w?ue(16,1,e,t,n,r,o,i,a,s):-52}function Ge(e,t,n,r,o,i,a){if(w)return ue(17,1,e,t,n,r,o,i,a)}var He,We=e=>{var t=Te(e)+1,n=pt(t);return n&&Se(e,n,t),n},qe=[],Xe={},Ye=()=>{if(!He){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:h||"./this.program"};for(e in Xe)void 0===Xe[e]?delete t[e]:t[e]=Xe[e];var n=[];for(e in t)n.push(`${e}=${t[e]}`);He=n}return He};function Ze(e,n){if(w)return ue(18,1,e,n);e>>>=0,n>>>=0;var r=0;return Ye().forEach(((o,a)=>{var s=n+r;for(a=i()[e+4*a>>>2>>>0]=s,s=0;s<o.length;++s)t()[a++>>>0>>>0]=o.charCodeAt(s);t()[a>>>0>>>0]=0,r+=o.length+1})),0}function Ke(e,t){if(w)return ue(19,1,e,t);e>>>=0,t>>>=0;var n=Ye();i()[e>>>2>>>0]=n.length;var r=0;return n.forEach((e=>r+=e.length+1)),i()[t>>>2>>>0]=r,0}function Je(e){return w?ue(20,1,e):52}function Qe(e,t,n,r){return w?ue(21,1,e,t,n,r):52}function et(e,t,n,r,o){return w?ue(22,1,e,t,n,r,o):70}var tt=[null,[],[]];function nt(e,t,n,o){if(w)return ue(23,1,e,t,n,o);t>>>=0,n>>>=0,o>>>=0;for(var a=0,s=0;s<n;s++){var u=i()[t>>>2>>>0],l=i()[t+4>>>2>>>0];t+=8;for(var c=0;c<l;c++){var p=r()[u+c>>>0],d=tt[e];0===p||10===p?((1===e?E:A)(ie(d,0)),d.length=0):d.push(p)}a+=l}return i()[o>>>2>>>0]=a,0}var rt=[31,29,31,30,31,30,31,31,30,31,30,31],ot=[31,28,31,30,31,30,31,31,30,31,30,31];function it(e,n,r,a){function s(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function u(e,t){return s(e,t,"0")}function l(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function c(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function p(e){var t=e.Ra;for(e=new Date(new Date(e.Sa+1900,0,1).getTime());0<t;){var n=e.getMonth(),r=(Be(e.getFullYear())?rt:ot)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return n=new Date(e.getFullYear()+1,0,4),t=c(new Date(e.getFullYear(),0,4)),n=c(n),0>=l(t,e)?0>=l(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}e>>>=0,n>>>=0,r>>>=0,a>>>=0;var d=i()[a+40>>>2>>>0];for(var f in a={ob:o()[a>>>2>>>0],nb:o()[a+4>>>2>>>0],Ta:o()[a+8>>>2>>>0],Xa:o()[a+12>>>2>>>0],Ua:o()[a+16>>>2>>>0],Sa:o()[a+20>>>2>>>0],Na:o()[a+24>>>2>>>0],Ra:o()[a+28>>>2>>>0],ub:o()[a+32>>>2>>>0],mb:o()[a+36>>>2>>>0],pb:d?ae(d):""},r=ae(r),d={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(f,"g"),d[f]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),g="January February March April May June July August September October November December".split(" ");for(f in d={"%a":e=>h[e.Na].substring(0,3),"%A":e=>h[e.Na],"%b":e=>g[e.Ua].substring(0,3),"%B":e=>g[e.Ua],"%C":e=>u((e.Sa+1900)/100|0,2),"%d":e=>u(e.Xa,2),"%e":e=>s(e.Xa,2," "),"%g":e=>p(e).toString().substring(2),"%G":e=>p(e),"%H":e=>u(e.Ta,2),"%I":e=>(0==(e=e.Ta)?e=12:12<e&&(e-=12),u(e,2)),"%j":e=>{for(var t=0,n=0;n<=e.Ua-1;t+=(Be(e.Sa+1900)?rt:ot)[n++]);return u(e.Xa+t,3)},"%m":e=>u(e.Ua+1,2),"%M":e=>u(e.nb,2),"%n":()=>"\n","%p":e=>0<=e.Ta&&12>e.Ta?"AM":"PM","%S":e=>u(e.ob,2),"%t":()=>"\t","%u":e=>e.Na||7,"%U":e=>u(Math.floor((e.Ra+7-e.Na)/7),2),"%V":e=>{var t=Math.floor((e.Ra+7-(e.Na+6)%7)/7);if(2>=(e.Na+371-e.Ra-2)%7&&t++,t)53==t&&(4==(n=(e.Na+371-e.Ra)%7)||3==n&&Be(e.Sa)||(t=1));else{t=52;var n=(e.Na+7-e.Ra-1)%7;(4==n||5==n&&Be(e.Sa%400-1))&&t++}return u(t,2)},"%w":e=>e.Na,"%W":e=>u(Math.floor((e.Ra+7-(e.Na+6)%7)/7),2),"%y":e=>(e.Sa+1900).toString().substring(2),"%Y":e=>e.Sa+1900,"%z":e=>(0<=(e=e.mb)?"+":"-")+("0000"+((e=Math.abs(e)/60)/60*100+e%60)).slice(-4),"%Z":e=>e.pb,"%%":()=>"%"},r=r.replace(/%%/g,"\0\0"),d)r.includes(f)&&(r=r.replace(new RegExp(f,"g"),d[f](a)));return f=function(e){var t=Array(Te(e)+1);return Oe(e,t,0,t.length),t}(r=r.replace(/\0\0/g,"%")),f.length>n?0:(((e,n)=>{t().set(e,n>>>0)})(f,e),f.length-1)}fe.Wa();var at=[le,ge,we,ve,xe,Ee,Ae,Ie,Pe,$e,De,Ne,Fe,ke,Ce,Re,ze,Ge,Ze,Ke,Je,Qe,et,nt],st={b:function(e,t,n){throw new ye(e>>>=0).Wa(t>>>0,n>>>0),e},L:function(e){dt(e>>>0,!b,1,!m,131072,!1),fe.ab()},j:function(e){e>>>=0,w?postMessage({cmd:"cleanupThread",thread:e}):fe.Za(fe.Ma[e])},H:_e,h:ve,S:xe,D:Ee,F:Ae,T:Ie,Q:Pe,J:$e,P:De,n:Ne,E:Fe,B:ke,R:Ce,C:Re,p:()=>1,z:function(e,t){(e>>>=0)==t>>>0?setTimeout((()=>Me())):w?postMessage({targetThread:e,cmd:"checkMailbox"}):(e=fe.Ma[e])&&e.postMessage({cmd:"checkMailbox"})},I:function(e,t,n,r){t>>>=0,je.length=n,r=r>>>0>>>3;for(var o=0;o<n;o++)je[o]=a()[r+o>>>0];return e=0>e?Q[-e-1]:at[e],fe.ib=t,t=e.apply(null,je),fe.ib=0,t},K:Le,o:function(e){y&&fe.Ma[e>>>0].ref()},s:function(e,t,n){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,n>>>=0,e=new Date(1e3*e),o()[n>>>2>>>0]=e.getUTCSeconds(),o()[n+4>>>2>>>0]=e.getUTCMinutes(),o()[n+8>>>2>>>0]=e.getUTCHours(),o()[n+12>>>2>>>0]=e.getUTCDate(),o()[n+16>>>2>>>0]=e.getUTCMonth(),o()[n+20>>>2>>>0]=e.getUTCFullYear()-1900,o()[n+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,o()[n+28>>>2>>>0]=e},t:function(e,t,n){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,n>>>=0,e=new Date(1e3*e),o()[n>>>2>>>0]=e.getSeconds(),o()[n+4>>>2>>>0]=e.getMinutes(),o()[n+8>>>2>>>0]=e.getHours(),o()[n+12>>>2>>>0]=e.getDate(),o()[n+16>>>2>>>0]=e.getMonth(),o()[n+20>>>2>>>0]=e.getFullYear()-1900,o()[n+24>>>2>>>0]=e.getDay(),t=(Be(e.getFullYear())?Ue:Ve)[e.getMonth()]+e.getDate()-1|0,o()[n+28>>>2>>>0]=t,o()[n+36>>>2>>>0]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(t!=r&&e.getTimezoneOffset()==Math.min(r,t)),o()[n+32>>>2>>>0]=e},u:function(e){e>>>=0;var t=new Date(o()[e+20>>>2>>>0]+1900,o()[e+16>>>2>>>0],o()[e+12>>>2>>>0],o()[e+8>>>2>>>0],o()[e+4>>>2>>>0],o()[e>>>2>>>0],0),n=o()[e+32>>>2>>>0],r=t.getTimezoneOffset(),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=new Date(t.getFullYear(),0,1).getTimezoneOffset(),s=Math.min(a,i);return 0>n?o()[e+32>>>2>>>0]=+(i!=a&&s==r):0<n!=(s==r)&&(i=Math.max(a,i),t.setTime(t.getTime()+6e4*((0<n?s:i)-r))),o()[e+24>>>2>>>0]=t.getDay(),n=(Be(t.getFullYear())?Ue:Ve)[t.getMonth()]+t.getDate()-1|0,o()[e+28>>>2>>>0]=n,o()[e>>>2>>>0]=t.getSeconds(),o()[e+4>>>2>>>0]=t.getMinutes(),o()[e+8>>>2>>>0]=t.getHours(),o()[e+12>>>2>>>0]=t.getDate(),o()[e+16>>>2>>>0]=t.getMonth(),o()[e+20>>>2>>>0]=t.getYear(),e=t.getTime(),isNaN(e)?(o()[lt()>>>2>>>0]=61,e=-1):e/=1e3,yt((J=e,1<=+Math.abs(J)?0<J?+Math.floor(J/4294967296)>>>0:~~+Math.ceil((J-+(~~J>>>0))/4294967296)>>>0:0)),e>>>0},q:ze,r:Ge,y:function(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}e>>>=0,t>>>=0,n>>>=0;var a=(new Date).getFullYear(),s=new Date(a,0,1),u=new Date(a,6,1);a=s.getTimezoneOffset();var l=u.getTimezoneOffset(),c=Math.max(a,l);i()[e>>>2>>>0]=60*c,o()[t>>>2>>>0]=+(a!=l),e=r(s),t=r(u),e=We(e),t=We(t),l<a?(i()[n>>>2>>>0]=e,i()[n+4>>>2>>>0]=t):(i()[n>>>2>>>0]=t,i()[n+4>>>2>>>0]=e)},c:()=>{W("")},O:function(e,t,n){e>>>=0,t>>>=0,n>>>=0,qe.length=0;for(var s;s=r()[t++>>>0];){var u=105!=s;n+=(u&=112!=s)&&n%8?4:0,qe.push(112==s?i()[n>>>2>>>0]:105==s?o()[n>>>2>>>0]:a()[n>>>3>>>0]),n+=u?8:4}return Q[e].apply(null,qe)},k:()=>{},i:()=>Date.now(),U:()=>{throw re+=1,"unwind"},A:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:()=>y?($p(),jt(Fp)).cpus().length:navigator.hardwareConcurrency,x:function(e){e>>>=0;var t=r().length;if(e<=t||4294901760<e)return!1;for(var n=1;4>=n;n*=2){var o=t*(1+.2/n);o=Math.min(o,e+100663296);var i=Math;o=Math.max(e,o);e:{i=(i.min.call(i,4294901760,o+(65536-o%65536)%65536)-I.buffer.byteLength+65535)/65536;try{I.grow(i),L();var a=1;break e}catch{}a=void 0}if(a)return!0}return!1},M:Ze,N:Ke,G:ce,g:Je,m:Qe,v:et,l:nt,a:I||l.wasmMemory,w:it,d:function(e,t,n,r){return it(e>>>0,t>>>0,n>>>0,r>>>0)}},ut=function(){function e(e,t){return ut=e.exports,ut=function(){var e=ut;e=Object.assign({},e);var t=e=>()=>e()>>>0,n=e=>t=>e(t)>>>0;return e.va=t(e.va),e.wa=t(e.wa),e.xa=n(e.xa),e.emscripten_main_runtime_thread_id=t(e.emscripten_main_runtime_thread_id),e.Ja=t(e.Ja),e.La=n(e.La),e}(),fe.bb.push(ut.za),me=ut.Aa,B.unshift(ut.V),P=t,H(),ut}var t={a:st};if(V++,l.instantiateWasm)try{return l.instantiateWasm(t,e)}catch(e){A(`Module.instantiateWasm callback failed with error: ${e}`),u(e)}return function(e,t){var n=q;return"function"!=typeof WebAssembly.instantiateStreaming||X(n)||Y(n)||y||"function"!=typeof fetch?K(n,e,t):fetch(n,{credentials:"same-origin"}).then((r=>WebAssembly.instantiateStreaming(r,e).then(t,(function(r){return A(`wasm streaming compile failed: ${r}`),A("falling back to ArrayBuffer instantiation"),K(n,e,t)}))))}(t,(function(t){e(t.instance,t.module)})).catch(u),{}}();l._OrtInit=(e,t)=>(l._OrtInit=ut.W)(e,t),l._OrtGetLastError=(e,t)=>(l._OrtGetLastError=ut.X)(e,t),l._OrtCreateSessionOptions=(e,t,n,r,o,i,a,s,u,c)=>(l._OrtCreateSessionOptions=ut.Y)(e,t,n,r,o,i,a,s,u,c),l._OrtAppendExecutionProvider=(e,t)=>(l._OrtAppendExecutionProvider=ut.Z)(e,t),l._OrtAddFreeDimensionOverride=(e,t,n)=>(l._OrtAddFreeDimensionOverride=ut._)(e,t,n),l._OrtAddSessionConfigEntry=(e,t,n)=>(l._OrtAddSessionConfigEntry=ut.$)(e,t,n),l._OrtReleaseSessionOptions=e=>(l._OrtReleaseSessionOptions=ut.aa)(e),l._OrtCreateSession=(e,t,n)=>(l._OrtCreateSession=ut.ba)(e,t,n),l._OrtReleaseSession=e=>(l._OrtReleaseSession=ut.ca)(e),l._OrtGetInputOutputCount=(e,t,n)=>(l._OrtGetInputOutputCount=ut.da)(e,t,n),l._OrtGetInputName=(e,t)=>(l._OrtGetInputName=ut.ea)(e,t),l._OrtGetOutputName=(e,t)=>(l._OrtGetOutputName=ut.fa)(e,t),l._OrtFree=e=>(l._OrtFree=ut.ga)(e),l._OrtCreateTensor=(e,t,n,r,o,i)=>(l._OrtCreateTensor=ut.ha)(e,t,n,r,o,i),l._OrtGetTensorData=(e,t,n,r,o)=>(l._OrtGetTensorData=ut.ia)(e,t,n,r,o),l._OrtReleaseTensor=e=>(l._OrtReleaseTensor=ut.ja)(e),l._OrtCreateRunOptions=(e,t,n,r)=>(l._OrtCreateRunOptions=ut.ka)(e,t,n,r),l._OrtAddRunConfigEntry=(e,t,n)=>(l._OrtAddRunConfigEntry=ut.la)(e,t,n),l._OrtReleaseRunOptions=e=>(l._OrtReleaseRunOptions=ut.ma)(e),l._OrtCreateBinding=e=>(l._OrtCreateBinding=ut.na)(e),l._OrtBindInput=(e,t,n)=>(l._OrtBindInput=ut.oa)(e,t,n),l._OrtBindOutput=(e,t,n,r)=>(l._OrtBindOutput=ut.pa)(e,t,n,r),l._OrtClearBoundOutputs=e=>(l._OrtClearBoundOutputs=ut.qa)(e),l._OrtReleaseBinding=e=>(l._OrtReleaseBinding=ut.ra)(e),l._OrtRunWithBinding=(e,t,n,r,o)=>(l._OrtRunWithBinding=ut.sa)(e,t,n,r,o),l._OrtRun=(e,t,n,r,o,i,a,s)=>(l._OrtRun=ut.ta)(e,t,n,r,o,i,a,s),l._OrtEndProfiling=e=>(l._OrtEndProfiling=ut.ua)(e);var lt=()=>(lt=ut.va)(),ct=l._pthread_self=()=>(ct=l._pthread_self=ut.wa)(),pt=l._malloc=e=>(pt=l._malloc=ut.xa)(e);l._free=e=>(l._free=ut.ya)(e),l.__emscripten_tls_init=()=>(l.__emscripten_tls_init=ut.za)();var dt=l.__emscripten_thread_init=(e,t,n,r,o,i)=>(dt=l.__emscripten_thread_init=ut.Ba)(e,t,n,r,o,i);l.__emscripten_thread_crashed=()=>(l.__emscripten_thread_crashed=ut.Ca)();var ft,ht=(e,t,n,r)=>(ht=ut.Da)(e,t,n,r),gt=e=>(gt=ut.Ea)(e),mt=l.__emscripten_thread_exit=e=>(mt=l.__emscripten_thread_exit=ut.Fa)(e),bt=()=>(bt=ut.Ga)(),yt=e=>(yt=ut.Ha)(e),wt=(e,t)=>(wt=ut.Ia)(e,t),_t=()=>(_t=ut.Ja)(),vt=e=>(vt=ut.Ka)(e),xt=e=>(xt=ut.La)(e);function Tt(){if(!(0<V))if(w)s(l),w||he(B),startWorker(l);else{if(l.preRun)for("function"==typeof l.preRun&&(l.preRun=[l.preRun]);l.preRun.length;)j.unshift(l.preRun.shift());he(j),0<V||ft||(ft=!0,l.calledRun=!0,R||(w||he(B),s(l),w||he(U)))}}return l.wasmMemory=I,l.stackAlloc=xt,l.stackSave=_t,l.stackRestore=vt,l.keepRuntimeAlive=()=>0<re,l.UTF8ToString=ae,l.stringToUTF8=Se,l.lengthBytesUTF8=Te,l.ExitStatus=ee,l.PThread=fe,G=function e(){ft||Tt(),ft||(G=e)},Tt(),e.ready});"object"==typeof e&&"object"==typeof t?t.exports=r:"function"==typeof define&&define.amd&&define([],(()=>r))})),Np=me(((e,t)=>{t.exports='"use strict";var Module={},ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads"),parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",e=>onmessage({data:e}));var fs=require("fs"),vm=require("vm");Object.assign(global,{self:global,require,Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:e=>vm.runInThisContext(fs.readFileSync(e,"utf8"),{filename:e}),postMessage:e=>parentPort.postMessage(e),performance:global.performance||{now:Date.now}})}var initializedJS=!1;function threadPrintErr(){var e=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,e+`\n`);return}console.error(e)}function threadAlert(){var e=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:e,threadId:Module._pthread_self()})}var err=threadPrintErr;self.alert=threadAlert,Module.instantiateWasm=(e,t)=>{var a=Module.wasmModule;Module.wasmModule=null;var r=new WebAssembly.Instance(a,e);return t(r)},self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{if(e.data.cmd==="load"){let a=[];self.onmessage=r=>a.push(r),self.startWorker=r=>{Module=r,postMessage({cmd:"loaded"});for(let s of a)handleMessage(s);self.onmessage=handleMessage},Module.wasmModule=e.data.wasmModule;for(const r of e.data.handlers)Module[r]=(...s)=>{postMessage({cmd:"callHandler",handler:r,args:s})};if(Module.wasmMemory=e.data.wasmMemory,Module.buffer=Module.wasmMemory.buffer,Module.ENVIRONMENT_IS_PTHREAD=!0,typeof e.data.urlOrBlob=="string")importScripts(e.data.urlOrBlob);else{var t=URL.createObjectURL(e.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}ortWasmThreaded(Module)}else if(e.data.cmd==="run"){Module.__emscripten_thread_init(e.data.pthread_ptr,0,0,1),Module.__emscripten_thread_mailbox_await(e.data.pthread_ptr),Module.establishStackSpace(),Module.PThread.receiveObjectTransfer(e.data),Module.PThread.threadInitTLS(),initializedJS||(initializedJS=!0);try{Module.invokeEntryPoint(e.data.start_routine,e.data.arg)}catch(a){if(a!="unwind")throw a}}else e.data.cmd==="cancel"?Module._pthread_self()&&Module.__emscripten_thread_exit(-1):e.data.target==="setimmediate"||(e.data.cmd==="checkMailbox"?initializedJS&&Module.checkMailbox():e.data.cmd&&(err(`worker.js received unknown command ${e.data.cmd}`),err(e.data)))}catch(a){throw Module.__emscripten_thread_crashed?.(),a}}self.onmessage=handleMessage;\n'})),Mp,ig,sa,ua,Po,Rp,ag,sg,ug,Gp,Ee,zr=L((()=>{Mp=Ep(),ig=Bp(),ua=!1,Po=!1,Rp=!1,ag=e=>{if(1===e)return!1;if(typeof SharedArrayBuffer>"u")return typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+e+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),!1;typeof process<"u"&&process.versions&&process.versions.node&&console.warn("env.wasm.numThreads is set to "+e+", however, currently onnxruntime-web does not support multi-threads in Node.js. Please consider using onnxruntime-node for performance critical scenarios.");try{return typeof MessageChannel<"u"&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},sg=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},ug=(e,t)=>e?t?"ort-wasm-simd-threaded.wasm":"ort-wasm-simd.wasm":t?"ort-wasm-threaded.wasm":"ort-wasm.wasm",Gp=async e=>{if(ua)return Promise.resolve();if(Po)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Rp)throw new Error("previous call to 'initializeWebAssembly()' failed.");Po=!0;let t=e.initTimeout,n=e.numThreads,r=e.simd,o=ag(n),i=r&&sg(),a=e.wasmPaths,s="string"==typeof a?a:void 0,u=ug(i,o),l="object"==typeof a?a[u]:void 0,c=!1,p=[];if(t>0&&p.push(new Promise((e=>{setTimeout((()=>{c=!0,e()}),t)}))),p.push(new Promise(((e,t)=>{let r=o?ig:Mp,i={locateFile:(e,t)=>o&&e.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([Np()],{type:"text/javascript"})):e.endsWith(".wasm")?l||(s??t)+u:t+e};if(o)if(i.numThreads=n,typeof Blob>"u")i.mainScriptUrlOrBlob=(void 0)(__dirname,"ort-wasm-threaded.js");else{let e=`var ortWasmThreaded=${r.toString()};`;i.mainScriptUrlOrBlob=new Blob([e],{type:"text/javascript"})}r(i).then((t=>{Po=!1,ua=!0,sa=t,e()}),(e=>{Po=!1,Rp=!0,t(e)}))}))),await Promise.race(p),c)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},Ee=()=>{if(ua&&sa)return sa;throw new Error("WebAssembly is not initialized yet.")}})),De,bn,Oe,Eo=L((()=>{zr(),De=(e,t)=>{let n=Ee(),r=n.lengthBytesUTF8(e)+1,o=n._malloc(r);return n.stringToUTF8(e,o,r),t.push(o),o},bn=(e,t,n,r)=>{if("object"==typeof e&&null!==e){if(n.has(e))throw new Error("Circular reference in options");n.add(e)}Object.entries(e).forEach((([e,o])=>{let i=t?t+e:e;if("object"==typeof o)bn(o,i+".",n,r);else if("string"==typeof o||"number"==typeof o)r(i,o.toString());else{if("boolean"!=typeof o)throw new Error("Can't handle extra config type: "+typeof o);r(i,o?"1":"0")}}))},Oe=e=>{let t=Ee(),n=t.stackSave();try{let n=t.stackAlloc(8);t._OrtGetLastError(n,n+4);let r=t.HEAP32[n/4],o=t.HEAPU32[n/4+1],i=o?t.UTF8ToString(o):"";throw new Error(`${e} ERROR_CODE: ${r}, ERROR_MESSAGE: ${i}`)}finally{t.stackRestore(n)}}})),Up,zp=L((()=>{zr(),Eo(),Up=e=>{let t=Ee(),n=0,r=[],o=e||{};try{if(void 0===e?.logSeverityLevel)o.logSeverityLevel=2;else if("number"!=typeof e.logSeverityLevel||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if(void 0===e?.logVerbosityLevel)o.logVerbosityLevel=0;else if("number"!=typeof e.logVerbosityLevel||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);void 0===e?.terminate&&(o.terminate=!1);let i=0;return void 0!==e?.tag&&(i=De(e.tag,r)),n=t._OrtCreateRunOptions(o.logSeverityLevel,o.logVerbosityLevel,!!o.terminate,i),0===n&&Oe("Can't create run options."),void 0!==e?.extra&&bn(e.extra,"",new WeakSet,((e,o)=>{let i=De(e,r),a=De(o,r);0!==t._OrtAddRunConfigEntry(n,i,a)&&Oe(`Can't set a run config entry: ${e} - ${o}.`)})),[n,r]}catch(e){throw 0!==n&&t._OrtReleaseRunOptions(n),r.forEach((e=>t._free(e))),e}}})),lg,fg,cg,pg,Vp,Wp=L((()=>{zr(),Eo(),lg=e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}},fg=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},cg=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some((e=>"webgpu"===("string"==typeof e?e:e.name)))&&(e.enableMemPattern=!1)},pg=(e,t,n)=>{for(let r of t){let t="string"==typeof r?r:r.name;switch(t){case"webnn":if(t="WEBNN","string"!=typeof r){let t=r;if(t?.deviceType){let r=De("deviceType",n),o=De(t.deviceType,n);0!==Ee()._OrtAddSessionConfigEntry(e,r,o)&&Oe(`Can't set a session config entry: 'deviceType' - ${t.deviceType}.`)}if(t?.numThreads){let r=t.numThreads;("number"!=typeof r||!Number.isInteger(r)||r<0)&&(r=0);let o=De("numThreads",n),i=De(r.toString(),n);0!==Ee()._OrtAddSessionConfigEntry(e,o,i)&&Oe(`Can't set a session config entry: 'numThreads' - ${t.numThreads}.`)}if(t?.powerPreference){let r=De("powerPreference",n),o=De(t.powerPreference,n);0!==Ee()._OrtAddSessionConfigEntry(e,r,o)&&Oe(`Can't set a session config entry: 'powerPreference' - ${t.powerPreference}.`)}}break;case"webgpu":if(t="JS","string"!=typeof r){let t=r;if(t?.preferredLayout){if("NCHW"!==t.preferredLayout&&"NHWC"!==t.preferredLayout)throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${t.preferredLayout}`);let r=De("preferredLayout",n),o=De(t.preferredLayout,n);0!==Ee()._OrtAddSessionConfigEntry(e,r,o)&&Oe(`Can't set a session config entry: 'preferredLayout' - ${t.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${t}`)}let o=De(t,n);0!==Ee()._OrtAppendExecutionProvider(e,o)&&Oe(`Can't append execution provider: ${t}.`)}},Vp=e=>{let t=Ee(),n=0,r=[],o=e||{};cg(o);try{let e=lg(o.graphOptimizationLevel??"all"),i=fg(o.executionMode??"sequential"),a="string"==typeof o.logId?De(o.logId,r):0,s=o.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw new Error(`log serverity level is not valid: ${s}`);let u=o.logVerbosityLevel??0;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log verbosity level is not valid: ${u}`);let l="string"==typeof o.optimizedModelFilePath?De(o.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!o.enableCpuMemArena,!!o.enableMemPattern,i,!!o.enableProfiling,0,a,s,u,l),0===n&&Oe("Can't create session options."),o.executionProviders&&pg(n,o.executionProviders,r),o.freeDimensionOverrides)for(let[e,i]of Object.entries(o.freeDimensionOverrides)){if("string"!=typeof e)throw new Error(`free dimension override name must be a string: ${e}`);if("number"!=typeof i||!Number.isInteger(i)||i<0)throw new Error(`free dimension override value must be a non-negative integer: ${i}`);let o=De(e,r);0!==t._OrtAddFreeDimensionOverride(n,o,i)&&Oe(`Can't set a free dimension override: ${e} - ${i}.`)}return void 0!==o.extra&&bn(o.extra,"",new WeakSet,((e,o)=>{let i=De(e,r),a=De(o,r);0!==t._OrtAddSessionConfigEntry(n,i,a)&&Oe(`Can't set a session config entry: ${e} - ${o}.`)})),[n,r]}catch(e){throw 0!==n&&t._OrtReleaseSessionOptions(n),r.forEach((e=>t._free(e))),e}}})),la,Hp,fa,qp,jp,Do,Yp,ca=L((()=>{la=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${e}`)}},Hp=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${e}`)}},fa=e=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][e],qp=e=>{switch(e){case"float16":case"uint16":return Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},jp=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}},Do=e=>"float32"===e||"int32"===e||"int64"===e||"bool"===e||"float16"===e||"uint32"===e,Yp=e=>{switch(e){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;default:throw new Error(`unsupported data location: ${e}`)}}})),gn,pa=L((()=>{gn=async e=>{if("string"!=typeof e)return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e);if(!(typeof process<"u"&&process.versions&&process.versions.node)){let t=await fetch(e);if(!t.ok)throw new Error(`failed to load external data file: ${e}`);let n=t.headers.get("Content-Length"),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let n,o=t.body.getReader();try{n=new ArrayBuffer(r)}catch(e){if(!(e instanceof RangeError))throw e;{let e=Math.ceil(r/65536);n=new WebAssembly.Memory({initial:e,maximum:e}).buffer}}let i=0;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=t.byteLength;new Uint8Array(n,i,r).set(t),i+=r}return new Uint8Array(n,0,r)}}try{return new Uint8Array(await(void 0)(e))}catch(t){if("ERR_FS_FILE_TOO_LARGE"===t.code){let t=(void 0)(e),n=[];for await(let e of t)n.push(e);return new Uint8Array(Buffer.concat(n))}throw t}}})),dg,Kp,Jp,yn,hg,da,Zp,Qp,Xp,ed,td,rd,nd=L((()=>{zp(),Wp(),ca(),zr(),Eo(),pa(),dg=(e,t)=>{0!==Ee()._OrtInit(e,t)&&Oe("Can't initialize onnxruntime.")},Kp=async e=>{dg(e.wasm.numThreads,jp(e.logLevel))},Jp=async(e,t)=>{},yn=new Map,hg=e=>{let t=Ee(),n=t.stackSave();try{let n=t.stackAlloc(8);return 0!==t._OrtGetInputOutputCount(e,n,n+4)&&Oe("Can't get session input/output count."),[t.HEAP32[n/4],t.HEAP32[n/4+1]]}finally{t.stackRestore(n)}},da=e=>{let t=Ee(),n=t._malloc(e.byteLength);if(0===n)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},Zp=async(e,t)=>{let n,r,o=Ee();Array.isArray(e)?[n,r]=e:e.buffer===o.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=da(e);let i=0,a=0,s=[],u=[],l=[];try{if([a,s]=Vp(t),t?.externalData&&o.mountExternalData){let e=[];for(let n of t.externalData){let t="string"==typeof n?n:n.path;e.push(gn("string"==typeof n?n:n.data).then((e=>{o.mountExternalData(t,e)})))}await Promise.all(e)}i=o._OrtCreateSession(n,r,a),0===i&&Oe("Can't create a session.");let[e,c]=hg(i),p=[],d=[];for(let t=0;t<e;t++){let e=o._OrtGetInputName(i,t);0===e&&Oe("Can't get an input name."),u.push(e),p.push(o.UTF8ToString(e))}for(let e=0;e<c;e++){let t=o._OrtGetOutputName(i,e);0===t&&Oe("Can't get an output name."),l.push(t);let n=o.UTF8ToString(t);d.push(n)}let f=null;return yn.set(i,[i,u,l,f]),[i,p,d]}catch(e){throw u.forEach((e=>o._OrtFree(e))),l.forEach((e=>o._OrtFree(e))),0!==i&&o._OrtReleaseSession(i),e}finally{o._free(n),0!==a&&o._OrtReleaseSessionOptions(a),s.forEach((e=>o._free(e))),o.unmountExternalData?.()}},Qp=e=>{let t=Ee(),n=yn.get(e);if(!n)throw new Error(`cannot release session. invalid session id: ${e}`);let[r,o,i,a]=n;a&&t._OrtReleaseBinding(a.handle),t.jsepUnregisterBuffers?.(e),o.forEach((e=>t._OrtFree(e))),i.forEach((e=>t._OrtFree(e))),t._OrtReleaseSession(r),yn.delete(e)},Xp=(e,t,n,r,o)=>{if(!e)return void t.push(0);let i,a,s=Ee(),u=e[0],l=e[1],c=e[3];if("string"===u&&"gpu-buffer"===c)throw new Error("String tensor is not supported on GPU.");if("gpu-buffer"===c){let t=e[2].gpuBuffer,n=fa(la(u));a=l.reduce(((e,t)=>e*t),1)*n,i=s.jsepRegisterBuffer(r,o,t,a)}else{let t=e[2];if(Array.isArray(t)){a=4*t.length,i=s._malloc(a),n.push(i);let e=i/4;for(let r=0;r<t.length;r++){if("string"!=typeof t[r])throw new TypeError(`tensor data at index ${r} is not a string`);s.HEAPU32[e++]=De(t[r],n)}}else a=t.byteLength,i=s._malloc(a),n.push(i),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,a),i)}let p=s.stackSave(),d=s.stackAlloc(4*l.length);try{let e=d/4;l.forEach((t=>s.HEAP32[e++]=t));let n=s._OrtCreateTensor(la(u),i,a,d,l.length,Yp(c));0===n&&Oe(`Can't create tensor for input/output. session=${r}, index=${o}.`),t.push(n)}finally{s.stackRestore(p)}},ed=async(e,t,n,r,o,i)=>{let a=Ee(),s=yn.get(e);if(!s)throw new Error(`cannot run inference. invalid session id: ${e}`);let[u,l,c,p]=s,d=t.length,f=r.length,h=0,g=[],m=[],b=[],y=[],w=a.stackSave(),_=a.stackAlloc(4*d),v=a.stackAlloc(4*d),x=a.stackAlloc(4*f),T=a.stackAlloc(4*f);try{[h,g]=Up(i);for(let r=0;r<d;r++)Xp(n[r],m,y,e,t[r]);for(let t=0;t<f;t++)Xp(o[t],b,y,e,d+r[t]);let s,w=_/4,O=v/4,S=x/4,E=T/4;for(let e=0;e<d;e++)a.HEAPU32[w++]=m[e],a.HEAPU32[O++]=l[t[e]];for(let e=0;e<f;e++)a.HEAPU32[S++]=b[e],a.HEAPU32[E++]=c[r[e]];s=await a._OrtRun(u,v,_,d,T,f,x,h),0!==s&&Oe("failed to call OrtRun().");let A=[];for(let e=0;e<f;e++){let t=a.HEAPU32[x/4+e];if(t===b[e]){A.push(o[e]);continue}let n,i=a.stackSave(),s=a.stackAlloc(16),u=!1,l=0;try{0!==a._OrtGetTensorData(t,s,s+4,s+8,s+12)&&Oe(`Can't access output tensor data on index ${e}.`);let o=s/4,i=a.HEAPU32[o++];l=a.HEAPU32[o++];let c=a.HEAPU32[o++],d=a.HEAPU32[o++],f=[];for(let e=0;e<d;e++)f.push(a.HEAPU32[c/4+e]);a._OrtFree(c);let h=f.reduce(((e,t)=>e*t),1);n=Hp(i);let g=p?.outputPreferredLocations[r[e]];if("string"===n){if("gpu-buffer"===g)throw new Error("String tensor is not supported on GPU.");let e=[],t=l/4;for(let n=0;n<h;n++){let r=a.HEAPU32[t++],o=n===h-1?void 0:a.HEAPU32[t]-r;e.push(a.UTF8ToString(r,o))}A.push([n,f,e,"cpu"])}else if("gpu-buffer"===g&&h>0){let e=a.jsepGetBuffer(l),r=fa(i);if(void 0===r||!Do(n))throw new Error(`Unsupported data type: ${n}`);u=!0,A.push([n,f,{gpuBuffer:e,download:a.jsepCreateDownloader(e,h*r,n),dispose:()=>{a._OrtReleaseTensor(t)}},"gpu-buffer"])}else{let e=new(qp(n))(h);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(a.HEAPU8.subarray(l,l+e.byteLength)),A.push([n,f,e,"cpu"])}}finally{a.stackRestore(i),"string"===n&&l&&a._free(l),u||a._OrtReleaseTensor(t)}}return p&&a._OrtClearBoundOutputs(p.handle),A}finally{a.stackRestore(w),m.forEach((e=>a._OrtReleaseTensor(e))),b.forEach((e=>a._OrtReleaseTensor(e))),y.forEach((e=>a._free(e))),0!==h&&a._OrtReleaseRunOptions(h),g.forEach((e=>a._free(e)))}},td=e=>{let t=Ee(),n=yn.get(e);if(!n)throw new Error("invalid session id");let r=n[0],o=t._OrtEndProfiling(r);0===o&&Oe("Can't get an profile file name."),t._OrtFree(o)},rd=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&"buffer"in e&&t.push(e.buffer)}return t}})),od=me(((e,t)=>{t.exports='/*!\n * ONNX Runtime Web v1.17.1\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n"use strict";(()=>{var Et=Object.defineProperty;var Jr=Object.getOwnPropertyDescriptor;var Xr=Object.getOwnPropertyNames;var Qr=Object.prototype.hasOwnProperty;var St=(u,d)=>()=>(u&&(d=u(u=0)),d);var et=(u,d)=>()=>(d||u((d={exports:{}}).exports,d),d.exports),Tt=(u,d)=>{for(var a in d)Et(u,a,{get:d[a],enumerable:!0})},Zr=(u,d,a,h)=>{if(d&&typeof d=="object"||typeof d=="function")for(let l of Xr(d))!Qr.call(u,l)&&l!==a&&Et(u,l,{get:()=>d[l],enumerable:!(h=Jr(d,l))||h.enumerable});return u};var tt=u=>Zr(Et({},"__esModule",{value:!0}),u);var At={};Tt(At,{createReadStream:()=>dr,readFile:()=>Kr,readFileSync:()=>en});var Kr,en,dr,Mt=St(()=>{Kr=void 0,en=void 0,dr=void 0});var Ct={};Tt(Ct,{join:()=>tn});var tn,Dt=St(()=>{tn=void 0});var gr=et((mr,xt)=>{"use strict";var pr=(()=>{var u=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(u=u||__filename),function(d={}){var a=d,h,l;a.ready=new Promise((r,o)=>{h=r,l=o});var w=Object.assign({},a),g="./this.program",i=typeof window=="object",A=typeof importScripts=="function",D=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",I="",B,F,U;if(D){var k=(Mt(),tt(At)),L=(Dt(),tt(Ct));I=A?L.dirname(I)+"/":__dirname+"/",B=(r,o)=>(r=ye(r)?new URL(r):L.normalize(r),k.readFileSync(r,o?void 0:"utf8")),U=r=>(r=B(r,!0),r.buffer||(r=new Uint8Array(r)),r),F=(r,o,s,m=!0)=>{r=ye(r)?new URL(r):L.normalize(r),k.readFile(r,m?void 0:"utf8",(O,S)=>{O?s(O):o(m?S.buffer:S)})},!a.thisProgram&&1<process.argv.length&&(g=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),a.inspect=()=>"[Emscripten Module object]"}else(i||A)&&(A?I=self.location.href:typeof document<"u"&&document.currentScript&&(I=document.currentScript.src),u&&(I=u),I.indexOf("blob:")!==0?I=I.substr(0,I.replace(/[?#].*/,"").lastIndexOf("/")+1):I="",B=r=>{var o=new XMLHttpRequest;return o.open("GET",r,!1),o.send(null),o.responseText},A&&(U=r=>{var o=new XMLHttpRequest;return o.open("GET",r,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),F=(r,o,s)=>{var m=new XMLHttpRequest;m.open("GET",r,!0),m.responseType="arraybuffer",m.onload=()=>{m.status==200||m.status==0&&m.response?o(m.response):s()},m.onerror=s,m.send(null)});var _=console.log.bind(console),x=console.error.bind(console);Object.assign(a,w),w=null,typeof WebAssembly!="object"&&de("no native wasm support detected");var N,he=!1,ie,ae,E,Y,ue;function Re(){var r=N.buffer;a.HEAP8=ie=new Int8Array(r),a.HEAP16=new Int16Array(r),a.HEAPU8=ae=new Uint8Array(r),a.HEAPU16=new Uint16Array(r),a.HEAP32=E=new Int32Array(r),a.HEAPU32=Y=new Uint32Array(r),a.HEAPF32=new Float32Array(r),a.HEAPF64=ue=new Float64Array(r)}var Ie=[],ee=[],j=[],ce=0,P=null,te=null;function de(r){throw r="Aborted("+r+")",x(r),he=!0,r=new WebAssembly.RuntimeError(r+". Build with -sASSERTIONS for more info."),l(r),r}var ge=r=>r.startsWith("data:application/octet-stream;base64,"),ye=r=>r.startsWith("file://"),J;if(J="ort-wasm.wasm",!ge(J)){var fe=J;J=a.locateFile?a.locateFile(fe,I):I+fe}function we(r){if(U)return U(r);throw"both async and sync fetching of the wasm failed"}function Ae(r){if(i||A){if(typeof fetch=="function"&&!ye(r))return fetch(r,{credentials:"same-origin"}).then(o=>{if(!o.ok)throw"failed to load wasm binary file at \'"+r+"\'";return o.arrayBuffer()}).catch(()=>we(r));if(F)return new Promise((o,s)=>{F(r,m=>o(new Uint8Array(m)),s)})}return Promise.resolve().then(()=>we(r))}function Me(r,o,s){return Ae(r).then(m=>WebAssembly.instantiate(m,o)).then(m=>m).then(s,m=>{x(`failed to asynchronously prepare wasm: ${m}`),de(m)})}function Fe(r,o){var s=J;return typeof WebAssembly.instantiateStreaming!="function"||ge(s)||ye(s)||D||typeof fetch!="function"?Me(s,r,o):fetch(s,{credentials:"same-origin"}).then(m=>WebAssembly.instantiateStreaming(m,r).then(o,function(O){return x(`wasm streaming compile failed: ${O}`),x("falling back to ArrayBuffer instantiation"),Me(s,r,o)}))}var Ee,pe={919888:(r,o,s,m)=>{if(typeof a>"u"||!a.za)return 1;if(r=be(r>>>0),r.startsWith("./")&&(r=r.substring(2)),r=a.za.get(r),!r)return 2;if(o>>>=0,s>>>=0,o+s>r.byteLength)return 3;try{return ae.set(r.subarray(o,o+s),m>>>0>>>0),0}catch{return 4}}};function Oe(r){this.xa=r-24,this.Ha=function(o){Y[this.xa+4>>>2>>>0]=o},this.Ga=function(o){Y[this.xa+8>>>2>>>0]=o},this.Aa=function(o,s){this.Fa(),this.Ha(o),this.Ga(s)},this.Fa=function(){Y[this.xa+16>>>2>>>0]=0}}var ve=0,re=0,Z=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ce=(r,o,s)=>{o>>>=0;var m=o+s;for(s=o;r[s]&&!(s>=m);)++s;if(16<s-o&&r.buffer&&Z)return Z.decode(r.subarray(o,s));for(m="";o<s;){var O=r[o++];if(O&128){var S=r[o++]&63;if((O&224)==192)m+=String.fromCharCode((O&31)<<6|S);else{var R=r[o++]&63;O=(O&240)==224?(O&15)<<12|S<<6|R:(O&7)<<18|S<<12|R<<6|r[o++]&63,65536>O?m+=String.fromCharCode(O):(O-=65536,m+=String.fromCharCode(55296|O>>10,56320|O&1023))}}else m+=String.fromCharCode(O)}return m},be=(r,o)=>(r>>>=0)?Ce(ae,r,o):"",_e=r=>{for(var o=0,s=0;s<r.length;++s){var m=r.charCodeAt(s);127>=m?o++:2047>=m?o+=2:55296<=m&&57343>=m?(o+=4,++s):o+=3}return o},ke=(r,o,s,m)=>{if(s>>>=0,!(0<m))return 0;var O=s;m=s+m-1;for(var S=0;S<r.length;++S){var R=r.charCodeAt(S);if(55296<=R&&57343>=R){var K=r.charCodeAt(++S);R=65536+((R&1023)<<10)|K&1023}if(127>=R){if(s>=m)break;o[s++>>>0]=R}else{if(2047>=R){if(s+1>=m)break;o[s++>>>0]=192|R>>6}else{if(65535>=R){if(s+2>=m)break;o[s++>>>0]=224|R>>12}else{if(s+3>=m)break;o[s++>>>0]=240|R>>18,o[s++>>>0]=128|R>>12&63}o[s++>>>0]=128|R>>6&63}o[s++>>>0]=128|R&63}}return o[s>>>0]=0,s-O},Ue=r=>r%4===0&&(r%100!==0||r%400===0),ze=[0,31,60,91,121,152,182,213,244,274,305,335],at=[0,31,59,90,120,151,181,212,243,273,304,334],De=r=>{var o=_e(r)+1,s=st(o);return s&&ke(r,ae,s,o),s},Ne=[],Pe={},He=()=>{if(!$e){var r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"},o;for(o in Pe)Pe[o]===void 0?delete r[o]:r[o]=Pe[o];var s=[];for(o in r)s.push(`${o}=${r[o]}`);$e=s}return $e},$e,Le=[null,[],[]],qe=[31,29,31,30,31,30,31,31,30,31,30,31],Ve=[31,28,31,30,31,30,31,31,30,31,30,31];function Ge(r){var o=Array(_e(r)+1);return ke(r,o,0,o.length),o}function ot(r,o,s,m){function O(c,W,G){for(c=typeof c=="number"?c.toString():c||"";c.length<W;)c=G[0]+c;return c}function S(c,W){return O(c,W,"0")}function R(c,W){function G(Ke){return 0>Ke?-1:0<Ke?1:0}var Se;return(Se=G(c.getFullYear()-W.getFullYear()))===0&&(Se=G(c.getMonth()-W.getMonth()))===0&&(Se=G(c.getDate()-W.getDate())),Se}function K(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function le(c){var W=c.ta;for(c=new Date(new Date(c.ua+1900,0,1).getTime());0<W;){var G=c.getMonth(),Se=(Ue(c.getFullYear())?qe:Ve)[G];if(W>Se-c.getDate())W-=Se-c.getDate()+1,c.setDate(1),11>G?c.setMonth(G+1):(c.setMonth(0),c.setFullYear(c.getFullYear()+1));else{c.setDate(c.getDate()+W);break}}return G=new Date(c.getFullYear()+1,0,4),W=K(new Date(c.getFullYear(),0,4)),G=K(G),0>=R(W,c)?0>=R(G,c)?c.getFullYear()+1:c.getFullYear():c.getFullYear()-1}r>>>=0,o>>>=0,s>>>=0,m>>>=0;var oe=Y[m+40>>>2>>>0];m={Da:E[m>>>2>>>0],Ca:E[m+4>>>2>>>0],va:E[m+8>>>2>>>0],ya:E[m+12>>>2>>>0],wa:E[m+16>>>2>>>0],ua:E[m+20>>>2>>>0],oa:E[m+24>>>2>>>0],ta:E[m+28>>>2>>>0],Ia:E[m+32>>>2>>>0],Ba:E[m+36>>>2>>>0],Ea:oe?be(oe):""},s=be(s),oe={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var se in oe)s=s.replace(new RegExp(se,"g"),oe[se]);var Qe="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ze="January February March April May June July August September October November December".split(" ");oe={"%a":c=>Qe[c.oa].substring(0,3),"%A":c=>Qe[c.oa],"%b":c=>Ze[c.wa].substring(0,3),"%B":c=>Ze[c.wa],"%C":c=>S((c.ua+1900)/100|0,2),"%d":c=>S(c.ya,2),"%e":c=>O(c.ya,2," "),"%g":c=>le(c).toString().substring(2),"%G":c=>le(c),"%H":c=>S(c.va,2),"%I":c=>(c=c.va,c==0?c=12:12<c&&(c-=12),S(c,2)),"%j":c=>{for(var W=0,G=0;G<=c.wa-1;W+=(Ue(c.ua+1900)?qe:Ve)[G++]);return S(c.ya+W,3)},"%m":c=>S(c.wa+1,2),"%M":c=>S(c.Ca,2),"%n":()=>`\n`,"%p":c=>0<=c.va&&12>c.va?"AM":"PM","%S":c=>S(c.Da,2),"%t":()=>"\t","%u":c=>c.oa||7,"%U":c=>S(Math.floor((c.ta+7-c.oa)/7),2),"%V":c=>{var W=Math.floor((c.ta+7-(c.oa+6)%7)/7);if(2>=(c.oa+371-c.ta-2)%7&&W++,W)W==53&&(G=(c.oa+371-c.ta)%7,G==4||G==3&&Ue(c.ua)||(W=1));else{W=52;var G=(c.oa+7-c.ta-1)%7;(G==4||G==5&&Ue(c.ua%400-1))&&W++}return S(W,2)},"%w":c=>c.oa,"%W":c=>S(Math.floor((c.ta+7-(c.oa+6)%7)/7),2),"%y":c=>(c.ua+1900).toString().substring(2),"%Y":c=>c.ua+1900,"%z":c=>{c=c.Ba;var W=0<=c;return c=Math.abs(c)/60,(W?"+":"-")+("0000"+(c/60*100+c%60)).slice(-4)},"%Z":c=>c.Ea,"%%":()=>"%"},s=s.replace(/%%/g,"\\0\\0");for(se in oe)s.includes(se)&&(s=s.replace(new RegExp(se,"g"),oe[se](m)));return s=s.replace(/\\0\\0/g,"%"),se=Ge(s),se.length>o?0:(ie.set(se,r>>>0),se.length-1)}var $={a:function(r,o,s){throw r>>>=0,new Oe(r).Aa(o>>>0,s>>>0),ve=r,re++,ve},e:function(){return 0},H:function(){},x:function(){},z:function(){},J:function(){return 0},F:function(){},A:function(){},E:function(){},g:function(){},y:function(){},v:function(){},G:function(){},w:function(){},k:()=>1,n:function(r,o,s){r=o+2097152>>>0<4194305-!!r?(r>>>0)+4294967296*o:NaN,s>>>=0,r=new Date(1e3*r),E[s>>>2>>>0]=r.getUTCSeconds(),E[s+4>>>2>>>0]=r.getUTCMinutes(),E[s+8>>>2>>>0]=r.getUTCHours(),E[s+12>>>2>>>0]=r.getUTCDate(),E[s+16>>>2>>>0]=r.getUTCMonth(),E[s+20>>>2>>>0]=r.getUTCFullYear()-1900,E[s+24>>>2>>>0]=r.getUTCDay(),E[s+28>>>2>>>0]=(r.getTime()-Date.UTC(r.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(r,o,s){r=o+2097152>>>0<4194305-!!r?(r>>>0)+4294967296*o:NaN,s>>>=0,r=new Date(1e3*r),E[s>>>2>>>0]=r.getSeconds(),E[s+4>>>2>>>0]=r.getMinutes(),E[s+8>>>2>>>0]=r.getHours(),E[s+12>>>2>>>0]=r.getDate(),E[s+16>>>2>>>0]=r.getMonth(),E[s+20>>>2>>>0]=r.getFullYear()-1900,E[s+24>>>2>>>0]=r.getDay(),E[s+28>>>2>>>0]=(Ue(r.getFullYear())?ze:at)[r.getMonth()]+r.getDate()-1|0,E[s+36>>>2>>>0]=-(60*r.getTimezoneOffset()),o=new Date(r.getFullYear(),6,1).getTimezoneOffset();var m=new Date(r.getFullYear(),0,1).getTimezoneOffset();E[s+32>>>2>>>0]=(o!=m&&r.getTimezoneOffset()==Math.min(m,o))|0},p:function(r){r>>>=0;var o=new Date(E[r+20>>>2>>>0]+1900,E[r+16>>>2>>>0],E[r+12>>>2>>>0],E[r+8>>>2>>>0],E[r+4>>>2>>>0],E[r>>>2>>>0],0),s=E[r+32>>>2>>>0],m=o.getTimezoneOffset(),O=new Date(o.getFullYear(),6,1).getTimezoneOffset(),S=new Date(o.getFullYear(),0,1).getTimezoneOffset(),R=Math.min(S,O);return 0>s?E[r+32>>>2>>>0]=+(O!=S&&R==m):0<s!=(R==m)&&(O=Math.max(S,O),o.setTime(o.getTime()+6e4*((0<s?R:O)-m))),E[r+24>>>2>>>0]=o.getDay(),E[r+28>>>2>>>0]=(Ue(o.getFullYear())?ze:at)[o.getMonth()]+o.getDate()-1|0,E[r>>>2>>>0]=o.getSeconds(),E[r+4>>>2>>>0]=o.getMinutes(),E[r+8>>>2>>>0]=o.getHours(),E[r+12>>>2>>>0]=o.getDate(),E[r+16>>>2>>>0]=o.getMonth(),E[r+20>>>2>>>0]=o.getYear(),r=o.getTime(),isNaN(r)?(E[Ye()>>>2>>>0]=61,r=-1):r/=1e3,Je((Ee=r,1<=+Math.abs(Ee)?0<Ee?+Math.floor(Ee/4294967296)>>>0:~~+Math.ceil((Ee-+(~~Ee>>>0))/4294967296)>>>0:0)),r>>>0},l:function(){return-52},m:function(){},t:function(r,o,s){function m(le){return(le=le.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?le[1]:"GMT"}s>>>=0;var O=new Date().getFullYear(),S=new Date(O,0,1),R=new Date(O,6,1);O=S.getTimezoneOffset();var K=R.getTimezoneOffset();Y[r>>>0>>>2>>>0]=60*Math.max(O,K),E[o>>>0>>>2>>>0]=+(O!=K),r=m(S),o=m(R),r=De(r),o=De(o),K<O?(Y[s>>>2>>>0]=r,Y[s+4>>>2>>>0]=o):(Y[s>>>2>>>0]=o,Y[s+4>>>2>>>0]=r)},d:()=>{de("")},B:function(r,o,s){r>>>=0,o>>>=0,s>>>=0,Ne.length=0;for(var m;m=ae[o++>>>0];){var O=m!=105;O&=m!=112,s+=O&&s%8?4:0,Ne.push(m==112?Y[s>>>2>>>0]:m==105?E[s>>>2>>>0]:ue[s>>>3>>>0]),s+=O?8:4}return pe[r].apply(null,Ne)},h:()=>Date.now(),u:function(){return 4294901760},b:()=>performance.now(),I:function(r,o,s){return o>>>=0,ae.copyWithin(r>>>0>>>0,o>>>0,o+(s>>>0)>>>0)},s:function(r){r>>>=0;var o=ae.length;if(4294901760<r)return!1;for(var s=1;4>=s;s*=2){var m=o*(1+.2/s);m=Math.min(m,r+100663296);var O=Math;m=Math.max(r,m);e:{O=(O.min.call(O,4294901760,m+(65536-m%65536)%65536)-N.buffer.byteLength+65535)/65536;try{N.grow(O),Re();var S=1;break e}catch{}S=void 0}if(S)return!0}return!1},C:function(r,o){r>>>=0,o>>>=0;var s=0;return He().forEach((m,O)=>{var S=o+s;for(O=Y[r+4*O>>>2>>>0]=S,S=0;S<m.length;++S)ie[O++>>>0>>>0]=m.charCodeAt(S);ie[O>>>0>>>0]=0,s+=m.length+1}),0},D:function(r,o){r>>>=0,o>>>=0;var s=He();Y[r>>>2>>>0]=s.length;var m=0;return s.forEach(O=>m+=O.length+1),Y[o>>>2>>>0]=m,0},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(r,o,s,m){o>>>=0,s>>>=0,m>>>=0;for(var O=0,S=0;S<s;S++){var R=Y[o>>>2>>>0],K=Y[o+4>>>2>>>0];o+=8;for(var le=0;le<K;le++){var oe=ae[R+le>>>0],se=Le[r];oe===0||oe===10?((r===1?_:x)(Ce(se,0)),se.length=0):se.push(oe)}O+=K}return Y[m>>>2>>>0]=O,0},r:ot,c:function(r,o,s,m){return ot(r>>>0,o>>>0,s>>>0,m>>>0)}},C=function(){function r(s){return C=s.exports,C=ut(),N=C.K,Re(),ee.unshift(C.L),ce--,ce==0&&(P!==null&&(clearInterval(P),P=null),te&&(s=te,te=null,s())),C}var o={a:$};if(ce++,a.instantiateWasm)try{return a.instantiateWasm(o,r)}catch(s){x(`Module.instantiateWasm callback failed with error: ${s}`),l(s)}return Fe(o,function(s){r(s.instance)}).catch(l),{}}();a._OrtInit=(r,o)=>(a._OrtInit=C.M)(r,o),a._OrtGetLastError=(r,o)=>(a._OrtGetLastError=C.N)(r,o),a._OrtCreateSessionOptions=(r,o,s,m,O,S,R,K,le,oe)=>(a._OrtCreateSessionOptions=C.O)(r,o,s,m,O,S,R,K,le,oe),a._OrtAppendExecutionProvider=(r,o)=>(a._OrtAppendExecutionProvider=C.P)(r,o),a._OrtAddFreeDimensionOverride=(r,o,s)=>(a._OrtAddFreeDimensionOverride=C.Q)(r,o,s),a._OrtAddSessionConfigEntry=(r,o,s)=>(a._OrtAddSessionConfigEntry=C.R)(r,o,s),a._OrtReleaseSessionOptions=r=>(a._OrtReleaseSessionOptions=C.S)(r),a._OrtCreateSession=(r,o,s)=>(a._OrtCreateSession=C.T)(r,o,s),a._OrtReleaseSession=r=>(a._OrtReleaseSession=C.U)(r),a._OrtGetInputOutputCount=(r,o,s)=>(a._OrtGetInputOutputCount=C.V)(r,o,s),a._OrtGetInputName=(r,o)=>(a._OrtGetInputName=C.W)(r,o),a._OrtGetOutputName=(r,o)=>(a._OrtGetOutputName=C.X)(r,o),a._OrtFree=r=>(a._OrtFree=C.Y)(r),a._OrtCreateTensor=(r,o,s,m,O,S)=>(a._OrtCreateTensor=C.Z)(r,o,s,m,O,S),a._OrtGetTensorData=(r,o,s,m,O)=>(a._OrtGetTensorData=C._)(r,o,s,m,O),a._OrtReleaseTensor=r=>(a._OrtReleaseTensor=C.$)(r),a._OrtCreateRunOptions=(r,o,s,m)=>(a._OrtCreateRunOptions=C.aa)(r,o,s,m),a._OrtAddRunConfigEntry=(r,o,s)=>(a._OrtAddRunConfigEntry=C.ba)(r,o,s),a._OrtReleaseRunOptions=r=>(a._OrtReleaseRunOptions=C.ca)(r),a._OrtCreateBinding=r=>(a._OrtCreateBinding=C.da)(r),a._OrtBindInput=(r,o,s)=>(a._OrtBindInput=C.ea)(r,o,s),a._OrtBindOutput=(r,o,s,m)=>(a._OrtBindOutput=C.fa)(r,o,s,m),a._OrtClearBoundOutputs=r=>(a._OrtClearBoundOutputs=C.ga)(r),a._OrtReleaseBinding=r=>(a._OrtReleaseBinding=C.ha)(r),a._OrtRunWithBinding=(r,o,s,m,O)=>(a._OrtRunWithBinding=C.ia)(r,o,s,m,O),a._OrtRun=(r,o,s,m,O,S,R,K)=>(a._OrtRun=C.ja)(r,o,s,m,O,S,R,K),a._OrtEndProfiling=r=>(a._OrtEndProfiling=C.ka)(r);var Ye=()=>(Ye=C.la)(),st=a._malloc=r=>(st=a._malloc=C.ma)(r);a._free=r=>(a._free=C.na)(r);var Je=r=>(Je=C.pa)(r),it=()=>(it=C.qa)(),M=r=>(M=C.ra)(r),Be=r=>(Be=C.sa)(r);function ut(){var r=C;r=Object.assign({},r);var o=m=>()=>m()>>>0,s=m=>O=>m(O)>>>0;return r.la=o(r.la),r.ma=s(r.ma),r.qa=o(r.qa),r.sa=s(r.sa),r}a.stackAlloc=Be,a.stackSave=it,a.stackRestore=M,a.UTF8ToString=be,a.stringToUTF8=(r,o,s)=>ke(r,ae,o,s),a.lengthBytesUTF8=_e;var xe;te=function r(){xe||Xe(),xe||(te=r)};function Xe(){if(!(0<ce)){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;){var r=a.preRun.shift();Ie.unshift(r)}for(;0<Ie.length;)Ie.shift()(a);if(!(0<ce||xe||(xe=!0,a.calledRun=!0,he))){for(;0<ee.length;)ee.shift()(a);for(h(a);0<j.length;)j.shift()(a)}}}return Xe(),d.ready}})();typeof mr=="object"&&typeof xt=="object"?xt.exports=pr:typeof define=="function"&&define.amd&&define([],()=>pr)});var hr=et(()=>{});var yr=et(()=>{});var br={};Tt(br,{cpus:()=>rn});var rn,wr=St(()=>{rn=void 0});var _r=et((vr,Ft)=>{"use strict";var Or=(()=>{var u=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(u=u||__filename),function(d={}){function a(){return j.buffer!=de.buffer&&we(),de}function h(){return j.buffer!=de.buffer&&we(),ge}function l(){return j.buffer!=de.buffer&&we(),ye}function w(){return j.buffer!=de.buffer&&we(),J}function g(){return j.buffer!=de.buffer&&we(),fe}var i=d,A,D;i.ready=new Promise((e,t)=>{A=e,D=t});var I=Object.assign({},i),B="./this.program",F=(e,t)=>{throw t},U=typeof window=="object",k=typeof importScripts=="function",L=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",_=i.ENVIRONMENT_IS_PTHREAD||!1,x="";function N(e){return i.locateFile?i.locateFile(e,x):x+e}var he,ie,ae;if(L){var E=(Mt(),tt(At)),Y=(Dt(),tt(Ct));x=k?Y.dirname(x)+"/":__dirname+"/",he=(t,n)=>(t=be(t)?new URL(t):Y.normalize(t),E.readFileSync(t,n?void 0:"utf8")),ae=t=>(t=he(t,!0),t.buffer||(t=new Uint8Array(t)),t),ie=(t,n,f,y=!0)=>{t=be(t)?new URL(t):Y.normalize(t),E.readFile(t,y?void 0:"utf8",(b,v)=>{b?f(b):n(y?v.buffer:v)})},!i.thisProgram&&1<process.argv.length&&(B=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),F=(t,n)=>{throw process.exitCode=t,n},i.inspect=()=>"[Emscripten Module object]";let e;try{e=hr()}catch(t){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),t}global.Worker=e.Worker}else(U||k)&&(k?x=self.location.href:typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),typeof u<"u"&&u&&(x=u),x.indexOf("blob:")!==0?x=x.substr(0,x.replace(/[?#].*/,"").lastIndexOf("/")+1):x="",L||(he=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},k&&(ae=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),ie=(e,t,n)=>{var f=new XMLHttpRequest;f.open("GET",e,!0),f.responseType="arraybuffer",f.onload=()=>{f.status==200||f.status==0&&f.response?t(f.response):n()},f.onerror=n,f.send(null)}));L&&typeof performance>"u"&&(global.performance=yr().performance);var ue=console.log.bind(console),Re=console.error.bind(console);L&&(ue=(...e)=>E.writeSync(1,e.join(" ")+`\n`),Re=(...e)=>E.writeSync(2,e.join(" ")+`\n`));var Ie=ue,ee=Re;Object.assign(i,I),I=null,typeof WebAssembly!="object"&&Z("no native wasm support detected");var j,ce,P=!1,te,de,ge,ye,J,fe;function we(){var e=j.buffer;i.HEAP8=de=new Int8Array(e),i.HEAP16=new Int16Array(e),i.HEAPU8=ge=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAP32=ye=new Int32Array(e),i.HEAPU32=J=new Uint32Array(e),i.HEAPF32=new Float32Array(e),i.HEAPF64=fe=new Float64Array(e)}var Ae=16777216;if(_)j=i.wasmMemory;else if(i.wasmMemory)j=i.wasmMemory;else if(j=new WebAssembly.Memory({initial:Ae/65536,maximum:65536,shared:!0}),!(j.buffer instanceof SharedArrayBuffer))throw ee("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),L&&ee("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");we(),Ae=j.buffer.byteLength;var Me=[],Fe=[],Ee=[],pe=0,Oe=null,ve=null;function re(){if(pe--,pe==0&&(Oe!==null&&(clearInterval(Oe),Oe=null),ve)){var e=ve;ve=null,e()}}function Z(e){throw e="Aborted("+e+")",ee(e),P=!0,te=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),D(e),e}var Ce=e=>e.startsWith("data:application/octet-stream;base64,"),be=e=>e.startsWith("file://"),_e;_e="ort-wasm-threaded.wasm",Ce(_e)||(_e=N(_e));function ke(e){if(ae)return ae(e);throw"both async and sync fetching of the wasm failed"}function Ue(e){if(U||k){if(typeof fetch=="function"&&!be(e))return fetch(e,{credentials:"same-origin"}).then(t=>{if(!t.ok)throw"failed to load wasm binary file at \'"+e+"\'";return t.arrayBuffer()}).catch(()=>ke(e));if(ie)return new Promise((t,n)=>{ie(e,f=>t(new Uint8Array(f)),n)})}return Promise.resolve().then(()=>ke(e))}function ze(e,t,n){return Ue(e).then(f=>WebAssembly.instantiate(f,t)).then(f=>f).then(n,f=>{ee(`failed to asynchronously prepare wasm: ${f}`),Z(f)})}function at(e,t){var n=_e;return typeof WebAssembly.instantiateStreaming!="function"||Ce(n)||be(n)||L||typeof fetch!="function"?ze(n,e,t):fetch(n,{credentials:"same-origin"}).then(f=>WebAssembly.instantiateStreaming(f,e).then(t,function(y){return ee(`wasm streaming compile failed: ${y}`),ee("falling back to ArrayBuffer instantiation"),ze(n,e,t)}))}var De,Ne={921276:(e,t,n,f)=>{if(typeof i>"u"||!i.cb)return 1;if(e=Ge(e>>>0),e.startsWith("./")&&(e=e.substring(2)),e=i.cb.get(e),!e)return 2;if(t>>>=0,n>>>=0,f>>>=0,t+n>e.byteLength)return 3;try{return h().set(e.subarray(t,t+n),f>>>0),0}catch{return 4}}};function Pe(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var He=e=>{e.terminate(),e.onmessage=()=>{}},$e=e=>{M.Pa.length==0&&(Je(),M.Ya(M.Pa[0]));var t=M.Pa.pop();if(!t)return 6;M.Qa.push(t),M.Ma[e.Oa]=t,t.Oa=e.Oa;var n={cmd:"run",start_routine:e.kb,arg:e.hb,pthread_ptr:e.Oa};return L&&t.unref(),t.postMessage(n,e.qb),0},Le=0,qe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ve=(e,t,n)=>{t>>>=0;var f=t+n;for(n=t;e[n]&&!(n>=f);)++n;if(16<n-t&&e.buffer&&qe)return qe.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,n):e.subarray(t,n));for(f="";t<n;){var y=e[t++];if(y&128){var b=e[t++]&63;if((y&224)==192)f+=String.fromCharCode((y&31)<<6|b);else{var v=e[t++]&63;y=(y&240)==224?(y&15)<<12|b<<6|v:(y&7)<<18|b<<12|v<<6|e[t++]&63,65536>y?f+=String.fromCharCode(y):(y-=65536,f+=String.fromCharCode(55296|y>>10,56320|y&1023))}}else f+=String.fromCharCode(y)}return f},Ge=(e,t)=>(e>>>=0)?Ve(h(),e,t):"",ot=e=>{var t=vt();return e=e(),ct(t),e};function $(e,t){var n=arguments.length-2,f=arguments;return ot(()=>{for(var y=_t(8*n),b=y>>>3,v=0;v<n;v++){var z=f[2+v];g()[b+v>>>0]=z}return ar(e,n,y,t)})}function C(e){if(_)return $(0,1,e);te=e,0<Le||(M.lb(),i.onExit?.(e),P=!0),F(e,new Pe(e))}var Ye=e=>{if(te=e,_)throw ut(e),"unwind";C(e)};function st(){for(var e=i.numThreads;e--;)Je();Me.unshift(()=>{pe++,it(()=>re())})}function Je(){var e=N("ort-wasm-threaded.worker.js");e=new Worker(e),M.Pa.push(e)}function it(e){_?e():Promise.all(M.Pa.map(M.Ya)).then(e)}var M={Pa:[],Qa:[],bb:[],Ma:{},Wa(){_?(M.receiveObjectTransfer=M.jb,M.threadInitTLS=M.ab,M.setExitStatus=M.$a):st()},$a:e=>te=e,tb:["$terminateWorker"],lb:()=>{for(var e of M.Qa)He(e);for(e of M.Pa)He(e);M.Pa=[],M.Qa=[],M.Ma=[]},Za:e=>{var t=e.Oa;delete M.Ma[t],M.Pa.push(e),M.Qa.splice(M.Qa.indexOf(e),1),e.Oa=0,wt(t)},jb(){},ab(){M.bb.forEach(e=>e())},Ya:e=>new Promise(t=>{e.onmessage=b=>{b=b.data;var v=b.cmd;if(b.targetThread&&b.targetThread!=lt()){var z=M.Ma[b.targetThread];z?z.postMessage(b,b.transferList):ee(`Internal error! Worker sent a message "${v}" to target pthread ${b.targetThread}, but that thread no longer exists!`)}else v==="checkMailbox"?ft():v==="spawnThread"?$e(b):v==="cleanupThread"?M.Za(M.Ma[b.thread]):v==="killThread"?(b=b.thread,v=M.Ma[b],delete M.Ma[b],He(v),wt(b),M.Qa.splice(M.Qa.indexOf(v),1),v.Oa=0):v==="cancelThread"?M.Ma[b.thread].postMessage({cmd:"cancel"}):v==="loaded"?(e.loaded=!0,L&&!e.Oa&&e.unref(),t(e)):v==="alert"?alert(`Thread ${b.threadId}: ${b.text}`):b.target==="setimmediate"?e.postMessage(b):v==="callHandler"?i[b.handler](...b.args):v&&ee(`worker sent an unknown command ${v}`)},e.onerror=b=>{throw ee(`worker sent an error! ${b.filename}:${b.lineno}: ${b.message}`),b},L&&(e.on("message",b=>e.onmessage({data:b})),e.on("error",b=>e.onerror(b)));var n=[],f=["onExit"],y;for(y of f)i.hasOwnProperty(y)&&n.push(y);e.postMessage({cmd:"load",handlers:n,urlOrBlob:i.mainScriptUrlOrBlob||u,wasmMemory:j,wasmModule:ce})})};i.PThread=M;var Be=e=>{for(;0<e.length;)e.shift()(i)};i.establishStackSpace=()=>{var e=lt(),t=w()[e+52>>>2>>>0];e=w()[e+56>>>2>>>0],ir(t,t-e),ct(t)};function ut(e){if(_)return $(1,0,e);Ye(e)}var xe=[],Xe;i.invokeEntryPoint=(e,t)=>{var n=xe[e];n||(e>=xe.length&&(xe.length=e+1),xe[e]=n=Xe.get(e)),e=n(t),0<Le?M.$a(e):Ot(e)};function r(e){this.Va=e-24,this.gb=function(t){w()[this.Va+4>>>2>>>0]=t},this.fb=function(t){w()[this.Va+8>>>2>>>0]=t},this.Wa=function(t,n){this.eb(),this.gb(t),this.fb(n)},this.eb=function(){w()[this.Va+16>>>2>>>0]=0}}var o=0,s=0;function m(e,t,n,f){return _?$(2,1,e,t,n,f):O(e,t,n,f)}function O(e,t,n,f){if(e>>>=0,t>>>=0,n>>>=0,f>>>=0,typeof SharedArrayBuffer>"u")return ee("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var y=[];return _&&y.length===0?m(e,t,n,f):(e={kb:n,Oa:e,hb:f,qb:y},_?(e.sb="spawnThread",postMessage(e,y),0):$e(e))}function S(e,t,n){return _?$(3,1,e,t,n):0}function R(e,t){if(_)return $(4,1,e,t)}var K=e=>{for(var t=0,n=0;n<e.length;++n){var f=e.charCodeAt(n);127>=f?t++:2047>=f?t+=2:55296<=f&&57343>=f?(t+=4,++n):t+=3}return t},le=(e,t,n,f)=>{if(n>>>=0,!(0<f))return 0;var y=n;f=n+f-1;for(var b=0;b<e.length;++b){var v=e.charCodeAt(b);if(55296<=v&&57343>=v){var z=e.charCodeAt(++b);v=65536+((v&1023)<<10)|z&1023}if(127>=v){if(n>=f)break;t[n++>>>0]=v}else{if(2047>=v){if(n+1>=f)break;t[n++>>>0]=192|v>>6}else{if(65535>=v){if(n+2>=f)break;t[n++>>>0]=224|v>>12}else{if(n+3>=f)break;t[n++>>>0]=240|v>>18,t[n++>>>0]=128|v>>12&63}t[n++>>>0]=128|v>>6&63}t[n++>>>0]=128|v&63}}return t[n>>>0]=0,n-y},oe=(e,t,n)=>le(e,h(),t,n);function se(e,t){if(_)return $(5,1,e,t)}function Qe(e,t,n){if(_)return $(6,1,e,t,n)}function Ze(e,t,n){return _?$(7,1,e,t,n):0}function c(e,t){if(_)return $(8,1,e,t)}function W(e,t,n){if(_)return $(9,1,e,t,n)}function G(e,t,n,f){if(_)return $(10,1,e,t,n,f)}function Se(e,t,n,f){if(_)return $(11,1,e,t,n,f)}function Ke(e,t,n,f){if(_)return $(12,1,e,t,n,f)}function Bt(e){if(_)return $(13,1,e)}function Wt(e,t){if(_)return $(14,1,e,t)}function kt(e,t,n){if(_)return $(15,1,e,t,n)}function mt(e){e>>>=0,typeof Atomics.rb=="function"&&(Atomics.rb(l(),e>>>2,e).value.then(ft),e+=128,Atomics.store(l(),e>>>2,1))}i.__emscripten_thread_mailbox_await=mt;var ft=()=>{var e=lt();if(e&&(mt(e),e=or,!P))try{if(e(),!(0<Le))try{_?Ot(te):Ye(te)}catch(t){t instanceof Pe||t=="unwind"||F(1,t)}}catch(t){t instanceof Pe||t=="unwind"||F(1,t)}};i.checkMailbox=ft;var gt=[],je=e=>e%4===0&&(e%100!==0||e%400===0),Nt=[0,31,60,91,121,152,182,213,244,274,305,335],Ht=[0,31,59,90,120,151,181,212,243,273,304,334];function $t(e,t,n,f,y,b,v,z){return _?$(16,1,e,t,n,f,y,b,v,z):-52}function Gt(e,t,n,f,y,b,v){if(_)return $(17,1,e,t,n,f,y,b,v)}var Yt=e=>{var t=K(e)+1,n=rr(t);return n&&oe(e,n,t),n},ht=[],yt={},jt=()=>{if(!bt){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:B||"./this.program"},t;for(t in yt)yt[t]===void 0?delete e[t]:e[t]=yt[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);bt=n}return bt},bt;function zt(e,t){if(_)return $(18,1,e,t);e>>>=0,t>>>=0;var n=0;return jt().forEach((f,y)=>{var b=t+n;for(y=w()[e+4*y>>>2>>>0]=b,b=0;b<f.length;++b)a()[y++>>>0>>>0]=f.charCodeAt(b);a()[y>>>0>>>0]=0,n+=f.length+1}),0}function qt(e,t){if(_)return $(19,1,e,t);e>>>=0,t>>>=0;var n=jt();w()[e>>>2>>>0]=n.length;var f=0;return n.forEach(y=>f+=y.length+1),w()[t>>>2>>>0]=f,0}function Vt(e){return _?$(20,1,e):52}function Jt(e,t,n,f){return _?$(21,1,e,t,n,f):52}function Xt(e,t,n,f,y){return _?$(22,1,e,t,n,f,y):70}var Gr=[null,[],[]];function Qt(e,t,n,f){if(_)return $(23,1,e,t,n,f);t>>>=0,n>>>=0,f>>>=0;for(var y=0,b=0;b<n;b++){var v=w()[t>>>2>>>0],z=w()[t+4>>>2>>>0];t+=8;for(var Te=0;Te<z;Te++){var ne=h()[v+Te>>>0],me=Gr[e];ne===0||ne===10?((e===1?Ie:ee)(Ve(me,0)),me.length=0):me.push(ne)}y+=z}return w()[f>>>2>>>0]=y,0}var Zt=[31,29,31,30,31,30,31,31,30,31,30,31],Kt=[31,28,31,30,31,30,31,31,30,31,30,31];function Yr(e){var t=Array(K(e)+1);return le(e,t,0,t.length),t}var jr=(e,t)=>{a().set(e,t>>>0)};function er(e,t,n,f){function y(p,H,q){for(p=typeof p=="number"?p.toString():p||"";p.length<H;)p=q[0]+p;return p}function b(p,H){return y(p,H,"0")}function v(p,H){function q(cr){return 0>cr?-1:0<cr?1:0}var We;return(We=q(p.getFullYear()-H.getFullYear()))===0&&(We=q(p.getMonth()-H.getMonth()))===0&&(We=q(p.getDate()-H.getDate())),We}function z(p){switch(p.getDay()){case 0:return new Date(p.getFullYear()-1,11,29);case 1:return p;case 2:return new Date(p.getFullYear(),0,3);case 3:return new Date(p.getFullYear(),0,2);case 4:return new Date(p.getFullYear(),0,1);case 5:return new Date(p.getFullYear()-1,11,31);case 6:return new Date(p.getFullYear()-1,11,30)}}function Te(p){var H=p.Ra;for(p=new Date(new Date(p.Sa+1900,0,1).getTime());0<H;){var q=p.getMonth(),We=(je(p.getFullYear())?Zt:Kt)[q];if(H>We-p.getDate())H-=We-p.getDate()+1,p.setDate(1),11>q?p.setMonth(q+1):(p.setMonth(0),p.setFullYear(p.getFullYear()+1));else{p.setDate(p.getDate()+H);break}}return q=new Date(p.getFullYear()+1,0,4),H=z(new Date(p.getFullYear(),0,4)),q=z(q),0>=v(H,p)?0>=v(q,p)?p.getFullYear()+1:p.getFullYear():p.getFullYear()-1}e>>>=0,t>>>=0,n>>>=0,f>>>=0;var ne=w()[f+40>>>2>>>0];f={ob:l()[f>>>2>>>0],nb:l()[f+4>>>2>>>0],Ta:l()[f+8>>>2>>>0],Xa:l()[f+12>>>2>>>0],Ua:l()[f+16>>>2>>>0],Sa:l()[f+20>>>2>>>0],Na:l()[f+24>>>2>>>0],Ra:l()[f+28>>>2>>>0],ub:l()[f+32>>>2>>>0],mb:l()[f+36>>>2>>>0],pb:ne?Ge(ne):""},n=Ge(n),ne={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var me in ne)n=n.replace(new RegExp(me,"g"),ne[me]);var fr="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),lr="January February March April May June July August September October November December".split(" ");ne={"%a":p=>fr[p.Na].substring(0,3),"%A":p=>fr[p.Na],"%b":p=>lr[p.Ua].substring(0,3),"%B":p=>lr[p.Ua],"%C":p=>b((p.Sa+1900)/100|0,2),"%d":p=>b(p.Xa,2),"%e":p=>y(p.Xa,2," "),"%g":p=>Te(p).toString().substring(2),"%G":p=>Te(p),"%H":p=>b(p.Ta,2),"%I":p=>(p=p.Ta,p==0?p=12:12<p&&(p-=12),b(p,2)),"%j":p=>{for(var H=0,q=0;q<=p.Ua-1;H+=(je(p.Sa+1900)?Zt:Kt)[q++]);return b(p.Xa+H,3)},"%m":p=>b(p.Ua+1,2),"%M":p=>b(p.nb,2),"%n":()=>`\n`,"%p":p=>0<=p.Ta&&12>p.Ta?"AM":"PM","%S":p=>b(p.ob,2),"%t":()=>"\t","%u":p=>p.Na||7,"%U":p=>b(Math.floor((p.Ra+7-p.Na)/7),2),"%V":p=>{var H=Math.floor((p.Ra+7-(p.Na+6)%7)/7);if(2>=(p.Na+371-p.Ra-2)%7&&H++,H)H==53&&(q=(p.Na+371-p.Ra)%7,q==4||q==3&&je(p.Sa)||(H=1));else{H=52;var q=(p.Na+7-p.Ra-1)%7;(q==4||q==5&&je(p.Sa%400-1))&&H++}return b(H,2)},"%w":p=>p.Na,"%W":p=>b(Math.floor((p.Ra+7-(p.Na+6)%7)/7),2),"%y":p=>(p.Sa+1900).toString().substring(2),"%Y":p=>p.Sa+1900,"%z":p=>{p=p.mb;var H=0<=p;return p=Math.abs(p)/60,(H?"+":"-")+("0000"+(p/60*100+p%60)).slice(-4)},"%Z":p=>p.pb,"%%":()=>"%"},n=n.replace(/%%/g,"\\0\\0");for(me in ne)n.includes(me)&&(n=n.replace(new RegExp(me,"g"),ne[me](f)));return n=n.replace(/\\0\\0/g,"%"),me=Yr(n),me.length>t?0:(jr(me,e),me.length-1)}M.Wa();var zr=[C,ut,m,S,R,se,Qe,Ze,c,W,G,Se,Ke,Bt,Wt,kt,$t,Gt,zt,qt,Vt,Jt,Xt,Qt],qr={b:function(e,t,n){throw e>>>=0,new r(e).Wa(t>>>0,n>>>0),o=e,s++,o},L:function(e){nr(e>>>0,!k,1,!U,131072,!1),M.ab()},j:function(e){e>>>=0,_?postMessage({cmd:"cleanupThread",thread:e}):M.Za(M.Ma[e])},H:O,h:S,S:R,D:se,F:Qe,T:Ze,Q:c,J:W,P:G,n:Se,E:Ke,B:Bt,R:Wt,C:kt,p:()=>1,z:function(e,t){e>>>=0,e==t>>>0?setTimeout(()=>ft()):_?postMessage({targetThread:e,cmd:"checkMailbox"}):(e=M.Ma[e])&&e.postMessage({cmd:"checkMailbox"})},I:function(e,t,n,f){t>>>=0,gt.length=n,f=f>>>0>>>3;for(var y=0;y<n;y++)gt[y]=g()[f+y>>>0];return e=0>e?Ne[-e-1]:zr[e],M.ib=t,t=e.apply(null,gt),M.ib=0,t},K:mt,o:function(e){L&&M.Ma[e>>>0].ref()},s:function(e,t,n){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,n>>>=0,e=new Date(1e3*e),l()[n>>>2>>>0]=e.getUTCSeconds(),l()[n+4>>>2>>>0]=e.getUTCMinutes(),l()[n+8>>>2>>>0]=e.getUTCHours(),l()[n+12>>>2>>>0]=e.getUTCDate(),l()[n+16>>>2>>>0]=e.getUTCMonth(),l()[n+20>>>2>>>0]=e.getUTCFullYear()-1900,l()[n+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,l()[n+28>>>2>>>0]=e},t:function(e,t,n){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,n>>>=0,e=new Date(1e3*e),l()[n>>>2>>>0]=e.getSeconds(),l()[n+4>>>2>>>0]=e.getMinutes(),l()[n+8>>>2>>>0]=e.getHours(),l()[n+12>>>2>>>0]=e.getDate(),l()[n+16>>>2>>>0]=e.getMonth(),l()[n+20>>>2>>>0]=e.getFullYear()-1900,l()[n+24>>>2>>>0]=e.getDay(),t=(je(e.getFullYear())?Nt:Ht)[e.getMonth()]+e.getDate()-1|0,l()[n+28>>>2>>>0]=t,l()[n+36>>>2>>>0]=-(60*e.getTimezoneOffset()),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var f=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=(t!=f&&e.getTimezoneOffset()==Math.min(f,t))|0,l()[n+32>>>2>>>0]=e},u:function(e){e>>>=0;var t=new Date(l()[e+20>>>2>>>0]+1900,l()[e+16>>>2>>>0],l()[e+12>>>2>>>0],l()[e+8>>>2>>>0],l()[e+4>>>2>>>0],l()[e>>>2>>>0],0),n=l()[e+32>>>2>>>0],f=t.getTimezoneOffset(),y=new Date(t.getFullYear(),6,1).getTimezoneOffset(),b=new Date(t.getFullYear(),0,1).getTimezoneOffset(),v=Math.min(b,y);return 0>n?l()[e+32>>>2>>>0]=+(y!=b&&v==f):0<n!=(v==f)&&(y=Math.max(b,y),t.setTime(t.getTime()+6e4*((0<n?v:y)-f))),l()[e+24>>>2>>>0]=t.getDay(),n=(je(t.getFullYear())?Nt:Ht)[t.getMonth()]+t.getDate()-1|0,l()[e+28>>>2>>>0]=n,l()[e>>>2>>>0]=t.getSeconds(),l()[e+4>>>2>>>0]=t.getMinutes(),l()[e+8>>>2>>>0]=t.getHours(),l()[e+12>>>2>>>0]=t.getDate(),l()[e+16>>>2>>>0]=t.getMonth(),l()[e+20>>>2>>>0]=t.getYear(),e=t.getTime(),isNaN(e)?(l()[tr()>>>2>>>0]=61,e=-1):e/=1e3,sr((De=e,1<=+Math.abs(De)?0<De?+Math.floor(De/4294967296)>>>0:~~+Math.ceil((De-+(~~De>>>0))/4294967296)>>>0:0)),e>>>0},q:$t,r:Gt,y:function(e,t,n){function f(ne){return(ne=ne.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?ne[1]:"GMT"}e>>>=0,t>>>=0,n>>>=0;var y=new Date().getFullYear(),b=new Date(y,0,1),v=new Date(y,6,1);y=b.getTimezoneOffset();var z=v.getTimezoneOffset(),Te=Math.max(y,z);w()[e>>>2>>>0]=60*Te,l()[t>>>2>>>0]=+(y!=z),e=f(b),t=f(v),e=Yt(e),t=Yt(t),z<y?(w()[n>>>2>>>0]=e,w()[n+4>>>2>>>0]=t):(w()[n>>>2>>>0]=t,w()[n+4>>>2>>>0]=e)},c:()=>{Z("")},O:function(e,t,n){e>>>=0,t>>>=0,n>>>=0,ht.length=0;for(var f;f=h()[t++>>>0];){var y=f!=105;y&=f!=112,n+=y&&n%8?4:0,ht.push(f==112?w()[n>>>2>>>0]:f==105?l()[n>>>2>>>0]:g()[n>>>3>>>0]),n+=y?8:4}return Ne[e].apply(null,ht)},k:()=>{},i:()=>Date.now(),U:()=>{throw Le+=1,"unwind"},A:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:()=>L?(wr(),tt(br)).cpus().length:navigator.hardwareConcurrency,x:function(e){e>>>=0;var t=h().length;if(e<=t||4294901760<e)return!1;for(var n=1;4>=n;n*=2){var f=t*(1+.2/n);f=Math.min(f,e+100663296);var y=Math;f=Math.max(e,f);e:{y=(y.min.call(y,4294901760,f+(65536-f%65536)%65536)-j.buffer.byteLength+65535)/65536;try{j.grow(y),we();var b=1;break e}catch{}b=void 0}if(b)return!0}return!1},M:zt,N:qt,G:Ye,g:Vt,m:Jt,v:Xt,l:Qt,a:j||i.wasmMemory,w:er,d:function(e,t,n,f){return er(e>>>0,t>>>0,n>>>0,f>>>0)}},T=function(){function e(n,f){return T=n.exports,T=Vr(),M.bb.push(T.za),Xe=T.Aa,Fe.unshift(T.V),ce=f,re(),T}var t={a:qr};if(pe++,i.instantiateWasm)try{return i.instantiateWasm(t,e)}catch(n){ee(`Module.instantiateWasm callback failed with error: ${n}`),D(n)}return at(t,function(n){e(n.instance,n.module)}).catch(D),{}}();i._OrtInit=(e,t)=>(i._OrtInit=T.W)(e,t),i._OrtGetLastError=(e,t)=>(i._OrtGetLastError=T.X)(e,t),i._OrtCreateSessionOptions=(e,t,n,f,y,b,v,z,Te,ne)=>(i._OrtCreateSessionOptions=T.Y)(e,t,n,f,y,b,v,z,Te,ne),i._OrtAppendExecutionProvider=(e,t)=>(i._OrtAppendExecutionProvider=T.Z)(e,t),i._OrtAddFreeDimensionOverride=(e,t,n)=>(i._OrtAddFreeDimensionOverride=T._)(e,t,n),i._OrtAddSessionConfigEntry=(e,t,n)=>(i._OrtAddSessionConfigEntry=T.$)(e,t,n),i._OrtReleaseSessionOptions=e=>(i._OrtReleaseSessionOptions=T.aa)(e),i._OrtCreateSession=(e,t,n)=>(i._OrtCreateSession=T.ba)(e,t,n),i._OrtReleaseSession=e=>(i._OrtReleaseSession=T.ca)(e),i._OrtGetInputOutputCount=(e,t,n)=>(i._OrtGetInputOutputCount=T.da)(e,t,n),i._OrtGetInputName=(e,t)=>(i._OrtGetInputName=T.ea)(e,t),i._OrtGetOutputName=(e,t)=>(i._OrtGetOutputName=T.fa)(e,t),i._OrtFree=e=>(i._OrtFree=T.ga)(e),i._OrtCreateTensor=(e,t,n,f,y,b)=>(i._OrtCreateTensor=T.ha)(e,t,n,f,y,b),i._OrtGetTensorData=(e,t,n,f,y)=>(i._OrtGetTensorData=T.ia)(e,t,n,f,y),i._OrtReleaseTensor=e=>(i._OrtReleaseTensor=T.ja)(e),i._OrtCreateRunOptions=(e,t,n,f)=>(i._OrtCreateRunOptions=T.ka)(e,t,n,f),i._OrtAddRunConfigEntry=(e,t,n)=>(i._OrtAddRunConfigEntry=T.la)(e,t,n),i._OrtReleaseRunOptions=e=>(i._OrtReleaseRunOptions=T.ma)(e),i._OrtCreateBinding=e=>(i._OrtCreateBinding=T.na)(e),i._OrtBindInput=(e,t,n)=>(i._OrtBindInput=T.oa)(e,t,n),i._OrtBindOutput=(e,t,n,f)=>(i._OrtBindOutput=T.pa)(e,t,n,f),i._OrtClearBoundOutputs=e=>(i._OrtClearBoundOutputs=T.qa)(e),i._OrtReleaseBinding=e=>(i._OrtReleaseBinding=T.ra)(e),i._OrtRunWithBinding=(e,t,n,f,y)=>(i._OrtRunWithBinding=T.sa)(e,t,n,f,y),i._OrtRun=(e,t,n,f,y,b,v,z)=>(i._OrtRun=T.ta)(e,t,n,f,y,b,v,z),i._OrtEndProfiling=e=>(i._OrtEndProfiling=T.ua)(e);var tr=()=>(tr=T.va)(),lt=i._pthread_self=()=>(lt=i._pthread_self=T.wa)(),rr=i._malloc=e=>(rr=i._malloc=T.xa)(e);i._free=e=>(i._free=T.ya)(e),i.__emscripten_tls_init=()=>(i.__emscripten_tls_init=T.za)();var nr=i.__emscripten_thread_init=(e,t,n,f,y,b)=>(nr=i.__emscripten_thread_init=T.Ba)(e,t,n,f,y,b);i.__emscripten_thread_crashed=()=>(i.__emscripten_thread_crashed=T.Ca)();var ar=(e,t,n,f)=>(ar=T.Da)(e,t,n,f),wt=e=>(wt=T.Ea)(e),Ot=i.__emscripten_thread_exit=e=>(Ot=i.__emscripten_thread_exit=T.Fa)(e),or=()=>(or=T.Ga)(),sr=e=>(sr=T.Ha)(e),ir=(e,t)=>(ir=T.Ia)(e,t),vt=()=>(vt=T.Ja)(),ct=e=>(ct=T.Ka)(e),_t=e=>(_t=T.La)(e);function Vr(){var e=T;e=Object.assign({},e);var t=f=>()=>f()>>>0,n=f=>y=>f(y)>>>0;return e.va=t(e.va),e.wa=t(e.wa),e.xa=n(e.xa),e.emscripten_main_runtime_thread_id=t(e.emscripten_main_runtime_thread_id),e.Ja=t(e.Ja),e.La=n(e.La),e}i.wasmMemory=j,i.stackAlloc=_t,i.stackSave=vt,i.stackRestore=ct,i.keepRuntimeAlive=()=>0<Le,i.UTF8ToString=Ge,i.stringToUTF8=oe,i.lengthBytesUTF8=K,i.ExitStatus=Pe,i.PThread=M;var dt;ve=function e(){dt||ur(),dt||(ve=e)};function ur(){if(!(0<pe))if(_)A(i),_||Be(Fe),startWorker(i);else{if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)Me.unshift(i.preRun.shift());Be(Me),0<pe||dt||(dt=!0,i.calledRun=!0,P||(_||Be(Fe),A(i),_||Be(Ee)))}}return ur(),d.ready}})();typeof vr=="object"&&typeof Ft=="object"?Ft.exports=Or:typeof define=="function"&&define.amd&&define([],()=>Or)});var Er=et((On,nn)=>{nn.exports=\'"use strict";var Module={},ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads"),parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",e=>onmessage({data:e}));var fs=require("fs"),vm=require("vm");Object.assign(global,{self:global,require,Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:e=>vm.runInThisContext(fs.readFileSync(e,"utf8"),{filename:e}),postMessage:e=>parentPort.postMessage(e),performance:global.performance||{now:Date.now}})}var initializedJS=!1;function threadPrintErr(){var e=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,e+`\\n`);return}console.error(e)}function threadAlert(){var e=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:e,threadId:Module._pthread_self()})}var err=threadPrintErr;self.alert=threadAlert,Module.instantiateWasm=(e,t)=>{var a=Module.wasmModule;Module.wasmModule=null;var r=new WebAssembly.Instance(a,e);return t(r)},self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{if(e.data.cmd==="load"){let a=[];self.onmessage=r=>a.push(r),self.startWorker=r=>{Module=r,postMessage({cmd:"loaded"});for(let s of a)handleMessage(s);self.onmessage=handleMessage},Module.wasmModule=e.data.wasmModule;for(const r of e.data.handlers)Module[r]=(...s)=>{postMessage({cmd:"callHandler",handler:r,args:s})};if(Module.wasmMemory=e.data.wasmMemory,Module.buffer=Module.wasmMemory.buffer,Module.ENVIRONMENT_IS_PTHREAD=!0,typeof e.data.urlOrBlob=="string")importScripts(e.data.urlOrBlob);else{var t=URL.createObjectURL(e.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}ortWasmThreaded(Module)}else if(e.data.cmd==="run"){Module.__emscripten_thread_init(e.data.pthread_ptr,0,0,1),Module.__emscripten_thread_mailbox_await(e.data.pthread_ptr),Module.establishStackSpace(),Module.PThread.receiveObjectTransfer(e.data),Module.PThread.threadInitTLS(),initializedJS||(initializedJS=!0);try{Module.invokeEntryPoint(e.data.start_routine,e.data.arg)}catch(a){if(a!="unwind")throw a}}else e.data.cmd==="cancel"?Module._pthread_self()&&Module.__emscripten_thread_exit(-1):e.data.target==="setimmediate"||(e.data.cmd==="checkMailbox"?initializedJS&&Module.checkMailbox():e.data.cmd&&(err(`worker.js received unknown command ${e.data.cmd}`),err(e.data)))}catch(a){throw Module.__emscripten_thread_crashed?.(),a}}self.onmessage=handleMessage;\\n\'});var Tr;Tr=gr();var an=_r(),Ut,Pt=!1,pt=!1,Sr=!1,on=u=>{if(u===1)return!1;if(typeof SharedArrayBuffer>"u")return typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+u+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),!1;typeof process<"u"&&process.versions&&process.versions.node&&console.warn("env.wasm.numThreads is set to "+u+", however, currently onnxruntime-web does not support multi-threads in Node.js. Please consider using onnxruntime-node for performance critical scenarios.");try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},sn=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},un=(u,d)=>u?d?"ort-wasm-simd-threaded.wasm":"ort-wasm-simd.wasm":d?"ort-wasm-threaded.wasm":"ort-wasm.wasm",Ar=async u=>{if(Pt)return Promise.resolve();if(pt)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(Sr)throw new Error("previous call to \'initializeWebAssembly()\' failed.");pt=!0;let d=u.initTimeout,a=u.numThreads,h=u.simd,l=on(a),w=h&&sn(),g=u.wasmPaths,i=typeof g=="string"?g:void 0,A=un(w,l),D=typeof g=="object"?g[A]:void 0,I=!1,B=[];if(d>0&&B.push(new Promise(F=>{setTimeout(()=>{I=!0,F()},d)})),B.push(new Promise((F,U)=>{let k=l?an:Tr,L={locateFile:(_,x)=>l&&_.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([Er()],{type:"text/javascript"})):_.endsWith(".wasm")?D||(i??x)+A:x+_};if(l)if(L.numThreads=a,typeof Blob>"u")L.mainScriptUrlOrBlob=(void 0)(__dirname,"ort-wasm-threaded.js");else{let _=`var ortWasmThreaded=${k.toString()};`;L.mainScriptUrlOrBlob=new Blob([_],{type:"text/javascript"})}k(L).then(_=>{pt=!1,Pt=!0,Ut=_,F()},_=>{pt=!1,Sr=!0,U(_)})})),await Promise.race(B),I)throw new Error(`WebAssembly backend initializing failed due to timeout: ${d}ms`)},X=()=>{if(Pt&&Ut)return Ut;throw new Error("WebAssembly is not initialized yet.")};var Q=(u,d)=>{let a=X(),h=a.lengthBytesUTF8(u)+1,l=a._malloc(h);return a.stringToUTF8(u,l,h),d.push(l),l},rt=(u,d,a,h)=>{if(typeof u=="object"&&u!==null){if(a.has(u))throw new Error("Circular reference in options");a.add(u)}Object.entries(u).forEach(([l,w])=>{let g=d?d+l:l;if(typeof w=="object")rt(w,g+".",a,h);else if(typeof w=="string"||typeof w=="number")h(g,w.toString());else if(typeof w=="boolean")h(g,w?"1":"0");else throw new Error(`Can\'t handle extra config type: ${typeof w}`)})},V=u=>{let d=X(),a=d.stackSave();try{let h=d.stackAlloc(8);d._OrtGetLastError(h,h+4);let l=d.HEAP32[h/4],w=d.HEAPU32[h/4+1],g=w?d.UTF8ToString(w):"";throw new Error(`${u} ERROR_CODE: ${l}, ERROR_MESSAGE: ${g}`)}finally{d.stackRestore(a)}};var Mr=u=>{let d=X(),a=0,h=[],l=u||{};try{if(u?.logSeverityLevel===void 0)l.logSeverityLevel=2;else if(typeof u.logSeverityLevel!="number"||!Number.isInteger(u.logSeverityLevel)||u.logSeverityLevel<0||u.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${u.logSeverityLevel}`);if(u?.logVerbosityLevel===void 0)l.logVerbosityLevel=0;else if(typeof u.logVerbosityLevel!="number"||!Number.isInteger(u.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${u.logVerbosityLevel}`);u?.terminate===void 0&&(l.terminate=!1);let w=0;return u?.tag!==void 0&&(w=Q(u.tag,h)),a=d._OrtCreateRunOptions(l.logSeverityLevel,l.logVerbosityLevel,!!l.terminate,w),a===0&&V("Can\'t create run options."),u?.extra!==void 0&&rt(u.extra,"",new WeakSet,(g,i)=>{let A=Q(g,h),D=Q(i,h);d._OrtAddRunConfigEntry(a,A,D)!==0&&V(`Can\'t set a run config entry: ${g} - ${i}.`)}),[a,h]}catch(w){throw a!==0&&d._OrtReleaseRunOptions(a),h.forEach(g=>d._free(g)),w}};var fn=u=>{switch(u){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${u}`)}},ln=u=>{switch(u){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${u}`)}},cn=u=>{u.extra||(u.extra={}),u.extra.session||(u.extra.session={});let d=u.extra.session;d.use_ort_model_bytes_directly||(d.use_ort_model_bytes_directly="1"),u.executionProviders&&u.executionProviders.some(a=>(typeof a=="string"?a:a.name)==="webgpu")&&(u.enableMemPattern=!1)},dn=(u,d,a)=>{for(let h of d){let l=typeof h=="string"?h:h.name;switch(l){case"webnn":if(l="WEBNN",typeof h!="string"){let g=h;if(g?.deviceType){let i=Q("deviceType",a),A=Q(g.deviceType,a);X()._OrtAddSessionConfigEntry(u,i,A)!==0&&V(`Can\'t set a session config entry: \'deviceType\' - ${g.deviceType}.`)}if(g?.numThreads){let i=g.numThreads;(typeof i!="number"||!Number.isInteger(i)||i<0)&&(i=0);let A=Q("numThreads",a),D=Q(i.toString(),a);X()._OrtAddSessionConfigEntry(u,A,D)!==0&&V(`Can\'t set a session config entry: \'numThreads\' - ${g.numThreads}.`)}if(g?.powerPreference){let i=Q("powerPreference",a),A=Q(g.powerPreference,a);X()._OrtAddSessionConfigEntry(u,i,A)!==0&&V(`Can\'t set a session config entry: \'powerPreference\' - ${g.powerPreference}.`)}}break;case"webgpu":if(l="JS",typeof h!="string"){let g=h;if(g?.preferredLayout){if(g.preferredLayout!=="NCHW"&&g.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either \'NCHW\' or \'NHWC\': ${g.preferredLayout}`);let i=Q("preferredLayout",a),A=Q(g.preferredLayout,a);X()._OrtAddSessionConfigEntry(u,i,A)!==0&&V(`Can\'t set a session config entry: \'preferredLayout\' - ${g.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${l}`)}let w=Q(l,a);X()._OrtAppendExecutionProvider(u,w)!==0&&V(`Can\'t append execution provider: ${l}.`)}},Cr=u=>{let d=X(),a=0,h=[],l=u||{};cn(l);try{let w=fn(l.graphOptimizationLevel??"all"),g=ln(l.executionMode??"sequential"),i=typeof l.logId=="string"?Q(l.logId,h):0,A=l.logSeverityLevel??2;if(!Number.isInteger(A)||A<0||A>4)throw new Error(`log serverity level is not valid: ${A}`);let D=l.logVerbosityLevel??0;if(!Number.isInteger(D)||D<0||D>4)throw new Error(`log verbosity level is not valid: ${D}`);let I=typeof l.optimizedModelFilePath=="string"?Q(l.optimizedModelFilePath,h):0;if(a=d._OrtCreateSessionOptions(w,!!l.enableCpuMemArena,!!l.enableMemPattern,g,!!l.enableProfiling,0,i,A,D,I),a===0&&V("Can\'t create session options."),l.executionProviders&&dn(a,l.executionProviders,h),l.freeDimensionOverrides)for(let[B,F]of Object.entries(l.freeDimensionOverrides)){if(typeof B!="string")throw new Error(`free dimension override name must be a string: ${B}`);if(typeof F!="number"||!Number.isInteger(F)||F<0)throw new Error(`free dimension override value must be a non-negative integer: ${F}`);let U=Q(B,h);d._OrtAddFreeDimensionOverride(a,U,F)!==0&&V(`Can\'t set a free dimension override: ${B} - ${F}.`)}return l.extra!==void 0&&rt(l.extra,"",new WeakSet,(B,F)=>{let U=Q(B,h),k=Q(F,h);d._OrtAddSessionConfigEntry(a,U,k)!==0&&V(`Can\'t set a session config entry: ${B} - ${F}.`)}),[a,h]}catch(w){throw a!==0&&d._OrtReleaseSessionOptions(a),h.forEach(g=>d._free(g)),w}};var Rt=u=>{switch(u){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${u}`)}},Dr=u=>{switch(u){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${u}`)}},It=u=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][u],xr=u=>{switch(u){case"float16":return Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${u}`)}},Fr=u=>{switch(u){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${u}`)}},Ur=u=>u==="float32"||u==="int32"||u==="int64"||u==="bool"||u==="float16"||u==="uint32",Pr=u=>{switch(u){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;default:throw new Error(`unsupported data location: ${u}`)}};var Rr=async u=>{if(typeof u=="string")if(typeof process<"u"&&process.versions&&process.versions.node)try{return new Uint8Array(await(void 0)(u))}catch(d){if(d.code==="ERR_FS_FILE_TOO_LARGE"){let a=(void 0)(u),h=[];for await(let l of a)h.push(l);return new Uint8Array(Buffer.concat(h))}throw d}else{let d=await fetch(u);if(!d.ok)throw new Error(`failed to load external data file: ${u}`);let a=d.headers.get("Content-Length"),h=a?parseInt(a,10):0;if(h<1073741824)return new Uint8Array(await d.arrayBuffer());{if(!d.body)throw new Error(`failed to load external data file: ${u}, no response body.`);let l=d.body.getReader(),w;try{w=new ArrayBuffer(h)}catch(i){if(i instanceof RangeError){let A=Math.ceil(h/65536);w=new WebAssembly.Memory({initial:A,maximum:A}).buffer}else throw i}let g=0;for(;;){let{done:i,value:A}=await l.read();if(i)break;let D=A.byteLength;new Uint8Array(w,g,D).set(A),g+=D}return new Uint8Array(w,0,h)}}else return u instanceof Blob?new Uint8Array(await u.arrayBuffer()):u instanceof Uint8Array?u:new Uint8Array(u)};var pn=(u,d)=>{X()._OrtInit(u,d)!==0&&V("Can\'t initialize onnxruntime.")},Lr=async u=>{pn(u.wasm.numThreads,Fr(u.logLevel))},Br=async(u,d)=>{},nt=new Map,mn=u=>{let d=X(),a=d.stackSave();try{let h=d.stackAlloc(8);return d._OrtGetInputOutputCount(u,h,h+4)!==0&&V("Can\'t get session input/output count."),[d.HEAP32[h/4],d.HEAP32[h/4+1]]}finally{d.stackRestore(a)}},Lt=u=>{let d=X(),a=d._malloc(u.byteLength);if(a===0)throw new Error(`Can\'t create a session. failed to allocate a buffer of size ${u.byteLength}.`);return d.HEAPU8.set(u,a),[a,u.byteLength]},Wr=async(u,d)=>{let a,h,l=X();Array.isArray(u)?[a,h]=u:u.buffer===l.HEAPU8.buffer?[a,h]=[u.byteOffset,u.byteLength]:[a,h]=Lt(u);let w=0,g=0,i=0,A=[],D=[],I=[];try{if([g,A]=Cr(d),d?.externalData&&l.mountExternalData){let x=[];for(let N of d.externalData){let he=typeof N=="string"?N:N.path;x.push(Rr(typeof N=="string"?N:N.data).then(ie=>{l.mountExternalData(he,ie)}))}await Promise.all(x)}w=l._OrtCreateSession(a,h,g),w===0&&V("Can\'t create a session.");let[B,F]=mn(w),U=[],k=[],L=[];for(let x=0;x<B;x++){let N=l._OrtGetInputName(w,x);N===0&&V("Can\'t get an input name."),D.push(N),U.push(l.UTF8ToString(N))}for(let x=0;x<F;x++){let N=l._OrtGetOutputName(w,x);N===0&&V("Can\'t get an output name."),I.push(N);let he=l.UTF8ToString(N);k.push(he)}let _=null;return nt.set(w,[w,D,I,_]),[w,U,k]}catch(B){throw D.forEach(F=>l._OrtFree(F)),I.forEach(F=>l._OrtFree(F)),i!==0&&l._OrtReleaseBinding(i),w!==0&&l._OrtReleaseSession(w),B}finally{l._free(a),g!==0&&l._OrtReleaseSessionOptions(g),A.forEach(B=>l._free(B)),l.unmountExternalData?.()}},kr=u=>{let d=X(),a=nt.get(u);if(!a)throw new Error(`cannot release session. invalid session id: ${u}`);let[h,l,w,g]=a;g&&d._OrtReleaseBinding(g.handle),d.jsepUnregisterBuffers?.(u),l.forEach(i=>d._OrtFree(i)),w.forEach(i=>d._OrtFree(i)),d._OrtReleaseSession(h),nt.delete(u)},Ir=(u,d,a,h,l)=>{if(!u){d.push(0);return}let w=X(),g=u[0],i=u[1],A=u[3],D,I;if(g==="string"&&A==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");if(A==="gpu-buffer"){let U=u[2].gpuBuffer,k=It(Rt(g));I=i.reduce((L,_)=>L*_,1)*k,D=w.jsepRegisterBuffer(h,l,U,I)}else{let U=u[2];if(Array.isArray(U)){I=4*U.length,D=w._malloc(I),a.push(D);let k=D/4;for(let L=0;L<U.length;L++){if(typeof U[L]!="string")throw new TypeError(`tensor data at index ${L} is not a string`);w.HEAPU32[k++]=Q(U[L],a)}}else I=U.byteLength,D=w._malloc(I),a.push(D),w.HEAPU8.set(new Uint8Array(U.buffer,U.byteOffset,I),D)}let B=w.stackSave(),F=w.stackAlloc(4*i.length);try{let U=F/4;i.forEach(L=>w.HEAP32[U++]=L);let k=w._OrtCreateTensor(Rt(g),D,I,F,i.length,Pr(A));k===0&&V(`Can\'t create tensor for input/output. session=${h}, index=${l}.`),d.push(k)}finally{w.stackRestore(B)}},Nr=async(u,d,a,h,l,w)=>{let g=X(),i=nt.get(u);if(!i)throw new Error(`cannot run inference. invalid session id: ${u}`);let[A,D,I,B]=i,F=d.length,U=h.length,k=0,L=[],_=[],x=[],N=[],he=g.stackSave(),ie=g.stackAlloc(F*4),ae=g.stackAlloc(F*4),E=g.stackAlloc(U*4),Y=g.stackAlloc(U*4);try{[k,L]=Mr(w);for(let P=0;P<F;P++)Ir(a[P],_,N,u,d[P]);for(let P=0;P<U;P++)Ir(l[P],x,N,u,F+h[P]);let ue=ie/4,Re=ae/4,Ie=E/4,ee=Y/4;for(let P=0;P<F;P++)g.HEAPU32[ue++]=_[P],g.HEAPU32[Re++]=D[d[P]];for(let P=0;P<U;P++)g.HEAPU32[Ie++]=x[P],g.HEAPU32[ee++]=I[h[P]];let j;j=await g._OrtRun(A,ae,ie,F,Y,U,E,k),j!==0&&V("failed to call OrtRun().");let ce=[];for(let P=0;P<U;P++){let te=g.HEAPU32[E/4+P];if(te===x[P]){ce.push(l[P]);continue}let de=g.stackSave(),ge=g.stackAlloc(4*4),ye=!1,J,fe=0;try{g._OrtGetTensorData(te,ge,ge+4,ge+8,ge+12)!==0&&V(`Can\'t access output tensor data on index ${P}.`);let Ae=ge/4,Me=g.HEAPU32[Ae++];fe=g.HEAPU32[Ae++];let Fe=g.HEAPU32[Ae++],Ee=g.HEAPU32[Ae++],pe=[];for(let re=0;re<Ee;re++)pe.push(g.HEAPU32[Fe/4+re]);g._OrtFree(Fe);let Oe=pe.reduce((re,Z)=>re*Z,1);J=Dr(Me);let ve=B?.outputPreferredLocations[h[P]];if(J==="string"){if(ve==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");let re=[],Z=fe/4;for(let Ce=0;Ce<Oe;Ce++){let be=g.HEAPU32[Z++],_e=Ce===Oe-1?void 0:g.HEAPU32[Z]-be;re.push(g.UTF8ToString(be,_e))}ce.push([J,pe,re,"cpu"])}else if(ve==="gpu-buffer"&&Oe>0){let re=g.jsepGetBuffer(fe),Z=It(Me);if(Z===void 0||!Ur(J))throw new Error(`Unsupported data type: ${J}`);ye=!0,ce.push([J,pe,{gpuBuffer:re,download:g.jsepCreateDownloader(re,Oe*Z,J),dispose:()=>{g._OrtReleaseTensor(te)}},"gpu-buffer"])}else{let re=xr(J),Z=new re(Oe);new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength).set(g.HEAPU8.subarray(fe,fe+Z.byteLength)),ce.push([J,pe,Z,"cpu"])}}finally{g.stackRestore(de),J==="string"&&fe&&g._free(fe),ye||g._OrtReleaseTensor(te)}}return B&&g._OrtClearBoundOutputs(B.handle),ce}finally{g.stackRestore(he),_.forEach(ue=>g._OrtReleaseTensor(ue)),x.forEach(ue=>g._OrtReleaseTensor(ue)),N.forEach(ue=>g._free(ue)),k!==0&&g._OrtReleaseRunOptions(k),L.forEach(ue=>g._free(ue))}},Hr=u=>{let d=X(),a=nt.get(u);if(!a)throw new Error("invalid session id");let h=a[0],l=d._OrtEndProfiling(h);l===0&&V("Can\'t get an profile file name."),d._OrtFree(l)},$r=u=>{let d=[];for(let a of u){let h=a[2];!Array.isArray(h)&&"buffer"in h&&d.push(h.buffer)}return d};self.onmessage=u=>{let{type:d,in:a}=u.data;try{switch(d){case"init-wasm":Ar(a.wasm).then(()=>{Lr(a).then(()=>{postMessage({type:d})},h=>{postMessage({type:d,err:h})})},h=>{postMessage({type:d,err:h})});break;case"init-ep":{let{epName:h,env:l}=a;Br(l,h).then(()=>{postMessage({type:d})},w=>{postMessage({type:d,err:w})});break}case"copy-from":{let{buffer:h}=a,l=Lt(h);postMessage({type:d,out:l});break}case"create":{let{model:h,options:l}=a;Wr(h,l).then(w=>{postMessage({type:d,out:w})},w=>{postMessage({type:d,err:w})});break}case"release":kr(a),postMessage({type:d});break;case"run":{let{sessionId:h,inputIndices:l,inputs:w,outputIndices:g,options:i}=a;Nr(h,l,w,g,new Array(g.length).fill(null),i).then(A=>{A.some(D=>D[3]!=="cpu")?postMessage({type:d,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:d,out:A},$r(A))},A=>{postMessage({type:d,err:A})});break}case"end-profiling":Hr(a),postMessage({type:d});break;default:}}catch(h){postMessage({type:d,err:h})}};})();\n'})),vr,bt,Tn,Fo,$o,ha,ma,Vr,Wr,gg,Lo,id,ad,sd,ud,ld,fd,cd,ba=L((()=>{vt(),nd(),zr(),vr=()=>!!Z.wasm.proxy&&typeof document<"u",Tn=!1,Fo=!1,$o=!1,ma=new Map,Vr=(e,t)=>{let n=ma.get(e);n?n.push(t):ma.set(e,[t])},Wr=()=>{if(Tn||!Fo||$o||!bt)throw new Error("worker not ready")},gg=e=>{switch(e.data.type){case"init-wasm":Tn=!1,e.data.err?($o=!0,ha[1](e.data.err)):(Fo=!0,ha[0]());break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let t=ma.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},Lo=typeof document<"u"?document?.currentScript?.src:void 0,id=async()=>{if(!Fo){if(Tn)throw new Error("multiple calls to 'initWasm()' detected.");if($o)throw new Error("previous call to 'initWasm()' failed.");if(Tn=!0,vr())return void 0===Z.wasm.wasmPaths&&Lo&&0!==Lo.indexOf("blob:")&&(Z.wasm.wasmPaths=Lo.substr(0,+Lo.lastIndexOf("/")+1)),new Promise(((e,t)=>{bt?.terminate();let n=URL.createObjectURL(new Blob([od()],{type:"text/javascript"}));(bt=new Worker(n,{name:"ort-wasm-proxy-worker"})).onerror=e=>t(e),bt.onmessage=gg,URL.revokeObjectURL(n),ha=[e,t];let r={type:"init-wasm",in:Z};bt.postMessage(r)}));try{await Gp(Z.wasm),await Kp(Z),Fo=!0}catch(e){throw $o=!0,e}finally{Tn=!1}}},ad=async e=>{if(vr())return Wr(),new Promise(((t,n)=>{Vr("init-ep",[t,n]);let r={type:"init-ep",in:{epName:e,env:Z}};bt.postMessage(r)}));await Jp(Z,e)},sd=async e=>vr()?(Wr(),new Promise(((t,n)=>{Vr("copy-from",[t,n]);let r={type:"copy-from",in:{buffer:e}};bt.postMessage(r,[e.buffer])}))):da(e),ud=async(e,t)=>{if(vr()){if(t?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Wr(),new Promise(((n,r)=>{Vr("create",[n,r]);let o={type:"create",in:{model:e,options:t}},i=[];e instanceof Uint8Array&&i.push(e.buffer),bt.postMessage(o,i)}))}return Zp(e,t)},ld=async e=>{if(vr())return Wr(),new Promise(((t,n)=>{Vr("release",[t,n]);let r={type:"release",in:e};bt.postMessage(r)}));Qp(e)},fd=async(e,t,n,r,o,i)=>{if(vr()){if(n.some((e=>"cpu"!==e[3])))throw new Error("input tensor on GPU is not supported for proxy.");if(o.some((e=>e)))throw new Error("pre-allocated output tensor is not supported for proxy.");return Wr(),new Promise(((o,a)=>{Vr("run",[o,a]);let s=n,u={type:"run",in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:i}};bt.postMessage(u,rd(s))}))}return ed(e,t,n,r,o,i)},cd=async e=>{if(vr())return Wr(),new Promise(((t,n)=>{Vr("end-profiling",[t,n]);let r={type:"end-profiling",in:e};bt.postMessage(r)}));td(e)}})),pd,yg,Co,dd=L((()=>{vt(),ba(),ca(),pa(),pd=(e,t)=>{switch(e.location){case"cpu":return[e.type,e.dims,e.data,"cpu"];case"gpu-buffer":return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},"gpu-buffer"];default:throw new Error(`invalid data location: ${e.location} for ${t()}`)}},yg=e=>{switch(e[3]){case"cpu":return new ke(e[0],e[2],e[1]);case"gpu-buffer":{let t=e[0];if(!Do(t))throw new Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:o}=e[2];return ke.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:o})}default:throw new Error(`invalid data location: ${e[3]}`)}},Co=class{async fetchModelAndCopyToWasmMemory(e){return sd(await gn(e))}async loadModel(e,t){let n;Xt(),n="string"==typeof e?typeof process<"u"&&process.versions&&process.versions.node?await gn(e):await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames]=await ud(n,t),Kt()}async dispose(){return ld(this.sessionId)}async run(e,t,n){Xt();let r=[],o=[];Object.entries(e).forEach((e=>{let t=e[0],n=e[1],i=this.inputNames.indexOf(t);if(-1===i)throw new Error(`invalid input '${t}'`);r.push(n),o.push(i)}));let i=[],a=[];Object.entries(t).forEach((e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(-1===r)throw new Error(`invalid output '${t}'`);i.push(n),a.push(r)}));let s=r.map(((e,t)=>pd(e,(()=>`input "${this.inputNames[o[t]]}"`)))),u=i.map(((e,t)=>e?pd(e,(()=>`output "${this.outputNames[a[t]]}"`)):null)),l=await fd(this.sessionId,o,s,a,u,n),c={};for(let e=0;e<l.length;e++)c[this.outputNames[a[e]]]=i[e]??yg(l[e]);return Kt(),c}startProfiling(){}endProfiling(){cd(this.sessionId)}}})),Tg,ko,hd=L((()=>{vt(),ba(),dd(),Tg=()=>{if(("number"!=typeof Z.wasm.initTimeout||Z.wasm.initTimeout<0)&&(Z.wasm.initTimeout=0),"boolean"!=typeof Z.wasm.simd&&(Z.wasm.simd=!0),"boolean"!=typeof Z.wasm.proxy&&(Z.wasm.proxy=!1),"boolean"!=typeof Z.wasm.trace&&(Z.wasm.trace=!1),"number"!=typeof Z.wasm.numThreads||!Number.isInteger(Z.wasm.numThreads)||Z.wasm.numThreads<=0){(typeof self<"u"&&!self.crossOriginIsolated||typeof process<"u"&&process.versions&&process.versions.node)&&(Z.wasm.numThreads=1);let e=typeof navigator>"u"?(void 0)().length:navigator.hardwareConcurrency;Z.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},ko=class{async init(e){Tg(),await id(),await ad(e)}async createInferenceSessionHandler(e,t){let n=new Co;return await n.loadModel(e,t),Promise.resolve(n)}}})),md={};ar(md,{wasmBackend:()=>xg});var xg,bd=L((()=>{hd(),xg=new ko})),wg={};ar(wg,{InferenceSession:()=>hs,TRACE:()=>jo,TRACE_FUNC_BEGIN:()=>Xt,TRACE_FUNC_END:()=>Kt,Tensor:()=>ke,TrainingSession:()=>ys,default:()=>vg,env:()=>Z,registerBackend:()=>Yt}),vt(),vt(),vt();var xs="1.17.1",vg=Xo;{let e=(Ip(),jt(Op)).onnxjsBackend;Yt("webgl",e,-10)}{let e=(bd(),jt(md)).wasmBackend;Yt("cpu",e,10),Yt("wasm",e,10),Yt("webnn",e,9)}return Object.defineProperty(Z.versions,"web",{value:xs,enumerable:!0}),jt(wg)})();