diff --git "a/js-esm/ort.min.js" "b/js-esm/ort.min.js"
new file mode 100644--- /dev/null
+++ "b/js-esm/ort.min.js"
@@ -0,0 +1,1827 @@
+/*!
+ * ONNX Runtime Web v1.19.0
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License.
+ */
+"use strict";var ort=(()=>{var wc=Object.create;var dr=Object.defineProperty;var vc=Object.getOwnPropertyDescriptor;var Ic=Object.getOwnPropertyNames;var _c=Object.getPrototypeOf,Sc=Object.prototype.hasOwnProperty;var En=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var x=(i,e)=>()=>(i&&(e=i(i=0)),e);var tt=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),ze=(i,e)=>{for(var o in e)dr(i,o,{get:e[o],enumerable:!0})},ni=(i,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ic(e))!Sc.call(i,r)&&r!==o&&dr(i,r,{get:()=>e[r],enumerable:!(t=vc(e,r))||t.enumerable});return i};var Ie=(i,e,o)=>(o=i!=null?wc(_c(i)):{},ni(e||!i||!i.__esModule?dr(o,"default",{value:i,enumerable:!0}):o,i)),hr=i=>ni(dr({},"__esModule",{value:!0}),i);var mr,oe,ie,Oc,br,gr=x(()=>{"use strict";mr=new Map,oe=[],ie=(i,e,o)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let t=mr.get(i);if(t===void 0)mr.set(i,{backend:e,priority:o});else{if(t.priority>o)return;if(t.priority===o&&t.backend!==e)throw new Error(`cannot register backend "${i}" using priority ${o}`)}if(o>=0){let r=oe.indexOf(i);r!==-1&&oe.splice(r,1);for(let n=0;n<oe.length;n++)if(mr.get(oe[n]).priority<=o){oe.splice(n,0,i);return}oe.push(i)}return}throw new TypeError("not a valid backend")},Oc=async i=>{let e=mr.get(i);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let o=!!e.initPromise;try{return o||(e.initPromise=e.backend.init(i)),await e.initPromise,e.initialized=!0,e.backend}catch(t){return o||(e.error=`${t}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},br=async i=>{let e=i.executionProviders||[],o=e.map(u=>typeof u=="string"?u:u.name),t=o.length===0?oe:o,r,n=[],s=new Set;for(let u of t){let l=await Oc(u);typeof l=="string"?n.push({name:u,err:l}):(r||(r=l),r===l&&s.add(u))}if(!r)throw new Error(`no available backend found. ERR: ${n.map(u=>`[${u.name}] ${u.err}`).join(", ")}`);for(let{name:u,err:l}of n)o.includes(u)&&console.warn(`removing requested execution provider "${u}" from session options because it is not available: ${l}`);let a=e.filter(u=>s.has(typeof u=="string"?u:u.name));return[r,new Proxy(i,{get:(u,l)=>l==="executionProviders"?a:Reflect.get(u,l)})]}});var oi=x(()=>{"use strict";gr()});var ii,ai=x(()=>{"use strict";ii="1.19.0"});var si,xt,Dn=x(()=>{"use strict";ai();si="warning",xt={wasm:{},webgl:{},webgpu:{},versions:{common:ii},set logLevel(i){if(i!==void 0){if(typeof i!="string"||["verbose","info","warning","error","fatal"].indexOf(i)===-1)throw new Error(`Unsupported logging level: ${i}`);si=i}},get logLevel(){return si}};Object.defineProperty(xt,"logLevel",{enumerable:!0})});var $,ui=x(()=>{"use strict";Dn();$=xt});var li,fi,ci=x(()=>{"use strict";li=(i,e)=>{let o=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);o.width=i.dims[3],o.height=i.dims[2];let t=o.getContext("2d");if(t!=null){let r,n;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(r=i.dims[2],n=i.dims[3]):(r=i.dims[3],n=i.dims[2]);let s=e?.format!==void 0?e.format:"RGB",a=e?.norm,u,l;a===void 0||a.mean===void 0?u=[255,255,255,255]:typeof a.mean=="number"?u=[a.mean,a.mean,a.mean,a.mean]:(u=[a.mean[0],a.mean[1],a.mean[2],0],a.mean[3]!==void 0&&(u[3]=a.mean[3])),a===void 0||a.bias===void 0?l=[0,0,0,0]:typeof a.bias=="number"?l=[a.bias,a.bias,a.bias,a.bias]:(l=[a.bias[0],a.bias[1],a.bias[2],0],a.bias[3]!==void 0&&(l[3]=a.bias[3]));let f=n*r,c=0,d=f,m=f*2,g=-1;s==="RGBA"?(c=0,d=f,m=f*2,g=f*3):s==="RGB"?(c=0,d=f,m=f*2):s==="RBG"&&(c=0,m=f,d=f*2);for(let y=0;y<n;y++)for(let T=0;T<r;T++){let _=(i.data[c++]-l[0])*u[0],w=(i.data[d++]-l[1])*u[1],v=(i.data[m++]-l[2])*u[2],L=g===-1?255:(i.data[g++]-l[3])*u[3];t.fillStyle="rgba("+_+","+w+","+v+","+L+")",t.fillRect(T,y,1,1)}if("toDataURL"in o)return o.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},fi=(i,e)=>{let o=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),t;if(o!=null){let r,n,s;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(r=i.dims[2],n=i.dims[1],s=i.dims[3]):(r=i.dims[3],n=i.dims[2],s=i.dims[1]);let a=e!==void 0&&e.format!==void 0?e.format:"RGB",u=e?.norm,l,f;u===void 0||u.mean===void 0?l=[255,255,255,255]:typeof u.mean=="number"?l=[u.mean,u.mean,u.mean,u.mean]:(l=[u.mean[0],u.mean[1],u.mean[2],255],u.mean[3]!==void 0&&(l[3]=u.mean[3])),u===void 0||u.bias===void 0?f=[0,0,0,0]:typeof u.bias=="number"?f=[u.bias,u.bias,u.bias,u.bias]:(f=[u.bias[0],u.bias[1],u.bias[2],0],u.bias[3]!==void 0&&(f[3]=u.bias[3]));let c=n*r;if(e!==void 0&&(e.format!==void 0&&s===4&&e.format!=="RGBA"||s===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,m=0,g=1,y=2,T=3,_=0,w=c,v=c*2,L=-1;a==="RGBA"?(_=0,w=c,v=c*2,L=c*3):a==="RGB"?(_=0,w=c,v=c*2):a==="RBG"&&(_=0,v=c,w=c*2),t=o.createImageData(r,n);for(let B=0;B<n*r;m+=d,g+=d,y+=d,T+=d,B++)t.data[m]=(i.data[_++]-f[0])*l[0],t.data[g]=(i.data[w++]-f[1])*l[1],t.data[y]=(i.data[v++]-f[2])*l[2],t.data[T]=L===-1?255:(i.data[L++]-f[3])*l[3]}else throw new Error("Can not access image data");return t}});var Ln,pi,di,hi,mi,bi=x(()=>{"use strict";yr();Ln=(i,e)=>{if(i===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:o,width:t}=e,r=e.norm??{mean:255,bias:0},n,s;typeof r.mean=="number"?n=[r.mean,r.mean,r.mean,r.mean]:n=[r.mean[0],r.mean[1],r.mean[2],r.mean[3]??255],typeof r.bias=="number"?s=[r.bias,r.bias,r.bias,r.bias]:s=[r.bias[0],r.bias[1],r.bias[2],r.bias[3]??0];let a=e.format!==void 0?e.format:"RGBA",u=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",l=o*t,f=u==="RGBA"?new Float32Array(l*4):new Float32Array(l*3),c=4,d=0,m=1,g=2,y=3,T=0,_=l,w=l*2,v=-1;a==="RGB"&&(c=3,d=0,m=1,g=2,y=-1),u==="RGBA"?v=l*3:u==="RBG"?(T=0,w=l,_=l*2):u==="BGR"&&(w=0,_=l,T=l*2);for(let B=0;B<l;B++,d+=c,g+=c,m+=c,y+=c)f[T++]=(i[d]+s[0])/n[0],f[_++]=(i[m]+s[1])/n[1],f[w++]=(i[g]+s[2])/n[2],v!==-1&&y!==-1&&(f[v++]=(i[y]+s[3])/n[3]);return u==="RGBA"?new ft("float32",f,[1,4,o,t]):new ft("float32",f,[1,3,o,t])},pi=async(i,e)=>{let o=typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement,t=typeof ImageData<"u"&&i instanceof ImageData,r=typeof ImageBitmap<"u"&&i instanceof ImageBitmap,n=typeof i=="string",s,a=e??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=f=>f instanceof HTMLCanvasElement||f instanceof OffscreenCanvas?f.getContext("2d"):null;if(o){let f=u();f.width=i.width,f.height=i.height;let c=l(f);if(c!=null){let d=i.height,m=i.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(d=e.resizedHeight,m=e.resizedWidth),e!==void 0){if(a=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=d,a.width=m}else a.tensorFormat="RGBA",a.height=d,a.width=m;c.drawImage(i,0,0),s=c.getImageData(0,0,m,d).data}else throw new Error("Can not access image data")}else if(t){let f,c;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(f=e.resizedHeight,c=e.resizedWidth):(f=i.height,c=i.width),e!==void 0&&(a=e),a.format="RGBA",a.height=f,a.width=c,e!==void 0){let d=u();d.width=c,d.height=f;let m=l(d);if(m!=null)m.putImageData(i,0,0),s=m.getImageData(0,0,c,f).data;else throw new Error("Can not access image data")}else s=i.data}else if(r){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let f=u();f.width=i.width,f.height=i.height;let c=l(f);if(c!=null){let d=i.height,m=i.width;return c.drawImage(i,0,0,m,d),s=c.getImageData(0,0,m,d).data,a.height=d,a.width=m,Ln(s,a)}else throw new Error("Can not access image data")}else{if(n)return new Promise((f,c)=>{let d=u(),m=l(d);if(!i||!m)return c();let g=new Image;g.crossOrigin="Anonymous",g.src=i,g.onload=()=>{d.width=g.width,d.height=g.height,m.drawImage(g,0,0,d.width,d.height);let y=m.getImageData(0,0,d.width,d.height);a.height=d.height,a.width=d.width,f(Ln(y.data,a))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Ln(s,a);throw new Error("Input data provided is not supported - aborted tensor creation")},di=(i,e)=>{let{width:o,height:t,download:r,dispose:n}=e,s=[1,t,o,4];return new ft({location:"texture",type:"float32",texture:i,dims:s,download:r,dispose:n})},hi=(i,e)=>{let{dataType:o,dims:t,download:r,dispose:n}=e;return new ft({location:"gpu-buffer",type:o??"float32",gpuBuffer:i,dims:t,download:r,dispose:n})},mi=(i,e,o)=>new ft({location:"cpu-pinned",type:i,data:e,dims:o??[e.length]})});var ae,We,gi,yi,xi=x(()=>{"use strict";ae=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),We=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),gi=!1,yi=()=>{if(!gi){gi=!0;let i=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,o=typeof Float16Array<"u"&&Float16Array.from;i&&(ae.set("int64",BigInt64Array),We.set(BigInt64Array,"int64")),e&&(ae.set("uint64",BigUint64Array),We.set(BigUint64Array,"uint64")),o?(ae.set("float16",Float16Array),We.set(Float16Array,"float16")):ae.set("float16",Uint16Array)}}});var Ti,wi,vi=x(()=>{"use strict";yr();Ti=i=>{let e=1;for(let o=0;o<i.length;o++){let t=i[o];if(typeof t!="number"||!Number.isSafeInteger(t))throw new TypeError(`dims[${o}] must be an integer, got: ${t}`);if(t<0)throw new RangeError(`dims[${o}] must be a non-negative integer, got: ${t}`);e*=t}return e},wi=(i,e)=>{switch(i.location){case"cpu":return new ft(i.type,i.data,e);case"cpu-pinned":return new ft({location:"cpu-pinned",data:i.data,type:i.type,dims:e});case"texture":return new ft({location:"texture",texture:i.texture,type:i.type,dims:e});case"gpu-buffer":return new ft({location:"gpu-buffer",gpuBuffer:i.gpuBuffer,type:i.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${i.location} is not supported`)}}});var ft,yr=x(()=>{"use strict";ci();bi();xi();vi();ft=class{constructor(e,o,t){yi();let r,n;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,r=e.type,n=e.dims,e.location){case"cpu-pinned":{let a=ae.get(r);if(!a)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=e.data;break}case"texture":{if(r!=="float32")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(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint8"&&r!=="bool")throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,u;if(typeof e=="string")if(r=e,u=t,e==="string"){if(!Array.isArray(o))throw new TypeError("A string tensor's data must be a string array.");a=o}else{let l=ae.get(e);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(o)){if(e==="float16"&&l===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");e==="uint64"||e==="int64"?a=l.from(o,BigInt):a=l.from(o)}else if(o instanceof l)a=o;else throw new TypeError(`A ${r} tensor's data must be type of ${l}`)}else if(u=o,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof e[0];if(l==="string")r="string",a=e;else if(l==="boolean")r="bool",a=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else{let l=We.get(e.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=l,a=e}if(u===void 0)u=[a.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");n=u,this.cpuData=a,this.dataLocation="cpu"}let s=Ti(n);if(this.cpuData&&s!==this.cpuData.length)throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=n,this.size=s}static async fromImage(e,o){return pi(e,o)}static fromTexture(e,o){return di(e,o)}static fromGpuBuffer(e,o){return hi(e,o)}static fromPinnedBuffer(e,o,t){return mi(e,o,t)}toDataURL(e){return li(this,e)}toImageData(e){return fi(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 o=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=o,e&&this.disposer&&(this.disposer(),this.disposer=void 0),o}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return wi(this,e)}}});var rt,xr=x(()=>{"use strict";yr();rt=ft});var $n,Ii,Kt,Jt,kn=x(()=>{"use strict";Dn();$n=(i,e)=>{(typeof xt.trace>"u"?!xt.wasm.trace:!xt.trace)||console.timeStamp(`${i}::ORT::${e}`)},Ii=(i,e)=>{let o=new Error().stack?.split(/\r\n|\r|\n/g)||[],t=!1;for(let r=0;r<o.length;r++){if(t&&!o[r].includes("TRACE_FUNC")){let n=`FUNC_${i}::${o[r].trim().split(" ")[1]}`;e&&(n+=`::${e}`),$n("CPU",n);return}o[r].includes("TRACE_FUNC")&&(t=!0)}},Kt=i=>{(typeof xt.trace>"u"?!xt.wasm.trace:!xt.trace)||Ii("BEGIN",i)},Jt=i=>{(typeof xt.trace>"u"?!xt.wasm.trace:!xt.trace)||Ii("END",i)}});var Tr,_i=x(()=>{"use strict";gr();xr();kn();Tr=class i{constructor(e){this.handler=e}async run(e,o,t){Kt();let r={},n={};if(typeof e!="object"||e===null||e instanceof rt||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof o=="object"){if(o===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(o instanceof rt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(o)){if(o.length===0)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let l of o){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);r[l]=null}if(typeof t=="object"&&t!==null)n=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,f=Object.getOwnPropertyNames(o);for(let c of this.outputNames)if(f.indexOf(c)!==-1){let d=o[c];(d===null||d instanceof rt)&&(l=!0,s=!1,r[c]=d)}if(l){if(typeof t=="object"&&t!==null)n=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else n=o}}else if(typeof o<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let l of this.inputNames)if(typeof e[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(s)for(let l of this.outputNames)r[l]=null;let a=await this.handler.run(e,r,n),u={};for(let l in a)if(Object.hasOwnProperty.call(a,l)){let f=a[l];f instanceof rt?u[l]=f:u[l]=new rt(f.type,f.data,f.dims)}return Jt(),u}async release(){return this.handler.dispose()}static async create(e,o,t,r){Kt();let n,s={};if(typeof e=="string"){if(n=e,typeof o=="object"&&o!==null)s=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(n=e,typeof o=="object"&&o!==null)s=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let f=e,c=0,d=e.byteLength;if(typeof o=="object"&&o!==null)s=o;else if(typeof o=="number"){if(c=o,!Number.isSafeInteger(c))throw new RangeError("'byteOffset' must be an integer.");if(c<0||c>=f.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${f.byteLength}).`);if(d=e.byteLength-c,typeof t=="number"){if(d=t,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||c+d>f.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${f.byteLength-c}].`);if(typeof r=="object"&&r!==null)s=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(typeof t<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof o<"u")throw new TypeError("'options' must be an object.");n=new Uint8Array(f,c,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[a,u]=await br(s),l=await a.createInferenceSessionHandler(n,u);return Jt(),new i(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var Si,Oi=x(()=>{"use strict";_i();Si=Tr});var Ai=x(()=>{"use strict"});var Pi=x(()=>{"use strict"});var Ei=x(()=>{"use strict"});var Di=x(()=>{"use strict"});var Ac,wr,Li=x(()=>{"use strict";gr();xr();Ac="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",wr=class i{constructor(e,o,t){this.handler=e,this.hasOptimizerModel=o,this.hasEvalModel=t}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(e,o){let t=e.evalModel||"",r=e.optimizerModel||"",n=o||{},[s,a]=await br(n);if(s.createTrainingSessionHandler){let u=await s.createTrainingSessionHandler(e.checkpointState,e.trainModel,t,r,a);return new i(u,!!e.optimizerModel,!!e.evalModel)}else throw new Error(Ac)}typeNarrowingForRunStep(e,o,t,r,n){let s={},a={};if(typeof t!="object"||t===null||t instanceof rt||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let u=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof rt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");u=!1;for(let l of r){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(o.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);s[l]=null}if(typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,f=Object.getOwnPropertyNames(r);for(let c of o)if(f.indexOf(c)!==-1){let d=r[c];(d===null||d instanceof rt)&&(l=!0,u=!1,s[c]=d)}if(l){if(typeof n=="object"&&n!==null)a=n;else if(typeof n<"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 l of e)if(typeof t[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(u)for(let l of o)s[l]=null;return[s,a]}convertHandlerReturnTypeToMapOfTensors(e){let o={};for(let t in e)if(Object.hasOwnProperty.call(e,t)){let r=e[t];r instanceof rt?o[t]=r:o[t]=new rt(r.type,r.data,r.dims)}return o}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,o,t){let[r,n]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,o,t),s=await this.handler.runTrainStep(e,r,n);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(e){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(e||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(e,o,t){if(this.hasEvalModel){let[r,n]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,o,t),s=await this.handler.runEvalStep(e,r,n);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(e=!0){return this.handler.getParametersSize(e)}async loadParametersBuffer(e,o=!0){let t=await this.getParametersSize(o);if(e.length!==4*t)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,o)}async getContiguousParameters(e=!0){return this.handler.getContiguousParameters(e)}async release(){return this.handler.dispose()}}});var $i,ki=x(()=>{"use strict";Li();$i=wr});var Bn={};ze(Bn,{InferenceSession:()=>Si,TRACE:()=>$n,TRACE_FUNC_BEGIN:()=>Kt,TRACE_FUNC_END:()=>Jt,Tensor:()=>rt,TrainingSession:()=>$i,env:()=>$,registerBackend:()=>ie});var $t=x(()=>{"use strict";oi();ui();Oi();xr();Ai();Pi();kn();Ei();Di();ki()});function Zt(i,e,o,t){if(e===void 0)return Ec(i);if(o===void 0)vr(i,e,1);else if(typeof o=="number"&&t===void 0)vr(i,e,o);else if(typeof o=="string"&&t===void 0)vr(i,o,1,e);else if(typeof o=="string"&&typeof t=="number")vr(i,o,t,e);else throw new TypeError("input is valid")}function Ec(i){return{verbose:Zt.verbose.bind(null,i),info:Zt.info.bind(null,i),warning:Zt.warning.bind(null,i),error:Zt.error.bind(null,i),fatal:Zt.fatal.bind(null,i)}}function vr(i,e,o,t){let r=He[t||""]||He[""];Fi[i]<Fi[r.minimalSeverity]||(r.logDateTime&&(e=`${new Date().toISOString()}|${e}`),r.logSourceLocation,Pc[r.provider].log(i,e,t))}var Fn,Nn,Fi,Pc,Ni,He,z,_r,Sr,Or,Ir,vt=x(()=>{"use strict";Fn=class{log(e,o,t){}},Nn=class{log(e,o,t){console.log(`${this.color(e)} ${t?"\x1B[35m"+t+"\x1B[0m ":""}${o}`)}color(e){switch(e){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${e}`)}}},Fi={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Pc={none:new Fn,console:new Nn},Ni={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},He={"":Ni};(u=>{function i(l,f){u("verbose",l,f)}u.verbose=i;function e(l,f){u("info",l,f)}u.info=e;function o(l,f){u("warning",l,f)}u.warning=o;function t(l,f){u("error",l,f)}u.error=t;function r(l,f){u("fatal",l,f)}u.fatal=r;function n(l){He={},s("",l||{})}u.reset=n;function s(l,f){if(l==="*")n(f);else{let c=He[l]||Ni;He[l]={provider:f.provider||c.provider,minimalSeverity:f.minimalSeverity||c.minimalSeverity,logDateTime:f.logDateTime===void 0?c.logDateTime:f.logDateTime,logSourceLocation:f.logSourceLocation===void 0?c.logSourceLocation:f.logSourceLocation}}}u.set=s;function a(l){let f={};l.logLevel&&(f.minimalSeverity=l.logLevel),s("",f)}u.setWithEnv=a})(Zt||={});z=Zt,_r=class{constructor(e,o,t,r,n,s){this.category=e;this.name=o;this.startTime=t;this.endCallback=r;this.timer=n;this.ctx=s}async end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},Sr=class{constructor(e,o,t,r){this.category=e;this.name=o;this.startTime=t;this.endTime=r}},Or=class{constructor(e,o,t){this._started=!1;this._flushPointer=0;this._started=!1,this._maxNumberEvents=e===void 0?1e4:e,this._flushBatchSize=o===void 0?10:o,this._flushIntervalInMilliseconds=t===void 0?5e3:t}static create(e){return e===void 0?new this:new this(e.maxNumberEvents,e.flushBatchSize,e.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=Ir(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,o,t,r){let n=this._started?this.begin(e,o,r):void 0,s=!1,a=t();if(a&&typeof a.then=="function")return s=!0,new Promise((u,l)=>{a.then(async f=>{n&&await n.end(),u(f)},async f=>{n&&await n.end(),l(f)})});if(!s&&n){let u=n.end();if(u&&typeof u.then=="function")return new Promise((l,f)=>{u.then(()=>{l(a)},c=>{f(c)})})}return a}begin(e,o,t){if(!this._started)throw new Error("profiler is not started yet");if(t===void 0){let r=Ir();return this.flush(r),new _r(e,o,r,n=>this.endSync(n))}else{let r=t.beginTimer();return new _r(e,o,0,async n=>this.end(n),r,t)}}async end(e){let o=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Sr(e.category,e.name,e.startTime,o)),this.flush(o))}endSync(e){let o=Ir();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Sr(e.category,e.name,e.startTime,o)),this.flush(o))}logOneEvent(e){z.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 o=this._flushPointer;this._flushPointer<o+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=Ir()}}get started(){return this._started}},Ir=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Ci(i,e,o){for(let t of o){let r=t[0],n=t[1],s=t[2],a=t[3],u=t[4];if(i.opType===r){for(let l of e)if((l.domain===n||l.domain==="ai.onnx"&&n==="")&&Dc(l.version,s))return{opImpl:a,opInit:u}}}throw new TypeError(`cannot resolve operator '${i.opType}' with opsets: ${e.map(t=>`${t.domain||"ai.onnx"} v${t.version}`).join(", ")}`)}function Dc(i,e){if(e.endsWith("+")){let o=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(o)&&o<=i}else if(e.split("-").length===2){let o=e.split("-"),t=Number.parseInt(o[0],10),r=Number.parseInt(o[1],10);return!isNaN(t)&&!isNaN(r)&&t<=i&&i<=r}else return Number.parseInt(e,10)===i}var Ri=x(()=>{"use strict"});var Gi=tt(Cn=>{"use strict";Cn.__esModule=!0;var Lc=function(){function i(e){if(!e)throw new TypeError("Invalid argument; `value` has no value.");this.value=i.EMPTY,e&&i.isGuid(e)&&(this.value=e)}return i.isGuid=function(e){var o=e.toString();return e&&(e instanceof i||i.validator.test(o))},i.create=function(){return new i([i.gen(2),i.gen(1),i.gen(1),i.gen(1),i.gen(3)].join("-"))},i.createEmpty=function(){return new i("emptyguid")},i.parse=function(e){return new i(e)},i.raw=function(){return[i.gen(2),i.gen(1),i.gen(1),i.gen(1),i.gen(3)].join("-")},i.gen=function(e){for(var o="",t=0;t<e;t++)o+=((1+Math.random())*65536|0).toString(16).substring(1);return o},i.prototype.equals=function(e){return i.isGuid(e)&&this.value===e.toString()},i.prototype.isEmpty=function(){return this.value===i.EMPTY},i.prototype.toString=function(){return this.value},i.prototype.toJSON=function(){return{value:this.value}},i.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),i.EMPTY="00000000-0000-0000-0000-000000000000",i}();Cn.Guid=Lc});function H(i,e,o){this.low=i|0,this.high=e|0,this.unsigned=!!o}function ut(i){return(i&&i.__isLong__)===!0}function Mi(i){var e=Math.clz32(i&-i);return i?31-e:e}function se(i,e){var o,t,r;return e?(i>>>=0,(r=0<=i&&i<256)&&(t=Ui[i],t)?t:(o=V(i,0,!0),r&&(Ui[i]=o),o)):(i|=0,(r=-128<=i&&i<128)&&(t=Vi[i],t)?t:(o=V(i,i<0?-1:0,!1),r&&(Vi[i]=o),o))}function _t(i,e){if(isNaN(i))return e?qt:kt;if(e){if(i<0)return qt;if(i>=qi)return Ki}else{if(i<=-Wi)return ht;if(i+1>=Wi)return Xi}return i<0?_t(-i,e).neg():V(i%Se|0,i/Se|0,e)}function V(i,e,o){return new H(i,e,o)}function Gn(i,e,o){if(i.length===0)throw Error("empty string");if(typeof e=="number"?(o=e,e=!1):e=!!e,i==="NaN"||i==="Infinity"||i==="+Infinity"||i==="-Infinity")return e?qt:kt;if(o=o||10,o<2||36<o)throw RangeError("radix");var t;if((t=i.indexOf("-"))>0)throw Error("interior hyphen");if(t===0)return Gn(i.substring(1),e,o).neg();for(var r=_t(Ar(o,8)),n=kt,s=0;s<i.length;s+=8){var a=Math.min(8,i.length-s),u=parseInt(i.substring(s,s+a),o);if(a<8){var l=_t(Ar(o,a));n=n.mul(l).add(_t(u))}else n=n.mul(r),n=n.add(_t(u))}return n.unsigned=e,n}function Bt(i,e){return typeof i=="number"?_t(i,e):typeof i=="string"?Gn(i,e):V(i.low,i.high,typeof e=="boolean"?e:i.unsigned)}var It,Vi,Ui,Ar,zi,$c,Se,qi,Wi,Hi,kt,qt,_e,ji,Rn,Xi,Ki,ht,I,jt,Mn=x(()=>{It=null;try{It=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{}H.prototype.__isLong__;Object.defineProperty(H.prototype,"__isLong__",{value:!0});H.isLong=ut;Vi={},Ui={};H.fromInt=se;H.fromNumber=_t;H.fromBits=V;Ar=Math.pow;H.fromString=Gn;H.fromValue=Bt;zi=65536,$c=1<<24,Se=zi*zi,qi=Se*Se,Wi=qi/2,Hi=se($c),kt=se(0);H.ZERO=kt;qt=se(0,!0);H.UZERO=qt;_e=se(1);H.ONE=_e;ji=se(1,!0);H.UONE=ji;Rn=se(-1);H.NEG_ONE=Rn;Xi=V(-1,2147483647,!1);H.MAX_VALUE=Xi;Ki=V(-1,-1,!0);H.MAX_UNSIGNED_VALUE=Ki;ht=V(0,-2147483648,!1);H.MIN_VALUE=ht;I=H.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low};I.toNumber=function(){return this.unsigned?(this.high>>>0)*Se+(this.low>>>0):this.high*Se+(this.low>>>0)};I.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(ht)){var o=_t(e),t=this.div(o),r=t.mul(o).sub(this);return t.toString(e)+r.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var n=_t(Ar(e,6),this.unsigned),s=this,a="";;){var u=s.div(n),l=s.sub(u.mul(n)).toInt()>>>0,f=l.toString(e);if(s=u,s.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};I.getHighBits=function(){return this.high};I.getHighBitsUnsigned=function(){return this.high>>>0};I.getLowBits=function(){return this.low};I.getLowBitsUnsigned=function(){return this.low>>>0};I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(ht)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,o=31;o>0&&!(e&1<<o);o--);return this.high!=0?o+33:o+1};I.isZero=function(){return this.high===0&&this.low===0};I.eqz=I.isZero;I.isNegative=function(){return!this.unsigned&&this.high<0};I.isPositive=function(){return this.unsigned||this.high>=0};I.isOdd=function(){return(this.low&1)===1};I.isEven=function(){return(this.low&1)===0};I.equals=function(e){return ut(e)||(e=Bt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};I.eq=I.equals;I.notEquals=function(e){return!this.eq(e)};I.neq=I.notEquals;I.ne=I.notEquals;I.lessThan=function(e){return this.comp(e)<0};I.lt=I.lessThan;I.lessThanOrEqual=function(e){return this.comp(e)<=0};I.lte=I.lessThanOrEqual;I.le=I.lessThanOrEqual;I.greaterThan=function(e){return this.comp(e)>0};I.gt=I.greaterThan;I.greaterThanOrEqual=function(e){return this.comp(e)>=0};I.gte=I.greaterThanOrEqual;I.ge=I.greaterThanOrEqual;I.compare=function(e){if(ut(e)||(e=Bt(e)),this.eq(e))return 0;var o=this.isNegative(),t=e.isNegative();return o&&!t?-1:!o&&t?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};I.comp=I.compare;I.negate=function(){return!this.unsigned&&this.eq(ht)?ht:this.not().add(_e)};I.neg=I.negate;I.add=function(e){ut(e)||(e=Bt(e));var o=this.high>>>16,t=this.high&65535,r=this.low>>>16,n=this.low&65535,s=e.high>>>16,a=e.high&65535,u=e.low>>>16,l=e.low&65535,f=0,c=0,d=0,m=0;return m+=n+l,d+=m>>>16,m&=65535,d+=r+u,c+=d>>>16,d&=65535,c+=t+a,f+=c>>>16,c&=65535,f+=o+s,f&=65535,V(d<<16|m,f<<16|c,this.unsigned)};I.subtract=function(e){return ut(e)||(e=Bt(e)),this.add(e.neg())};I.sub=I.subtract;I.multiply=function(e){if(this.isZero())return this;if(ut(e)||(e=Bt(e)),It){var o=It.mul(this.low,this.high,e.low,e.high);return V(o,It.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?qt:kt;if(this.eq(ht))return e.isOdd()?ht:kt;if(e.eq(ht))return this.isOdd()?ht:kt;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(Hi)&&e.lt(Hi))return _t(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=this.high&65535,n=this.low>>>16,s=this.low&65535,a=e.high>>>16,u=e.high&65535,l=e.low>>>16,f=e.low&65535,c=0,d=0,m=0,g=0;return g+=s*f,m+=g>>>16,g&=65535,m+=n*f,d+=m>>>16,m&=65535,m+=s*l,d+=m>>>16,m&=65535,d+=r*f,c+=d>>>16,d&=65535,d+=n*l,c+=d>>>16,d&=65535,d+=s*u,c+=d>>>16,d&=65535,c+=t*f+r*l+n*u+s*a,c&=65535,V(m<<16|g,c<<16|d,this.unsigned)};I.mul=I.multiply;I.divide=function(e){if(ut(e)||(e=Bt(e)),e.isZero())throw Error("division by zero");if(It){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var o=(this.unsigned?It.div_u:It.div_s)(this.low,this.high,e.low,e.high);return V(o,It.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?qt:kt;var t,r,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return qt;if(e.gt(this.shru(1)))return ji;n=qt}else{if(this.eq(ht)){if(e.eq(_e)||e.eq(Rn))return ht;if(e.eq(ht))return _e;var s=this.shr(1);return t=s.div(e).shl(1),t.eq(kt)?e.isNegative()?_e:Rn:(r=this.sub(e.mul(t)),n=t.add(r.div(e)),n)}else if(e.eq(ht))return this.unsigned?qt:kt;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();n=kt}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(t)/Math.LN2),u=a<=48?1:Ar(2,a-48),l=_t(t),f=l.mul(e);f.isNegative()||f.gt(r);)t-=u,l=_t(t,this.unsigned),f=l.mul(e);l.isZero()&&(l=_e),n=n.add(l),r=r.sub(f)}return n};I.div=I.divide;I.modulo=function(e){if(ut(e)||(e=Bt(e)),It){var o=(this.unsigned?It.rem_u:It.rem_s)(this.low,this.high,e.low,e.high);return V(o,It.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};I.mod=I.modulo;I.rem=I.modulo;I.not=function(){return V(~this.low,~this.high,this.unsigned)};I.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};I.clz=I.countLeadingZeros;I.countTrailingZeros=function(){return this.low?Mi(this.low):Mi(this.high)+32};I.ctz=I.countTrailingZeros;I.and=function(e){return ut(e)||(e=Bt(e)),V(this.low&e.low,this.high&e.high,this.unsigned)};I.or=function(e){return ut(e)||(e=Bt(e)),V(this.low|e.low,this.high|e.high,this.unsigned)};I.xor=function(e){return ut(e)||(e=Bt(e)),V(this.low^e.low,this.high^e.high,this.unsigned)};I.shiftLeft=function(e){return ut(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?V(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):V(0,this.low<<e-32,this.unsigned)};I.shl=I.shiftLeft;I.shiftRight=function(e){return ut(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?V(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):V(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};I.shr=I.shiftRight;I.shiftRightUnsigned=function(e){return ut(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?V(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?V(this.high,0,this.unsigned):V(this.high>>>e-32,0,this.unsigned)};I.shru=I.shiftRightUnsigned;I.shr_u=I.shiftRightUnsigned;I.rotateLeft=function(e){var o;return ut(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?V(this.high,this.low,this.unsigned):e<32?(o=32-e,V(this.low<<e|this.high>>>o,this.high<<e|this.low>>>o,this.unsigned)):(e-=32,o=32-e,V(this.high<<e|this.low>>>o,this.low<<e|this.high>>>o,this.unsigned))};I.rotl=I.rotateLeft;I.rotateRight=function(e){var o;return ut(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?V(this.high,this.low,this.unsigned):e<32?(o=32-e,V(this.high<<o|this.low>>>e,this.low<<o|this.high>>>e,this.unsigned)):(e-=32,o=32-e,V(this.low<<o|this.high>>>e,this.high<<o|this.low>>>e,this.unsigned))};I.rotr=I.rotateRight;I.toSigned=function(){return this.unsigned?V(this.low,this.high,!1):this};I.toUnsigned=function(){return this.unsigned?this:V(this.low,this.high,!0)};I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};I.toBytesLE=function(){var e=this.high,o=this.low;return[o&255,o>>>8&255,o>>>16&255,o>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};I.toBytesBE=function(){var e=this.high,o=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,o>>>24,o>>>16&255,o>>>8&255,o&255]};H.fromBytes=function(e,o,t){return t?H.fromBytesLE(e,o):H.fromBytesBE(e,o)};H.fromBytesLE=function(e,o){return new H(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,o)};H.fromBytesBE=function(e,o){return new H(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],o)};jt=H});var b,Pr=x(()=>{b={};b.Offset;b.Table;b.SIZEOF_SHORT=2;b.SIZEOF_INT=4;b.FILE_IDENTIFIER_LENGTH=4;b.SIZE_PREFIX_LENGTH=4;b.Encoding={UTF8_BYTES:1,UTF16_STRING:2};b.int32=new Int32Array(2);b.float32=new Float32Array(b.int32.buffer);b.float64=new Float64Array(b.int32.buffer);b.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;b.Long=function(i,e){this.low=i|0,this.high=e|0};b.Long.create=function(i,e){return i==0&&e==0?b.Long.ZERO:new b.Long(i,e)};b.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296};b.Long.prototype.equals=function(i){return this.low==i.low&&this.high==i.high};b.Long.ZERO=new b.Long(0,0);b.Builder=function(i){if(i)var e=i;else var e=1024;this.bb=b.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1};b.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1};b.Builder.prototype.forceDefaults=function(i){this.force_defaults=i};b.Builder.prototype.dataBuffer=function(){return this.bb};b.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())};b.Builder.prototype.prep=function(i,e){i>this.minalign&&(this.minalign=i);for(var o=~(this.bb.capacity()-this.space+e)+1&i-1;this.space<o+i+e;){var t=this.bb.capacity();this.bb=b.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(o)};b.Builder.prototype.pad=function(i){for(var e=0;e<i;e++)this.bb.writeInt8(--this.space,0)};b.Builder.prototype.writeInt8=function(i){this.bb.writeInt8(this.space-=1,i)};b.Builder.prototype.writeInt16=function(i){this.bb.writeInt16(this.space-=2,i)};b.Builder.prototype.writeInt32=function(i){this.bb.writeInt32(this.space-=4,i)};b.Builder.prototype.writeInt64=function(i){this.bb.writeInt64(this.space-=8,i)};b.Builder.prototype.writeFloat32=function(i){this.bb.writeFloat32(this.space-=4,i)};b.Builder.prototype.writeFloat64=function(i){this.bb.writeFloat64(this.space-=8,i)};b.Builder.prototype.addInt8=function(i){this.prep(1,0),this.writeInt8(i)};b.Builder.prototype.addInt16=function(i){this.prep(2,0),this.writeInt16(i)};b.Builder.prototype.addInt32=function(i){this.prep(4,0),this.writeInt32(i)};b.Builder.prototype.addInt64=function(i){this.prep(8,0),this.writeInt64(i)};b.Builder.prototype.addFloat32=function(i){this.prep(4,0),this.writeFloat32(i)};b.Builder.prototype.addFloat64=function(i){this.prep(8,0),this.writeFloat64(i)};b.Builder.prototype.addFieldInt8=function(i,e,o){(this.force_defaults||e!=o)&&(this.addInt8(e),this.slot(i))};b.Builder.prototype.addFieldInt16=function(i,e,o){(this.force_defaults||e!=o)&&(this.addInt16(e),this.slot(i))};b.Builder.prototype.addFieldInt32=function(i,e,o){(this.force_defaults||e!=o)&&(this.addInt32(e),this.slot(i))};b.Builder.prototype.addFieldInt64=function(i,e,o){(this.force_defaults||!e.equals(o))&&(this.addInt64(e),this.slot(i))};b.Builder.prototype.addFieldFloat32=function(i,e,o){(this.force_defaults||e!=o)&&(this.addFloat32(e),this.slot(i))};b.Builder.prototype.addFieldFloat64=function(i,e,o){(this.force_defaults||e!=o)&&(this.addFloat64(e),this.slot(i))};b.Builder.prototype.addFieldOffset=function(i,e,o){(this.force_defaults||e!=o)&&(this.addOffset(e),this.slot(i))};b.Builder.prototype.addFieldStruct=function(i,e,o){e!=o&&(this.nested(e),this.slot(i))};b.Builder.prototype.nested=function(i){if(i!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")};b.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")};b.Builder.prototype.slot=function(i){this.vtable[i]=this.offset()};b.Builder.prototype.offset=function(){return this.bb.capacity()-this.space};b.Builder.growByteBuffer=function(i){var e=i.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var o=e<<1,t=b.ByteBuffer.allocate(o);return t.setPosition(o-e),t.bytes().set(i.bytes(),o-e),t};b.Builder.prototype.addOffset=function(i){this.prep(b.SIZEOF_INT,0),this.writeInt32(this.offset()-i+b.SIZEOF_INT)};b.Builder.prototype.startObject=function(i){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=i;for(var e=0;e<i;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()};b.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var i=this.offset(),e=this.vtable_in_use-1;e>=0&&this.vtable[e]==0;e--);for(var o=e+1;e>=0;e--)this.addInt16(this.vtable[e]!=0?i-this.vtable[e]:0);var t=2;this.addInt16(i-this.object_start);var r=(o+t)*b.SIZEOF_SHORT;this.addInt16(r);var n=0,s=this.space;t:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(a)){for(var u=b.SIZEOF_SHORT;u<r;u+=b.SIZEOF_SHORT)if(this.bb.readInt16(s+u)!=this.bb.readInt16(a+u))continue t;n=this.vtables[e];break}}return n?(this.space=this.bb.capacity()-i,this.bb.writeInt32(this.space,n-i)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-i,this.offset()-i)),this.isNested=!1,i};b.Builder.prototype.finish=function(i,e,o){var t=o?b.SIZE_PREFIX_LENGTH:0;if(e){var r=e;if(this.prep(this.minalign,b.SIZEOF_INT+b.FILE_IDENTIFIER_LENGTH+t),r.length!=b.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+b.FILE_IDENTIFIER_LENGTH);for(var n=b.FILE_IDENTIFIER_LENGTH-1;n>=0;n--)this.writeInt8(r.charCodeAt(n))}this.prep(this.minalign,b.SIZEOF_INT+t),this.addOffset(i),t&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)};b.Builder.prototype.finishSizePrefixed=function(i,e){this.finish(i,e,!0)};b.Builder.prototype.requiredField=function(i,e){var o=this.bb.capacity()-i,t=o-this.bb.readInt32(o),r=this.bb.readInt16(t+e)!=0;if(!r)throw new Error("FlatBuffers: field "+e+" must be set")};b.Builder.prototype.startVector=function(i,e,o){this.notNested(),this.vector_num_elems=e,this.prep(b.SIZEOF_INT,i*e),this.prep(o,i*e)};b.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()};b.Builder.prototype.createString=function(i){if(i instanceof Uint8Array)var e=i;else for(var e=[],o=0;o<i.length;){var t,r=i.charCodeAt(o++);if(r<55296||r>=56320)t=r;else{var n=i.charCodeAt(o++);t=(r<<10)+n+(65536-56623104-56320)}t<128?e.push(t):(t<2048?e.push(t>>6&31|192):(t<65536?e.push(t>>12&15|224):e.push(t>>18&7|240,t>>12&63|128),e.push(t>>6&63|128)),e.push(t&63|128))}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(var o=0,s=this.space,a=this.bb.bytes();o<e.length;o++)a[s++]=e[o];return this.endVector()};b.Builder.prototype.createLong=function(i,e){return b.Long.create(i,e)};b.ByteBuffer=function(i){this.bytes_=i,this.position_=0};b.ByteBuffer.allocate=function(i){return new b.ByteBuffer(new Uint8Array(i))};b.ByteBuffer.prototype.clear=function(){this.position_=0};b.ByteBuffer.prototype.bytes=function(){return this.bytes_};b.ByteBuffer.prototype.position=function(){return this.position_};b.ByteBuffer.prototype.setPosition=function(i){this.position_=i};b.ByteBuffer.prototype.capacity=function(){return this.bytes_.length};b.ByteBuffer.prototype.readInt8=function(i){return this.readUint8(i)<<24>>24};b.ByteBuffer.prototype.readUint8=function(i){return this.bytes_[i]};b.ByteBuffer.prototype.readInt16=function(i){return this.readUint16(i)<<16>>16};b.ByteBuffer.prototype.readUint16=function(i){return this.bytes_[i]|this.bytes_[i+1]<<8};b.ByteBuffer.prototype.readInt32=function(i){return this.bytes_[i]|this.bytes_[i+1]<<8|this.bytes_[i+2]<<16|this.bytes_[i+3]<<24};b.ByteBuffer.prototype.readUint32=function(i){return this.readInt32(i)>>>0};b.ByteBuffer.prototype.readInt64=function(i){return new b.Long(this.readInt32(i),this.readInt32(i+4))};b.ByteBuffer.prototype.readUint64=function(i){return new b.Long(this.readUint32(i),this.readUint32(i+4))};b.ByteBuffer.prototype.readFloat32=function(i){return b.int32[0]=this.readInt32(i),b.float32[0]};b.ByteBuffer.prototype.readFloat64=function(i){return b.int32[b.isLittleEndian?0:1]=this.readInt32(i),b.int32[b.isLittleEndian?1:0]=this.readInt32(i+4),b.float64[0]};b.ByteBuffer.prototype.writeInt8=function(i,e){this.bytes_[i]=e};b.ByteBuffer.prototype.writeUint8=function(i,e){this.bytes_[i]=e};b.ByteBuffer.prototype.writeInt16=function(i,e){this.bytes_[i]=e,this.bytes_[i+1]=e>>8};b.ByteBuffer.prototype.writeUint16=function(i,e){this.bytes_[i]=e,this.bytes_[i+1]=e>>8};b.ByteBuffer.prototype.writeInt32=function(i,e){this.bytes_[i]=e,this.bytes_[i+1]=e>>8,this.bytes_[i+2]=e>>16,this.bytes_[i+3]=e>>24};b.ByteBuffer.prototype.writeUint32=function(i,e){this.bytes_[i]=e,this.bytes_[i+1]=e>>8,this.bytes_[i+2]=e>>16,this.bytes_[i+3]=e>>24};b.ByteBuffer.prototype.writeInt64=function(i,e){this.writeInt32(i,e.low),this.writeInt32(i+4,e.high)};b.ByteBuffer.prototype.writeUint64=function(i,e){this.writeUint32(i,e.low),this.writeUint32(i+4,e.high)};b.ByteBuffer.prototype.writeFloat32=function(i,e){b.float32[0]=e,this.writeInt32(i,b.int32[0])};b.ByteBuffer.prototype.writeFloat64=function(i,e){b.float64[0]=e,this.writeInt32(i,b.int32[b.isLittleEndian?0:1]),this.writeInt32(i+4,b.int32[b.isLittleEndian?1:0])};b.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+b.SIZEOF_INT+b.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var i="",e=0;e<b.FILE_IDENTIFIER_LENGTH;e++)i+=String.fromCharCode(this.readInt8(this.position_+b.SIZEOF_INT+e));return i};b.ByteBuffer.prototype.__offset=function(i,e){var o=i-this.readInt32(i);return e<this.readInt16(o)?this.readInt16(o+e):0};b.ByteBuffer.prototype.__union=function(i,e){return i.bb_pos=e+this.readInt32(e),i.bb=this,i};b.ByteBuffer.prototype.__string=function(i,e){i+=this.readInt32(i);var o=this.readInt32(i),t="",r=0;if(i+=b.SIZEOF_INT,e===b.Encoding.UTF8_BYTES)return this.bytes_.subarray(i,i+o);for(;r<o;){var n,s=this.readUint8(i+r++);if(s<192)n=s;else{var a=this.readUint8(i+r++);if(s<224)n=(s&31)<<6|a&63;else{var u=this.readUint8(i+r++);if(s<240)n=(s&15)<<12|(a&63)<<6|u&63;else{var l=this.readUint8(i+r++);n=(s&7)<<18|(a&63)<<12|(u&63)<<6|l&63}}}n<65536?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1024-1)+56320))}return t};b.ByteBuffer.prototype.__indirect=function(i){return i+this.readInt32(i)};b.ByteBuffer.prototype.__vector=function(i){return i+this.readInt32(i)+b.SIZEOF_INT};b.ByteBuffer.prototype.__vector_len=function(i){return this.readInt32(i+this.readInt32(i))};b.ByteBuffer.prototype.__has_identifier=function(i){if(i.length!=b.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+b.FILE_IDENTIFIER_LENGTH);for(var e=0;e<b.FILE_IDENTIFIER_LENGTH;e++)if(i.charCodeAt(e)!=this.readInt8(this.position_+b.SIZEOF_INT+e))return!1;return!0};b.ByteBuffer.prototype.createLong=function(i,e){return b.Long.create(i,e)}});var P,qe=x(()=>{"use strict";Pr();(e=>{let i;(t=>{let o;(n=>{let r;(v=>(v[v.UNDEFINED=0]="UNDEFINED",v[v.FLOAT=1]="FLOAT",v[v.INT=2]="INT",v[v.STRING=3]="STRING",v[v.TENSOR=4]="TENSOR",v[v.GRAPH=5]="GRAPH",v[v.FLOATS=6]="FLOATS",v[v.INTS=7]="INTS",v[v.STRINGS=8]="STRINGS",v[v.TENSORS=9]="TENSORS",v[v.GRAPHS=10]="GRAPHS",v[v.SPARSE_TENSOR=11]="SPARSE_TENSOR",v[v.SPARSE_TENSORS=12]="SPARSE_TENSORS"))(r=n.AttributeType||={})})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{let r;(l=>(l[l.UNKNOWN=0]="UNKNOWN",l[l.VALUE=1]="VALUE",l[l.PARAM=2]="PARAM"))(r=n.DimensionValueType||={})})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{let r;(k=>(k[k.UNDEFINED=0]="UNDEFINED",k[k.FLOAT=1]="FLOAT",k[k.UINT8=2]="UINT8",k[k.INT8=3]="INT8",k[k.UINT16=4]="UINT16",k[k.INT16=5]="INT16",k[k.INT32=6]="INT32",k[k.INT64=7]="INT64",k[k.STRING=8]="STRING",k[k.BOOL=9]="BOOL",k[k.FLOAT16=10]="FLOAT16",k[k.DOUBLE=11]="DOUBLE",k[k.UINT32=12]="UINT32",k[k.UINT64=13]="UINT64",k[k.COMPLEX64=14]="COMPLEX64",k[k.COMPLEX128=15]="COMPLEX128",k[k.BFLOAT16=16]="BFLOAT16",k[k.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",k[k.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",k[k.FLOAT8E5M2=19]="FLOAT8E5M2",k[k.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"))(r=n.TensorDataType||={})})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{let r;(u=>(u[u.Primitive=0]="Primitive",u[u.Fused=1]="Fused"))(r=n.NodeType||={})})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{let r;(f=>(f[f.NONE=0]="NONE",f[f.tensor_type=1]="tensor_type",f[f.sequence_type=2]="sequence_type",f[f.map_type=3]="map_type"))(r=n.TypeInfoValue||={})})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsShape(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsShape(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}dim(a,u){let l=this.bb.__offset(this.bb_pos,4);return l?(u||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}dimLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}static startShape(a){a.startObject(1)}static addDim(a,u){a.addFieldOffset(0,u,0)}static createDimVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startDimVector(a,u){a.startVector(4,u,4)}static endShape(a){return a.endObject()}static createShape(a,u){return r.startShape(a),r.addDim(a,u),r.endShape(a)}}n.Shape=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsDimension(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsDimension(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}value(a){let u=this.bb.__offset(this.bb_pos,4);return u?(a||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}denotation(a){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__string(this.bb_pos+u,a):null}static startDimension(a){a.startObject(2)}static addValue(a,u){a.addFieldOffset(0,u,0)}static addDenotation(a,u){a.addFieldOffset(1,u,0)}static endDimension(a){return a.endObject()}static createDimension(a,u,l){return r.startDimension(a),r.addValue(a,u),r.addDenotation(a,l),r.endDimension(a)}}n.Dimension=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsDimensionValue(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsDimensionValue(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}dimType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt8(this.bb_pos+a):0}dimValue(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}dimParam(a){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__string(this.bb_pos+u,a):null}static startDimensionValue(a){a.startObject(3)}static addDimType(a,u){a.addFieldInt8(0,u,0)}static addDimValue(a,u){a.addFieldInt64(1,u,a.createLong(0,0))}static addDimParam(a,u){a.addFieldOffset(2,u,0)}static endDimensionValue(a){return a.endObject()}static createDimensionValue(a,u,l,f){return r.startDimensionValue(a),r.addDimType(a,u),r.addDimValue(a,l),r.addDimParam(a,f),r.endDimensionValue(a)}}n.DimensionValue=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsTensorTypeAndShape(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTensorTypeAndShape(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}elemType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt32(this.bb_pos+a):0}shape(a){let u=this.bb.__offset(this.bb_pos,6);return u?(a||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}static startTensorTypeAndShape(a){a.startObject(2)}static addElemType(a,u){a.addFieldInt32(0,u,0)}static addShape(a,u){a.addFieldOffset(1,u,0)}static endTensorTypeAndShape(a){return a.endObject()}static createTensorTypeAndShape(a,u,l){return r.startTensorTypeAndShape(a),r.addElemType(a,u),r.addShape(a,l),r.endTensorTypeAndShape(a)}}n.TensorTypeAndShape=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsMapType(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsMapType(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}keyType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt32(this.bb_pos+a):0}valueType(a){let u=this.bb.__offset(this.bb_pos,6);return u?(a||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}static startMapType(a){a.startObject(2)}static addKeyType(a,u){a.addFieldInt32(0,u,0)}static addValueType(a,u){a.addFieldOffset(1,u,0)}static endMapType(a){return a.endObject()}static createMapType(a,u,l){return r.startMapType(a),r.addKeyType(a,u),r.addValueType(a,l),r.endMapType(a)}}n.MapType=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsSequenceType(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSequenceType(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}elemType(a){let u=this.bb.__offset(this.bb_pos,4);return u?(a||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}static startSequenceType(a){a.startObject(1)}static addElemType(a,u){a.addFieldOffset(0,u,0)}static endSequenceType(a){return a.endObject()}static createSequenceType(a,u){return r.startSequenceType(a),r.addElemType(a,u),r.endSequenceType(a)}}n.SequenceType=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,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(a,u,l,f){return a.prep(4,12),a.writeInt32(f),a.writeInt32(l),a.writeInt32(u),a.offset()}}n.EdgeEnd=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsNodeEdge(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsNodeEdge(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}nodeIndex(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readUint32(this.bb_pos+a):0}inputEdges(a,u){let l=this.bb.__offset(this.bb_pos,6);return l?(u||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+l)+a*12,this.bb):null}inputEdgesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}outputEdges(a,u){let l=this.bb.__offset(this.bb_pos,8);return l?(u||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+l)+a*12,this.bb):null}outputEdgesLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}static startNodeEdge(a){a.startObject(3)}static addNodeIndex(a,u){a.addFieldInt32(0,u,0)}static addInputEdges(a,u){a.addFieldOffset(1,u,0)}static startInputEdgesVector(a,u){a.startVector(12,u,4)}static addOutputEdges(a,u){a.addFieldOffset(2,u,0)}static startOutputEdgesVector(a,u){a.startVector(12,u,4)}static endNodeEdge(a){return a.endObject()}static createNodeEdge(a,u,l,f){return r.startNodeEdge(a),r.addNodeIndex(a,u),r.addInputEdges(a,l),r.addOutputEdges(a,f),r.endNodeEdge(a)}}n.NodeEdge=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsNode(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsNode(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}name(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}docString(a){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__string(this.bb_pos+u,a):null}domain(a){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__string(this.bb_pos+u,a):null}sinceVersion(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readInt32(this.bb_pos+a):0}index(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readUint32(this.bb_pos+a):0}opType(a){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.__string(this.bb_pos+u,a):null}type(){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.readInt32(this.bb_pos+a):0}executionProviderType(a){let u=this.bb.__offset(this.bb_pos,18);return u?this.bb.__string(this.bb_pos+u,a):null}inputs(a,u){let l=this.bb.__offset(this.bb_pos,20);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}inputsLength(){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__vector_len(this.bb_pos+a):0}outputs(a,u){let l=this.bb.__offset(this.bb_pos,22);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}outputsLength(){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.__vector_len(this.bb_pos+a):0}attributes(a,u){let l=this.bb.__offset(this.bb_pos,24);return l?(u||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}attributesLength(){let a=this.bb.__offset(this.bb_pos,24);return a?this.bb.__vector_len(this.bb_pos+a):0}inputArgCounts(a){let u=this.bb.__offset(this.bb_pos,26);return u?this.bb.readInt32(this.bb.__vector(this.bb_pos+u)+a*4):0}inputArgCountsLength(){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.__vector_len(this.bb_pos+a):0}inputArgCountsArray(){let a=this.bb.__offset(this.bb_pos,26);return a?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}implicitInputs(a,u){let l=this.bb.__offset(this.bb_pos,28);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}implicitInputsLength(){let a=this.bb.__offset(this.bb_pos,28);return a?this.bb.__vector_len(this.bb_pos+a):0}static startNode(a){a.startObject(13)}static addName(a,u){a.addFieldOffset(0,u,0)}static addDocString(a,u){a.addFieldOffset(1,u,0)}static addDomain(a,u){a.addFieldOffset(2,u,0)}static addSinceVersion(a,u){a.addFieldInt32(3,u,0)}static addIndex(a,u){a.addFieldInt32(4,u,0)}static addOpType(a,u){a.addFieldOffset(5,u,0)}static addType(a,u){a.addFieldInt32(6,u,0)}static addExecutionProviderType(a,u){a.addFieldOffset(7,u,0)}static addInputs(a,u){a.addFieldOffset(8,u,0)}static createInputsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startInputsVector(a,u){a.startVector(4,u,4)}static addOutputs(a,u){a.addFieldOffset(9,u,0)}static createOutputsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startOutputsVector(a,u){a.startVector(4,u,4)}static addAttributes(a,u){a.addFieldOffset(10,u,0)}static createAttributesVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startAttributesVector(a,u){a.startVector(4,u,4)}static addInputArgCounts(a,u){a.addFieldOffset(11,u,0)}static createInputArgCountsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addInt32(u[l]);return a.endVector()}static startInputArgCountsVector(a,u){a.startVector(4,u,4)}static addImplicitInputs(a,u){a.addFieldOffset(12,u,0)}static createImplicitInputsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startImplicitInputsVector(a,u){a.startVector(4,u,4)}static endNode(a){return a.endObject()}static createNode(a,u,l,f,c,d,m,g,y,T,_,w,v,L){return r.startNode(a),r.addName(a,u),r.addDocString(a,l),r.addDomain(a,f),r.addSinceVersion(a,c),r.addIndex(a,d),r.addOpType(a,m),r.addType(a,g),r.addExecutionProviderType(a,y),r.addInputs(a,T),r.addOutputs(a,_),r.addAttributes(a,w),r.addInputArgCounts(a,v),r.addImplicitInputs(a,L),r.endNode(a)}}n.Node=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsValueInfo(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsValueInfo(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}name(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}docString(a){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__string(this.bb_pos+u,a):null}type(a){let u=this.bb.__offset(this.bb_pos,8);return u?(a||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}static startValueInfo(a){a.startObject(3)}static addName(a,u){a.addFieldOffset(0,u,0)}static addDocString(a,u){a.addFieldOffset(1,u,0)}static addType(a,u){a.addFieldOffset(2,u,0)}static endValueInfo(a){return a.endObject()}static createValueInfo(a,u,l,f){return r.startValueInfo(a),r.addName(a,u),r.addDocString(a,l),r.addType(a,f),r.endValueInfo(a)}}n.ValueInfo=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsTypeInfo(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTypeInfo(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}denotation(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}valueType(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readUint8(this.bb_pos+a):0}value(a){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__union(a,this.bb_pos+u):null}static startTypeInfo(a){a.startObject(3)}static addDenotation(a,u){a.addFieldOffset(0,u,0)}static addValueType(a,u){a.addFieldInt8(1,u,0)}static addValue(a,u){a.addFieldOffset(2,u,0)}static endTypeInfo(a){return a.endObject()}static createTypeInfo(a,u,l,f){return r.startTypeInfo(a),r.addDenotation(a,u),r.addValueType(a,l),r.addValue(a,f),r.endTypeInfo(a)}}n.TypeInfo=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsOperatorSetId(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsOperatorSetId(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}domain(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}version(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}static startOperatorSetId(a){a.startObject(2)}static addDomain(a,u){a.addFieldOffset(0,u,0)}static addVersion(a,u){a.addFieldInt64(1,u,a.createLong(0,0))}static endOperatorSetId(a){return a.endObject()}static createOperatorSetId(a,u,l){return r.startOperatorSetId(a),r.addDomain(a,u),r.addVersion(a,l),r.endOperatorSetId(a)}}n.OperatorSetId=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsTensor(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTensor(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}name(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}docString(a){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__string(this.bb_pos+u,a):null}dims(a){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.readInt64(this.bb.__vector(this.bb_pos+u)+a*8):this.bb.createLong(0,0)}dimsLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}dataType(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readInt32(this.bb_pos+a):0}rawData(a){let u=this.bb.__offset(this.bb_pos,12);return u?this.bb.readUint8(this.bb.__vector(this.bb_pos+u)+a):0}rawDataLength(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__vector_len(this.bb_pos+a):0}rawDataArray(){let a=this.bb.__offset(this.bb_pos,12);return a?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}stringData(a,u){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}stringDataLength(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__vector_len(this.bb_pos+a):0}static startTensor(a){a.startObject(6)}static addName(a,u){a.addFieldOffset(0,u,0)}static addDocString(a,u){a.addFieldOffset(1,u,0)}static addDims(a,u){a.addFieldOffset(2,u,0)}static createDimsVector(a,u){a.startVector(8,u.length,8);for(let l=u.length-1;l>=0;l--)a.addInt64(u[l]);return a.endVector()}static startDimsVector(a,u){a.startVector(8,u,8)}static addDataType(a,u){a.addFieldInt32(3,u,0)}static addRawData(a,u){a.addFieldOffset(4,u,0)}static createRawDataVector(a,u){a.startVector(1,u.length,1);for(let l=u.length-1;l>=0;l--)a.addInt8(u[l]);return a.endVector()}static startRawDataVector(a,u){a.startVector(1,u,1)}static addStringData(a,u){a.addFieldOffset(5,u,0)}static createStringDataVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startStringDataVector(a,u){a.startVector(4,u,4)}static endTensor(a){return a.endObject()}static createTensor(a,u,l,f,c,d,m){return r.startTensor(a),r.addName(a,u),r.addDocString(a,l),r.addDims(a,f),r.addDataType(a,c),r.addRawData(a,d),r.addStringData(a,m),r.endTensor(a)}}n.Tensor=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsSparseTensor(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSparseTensor(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}values(a){let u=this.bb.__offset(this.bb_pos,4);return u?(a||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}indices(a){let u=this.bb.__offset(this.bb_pos,6);return u?(a||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}dims(a){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.readInt64(this.bb.__vector(this.bb_pos+u)+a*8):this.bb.createLong(0,0)}dimsLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}static startSparseTensor(a){a.startObject(3)}static addValues(a,u){a.addFieldOffset(0,u,0)}static addIndices(a,u){a.addFieldOffset(1,u,0)}static addDims(a,u){a.addFieldOffset(2,u,0)}static createDimsVector(a,u){a.startVector(8,u.length,8);for(let l=u.length-1;l>=0;l--)a.addInt64(u[l]);return a.endVector()}static startDimsVector(a,u){a.startVector(8,u,8)}static endSparseTensor(a){return a.endObject()}static createSparseTensor(a,u,l,f){return r.startSparseTensor(a),r.addValues(a,u),r.addIndices(a,l),r.addDims(a,f),r.endSparseTensor(a)}}n.SparseTensor=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsAttribute(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsAttribute(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}name(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}docString(a){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__string(this.bb_pos+u,a):null}type(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt32(this.bb_pos+a):0}f(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readFloat32(this.bb_pos+a):0}i(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}s(a){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.__string(this.bb_pos+u,a):null}t(a){let u=this.bb.__offset(this.bb_pos,16);return u?(a||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}g(a){let u=this.bb.__offset(this.bb_pos,18);return u?(a||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}floats(a){let u=this.bb.__offset(this.bb_pos,20);return u?this.bb.readFloat32(this.bb.__vector(this.bb_pos+u)+a*4):0}floatsLength(){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__vector_len(this.bb_pos+a):0}floatsArray(){let a=this.bb.__offset(this.bb_pos,20);return a?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}ints(a){let u=this.bb.__offset(this.bb_pos,22);return u?this.bb.readInt64(this.bb.__vector(this.bb_pos+u)+a*8):this.bb.createLong(0,0)}intsLength(){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.__vector_len(this.bb_pos+a):0}strings(a,u){let l=this.bb.__offset(this.bb_pos,24);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}stringsLength(){let a=this.bb.__offset(this.bb_pos,24);return a?this.bb.__vector_len(this.bb_pos+a):0}tensors(a,u){let l=this.bb.__offset(this.bb_pos,26);return l?(u||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}tensorsLength(){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.__vector_len(this.bb_pos+a):0}graphs(a,u){let l=this.bb.__offset(this.bb_pos,28);return l?(u||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}graphsLength(){let a=this.bb.__offset(this.bb_pos,28);return a?this.bb.__vector_len(this.bb_pos+a):0}static startAttribute(a){a.startObject(13)}static addName(a,u){a.addFieldOffset(0,u,0)}static addDocString(a,u){a.addFieldOffset(1,u,0)}static addType(a,u){a.addFieldInt32(2,u,0)}static addF(a,u){a.addFieldFloat32(3,u,0)}static addI(a,u){a.addFieldInt64(4,u,a.createLong(0,0))}static addS(a,u){a.addFieldOffset(5,u,0)}static addT(a,u){a.addFieldOffset(6,u,0)}static addG(a,u){a.addFieldOffset(7,u,0)}static addFloats(a,u){a.addFieldOffset(8,u,0)}static createFloatsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addFloat32(u[l]);return a.endVector()}static startFloatsVector(a,u){a.startVector(4,u,4)}static addInts(a,u){a.addFieldOffset(9,u,0)}static createIntsVector(a,u){a.startVector(8,u.length,8);for(let l=u.length-1;l>=0;l--)a.addInt64(u[l]);return a.endVector()}static startIntsVector(a,u){a.startVector(8,u,8)}static addStrings(a,u){a.addFieldOffset(10,u,0)}static createStringsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startStringsVector(a,u){a.startVector(4,u,4)}static addTensors(a,u){a.addFieldOffset(11,u,0)}static createTensorsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startTensorsVector(a,u){a.startVector(4,u,4)}static addGraphs(a,u){a.addFieldOffset(12,u,0)}static createGraphsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startGraphsVector(a,u){a.startVector(4,u,4)}static endAttribute(a){return a.endObject()}static createAttribute(a,u,l,f,c,d,m,g,y,T,_,w,v,L){return r.startAttribute(a),r.addName(a,u),r.addDocString(a,l),r.addType(a,f),r.addF(a,c),r.addI(a,d),r.addS(a,m),r.addT(a,g),r.addG(a,y),r.addFloats(a,T),r.addInts(a,_),r.addStrings(a,w),r.addTensors(a,v),r.addGraphs(a,L),r.endAttribute(a)}}n.Attribute=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsGraph(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsGraph(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}initializers(a,u){let l=this.bb.__offset(this.bb_pos,4);return l?(u||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}initializersLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}nodeArgs(a,u){let l=this.bb.__offset(this.bb_pos,6);return l?(u||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}nodeArgsLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}nodes(a,u){let l=this.bb.__offset(this.bb_pos,8);return l?(u||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}nodesLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}maxNodeIndex(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readUint32(this.bb_pos+a):0}nodeEdges(a,u){let l=this.bb.__offset(this.bb_pos,12);return l?(u||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}nodeEdgesLength(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__vector_len(this.bb_pos+a):0}inputs(a,u){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}inputsLength(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__vector_len(this.bb_pos+a):0}outputs(a,u){let l=this.bb.__offset(this.bb_pos,16);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+a*4,u):null}outputsLength(){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.__vector_len(this.bb_pos+a):0}sparseInitializers(a,u){let l=this.bb.__offset(this.bb_pos,18);return l?(u||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}sparseInitializersLength(){let a=this.bb.__offset(this.bb_pos,18);return a?this.bb.__vector_len(this.bb_pos+a):0}static startGraph(a){a.startObject(8)}static addInitializers(a,u){a.addFieldOffset(0,u,0)}static createInitializersVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startInitializersVector(a,u){a.startVector(4,u,4)}static addNodeArgs(a,u){a.addFieldOffset(1,u,0)}static createNodeArgsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startNodeArgsVector(a,u){a.startVector(4,u,4)}static addNodes(a,u){a.addFieldOffset(2,u,0)}static createNodesVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startNodesVector(a,u){a.startVector(4,u,4)}static addMaxNodeIndex(a,u){a.addFieldInt32(3,u,0)}static addNodeEdges(a,u){a.addFieldOffset(4,u,0)}static createNodeEdgesVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startNodeEdgesVector(a,u){a.startVector(4,u,4)}static addInputs(a,u){a.addFieldOffset(5,u,0)}static createInputsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startInputsVector(a,u){a.startVector(4,u,4)}static addOutputs(a,u){a.addFieldOffset(6,u,0)}static createOutputsVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startOutputsVector(a,u){a.startVector(4,u,4)}static addSparseInitializers(a,u){a.addFieldOffset(7,u,0)}static createSparseInitializersVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startSparseInitializersVector(a,u){a.startVector(4,u,4)}static endGraph(a){return a.endObject()}static createGraph(a,u,l,f,c,d,m,g,y){return r.startGraph(a),r.addInitializers(a,u),r.addNodeArgs(a,l),r.addNodes(a,f),r.addMaxNodeIndex(a,c),r.addNodeEdges(a,d),r.addInputs(a,m),r.addOutputs(a,g),r.addSparseInitializers(a,y),r.endGraph(a)}}n.Graph=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsModel(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsModel(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}irVersion(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}opsetImport(a,u){let l=this.bb.__offset(this.bb_pos,6);return l?(u||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}opsetImportLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}producerName(a){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__string(this.bb_pos+u,a):null}producerVersion(a){let u=this.bb.__offset(this.bb_pos,10);return u?this.bb.__string(this.bb_pos+u,a):null}domain(a){let u=this.bb.__offset(this.bb_pos,12);return u?this.bb.__string(this.bb_pos+u,a):null}modelVersion(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}docString(a){let u=this.bb.__offset(this.bb_pos,16);return u?this.bb.__string(this.bb_pos+u,a):null}graph(a){let u=this.bb.__offset(this.bb_pos,18);return u?(a||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}graphDocString(a){let u=this.bb.__offset(this.bb_pos,20);return u?this.bb.__string(this.bb_pos+u,a):null}static startModel(a){a.startObject(9)}static addIrVersion(a,u){a.addFieldInt64(0,u,a.createLong(0,0))}static addOpsetImport(a,u){a.addFieldOffset(1,u,0)}static createOpsetImportVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startOpsetImportVector(a,u){a.startVector(4,u,4)}static addProducerName(a,u){a.addFieldOffset(2,u,0)}static addProducerVersion(a,u){a.addFieldOffset(3,u,0)}static addDomain(a,u){a.addFieldOffset(4,u,0)}static addModelVersion(a,u){a.addFieldInt64(5,u,a.createLong(0,0))}static addDocString(a,u){a.addFieldOffset(6,u,0)}static addGraph(a,u){a.addFieldOffset(7,u,0)}static addGraphDocString(a,u){a.addFieldOffset(8,u,0)}static endModel(a){return a.endObject()}static createModel(a,u,l,f,c,d,m,g,y,T){return r.startModel(a),r.addIrVersion(a,u),r.addOpsetImport(a,l),r.addProducerName(a,f),r.addProducerVersion(a,c),r.addDomain(a,d),r.addModelVersion(a,m),r.addDocString(a,g),r.addGraph(a,y),r.addGraphDocString(a,T),r.endModel(a)}}n.Model=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsKernelCreateInfos(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsKernelCreateInfos(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}nodeIndices(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.readUint32(this.bb.__vector(this.bb_pos+u)+a*4):0}nodeIndicesLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}nodeIndicesArray(){let a=this.bb.__offset(this.bb_pos,4);return a?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}kernelDefHashes(a){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.readUint64(this.bb.__vector(this.bb_pos+u)+a*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}static startKernelCreateInfos(a){a.startObject(2)}static addNodeIndices(a,u){a.addFieldOffset(0,u,0)}static createNodeIndicesVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addInt32(u[l]);return a.endVector()}static startNodeIndicesVector(a,u){a.startVector(4,u,4)}static addKernelDefHashes(a,u){a.addFieldOffset(1,u,0)}static createKernelDefHashesVector(a,u){a.startVector(8,u.length,8);for(let l=u.length-1;l>=0;l--)a.addInt64(u[l]);return a.endVector()}static startKernelDefHashesVector(a,u){a.startVector(8,u,8)}static endKernelCreateInfos(a){return a.endObject()}static createKernelCreateInfos(a,u,l){return r.startKernelCreateInfos(a),r.addNodeIndices(a,u),r.addKernelDefHashes(a,l),r.endKernelCreateInfos(a)}}n.KernelCreateInfos=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsSubGraphSessionState(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSubGraphSessionState(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}graphId(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}sessionState(a){let u=this.bb.__offset(this.bb_pos,6);return u?(a||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}static startSubGraphSessionState(a){a.startObject(2)}static addGraphId(a,u){a.addFieldOffset(0,u,0)}static addSessionState(a,u){a.addFieldOffset(1,u,0)}static endSubGraphSessionState(a){let u=a.endObject();return a.requiredField(u,4),u}static createSubGraphSessionState(a,u,l){return r.startSubGraphSessionState(a),r.addGraphId(a,u),r.addSessionState(a,l),r.endSubGraphSessionState(a)}}n.SubGraphSessionState=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsSessionState(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSessionState(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}kernels(a){let u=this.bb.__offset(this.bb_pos,4);return u?(a||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}subGraphSessionStates(a,u){let l=this.bb.__offset(this.bb_pos,6);return l?(u||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+a*4),this.bb):null}subGraphSessionStatesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}static startSessionState(a){a.startObject(2)}static addKernels(a,u){a.addFieldOffset(0,u,0)}static addSubGraphSessionStates(a,u){a.addFieldOffset(1,u,0)}static createSubGraphSessionStatesVector(a,u){a.startVector(4,u.length,4);for(let l=u.length-1;l>=0;l--)a.addOffset(u[l]);return a.endVector()}static startSubGraphSessionStatesVector(a,u){a.startVector(4,u,4)}static endSessionState(a){return a.endObject()}static createSessionState(a,u,l){return r.startSessionState(a),r.addKernels(a,u),r.addSubGraphSessionStates(a,l),r.endSessionState(a)}}n.SessionState=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={});(e=>{let i;(t=>{let o;(n=>{class r{constructor(){this.bb=null;this.bb_pos=0}__init(a,u){return this.bb_pos=a,this.bb=u,this}static getRootAsInferenceSession(a,u){return(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsInferenceSession(a,u){return a.setPosition(a.position()+b.SIZE_PREFIX_LENGTH),(u||new r).__init(a.readInt32(a.position())+a.position(),a)}static bufferHasIdentifier(a){return a.__has_identifier("ORTM")}ortVersion(a){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__string(this.bb_pos+u,a):null}model(a){let u=this.bb.__offset(this.bb_pos,6);return u?(a||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}sessionState(a){let u=this.bb.__offset(this.bb_pos,8);return u?(a||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+u),this.bb):null}static startInferenceSession(a){a.startObject(3)}static addOrtVersion(a,u){a.addFieldOffset(0,u,0)}static addModel(a,u){a.addFieldOffset(1,u,0)}static addSessionState(a,u){a.addFieldOffset(2,u,0)}static endInferenceSession(a){return a.endObject()}static finishInferenceSessionBuffer(a,u){a.finish(u,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(a,u){a.finish(u,"ORTM",!0)}static createInferenceSession(a,u,l,f){return r.startInferenceSession(a),r.addOrtVersion(a,u),r.addModel(a,l),r.addSessionState(a,f),r.endInferenceSession(a)}}n.InferenceSession=r})(o=t.fbs||={})})(i=e.experimental||={})})(P||={})});var Zi=tt((yb,Ji)=>{"use strict";Ji.exports=kc;function kc(i,e){for(var o=new Array(arguments.length-1),t=0,r=2,n=!0;r<arguments.length;)o[t++]=arguments[r++];return new Promise(function(a,u){o[t]=function(f){if(n)if(n=!1,f)u(f);else{for(var c=new Array(arguments.length-1),d=0;d<c.length;)c[d++]=arguments[d];a.apply(null,c)}};try{i.apply(e||null,o)}catch(l){n&&(n=!1,u(l))}})}});var ea=tt(ta=>{"use strict";var Er=ta;Er.length=function(e){var o=e.length;if(!o)return 0;for(var t=0;--o%4>1&&e.charAt(o)==="=";)++t;return Math.ceil(e.length*3)/4-t};var Oe=new Array(64),Qi=new Array(123);for(Ft=0;Ft<64;)Qi[Oe[Ft]=Ft<26?Ft+65:Ft<52?Ft+71:Ft<62?Ft-4:Ft-59|43]=Ft++;var Ft;Er.encode=function(e,o,t){for(var r=null,n=[],s=0,a=0,u;o<t;){var l=e[o++];switch(a){case 0:n[s++]=Oe[l>>2],u=(l&3)<<4,a=1;break;case 1:n[s++]=Oe[u|l>>4],u=(l&15)<<2,a=2;break;case 2:n[s++]=Oe[u|l>>6],n[s++]=Oe[l&63],a=0;break}s>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,n)),s=0)}return a&&(n[s++]=Oe[u],n[s++]=61,a===1&&(n[s++]=61)),r?(s&&r.push(String.fromCharCode.apply(String,n.slice(0,s))),r.join("")):String.fromCharCode.apply(String,n.slice(0,s))};var Yi="invalid encoding";Er.decode=function(e,o,t){for(var r=t,n=0,s,a=0;a<e.length;){var u=e.charCodeAt(a++);if(u===61&&n>1)break;if((u=Qi[u])===void 0)throw Error(Yi);switch(n){case 0:s=u,n=1;break;case 1:o[t++]=s<<2|(u&48)>>4,s=u,n=2;break;case 2:o[t++]=(s&15)<<4|(u&60)>>2,s=u,n=3;break;case 3:o[t++]=(s&3)<<6|u,n=0;break}}if(n===1)throw Error(Yi);return t-r};Er.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}});var na=tt((Tb,ra)=>{"use strict";ra.exports=Dr;function Dr(){this._listeners={}}Dr.prototype.on=function(e,o,t){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:o,ctx:t||this}),this};Dr.prototype.off=function(e,o){if(e===void 0)this._listeners={};else if(o===void 0)this._listeners[e]=[];else for(var t=this._listeners[e],r=0;r<t.length;)t[r].fn===o?t.splice(r,1):++r;return this};Dr.prototype.emit=function(e){var o=this._listeners[e];if(o){for(var t=[],r=1;r<arguments.length;)t.push(arguments[r++]);for(r=0;r<o.length;)o[r].fn.apply(o[r++].ctx,t)}return this}});var fa=tt((wb,la)=>{"use strict";la.exports=oa(oa);function oa(i){return typeof Float32Array<"u"?function(){var e=new Float32Array([-0]),o=new Uint8Array(e.buffer),t=o[3]===128;function r(u,l,f){e[0]=u,l[f]=o[0],l[f+1]=o[1],l[f+2]=o[2],l[f+3]=o[3]}function n(u,l,f){e[0]=u,l[f]=o[3],l[f+1]=o[2],l[f+2]=o[1],l[f+3]=o[0]}i.writeFloatLE=t?r:n,i.writeFloatBE=t?n:r;function s(u,l){return o[0]=u[l],o[1]=u[l+1],o[2]=u[l+2],o[3]=u[l+3],e[0]}function a(u,l){return o[3]=u[l],o[2]=u[l+1],o[1]=u[l+2],o[0]=u[l+3],e[0]}i.readFloatLE=t?s:a,i.readFloatBE=t?a:s}():function(){function e(t,r,n,s){var a=r<0?1:0;if(a&&(r=-r),r===0)t(1/r>0?0:2147483648,n,s);else if(isNaN(r))t(2143289344,n,s);else if(r>34028234663852886e22)t((a<<31|2139095040)>>>0,n,s);else if(r<11754943508222875e-54)t((a<<31|Math.round(r/1401298464324817e-60))>>>0,n,s);else{var u=Math.floor(Math.log(r)/Math.LN2),l=Math.round(r*Math.pow(2,-u)*8388608)&8388607;t((a<<31|u+127<<23|l)>>>0,n,s)}}i.writeFloatLE=e.bind(null,ia),i.writeFloatBE=e.bind(null,aa);function o(t,r,n){var s=t(r,n),a=(s>>31)*2+1,u=s>>>23&255,l=s&8388607;return u===255?l?NaN:a*(1/0):u===0?a*1401298464324817e-60*l:a*Math.pow(2,u-150)*(l+8388608)}i.readFloatLE=o.bind(null,sa),i.readFloatBE=o.bind(null,ua)}(),typeof Float64Array<"u"?function(){var e=new Float64Array([-0]),o=new Uint8Array(e.buffer),t=o[7]===128;function r(u,l,f){e[0]=u,l[f]=o[0],l[f+1]=o[1],l[f+2]=o[2],l[f+3]=o[3],l[f+4]=o[4],l[f+5]=o[5],l[f+6]=o[6],l[f+7]=o[7]}function n(u,l,f){e[0]=u,l[f]=o[7],l[f+1]=o[6],l[f+2]=o[5],l[f+3]=o[4],l[f+4]=o[3],l[f+5]=o[2],l[f+6]=o[1],l[f+7]=o[0]}i.writeDoubleLE=t?r:n,i.writeDoubleBE=t?n:r;function s(u,l){return o[0]=u[l],o[1]=u[l+1],o[2]=u[l+2],o[3]=u[l+3],o[4]=u[l+4],o[5]=u[l+5],o[6]=u[l+6],o[7]=u[l+7],e[0]}function a(u,l){return o[7]=u[l],o[6]=u[l+1],o[5]=u[l+2],o[4]=u[l+3],o[3]=u[l+4],o[2]=u[l+5],o[1]=u[l+6],o[0]=u[l+7],e[0]}i.readDoubleLE=t?s:a,i.readDoubleBE=t?a:s}():function(){function e(t,r,n,s,a,u){var l=s<0?1:0;if(l&&(s=-s),s===0)t(0,a,u+r),t(1/s>0?0:2147483648,a,u+n);else if(isNaN(s))t(0,a,u+r),t(2146959360,a,u+n);else if(s>17976931348623157e292)t(0,a,u+r),t((l<<31|2146435072)>>>0,a,u+n);else{var f;if(s<22250738585072014e-324)f=s/5e-324,t(f>>>0,a,u+r),t((l<<31|f/4294967296)>>>0,a,u+n);else{var c=Math.floor(Math.log(s)/Math.LN2);c===1024&&(c=1023),f=s*Math.pow(2,-c),t(f*4503599627370496>>>0,a,u+r),t((l<<31|c+1023<<20|f*1048576&1048575)>>>0,a,u+n)}}}i.writeDoubleLE=e.bind(null,ia,0,4),i.writeDoubleBE=e.bind(null,aa,4,0);function o(t,r,n,s,a){var u=t(s,a+r),l=t(s,a+n),f=(l>>31)*2+1,c=l>>>20&2047,d=4294967296*(l&1048575)+u;return c===2047?d?NaN:f*(1/0):c===0?f*5e-324*d:f*Math.pow(2,c-1075)*(d+4503599627370496)}i.readDoubleLE=o.bind(null,sa,0,4),i.readDoubleBE=o.bind(null,ua,4,0)}(),i}function ia(i,e,o){e[o]=i&255,e[o+1]=i>>>8&255,e[o+2]=i>>>16&255,e[o+3]=i>>>24}function aa(i,e,o){e[o]=i>>>24,e[o+1]=i>>>16&255,e[o+2]=i>>>8&255,e[o+3]=i&255}function sa(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24)>>>0}function ua(i,e){return(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0}});var ca=tt((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(i){}return null}});var da=tt(pa=>{"use strict";var Vn=pa;Vn.length=function(e){for(var o=0,t=0,r=0;r<e.length;++r)t=e.charCodeAt(r),t<128?o+=1:t<2048?o+=2:(t&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320?(++r,o+=4):o+=3;return o};Vn.read=function(e,o,t){var r=t-o;if(r<1)return"";for(var n=null,s=[],a=0,u;o<t;)u=e[o++],u<128?s[a++]=u:u>191&&u<224?s[a++]=(u&31)<<6|e[o++]&63:u>239&&u<365?(u=((u&7)<<18|(e[o++]&63)<<12|(e[o++]&63)<<6|e[o++]&63)-65536,s[a++]=55296+(u>>10),s[a++]=56320+(u&1023)):s[a++]=(u&15)<<12|(e[o++]&63)<<6|e[o++]&63,a>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,s)),a=0);return n?(a&&n.push(String.fromCharCode.apply(String,s.slice(0,a))),n.join("")):String.fromCharCode.apply(String,s.slice(0,a))};Vn.write=function(e,o,t){for(var r=t,n,s,a=0;a<e.length;++a)n=e.charCodeAt(a),n<128?o[t++]=n:n<2048?(o[t++]=n>>6|192,o[t++]=n&63|128):(n&64512)===55296&&((s=e.charCodeAt(a+1))&64512)===56320?(n=65536+((n&1023)<<10)+(s&1023),++a,o[t++]=n>>18|240,o[t++]=n>>12&63|128,o[t++]=n>>6&63|128,o[t++]=n&63|128):(o[t++]=n>>12|224,o[t++]=n>>6&63|128,o[t++]=n&63|128);return t-r}});var ma=tt((Ib,ha)=>{"use strict";ha.exports=Bc;function Bc(i,e,o){var t=o||8192,r=t>>>1,n=null,s=t;return function(u){if(u<1||u>r)return i(u);s+u>t&&(n=i(t),s=0);var l=e.call(n,s,s+=u);return s&7&&(s=(s|7)+1),l}}});var ga=tt((_b,ba)=>{"use strict";ba.exports=it;var je=Qt();function it(i,e){this.lo=i>>>0,this.hi=e>>>0}var ue=it.zero=new it(0,0);ue.toNumber=function(){return 0};ue.zzEncode=ue.zzDecode=function(){return this};ue.length=function(){return 1};var Fc=it.zeroHash="\0\0\0\0\0\0\0\0";it.fromNumber=function(e){if(e===0)return ue;var o=e<0;o&&(e=-e);var t=e>>>0,r=(e-t)/4294967296>>>0;return o&&(r=~r>>>0,t=~t>>>0,++t>4294967295&&(t=0,++r>4294967295&&(r=0))),new it(t,r)};it.from=function(e){if(typeof e=="number")return it.fromNumber(e);if(je.isString(e))if(je.Long)e=je.Long.fromString(e);else return it.fromNumber(parseInt(e,10));return e.low||e.high?new it(e.low>>>0,e.high>>>0):ue};it.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var o=~this.lo+1>>>0,t=~this.hi>>>0;return o||(t=t+1>>>0),-(o+t*4294967296)}return this.lo+this.hi*4294967296};it.prototype.toLong=function(e){return je.Long?new je.Long(this.lo|0,this.hi|0,!!e):{low:this.lo|0,high:this.hi|0,unsigned:!!e}};var Yt=String.prototype.charCodeAt;it.fromHash=function(e){return e===Fc?ue:new it((Yt.call(e,0)|Yt.call(e,1)<<8|Yt.call(e,2)<<16|Yt.call(e,3)<<24)>>>0,(Yt.call(e,4)|Yt.call(e,5)<<8|Yt.call(e,6)<<16|Yt.call(e,7)<<24)>>>0)};it.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};it.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};it.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};it.prototype.length=function(){var e=this.lo,o=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?o===0?e<16384?e<128?1:2:e<2097152?3:4:o<16384?o<128?5:6:o<2097152?7:8:t<128?9:10}});var Qt=tt(Un=>{"use strict";var E=Un;E.asPromise=Zi();E.base64=ea();E.EventEmitter=na();E.float=fa();E.inquire=ca();E.utf8=da();E.pool=ma();E.LongBits=ga();E.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node);E.global=E.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||Un;E.emptyArray=Object.freeze?Object.freeze([]):[];E.emptyObject=Object.freeze?Object.freeze({}):{};E.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};E.isString=function(e){return typeof e=="string"||e instanceof String};E.isObject=function(e){return e&&typeof e=="object"};E.isset=E.isSet=function(e,o){var t=e[o];return t!=null&&e.hasOwnProperty(o)?typeof t!="object"||(Array.isArray(t)?t.length:Object.keys(t).length)>0:!1};E.Buffer=function(){try{var i=E.inquire("buffer").Buffer;return i.prototype.utf8Write?i:null}catch{return null}}();E._Buffer_from=null;E._Buffer_allocUnsafe=null;E.newBuffer=function(e){return typeof e=="number"?E.Buffer?E._Buffer_allocUnsafe(e):new E.Array(e):E.Buffer?E._Buffer_from(e):typeof Uint8Array>"u"?e:new Uint8Array(e)};E.Array=typeof Uint8Array<"u"?Uint8Array:Array;E.Long=E.global.dcodeIO&&E.global.dcodeIO.Long||E.global.Long||E.inquire("long");E.key2Re=/^true|false|0|1$/;E.key32Re=/^-?(?:0|[1-9][0-9]*)$/;E.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;E.longToHash=function(e){return e?E.LongBits.from(e).toHash():E.LongBits.zeroHash};E.longFromHash=function(e,o){var t=E.LongBits.fromHash(e);return E.Long?E.Long.fromBits(t.lo,t.hi,o):t.toNumber(!!o)};function ya(i,e,o){for(var t=Object.keys(e),r=0;r<t.length;++r)(i[t[r]]===void 0||!o)&&(i[t[r]]=e[t[r]]);return i}E.merge=ya;E.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function xa(i){function e(o,t){if(!(this instanceof e))return new e(o,t);Object.defineProperty(this,"message",{get:function(){return o}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),t&&ya(this,t)}return e.prototype=Object.create(Error.prototype,{constructor:{value:e,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return i},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),e}E.newError=xa;E.ProtocolError=xa("ProtocolError");E.oneOfGetter=function(e){for(var o={},t=0;t<e.length;++t)o[e[t]]=1;return function(){for(var r=Object.keys(this),n=r.length-1;n>-1;--n)if(o[r[n]]===1&&this[r[n]]!==void 0&&this[r[n]]!==null)return r[n]}};E.oneOfSetter=function(e){return function(o){for(var t=0;t<e.length;++t)e[t]!==o&&delete this[e[t]]}};E.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};E._configure=function(){var i=E.Buffer;if(!i){E._Buffer_from=E._Buffer_allocUnsafe=null;return}E._Buffer_from=i.from!==Uint8Array.from&&i.from||function(o,t){return new i(o,t)},E._Buffer_allocUnsafe=i.allocUnsafe||function(o){return new i(o)}}});var Kn=tt((Ob,Ia)=>{"use strict";Ia.exports=G;var St=Qt(),zn,Lr=St.LongBits,Ta=St.base64,wa=St.utf8;function Xe(i,e,o){this.fn=i,this.len=e,this.next=void 0,this.val=o}function Hn(){}function Nc(i){this.head=i.head,this.tail=i.tail,this.len=i.len,this.next=i.states}function G(){this.len=0,this.head=new Xe(Hn,0,0),this.tail=this.head,this.states=null}var va=function(){return St.Buffer?function(){return(G.create=function(){return new zn})()}:function(){return new G}};G.create=va();G.alloc=function(e){return new St.Array(e)};St.Array!==Array&&(G.alloc=St.pool(G.alloc,St.Array.prototype.subarray));G.prototype._push=function(e,o,t){return this.tail=this.tail.next=new Xe(e,o,t),this.len+=o,this};function qn(i,e,o){e[o]=i&255}function Cc(i,e,o){for(;i>127;)e[o++]=i&127|128,i>>>=7;e[o]=i}function jn(i,e){this.len=i,this.next=void 0,this.val=e}jn.prototype=Object.create(Xe.prototype);jn.prototype.fn=Cc;G.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new jn((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};G.prototype.int32=function(e){return e<0?this._push(Xn,10,Lr.fromNumber(e)):this.uint32(e)};G.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function Xn(i,e,o){for(;i.hi;)e[o++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)e[o++]=i.lo&127|128,i.lo=i.lo>>>7;e[o++]=i.lo}G.prototype.uint64=function(e){var o=Lr.from(e);return this._push(Xn,o.length(),o)};G.prototype.int64=G.prototype.uint64;G.prototype.sint64=function(e){var o=Lr.from(e).zzEncode();return this._push(Xn,o.length(),o)};G.prototype.bool=function(e){return this._push(qn,1,e?1:0)};function Wn(i,e,o){e[o]=i&255,e[o+1]=i>>>8&255,e[o+2]=i>>>16&255,e[o+3]=i>>>24}G.prototype.fixed32=function(e){return this._push(Wn,4,e>>>0)};G.prototype.sfixed32=G.prototype.fixed32;G.prototype.fixed64=function(e){var o=Lr.from(e);return this._push(Wn,4,o.lo)._push(Wn,4,o.hi)};G.prototype.sfixed64=G.prototype.fixed64;G.prototype.float=function(e){return this._push(St.float.writeFloatLE,4,e)};G.prototype.double=function(e){return this._push(St.float.writeDoubleLE,8,e)};var Rc=St.Array.prototype.set?function(e,o,t){o.set(e,t)}:function(e,o,t){for(var r=0;r<e.length;++r)o[t+r]=e[r]};G.prototype.bytes=function(e){var o=e.length>>>0;if(!o)return this._push(qn,1,0);if(St.isString(e)){var t=G.alloc(o=Ta.length(e));Ta.decode(e,t,0),e=t}return this.uint32(o)._push(Rc,o,e)};G.prototype.string=function(e){var o=wa.length(e);return o?this.uint32(o)._push(wa.write,o,e):this._push(qn,1,0)};G.prototype.fork=function(){return this.states=new Nc(this),this.head=this.tail=new Xe(Hn,0,0),this.len=0,this};G.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 Xe(Hn,0,0),this.len=0),this};G.prototype.ldelim=function(){var e=this.head,o=this.tail,t=this.len;return this.reset().uint32(t),t&&(this.tail.next=e.next,this.tail=o,this.len+=t),this};G.prototype.finish=function(){for(var e=this.head.next,o=this.constructor.alloc(this.len),t=0;e;)e.fn(e.val,o,t),t+=e.len,e=e.next;return o};G._configure=function(i){zn=i,G.create=va(),zn._configure()}});var Oa=tt((Ab,Sa)=>{"use strict";Sa.exports=Gt;var _a=Kn();(Gt.prototype=Object.create(_a.prototype)).constructor=Gt;var te=Qt();function Gt(){_a.call(this)}Gt._configure=function(){Gt.alloc=te._Buffer_allocUnsafe,Gt.writeBytesBuffer=te.Buffer&&te.Buffer.prototype instanceof Uint8Array&&te.Buffer.prototype.set.name==="set"?function(e,o,t){o.set(e,t)}:function(e,o,t){if(e.copy)e.copy(o,t,0,e.length);else for(var r=0;r<e.length;)o[t++]=e[r++]}};Gt.prototype.bytes=function(e){te.isString(e)&&(e=te._Buffer_from(e,"base64"));var o=e.length>>>0;return this.uint32(o),o&&this._push(Gt.writeBytesBuffer,o,e),this};function Gc(i,e,o){i.length<40?te.utf8.write(i,e,o):e.utf8Write?e.utf8Write(i,o):e.write(i,o)}Gt.prototype.string=function(e){var o=te.Buffer.byteLength(e);return this.uint32(o),o&&this._push(Gc,o,e),this};Gt._configure()});var Yn=tt((Pb,La)=>{"use strict";La.exports=K;var Nt=Qt(),Zn,Ea=Nt.LongBits,Mc=Nt.utf8;function Ct(i,e){return RangeError("index out of range: "+i.pos+" + "+(e||1)+" > "+i.len)}function K(i){this.buf=i,this.pos=0,this.len=i.length}var Aa=typeof Uint8Array<"u"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new K(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new K(e);throw Error("illegal buffer")},Da=function(){return Nt.Buffer?function(o){return(K.create=function(r){return Nt.Buffer.isBuffer(r)?new Zn(r):Aa(r)})(o)}:Aa};K.create=Da();K.prototype._slice=Nt.Array.prototype.subarray||Nt.Array.prototype.slice;K.prototype.uint32=function(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ct(this,10);return e}}();K.prototype.int32=function(){return this.uint32()|0};K.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function Jn(){var i=new Ea(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(i.lo=(i.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return i;if(i.lo=(i.lo|(this.buf[this.pos]&127)<<28)>>>0,i.hi=(i.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return i;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Ct(this);if(i.lo=(i.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return i}return i.lo=(i.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,i}if(this.len-this.pos>4){for(;e<5;++e)if(i.hi=(i.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return i}else for(;e<5;++e){if(this.pos>=this.len)throw Ct(this);if(i.hi=(i.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return i}throw Error("invalid varint encoding")}K.prototype.bool=function(){return this.uint32()!==0};function $r(i,e){return(i[e-4]|i[e-3]<<8|i[e-2]<<16|i[e-1]<<24)>>>0}K.prototype.fixed32=function(){if(this.pos+4>this.len)throw Ct(this,4);return $r(this.buf,this.pos+=4)};K.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Ct(this,4);return $r(this.buf,this.pos+=4)|0};function Pa(){if(this.pos+8>this.len)throw Ct(this,8);return new Ea($r(this.buf,this.pos+=4),$r(this.buf,this.pos+=4))}K.prototype.float=function(){if(this.pos+4>this.len)throw Ct(this,4);var e=Nt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};K.prototype.double=function(){if(this.pos+8>this.len)throw Ct(this,4);var e=Nt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};K.prototype.bytes=function(){var e=this.uint32(),o=this.pos,t=this.pos+e;if(t>this.len)throw Ct(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(o,t);if(o===t){var r=Nt.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,o,t)};K.prototype.string=function(){var e=this.bytes();return Mc.read(e,0,e.length)};K.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ct(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ct(this);while(this.buf[this.pos++]&128);return this};K.prototype.skipType=function(i){switch(i){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(i=this.uint32()&7)!==4;)this.skipType(i);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+i+" at offset "+this.pos)}return this};K._configure=function(i){Zn=i,K.create=Da(),Zn._configure();var e=Nt.Long?"toLong":"toNumber";Nt.merge(K.prototype,{int64:function(){return Jn.call(this)[e](!1)},uint64:function(){return Jn.call(this)[e](!0)},sint64:function(){return Jn.call(this).zzDecode()[e](!1)},fixed64:function(){return Pa.call(this)[e](!0)},sfixed64:function(){return Pa.call(this)[e](!1)}})}});var Fa=tt((Eb,Ba)=>{"use strict";Ba.exports=le;var ka=Yn();(le.prototype=Object.create(ka.prototype)).constructor=le;var $a=Qt();function le(i){ka.call(this,i)}le._configure=function(){$a.Buffer&&(le.prototype._slice=$a.Buffer.prototype.slice)};le.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))};le._configure()});var Ca=tt((Db,Na)=>{"use strict";Na.exports=Ke;var Qn=Qt();(Ke.prototype=Object.create(Qn.EventEmitter.prototype)).constructor=Ke;function Ke(i,e,o){if(typeof i!="function")throw TypeError("rpcImpl must be a function");Qn.EventEmitter.call(this),this.rpcImpl=i,this.requestDelimited=!!e,this.responseDelimited=!!o}Ke.prototype.rpcCall=function i(e,o,t,r,n){if(!r)throw TypeError("request must be specified");var s=this;if(!n)return Qn.asPromise(i,s,e,o,t,r);if(!s.rpcImpl){setTimeout(function(){n(Error("already ended"))},0);return}try{return s.rpcImpl(e,o[s.requestDelimited?"encodeDelimited":"encode"](r).finish(),function(u,l){if(u)return s.emit("error",u,e),n(u);if(l===null){s.end(!0);return}if(!(l instanceof t))try{l=t[s.responseDelimited?"decodeDelimited":"decode"](l)}catch(f){return s.emit("error",f,e),n(f)}return s.emit("data",l,e),n(null,l)})}catch(a){s.emit("error",a,e),setTimeout(function(){n(a)},0);return}};Ke.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var Ga=tt(Ra=>{"use strict";var Vc=Ra;Vc.Service=Ca()});var Va=tt(($b,Ma)=>{"use strict";Ma.exports={}});var Wa=tt(za=>{"use strict";var mt=za;mt.build="minimal";mt.Writer=Kn();mt.BufferWriter=Oa();mt.Reader=Yn();mt.BufferReader=Fa();mt.util=Qt();mt.rpc=Ga();mt.roots=Va();mt.configure=Ua;function Ua(){mt.util._configure(),mt.Writer._configure(mt.BufferWriter),mt.Reader._configure(mt.BufferReader)}Ua()});var qa=tt((Bb,Ha)=>{"use strict";Ha.exports=Wa()});var Ae=tt((Fb,ja)=>{"use strict";var q=qa(),S=q.Reader,J=q.Writer,h=q.util,p=q.roots.default||(q.roots.default={});p.onnx=function(){var i={};return i.Version=function(){var e={},o=Object.create(e);return o[e[0]="_START_VERSION"]=0,o[e[1]="IR_VERSION_2017_10_10"]=1,o[e[2]="IR_VERSION_2017_10_30"]=2,o[e[3]="IR_VERSION_2017_11_3"]=3,o[e[4]="IR_VERSION_2019_1_22"]=4,o[e[5]="IR_VERSION_2019_3_18"]=5,o[e[6]="IR_VERSION_2019_9_19"]=6,o[e[7]="IR_VERSION_2020_5_8"]=7,o[e[8]="IR_VERSION_2021_7_30"]=8,o[e[9]="IR_VERSION"]=9,o}(),i.AttributeProto=function(){function e(o){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.name="",e.prototype.refAttrName="",e.prototype.docString="",e.prototype.type=0,e.prototype.f=0,e.prototype.i=h.Long?h.Long.fromBits(0,0,!1):0,e.prototype.s=h.newBuffer([]),e.prototype.t=null,e.prototype.g=null,e.prototype.sparseTensor=null,e.prototype.tp=null,e.prototype.floats=h.emptyArray,e.prototype.ints=h.emptyArray,e.prototype.strings=h.emptyArray,e.prototype.tensors=h.emptyArray,e.prototype.graphs=h.emptyArray,e.prototype.sparseTensors=h.emptyArray,e.prototype.typeProtos=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&r.uint32(10).string(t.name),t.f!=null&&Object.hasOwnProperty.call(t,"f")&&r.uint32(21).float(t.f),t.i!=null&&Object.hasOwnProperty.call(t,"i")&&r.uint32(24).int64(t.i),t.s!=null&&Object.hasOwnProperty.call(t,"s")&&r.uint32(34).bytes(t.s),t.t!=null&&Object.hasOwnProperty.call(t,"t")&&p.onnx.TensorProto.encode(t.t,r.uint32(42).fork()).ldelim(),t.g!=null&&Object.hasOwnProperty.call(t,"g")&&p.onnx.GraphProto.encode(t.g,r.uint32(50).fork()).ldelim(),t.floats!=null&&t.floats.length){r.uint32(58).fork();for(var n=0;n<t.floats.length;++n)r.float(t.floats[n]);r.ldelim()}if(t.ints!=null&&t.ints.length){r.uint32(66).fork();for(var n=0;n<t.ints.length;++n)r.int64(t.ints[n]);r.ldelim()}if(t.strings!=null&&t.strings.length)for(var n=0;n<t.strings.length;++n)r.uint32(74).bytes(t.strings[n]);if(t.tensors!=null&&t.tensors.length)for(var n=0;n<t.tensors.length;++n)p.onnx.TensorProto.encode(t.tensors[n],r.uint32(82).fork()).ldelim();if(t.graphs!=null&&t.graphs.length)for(var n=0;n<t.graphs.length;++n)p.onnx.GraphProto.encode(t.graphs[n],r.uint32(90).fork()).ldelim();if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(106).string(t.docString),t.tp!=null&&Object.hasOwnProperty.call(t,"tp")&&p.onnx.TypeProto.encode(t.tp,r.uint32(114).fork()).ldelim(),t.typeProtos!=null&&t.typeProtos.length)for(var n=0;n<t.typeProtos.length;++n)p.onnx.TypeProto.encode(t.typeProtos[n],r.uint32(122).fork()).ldelim();if(t.type!=null&&Object.hasOwnProperty.call(t,"type")&&r.uint32(160).int32(t.type),t.refAttrName!=null&&Object.hasOwnProperty.call(t,"refAttrName")&&r.uint32(170).string(t.refAttrName),t.sparseTensor!=null&&Object.hasOwnProperty.call(t,"sparseTensor")&&p.onnx.SparseTensorProto.encode(t.sparseTensor,r.uint32(178).fork()).ldelim(),t.sparseTensors!=null&&t.sparseTensors.length)for(var n=0;n<t.sparseTensors.length;++n)p.onnx.SparseTensorProto.encode(t.sparseTensors[n],r.uint32(186).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.AttributeProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.name=t.string();break}case 21:{s.refAttrName=t.string();break}case 13:{s.docString=t.string();break}case 20:{s.type=t.int32();break}case 2:{s.f=t.float();break}case 3:{s.i=t.int64();break}case 4:{s.s=t.bytes();break}case 5:{s.t=p.onnx.TensorProto.decode(t,t.uint32());break}case 6:{s.g=p.onnx.GraphProto.decode(t,t.uint32());break}case 22:{s.sparseTensor=p.onnx.SparseTensorProto.decode(t,t.uint32());break}case 14:{s.tp=p.onnx.TypeProto.decode(t,t.uint32());break}case 7:{if(s.floats&&s.floats.length||(s.floats=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.floats.push(t.float());else s.floats.push(t.float());break}case 8:{if(s.ints&&s.ints.length||(s.ints=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.ints.push(t.int64());else s.ints.push(t.int64());break}case 9:{s.strings&&s.strings.length||(s.strings=[]),s.strings.push(t.bytes());break}case 10:{s.tensors&&s.tensors.length||(s.tensors=[]),s.tensors.push(p.onnx.TensorProto.decode(t,t.uint32()));break}case 11:{s.graphs&&s.graphs.length||(s.graphs=[]),s.graphs.push(p.onnx.GraphProto.decode(t,t.uint32()));break}case 23:{s.sparseTensors&&s.sparseTensors.length||(s.sparseTensors=[]),s.sparseTensors.push(p.onnx.SparseTensorProto.decode(t,t.uint32()));break}case 15:{s.typeProtos&&s.typeProtos.length||(s.typeProtos=[]),s.typeProtos.push(p.onnx.TypeProto.decode(t,t.uint32()));break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&!h.isString(t.refAttrName))return"refAttrName: string expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.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:break}if(t.f!=null&&t.hasOwnProperty("f")&&typeof t.f!="number")return"f: number expected";if(t.i!=null&&t.hasOwnProperty("i")&&!h.isInteger(t.i)&&!(t.i&&h.isInteger(t.i.low)&&h.isInteger(t.i.high)))return"i: integer|Long expected";if(t.s!=null&&t.hasOwnProperty("s")&&!(t.s&&typeof t.s.length=="number"||h.isString(t.s)))return"s: buffer expected";if(t.t!=null&&t.hasOwnProperty("t")){var r=p.onnx.TensorProto.verify(t.t);if(r)return"t."+r}if(t.g!=null&&t.hasOwnProperty("g")){var r=p.onnx.GraphProto.verify(t.g);if(r)return"g."+r}if(t.sparseTensor!=null&&t.hasOwnProperty("sparseTensor")){var r=p.onnx.SparseTensorProto.verify(t.sparseTensor);if(r)return"sparseTensor."+r}if(t.tp!=null&&t.hasOwnProperty("tp")){var r=p.onnx.TypeProto.verify(t.tp);if(r)return"tp."+r}if(t.floats!=null&&t.hasOwnProperty("floats")){if(!Array.isArray(t.floats))return"floats: array expected";for(var n=0;n<t.floats.length;++n)if(typeof t.floats[n]!="number")return"floats: number[] expected"}if(t.ints!=null&&t.hasOwnProperty("ints")){if(!Array.isArray(t.ints))return"ints: array expected";for(var n=0;n<t.ints.length;++n)if(!h.isInteger(t.ints[n])&&!(t.ints[n]&&h.isInteger(t.ints[n].low)&&h.isInteger(t.ints[n].high)))return"ints: integer|Long[] expected"}if(t.strings!=null&&t.hasOwnProperty("strings")){if(!Array.isArray(t.strings))return"strings: array expected";for(var n=0;n<t.strings.length;++n)if(!(t.strings[n]&&typeof t.strings[n].length=="number"||h.isString(t.strings[n])))return"strings: buffer[] expected"}if(t.tensors!=null&&t.hasOwnProperty("tensors")){if(!Array.isArray(t.tensors))return"tensors: array expected";for(var n=0;n<t.tensors.length;++n){var r=p.onnx.TensorProto.verify(t.tensors[n]);if(r)return"tensors."+r}}if(t.graphs!=null&&t.hasOwnProperty("graphs")){if(!Array.isArray(t.graphs))return"graphs: array expected";for(var n=0;n<t.graphs.length;++n){var r=p.onnx.GraphProto.verify(t.graphs[n]);if(r)return"graphs."+r}}if(t.sparseTensors!=null&&t.hasOwnProperty("sparseTensors")){if(!Array.isArray(t.sparseTensors))return"sparseTensors: array expected";for(var n=0;n<t.sparseTensors.length;++n){var r=p.onnx.SparseTensorProto.verify(t.sparseTensors[n]);if(r)return"sparseTensors."+r}}if(t.typeProtos!=null&&t.hasOwnProperty("typeProtos")){if(!Array.isArray(t.typeProtos))return"typeProtos: array expected";for(var n=0;n<t.typeProtos.length;++n){var r=p.onnx.TypeProto.verify(t.typeProtos[n]);if(r)return"typeProtos."+r}}return null},e.fromObject=function(t){if(t instanceof p.onnx.AttributeProto)return t;var r=new p.onnx.AttributeProto;switch(t.name!=null&&(r.name=String(t.name)),t.refAttrName!=null&&(r.refAttrName=String(t.refAttrName)),t.docString!=null&&(r.docString=String(t.docString)),t.type){default:if(typeof t.type=="number"){r.type=t.type;break}break;case"UNDEFINED":case 0:r.type=0;break;case"FLOAT":case 1:r.type=1;break;case"INT":case 2:r.type=2;break;case"STRING":case 3:r.type=3;break;case"TENSOR":case 4:r.type=4;break;case"GRAPH":case 5:r.type=5;break;case"SPARSE_TENSOR":case 11:r.type=11;break;case"TYPE_PROTO":case 13:r.type=13;break;case"FLOATS":case 6:r.type=6;break;case"INTS":case 7:r.type=7;break;case"STRINGS":case 8:r.type=8;break;case"TENSORS":case 9:r.type=9;break;case"GRAPHS":case 10:r.type=10;break;case"SPARSE_TENSORS":case 12:r.type=12;break;case"TYPE_PROTOS":case 14:r.type=14;break}if(t.f!=null&&(r.f=Number(t.f)),t.i!=null&&(h.Long?(r.i=h.Long.fromValue(t.i)).unsigned=!1:typeof t.i=="string"?r.i=parseInt(t.i,10):typeof t.i=="number"?r.i=t.i:typeof t.i=="object"&&(r.i=new h.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber())),t.s!=null&&(typeof t.s=="string"?h.base64.decode(t.s,r.s=h.newBuffer(h.base64.length(t.s)),0):t.s.length>=0&&(r.s=t.s)),t.t!=null){if(typeof t.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");r.t=p.onnx.TensorProto.fromObject(t.t)}if(t.g!=null){if(typeof t.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");r.g=p.onnx.GraphProto.fromObject(t.g)}if(t.sparseTensor!=null){if(typeof t.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");r.sparseTensor=p.onnx.SparseTensorProto.fromObject(t.sparseTensor)}if(t.tp!=null){if(typeof t.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");r.tp=p.onnx.TypeProto.fromObject(t.tp)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");r.floats=[];for(var n=0;n<t.floats.length;++n)r.floats[n]=Number(t.floats[n])}if(t.ints){if(!Array.isArray(t.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");r.ints=[];for(var n=0;n<t.ints.length;++n)h.Long?(r.ints[n]=h.Long.fromValue(t.ints[n])).unsigned=!1:typeof t.ints[n]=="string"?r.ints[n]=parseInt(t.ints[n],10):typeof t.ints[n]=="number"?r.ints[n]=t.ints[n]:typeof t.ints[n]=="object"&&(r.ints[n]=new h.LongBits(t.ints[n].low>>>0,t.ints[n].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");r.strings=[];for(var n=0;n<t.strings.length;++n)typeof t.strings[n]=="string"?h.base64.decode(t.strings[n],r.strings[n]=h.newBuffer(h.base64.length(t.strings[n])),0):t.strings[n].length>=0&&(r.strings[n]=t.strings[n])}if(t.tensors){if(!Array.isArray(t.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");r.tensors=[];for(var n=0;n<t.tensors.length;++n){if(typeof t.tensors[n]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");r.tensors[n]=p.onnx.TensorProto.fromObject(t.tensors[n])}}if(t.graphs){if(!Array.isArray(t.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");r.graphs=[];for(var n=0;n<t.graphs.length;++n){if(typeof t.graphs[n]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");r.graphs[n]=p.onnx.GraphProto.fromObject(t.graphs[n])}}if(t.sparseTensors){if(!Array.isArray(t.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");r.sparseTensors=[];for(var n=0;n<t.sparseTensors.length;++n){if(typeof t.sparseTensors[n]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");r.sparseTensors[n]=p.onnx.SparseTensorProto.fromObject(t.sparseTensors[n])}}if(t.typeProtos){if(!Array.isArray(t.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");r.typeProtos=[];for(var n=0;n<t.typeProtos.length;++n){if(typeof t.typeProtos[n]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");r.typeProtos[n]=p.onnx.TypeProto.fromObject(t.typeProtos[n])}}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.floats=[],n.ints=[],n.strings=[],n.tensors=[],n.graphs=[],n.typeProtos=[],n.sparseTensors=[]),r.defaults){if(n.name="",n.f=0,h.Long){var s=new h.Long(0,0,!1);n.i=r.longs===String?s.toString():r.longs===Number?s.toNumber():s}else n.i=r.longs===String?"0":0;r.bytes===String?n.s="":(n.s=[],r.bytes!==Array&&(n.s=h.newBuffer(n.s))),n.t=null,n.g=null,n.docString="",n.tp=null,n.type=r.enums===String?"UNDEFINED":0,n.refAttrName="",n.sparseTensor=null}if(t.name!=null&&t.hasOwnProperty("name")&&(n.name=t.name),t.f!=null&&t.hasOwnProperty("f")&&(n.f=r.json&&!isFinite(t.f)?String(t.f):t.f),t.i!=null&&t.hasOwnProperty("i")&&(typeof t.i=="number"?n.i=r.longs===String?String(t.i):t.i:n.i=r.longs===String?h.Long.prototype.toString.call(t.i):r.longs===Number?new h.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber():t.i),t.s!=null&&t.hasOwnProperty("s")&&(n.s=r.bytes===String?h.base64.encode(t.s,0,t.s.length):r.bytes===Array?Array.prototype.slice.call(t.s):t.s),t.t!=null&&t.hasOwnProperty("t")&&(n.t=p.onnx.TensorProto.toObject(t.t,r)),t.g!=null&&t.hasOwnProperty("g")&&(n.g=p.onnx.GraphProto.toObject(t.g,r)),t.floats&&t.floats.length){n.floats=[];for(var a=0;a<t.floats.length;++a)n.floats[a]=r.json&&!isFinite(t.floats[a])?String(t.floats[a]):t.floats[a]}if(t.ints&&t.ints.length){n.ints=[];for(var a=0;a<t.ints.length;++a)typeof t.ints[a]=="number"?n.ints[a]=r.longs===String?String(t.ints[a]):t.ints[a]:n.ints[a]=r.longs===String?h.Long.prototype.toString.call(t.ints[a]):r.longs===Number?new h.LongBits(t.ints[a].low>>>0,t.ints[a].high>>>0).toNumber():t.ints[a]}if(t.strings&&t.strings.length){n.strings=[];for(var a=0;a<t.strings.length;++a)n.strings[a]=r.bytes===String?h.base64.encode(t.strings[a],0,t.strings[a].length):r.bytes===Array?Array.prototype.slice.call(t.strings[a]):t.strings[a]}if(t.tensors&&t.tensors.length){n.tensors=[];for(var a=0;a<t.tensors.length;++a)n.tensors[a]=p.onnx.TensorProto.toObject(t.tensors[a],r)}if(t.graphs&&t.graphs.length){n.graphs=[];for(var a=0;a<t.graphs.length;++a)n.graphs[a]=p.onnx.GraphProto.toObject(t.graphs[a],r)}if(t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.tp!=null&&t.hasOwnProperty("tp")&&(n.tp=p.onnx.TypeProto.toObject(t.tp,r)),t.typeProtos&&t.typeProtos.length){n.typeProtos=[];for(var a=0;a<t.typeProtos.length;++a)n.typeProtos[a]=p.onnx.TypeProto.toObject(t.typeProtos[a],r)}if(t.type!=null&&t.hasOwnProperty("type")&&(n.type=r.enums===String?p.onnx.AttributeProto.AttributeType[t.type]===void 0?t.type:p.onnx.AttributeProto.AttributeType[t.type]:t.type),t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&(n.refAttrName=t.refAttrName),t.sparseTensor!=null&&t.hasOwnProperty("sparseTensor")&&(n.sparseTensor=p.onnx.SparseTensorProto.toObject(t.sparseTensor,r)),t.sparseTensors&&t.sparseTensors.length){n.sparseTensors=[];for(var a=0;a<t.sparseTensors.length;++a)n.sparseTensors[a]=p.onnx.SparseTensorProto.toObject(t.sparseTensors[a],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.AttributeProto"},e.AttributeType=function(){var o={},t=Object.create(o);return t[o[0]="UNDEFINED"]=0,t[o[1]="FLOAT"]=1,t[o[2]="INT"]=2,t[o[3]="STRING"]=3,t[o[4]="TENSOR"]=4,t[o[5]="GRAPH"]=5,t[o[11]="SPARSE_TENSOR"]=11,t[o[13]="TYPE_PROTO"]=13,t[o[6]="FLOATS"]=6,t[o[7]="INTS"]=7,t[o[8]="STRINGS"]=8,t[o[9]="TENSORS"]=9,t[o[10]="GRAPHS"]=10,t[o[12]="SPARSE_TENSORS"]=12,t[o[14]="TYPE_PROTOS"]=14,t}(),e}(),i.ValueInfoProto=function(){function e(o){if(o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.name="",e.prototype.type=null,e.prototype.docString="",e.create=function(t){return new e(t)},e.encode=function(t,r){return r||(r=J.create()),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&r.uint32(10).string(t.name),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&p.onnx.TypeProto.encode(t.type,r.uint32(18).fork()).ldelim(),t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(26).string(t.docString),r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.ValueInfoProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.name=t.string();break}case 2:{s.type=p.onnx.TypeProto.decode(t,t.uint32());break}case 3:{s.docString=t.string();break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.type!=null&&t.hasOwnProperty("type")){var r=p.onnx.TypeProto.verify(t.type);if(r)return"type."+r}return t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString)?"docString: string expected":null},e.fromObject=function(t){if(t instanceof p.onnx.ValueInfoProto)return t;var r=new p.onnx.ValueInfoProto;if(t.name!=null&&(r.name=String(t.name)),t.type!=null){if(typeof t.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");r.type=p.onnx.TypeProto.fromObject(t.type)}return t.docString!=null&&(r.docString=String(t.docString)),r},e.toObject=function(t,r){r||(r={});var n={};return r.defaults&&(n.name="",n.type=null,n.docString=""),t.name!=null&&t.hasOwnProperty("name")&&(n.name=t.name),t.type!=null&&t.hasOwnProperty("type")&&(n.type=p.onnx.TypeProto.toObject(t.type,r)),t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.ValueInfoProto"},e}(),i.NodeProto=function(){function e(o){if(this.input=[],this.output=[],this.attribute=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.input=h.emptyArray,e.prototype.output=h.emptyArray,e.prototype.name="",e.prototype.opType="",e.prototype.domain="",e.prototype.attribute=h.emptyArray,e.prototype.docString="",e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.input!=null&&t.input.length)for(var n=0;n<t.input.length;++n)r.uint32(10).string(t.input[n]);if(t.output!=null&&t.output.length)for(var n=0;n<t.output.length;++n)r.uint32(18).string(t.output[n]);if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&r.uint32(26).string(t.name),t.opType!=null&&Object.hasOwnProperty.call(t,"opType")&&r.uint32(34).string(t.opType),t.attribute!=null&&t.attribute.length)for(var n=0;n<t.attribute.length;++n)p.onnx.AttributeProto.encode(t.attribute[n],r.uint32(42).fork()).ldelim();return t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(50).string(t.docString),t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&r.uint32(58).string(t.domain),r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.NodeProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.input&&s.input.length||(s.input=[]),s.input.push(t.string());break}case 2:{s.output&&s.output.length||(s.output=[]),s.output.push(t.string());break}case 3:{s.name=t.string();break}case 4:{s.opType=t.string();break}case 7:{s.domain=t.string();break}case 5:{s.attribute&&s.attribute.length||(s.attribute=[]),s.attribute.push(p.onnx.AttributeProto.decode(t,t.uint32()));break}case 6:{s.docString=t.string();break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var r=0;r<t.input.length;++r)if(!h.isString(t.input[r]))return"input: string[] expected"}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var r=0;r<t.output.length;++r)if(!h.isString(t.output[r]))return"output: string[] expected"}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.opType!=null&&t.hasOwnProperty("opType")&&!h.isString(t.opType))return"opType: string expected";if(t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain))return"domain: string expected";if(t.attribute!=null&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(var r=0;r<t.attribute.length;++r){var n=p.onnx.AttributeProto.verify(t.attribute[r]);if(n)return"attribute."+n}}return t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString)?"docString: string expected":null},e.fromObject=function(t){if(t instanceof p.onnx.NodeProto)return t;var r=new p.onnx.NodeProto;if(t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.NodeProto.input: array expected");r.input=[];for(var n=0;n<t.input.length;++n)r.input[n]=String(t.input[n])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.NodeProto.output: array expected");r.output=[];for(var n=0;n<t.output.length;++n)r.output[n]=String(t.output[n])}if(t.name!=null&&(r.name=String(t.name)),t.opType!=null&&(r.opType=String(t.opType)),t.domain!=null&&(r.domain=String(t.domain)),t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");r.attribute=[];for(var n=0;n<t.attribute.length;++n){if(typeof t.attribute[n]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");r.attribute[n]=p.onnx.AttributeProto.fromObject(t.attribute[n])}}return t.docString!=null&&(r.docString=String(t.docString)),r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.input=[],n.output=[],n.attribute=[]),r.defaults&&(n.name="",n.opType="",n.docString="",n.domain=""),t.input&&t.input.length){n.input=[];for(var s=0;s<t.input.length;++s)n.input[s]=t.input[s]}if(t.output&&t.output.length){n.output=[];for(var s=0;s<t.output.length;++s)n.output[s]=t.output[s]}if(t.name!=null&&t.hasOwnProperty("name")&&(n.name=t.name),t.opType!=null&&t.hasOwnProperty("opType")&&(n.opType=t.opType),t.attribute&&t.attribute.length){n.attribute=[];for(var s=0;s<t.attribute.length;++s)n.attribute[s]=p.onnx.AttributeProto.toObject(t.attribute[s],r)}return t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.domain!=null&&t.hasOwnProperty("domain")&&(n.domain=t.domain),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.NodeProto"},e}(),i.TrainingInfoProto=function(){function e(o){if(this.initializationBinding=[],this.updateBinding=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.initialization=null,e.prototype.algorithm=null,e.prototype.initializationBinding=h.emptyArray,e.prototype.updateBinding=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.initialization!=null&&Object.hasOwnProperty.call(t,"initialization")&&p.onnx.GraphProto.encode(t.initialization,r.uint32(10).fork()).ldelim(),t.algorithm!=null&&Object.hasOwnProperty.call(t,"algorithm")&&p.onnx.GraphProto.encode(t.algorithm,r.uint32(18).fork()).ldelim(),t.initializationBinding!=null&&t.initializationBinding.length)for(var n=0;n<t.initializationBinding.length;++n)p.onnx.StringStringEntryProto.encode(t.initializationBinding[n],r.uint32(26).fork()).ldelim();if(t.updateBinding!=null&&t.updateBinding.length)for(var n=0;n<t.updateBinding.length;++n)p.onnx.StringStringEntryProto.encode(t.updateBinding[n],r.uint32(34).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.TrainingInfoProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.initialization=p.onnx.GraphProto.decode(t,t.uint32());break}case 2:{s.algorithm=p.onnx.GraphProto.decode(t,t.uint32());break}case 3:{s.initializationBinding&&s.initializationBinding.length||(s.initializationBinding=[]),s.initializationBinding.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break}case 4:{s.updateBinding&&s.updateBinding.length||(s.updateBinding=[]),s.updateBinding.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.initialization!=null&&t.hasOwnProperty("initialization")){var r=p.onnx.GraphProto.verify(t.initialization);if(r)return"initialization."+r}if(t.algorithm!=null&&t.hasOwnProperty("algorithm")){var r=p.onnx.GraphProto.verify(t.algorithm);if(r)return"algorithm."+r}if(t.initializationBinding!=null&&t.hasOwnProperty("initializationBinding")){if(!Array.isArray(t.initializationBinding))return"initializationBinding: array expected";for(var n=0;n<t.initializationBinding.length;++n){var r=p.onnx.StringStringEntryProto.verify(t.initializationBinding[n]);if(r)return"initializationBinding."+r}}if(t.updateBinding!=null&&t.hasOwnProperty("updateBinding")){if(!Array.isArray(t.updateBinding))return"updateBinding: array expected";for(var n=0;n<t.updateBinding.length;++n){var r=p.onnx.StringStringEntryProto.verify(t.updateBinding[n]);if(r)return"updateBinding."+r}}return null},e.fromObject=function(t){if(t instanceof p.onnx.TrainingInfoProto)return t;var r=new p.onnx.TrainingInfoProto;if(t.initialization!=null){if(typeof t.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");r.initialization=p.onnx.GraphProto.fromObject(t.initialization)}if(t.algorithm!=null){if(typeof t.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");r.algorithm=p.onnx.GraphProto.fromObject(t.algorithm)}if(t.initializationBinding){if(!Array.isArray(t.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");r.initializationBinding=[];for(var n=0;n<t.initializationBinding.length;++n){if(typeof t.initializationBinding[n]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");r.initializationBinding[n]=p.onnx.StringStringEntryProto.fromObject(t.initializationBinding[n])}}if(t.updateBinding){if(!Array.isArray(t.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");r.updateBinding=[];for(var n=0;n<t.updateBinding.length;++n){if(typeof t.updateBinding[n]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");r.updateBinding[n]=p.onnx.StringStringEntryProto.fromObject(t.updateBinding[n])}}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.initializationBinding=[],n.updateBinding=[]),r.defaults&&(n.initialization=null,n.algorithm=null),t.initialization!=null&&t.hasOwnProperty("initialization")&&(n.initialization=p.onnx.GraphProto.toObject(t.initialization,r)),t.algorithm!=null&&t.hasOwnProperty("algorithm")&&(n.algorithm=p.onnx.GraphProto.toObject(t.algorithm,r)),t.initializationBinding&&t.initializationBinding.length){n.initializationBinding=[];for(var s=0;s<t.initializationBinding.length;++s)n.initializationBinding[s]=p.onnx.StringStringEntryProto.toObject(t.initializationBinding[s],r)}if(t.updateBinding&&t.updateBinding.length){n.updateBinding=[];for(var s=0;s<t.updateBinding.length;++s)n.updateBinding[s]=p.onnx.StringStringEntryProto.toObject(t.updateBinding[s],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TrainingInfoProto"},e}(),i.ModelProto=function(){function e(o){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.irVersion=h.Long?h.Long.fromBits(0,0,!1):0,e.prototype.opsetImport=h.emptyArray,e.prototype.producerName="",e.prototype.producerVersion="",e.prototype.domain="",e.prototype.modelVersion=h.Long?h.Long.fromBits(0,0,!1):0,e.prototype.docString="",e.prototype.graph=null,e.prototype.metadataProps=h.emptyArray,e.prototype.trainingInfo=h.emptyArray,e.prototype.functions=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.irVersion!=null&&Object.hasOwnProperty.call(t,"irVersion")&&r.uint32(8).int64(t.irVersion),t.producerName!=null&&Object.hasOwnProperty.call(t,"producerName")&&r.uint32(18).string(t.producerName),t.producerVersion!=null&&Object.hasOwnProperty.call(t,"producerVersion")&&r.uint32(26).string(t.producerVersion),t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&r.uint32(34).string(t.domain),t.modelVersion!=null&&Object.hasOwnProperty.call(t,"modelVersion")&&r.uint32(40).int64(t.modelVersion),t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(50).string(t.docString),t.graph!=null&&Object.hasOwnProperty.call(t,"graph")&&p.onnx.GraphProto.encode(t.graph,r.uint32(58).fork()).ldelim(),t.opsetImport!=null&&t.opsetImport.length)for(var n=0;n<t.opsetImport.length;++n)p.onnx.OperatorSetIdProto.encode(t.opsetImport[n],r.uint32(66).fork()).ldelim();if(t.metadataProps!=null&&t.metadataProps.length)for(var n=0;n<t.metadataProps.length;++n)p.onnx.StringStringEntryProto.encode(t.metadataProps[n],r.uint32(114).fork()).ldelim();if(t.trainingInfo!=null&&t.trainingInfo.length)for(var n=0;n<t.trainingInfo.length;++n)p.onnx.TrainingInfoProto.encode(t.trainingInfo[n],r.uint32(162).fork()).ldelim();if(t.functions!=null&&t.functions.length)for(var n=0;n<t.functions.length;++n)p.onnx.FunctionProto.encode(t.functions[n],r.uint32(202).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.ModelProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.irVersion=t.int64();break}case 8:{s.opsetImport&&s.opsetImport.length||(s.opsetImport=[]),s.opsetImport.push(p.onnx.OperatorSetIdProto.decode(t,t.uint32()));break}case 2:{s.producerName=t.string();break}case 3:{s.producerVersion=t.string();break}case 4:{s.domain=t.string();break}case 5:{s.modelVersion=t.int64();break}case 6:{s.docString=t.string();break}case 7:{s.graph=p.onnx.GraphProto.decode(t,t.uint32());break}case 14:{s.metadataProps&&s.metadataProps.length||(s.metadataProps=[]),s.metadataProps.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break}case 20:{s.trainingInfo&&s.trainingInfo.length||(s.trainingInfo=[]),s.trainingInfo.push(p.onnx.TrainingInfoProto.decode(t,t.uint32()));break}case 25:{s.functions&&s.functions.length||(s.functions=[]),s.functions.push(p.onnx.FunctionProto.decode(t,t.uint32()));break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&!h.isInteger(t.irVersion)&&!(t.irVersion&&h.isInteger(t.irVersion.low)&&h.isInteger(t.irVersion.high)))return"irVersion: integer|Long expected";if(t.opsetImport!=null&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var r=0;r<t.opsetImport.length;++r){var n=p.onnx.OperatorSetIdProto.verify(t.opsetImport[r]);if(n)return"opsetImport."+n}}if(t.producerName!=null&&t.hasOwnProperty("producerName")&&!h.isString(t.producerName))return"producerName: string expected";if(t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&!h.isString(t.producerVersion))return"producerVersion: string expected";if(t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain))return"domain: string expected";if(t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&!h.isInteger(t.modelVersion)&&!(t.modelVersion&&h.isInteger(t.modelVersion.low)&&h.isInteger(t.modelVersion.high)))return"modelVersion: integer|Long expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.graph!=null&&t.hasOwnProperty("graph")){var n=p.onnx.GraphProto.verify(t.graph);if(n)return"graph."+n}if(t.metadataProps!=null&&t.hasOwnProperty("metadataProps")){if(!Array.isArray(t.metadataProps))return"metadataProps: array expected";for(var r=0;r<t.metadataProps.length;++r){var n=p.onnx.StringStringEntryProto.verify(t.metadataProps[r]);if(n)return"metadataProps."+n}}if(t.trainingInfo!=null&&t.hasOwnProperty("trainingInfo")){if(!Array.isArray(t.trainingInfo))return"trainingInfo: array expected";for(var r=0;r<t.trainingInfo.length;++r){var n=p.onnx.TrainingInfoProto.verify(t.trainingInfo[r]);if(n)return"trainingInfo."+n}}if(t.functions!=null&&t.hasOwnProperty("functions")){if(!Array.isArray(t.functions))return"functions: array expected";for(var r=0;r<t.functions.length;++r){var n=p.onnx.FunctionProto.verify(t.functions[r]);if(n)return"functions."+n}}return null},e.fromObject=function(t){if(t instanceof p.onnx.ModelProto)return t;var r=new p.onnx.ModelProto;if(t.irVersion!=null&&(h.Long?(r.irVersion=h.Long.fromValue(t.irVersion)).unsigned=!1:typeof t.irVersion=="string"?r.irVersion=parseInt(t.irVersion,10):typeof t.irVersion=="number"?r.irVersion=t.irVersion:typeof t.irVersion=="object"&&(r.irVersion=new h.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber())),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");r.opsetImport=[];for(var n=0;n<t.opsetImport.length;++n){if(typeof t.opsetImport[n]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");r.opsetImport[n]=p.onnx.OperatorSetIdProto.fromObject(t.opsetImport[n])}}if(t.producerName!=null&&(r.producerName=String(t.producerName)),t.producerVersion!=null&&(r.producerVersion=String(t.producerVersion)),t.domain!=null&&(r.domain=String(t.domain)),t.modelVersion!=null&&(h.Long?(r.modelVersion=h.Long.fromValue(t.modelVersion)).unsigned=!1:typeof t.modelVersion=="string"?r.modelVersion=parseInt(t.modelVersion,10):typeof t.modelVersion=="number"?r.modelVersion=t.modelVersion:typeof t.modelVersion=="object"&&(r.modelVersion=new h.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber())),t.docString!=null&&(r.docString=String(t.docString)),t.graph!=null){if(typeof t.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");r.graph=p.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");r.metadataProps=[];for(var n=0;n<t.metadataProps.length;++n){if(typeof t.metadataProps[n]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");r.metadataProps[n]=p.onnx.StringStringEntryProto.fromObject(t.metadataProps[n])}}if(t.trainingInfo){if(!Array.isArray(t.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");r.trainingInfo=[];for(var n=0;n<t.trainingInfo.length;++n){if(typeof t.trainingInfo[n]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");r.trainingInfo[n]=p.onnx.TrainingInfoProto.fromObject(t.trainingInfo[n])}}if(t.functions){if(!Array.isArray(t.functions))throw TypeError(".onnx.ModelProto.functions: array expected");r.functions=[];for(var n=0;n<t.functions.length;++n){if(typeof t.functions[n]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");r.functions[n]=p.onnx.FunctionProto.fromObject(t.functions[n])}}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.opsetImport=[],n.metadataProps=[],n.trainingInfo=[],n.functions=[]),r.defaults){if(h.Long){var s=new h.Long(0,0,!1);n.irVersion=r.longs===String?s.toString():r.longs===Number?s.toNumber():s}else n.irVersion=r.longs===String?"0":0;if(n.producerName="",n.producerVersion="",n.domain="",h.Long){var s=new h.Long(0,0,!1);n.modelVersion=r.longs===String?s.toString():r.longs===Number?s.toNumber():s}else n.modelVersion=r.longs===String?"0":0;n.docString="",n.graph=null}if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&(typeof t.irVersion=="number"?n.irVersion=r.longs===String?String(t.irVersion):t.irVersion:n.irVersion=r.longs===String?h.Long.prototype.toString.call(t.irVersion):r.longs===Number?new h.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber():t.irVersion),t.producerName!=null&&t.hasOwnProperty("producerName")&&(n.producerName=t.producerName),t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&(n.producerVersion=t.producerVersion),t.domain!=null&&t.hasOwnProperty("domain")&&(n.domain=t.domain),t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&(typeof t.modelVersion=="number"?n.modelVersion=r.longs===String?String(t.modelVersion):t.modelVersion:n.modelVersion=r.longs===String?h.Long.prototype.toString.call(t.modelVersion):r.longs===Number?new h.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.graph!=null&&t.hasOwnProperty("graph")&&(n.graph=p.onnx.GraphProto.toObject(t.graph,r)),t.opsetImport&&t.opsetImport.length){n.opsetImport=[];for(var a=0;a<t.opsetImport.length;++a)n.opsetImport[a]=p.onnx.OperatorSetIdProto.toObject(t.opsetImport[a],r)}if(t.metadataProps&&t.metadataProps.length){n.metadataProps=[];for(var a=0;a<t.metadataProps.length;++a)n.metadataProps[a]=p.onnx.StringStringEntryProto.toObject(t.metadataProps[a],r)}if(t.trainingInfo&&t.trainingInfo.length){n.trainingInfo=[];for(var a=0;a<t.trainingInfo.length;++a)n.trainingInfo[a]=p.onnx.TrainingInfoProto.toObject(t.trainingInfo[a],r)}if(t.functions&&t.functions.length){n.functions=[];for(var a=0;a<t.functions.length;++a)n.functions[a]=p.onnx.FunctionProto.toObject(t.functions[a],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.ModelProto"},e}(),i.StringStringEntryProto=function(){function e(o){if(o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.key="",e.prototype.value="",e.create=function(t){return new e(t)},e.encode=function(t,r){return r||(r=J.create()),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&r.uint32(10).string(t.key),t.value!=null&&Object.hasOwnProperty.call(t,"value")&&r.uint32(18).string(t.value),r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.StringStringEntryProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.key=t.string();break}case 2:{s.value=t.string();break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.key!=null&&t.hasOwnProperty("key")&&!h.isString(t.key)?"key: string expected":t.value!=null&&t.hasOwnProperty("value")&&!h.isString(t.value)?"value: string expected":null},e.fromObject=function(t){if(t instanceof p.onnx.StringStringEntryProto)return t;var r=new p.onnx.StringStringEntryProto;return t.key!=null&&(r.key=String(t.key)),t.value!=null&&(r.value=String(t.value)),r},e.toObject=function(t,r){r||(r={});var n={};return r.defaults&&(n.key="",n.value=""),t.key!=null&&t.hasOwnProperty("key")&&(n.key=t.key),t.value!=null&&t.hasOwnProperty("value")&&(n.value=t.value),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.StringStringEntryProto"},e}(),i.TensorAnnotation=function(){function e(o){if(this.quantParameterTensorNames=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.tensorName="",e.prototype.quantParameterTensorNames=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.tensorName!=null&&Object.hasOwnProperty.call(t,"tensorName")&&r.uint32(10).string(t.tensorName),t.quantParameterTensorNames!=null&&t.quantParameterTensorNames.length)for(var n=0;n<t.quantParameterTensorNames.length;++n)p.onnx.StringStringEntryProto.encode(t.quantParameterTensorNames[n],r.uint32(18).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.TensorAnnotation;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.tensorName=t.string();break}case 2:{s.quantParameterTensorNames&&s.quantParameterTensorNames.length||(s.quantParameterTensorNames=[]),s.quantParameterTensorNames.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.tensorName!=null&&t.hasOwnProperty("tensorName")&&!h.isString(t.tensorName))return"tensorName: string expected";if(t.quantParameterTensorNames!=null&&t.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(t.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var r=0;r<t.quantParameterTensorNames.length;++r){var n=p.onnx.StringStringEntryProto.verify(t.quantParameterTensorNames[r]);if(n)return"quantParameterTensorNames."+n}}return null},e.fromObject=function(t){if(t instanceof p.onnx.TensorAnnotation)return t;var r=new p.onnx.TensorAnnotation;if(t.tensorName!=null&&(r.tensorName=String(t.tensorName)),t.quantParameterTensorNames){if(!Array.isArray(t.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");r.quantParameterTensorNames=[];for(var n=0;n<t.quantParameterTensorNames.length;++n){if(typeof t.quantParameterTensorNames[n]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");r.quantParameterTensorNames[n]=p.onnx.StringStringEntryProto.fromObject(t.quantParameterTensorNames[n])}}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.quantParameterTensorNames=[]),r.defaults&&(n.tensorName=""),t.tensorName!=null&&t.hasOwnProperty("tensorName")&&(n.tensorName=t.tensorName),t.quantParameterTensorNames&&t.quantParameterTensorNames.length){n.quantParameterTensorNames=[];for(var s=0;s<t.quantParameterTensorNames.length;++s)n.quantParameterTensorNames[s]=p.onnx.StringStringEntryProto.toObject(t.quantParameterTensorNames[s],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TensorAnnotation"},e}(),i.GraphProto=function(){function e(o){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.node=h.emptyArray,e.prototype.name="",e.prototype.initializer=h.emptyArray,e.prototype.sparseInitializer=h.emptyArray,e.prototype.docString="",e.prototype.input=h.emptyArray,e.prototype.output=h.emptyArray,e.prototype.valueInfo=h.emptyArray,e.prototype.quantizationAnnotation=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.node!=null&&t.node.length)for(var n=0;n<t.node.length;++n)p.onnx.NodeProto.encode(t.node[n],r.uint32(10).fork()).ldelim();if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&r.uint32(18).string(t.name),t.initializer!=null&&t.initializer.length)for(var n=0;n<t.initializer.length;++n)p.onnx.TensorProto.encode(t.initializer[n],r.uint32(42).fork()).ldelim();if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(82).string(t.docString),t.input!=null&&t.input.length)for(var n=0;n<t.input.length;++n)p.onnx.ValueInfoProto.encode(t.input[n],r.uint32(90).fork()).ldelim();if(t.output!=null&&t.output.length)for(var n=0;n<t.output.length;++n)p.onnx.ValueInfoProto.encode(t.output[n],r.uint32(98).fork()).ldelim();if(t.valueInfo!=null&&t.valueInfo.length)for(var n=0;n<t.valueInfo.length;++n)p.onnx.ValueInfoProto.encode(t.valueInfo[n],r.uint32(106).fork()).ldelim();if(t.quantizationAnnotation!=null&&t.quantizationAnnotation.length)for(var n=0;n<t.quantizationAnnotation.length;++n)p.onnx.TensorAnnotation.encode(t.quantizationAnnotation[n],r.uint32(114).fork()).ldelim();if(t.sparseInitializer!=null&&t.sparseInitializer.length)for(var n=0;n<t.sparseInitializer.length;++n)p.onnx.SparseTensorProto.encode(t.sparseInitializer[n],r.uint32(122).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.GraphProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.node&&s.node.length||(s.node=[]),s.node.push(p.onnx.NodeProto.decode(t,t.uint32()));break}case 2:{s.name=t.string();break}case 5:{s.initializer&&s.initializer.length||(s.initializer=[]),s.initializer.push(p.onnx.TensorProto.decode(t,t.uint32()));break}case 15:{s.sparseInitializer&&s.sparseInitializer.length||(s.sparseInitializer=[]),s.sparseInitializer.push(p.onnx.SparseTensorProto.decode(t,t.uint32()));break}case 10:{s.docString=t.string();break}case 11:{s.input&&s.input.length||(s.input=[]),s.input.push(p.onnx.ValueInfoProto.decode(t,t.uint32()));break}case 12:{s.output&&s.output.length||(s.output=[]),s.output.push(p.onnx.ValueInfoProto.decode(t,t.uint32()));break}case 13:{s.valueInfo&&s.valueInfo.length||(s.valueInfo=[]),s.valueInfo.push(p.onnx.ValueInfoProto.decode(t,t.uint32()));break}case 14:{s.quantizationAnnotation&&s.quantizationAnnotation.length||(s.quantizationAnnotation=[]),s.quantizationAnnotation.push(p.onnx.TensorAnnotation.decode(t,t.uint32()));break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.node!=null&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var r=0;r<t.node.length;++r){var n=p.onnx.NodeProto.verify(t.node[r]);if(n)return"node."+n}}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.initializer!=null&&t.hasOwnProperty("initializer")){if(!Array.isArray(t.initializer))return"initializer: array expected";for(var r=0;r<t.initializer.length;++r){var n=p.onnx.TensorProto.verify(t.initializer[r]);if(n)return"initializer."+n}}if(t.sparseInitializer!=null&&t.hasOwnProperty("sparseInitializer")){if(!Array.isArray(t.sparseInitializer))return"sparseInitializer: array expected";for(var r=0;r<t.sparseInitializer.length;++r){var n=p.onnx.SparseTensorProto.verify(t.sparseInitializer[r]);if(n)return"sparseInitializer."+n}}if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var r=0;r<t.input.length;++r){var n=p.onnx.ValueInfoProto.verify(t.input[r]);if(n)return"input."+n}}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var r=0;r<t.output.length;++r){var n=p.onnx.ValueInfoProto.verify(t.output[r]);if(n)return"output."+n}}if(t.valueInfo!=null&&t.hasOwnProperty("valueInfo")){if(!Array.isArray(t.valueInfo))return"valueInfo: array expected";for(var r=0;r<t.valueInfo.length;++r){var n=p.onnx.ValueInfoProto.verify(t.valueInfo[r]);if(n)return"valueInfo."+n}}if(t.quantizationAnnotation!=null&&t.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(t.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var r=0;r<t.quantizationAnnotation.length;++r){var n=p.onnx.TensorAnnotation.verify(t.quantizationAnnotation[r]);if(n)return"quantizationAnnotation."+n}}return null},e.fromObject=function(t){if(t instanceof p.onnx.GraphProto)return t;var r=new p.onnx.GraphProto;if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.GraphProto.node: array expected");r.node=[];for(var n=0;n<t.node.length;++n){if(typeof t.node[n]!="object")throw TypeError(".onnx.GraphProto.node: object expected");r.node[n]=p.onnx.NodeProto.fromObject(t.node[n])}}if(t.name!=null&&(r.name=String(t.name)),t.initializer){if(!Array.isArray(t.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");r.initializer=[];for(var n=0;n<t.initializer.length;++n){if(typeof t.initializer[n]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");r.initializer[n]=p.onnx.TensorProto.fromObject(t.initializer[n])}}if(t.sparseInitializer){if(!Array.isArray(t.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");r.sparseInitializer=[];for(var n=0;n<t.sparseInitializer.length;++n){if(typeof t.sparseInitializer[n]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");r.sparseInitializer[n]=p.onnx.SparseTensorProto.fromObject(t.sparseInitializer[n])}}if(t.docString!=null&&(r.docString=String(t.docString)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.GraphProto.input: array expected");r.input=[];for(var n=0;n<t.input.length;++n){if(typeof t.input[n]!="object")throw TypeError(".onnx.GraphProto.input: object expected");r.input[n]=p.onnx.ValueInfoProto.fromObject(t.input[n])}}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.GraphProto.output: array expected");r.output=[];for(var n=0;n<t.output.length;++n){if(typeof t.output[n]!="object")throw TypeError(".onnx.GraphProto.output: object expected");r.output[n]=p.onnx.ValueInfoProto.fromObject(t.output[n])}}if(t.valueInfo){if(!Array.isArray(t.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");r.valueInfo=[];for(var n=0;n<t.valueInfo.length;++n){if(typeof t.valueInfo[n]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");r.valueInfo[n]=p.onnx.ValueInfoProto.fromObject(t.valueInfo[n])}}if(t.quantizationAnnotation){if(!Array.isArray(t.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");r.quantizationAnnotation=[];for(var n=0;n<t.quantizationAnnotation.length;++n){if(typeof t.quantizationAnnotation[n]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");r.quantizationAnnotation[n]=p.onnx.TensorAnnotation.fromObject(t.quantizationAnnotation[n])}}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.node=[],n.initializer=[],n.input=[],n.output=[],n.valueInfo=[],n.quantizationAnnotation=[],n.sparseInitializer=[]),r.defaults&&(n.name="",n.docString=""),t.node&&t.node.length){n.node=[];for(var s=0;s<t.node.length;++s)n.node[s]=p.onnx.NodeProto.toObject(t.node[s],r)}if(t.name!=null&&t.hasOwnProperty("name")&&(n.name=t.name),t.initializer&&t.initializer.length){n.initializer=[];for(var s=0;s<t.initializer.length;++s)n.initializer[s]=p.onnx.TensorProto.toObject(t.initializer[s],r)}if(t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.input&&t.input.length){n.input=[];for(var s=0;s<t.input.length;++s)n.input[s]=p.onnx.ValueInfoProto.toObject(t.input[s],r)}if(t.output&&t.output.length){n.output=[];for(var s=0;s<t.output.length;++s)n.output[s]=p.onnx.ValueInfoProto.toObject(t.output[s],r)}if(t.valueInfo&&t.valueInfo.length){n.valueInfo=[];for(var s=0;s<t.valueInfo.length;++s)n.valueInfo[s]=p.onnx.ValueInfoProto.toObject(t.valueInfo[s],r)}if(t.quantizationAnnotation&&t.quantizationAnnotation.length){n.quantizationAnnotation=[];for(var s=0;s<t.quantizationAnnotation.length;++s)n.quantizationAnnotation[s]=p.onnx.TensorAnnotation.toObject(t.quantizationAnnotation[s],r)}if(t.sparseInitializer&&t.sparseInitializer.length){n.sparseInitializer=[];for(var s=0;s<t.sparseInitializer.length;++s)n.sparseInitializer[s]=p.onnx.SparseTensorProto.toObject(t.sparseInitializer[s],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.GraphProto"},e}(),i.TensorProto=function(){function e(o){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.dims=h.emptyArray,e.prototype.dataType=0,e.prototype.segment=null,e.prototype.floatData=h.emptyArray,e.prototype.int32Data=h.emptyArray,e.prototype.stringData=h.emptyArray,e.prototype.int64Data=h.emptyArray,e.prototype.name="",e.prototype.docString="",e.prototype.rawData=h.newBuffer([]),e.prototype.externalData=h.emptyArray,e.prototype.dataLocation=0,e.prototype.doubleData=h.emptyArray,e.prototype.uint64Data=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.dims!=null&&t.dims.length){r.uint32(10).fork();for(var n=0;n<t.dims.length;++n)r.int64(t.dims[n]);r.ldelim()}if(t.dataType!=null&&Object.hasOwnProperty.call(t,"dataType")&&r.uint32(16).int32(t.dataType),t.segment!=null&&Object.hasOwnProperty.call(t,"segment")&&p.onnx.TensorProto.Segment.encode(t.segment,r.uint32(26).fork()).ldelim(),t.floatData!=null&&t.floatData.length){r.uint32(34).fork();for(var n=0;n<t.floatData.length;++n)r.float(t.floatData[n]);r.ldelim()}if(t.int32Data!=null&&t.int32Data.length){r.uint32(42).fork();for(var n=0;n<t.int32Data.length;++n)r.int32(t.int32Data[n]);r.ldelim()}if(t.stringData!=null&&t.stringData.length)for(var n=0;n<t.stringData.length;++n)r.uint32(50).bytes(t.stringData[n]);if(t.int64Data!=null&&t.int64Data.length){r.uint32(58).fork();for(var n=0;n<t.int64Data.length;++n)r.int64(t.int64Data[n]);r.ldelim()}if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&r.uint32(66).string(t.name),t.rawData!=null&&Object.hasOwnProperty.call(t,"rawData")&&r.uint32(74).bytes(t.rawData),t.doubleData!=null&&t.doubleData.length){r.uint32(82).fork();for(var n=0;n<t.doubleData.length;++n)r.double(t.doubleData[n]);r.ldelim()}if(t.uint64Data!=null&&t.uint64Data.length){r.uint32(90).fork();for(var n=0;n<t.uint64Data.length;++n)r.uint64(t.uint64Data[n]);r.ldelim()}if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(98).string(t.docString),t.externalData!=null&&t.externalData.length)for(var n=0;n<t.externalData.length;++n)p.onnx.StringStringEntryProto.encode(t.externalData[n],r.uint32(106).fork()).ldelim();return t.dataLocation!=null&&Object.hasOwnProperty.call(t,"dataLocation")&&r.uint32(112).int32(t.dataLocation),r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.TensorProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{if(s.dims&&s.dims.length||(s.dims=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.dims.push(t.int64());else s.dims.push(t.int64());break}case 2:{s.dataType=t.int32();break}case 3:{s.segment=p.onnx.TensorProto.Segment.decode(t,t.uint32());break}case 4:{if(s.floatData&&s.floatData.length||(s.floatData=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.floatData.push(t.float());else s.floatData.push(t.float());break}case 5:{if(s.int32Data&&s.int32Data.length||(s.int32Data=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.int32Data.push(t.int32());else s.int32Data.push(t.int32());break}case 6:{s.stringData&&s.stringData.length||(s.stringData=[]),s.stringData.push(t.bytes());break}case 7:{if(s.int64Data&&s.int64Data.length||(s.int64Data=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.int64Data.push(t.int64());else s.int64Data.push(t.int64());break}case 8:{s.name=t.string();break}case 12:{s.docString=t.string();break}case 9:{s.rawData=t.bytes();break}case 13:{s.externalData&&s.externalData.length||(s.externalData=[]),s.externalData.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break}case 14:{s.dataLocation=t.int32();break}case 10:{if(s.doubleData&&s.doubleData.length||(s.doubleData=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.doubleData.push(t.double());else s.doubleData.push(t.double());break}case 11:{if(s.uint64Data&&s.uint64Data.length||(s.uint64Data=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.uint64Data.push(t.uint64());else s.uint64Data.push(t.uint64());break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dims!=null&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var r=0;r<t.dims.length;++r)if(!h.isInteger(t.dims[r])&&!(t.dims[r]&&h.isInteger(t.dims[r].low)&&h.isInteger(t.dims[r].high)))return"dims: integer|Long[] expected"}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&!h.isInteger(t.dataType))return"dataType: integer expected";if(t.segment!=null&&t.hasOwnProperty("segment")){var n=p.onnx.TensorProto.Segment.verify(t.segment);if(n)return"segment."+n}if(t.floatData!=null&&t.hasOwnProperty("floatData")){if(!Array.isArray(t.floatData))return"floatData: array expected";for(var r=0;r<t.floatData.length;++r)if(typeof t.floatData[r]!="number")return"floatData: number[] expected"}if(t.int32Data!=null&&t.hasOwnProperty("int32Data")){if(!Array.isArray(t.int32Data))return"int32Data: array expected";for(var r=0;r<t.int32Data.length;++r)if(!h.isInteger(t.int32Data[r]))return"int32Data: integer[] expected"}if(t.stringData!=null&&t.hasOwnProperty("stringData")){if(!Array.isArray(t.stringData))return"stringData: array expected";for(var r=0;r<t.stringData.length;++r)if(!(t.stringData[r]&&typeof t.stringData[r].length=="number"||h.isString(t.stringData[r])))return"stringData: buffer[] expected"}if(t.int64Data!=null&&t.hasOwnProperty("int64Data")){if(!Array.isArray(t.int64Data))return"int64Data: array expected";for(var r=0;r<t.int64Data.length;++r)if(!h.isInteger(t.int64Data[r])&&!(t.int64Data[r]&&h.isInteger(t.int64Data[r].low)&&h.isInteger(t.int64Data[r].high)))return"int64Data: integer|Long[] expected"}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.rawData!=null&&t.hasOwnProperty("rawData")&&!(t.rawData&&typeof t.rawData.length=="number"||h.isString(t.rawData)))return"rawData: buffer expected";if(t.externalData!=null&&t.hasOwnProperty("externalData")){if(!Array.isArray(t.externalData))return"externalData: array expected";for(var r=0;r<t.externalData.length;++r){var n=p.onnx.StringStringEntryProto.verify(t.externalData[r]);if(n)return"externalData."+n}}if(t.dataLocation!=null&&t.hasOwnProperty("dataLocation"))switch(t.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:break}if(t.doubleData!=null&&t.hasOwnProperty("doubleData")){if(!Array.isArray(t.doubleData))return"doubleData: array expected";for(var r=0;r<t.doubleData.length;++r)if(typeof t.doubleData[r]!="number")return"doubleData: number[] expected"}if(t.uint64Data!=null&&t.hasOwnProperty("uint64Data")){if(!Array.isArray(t.uint64Data))return"uint64Data: array expected";for(var r=0;r<t.uint64Data.length;++r)if(!h.isInteger(t.uint64Data[r])&&!(t.uint64Data[r]&&h.isInteger(t.uint64Data[r].low)&&h.isInteger(t.uint64Data[r].high)))return"uint64Data: integer|Long[] expected"}return null},e.fromObject=function(t){if(t instanceof p.onnx.TensorProto)return t;var r=new p.onnx.TensorProto;if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.TensorProto.dims: array expected");r.dims=[];for(var n=0;n<t.dims.length;++n)h.Long?(r.dims[n]=h.Long.fromValue(t.dims[n])).unsigned=!1:typeof t.dims[n]=="string"?r.dims[n]=parseInt(t.dims[n],10):typeof t.dims[n]=="number"?r.dims[n]=t.dims[n]:typeof t.dims[n]=="object"&&(r.dims[n]=new h.LongBits(t.dims[n].low>>>0,t.dims[n].high>>>0).toNumber())}if(t.dataType!=null&&(r.dataType=t.dataType|0),t.segment!=null){if(typeof t.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");r.segment=p.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");r.floatData=[];for(var n=0;n<t.floatData.length;++n)r.floatData[n]=Number(t.floatData[n])}if(t.int32Data){if(!Array.isArray(t.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");r.int32Data=[];for(var n=0;n<t.int32Data.length;++n)r.int32Data[n]=t.int32Data[n]|0}if(t.stringData){if(!Array.isArray(t.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");r.stringData=[];for(var n=0;n<t.stringData.length;++n)typeof t.stringData[n]=="string"?h.base64.decode(t.stringData[n],r.stringData[n]=h.newBuffer(h.base64.length(t.stringData[n])),0):t.stringData[n].length>=0&&(r.stringData[n]=t.stringData[n])}if(t.int64Data){if(!Array.isArray(t.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");r.int64Data=[];for(var n=0;n<t.int64Data.length;++n)h.Long?(r.int64Data[n]=h.Long.fromValue(t.int64Data[n])).unsigned=!1:typeof t.int64Data[n]=="string"?r.int64Data[n]=parseInt(t.int64Data[n],10):typeof t.int64Data[n]=="number"?r.int64Data[n]=t.int64Data[n]:typeof t.int64Data[n]=="object"&&(r.int64Data[n]=new h.LongBits(t.int64Data[n].low>>>0,t.int64Data[n].high>>>0).toNumber())}if(t.name!=null&&(r.name=String(t.name)),t.docString!=null&&(r.docString=String(t.docString)),t.rawData!=null&&(typeof t.rawData=="string"?h.base64.decode(t.rawData,r.rawData=h.newBuffer(h.base64.length(t.rawData)),0):t.rawData.length>=0&&(r.rawData=t.rawData)),t.externalData){if(!Array.isArray(t.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");r.externalData=[];for(var n=0;n<t.externalData.length;++n){if(typeof t.externalData[n]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");r.externalData[n]=p.onnx.StringStringEntryProto.fromObject(t.externalData[n])}}switch(t.dataLocation){default:if(typeof t.dataLocation=="number"){r.dataLocation=t.dataLocation;break}break;case"DEFAULT":case 0:r.dataLocation=0;break;case"EXTERNAL":case 1:r.dataLocation=1;break}if(t.doubleData){if(!Array.isArray(t.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");r.doubleData=[];for(var n=0;n<t.doubleData.length;++n)r.doubleData[n]=Number(t.doubleData[n])}if(t.uint64Data){if(!Array.isArray(t.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");r.uint64Data=[];for(var n=0;n<t.uint64Data.length;++n)h.Long?(r.uint64Data[n]=h.Long.fromValue(t.uint64Data[n])).unsigned=!0:typeof t.uint64Data[n]=="string"?r.uint64Data[n]=parseInt(t.uint64Data[n],10):typeof t.uint64Data[n]=="number"?r.uint64Data[n]=t.uint64Data[n]:typeof t.uint64Data[n]=="object"&&(r.uint64Data[n]=new h.LongBits(t.uint64Data[n].low>>>0,t.uint64Data[n].high>>>0).toNumber(!0))}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.dims=[],n.floatData=[],n.int32Data=[],n.stringData=[],n.int64Data=[],n.doubleData=[],n.uint64Data=[],n.externalData=[]),r.defaults&&(n.dataType=0,n.segment=null,n.name="",r.bytes===String?n.rawData="":(n.rawData=[],r.bytes!==Array&&(n.rawData=h.newBuffer(n.rawData))),n.docString="",n.dataLocation=r.enums===String?"DEFAULT":0),t.dims&&t.dims.length){n.dims=[];for(var s=0;s<t.dims.length;++s)typeof t.dims[s]=="number"?n.dims[s]=r.longs===String?String(t.dims[s]):t.dims[s]:n.dims[s]=r.longs===String?h.Long.prototype.toString.call(t.dims[s]):r.longs===Number?new h.LongBits(t.dims[s].low>>>0,t.dims[s].high>>>0).toNumber():t.dims[s]}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&(n.dataType=t.dataType),t.segment!=null&&t.hasOwnProperty("segment")&&(n.segment=p.onnx.TensorProto.Segment.toObject(t.segment,r)),t.floatData&&t.floatData.length){n.floatData=[];for(var s=0;s<t.floatData.length;++s)n.floatData[s]=r.json&&!isFinite(t.floatData[s])?String(t.floatData[s]):t.floatData[s]}if(t.int32Data&&t.int32Data.length){n.int32Data=[];for(var s=0;s<t.int32Data.length;++s)n.int32Data[s]=t.int32Data[s]}if(t.stringData&&t.stringData.length){n.stringData=[];for(var s=0;s<t.stringData.length;++s)n.stringData[s]=r.bytes===String?h.base64.encode(t.stringData[s],0,t.stringData[s].length):r.bytes===Array?Array.prototype.slice.call(t.stringData[s]):t.stringData[s]}if(t.int64Data&&t.int64Data.length){n.int64Data=[];for(var s=0;s<t.int64Data.length;++s)typeof t.int64Data[s]=="number"?n.int64Data[s]=r.longs===String?String(t.int64Data[s]):t.int64Data[s]:n.int64Data[s]=r.longs===String?h.Long.prototype.toString.call(t.int64Data[s]):r.longs===Number?new h.LongBits(t.int64Data[s].low>>>0,t.int64Data[s].high>>>0).toNumber():t.int64Data[s]}if(t.name!=null&&t.hasOwnProperty("name")&&(n.name=t.name),t.rawData!=null&&t.hasOwnProperty("rawData")&&(n.rawData=r.bytes===String?h.base64.encode(t.rawData,0,t.rawData.length):r.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length){n.doubleData=[];for(var s=0;s<t.doubleData.length;++s)n.doubleData[s]=r.json&&!isFinite(t.doubleData[s])?String(t.doubleData[s]):t.doubleData[s]}if(t.uint64Data&&t.uint64Data.length){n.uint64Data=[];for(var s=0;s<t.uint64Data.length;++s)typeof t.uint64Data[s]=="number"?n.uint64Data[s]=r.longs===String?String(t.uint64Data[s]):t.uint64Data[s]:n.uint64Data[s]=r.longs===String?h.Long.prototype.toString.call(t.uint64Data[s]):r.longs===Number?new h.LongBits(t.uint64Data[s].low>>>0,t.uint64Data[s].high>>>0).toNumber(!0):t.uint64Data[s]}if(t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.externalData&&t.externalData.length){n.externalData=[];for(var s=0;s<t.externalData.length;++s)n.externalData[s]=p.onnx.StringStringEntryProto.toObject(t.externalData[s],r)}return t.dataLocation!=null&&t.hasOwnProperty("dataLocation")&&(n.dataLocation=r.enums===String?p.onnx.TensorProto.DataLocation[t.dataLocation]===void 0?t.dataLocation:p.onnx.TensorProto.DataLocation[t.dataLocation]:t.dataLocation),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TensorProto"},e.DataType=function(){var o={},t=Object.create(o);return t[o[0]="UNDEFINED"]=0,t[o[1]="FLOAT"]=1,t[o[2]="UINT8"]=2,t[o[3]="INT8"]=3,t[o[4]="UINT16"]=4,t[o[5]="INT16"]=5,t[o[6]="INT32"]=6,t[o[7]="INT64"]=7,t[o[8]="STRING"]=8,t[o[9]="BOOL"]=9,t[o[10]="FLOAT16"]=10,t[o[11]="DOUBLE"]=11,t[o[12]="UINT32"]=12,t[o[13]="UINT64"]=13,t[o[14]="COMPLEX64"]=14,t[o[15]="COMPLEX128"]=15,t[o[16]="BFLOAT16"]=16,t[o[17]="FLOAT8E4M3FN"]=17,t[o[18]="FLOAT8E4M3FNUZ"]=18,t[o[19]="FLOAT8E5M2"]=19,t[o[20]="FLOAT8E5M2FNUZ"]=20,t}(),e.Segment=function(){function o(t){if(t)for(var r=Object.keys(t),n=0;n<r.length;++n)t[r[n]]!=null&&(this[r[n]]=t[r[n]])}return o.prototype.begin=h.Long?h.Long.fromBits(0,0,!1):0,o.prototype.end=h.Long?h.Long.fromBits(0,0,!1):0,o.create=function(r){return new o(r)},o.encode=function(r,n){return n||(n=J.create()),r.begin!=null&&Object.hasOwnProperty.call(r,"begin")&&n.uint32(8).int64(r.begin),r.end!=null&&Object.hasOwnProperty.call(r,"end")&&n.uint32(16).int64(r.end),n},o.encodeDelimited=function(r,n){return this.encode(r,n).ldelim()},o.decode=function(r,n){r instanceof S||(r=S.create(r));for(var s=n===void 0?r.len:r.pos+n,a=new p.onnx.TensorProto.Segment;r.pos<s;){var u=r.uint32();switch(u>>>3){case 1:{a.begin=r.int64();break}case 2:{a.end=r.int64();break}default:r.skipType(u&7);break}}return a},o.decodeDelimited=function(r){return r instanceof S||(r=new S(r)),this.decode(r,r.uint32())},o.verify=function(r){return typeof r!="object"||r===null?"object expected":r.begin!=null&&r.hasOwnProperty("begin")&&!h.isInteger(r.begin)&&!(r.begin&&h.isInteger(r.begin.low)&&h.isInteger(r.begin.high))?"begin: integer|Long expected":r.end!=null&&r.hasOwnProperty("end")&&!h.isInteger(r.end)&&!(r.end&&h.isInteger(r.end.low)&&h.isInteger(r.end.high))?"end: integer|Long expected":null},o.fromObject=function(r){if(r instanceof p.onnx.TensorProto.Segment)return r;var n=new p.onnx.TensorProto.Segment;return r.begin!=null&&(h.Long?(n.begin=h.Long.fromValue(r.begin)).unsigned=!1:typeof r.begin=="string"?n.begin=parseInt(r.begin,10):typeof r.begin=="number"?n.begin=r.begin:typeof r.begin=="object"&&(n.begin=new h.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber())),r.end!=null&&(h.Long?(n.end=h.Long.fromValue(r.end)).unsigned=!1:typeof r.end=="string"?n.end=parseInt(r.end,10):typeof r.end=="number"?n.end=r.end:typeof r.end=="object"&&(n.end=new h.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber())),n},o.toObject=function(r,n){n||(n={});var s={};if(n.defaults){if(h.Long){var a=new h.Long(0,0,!1);s.begin=n.longs===String?a.toString():n.longs===Number?a.toNumber():a}else s.begin=n.longs===String?"0":0;if(h.Long){var a=new h.Long(0,0,!1);s.end=n.longs===String?a.toString():n.longs===Number?a.toNumber():a}else s.end=n.longs===String?"0":0}return r.begin!=null&&r.hasOwnProperty("begin")&&(typeof r.begin=="number"?s.begin=n.longs===String?String(r.begin):r.begin:s.begin=n.longs===String?h.Long.prototype.toString.call(r.begin):n.longs===Number?new h.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber():r.begin),r.end!=null&&r.hasOwnProperty("end")&&(typeof r.end=="number"?s.end=n.longs===String?String(r.end):r.end:s.end=n.longs===String?h.Long.prototype.toString.call(r.end):n.longs===Number?new h.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber():r.end),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},o.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorProto.Segment"},o}(),e.DataLocation=function(){var o={},t=Object.create(o);return t[o[0]="DEFAULT"]=0,t[o[1]="EXTERNAL"]=1,t}(),e}(),i.SparseTensorProto=function(){function e(o){if(this.dims=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.values=null,e.prototype.indices=null,e.prototype.dims=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.values!=null&&Object.hasOwnProperty.call(t,"values")&&p.onnx.TensorProto.encode(t.values,r.uint32(10).fork()).ldelim(),t.indices!=null&&Object.hasOwnProperty.call(t,"indices")&&p.onnx.TensorProto.encode(t.indices,r.uint32(18).fork()).ldelim(),t.dims!=null&&t.dims.length){r.uint32(26).fork();for(var n=0;n<t.dims.length;++n)r.int64(t.dims[n]);r.ldelim()}return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.SparseTensorProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.values=p.onnx.TensorProto.decode(t,t.uint32());break}case 2:{s.indices=p.onnx.TensorProto.decode(t,t.uint32());break}case 3:{if(s.dims&&s.dims.length||(s.dims=[]),(a&7)===2)for(var u=t.uint32()+t.pos;t.pos<u;)s.dims.push(t.int64());else s.dims.push(t.int64());break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.values!=null&&t.hasOwnProperty("values")){var r=p.onnx.TensorProto.verify(t.values);if(r)return"values."+r}if(t.indices!=null&&t.hasOwnProperty("indices")){var r=p.onnx.TensorProto.verify(t.indices);if(r)return"indices."+r}if(t.dims!=null&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var n=0;n<t.dims.length;++n)if(!h.isInteger(t.dims[n])&&!(t.dims[n]&&h.isInteger(t.dims[n].low)&&h.isInteger(t.dims[n].high)))return"dims: integer|Long[] expected"}return null},e.fromObject=function(t){if(t instanceof p.onnx.SparseTensorProto)return t;var r=new p.onnx.SparseTensorProto;if(t.values!=null){if(typeof t.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");r.values=p.onnx.TensorProto.fromObject(t.values)}if(t.indices!=null){if(typeof t.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");r.indices=p.onnx.TensorProto.fromObject(t.indices)}if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");r.dims=[];for(var n=0;n<t.dims.length;++n)h.Long?(r.dims[n]=h.Long.fromValue(t.dims[n])).unsigned=!1:typeof t.dims[n]=="string"?r.dims[n]=parseInt(t.dims[n],10):typeof t.dims[n]=="number"?r.dims[n]=t.dims[n]:typeof t.dims[n]=="object"&&(r.dims[n]=new h.LongBits(t.dims[n].low>>>0,t.dims[n].high>>>0).toNumber())}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.dims=[]),r.defaults&&(n.values=null,n.indices=null),t.values!=null&&t.hasOwnProperty("values")&&(n.values=p.onnx.TensorProto.toObject(t.values,r)),t.indices!=null&&t.hasOwnProperty("indices")&&(n.indices=p.onnx.TensorProto.toObject(t.indices,r)),t.dims&&t.dims.length){n.dims=[];for(var s=0;s<t.dims.length;++s)typeof t.dims[s]=="number"?n.dims[s]=r.longs===String?String(t.dims[s]):t.dims[s]:n.dims[s]=r.longs===String?h.Long.prototype.toString.call(t.dims[s]):r.longs===Number?new h.LongBits(t.dims[s].low>>>0,t.dims[s].high>>>0).toNumber():t.dims[s]}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.SparseTensorProto"},e}(),i.TensorShapeProto=function(){function e(o){if(this.dim=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.dim=h.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.dim!=null&&t.dim.length)for(var n=0;n<t.dim.length;++n)p.onnx.TensorShapeProto.Dimension.encode(t.dim[n],r.uint32(10).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.TensorShapeProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.dim&&s.dim.length||(s.dim=[]),s.dim.push(p.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()));break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dim!=null&&t.hasOwnProperty("dim")){if(!Array.isArray(t.dim))return"dim: array expected";for(var r=0;r<t.dim.length;++r){var n=p.onnx.TensorShapeProto.Dimension.verify(t.dim[r]);if(n)return"dim."+n}}return null},e.fromObject=function(t){if(t instanceof p.onnx.TensorShapeProto)return t;var r=new p.onnx.TensorShapeProto;if(t.dim){if(!Array.isArray(t.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");r.dim=[];for(var n=0;n<t.dim.length;++n){if(typeof t.dim[n]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");r.dim[n]=p.onnx.TensorShapeProto.Dimension.fromObject(t.dim[n])}}return r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.dim=[]),t.dim&&t.dim.length){n.dim=[];for(var s=0;s<t.dim.length;++s)n.dim[s]=p.onnx.TensorShapeProto.Dimension.toObject(t.dim[s],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TensorShapeProto"},e.Dimension=function(){function o(r){if(r)for(var n=Object.keys(r),s=0;s<n.length;++s)r[n[s]]!=null&&(this[n[s]]=r[n[s]])}o.prototype.dimValue=null,o.prototype.dimParam=null,o.prototype.denotation="";var t;return Object.defineProperty(o.prototype,"value",{get:h.oneOfGetter(t=["dimValue","dimParam"]),set:h.oneOfSetter(t)}),o.create=function(n){return new o(n)},o.encode=function(n,s){return s||(s=J.create()),n.dimValue!=null&&Object.hasOwnProperty.call(n,"dimValue")&&s.uint32(8).int64(n.dimValue),n.dimParam!=null&&Object.hasOwnProperty.call(n,"dimParam")&&s.uint32(18).string(n.dimParam),n.denotation!=null&&Object.hasOwnProperty.call(n,"denotation")&&s.uint32(26).string(n.denotation),s},o.encodeDelimited=function(n,s){return this.encode(n,s).ldelim()},o.decode=function(n,s){n instanceof S||(n=S.create(n));for(var a=s===void 0?n.len:n.pos+s,u=new p.onnx.TensorShapeProto.Dimension;n.pos<a;){var l=n.uint32();switch(l>>>3){case 1:{u.dimValue=n.int64();break}case 2:{u.dimParam=n.string();break}case 3:{u.denotation=n.string();break}default:n.skipType(l&7);break}}return u},o.decodeDelimited=function(n){return n instanceof S||(n=new S(n)),this.decode(n,n.uint32())},o.verify=function(n){if(typeof n!="object"||n===null)return"object expected";var s={};if(n.dimValue!=null&&n.hasOwnProperty("dimValue")&&(s.value=1,!h.isInteger(n.dimValue)&&!(n.dimValue&&h.isInteger(n.dimValue.low)&&h.isInteger(n.dimValue.high))))return"dimValue: integer|Long expected";if(n.dimParam!=null&&n.hasOwnProperty("dimParam")){if(s.value===1)return"value: multiple values";if(s.value=1,!h.isString(n.dimParam))return"dimParam: string expected"}return n.denotation!=null&&n.hasOwnProperty("denotation")&&!h.isString(n.denotation)?"denotation: string expected":null},o.fromObject=function(n){if(n instanceof p.onnx.TensorShapeProto.Dimension)return n;var s=new p.onnx.TensorShapeProto.Dimension;return n.dimValue!=null&&(h.Long?(s.dimValue=h.Long.fromValue(n.dimValue)).unsigned=!1:typeof n.dimValue=="string"?s.dimValue=parseInt(n.dimValue,10):typeof n.dimValue=="number"?s.dimValue=n.dimValue:typeof n.dimValue=="object"&&(s.dimValue=new h.LongBits(n.dimValue.low>>>0,n.dimValue.high>>>0).toNumber())),n.dimParam!=null&&(s.dimParam=String(n.dimParam)),n.denotation!=null&&(s.denotation=String(n.denotation)),s},o.toObject=function(n,s){s||(s={});var a={};return s.defaults&&(a.denotation=""),n.dimValue!=null&&n.hasOwnProperty("dimValue")&&(typeof n.dimValue=="number"?a.dimValue=s.longs===String?String(n.dimValue):n.dimValue:a.dimValue=s.longs===String?h.Long.prototype.toString.call(n.dimValue):s.longs===Number?new h.LongBits(n.dimValue.low>>>0,n.dimValue.high>>>0).toNumber():n.dimValue,s.oneofs&&(a.value="dimValue")),n.dimParam!=null&&n.hasOwnProperty("dimParam")&&(a.dimParam=n.dimParam,s.oneofs&&(a.value="dimParam")),n.denotation!=null&&n.hasOwnProperty("denotation")&&(a.denotation=n.denotation),a},o.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},o.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/onnx.TensorShapeProto.Dimension"},o}(),e}(),i.TypeProto=function(){function e(t){if(t)for(var r=Object.keys(t),n=0;n<r.length;++n)t[r[n]]!=null&&(this[r[n]]=t[r[n]])}e.prototype.tensorType=null,e.prototype.sequenceType=null,e.prototype.mapType=null,e.prototype.optionalType=null,e.prototype.sparseTensorType=null,e.prototype.denotation="";var o;return Object.defineProperty(e.prototype,"value",{get:h.oneOfGetter(o=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:h.oneOfSetter(o)}),e.create=function(r){return new e(r)},e.encode=function(r,n){return n||(n=J.create()),r.tensorType!=null&&Object.hasOwnProperty.call(r,"tensorType")&&p.onnx.TypeProto.Tensor.encode(r.tensorType,n.uint32(10).fork()).ldelim(),r.sequenceType!=null&&Object.hasOwnProperty.call(r,"sequenceType")&&p.onnx.TypeProto.Sequence.encode(r.sequenceType,n.uint32(34).fork()).ldelim(),r.mapType!=null&&Object.hasOwnProperty.call(r,"mapType")&&p.onnx.TypeProto.Map.encode(r.mapType,n.uint32(42).fork()).ldelim(),r.denotation!=null&&Object.hasOwnProperty.call(r,"denotation")&&n.uint32(50).string(r.denotation),r.sparseTensorType!=null&&Object.hasOwnProperty.call(r,"sparseTensorType")&&p.onnx.TypeProto.SparseTensor.encode(r.sparseTensorType,n.uint32(66).fork()).ldelim(),r.optionalType!=null&&Object.hasOwnProperty.call(r,"optionalType")&&p.onnx.TypeProto.Optional.encode(r.optionalType,n.uint32(74).fork()).ldelim(),n},e.encodeDelimited=function(r,n){return this.encode(r,n).ldelim()},e.decode=function(r,n){r instanceof S||(r=S.create(r));for(var s=n===void 0?r.len:r.pos+n,a=new p.onnx.TypeProto;r.pos<s;){var u=r.uint32();switch(u>>>3){case 1:{a.tensorType=p.onnx.TypeProto.Tensor.decode(r,r.uint32());break}case 4:{a.sequenceType=p.onnx.TypeProto.Sequence.decode(r,r.uint32());break}case 5:{a.mapType=p.onnx.TypeProto.Map.decode(r,r.uint32());break}case 9:{a.optionalType=p.onnx.TypeProto.Optional.decode(r,r.uint32());break}case 8:{a.sparseTensorType=p.onnx.TypeProto.SparseTensor.decode(r,r.uint32());break}case 6:{a.denotation=r.string();break}default:r.skipType(u&7);break}}return a},e.decodeDelimited=function(r){return r instanceof S||(r=new S(r)),this.decode(r,r.uint32())},e.verify=function(r){if(typeof r!="object"||r===null)return"object expected";var n={};if(r.tensorType!=null&&r.hasOwnProperty("tensorType")){n.value=1;{var s=p.onnx.TypeProto.Tensor.verify(r.tensorType);if(s)return"tensorType."+s}}if(r.sequenceType!=null&&r.hasOwnProperty("sequenceType")){if(n.value===1)return"value: multiple values";n.value=1;{var s=p.onnx.TypeProto.Sequence.verify(r.sequenceType);if(s)return"sequenceType."+s}}if(r.mapType!=null&&r.hasOwnProperty("mapType")){if(n.value===1)return"value: multiple values";n.value=1;{var s=p.onnx.TypeProto.Map.verify(r.mapType);if(s)return"mapType."+s}}if(r.optionalType!=null&&r.hasOwnProperty("optionalType")){if(n.value===1)return"value: multiple values";n.value=1;{var s=p.onnx.TypeProto.Optional.verify(r.optionalType);if(s)return"optionalType."+s}}if(r.sparseTensorType!=null&&r.hasOwnProperty("sparseTensorType")){if(n.value===1)return"value: multiple values";n.value=1;{var s=p.onnx.TypeProto.SparseTensor.verify(r.sparseTensorType);if(s)return"sparseTensorType."+s}}return r.denotation!=null&&r.hasOwnProperty("denotation")&&!h.isString(r.denotation)?"denotation: string expected":null},e.fromObject=function(r){if(r instanceof p.onnx.TypeProto)return r;var n=new p.onnx.TypeProto;if(r.tensorType!=null){if(typeof r.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");n.tensorType=p.onnx.TypeProto.Tensor.fromObject(r.tensorType)}if(r.sequenceType!=null){if(typeof r.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");n.sequenceType=p.onnx.TypeProto.Sequence.fromObject(r.sequenceType)}if(r.mapType!=null){if(typeof r.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");n.mapType=p.onnx.TypeProto.Map.fromObject(r.mapType)}if(r.optionalType!=null){if(typeof r.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");n.optionalType=p.onnx.TypeProto.Optional.fromObject(r.optionalType)}if(r.sparseTensorType!=null){if(typeof r.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");n.sparseTensorType=p.onnx.TypeProto.SparseTensor.fromObject(r.sparseTensorType)}return r.denotation!=null&&(n.denotation=String(r.denotation)),n},e.toObject=function(r,n){n||(n={});var s={};return n.defaults&&(s.denotation=""),r.tensorType!=null&&r.hasOwnProperty("tensorType")&&(s.tensorType=p.onnx.TypeProto.Tensor.toObject(r.tensorType,n),n.oneofs&&(s.value="tensorType")),r.sequenceType!=null&&r.hasOwnProperty("sequenceType")&&(s.sequenceType=p.onnx.TypeProto.Sequence.toObject(r.sequenceType,n),n.oneofs&&(s.value="sequenceType")),r.mapType!=null&&r.hasOwnProperty("mapType")&&(s.mapType=p.onnx.TypeProto.Map.toObject(r.mapType,n),n.oneofs&&(s.value="mapType")),r.denotation!=null&&r.hasOwnProperty("denotation")&&(s.denotation=r.denotation),r.sparseTensorType!=null&&r.hasOwnProperty("sparseTensorType")&&(s.sparseTensorType=p.onnx.TypeProto.SparseTensor.toObject(r.sparseTensorType,n),n.oneofs&&(s.value="sparseTensorType")),r.optionalType!=null&&r.hasOwnProperty("optionalType")&&(s.optionalType=p.onnx.TypeProto.Optional.toObject(r.optionalType,n),n.oneofs&&(s.value="optionalType")),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TypeProto"},e.Tensor=function(){function t(r){if(r)for(var n=Object.keys(r),s=0;s<n.length;++s)r[n[s]]!=null&&(this[n[s]]=r[n[s]])}return t.prototype.elemType=0,t.prototype.shape=null,t.create=function(n){return new t(n)},t.encode=function(n,s){return s||(s=J.create()),n.elemType!=null&&Object.hasOwnProperty.call(n,"elemType")&&s.uint32(8).int32(n.elemType),n.shape!=null&&Object.hasOwnProperty.call(n,"shape")&&p.onnx.TensorShapeProto.encode(n.shape,s.uint32(18).fork()).ldelim(),s},t.encodeDelimited=function(n,s){return this.encode(n,s).ldelim()},t.decode=function(n,s){n instanceof S||(n=S.create(n));for(var a=s===void 0?n.len:n.pos+s,u=new p.onnx.TypeProto.Tensor;n.pos<a;){var l=n.uint32();switch(l>>>3){case 1:{u.elemType=n.int32();break}case 2:{u.shape=p.onnx.TensorShapeProto.decode(n,n.uint32());break}default:n.skipType(l&7);break}}return u},t.decodeDelimited=function(n){return n instanceof S||(n=new S(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.elemType!=null&&n.hasOwnProperty("elemType")&&!h.isInteger(n.elemType))return"elemType: integer expected";if(n.shape!=null&&n.hasOwnProperty("shape")){var s=p.onnx.TensorShapeProto.verify(n.shape);if(s)return"shape."+s}return null},t.fromObject=function(n){if(n instanceof p.onnx.TypeProto.Tensor)return n;var s=new p.onnx.TypeProto.Tensor;if(n.elemType!=null&&(s.elemType=n.elemType|0),n.shape!=null){if(typeof n.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");s.shape=p.onnx.TensorShapeProto.fromObject(n.shape)}return s},t.toObject=function(n,s){s||(s={});var a={};return s.defaults&&(a.elemType=0,a.shape=null),n.elemType!=null&&n.hasOwnProperty("elemType")&&(a.elemType=n.elemType),n.shape!=null&&n.hasOwnProperty("shape")&&(a.shape=p.onnx.TensorShapeProto.toObject(n.shape,s)),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},t.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/onnx.TypeProto.Tensor"},t}(),e.Sequence=function(){function t(r){if(r)for(var n=Object.keys(r),s=0;s<n.length;++s)r[n[s]]!=null&&(this[n[s]]=r[n[s]])}return t.prototype.elemType=null,t.create=function(n){return new t(n)},t.encode=function(n,s){return s||(s=J.create()),n.elemType!=null&&Object.hasOwnProperty.call(n,"elemType")&&p.onnx.TypeProto.encode(n.elemType,s.uint32(10).fork()).ldelim(),s},t.encodeDelimited=function(n,s){return this.encode(n,s).ldelim()},t.decode=function(n,s){n instanceof S||(n=S.create(n));for(var a=s===void 0?n.len:n.pos+s,u=new p.onnx.TypeProto.Sequence;n.pos<a;){var l=n.uint32();switch(l>>>3){case 1:{u.elemType=p.onnx.TypeProto.decode(n,n.uint32());break}default:n.skipType(l&7);break}}return u},t.decodeDelimited=function(n){return n instanceof S||(n=new S(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.elemType!=null&&n.hasOwnProperty("elemType")){var s=p.onnx.TypeProto.verify(n.elemType);if(s)return"elemType."+s}return null},t.fromObject=function(n){if(n instanceof p.onnx.TypeProto.Sequence)return n;var s=new p.onnx.TypeProto.Sequence;if(n.elemType!=null){if(typeof n.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");s.elemType=p.onnx.TypeProto.fromObject(n.elemType)}return s},t.toObject=function(n,s){s||(s={});var a={};return s.defaults&&(a.elemType=null),n.elemType!=null&&n.hasOwnProperty("elemType")&&(a.elemType=p.onnx.TypeProto.toObject(n.elemType,s)),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},t.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/onnx.TypeProto.Sequence"},t}(),e.Map=function(){function t(r){if(r)for(var n=Object.keys(r),s=0;s<n.length;++s)r[n[s]]!=null&&(this[n[s]]=r[n[s]])}return t.prototype.keyType=0,t.prototype.valueType=null,t.create=function(n){return new t(n)},t.encode=function(n,s){return s||(s=J.create()),n.keyType!=null&&Object.hasOwnProperty.call(n,"keyType")&&s.uint32(8).int32(n.keyType),n.valueType!=null&&Object.hasOwnProperty.call(n,"valueType")&&p.onnx.TypeProto.encode(n.valueType,s.uint32(18).fork()).ldelim(),s},t.encodeDelimited=function(n,s){return this.encode(n,s).ldelim()},t.decode=function(n,s){n instanceof S||(n=S.create(n));for(var a=s===void 0?n.len:n.pos+s,u=new p.onnx.TypeProto.Map;n.pos<a;){var l=n.uint32();switch(l>>>3){case 1:{u.keyType=n.int32();break}case 2:{u.valueType=p.onnx.TypeProto.decode(n,n.uint32());break}default:n.skipType(l&7);break}}return u},t.decodeDelimited=function(n){return n instanceof S||(n=new S(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.keyType!=null&&n.hasOwnProperty("keyType")&&!h.isInteger(n.keyType))return"keyType: integer expected";if(n.valueType!=null&&n.hasOwnProperty("valueType")){var s=p.onnx.TypeProto.verify(n.valueType);if(s)return"valueType."+s}return null},t.fromObject=function(n){if(n instanceof p.onnx.TypeProto.Map)return n;var s=new p.onnx.TypeProto.Map;if(n.keyType!=null&&(s.keyType=n.keyType|0),n.valueType!=null){if(typeof n.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");s.valueType=p.onnx.TypeProto.fromObject(n.valueType)}return s},t.toObject=function(n,s){s||(s={});var a={};return s.defaults&&(a.keyType=0,a.valueType=null),n.keyType!=null&&n.hasOwnProperty("keyType")&&(a.keyType=n.keyType),n.valueType!=null&&n.hasOwnProperty("valueType")&&(a.valueType=p.onnx.TypeProto.toObject(n.valueType,s)),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},t.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/onnx.TypeProto.Map"},t}(),e.Optional=function(){function t(r){if(r)for(var n=Object.keys(r),s=0;s<n.length;++s)r[n[s]]!=null&&(this[n[s]]=r[n[s]])}return t.prototype.elemType=null,t.create=function(n){return new t(n)},t.encode=function(n,s){return s||(s=J.create()),n.elemType!=null&&Object.hasOwnProperty.call(n,"elemType")&&p.onnx.TypeProto.encode(n.elemType,s.uint32(10).fork()).ldelim(),s},t.encodeDelimited=function(n,s){return this.encode(n,s).ldelim()},t.decode=function(n,s){n instanceof S||(n=S.create(n));for(var a=s===void 0?n.len:n.pos+s,u=new p.onnx.TypeProto.Optional;n.pos<a;){var l=n.uint32();switch(l>>>3){case 1:{u.elemType=p.onnx.TypeProto.decode(n,n.uint32());break}default:n.skipType(l&7);break}}return u},t.decodeDelimited=function(n){return n instanceof S||(n=new S(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.elemType!=null&&n.hasOwnProperty("elemType")){var s=p.onnx.TypeProto.verify(n.elemType);if(s)return"elemType."+s}return null},t.fromObject=function(n){if(n instanceof p.onnx.TypeProto.Optional)return n;var s=new p.onnx.TypeProto.Optional;if(n.elemType!=null){if(typeof n.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");s.elemType=p.onnx.TypeProto.fromObject(n.elemType)}return s},t.toObject=function(n,s){s||(s={});var a={};return s.defaults&&(a.elemType=null),n.elemType!=null&&n.hasOwnProperty("elemType")&&(a.elemType=p.onnx.TypeProto.toObject(n.elemType,s)),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},t.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/onnx.TypeProto.Optional"},t}(),e.SparseTensor=function(){function t(r){if(r)for(var n=Object.keys(r),s=0;s<n.length;++s)r[n[s]]!=null&&(this[n[s]]=r[n[s]])}return t.prototype.elemType=0,t.prototype.shape=null,t.create=function(n){return new t(n)},t.encode=function(n,s){return s||(s=J.create()),n.elemType!=null&&Object.hasOwnProperty.call(n,"elemType")&&s.uint32(8).int32(n.elemType),n.shape!=null&&Object.hasOwnProperty.call(n,"shape")&&p.onnx.TensorShapeProto.encode(n.shape,s.uint32(18).fork()).ldelim(),s},t.encodeDelimited=function(n,s){return this.encode(n,s).ldelim()},t.decode=function(n,s){n instanceof S||(n=S.create(n));for(var a=s===void 0?n.len:n.pos+s,u=new p.onnx.TypeProto.SparseTensor;n.pos<a;){var l=n.uint32();switch(l>>>3){case 1:{u.elemType=n.int32();break}case 2:{u.shape=p.onnx.TensorShapeProto.decode(n,n.uint32());break}default:n.skipType(l&7);break}}return u},t.decodeDelimited=function(n){return n instanceof S||(n=new S(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.elemType!=null&&n.hasOwnProperty("elemType")&&!h.isInteger(n.elemType))return"elemType: integer expected";if(n.shape!=null&&n.hasOwnProperty("shape")){var s=p.onnx.TensorShapeProto.verify(n.shape);if(s)return"shape."+s}return null},t.fromObject=function(n){if(n instanceof p.onnx.TypeProto.SparseTensor)return n;var s=new p.onnx.TypeProto.SparseTensor;if(n.elemType!=null&&(s.elemType=n.elemType|0),n.shape!=null){if(typeof n.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");s.shape=p.onnx.TensorShapeProto.fromObject(n.shape)}return s},t.toObject=function(n,s){s||(s={});var a={};return s.defaults&&(a.elemType=0,a.shape=null),n.elemType!=null&&n.hasOwnProperty("elemType")&&(a.elemType=n.elemType),n.shape!=null&&n.hasOwnProperty("shape")&&(a.shape=p.onnx.TensorShapeProto.toObject(n.shape,s)),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},t.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/onnx.TypeProto.SparseTensor"},t}(),e}(),i.OperatorSetIdProto=function(){function e(o){if(o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.domain="",e.prototype.version=h.Long?h.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(t,r){return r||(r=J.create()),t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&r.uint32(10).string(t.domain),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&r.uint32(16).int64(t.version),r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.OperatorSetIdProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.domain=t.string();break}case 2:{s.version=t.int64();break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain)?"domain: string expected":t.version!=null&&t.hasOwnProperty("version")&&!h.isInteger(t.version)&&!(t.version&&h.isInteger(t.version.low)&&h.isInteger(t.version.high))?"version: integer|Long expected":null},e.fromObject=function(t){if(t instanceof p.onnx.OperatorSetIdProto)return t;var r=new p.onnx.OperatorSetIdProto;return t.domain!=null&&(r.domain=String(t.domain)),t.version!=null&&(h.Long?(r.version=h.Long.fromValue(t.version)).unsigned=!1:typeof t.version=="string"?r.version=parseInt(t.version,10):typeof t.version=="number"?r.version=t.version:typeof t.version=="object"&&(r.version=new h.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),r},e.toObject=function(t,r){r||(r={});var n={};if(r.defaults)if(n.domain="",h.Long){var s=new h.Long(0,0,!1);n.version=r.longs===String?s.toString():r.longs===Number?s.toNumber():s}else n.version=r.longs===String?"0":0;return t.domain!=null&&t.hasOwnProperty("domain")&&(n.domain=t.domain),t.version!=null&&t.hasOwnProperty("version")&&(typeof t.version=="number"?n.version=r.longs===String?String(t.version):t.version:n.version=r.longs===String?h.Long.prototype.toString.call(t.version):r.longs===Number?new h.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.OperatorSetIdProto"},e}(),i.OperatorStatus=function(){var e={},o=Object.create(e);return o[e[0]="EXPERIMENTAL"]=0,o[e[1]="STABLE"]=1,o}(),i.FunctionProto=function(){function e(o){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],o)for(var t=Object.keys(o),r=0;r<t.length;++r)o[t[r]]!=null&&(this[t[r]]=o[t[r]])}return e.prototype.name="",e.prototype.input=h.emptyArray,e.prototype.output=h.emptyArray,e.prototype.attribute=h.emptyArray,e.prototype.attributeProto=h.emptyArray,e.prototype.node=h.emptyArray,e.prototype.docString="",e.prototype.opsetImport=h.emptyArray,e.prototype.domain="",e.create=function(t){return new e(t)},e.encode=function(t,r){if(r||(r=J.create()),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&r.uint32(10).string(t.name),t.input!=null&&t.input.length)for(var n=0;n<t.input.length;++n)r.uint32(34).string(t.input[n]);if(t.output!=null&&t.output.length)for(var n=0;n<t.output.length;++n)r.uint32(42).string(t.output[n]);if(t.attribute!=null&&t.attribute.length)for(var n=0;n<t.attribute.length;++n)r.uint32(50).string(t.attribute[n]);if(t.node!=null&&t.node.length)for(var n=0;n<t.node.length;++n)p.onnx.NodeProto.encode(t.node[n],r.uint32(58).fork()).ldelim();if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&r.uint32(66).string(t.docString),t.opsetImport!=null&&t.opsetImport.length)for(var n=0;n<t.opsetImport.length;++n)p.onnx.OperatorSetIdProto.encode(t.opsetImport[n],r.uint32(74).fork()).ldelim();if(t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&r.uint32(82).string(t.domain),t.attributeProto!=null&&t.attributeProto.length)for(var n=0;n<t.attributeProto.length;++n)p.onnx.AttributeProto.encode(t.attributeProto[n],r.uint32(90).fork()).ldelim();return r},e.encodeDelimited=function(t,r){return this.encode(t,r).ldelim()},e.decode=function(t,r){t instanceof S||(t=S.create(t));for(var n=r===void 0?t.len:t.pos+r,s=new p.onnx.FunctionProto;t.pos<n;){var a=t.uint32();switch(a>>>3){case 1:{s.name=t.string();break}case 4:{s.input&&s.input.length||(s.input=[]),s.input.push(t.string());break}case 5:{s.output&&s.output.length||(s.output=[]),s.output.push(t.string());break}case 6:{s.attribute&&s.attribute.length||(s.attribute=[]),s.attribute.push(t.string());break}case 11:{s.attributeProto&&s.attributeProto.length||(s.attributeProto=[]),s.attributeProto.push(p.onnx.AttributeProto.decode(t,t.uint32()));break}case 7:{s.node&&s.node.length||(s.node=[]),s.node.push(p.onnx.NodeProto.decode(t,t.uint32()));break}case 8:{s.docString=t.string();break}case 9:{s.opsetImport&&s.opsetImport.length||(s.opsetImport=[]),s.opsetImport.push(p.onnx.OperatorSetIdProto.decode(t,t.uint32()));break}case 10:{s.domain=t.string();break}default:t.skipType(a&7);break}}return s},e.decodeDelimited=function(t){return t instanceof S||(t=new S(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var r=0;r<t.input.length;++r)if(!h.isString(t.input[r]))return"input: string[] expected"}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var r=0;r<t.output.length;++r)if(!h.isString(t.output[r]))return"output: string[] expected"}if(t.attribute!=null&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(var r=0;r<t.attribute.length;++r)if(!h.isString(t.attribute[r]))return"attribute: string[] expected"}if(t.attributeProto!=null&&t.hasOwnProperty("attributeProto")){if(!Array.isArray(t.attributeProto))return"attributeProto: array expected";for(var r=0;r<t.attributeProto.length;++r){var n=p.onnx.AttributeProto.verify(t.attributeProto[r]);if(n)return"attributeProto."+n}}if(t.node!=null&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var r=0;r<t.node.length;++r){var n=p.onnx.NodeProto.verify(t.node[r]);if(n)return"node."+n}}if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.opsetImport!=null&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var r=0;r<t.opsetImport.length;++r){var n=p.onnx.OperatorSetIdProto.verify(t.opsetImport[r]);if(n)return"opsetImport."+n}}return t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain)?"domain: string expected":null},e.fromObject=function(t){if(t instanceof p.onnx.FunctionProto)return t;var r=new p.onnx.FunctionProto;if(t.name!=null&&(r.name=String(t.name)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.FunctionProto.input: array expected");r.input=[];for(var n=0;n<t.input.length;++n)r.input[n]=String(t.input[n])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.FunctionProto.output: array expected");r.output=[];for(var n=0;n<t.output.length;++n)r.output[n]=String(t.output[n])}if(t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");r.attribute=[];for(var n=0;n<t.attribute.length;++n)r.attribute[n]=String(t.attribute[n])}if(t.attributeProto){if(!Array.isArray(t.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");r.attributeProto=[];for(var n=0;n<t.attributeProto.length;++n){if(typeof t.attributeProto[n]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");r.attributeProto[n]=p.onnx.AttributeProto.fromObject(t.attributeProto[n])}}if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.FunctionProto.node: array expected");r.node=[];for(var n=0;n<t.node.length;++n){if(typeof t.node[n]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");r.node[n]=p.onnx.NodeProto.fromObject(t.node[n])}}if(t.docString!=null&&(r.docString=String(t.docString)),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");r.opsetImport=[];for(var n=0;n<t.opsetImport.length;++n){if(typeof t.opsetImport[n]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");r.opsetImport[n]=p.onnx.OperatorSetIdProto.fromObject(t.opsetImport[n])}}return t.domain!=null&&(r.domain=String(t.domain)),r},e.toObject=function(t,r){r||(r={});var n={};if((r.arrays||r.defaults)&&(n.input=[],n.output=[],n.attribute=[],n.node=[],n.opsetImport=[],n.attributeProto=[]),r.defaults&&(n.name="",n.docString="",n.domain=""),t.name!=null&&t.hasOwnProperty("name")&&(n.name=t.name),t.input&&t.input.length){n.input=[];for(var s=0;s<t.input.length;++s)n.input[s]=t.input[s]}if(t.output&&t.output.length){n.output=[];for(var s=0;s<t.output.length;++s)n.output[s]=t.output[s]}if(t.attribute&&t.attribute.length){n.attribute=[];for(var s=0;s<t.attribute.length;++s)n.attribute[s]=t.attribute[s]}if(t.node&&t.node.length){n.node=[];for(var s=0;s<t.node.length;++s)n.node[s]=p.onnx.NodeProto.toObject(t.node[s],r)}if(t.docString!=null&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.opsetImport&&t.opsetImport.length){n.opsetImport=[];for(var s=0;s<t.opsetImport.length;++s)n.opsetImport[s]=p.onnx.OperatorSetIdProto.toObject(t.opsetImport[s],r)}if(t.domain!=null&&t.hasOwnProperty("domain")&&(n.domain=t.domain),t.attributeProto&&t.attributeProto.length){n.attributeProto=[];for(var s=0;s<t.attributeProto.length;++s)n.attributeProto[s]=p.onnx.AttributeProto.toObject(t.attributeProto[s],r)}return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,q.util.toJSONOptions)},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.FunctionProto"},e}(),i}();ja.exports=p});function Pe(i,e){if(!i)throw new Error(typeof e=="string"?e:e())}function Ze(i){return new TextDecoder().decode(i)}var j,fe,to,ct,kr,st,bt,A,Je,ce,pe,de,U=x(()=>{"use strict";Pr();Mn();j=Ie(Ae());he();fe=class{static arraysEqual(e,o){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==o[t])return!1;return!0}},to=class{static preprocessInputShapes(e,o){let t=e.length===1?[1,e[0]]:e,r=o.length===1?[o[0],1]:o;return[t,r]}static postprocessOutputShape(e,o,t){o===1&&e.splice(e.length-2,1),t===1&&e.pop()}static calcMatMulShape(e,o){return e[1]!==o[0]?void 0:[e[0],o[1]]}},ct=class i{static calcShape(e,o,t=!1){let r=e.length,n=o.length;if(r===0)return o;if(n===0)return e;let s=Math.max(e.length,o.length),a=new Array(s);if(t){if(r<2||n<2)return;let u=to.calcMatMulShape([e[r-2],e[r-1]],[o[n-2],o[n-1]]);if(u===void 0)return;[a[s-2],a[s-1]]=u}for(let u=t?3:1;u<=s;u++){let l=r-u<0?1:e[r-u],f=n-u<0?1:o[n-u];if(l!==f&&l>1&&f>1)return;a[s-u]=Math.max(l,f)}return a}static index(e,o){let t=new Array(o.length);return i.fillIndex(e,o,t),t}static fillIndex(e,o,t){let r=e.length-o.length;for(let n=0;n<o.length;n++)t[n]=e[r+n]%o[n]}static calc(e,o,t,r,n){let s=i.calcShape(e.dims,o.dims);if(s){if(r&&!A.areEqual(s,e.dims))return;let a=A.size(s),u=r?e:new et(s,n||e.type);if(s.length===0)u.set([],t(e.get([]),o.get([])));else{let l=new Array(s.length),f=new Array(e.dims.length),c=new Array(o.dims.length),d=0,m=0,g=!1,y=!1;e.dims.length===0&&(d=e.get([]),g=!0),o.dims.length===0&&(m=o.get([]),y=!0);let T;for(let _=0;_<a;_++){T=_;for(let w=s.length-1;w>=0;w--)l[w]=T%s[w],T=Math.floor(T/s[w]);g||(i.fillIndex(l,e.dims,f),d=e.get(f)),y||(i.fillIndex(l,o.dims,c),m=o.get(c)),u.set(l,t(d,m))}}return u}}static isValidBroadcast(e,o){let t=e.length,r=o.length;if(t>r)return!1;for(let n=1;n<=t;n++)if(e[t-n]!==1&&e[t-n]!==o[r-n])return!1;return!0}static getBroadcastDims(e,o){let t=e.length,r=[];for(let n=0;n<t;n++){let s=t-1-n,a=e[s]||1;(o[o.length-1-n]||1)>1&&a===1&&r.unshift(s)}return r}},kr=class{static getShapeOfGemmResult(e,o,t,r,n){if(e.length!==2||t.length!==2)throw new Error("shape need to be of size 2");let s,a,u;o?(s=e[1],a=e[0]):(s=e[0],a=e[1]);let l=-1;if(r?(u=t[0],l=1):(u=t[1],l=0),t[l]!==a)throw new Error("dimension mismatch");if(s<=0||u<=0||a<=0)throw new Error("invalid shape specified");if(n&&!ct.isValidBroadcast(n,[s,u]))throw new Error("gemm: invalid bias shape for broadcast");return[s,u,a]}},st=class i{static tensorDataTypeFromProto(e){switch(e){case j.onnx.TensorProto.DataType.INT8:return"int8";case j.onnx.TensorProto.DataType.UINT8:return"uint8";case j.onnx.TensorProto.DataType.BOOL:return"bool";case j.onnx.TensorProto.DataType.INT16:return"int16";case j.onnx.TensorProto.DataType.UINT16:return"uint16";case j.onnx.TensorProto.DataType.INT32:return"int32";case j.onnx.TensorProto.DataType.UINT32:return"uint32";case j.onnx.TensorProto.DataType.FLOAT:return"float32";case j.onnx.TensorProto.DataType.DOUBLE:return"float64";case j.onnx.TensorProto.DataType.STRING:return"string";case j.onnx.TensorProto.DataType.INT64:return"int32";case j.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${j.onnx.TensorProto.DataType[e]}`)}}static tensorDataTypeStringToEnum(e){switch(e){case"int8":return j.onnx.TensorProto.DataType.INT8;case"uint8":return j.onnx.TensorProto.DataType.UINT8;case"bool":return j.onnx.TensorProto.DataType.BOOL;case"int16":return j.onnx.TensorProto.DataType.INT16;case"uint16":return j.onnx.TensorProto.DataType.UINT16;case"int32":return j.onnx.TensorProto.DataType.INT32;case"uint32":return j.onnx.TensorProto.DataType.UINT32;case"float32":return j.onnx.TensorProto.DataType.FLOAT;case"float64":return j.onnx.TensorProto.DataType.DOUBLE;case"string":return j.onnx.TensorProto.DataType.STRING;case"int64":return j.onnx.TensorProto.DataType.INT64;case"uint64":return j.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${e}`)}}static tensorDimsFromProto(e){return e.map(o=>jt.isLong(o)?o.toNumber():o)}static tensorValueTypeFromProto(e){return{tensorType:i.tensorDataTypeFromProto(e.elemType),shape:{dims:i.tensorDimsFromProto(e.shape.dim.map(o=>o.dimValue))}}}static tensorDimsFromORTFormat(e){let o=[];for(let t=0;t<e.dimsLength();t++)o.push(bt.longToNumber(e.dims(t)));return o}static tensorAttributesFromORTFormat(e){let o=[];for(let t=0;t<e.attributesLength();t++)o.push(e.attributes(t));return o}},bt=class{static longToNumber(e,o){return jt.isLong(e)?e.toNumber():e instanceof b.Long?jt.fromValue({low:e.low,high:e.high,unsigned:o??!1}).toNumber():e}static isLong(e){return jt.isLong(e)||e instanceof b.Long}},A=class i{static size(e){return i.getSizeFromDimensionRange(e,0,e.length)}static sizeFromDimension(e,o){if(o<0||o>e.length)throw new Error(`invalid dimension of ${o} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return i.getSizeFromDimensionRange(e,o,e.length)}static sizeToDimension(e,o){if(o<0||o>e.length)throw new Error(`invalid dimension of ${o} for sizeToDimension as Tensor has ${e.length} dimensions.`);return i.getSizeFromDimensionRange(e,0,o)}static getSizeFromDimensionRange(e,o,t){let r=1;for(let n=o;n<t;n++){if(e[n]<=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[n]}return r}static computeStrides(e){let o=e.length;if(o===0)return[];if(o===1)return[1];let t=new Array(o);t[o-1]=1,t[o-2]=e[o-1];for(let r=o-3;r>=0;--r)t[r]=t[r+1]*e[r+1];return t}static transpose(e){return e.slice().reverse()}static indicesToOffset(e,o,t){t===void 0&&(t=e.length);let r=0;for(let n=0;n<t;++n)r+=o[n]*e[n];return r}static offsetToIndices(e,o){let t=o.length;if(t===0)return[];if(t===1)return[e*o[0]];let r=new Array(o.length);for(let n=0;n<r.length-1;++n)r[n]=Math.floor(e/o[n]),e-=r[n]*o[n];return r[r.length-1]=e,r}static normalizeAxis(e,o){if(e<-o&&e>=o)throw new Error("unsupported axis for this operation.");return e<0?e+o:e}static normalizeAxes(e,o){return e.map(t=>this.normalizeAxis(t,o))}static incrementIndex(e,o,t){if(o.length===0||e.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(t===void 0)t=o.length;else if(t<=0||t>o.length)throw new Error("Incorrect axis to increment on");for(let r=t-1;r>=0&&(e[r]++,!(e[r]<o[r]));--r)e[r]=0}static calculateReshapedDims(e,o){if(o.length===0){if(e.length===0||i.size(e)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}let t=o.length,r=new Array(t),n=-1,s=1;for(let u=0;u<t;u++){if(o[u]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(o[u]===-1){if(n!==-1)throw new Error("at most one dimension in shape hints can be -1");n=u}else{if(o[u]===0){if(u>=e.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");r[u]=e[u]}else r[u]=o[u];s*=r[u]}}let a=i.size(e);if(n!==-1){if(a%s!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${e}] Output shape: [${o}]`);r[n]=a/s}else if(s!==a)throw new Error("reshapedDims and originalDims don't have matching sizes");return r}static sortBasedOnPerm(e,o){return o?o.map(t=>e[t]):e.slice().reverse()}static padShape(e,o){let t=e.length;return e.map((r,n)=>r+o[n]+o[n+t])}static areEqual(e,o){return e.length!==o.length?!1:e.every((t,r)=>t===o[r])}static validateDimsAndCalcSize(e){if(e.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let o=1;for(let t of e){if(!Number.isInteger(t))throw new TypeError(`Invalid shape: ${t} is not an integer`);if(t<0||t>2147483647)throw new TypeError(`Invalid shape: length ${t} is not allowed`);o*=t}return o}static flattenShape(e,o){o<0&&(o+=e.length);let t=e.reduce((s,a)=>s*a,1),r=e.slice(o).reduce((s,a)=>s*a,1);return[t/r,r]}static squeezeShape(e,o){let t=new Array;o=i.normalizeAxes(o,e.length);for(let r=0;r<e.length;r++){let n=o.indexOf(r)>=0;if(n&&e[r]!==1)throw new Error("squeeze an axis of size different than 1");(o.length===0&&e[r]>1||o.length>0&&!n)&&t.push(e[r])}return t}static unsqueezeShape(e,o){let t=new Array(e.length+o.length);t.fill(0);for(let n=0;n<o.length;n++){let s=i.normalizeAxis(o[n],t.length);if(s>=t.length)throw new Error("'axes' has an out of range axis");if(t[s]!==0)throw new Error("'axes' has a duplicate axis");t[s]=1}let r=0;for(let n=0;n<t.length;n++)t[n]===0&&(t[n]=e[r++]);if(r!==e.length)throw new Error("the unsqueezed dimension could not be established");return t}},Je=class i{static splitShape(e,o,t,r){if(t.length===0){if(!r)throw new Error("need to know number of outputs when the 'split' attribute is not specified");i.determineSplit(e[o],r,t)}let n=[],s=[0];for(let a=0;a<t.length;++a){a!==0&&s.push(s[a-1]+t[a-1]);let u=e.slice();u[o]=t[a],n.push(u)}return[n,s]}static determineSplit(e,o,t){if(e%o!==0)throw new Error("cannot split tensor to equal sized parts");for(let r=0;r<o;++r)t.push(e/o)}},ce=class i{static adjustPoolAttributes(e,o,t,r,n,s){if(!e&&t.length!==o.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let a=0;a<o.length-2;a++)a>=t.length?t.push(o[a+2]):t[a]=o[a+2];for(let a=0;a<t.length;a++)if(a<r.length){if(r[a]<0)throw new Error("strides should be greater than or equal to 1")}else r.push(1);for(let a=0;a<t.length;a++)if(a<n.length){if(n[a]<0)throw new Error("dilations should be greater than or equal to 1")}else n.push(1);for(let a=0;a<t.length*2;a++)if(a<s.length){if(s[a]<0)throw new Error("pad should be greater than or equal to 1")}else s.push(0);for(let a=0;a<t.length;a++){if(t[a]<=0)throw new Error("kernel shapes need to be greater than 0");if(s[a]>=t[a]||s[a+t.length]>=t[a])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,o,t,r,n,s){if(s){if(n.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(o.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(r.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let a=0;a<e.length-2;a++)i.adjustPadAndReturnShape(e[a+2],o[a],t[a],r[a],n,a,a+e.length-2,s)}}static computePoolOutputShape(e,o,t,r,n,s,a){if(o.length<=0)throw new Error("input shape must be of size greater than 0");let u=[o[0],o[1]];return i.computeShapeHelper(e,o,u,t,r,n,s,a),u}static computeConvOutputShape(e,o,t,r,n,s,a){if(e.length<=0||o.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let u=[e[0],o[0]];return i.computeShapeHelper(!1,e,u,t,r,n,s,a),u}static computeShapeHelper(e,o,t,r,n,s,a,u){if(e)for(let l=0;l<o.length-2;l++)t.push(1);else for(let l=0;l<o.length-2;l++)t.push(i.adjustPadAndReturnShape(o[l+2],r[l],n[l],s[l],a,l,l+o.length-2,u))}static adjustPadAndReturnShape(e,o,t,r,n,s,a,u){let l=t*(r-1)+1;if(u&&u!=="NOTSET")switch(u){case"VALID":return n[s]=0,n[a]=0,Math.floor((e-l)/o+1);case"SAME_LOWER":case"SAME_UPPER":if(t!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let c=((e+o-1)/o-1)*o+r-e;return n[s]=Math.floor(u==="SAME_LOWER"?(c+1)/2:c/2),n[a]=c-n[s],Math.floor((e+c-r)/o+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((e+n[s]+n[a]-l)/o+1)}},pe=-34028234663852886e22,de=34028234663852886e22});function Uc(i){switch(i){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 ${i}`)}}function Xa(i){switch(i){case N.onnx.TensorProto.DataType.UINT8:case N.onnx.TensorProto.DataType.INT8:case N.onnx.TensorProto.DataType.BOOL:return 1;case N.onnx.TensorProto.DataType.UINT16:case N.onnx.TensorProto.DataType.INT16:return 2;case N.onnx.TensorProto.DataType.FLOAT:case N.onnx.TensorProto.DataType.INT32:case N.onnx.TensorProto.DataType.UINT32:return 4;case N.onnx.TensorProto.DataType.INT64:case N.onnx.TensorProto.DataType.DOUBLE:case N.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${N.onnx.TensorProto.DataType[i]}`)}}function zc(i,e){return new(Za(e))(i)}function Za(i){switch(i){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 ro(i,e){if(e===N.onnx.TensorProto.DataType.INT64||e===eo.TensorDataType.INT64){if(i.greaterThanOrEqual(2147483648)||i.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(e===N.onnx.TensorProto.DataType.UINT32||e===eo.TensorDataType.UINT32||e===N.onnx.TensorProto.DataType.UINT64||e===eo.TensorDataType.UINT64){if(i.greaterThanOrEqual(4294967296)||i.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${N.onnx.TensorProto.DataType[e]}`);return i.toNumber()}function Ka(i,e,o){switch(e){case N.onnx.TensorProto.DataType.BOOL:case N.onnx.TensorProto.DataType.UINT8:return i.getUint8(o);case N.onnx.TensorProto.DataType.INT8:return i.getInt8(o);case N.onnx.TensorProto.DataType.UINT16:return i.getUint16(o,!0);case N.onnx.TensorProto.DataType.INT16:return i.getInt16(o,!0);case N.onnx.TensorProto.DataType.FLOAT:return i.getFloat32(o,!0);case N.onnx.TensorProto.DataType.INT32:return i.getInt32(o,!0);case N.onnx.TensorProto.DataType.UINT32:return i.getUint32(o,!0);case N.onnx.TensorProto.DataType.INT64:return ro(jt.fromBits(i.getUint32(o,!0),i.getUint32(o+4,!0),!1),e);case N.onnx.TensorProto.DataType.DOUBLE:return i.getFloat64(o,!0);case N.onnx.TensorProto.DataType.UINT64:return ro(jt.fromBits(i.getUint32(o,!0),i.getUint32(o+4,!0),!0),e);default:throw new Error(`cannot read from DataView for type ${N.onnx.TensorProto.DataType[e]}`)}}var Ja,N,eo,et,he=x(()=>{"use strict";Ja=Ie(Gi());Mn();qe();N=Ie(Ae());U();eo=P.experimental.fbs,et=class i{constructor(e,o,t,r,n,s=Ja.Guid.create()){this.dims=e;this.type=o;this.dataProvider=t;this.asyncDataProvider=r;this.cache=n;this.dataId=s;this.size=A.validateDimsAndCalcSize(e);let a=this.size,u=t===void 0&&r===void 0&&n===void 0;if(n!==void 0&&n.length!==a)throw new RangeError("Input dims doesn't match data length.");if(o==="string"){if(n!==void 0&&(!Array.isArray(n)||!n.every(l=>typeof l=="string")))throw new TypeError("cache should be a string array");u&&(this.cache=new Array(a))}else{if(n!==void 0){let l=Za(o);if(!(n instanceof l))throw new TypeError(`cache should be type ${l.name}`)}if(u){let l=new ArrayBuffer(a*Uc(o));this.cache=zc(l,o)}}}get data(){if(this.cache===void 0){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(this.type!=="string")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(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(e){return this.data[A.indicesToOffset(e,this.strides)]}set(e,o){this.data[A.indicesToOffset(e,this.strides)]=o}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=A.computeStrides(this.dims)),this._strides}static fromProto(e){if(!e)throw new Error("cannot construct Value from an empty tensor");let o=st.tensorDataTypeFromProto(e.dataType),t=st.tensorDimsFromProto(e.dims),r=new i(t,o);if(o==="string")e.stringData.forEach((n,s)=>{r.data[s]=Ze(n)});else if(e.rawData&&typeof e.rawData.byteLength=="number"&&e.rawData.byteLength>0){let n=r.data,s=new DataView(e.rawData.buffer,e.rawData.byteOffset,e.rawData.byteLength),a=Xa(e.dataType),u=e.rawData.byteLength/a;if(e.rawData.byteLength%a!==0)throw new Error("invalid buffer length");if(n.length!==u)throw new Error("buffer length mismatch");for(let l=0;l<u;l++){let f=Ka(s,e.dataType,l*a);n[l]=f}}else{let n;switch(e.dataType){case N.onnx.TensorProto.DataType.FLOAT:n=e.floatData;break;case N.onnx.TensorProto.DataType.INT32:case N.onnx.TensorProto.DataType.INT16:case N.onnx.TensorProto.DataType.UINT16:case N.onnx.TensorProto.DataType.INT8:case N.onnx.TensorProto.DataType.UINT8:case N.onnx.TensorProto.DataType.BOOL:n=e.int32Data;break;case N.onnx.TensorProto.DataType.INT64:n=e.int64Data;break;case N.onnx.TensorProto.DataType.DOUBLE:n=e.doubleData;break;case N.onnx.TensorProto.DataType.UINT32:case N.onnx.TensorProto.DataType.UINT64:n=e.uint64Data;break;default:throw new Error("unspecific error")}if(n==null)throw new Error("failed to populate data from a tensorproto value");let s=r.data;if(s.length!==n.length)throw new Error("array length mismatch");for(let a=0;a<n.length;a++){let u=n[a];jt.isLong(u)?s[a]=ro(u,e.dataType):s[a]=u}}return r}static fromData(e,o,t){return new i(o,t,void 0,void 0,e)}static fromOrtTensor(e){if(!e)throw new Error("cannot construct Value from an empty tensor");let o=st.tensorDimsFromORTFormat(e),t=st.tensorDataTypeFromProto(e.dataType()),r=new i(o,t);if(t==="string")for(let n=0;n<e.stringDataLength();n++)r.data[n]=e.stringData(n);else if(e.rawDataArray()&&typeof e.rawDataLength()=="number"&&e.rawDataLength()>0){let n=r.data,s=new DataView(e.rawDataArray().buffer,e.rawDataArray().byteOffset,e.rawDataLength()),a=Xa(e.dataType()),u=e.rawDataLength()/a;if(e.rawDataLength()%a!==0)throw new Error("invalid buffer length");if(n.length!==u)throw new Error("buffer length mismatch");for(let l=0;l<u;l++){let f=Ka(s,e.dataType(),l*a);n[l]=f}}return r}}});function D(i){return i===1?Wc:Hc}function Ya(i){let e=D(i);return`${e.version}
+      precision highp float;
+      ${e.attribute} vec3 position;
+      ${e.attribute} vec2 textureCoord;
+
+      ${e.varyingVertex} vec2 TexCoords;
+
+      void main()
+      {
+          gl_Position = vec4(position, 1.0);
+          TexCoords = textureCoord;
+      }`}function Qa(i){let e=D(i);return`${e.version}
+    precision highp float;
+    precision highp int;
+    precision highp sampler2D;
+    ${e.varyingFrag} vec2 TexCoords;
+    ${e.outputDeclaration}
+    const vec2 halfCR = vec2(0.5, 0.5);
+
+    // Custom vector types to handle higher dimenalities.
+    struct ivec5
+    {
+      int x;
+      int y;
+      int z;
+      int w;
+      int u;
+    };
+
+    struct ivec6
+    {
+      int x;
+      int y;
+      int z;
+      int w;
+      int u;
+      int v;
+    };
+
+    int imod(int x, int y) {
+      return x - y * (x / y);
+    }
+
+    `}function ts(i,e){let o=D(i);return`
+  void main() {
+    int indices[${e}];
+    toVec(TexCoords, indices);
+    vec4 result = vec4(process(indices));
+    ${o.output} = result;
+  }
+  `}var Wc,Hc,X=x(()=>{"use strict";Wc={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},Hc={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}});var R=x(()=>{"use strict"});async function no(i,e=t=>0,o){return new Promise((t,r)=>{let n=0,s=()=>{if(i()){t();return}n++;let a=e(n);if(o!=null&&n>=o){r();return}setTimeout(s,a)};s()})}function Br(i){return Pe(typeof i<"u"&&i.length!==0,()=>"empty string found for sampler name"),"get"+i.charAt(0).toUpperCase()+i.slice(1)}function es(i){return Pe(typeof i<"u"&&i.length!==0,()=>"empty string found for sampler name"),"get"+i.charAt(0).toUpperCase()+i.slice(1)+"AtOutCoords"}function Ee(i,e){let o=JSON.parse(JSON.stringify(i));return o=e,o}function De(i,e){return e.map(o=>i[o]).join(", ")}function pt(i){if(i<=1)return"int";if(i===2)return"ivec2";if(i===3)return"ivec3";if(i===4)return"ivec4";if(i===5)return"ivec5";if(i===6)return"ivec6";throw Error(`GPU for rank ${i} is not yet supported`)}function Rt(i=6){return["x","y","z","w","u","v"].slice(0,i)}var Mt=x(()=>{"use strict";U()});function qc(i,e){return Rt(e).map(o=>`${i}.${o}`)}function Le(i,e){return e===1?[i]:qc(i,e)}function Vt(){return`
+    float getChannel(vec4 frag, int dim) {
+      int modCoord = imod(dim, 2);
+      return modCoord == 0 ? frag.r : frag.g;
+    }
+
+    float getChannel(vec4 frag, vec2 innerDims) {
+      vec2 modCoord = mod(innerDims, 2.);
+      return modCoord.x == 0. ?
+        (modCoord.y == 0. ? frag.r : frag.g) :
+        (modCoord.y == 0. ? frag.b : frag.a);
+    }
+  `}var me=x(()=>{"use strict";Mt()});function Xc(i,e,o){if(i===0)return"false";if(i===1)return`rc > ${e[0]}`;let t="";for(let r=i-2;r<i;r++)t+=`${o[r]} >= ${e[r-i+2]}`,r<i-1&&(t+="||");return t}function Kc(i,e){let o=i.length;if(o===0)return"getA(), 0, 0, 0";if(o===1)return`getA(rc),
+            rc + 1 >= ${i[0]} ? 0. : getA(rc + 1),
+            0, 0`;let t="r, c",r="r, cp1",n="rp1, c",s="rp1, cp1",a="";if(o>2)for(let u=0;u<o-2;++u)a=a+`${e[u]},`;return`getA(${a}${t}),
+          rEdge ? 0. : getA(${a}${n}),
+          cEdge ? 0. : getA(${a}${r}),
+          rEdge || cEdge ? 0. : getA(${a}${s})`}function Jc(i,e,o,t){return i===0||i===1?"":`
+    int r = ${e[i-2]};
+    int c = ${e[i-1]};
+    int rp1 = ${e[i-2]} + 1;
+    int cp1 = ${e[i-1]} + 1;
+    bool rEdge = rp1 >= ${t};
+    bool cEdge = cp1 >= ${o};
+    `}var rs,jc,ns,os=x(()=>{"use strict";X();R();Mt();me();rs={name:"pack",inputNames:["A"],inputTypes:[1]},jc=(i,e)=>{let o=D(i.session.backend.glContext.version),t=e.dims,r=t.length,n=e.dims.length,s=pt(n),a=Le("rc",n),u=Jc(n,a,t[t.length-2],t[t.length-1]),l;r===0?l=[1,1]:r===1?l=[t[0],1]:l=[t[n-1],t[n-2]];let f=Xc(n,l,a),c=Kc(t,a),d=`
+        void main() {
+          ${s} rc = getOutputCoords();
+
+          if(${f}) {
+            ${o.output} = vec4(0);
+          } else {
+            ${u}
+
+            ${o.output} = vec4(${c});
+          }
+        }
+      `;return{...rs,hasMain:!0,output:{dims:e.dims,type:e.type,textureType:2},shaderSource:d}},ns=(i,e)=>({...rs,get:()=>jc(i,e)})});function oo(i){if(i.length===0)return[1,1,1];let e=1;for(let o=0;o<i.length-2;++o)e*=i[o];return[e,i.length>1?i[i.length-2]:1,i[i.length-1]]}function as(i,e){let o=!1;return i.length===0||e.length===0?o=!0:i.length<2||e.length<2?o=i[i.length-1]===e[e.length-1]:o=i[i.length-1]===e[e.length-1]&&i[i.length-2]===e[e.length-2],o}function Qc(i){let e=A.computeStrides(i),o=["b","r","c"],t="index";return`
+    ivec3 inputCoordsFromReshapedOutCoords(int index) {
+      ${e.map((n,s)=>{let a=`int ${o[s]} = ${t} / ${n}`,u=s===e.length-1?`int ${o[s+1]} = ${t} - ${o[s]} * ${n}`:`index -= ${o[s]} * ${n}`;return`${a}; ${u};`}).join("")}
+      return ivec3(b, r, c);
+    }
+  `}function tp(i){let e=A.computeStrides(i);return`
+  int getFlattenedIndex(ivec3 coords) {
+    // reverse y, z order
+    return coords.x * ${e[0]} + coords.z * ${e[1]} + coords.y;
+  }
+`}var Zc,Yc,is,ss=x(()=>{"use strict";U();X();R();me();Zc=i=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${i}`}),Yc=(i,e,o,t)=>{let r=e.dims,n=t,s="";for(let l=0;l<4;l++){let f="";switch(l){case 0:f="outputCoords = rc;";break;case 1:f="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:f="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:f="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}s+=`
+        ${f}
+        ${l>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
+          int flattenedIndex = getFlattenedIndex(outputCoords);
+
+          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);
+          vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));
+
+          result[${l}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
+
+        ${l>0?"}":""}
+      `}let a=D(i.session.backend.glContext.version),u=`
+      ${Qc(r)}
+      ${tp(n)}
+      ${Vt()}
+
+      void main() {
+        ivec3 rc = getOutputCoords();
+
+        vec4 result = vec4(0.0);
+
+        ivec3 outputCoords;
+        int rows = ${n[2]};
+        int cols = ${n[1]};
+
+        ${s}
+        ${a.output} = result;
+      }
+    `;return{...o,output:{dims:n,type:e.type,textureType:2},shaderSource:u,hasMain:!0}},is=(i,e,o)=>{let t=Zc(o);return{...t,get:()=>Yc(i,e,t,o)}}});var io,us=x(()=>{"use strict";X();R();io=(i,e)=>{let o=e.shape,t=D(i.session.backend.glContext.version),r=`
+    const float FLOAT_MAX = 1.70141184e38;
+    const float FLOAT_MIN = 1.17549435e-38;
+
+    bool isNaN(float val) {
+      return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;
+    }
+
+    highp vec4 encodeAsUint8(highp float v) {
+      if (isNaN(v)) {
+        return vec4(255, 255, 255, 255);
+      }
+
+      highp float av = abs(v);
+
+      if(av < FLOAT_MIN) {
+        return vec4(0.0, 0.0, 0.0, 0.0);
+      } else if(v > FLOAT_MAX) {
+        return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
+      } else if(v < -FLOAT_MAX) {
+        return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;
+      }
+
+      highp vec4 c = vec4(0,0,0,0);
+
+      highp float e = floor(log2(av));
+      highp float m = exp2(fract(log2(av))) - 1.0;
+
+      c[2] = floor(128.0 * m);
+      m -= c[2] / 128.0;
+      c[1] = floor(32768.0 * m);
+      m -= c[1] / 32768.0;
+      c[0] = floor(8388608.0 * m);
+
+      highp float ebias = e + 127.0;
+      c[3] = floor(ebias / 2.0);
+      ebias -= c[3] * 2.0;
+      c[2] += floor(ebias) * 128.0;
+
+      c[3] += 128.0 * step(0.0, -v);
+
+      return c / 255.0;
+    }
+
+    void main() {
+      float value = ${t.texture2D}(X,TexCoords).r;
+      ${t.output} = encodeAsUint8(value);
+    }`,n={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:o,type:e.tensor.type,textureType:3},shaderSource:r,hasMain:!0};return i.executeProgram(n,[e.tensor])}});function rp(i,e){if(i===1)return"rc";let o="";for(let t=0;t<i;t++)o+=e[t],t<i-1&&(o+=",");return o}var ls,ep,fs,cs=x(()=>{"use strict";X();R();Mt();me();ls={name:"unpack",inputNames:["A"],inputTypes:[2]},ep=(i,e)=>{let o=e.dims.length,t=Le("rc",o),r=t.slice(-2),n=pt(o),s=Vt(),u=e.dims.length===0?"":rp(o,t),l=o<=1?"rc":`vec2(${r.join(",")})`,f=D(i.session.backend.glContext.version),c=`
+    ${s}
+    void main() {
+      ${n} rc = getOutputCoords();
+
+       // Sample the texture with the coords to get the rgba channel value.
+       vec4 packedInput = getA(${u});
+
+       ${f.output} = vec4(getChannel(packedInput, ${l}), 0, 0, 0);
+     }
+   `;return{...ls,hasMain:!0,output:{dims:e.dims,type:e.type,textureType:0},shaderSource:c}},fs=(i,e)=>({...ls,get:()=>ep(i,e)})});var Fr,Ye,Nr,Qe=x(()=>{"use strict";vt();Fr=class{constructor(e,o=1){if(o===1)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=o;else if(o===4)this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=o;else throw new Error(`Invalid number of channels: ${o}`)}encode(e,o){let t,r;return e.constructor!==Float32Array&&(z.warning("Encoder","data was not of type Float32; creating new Float32Array"),r=new Float32Array(e)),o*this.channelSize>e.length?(z.warning("Encoder","Source data too small. Allocating larger array"),r=e,t=this.allocate(o*this.channelSize),r.forEach((n,s)=>t[s]=n)):(r=e,t=r),t}allocate(e){return new Float32Array(e*4)}decode(e,o){return this.channelSize===1?e.filter((r,n)=>n%4===0).subarray(0,o):e.subarray(0,o)}},Ye=class{constructor(e,o=1,t){if(o!==1&&o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=o,this.textureType=t||e.FLOAT}encode(e,o){let t=e;return this.channelSize===1&&(z.verbose("Encoder","Exploding into a larger array"),t=this.allocate(o),e.forEach((r,n)=>t[n*4]=r)),t}allocate(e){return new Float32Array(e*4)}decode(e,o){return this.channelSize===1?e.filter((r,n)=>n%4===0).subarray(0,o):e.subarray(0,o)}},Nr=class{constructor(e,o=1){this.channelSize=4;if(o===1)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=o;else if(o===4)this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=o;else throw new Error(`Invalid number of channels: ${o}`)}encode(e,o){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,o){if(e instanceof Uint8Array)return e.subarray(0,o);throw new Error(`Invalid array type: ${e.constructor}`)}}});var tr,ps,ao,ds=x(()=>{"use strict";U();R();tr=(i,e,o)=>{let t=o===0||o===1?1:4,r=o===2,n=o===1||o===2,s=o===4?e.length-1:void 0,a=o===4?e.map((u,l)=>l===e.length-1?u*4:u):void 0;return ao(i,e,t,a,{isPacked:r,reverseWH:n,breakAxis:s})},ps=(i,e,o)=>{let t=tr(i,e,o);return[t.width,t.height]},ao=(i,e,o=1,t,r)=>{let n=!!(r&&r.isPacked),[s,a]=i.computeTextureWH(n&&t||e,r),u=e.length,l=e.slice(0);if(u===0&&(l=[1]),o===1)t=e;else if(n){if(o!==4)throw new Error("a packed texture must be 4-channel");t=e,u>0&&(l[u-1]=Math.ceil(l[u-1]/2)),u>1&&(l[u-2]=Math.ceil(l[u-2]/2))}else if(!t)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:a,channels:o,isPacked:n,shape:l,strides:A.computeStrides(l),unpackedShape:t,reversedWH:r&&r.reverseWH}}});var op,Cr,ms=x(()=>{"use strict";vt();he();U();os();ss();us();cs();Qe();ds();R();op=(i,e)=>{let o=e.map(r=>`${r.unpackedShape.join(",")};${r.width}x${r.height}`).join("_"),t=i.name;return i.cacheHint&&(t+="["+i.cacheHint+"]"),t+=":"+o,t},Cr=class{constructor(e){this.session=e;this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,o){return ps(this.session.layoutStrategy,e,o)}executeProgram(e,o){if(o.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 t=[];for(let l=0;l<e.inputNames.length;++l)t[l]=this.getOrCreateTextureData(o[l],e.inputTypes[l]);let r=op(e,t),n=this.session.programManager.getArtifact(r),s=n?n.programInfo:typeof e.get=="function"?e.get():e,a=tr(this.session.layoutStrategy,s.output.dims,s.output.textureType),u=this.createTextureData(a,s.output.type);return n||(n=this.session.programManager.build(s,t,u),this.session.programManager.setArtifact(r,n)),this.runProgram(n,t,u),u}run(e,o){return this.executeProgram(e,o).tensor}runProgram(e,o,t){for(let r=0;r<o.length;++r)if(!!o[r].isPacked!=(e.programInfo.inputTypes[r]===2))throw new Error(`input[${r}] property packed inconsistent`);if(!!t.isPacked!=(e.programInfo.output.textureType===2))throw new Error("output property packed inconsistent");this.session.programManager.run(e,o,t)}getOrCreateTextureData(e,o){let t=this.getTextureData(e.dataId,o===2);if(!t&&(t=this.getTextureData(e.dataId,o!==2),t))return o===2?this.pack(t):this.unpack(t);if(!t){let r=tr(this.session.layoutStrategy,e.dims,o);if(o===4){let a=e.dims;if(a.length===4){let u=[a[0],Math.ceil(a[1]*a[2]*a[3]/4)],l=tr(this.session.layoutStrategy,u,o),f=e.numberData;if(a[1]*a[2]*a[3]%4!==0){let c=a[0],d=a[1]*a[2]*a[3],m=Math.ceil(d*1/4)*4,g=c*m;f=new Float32Array(g);for(let y=0;y<c;++y){let T=y*d,_=y*m+y%1*d;f.set(e.numberData.subarray(T,T+d),_)}}return this.createTextureData(l,e.type,f,e,1)}}if(o===2){let n=ao(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),s=this.createTextureData(n,e.type,e.numberData,e,1);t=this.pack(s)}else t=this.createTextureData(r,e.type,e.numberData,e,1)}return t}createTextureDataFromLayoutBindTensor(e,o,t,r){return this.createTextureData(e,o,t,r,1)}createTextureData(e,o,t,r,n){z.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);let s=this.session.textureManager.createTextureFromLayout(o,e,t,n);return this.createTextureDataFromTexture(e,o,s,r)}reshapeUnpacked(e,o){let t=this.getOrCreateTextureData(e,0),r={channels:t.channels,height:t.height,width:t.width,shape:o.length!==0?o:[1],strides:A.computeStrides(o),unpackedShape:o};return this.createTextureDataFromTexture(r,e.type,t.texture).tensor}reshapePacked(e,o){let t=this.getOrCreateTextureData(e,2);if(as(e.dims,o)){let l={channels:t.channels,height:t.height,width:t.width,shape:o.length!==0?o:[1],strides:A.computeStrides(o),unpackedShape:o,isPacked:!0};return this.createTextureDataFromTexture(l,e.type,t.texture).tensor}let r=oo(e.dims),n=oo(o),s=this.reshapePacked(e,r),a=this.run(is(this,s,n),[s]);return this.reshapePacked(a,o)}cast(e,o){let t=this.getOrCreateTextureData(e,0);return this.createTextureDataFromTexture(t,o,t.texture).tensor}createTextureDataFromTexture(e,o,t,r,n){let s={...e,tensor:r||new et(e.unpackedShape,o,a=>this.readTexture(s),async a=>this.readTextureAsync(s),void 0,n),texture:t};return this.setTextureData(s.tensor.dataId,s,e.isPacked),s}getTextureData(e,o=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,o):o?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,o,t=!1){this.session.isInitializer(e)?this.session.setTextureData(e,o,t):(t?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,o)}isTextureLayoutCached(e,o=!1){return!!this.getTextureData(e.dataId,o)}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(io(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(io(this,e))}pack(e){return this.executeProgram(ns(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(fs(this,e.tensor),[e.tensor])}}});var so,F,at=x(()=>{"use strict";so=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}},F=i=>new so(i)});var bs,gs,ys,ip,ap,xs=x(()=>{"use strict";at();X();R();bs={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},gs=(i,e,o)=>(ap(e),[i.run({...bs,cacheHint:o.cacheKey,get:()=>ip(i,e,o)},e)]),ys=i=>{let e=i.attributes.getFloat("epsilon",1e-5),o=i.attributes.getFloat("momentum",.9),t=i.attributes.getInt("spatial",1);return F({epsilon:e,momentum:o,spatial:t})},ip=(i,e,o)=>{let t=D(i.session.backend.glContext.version),r=e[0].dims.length,[n,s]=i.calculateTextureWidthAndHeight(e[1].dims,0),a=`
+  float process(int[${r}] indices) {
+    vec2 position = offsetToCoords(indices[1], ${n}, ${s});
+    float scale = getColorAsFloat(${t.texture2D}(Scale, position));
+    float mean = getColorAsFloat(${t.texture2D}(Mean, position));
+    float variance = getColorAsFloat(${t.texture2D}(Variance, position));
+    float b = getColorAsFloat(${t.texture2D}(B, position));
+
+    return scale * ( (_A(indices) - mean) / sqrt(variance + float(${o.epsilon})) ) + b;
+  }`;return{...bs,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:a}},ap=i=>{if(!i||i.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let e=i[0],o=i[1],t=i[2],r=i[3],n=i[4];if(e.dims.length<3||o.dims.length!==1||t.dims.length!==1||r.dims.length!==1||n.dims.length!==1)throw new Error("invalid input shape.");if(o.dims[0]!==e.dims[1]||t.dims[0]!==e.dims[1]||r.dims[0]!==e.dims[1]||n.dims[0]!==e.dims[1])throw new Error("invalid input shape.");if(e.type!=="float32"&&e.type!=="float64"||o.type!=="float32"&&o.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||r.type!=="float32"&&r.type!=="float64"||n.type!=="float32"&&n.type!=="float64")throw new Error("invalid input tensor types.")}});var Rr,Ot,O,er,Gr,Xt=x(()=>{"use strict";Rr=class{constructor(e,o,t,r){this.glContext=e;this.programInfo=o;this.inputTextureLayouts=t;this.outputTextureLayout=r}},Ot=class{constructor(e){this.context=e}},O=class{constructor(e,o){this.routineBody=e;this.dependencies=o}},er=class{constructor(e,o,t){this.name=e;t?this.dependencies=t:this.dependencies=[],o&&(this.routineBody=o)}addDependency(e){e&&this.dependencies.push(e)}},Gr=class{static returnOrderedNodes(e){if(!e||e.length===0)return[];if(e.length===1)return e;let o=new Set,t=new Set,r=new Array;return this.createOrderedNodes(e,o,t,r),r}static createOrderedNodes(e,o,t,r){for(let n=0;n<e.length;++n)this.dfsTraverse(e[n],o,t,r)}static dfsTraverse(e,o,t,r){if(!e||t.has(e.name))return;if(o.has(e.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");o.add(e.name);let n=e.dependencies;if(n&&n.length>0)for(let s=0;s<n.length;++s)this.dfsTraverse(n[s],o,t,r);r.push(e),t.add(e.name),o.delete(e.name)}}});function up(){let i="add_";return{body:`
+  float ${i}(float a, float b) {
+    return a + b;
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return v1 + v2;
+  }
+  `,name:i,type:0}}function lp(){let i="div_";return{body:`
+  float ${i}(float a, float b) {
+    return a / b;
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return v1 / v2;
+  }
+  `,name:i,type:0}}function fp(){let i="mul_";return{body:`
+  float ${i}(float a, float b) {
+    return a * b;
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return v1 * v2;
+  }
+  `,name:i,type:0}}function cp(){let i="sub_";return{body:`
+  float ${i}(float a, float b) {
+    return a - b;
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return v1 - v2;
+  }
+  `,name:i,type:0}}function pp(){let i="equal_";return{body:`
+  float ${i}(float a, float b) {
+    return float(a == b);
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return vec4(equal(v1, v2));
+  }
+  `,name:i,type:0}}function dp(){let i="greater_";return{body:`
+  float ${i}(float a, float b) {
+    return float(a > b);
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return vec4( v1.r > v2.r ,
+      v1.g > v2.g,
+      v1.b > v2.b,
+      v1.a > v2.a );
+  }
+  `,name:i,type:0}}function hp(){let i="less_";return{body:`
+  float ${i}(float a, float b) {
+    return float(a < b);
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return vec4( v1.r < v2.r ,
+                v1.g < v2.g,
+                v1.b < v2.b,
+                v1.a < v2.a );
+  }
+  `,name:i,type:0}}function mp(){let i="and_";return{body:`
+  float ${i}(float a, float b) {
+    return float( bool(a) && bool(b) );
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    bvec4 b1 = bvec4(v1);
+    bvec4 b2 = bvec4(v2);
+    return vec4( b1.r && b2.r ,
+                b1.g && b2.g,
+                b1.b && b2.b,
+                b1.a && b2.a );
+  }
+  `,name:i,type:0}}function bp(){let i="or_";return{body:`
+  float ${i}(float a, float b) {
+    return float( bool(a) || bool(b) );
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    bvec4 b1 = bvec4(v1);
+    bvec4 b2 = bvec4(v2);
+    return vec4( b1.r || b2.r ,
+                b1.g || b2.g,
+                b1.b || b2.b,
+                b1.a || b2.a );
+  }
+  `,name:i,type:0}}function gp(){let i="xor_";return{body:`
+  float ${i}(float a, float b) {
+    return float( bool(a) ^^ bool(b) );
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    bvec4 b1 = bvec4(v1);
+    bvec4 b2 = bvec4(v2);
+    return vec4( b1.r ^^ b2.r ,
+                b1.g ^^ b2.g,
+                b1.b ^^ b2.b,
+                b1.a ^^ b2.a );
+  }
+  `,name:i,type:0}}function yp(){return Tp("pow")}function xp(){let i="prelu_";return{body:`
+  float ${i}(float a, float b) {
+    return a < 0.0 ? a * b: a;
+  }
+  vec4 ${i}(vec4 v1, vec4 v2) {
+    return vec4(
+      v1.r < 0.0 ? v1.r * v2.r: v1.r,
+      v1.g < 0.0 ? v1.g * v2.g: v1.g,
+      v1.b < 0.0 ? v1.b * v2.b: v1.b,
+      v1.a < 0.0 ? v1.a * v2.a: v1.a
+      );
+  }
+  `,name:i,type:0}}function Tp(i){let e=`${i}_`;return{body:`
+  float ${e}(float a, float b) {
+    return ${i}(a, b);
+  }
+  vec4 ${e}(vec4 v1, vec4 v2) {
+    return ${i}(v1, v2);
+  }
+  `,name:e,type:0}}var At,wp,Ts,ws,vs,Is,_s,Ss,Os,As,Ps,Es,Ds,Ls,$s=x(()=>{"use strict";U();Xt();X();R();At=(i,e,o,t=e[0].type,r)=>{let n=i.session.pack?2:0;return{name:o.name,inputNames:["A","B"],inputTypes:[n,n],cacheHint:r,get:()=>wp(i,e,o,t)}},wp=(i,e,o,t=e[0].type)=>{let r=i.session.pack?2:0,n=!A.areEqual(e[0].dims,e[1].dims),s=e[0].dims,a=i.session.pack;if(n){let f=ct.calcShape(e[0].dims,e[1].dims,!1);if(!f)throw new Error("Can't perform binary op on the given tensors");s=f;let c=s.length,d=e[0].dims.length!==0?e[0].dims.length:1,m=e[1].dims.length!==0?e[1].dims.length:1,g=e[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",y=e[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",T=D(i.session.backend.glContext.version),_=a?`
+      ${o.body}
+      void main() {
+        vec4 a = getAAtOutCoords();
+        vec4 b = getBAtOutCoords();
+        vec4 result = ${o.name}(a, b);
+        ${T.output} = result;
+      }`:`
+      ${o.body}
+      float process(int indices[${c}]) {
+        int aindices[${d}];
+        int bindices[${m}];
+        ${g}
+        ${y}
+        return ${o.name}(_A(aindices), _B(bindices));
+      }`;return{name:o.name,inputNames:["A","B"],inputTypes:[r,r],output:{dims:s,type:t,textureType:r},shaderSource:_,hasMain:a}}let u=D(i.session.backend.glContext.version),l=`
+    ${o.body}
+    void main() {
+      vec4 v1 = ${u.texture2D}(A, TexCoords);
+      vec4 v2 = ${u.texture2D}(B, TexCoords);
+      vec4 result = ${o.name}(v1, v2);
+      ${u.output} = result;
+    }
+    `;return{name:o.name,inputNames:["A","B"],inputTypes:[r,r],output:{dims:e[0].dims,type:t,textureType:r},shaderSource:l,hasMain:!0}},Ts=(i,e)=>[i.run(At(i,e,up()),e)],ws=(i,e)=>[i.run(At(i,e,mp(),"bool"),e)],vs=(i,e)=>[i.run(At(i,e,lp()),e)],Is=(i,e)=>[i.run(At(i,e,pp(),"bool"),e)],_s=(i,e)=>[i.run(At(i,e,dp(),"bool"),e)],Ss=(i,e)=>[i.run(At(i,e,hp(),"bool"),e)],Os=(i,e)=>[i.run(At(i,e,fp()),e)],As=(i,e)=>[i.run(At(i,e,bp(),"bool"),e)],Ps=(i,e)=>[i.run(At(i,e,yp()),e)],Es=(i,e)=>[i.run(At(i,e,xp()),e)],Ds=(i,e)=>[i.run(At(i,e,cp()),e)],Ls=(i,e)=>[i.run(At(i,e,gp(),"bool"),e)]});var ks,Bs,Ip,Fs=x(()=>{"use strict";U();ks=(i,e,o)=>(Ip(e),[i.cast(e[0],o)]),Bs=i=>st.tensorDataTypeFromProto(i.attributes.getInt("to")),Ip=i=>{if(!i||i.length!==1)throw new Error("Cast requires 1 input.");if(i[0].type==="string")throw new Error("Invalid input type.")}});var _p,Sp,Ns,Mr,Cs=x(()=>{"use strict";X();R();Mt();me();_p=(i,e)=>({name:"Concat (packed)",inputNames:Array.from({length:i},(o,t)=>`X${t}`),inputTypes:Array(i).fill(2),cacheHint:e}),Sp=(i,e,o,t)=>{let r=o[0].dims.slice();if(t>=r.length||t<-1*r.length)throw new Error("axis specified for concat doesn't match input dimensionality");t<0&&(t=r.length+t);let n=r.slice(0);for(let B=1;B<o.length;B++){let Q=o[B].dims.slice();for(let lt=0;lt<r.length;lt++)if(lt===t)n[t]+=Q[lt];else if(r[lt]!==Q[lt])throw new Error("non concat dimensions must match")}let s=n.length,a=Le("coords",s),u=pt(s),l=Vt(),f=o.map(B=>B.dims),c=Rt(s),d=new Array(f.length-1);d[0]=f[0][t];for(let B=1;B<d.length;B++)d[B]=d[B-1]+f[B][t];let m=c[t],g=c.slice(-2),y=c.join(),T=`if (${m} < ${d[0]}) {
+        return getChannel(
+            getX0(${y}), vec2(${g.join()}));
+        }`;for(let B=1;B<d.length;B++){let Q=d[B-1];T+=`
+            if (${m} < ${d[B]}  && ${m} >= ${d[B-1]}) {
+              return getChannel(
+                getX${B}(${Mr(c,m,Q)}),
+                vec2(${Mr(g,m,Q)}));
+            }`}let _=d.length,w=d[d.length-1];T+=`
+            return getChannel(
+              getX${_}(${Mr(c,m,w)}),
+              vec2(${Mr(g,m,w)}));`;let v=D(i.session.backend.glContext.version),L=`
+          ${l}
+          float getValue(${c.map(B=>"int "+B)}) {
+            ${T}
+          }
+
+          void main() {
+            ${u} coords = getOutputCoords();
+            int lastDim = coords.${c[s-1]};
+            coords.${c[s-1]} = coords.${c[s-2]};
+            coords.${c[s-2]} = lastDim;
+
+            vec4 result = vec4(getValue(${a}), 0., 0., 0.);
+
+            ${a[s-1]} = ${a[s-1]} + 1;
+            if (${a[s-1]} < ${n[s-1]}) {
+              result.g = getValue(${a});
+            }
+
+            ${a[s-2]} = ${a[s-2]} + 1;
+            if (${a[s-2]} < ${n[s-2]}) {
+              result.a = getValue(${a});
+            }
+
+            ${a[s-1]} = ${a[s-1]} - 1;
+            if (${a[s-2]} < ${n[s-2]} &&
+                ${a[s-1]} < ${n[s-1]}) {
+              result.b = getValue(${a});
+            }
+            ${v.output} = result;
+          }
+        `;return{...e,output:{dims:n,type:o[0].type,textureType:2},shaderSource:L,hasMain:!0}},Ns=(i,e,o)=>{let t=_p(e.length,o.cacheKey);return{...t,get:()=>Sp(i,t,e,o.axis)}},Mr=(i,e,o)=>{let t=i.indexOf(e);return i.map((n,s)=>s===t?`${n} - ${o}`:n).join()}});var Rs,Op,Ap,Pp,Gs,Ep,Dp,Lp,Ms,$p,Vs=x(()=>{"use strict";at();R();Cs();Rs=(i,e,o)=>($p(e),i.session.pack&&e[0].dims.length>1?[i.run(Ns(i,e,o),e)]:[i.run(Pp(i,e,o),e)]),Op=(i,e)=>({name:"Concat",inputNames:Array.from({length:i},(o,t)=>`X${t}`),inputTypes:Array(i).fill(0),cacheHint:e}),Ap=(i,e,o,t)=>{let r=o[0].dims.slice();if(t>=r.length||t<-1*r.length)throw new Error("axis specified for concat doesn't match input dimensionality");t<0&&(t=r.length+t);let n=r.slice(0);for(let m=1;m<o.length;m++){let g=o[m].dims.slice();for(let y=0;y<r.length;y++)if(y===t)n[t]+=g[y];else if(r[y]!==g[y])throw new Error("non concat dimensions must match")}let s=n.length,a=new Array(o.length),u=0;for(let m=0;m<a.length;++m)u+=o[m].dims[t],a[m]=u;let l="";o.length<5?l=Gs(a):l=Ep(a);let f=Dp(o.length,s),c=Lp(a),d=`
+        ${f}
+        ${c}
+        ${l}
+        float process(int indices[${s}]) {
+          int textureIndex = getTextureWhereDataResides (indices[${t}]);
+
+          if(textureIndex != 0) {
+            indices[${t}] = indices[${t}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
+          }
+
+          return fetchDataFromCorrectTexture(textureIndex, indices);
+        }`;return{...e,output:{dims:n,type:o[0].type,textureType:0},shaderSource:d}},Pp=(i,e,o)=>{let t=Op(e.length,o.cacheKey);return{...t,get:()=>Ap(i,t,e,o.axis)}},Gs=i=>`int getTextureWhereDataResides(int index) {
+      ${i.map((o,t)=>`if(index<${o}) {return ${t};}
+`).join("")}
+    }`,Ep=i=>Gs(i),Dp=(i,e)=>{let o=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${e}]) {`];for(let t=0;t<i;++t)t===0?o.push(`	if (textureIndex == ${t}) { return _X${t}(indices); }`):t===i-1?o.push(`	else { return _X${t}(indices); }`):o.push(`	else if (textureIndex == ${t}) { return _X${t}(indices); }`);return o.push("	}"),o.join(`
+`)},Lp=i=>{let e=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let o=0;o<i.length;++o)o===0?e.push(`	if (index == ${o}) { return ${i[o]}; }`):o===i.length-1?e.push(`	else { return ${i[o]}; }`):e.push(`	else if (index == ${o}) { return ${i[o]}; }`);return e.push("	}"),e.join(`
+`)},Ms=i=>F({axis:i.attributes.getInt("axis")}),$p=i=>{if(!i||i.length<1)throw new Error("too few inputs");let e=i[0].type,o=i[0].dims.length;if(e==="string")throw new Error("string tensor is not supported yet");for(let t of i){if(t.type!==e)throw new Error("input tensors should be one type");if(t.dims.length!==o)throw new Error("input tensors should have the same shape")}}});function kp(){return Pt("abs")}function Bp(){return Pt("acos")}function Fp(){return Pt("asin")}function Np(){return Pt("atan")}function Cp(){return Pt("ceil")}function Rp(){return Pt("cos")}function Gp(i){let e="elu";return{body:`
+  const float alpha = float(${i});
+
+  float ${e}_(float a) {
+    return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
+  }
+  vec4 ${e}_(vec4 v) {
+    return vec4(${e}_(v.x), ${e}_(v.y), ${e}_(v.z), ${e}_(v.w));
+  }
+  `,name:e,type:0}}function Mp(){return Pt("exp")}function Vp(){return Pt("floor")}function uo(i,e){let o="clip";return{body:`
+  const float min = float(${i});
+  const float max = float(${e});
+
+  float ${o}_(float a) {
+    return clamp(a, min, max);
+  }
+  vec4 ${o}_(vec4 v) {
+    return clamp(v, min, max);
+  }
+  `,name:o,type:0}}function Up(){let i="indentity";return{body:`
+  float ${i}_(float a) {
+    return a;
+  }
+  vec4 ${i}_(vec4 v) {
+    return v;
+  }
+  `,name:i,type:0}}function zp(i){let e="leakyRelu";return{body:`
+  const float alpha = float(${i});
+
+  float ${e}_(float a) {
+    return a < 0.0 ? a * alpha : a;
+  }
+  vec4 ${e}_(vec4 v) {
+    return vec4(${e}_(v.x), ${e}_(v.y), ${e}_(v.z), ${e}_(v.w));
+  }
+  `,name:e,type:0}}function Wp(){return Pt("log")}function Hp(){let i="neg";return{body:`
+  float ${i}_(float a) {
+    return -a;
+  }
+  vec4 ${i}_(vec4 v) {
+    return -v;
+  }
+  `,name:i,type:0}}function qp(){let i="not";return{body:`
+  float ${i}_(float a) {
+    return float( ! bool(a) );
+  }
+  bool ${i}_(bool a) {
+    return !a;
+  }
+  vec4 ${i}_(vec4 v) {
+    return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
+  }
+  bvec4 ${i}_(bvec4 v) {
+    return bvec4(!v.x, !v.y, !v.z, !v.w);
+  }
+  `,name:i,type:0}}function jp(){return Pt("sin")}function lo(){let i="relu";return{body:`
+  float ${i}_(float a) {
+    return max( a, 0.0 );
+  }
+  vec4 ${i}_(vec4 v) {
+    return max( v, 0.0 );
+  }
+  `,name:i,type:0}}function fo(){let i="sigmoid";return{body:`
+  float ${i}_(float a) {
+    return 1.0 / (1.0 + exp(-a));
+  }
+  vec4 ${i}_(vec4 v) {
+    return 1.0 / (1.0 + exp(-v));
+  }
+  `,name:i,type:0}}function Xp(){return Pt("sqrt")}function Kp(){return Pt("tan")}function Jp(){let i="tanh";return{body:`
+  float ${i}_(float a) {
+    a = clamp(a, -10., 10.);
+    a = exp(2.*a);
+    return (a - 1.) / (a + 1.);
+  }
+  vec4 ${i}_(vec4 v) {
+    v = clamp(v, -10., 10.);
+    v = exp(2.*v);
+    return (v - 1.) / (v + 1.);
+  }
+  `,name:i,type:0}}function Pt(i){return{body:`
+  float ${i}_(float a) {
+    return ${i}(a);
+  }
+  vec4 ${i}_(vec4 v) {
+    return ${i}(v);
+  }
+  `,name:i,type:0}}var Zp,Z,Us,zs,Ws,Hs,co,qs,js,Yp,Xs,Ks,Js,Zs,Ys,Qs,po,tu,eu,ru,nu,ou,iu,au,su,uu,lu,fu,ho=x(()=>{"use strict";at();U();Xt();X();R();Zp=(i,e,o,t)=>{let r=i.session.pack?2:0,n=D(i.session.backend.glContext.version);return{...e,output:{dims:o.dims,type:o.type,textureType:r},shaderSource:`
+     ${t.body}
+     void main() {
+       vec4 v = ${n.texture2D}(A, TexCoords);
+       v = ${t.name}_(v);
+       ${n.output} = v;
+     }
+     `,hasMain:!0}},Z=(i,e,o,t)=>{let r=i.session.pack?2:0,n={name:o.name,inputTypes:[r],inputNames:["A"],cacheHint:t};return{...n,get:()=>Zp(i,n,e,o)}},Us=(i,e)=>[i.run(Z(i,e[0],kp()),e)],zs=(i,e)=>[i.run(Z(i,e[0],Bp()),e)],Ws=(i,e)=>[i.run(Z(i,e[0],Fp()),e)],Hs=(i,e)=>[i.run(Z(i,e[0],Np()),e)],co=(i,e,o)=>[i.run(Z(i,e[0],uo(o.min,o.max),o.cacheKey),e)],qs=i=>F({min:i.attributes.getFloat("min",pe),max:i.attributes.getFloat("max",de)}),js=(i,e)=>{let o=Yp(i,e);return co(i,[e[0]],o)},Yp=(i,e)=>{if(e.length>=3&&(!i.session.isInitializer(e[1].dataId)||!i.session.isInitializer(e[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let o=e.length>=3?e[1].numberData[0]:pe,t=e.length>=3?e[2].numberData[0]:de;return F({min:o,max:t})},Xs=(i,e)=>[i.run(Z(i,e[0],Cp()),e)],Ks=(i,e)=>[i.run(Z(i,e[0],Rp()),e)],Js=(i,e,o)=>[i.run(Z(i,e[0],Gp(o.alpha),o.cacheKey),e)],Zs=i=>F({alpha:i.attributes.getFloat("alpha",1)}),Ys=(i,e)=>[i.run(Z(i,e[0],Mp()),e)],Qs=(i,e)=>[i.run(Z(i,e[0],Vp()),e)],po=(i,e)=>[i.run(Z(i,e[0],Up()),e)],tu=(i,e,o)=>[i.run(Z(i,e[0],zp(o.alpha),o.cacheKey),e)],eu=i=>F({alpha:i.attributes.getFloat("alpha",.01)}),ru=(i,e)=>[i.run(Z(i,e[0],Wp()),e)],nu=(i,e)=>[i.run(Z(i,e[0],Hp()),e)],ou=(i,e)=>[i.run(Z(i,e[0],qp()),e)],iu=(i,e)=>[i.run(Z(i,e[0],lo()),e)],au=(i,e)=>[i.run(Z(i,e[0],fo()),e)],su=(i,e)=>[i.run(Z(i,e[0],jp()),e)],uu=(i,e)=>[i.run(Z(i,e[0],Xp()),e)],lu=(i,e)=>[i.run(Z(i,e[0],Kp()),e)],fu=(i,e)=>[i.run(Z(i,e[0],Jp()),e)]});function Ut(i){let e;switch(i.activation){case"Relu":e=lo();break;case"Sigmoid":e=fo();break;case"Clip":e=uo(i.clipMin,i.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let o=e.name,t=e.body,r=`value = ${o}_(value);`;return{activationFunction:t,applyActivation:r}}var $e,be=x(()=>{"use strict";U();ho();$e=i=>{let e=i.getString("activation","");if(e==="Clip"){let[o,t]=i.getFloats("activation_params",[pe,de]);return{activation:e,clipMax:t,clipMin:o,activationCacheKey:`${e}:${o},${t}`}}return{activation:e,activationCacheKey:e}}});var td,ed,cu,pu=x(()=>{"use strict";vt();X();R();Vr();be();td=(i,e)=>({name:"GroupedConv",inputNames:i?["X","W","Bias"]:["X","W"],inputTypes:i?[0,0,0]:[0,0],cacheHint:e}),ed=(i,e,o,t)=>{let n=e.length>2?"value += getBias(output_channel);":"",s=e[0].dims.slice(),a=e[1].dims.slice(),u=a[0]/t.group;z.verbose("GroupedConv",`autpPad:${t.autoPad}, dilations:${t.dilations}, group:${t.group}, kernelShape:${t.kernelShape}, pads:${t.pads}, strides:${t.strides}`);let l=ke(s,a,t.dilations,t.pads,t.strides),f=D(i.session.backend.glContext.version),{activationFunction:c,applyActivation:d}=Ut(t),m=`
+  const ivec2 strides = ivec2(${t.strides[0]}, ${t.strides[1]});
+  const ivec2 pads = ivec2(${t.pads[0]}, ${t.pads[1]});
+  ${c}
+  void main() {
+    ivec4 coords = getOutputCoords();
+    int batch = coords.x;
+    int output_channel = coords.y;
+    ivec2 xRCCorner = coords.zw * strides - pads;
+    int group_id = output_channel / ${u};
+
+    float value = 0.0;
+    for (int wInChannel = 0; wInChannel < ${a[1]}; wInChannel++) {
+      int input_channel = group_id * ${a[1]} + wInChannel;
+      for (int wHeight = 0; wHeight < ${a[2]}; wHeight++) {
+        int xHeight = xRCCorner.x + wHeight * ${t.dilations[0]};
+
+        if (xHeight < 0 || xHeight >= ${s[2]}) {
+          continue;
+        }
+
+        for (int wWidth = 0; wWidth < ${a[3]}; wWidth++) {
+          int xWidth = xRCCorner.y + wWidth * ${t.dilations[1]};
+          if (xWidth < 0 || xWidth >= ${s[3]}) {
+            continue;
+          }
+
+          float xVal = getX(batch, input_channel, xWidth, xHeight);
+          float wVal = getW(output_channel, wInChannel, wWidth, wHeight);
+          value += xVal*wVal;
+        }
+      }
+    }
+    ${n}
+    ${d}
+    ${f.output} = vec4(value, .0, .0, .0);
+  }
+`;return{...o,output:{dims:l,type:e[0].type,textureType:0},shaderSource:m,hasMain:!0}},cu=(i,e,o)=>{let t=td(e.length>2,o.cacheKey);return{...t,get:()=>ed(i,e,t,o)}}});var rd,nd,du,hu=x(()=>{"use strict";X();R();me();rd=i=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:i}),nd=(i,e,o,t,r,n)=>{let s=o.dims,a=t.dims,u=2,l=3,f=r.length,c=[a[1]*a[2]*a[3],r[2]*r[3]],d=a[2]*a[3],m=Vt(),g=D(i.session.backend.glContext.version),y="";for(let _=0;_<=1;_++)for(let w=0;w<=1;w++)y+=`
+            blockIndex = rc.x + ${w};
+            pos = rc.y + ${_};
+
+            if(blockIndex < ${c[1]} && pos < ${c[0]}) {
+              offsetY = int(blockIndex / (${r[f-1]})) * ${n.strides[0]} -
+                ${n.pads[0]};
+              d0 = offsetY + ${n.dilations[0]} * (imod(pos, ${d}) / ${a[2]});
+
+              if(d0 < ${s[u]} && d0 >= 0) {
+                offsetX = imod(blockIndex, ${r[f-1]}) * ${n.strides[1]} -
+                  ${n.pads[1]};
+                d1 = offsetX + ${n.dilations[1]} * imod(imod(pos, ${d}), ${a[2]});
+
+                if(d1 < ${s[l]} && d1 >= 0) {
+
+                  ch = int(float(pos)/ ${d}.);
+                    innerDims = vec2(d0, d1);
+                    result[${_*2+w}] = getChannel(
+                      getA(0, ch, int(innerDims.x),
+                      int(innerDims.y)), innerDims);
+                }
+              }
+            }
+
+          `;let T=`
+      ${m}
+
+      void main() {
+        ivec2 rc = getOutputCoords();
+          vec4 result = vec4(0.0);
+          int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
+          vec2 innerDims;
+          ${y}
+          ${g.output} = result;
+      }
+            `;return{...e,output:{dims:c,type:o.type,textureType:2},shaderSource:T,hasMain:!0}},du=(i,e,o,t,r)=>{let n=rd(r.cacheKey);return{...n,get:()=>nd(i,n,e,o,t,r)}}});function id(i,e,o){let t=e[0].dims,r=e[1].dims,n=ct.calcShape(t,r,!0);if(!n)throw new Error("Can't use matmul on the given tensors");let s=pt(n.length),a=Rt(),{activationFunction:u,applyActivation:l}=Ut(o),f=e.length>2,c=f?"value += getBiasForMatmul();":"",d=f?`${bo(s,a,e[2].dims,n,!1)}`:"",m=n.length,g=t.length,y=r.length,T=t[t.length-1],_=`
+    ${u}
+    ${d}
+    float process(int indices[${m}]) {
+        int a[${g}];
+        int b[${y}];
+        bcastMatmulIndices_A(indices, a);
+        bcastMatmulIndices_B(indices, b);
+
+        float value;
+        for (int k=0; k<${T}; ++k) {
+            a[${g-1}] = k;
+            b[${y-2}] = k;
+            value += _A(a) * _B(b);
+        }
+        ${c}
+        ${l}
+        return value;
+    }`;return{...i,output:{dims:n,type:e[0].type,textureType:0},shaderSource:_}}function mo(i,e){let o=od(i.length>2,e.activationCacheKey);return{...o,get:()=>id(o,i,e)}}function bo(i,e,o,t,r){let n="",s=o.length,a=t.length,u=a-s;a<2&&s>0?n="coords":n=o.map((y,T)=>`coords.${e[T+u]}`).join(", ");let f=ct.getBroadcastDims(o,t).map(y=>`coords.${e[y+u]} = 0;`).join(`
+`),d=A.size(o)===1,m="vec4(outputValue.xx, outputValue.yy)";return d&&(m="vec4(outputValue.x)"),r?`
+vec4 getBiasForMatmul() {
+  ${i} coords = getOutputCoords();
+  ${f}
+  vec4 outputValue = getBias(${n});
+  return ${m};
+}`:`
+float getBiasForMatmul() {
+  ${i} coords = getOutputCoords();
+  ${f}
+  return getBias(coords.x);
+}`}var mu,bu,od,ad,Ur=x(()=>{"use strict";U();R();Mt();be();go();mu=(i,e,o)=>(ad(e),i.session.pack?[i.run(zr(i,e,o),e)]:[i.run(mo(e,o),e)]),bu=i=>$e(i.attributes),od=(i,e)=>({name:"MatMul",inputNames:i?["A","B","Bias"]:["A","B"],inputTypes:i?[0,0,0]:[0,0],cacheHint:e});ad=i=>{if(!i||i.length!==2)throw new Error("MatMul requires 2 inputs.");if(i[0].dims[i[0].dims.length-1]!==i[1].dims[i[1].dims.length-2])throw new Error("shared dimension does not match.");if(i[0].type!=="float32"&&i[0].type!=="float64"||i[1].type!=="float32"&&i[1].type!=="float64")throw new Error("inputs should be float type");if(i[0].type!==i[1].type)throw new Error("inputs types should match")}});function ld(i,e,o,t){let r=[],n=[],s=o[0].dims,a=o[1].dims,u=s.length,l=a.length,f=t.length,c=f-u,d=f-l;r=s.map((v,L)=>`coords.${e[L+c]}`),r[u-1]="i*2",r.join(", "),n=a.map((v,L)=>`coords.${e[L+d]}`),n[l-2]="i*2",n.join(", ");let m=ct.getBroadcastDims(s,t),g=ct.getBroadcastDims(a,t),y=m.map(v=>`coords.${e[v+c]} = 0;`).join(`
+`),T=g.map(v=>`coords.${e[v+d]} = 0;`).join(`
+`),_=`int lastDim = coords.${e[f-1]};
+  coords.${e[f-1]} = coords.${e[f-2]};
+  coords.${e[f-2]} = lastDim;`;return`
+vec4 getAAtOutCoordsMatmul(int i) {
+  ${i} coords = getOutputCoords();
+  ${_}
+  ${y}
+  vec4 outputValue = getA(${r});
+  return outputValue;
+}
+
+vec4 getBAtOutCoordsMatmul(int i) {
+  ${i} coords = getOutputCoords();
+  ${_}
+  ${T}
+  vec4 outputValue = getB(${n});
+  return outputValue;
+}`}function fd(i,e){let o="";for(let t=0;t<e-2;t++)o+=`rc.${i[t]}, `;return o+=`rc.${i[e-2]}, i*2`,o}function cd(i,e){let o="";for(let t=0;t<e-2;t++)o+=`rc.${i[t]}, `;return o+=`i*2, rc.${i[e-1]}`,o}var sd,ud,zr,go=x(()=>{"use strict";U();X();R();Mt();be();Ur();sd=(i,e)=>({name:"MatMul (packed)",inputNames:i?["A","B","Bias"]:["A","B"],inputTypes:i?[2,2,2]:[2,2],cacheHint:e}),ud=(i,e,o,t)=>{let r=o.length>2,n=r?"value += getBiasForMatmul();":"",s=o[0].dims,a=o[1].dims,u=ct.calcShape(s,a,!0),l=!A.areEqual(o[0].dims,o[1].dims);if(!u)throw new Error("Can't use matmul on the given tensors");let f=s[s.length-1],c=Math.ceil(f/2),d=s.length,m=a.length,g=D(i.session.backend.glContext.version),y=pt(u.length),T=u.length,_=Rt(),{activationFunction:w,applyActivation:v}=Ut(t),L=r?`${bo(y,_,o[2].dims,u,!0)}`:"",B=l?`${ld(y,_,o,u)}`:"",Q=l?"getAAtOutCoordsMatmul(i)":`getA(${fd(_,d)})`,lt=l?"getBAtOutCoordsMatmul(i)":`getB(${cd(_,m)})`,Wt=l?"":`${y} rc =
+          getOutputCoords(); int lastDim = rc.${_[T-1]}; rc.${_[T-1]} =
+          rc.${_[T-2]}; rc.${_[T-2]} = lastDim;
+      `,Tt=`
+            ${B}
+            ${L}
+            ${w}
+            void main() {
+              ${Wt}
+
+              vec4 value = vec4(0);
+              for (int i = 0; i < ${c}; i++) {
+                vec4 a = ${Q};
+                vec4 b = ${lt};
+
+                value += (a.rrbb * b.rgrg);
+                value += (a.ggaa * b.baba);
+              }
+              ${n}
+              ${v}
+              ${g.output} = value;
+            }`;return{...e,output:{dims:u,type:o[0].type,textureType:2},shaderSource:Tt,hasMain:!0}},zr=(i,e,o)=>{let t=sd(e.length>2,o.activationCacheKey);return{...t,get:()=>ud(i,t,e,o)}}});var gu,yu=x(()=>{"use strict";Vr();hu();go();gu=(i,e,o)=>{let t=e[0].dims,r=e[1].dims,n=ke(t,r,o.dilations,o.pads,o.strides),s=i.run(du(i,e[0],e[1],n,o),[e[0]]),a=i.reshapePacked(e[1],[r[0],r[1]*r[2]*r[3]]),u=e.length===3?[a,s,e[2]]:[a,s],l=i.run(zr(i,u,o),u);return i.reshapePacked(l,n)}});var pd,dd,xu,yo,xo=x(()=>{"use strict";R();pd=i=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:i}),dd=(i,e,o,t,r,n)=>{let s=o.dims,a=t.dims,u=r.length,l=yo(s,a,r,4),f=`
+        const int XC = ${s[1]};
+        const int XH = ${s[2]};
+        const int XW = ${s[3]};
+        const int KH = ${n.kernelShape[0]};
+        const int KW = ${n.kernelShape[1]};
+        const int dilationH = ${n.dilations[0]};
+        const int dilationW = ${n.dilations[1]};
+        const int strideH = ${n.strides[0]};
+        const int strideW = ${n.strides[1]};
+        const int padH = ${n.pads[0]};
+        const int padW = ${n.pads[1]};
+        const int KHKW = KH*KW;
+        const int XCKHKW = XC * KHKW;
+        const int outputChannels = 4;
+        vec4 process(int indices[${u}]) {
+          int b  = indices[0]; // batch size
+          int oh = indices[1] * strideH - padH; //output height
+          int ow = indices[2] * strideW - padW; //output width
+          int p = indices[3] * outputChannels; //patch
+          vec4 value = vec4(0.0);
+          for(int i=0; i < outputChannels; ++i) {
+            if(p < XCKHKW) {
+              int patchC = p / KHKW;
+              int patchH = (p - patchC*KHKW) / KW;
+              int patchW = (p - patchC*KHKW) - patchH * KW;
+              int xh2 = oh + patchH * dilationH;
+              int xw2 = ow + patchW * dilationW;
+              int x[${s.length}];
+              x[0] = b;
+              x[1] = patchC;
+              x[2] = xh2;
+              x[3] = xw2;
+              if(xh2 >= 0 &&
+                  xh2 < XH &&
+                  xw2 >= 0 &&
+                  xw2 < XW) {
+                value[i] = _X(x);
+              }
+            }
+            ++p;
+          }
+          return value;
+        }
+        `;return{...e,output:{dims:l,type:o.type,textureType:4},shaderSource:f}},xu=(i,e,o,t,r)=>{let n=pd(r.cacheKey);return{...n,get:()=>dd(i,n,e,o,t,r)}},yo=(i,e,o,t=4)=>[o[0],o[2],o[3],Math.ceil(i[1]*e[2]*e[3]/t)]});var hd,md,Tu,wu=x(()=>{"use strict";U();X();R();be();xo();hd=(i,e)=>({name:"ConvDotProduct",inputNames:i?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:i?[0,4,0]:[0,4],cacheKey:e.activationCacheKey}),md=(i,e,o,t,r)=>{let n=o[0].dims,s=o[1].dims,a=[s[0],Math.ceil(n[1]*s[2]*s[3]/4)],u=yo(n,s,t),[l,f]=i.calculateTextureWidthAndHeight(a,4),c=A.computeStrides(u),[d,m]=i.calculateTextureWidthAndHeight(u,4),g=t.length,y=o.length<3?"0.0":"_B(b)",T=Math.ceil(n[1]*s[2]*s[3]/4),{activationFunction:_,applyActivation:w}=Ut(r),v=D(i.session.backend.glContext.version),L=`
+${_}
+float process(int indices[${g}]) {
+  int b[1];
+  b[0] = indices[1];
+  int im2col[4];
+  im2col[0] = indices[0];
+  im2col[1] = indices[2];
+  im2col[2] = indices[3];
+  int im2colOffset = im2col[0] * ${c[0]} + im2col[1] * ${c[1]} + im2col[2] * ${c[2]};
+  int kernelOffset = indices[1] * ${a[1]};
+  float value = ${y};
+  for (int i = 0; i < ${T}; ++i) {
+    vec2 im2colCoords = offsetToCoords(im2colOffset, ${d}, ${m});
+    vec2 kernelCoords = offsetToCoords(kernelOffset, ${l}, ${f});
+    value += dot(${v.texture2D}(Im2Col, im2colCoords), ${v.texture2D}(K, kernelCoords));
+    ++im2colOffset;
+    ++kernelOffset;
+  }
+  ${w}
+  return value;
+}`;return{...e,output:{dims:t,type:o[0].type,textureType:0},shaderSource:L}},Tu=(i,e,o,t)=>{let r=hd(e.length>2,t);return{...r,get:()=>md(i,r,e,o,t)}}});var ke,To,bd,gd,yd,xd,wo,Td,Vr=x(()=>{"use strict";at();U();pu();yu();wu();be();xo();Ur();ke=(i,e,o,t,r)=>{let n=i[0],s=i.slice(2),a=s.length,u=e[0],f=e.slice(2).map((g,y)=>g+(g-1)*(o[y]-1)),d=s.map((g,y)=>g+t[y]+t[y+a]).map((g,y)=>Math.floor((g-f[y]+r[y])/r[y]));return[n,u].concat(...d)},To=(i,e,o)=>(Td(e,o),bd(i,e,o)),bd=(i,e,o)=>{let t=xd(o,e),r=i.session.pack,n=t.kernelShape[0]===1&&t.kernelShape[1]===1;return t.group>1?[i.run(cu(i,e,t),e)]:n&&r?[gd(i,e,t)]:r&&e[0].dims.length===4&&e[0].dims[0]===1&&!n?[gu(i,e,t)]:[yd(i,e,t)]},gd=(i,e,o)=>{let t=e[0].dims,r=e[1].dims,n=ke(t,r,o.dilations,o.pads,o.strides),s=i.reshapeUnpacked(e[0],[t[1],t[2]*t[3]]),a=i.reshapeUnpacked(e[1],[r[0],r[1]]),u=e.length>2?[a,s,e[2]]:[a,s],l=i.run(mo(u,o),u);return i.reshapeUnpacked(l,n)},yd=(i,e,o)=>{let t=e[0].dims,r=e[1].dims,n=ke(t,r,o.dilations,o.pads,o.strides),s=i.run(xu(i,e[0],e[1],n,o),[e[0]]),a=e.length===3?[s,e[1],e[2]]:[s,e[1]];return i.run(Tu(i,e,n,o),a)},xd=(i,e)=>{let o=i.kernelShape.slice();if(i.kernelShape.length===0)for(let n=2;n<e[1].dims.length;++n)o.push(e[1].dims[n]);let t=i.pads.slice();ce.adjustPadsBasedOnAutoPad(e[0].dims,i.strides,i.dilations,o,t,i.autoPad);let r=Object.assign({},i);return Object.assign(r,{kernelShape:o,pads:t,cacheKey:i.cacheKey}),r},wo=i=>{let e=i.attributes,o=$e(e),t=e.getString("auto_pad","NOTSET"),r=e.getInts("dilations",[1,1]),n=e.getInt("group",1),s=e.getInts("kernel_shape",[]),a=e.getInts("pads",[0,0,0,0]),u=e.getInts("strides",[1,1]);return F({autoPad:t,dilations:r,group:n,kernelShape:s,pads:a,strides:u,...o})},Td=(i,e)=>{if(!i||i.length!==2&&i.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(i[0].dims.length!==4||i[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let o=i[0].dims[1],t=i[1].dims[1]*e.group;if(o!==t)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(i.length===3&&(i[2].dims.length!==1||i[1].dims[0]!==i[2].dims[0]))throw new Error("invalid bias");let r=i[0].dims.length-2;if(e.dilations.length!==r)throw new Error(`dilations should be ${r}D`);if(e.strides.length!==r)throw new Error(`strides should be ${r}D`);if(e.pads.length!==r*2)throw new Error(`pads should be ${r*2}D`);if(e.kernelShape.length!==0&&e.kernelShape.length!==i[1].dims.length-2)throw new Error("invalid kernel shape");if(i[0].type!=="float32"||i[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(i.length===3&&i[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}});var wd,vd,Id,vu,_d,Sd,Od,Ad,Pd,Ed,Iu,Dd,_u=x(()=>{"use strict";at();X();R();be();wd=(i,e,o,t,r,n)=>(i-1)*e+o+(t-1)*r+1-n,vd=(i,e,o,t,r)=>{let n=Math.floor(i/2);e==="SAME_UPPER"?(o[t]=n,o[r]=i-n):e==="SAME_LOWER"&&(o[t]=i-n,o[r]=n)},Id=(i,e,o,t,r,n,s,a)=>{let u=i.length-2,l=a.length===0;for(let f=0;f<u;++f){let c=l?i[f+2]*n[f]:a[f],d=wd(i[f+2],n[f],r[f],e[f],o[f],c);vd(d,t,r,f,f+u),l&&a.push(n[f]*(i[f+2]-1)+s[f]+(e[f]-1)*o[f]+1-r[f]-r[f+u])}},vu=(i,e,o)=>(Dd(e,o),_d(i,e,o)),_d=(i,e,o)=>{let t=Ed(o,e);return[Pd(i,e,t)]},Sd=(i,e)=>({name:"ConvTranspose",inputNames:i?["X","W","B"]:["X","W"],inputTypes:i?[0,0,0]:[0,0],cacheHint:e}),Od=(i,e,o,t)=>{let n=e.length>2?"getB(output_channel)":"0.0",s=e[0].dims,a=e[1].dims,u=a[1],l=a[0]/t.group,f=[e[0].dims[0],e[1].dims[1]*t.group,...t.outputShape],c=D(i.session.backend.glContext.version),{activationFunction:d,applyActivation:m}=Ut(t),g=`
+  const ivec2 strides = ivec2(${t.strides[0]}, ${t.strides[1]});
+  const ivec2 pads = ivec2(${t.pads[0]}, ${t.pads[1]});
+  ${d}
+  void main() {
+    ivec4 coords = getOutputCoords();
+    int batch = coords.x;
+    int output_channel = coords.y;
+
+    ivec2 loc = coords.zw + pads;
+
+    int group_id = output_channel / ${u};
+    int wOutChannel = output_channel - group_id * ${u};
+
+    float value = ${n};
+    for (int inChannelOffset = 0; inChannelOffset < ${l}; inChannelOffset++) {
+      int input_channel = group_id * ${l} + inChannelOffset;
+      for (int wWOff = 0; wWOff < ${a[2]}; wWOff++) {
+        for (int wHOff = 0; wHOff < ${a[3]}; wHOff++) {
+          ivec2 wOff = ivec2(wWOff * ${t.dilations[0]}, wHOff * ${t.dilations[1]});
+          ivec2 wLoc = loc - wOff;
+          ivec2 wLocIn = wLoc / strides;
+          if (
+            wLocIn * strides == wLoc &&
+            wLocIn.x >= 0 && wLocIn.x < ${s[2]} &&
+            wLocIn.y >= 0 && wLocIn.y < ${s[3]}
+          ) {
+            float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);
+            float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);
+            value += xVal * wVal;
+          }
+        }
+      }
+    }
+    ${m}
+    ${c.output} = vec4(value, .0, .0, .0);
+  }
+`;return{...o,output:{dims:f,type:e[0].type,textureType:0},shaderSource:g,hasMain:!0}},Ad=(i,e,o)=>{let t=Sd(e.length>2,o.cacheKey);return{...t,get:()=>Od(i,e,t,o)}},Pd=(i,e,o)=>i.run(Ad(i,e,o),e),Ed=(i,e)=>{let o=i.kernelShape.slice();if(i.kernelShape.length===0)for(let a=2;a<e[1].dims.length;++a)o.push(e[1].dims[a]);let t=i.pads.slice(),r=i.outputShape.slice(),n=e[0].dims;Id(n,o,i.dilations,i.autoPad,t,i.strides,i.outputPadding,r);let s=Object.assign({},i);return Object.assign(s,{kernelShape:o,pads:t,outputShape:r,cacheKey:i.cacheKey}),s},Iu=i=>{let e=i.attributes,o=$e(e),t=e.getString("auto_pad","NOTSET"),r=e.getInts("dilations",[1,1]),n=e.getInt("group",1),s=e.getInts("kernel_shape",[]),a=e.getInts("output_padding",[0,0]),u=e.getInts("output_shape",[]),l=e.getInts("pads",[0,0,0,0]),f=e.getInts("strides",[1,1]);return F({autoPad:t,dilations:r,group:n,kernelShape:s,outputPadding:a,outputShape:u,pads:l,strides:f,...o})},Dd=(i,e)=>{if(!i||i.length!==2&&i.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(i[0].dims.length!==4||i[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let o=i[0].dims[1],t=i[1].dims[0];if(o!==t)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let r=i[1].dims[1]*e.group;if(i.length===3&&(i[2].dims.length!==1||i[2].dims[0]!==r))throw new Error("invalid bias");let n=i[0].dims.length-2;if(e.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(e.strides.length!==n)throw new Error(`strides should be ${n}D`);if(e.pads.length!==n*2)throw new Error(`pads should be ${n*2}D`);if(e.outputPadding.length!==n)throw new Error(`output_padding should be ${n}D`);if(e.kernelShape.length!==0&&e.kernelShape.length!==i[1].dims.length-2)throw new Error("invalid kernel shape");if(e.outputShape.length!==0&&e.outputShape.length!==i[0].dims.length-2)throw new Error("invalid output shape");if(i[0].type!=="float32"||i[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(i.length===3&&i[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}});var Su,ge,Ou,Ld,Au,$d,kd,Bd,Wr=x(()=>{"use strict";at();U();R();Su={name:"Transpose",inputNames:["A"],inputTypes:[0]},ge=(i,e,o)=>(Bd(e),[i.run({...Su,cacheHint:o.cacheKey,get:()=>Ld(i,e[0],o.perm)},e)]),Ou=i=>F({perm:i.attributes.getInts("perm",[])}),Ld=(i,e,o)=>{let t=e.dims;o=Au(t,o);let r=$d(t,o),n=t.length,s=`
+      ${kd("perm",o,n)}
+      float process(int indices[${n}]) {
+        int a[${n}];
+        perm(a, indices);
+        return _A(a);
+      }`;return{...Su,output:{dims:r,type:e.type,textureType:0},shaderSource:s}},Au=(i,e)=>(e&&e.length!==i.length&&(e=[...i.keys()].reverse()),e),$d=(i,e)=>(e=Au(i,e),A.sortBasedOnPerm(i,e)),kd=(i,e,o)=>{let t=[];t.push(`void ${i}(out int a[${o}], int src[${o}]) {`);for(let r=0;r<o;++r)t.push(`	a[${e[r]}]=src[${r}];`);return t.push("	}"),t.join(`
+`)},Bd=i=>{if(!i||i.length!==1)throw new Error("Transpose requires 1 input.");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("input should be float tensor")}});var Pu,Eu,Fd,Du=x(()=>{"use strict";Wr();Pu=(i,e,o)=>{Fd(e);let t=o.blocksize,r=t*t,n=o.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],s=o.mode==="DCR"?[e[0].dims[0],t,t,e[0].dims[1]/r,e[0].dims[2],e[0].dims[3]]:[e[0].dims[0],e[0].dims[1]/r,t,t,e[0].dims[2],e[0].dims[3]],a=i.reshapeUnpacked(e[0],s),u={perm:n,cacheKey:`${n}`},[l]=ge(i,[a],u),f=[e[0].dims[0],e[0].dims[1]/r,e[0].dims[2]*t,e[0].dims[3]*t];return[i.reshapeUnpacked(l,f)]},Eu=i=>{let e=i.attributes.getInt("blocksize");if(e<1)throw new Error(`blocksize must be >= 1, but got : ${e} for DepthToSpace`);let o=i.attributes.getString("mode","DCR");if(o!=="DCR"&&o!=="CRD")throw new Error(`unrecognized mode: ${o} for DepthToSpace`);return{mode:o,blocksize:e}},Fd=i=>{if(i.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${i.length}`);if(i[0].type==="string"||i[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}});var Lu,$u,Nd,ku=x(()=>{"use strict";U();Lu=(i,e,o)=>{Nd(e,o);let t=A.flattenShape(e[0].dims,o);return[i.reshapeUnpacked(e[0],t)]},$u=i=>i.attributes.getInt("axis",1),Nd=(i,e)=>{if(!i||i.length!==1)throw new Error("Flatten requires 1 input.");let o=i[0].dims.length;if(o===0)throw new Error("scalar tensor is not supported.");if(e<-o||e>o)throw new Error("Invalid axis");if(i[0].type==="string")throw new Error("string tensor is not supported.")}});var ee,rr=x(()=>{"use strict";ee=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]});var Bu,Fu,Cd,Rd,Gd,Md,Nu=x(()=>{"use strict";at();rr();U();R();Bu=(i,e,o)=>(Md(e,o.axis),[i.run(Gd(i,e,o),e)]),Fu=i=>F({axis:i.attributes.getInt("axis",0)}),Cd={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},Rd=(i,e,o,t)=>{let r=o[0].dims.slice(),n=o[1].dims.slice(),s=new Array(r.length+n.length-1);t=A.normalizeAxis(t,r.length);let a=[];for(let d=0;d<s.length;d++)d<t?(s[d]=r[d],a.push(`inputIdx[${d}] = outputIdx[${d}];`)):d<t+n.length?(s[d]=n[d-t],a.push(`indexDataIdx[${d-t}] = outputIdx[${d}];`)):(s[d]=r[d-n.length+1],a.push(`inputIdx[${d-n.length+1}] = outputIdx[${d}];`));let u=s.length||1,l=r.length,f=n.length||1,c=`
+      float process(int outputIdx[${u}]) {
+        int inputIdx[${l}];
+        int indexDataIdx[${f}];
+        indexDataIdx[0] = 0;
+        ${a.join(`
+        `)}
+        int idx = int(_B(indexDataIdx));
+        inputIdx[${t}] = idx < 0 ? idx + ${r[t]} : idx;
+        return _A(inputIdx);
+      }`;return{...e,output:{dims:s,type:o[0].type,textureType:0},shaderSource:c}},Gd=(i,e,o)=>{let t={...Cd,cacheHint:o.cacheKey};return{...t,get:()=>Rd(i,t,e,o.axis)}},Md=(i,e)=>{if(!i||i.length!==2)throw new Error("Gather requires 2 inputs.");let o=i[0].dims.length;if(o<1)throw new Error("Invalid input shape.");if(e<-o||e>o-1)throw new Error("Invalid axis.");if(ee.indexOf(i[0].type)===-1)throw new Error("Invaid input type.");if(i[1].type!=="int32"&&i[1].type!=="int16")throw new Error("Invaid input type.")}});var vo,Cu,Ru,Gu,Vd,Ud,zd,Mu=x(()=>{"use strict";at();U();R();vo=(i,e,o)=>(zd(e,o),[i.run(Vd(e,o),e)]),Cu=(i,e)=>{let o=i.attributes.getInt("transA",0)!==0,t=i.attributes.getInt("transB",0)!==0,r=i.attributes.getFloat("alpha",1),n=i.attributes.getFloat("beta",1);return F({transA:o,transB:t,alpha:r,beta:n,isOptionalC:e})},Ru=i=>Cu(i,!1),Gu=i=>Cu(i,!0),Vd=(i,e)=>{let o={name:"Gemm",inputNames:i.length===3?["A","B","C"]:["A","B"],inputTypes:i.length===3?[0,0,0]:[0,0],key:e.cacheKey};return{...o,get:()=>Ud(o,i,e)}},Ud=(i,e,o)=>{let t=e[0].dims.slice(),r=e[1].dims.slice(),[n,s]=kr.getShapeOfGemmResult(t,o.transA,r,o.transB,e.length===3?e[2].dims:void 0),a=[n,s];if(!a)throw new Error("Can't use gemm on the given tensors");let u=t[t.length-1],l="";o.transA&&(u=t[0]),o.transA&&o.transB?l="value += _A_T(a) * _B_T(b);":o.transA&&!o.transB?l="value += _A_T(a) * _B(b);":!o.transA&&o.transB?l="value += _A(a) * _B_T(b);":!o.transA&&!o.transB&&(l="value += _A(a) * _B(b);");let f=a.length,c=e.length===3?`int c[${e[2].dims.length}];`:"",d=e.length===3?"bcastIndices_C(indices, c);":"",m=e.length===3?"value += beta * _C(c);":"",g=`
+      float process(int indices[${f}]) {
+          int a[${f}];
+          int b[${f}];
+          ${c}
+
+          copyVec(indices, a);
+          copyVec(indices, b);
+          ${d}
+
+          float value = 0.0;
+          for (int k=0; k<${u}; ++k) {
+              a[${f-1}] = k;
+              b[${f-2}] = k;
+              ${l}
+          }
+
+          value = value * alpha;
+          ${m}
+          return value;
+      }`;return{...i,output:{dims:a,type:e[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:o.alpha},{name:"beta",type:"float",data:o.beta}],shaderSource:g}},zd=(i,e)=>{if(!i)throw new Error("Input is missing");if(e.isOptionalC&&(i.length<2||i.length>3))throw new Error("Invaid input shape.");if(!e.isOptionalC&&i.length!==3)throw new Error("Gemm requires 3 inputs");if(i.length===3&&i[2].dims.length!==1&&i[2].dims.length!==2)throw new Error("Invalid input shape of C");if(i[0].type!=="float32"&&i[0].type!=="float64"||i[1].type!=="float32"&&i[1].type!=="float64"||i.length===3&&i[2].type!=="float32"&&i[2].type!=="float64")throw new Error("Invalid input type.");if(i[0].type!==i[1].type||i.length===3&&i[0].type!==i[2].type)throw new Error("Input types are mismatched")}});var Vu,Uu,Wd,Hd,qd,jd,Xd,zu=x(()=>{"use strict";at();R();Vu=(i,e,o)=>(Xd(e),[i.run(qd(i,e,o),e)]),Uu=i=>{let e=i.attributes.getFloat("scale"),o=i.attributes.getFloats("bias");return F({scale:e,bias:o})},Wd={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},Hd=(i,e,o,t)=>{let r=o[0].dims.slice(),n=r.length,a=`
+      ${jd(t.bias.length)}
+      float process(int indices[${n}]) {
+        return _X(indices) * scale + getBias(bias, indices[1]);
+      }`;return{...e,output:{dims:r,type:o[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:t.bias.length,data:t.bias},{name:"scale",type:"float",data:t.scale}],shaderSource:a}},qd=(i,e,o)=>{let t={...Wd,cacheHint:o.cacheKey};return{...t,get:()=>Hd(i,t,e,o)}},jd=i=>{let e=[`float getBias(float bias[${i}], int channel) {`];for(let o=0;o<i;++o)o===0?e.push(`	if (channel == ${o}) { return bias[${o}]; }`):o===i-1?e.push(`	else { return bias[${o}]; }`):e.push(`	else if (channel == ${o}) { return bias[${o}]; }`);return e.push("	}"),e.join(`
+`)},Xd=i=>{if(!i||i.length!==1)throw new Error("ImageScaler requires 1 input.");if(i[0].dims.length!==4)throw new Error("Invalid input shape.");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("Invalid input type.")}});var Hu,qu,Wu,Kd,Jd,Zd,Yd,Qd,th,ju=x(()=>{"use strict";X();R();Hu=(i,e,o)=>{th(e);let t=i.run(Jd(e[0]),e);return[i.run(Qd(i,e[0],o,t.dims),[e[0],t,e[1],e[2]])]},qu=i=>i.attributes.getFloat("epsilon",1e-5),Wu={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},Kd=(i,e)=>{let o=e.dims.slice(),t=o[1],r=o[2]*o[3],n=[o[0],t],s=`
+      vec4 process(int[2] indices) {
+        vec4 v = vec4(0.0);
+        int a[4];
+        a[0] = indices[0];
+        a[1] = indices[1];
+        float temp = 0.0;
+        for(int a2=0; a2<${o[2]}; a2++) {
+          a[2] = a2;
+          for(int a3=0; a3<${o[3]}; a3++) {
+            a[3] = a3;
+            float x = _X(a);
+            temp += x;
+          }
+        }
+        float mean = temp / float(${r});
+        temp = 0.0;
+        for(int a2=0; a2<${o[2]}; a2++) {
+          a[2] = a2;
+          for(int a3=0; a3<${o[3]}; a3++) {
+            a[3] = a3;
+            float x = _X(a);
+            temp += (x - mean) * (x - mean);
+          }
+        }
+        v.r = mean;
+        v.g = temp / float(${r});
+
+        return v;
+      }`;return{...i,output:{dims:n,type:e.type,textureType:4},shaderSource:s}},Jd=i=>({...Wu,get:()=>Kd(Wu,i)}),Zd={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},Yd=(i,e,o,t,r)=>{let n=D(i.session.backend.glContext.version),[s,a]=i.calculateTextureWidthAndHeight(r,4),[u,l]=[s/4,a],f=`
+      vec4 get_MeanAndVariance(int[2] mv) {
+        int offset = indicesToOffset_MeanAndVariance(mv);
+        vec2 coords = offsetToCoords(offset, ${u}, ${l});
+        return ${n.texture2D}(MeanAndVariance, coords);
+      }
+
+      float process(int[4] indices) {
+        int mv[2];
+        mv[0] = indices[0];
+        mv[1] = indices[1];
+        vec4 mean_and_variance = get_MeanAndVariance(mv);
+        float mean = mean_and_variance.r;
+        float variance = mean_and_variance.g;
+
+        int sb[1];
+        sb[0] = indices[1];
+        float scale = _Scale(sb);
+        float b = _B(sb);
+
+        return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
+      }`;return{...e,output:{dims:o.dims,type:o.type,textureType:0},variables:[{name:"epsilon",type:"float",data:t}],shaderSource:f}},Qd=(i,e,o,t)=>{let r={...Zd,cacheHint:`${o}`};return{...r,get:()=>Yd(i,r,e,o,t)}},th=i=>{if(!i||i.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let e=i[0],o=i[1],t=i[2];if(e.dims.length<3||o.dims.length!==1||t.dims.length!==1)throw new Error("Invalid input shape.");if(o.dims[0]!==e.dims[1]||t.dims[0]!==e.dims[1])throw new Error("Input shapes are mismatched.");if(e.type!=="float32"&&e.type!=="float64"||o.type!=="float32"&&o.type!=="float64"||t.type!=="float32"&&t.type!=="float64")throw new Error("Invalid input type.");if(i[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function eh(i,e){let o=i[0].dims[1],t=i[0].dims.length,r=-Math.floor((e.size-1)/2),n=Math.ceil((e.size-1)/2),s=`float(${e.alpha}) / float(${e.size})`,a=`float(${e.bias})`,u=`float(${e.beta})`,l=`
+    float process(int indices[${t}]) {
+        int c = indices[1];
+        float x = _X(indices);
+        float square_sum = 0.0;
+
+        for (int i = ${r}; i <= ${n}; i++) {
+          int idx = c + i;
+          if (c >= 0 && c < ${o}) {
+            indices[1] = idx;
+            float j = _X(indices);
+            square_sum += j * j;
+          }
+        }
+        return x / pow(${a} + ${s} * square_sum, ${u});
+    }`;return{...Ju,cacheHint:e.cacheKey,output:{dims:i[0].dims,type:i[0].type,textureType:0},shaderSource:l}}function rh(i,e){return{...Ju,cacheHint:e.cacheKey,get:()=>eh(i,e)}}var Xu,Ku,Ju,nh,Zu=x(()=>{"use strict";at();R();Xu=(i,e,o)=>(nh(e),[i.run(rh(e,o),e)]),Ku=i=>{let e=i.attributes.getFloat("alpha",1e-4),o=i.attributes.getFloat("beta",.75),t=i.attributes.getFloat("bias",1),r=i.attributes.getInt("size");return F({alpha:e,beta:o,bias:t,size:r})},Ju={name:"LRN",inputNames:["X"],inputTypes:[0]};nh=i=>{if(!i||i.length!==1)throw new Error("LRN requires 1 input.");if(i[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(i[0].type!=="float32")throw new Error("input should be float type")}});var oh,Io,Yu,Qu,tl,ih,ah,sh,uh,lh,fh,ch,ph,el=x(()=>{"use strict";at();U();X();R();oh={name:"Pad",inputNames:["A"],inputTypes:[0]},Io=(i,e,o)=>(sh(e),[i.run({...oh,cacheHint:o.cacheKey,get:()=>ah(i,e[0],o)},e)]),Yu=i=>{let e=i.attributes.getString("mode","constant"),o=i.attributes.getFloat("value",0),t=i.attributes.getInts("pads");return F({mode:e,value:o,pads:t})},Qu=(i,e,o)=>{uh(e);let t=ih(i,e,o);return Io(i,[e[0]],t)},tl=i=>i.attributes.getString("mode","constant"),ih=(i,e,o)=>{if(!i.session.isInitializer(e[1].dataId)||e.length>=3&&!i.session.isInitializer(e[2].dataId))throw new Error("dynamic pad attributes are not allowed");let t=Array.from(e[1].integerData),r=e.length>=3?e[2].floatData[0]:0;return F({mode:o,pads:t,value:r})},ah=(i,e,o)=>{let t=A.padShape(e.dims.slice(),o.pads),r=t.length,s=`
+      ${lh(i,e,o)}
+      float process(int[${r}] indices) {
+          return padA(indices);
+      }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:t,type:e.type,textureType:0},shaderSource:s}},sh=i=>{if(!i||i.length!==1)throw new Error("Pad requires 1 input");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("Invalid input type.")},uh=i=>{if(!i||i.length!==2&&i.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(i[1].type!=="int32")throw new Error("Invalid input type.");if(i.length>=3&&i[2].type==="string")throw new Error("Invalid input type.")},lh=(i,e,o)=>{let t=D(i.session.backend.glContext.version),[r,n]=i.calculateTextureWidthAndHeight(e.dims,0),s=A.computeStrides(e.dims);switch(o.mode){case"constant":return fh(t,e.dims,s,r,n,o.pads,o.value);case"reflect":return ch(t,e.dims,s,r,n,o.pads);case"edge":return ph(t,e.dims,s,r,n,o.pads);default:throw new Error("Invalid mode")}},fh=(i,e,o,t,r,n,s)=>{let a=e.length,u="";for(let l=a-1;l>=0;--l)u+=`
+        k = m[${l}] - ${n[l]};
+        if (k < 0)  return constant;
+        if (k >= ${e[l]}) return constant;
+        offset += k * ${o[l]};
+        `;return`
+      float padA(int m[${a}]) {
+        const float constant = float(${s});
+        int offset = 0;
+        int k = 0;
+        ${u}
+        vec2 coords = offsetToCoords(offset, ${t}, ${r});
+        float value = getColorAsFloat(${i.texture2D}(A, coords));
+        return value;
+      }
+      `},ch=(i,e,o,t,r,n)=>{let s=e.length,a="";for(let u=s-1;u>=0;--u)a+=`
+        k = m[${u}] - ${n[u]};
+        if (k < 0) { k = -k; }
+        {
+          const int _2n_1 = ${2*(e[u]-1)};
+          k = int( mod( float(k), float(_2n_1) ) ) ;
+          if(k >= ${e[u]}) { k = _2n_1 - k; }
+        }
+        offset += k * ${o[u]};
+        `;return`
+      float padA(int m[${s}]) {
+        int offset = 0;
+        int k = 0;
+        ${a}
+        vec2 coords = offsetToCoords(offset, ${t}, ${r});
+        float value = getColorAsFloat(${i.texture2D}(A, coords));
+        return value;
+      }
+      `},ph=(i,e,o,t,r,n)=>{let s=e.length,a="";for(let u=s-1;u>=0;--u)a+=`
+        k = m[${u}] - ${n[u]};
+        if (k < 0)  k = 0;
+        if (k >= ${e[u]}) k = ${e[u]-1};
+        offset += k * ${o[u]};
+      `;return`
+      float padA(int m[${s}]) {
+        int offset = 0;
+        int k = 0;
+        ${a}
+        vec2 coords = offsetToCoords(offset, ${t}, ${r});
+        float value = getColorAsFloat(${i.texture2D}(A, coords));
+        return value;
+      }
+      `}});var nl,ol,il,al,sl,ul,ll,fl,cl,dh,rl,pl,qr,dl,Hr,hh,hl=x(()=>{"use strict";at();U();R();nl=(i,e,o)=>{qr(e);let t={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:o.cacheKey};return[i.run({...t,get:()=>il(e,t,!1,o)},e)]},ol=i=>{let e=i.attributes.getString("auto_pad","NOTSET"),o=i.attributes.getInt("ceil_mode",0),t=i.attributes.getInt("count_include_pad",0)!==0,r=i.attributes.getInts("kernel_shape"),n=i.attributes.getInts("strides",[]),s=i.attributes.getInts("pads",[]);if(o!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return F({autoPad:e,ceilMode:o,countIncludePad:t,kernelShape:r,strides:n,pads:s})},il=(i,e,o,t)=>{let[r,n]=cl(i,t,o),s=A.size(r.kernelShape),a="value += _X(x);",u="";r.countIncludePad?u+=`value /= float(${s});`:u+=`value /= float(${s} - pad);`;let f=`
+        ${dl(i[0].dims,r,a,u,"0.0")}
+      `;return{...e,output:{dims:n,type:i[0].type,textureType:0},shaderSource:f}},al=(i,e,o)=>{qr(e);let t={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${o.countIncludePad}`};return[i.run({...t,get:()=>il(e,t,!0,o)},e)]},sl=i=>{let e=i.attributes.getInt("count_include_pad",0)!==0;return F({autoPad:"",ceilMode:0,countIncludePad:e,kernelShape:[],strides:[],pads:[]})},ul=(i,e,o)=>{qr(e);let t={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:o.cacheKey};return[i.run({...t,get:()=>fl(e,t,!1,o)},e)]},ll=i=>{let e=i.attributes.getString("auto_pad","NOTSET"),o=i.attributes.getInt("ceil_mode",0),t=i.attributes.getInts("kernel_shape"),r=i.attributes.getInts("strides",[]),n=i.attributes.getInts("pads",[]),s=i.attributes.getInt("storage_order",0),a=i.attributes.getInts("dilations",[]);if(s!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(o!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return F({autoPad:e,ceilMode:o,countIncludePad:!1,kernelShape:t,strides:r,pads:n,storageOrder:s,dilations:a})},fl=(i,e,o,t)=>{let[r,n]=cl(i,t,o),s=`
+      value = max(_X(x), value);
+    `,a="",l=`
+      ${dl(i[0].dims,r,s,a,"-1e5")}
+    `;return{...e,output:{dims:n,type:i[0].type,textureType:0},shaderSource:l}},cl=(i,e,o)=>{let t=i[0].dims.slice(),r=Object.hasOwnProperty.call(e,"dilations"),n=e.kernelShape.slice(),s=e.strides.slice(),a=r?e.dilations.slice():[],u=e.pads.slice();ce.adjustPoolAttributes(o,t,n,s,a,u);let l=ce.computePoolOutputShape(o,t,s,a,n,u,e.autoPad),f=Object.assign({},e);return r?Object.assign(f,{kernelShape:n,strides:s,pads:u,dilations:a,cacheKey:e.cacheKey}):Object.assign(f,{kernelShape:n,strides:s,pads:u,cacheKey:e.cacheKey}),[f,l]},dh={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},rl={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},pl=(i,e)=>(qr(e),[i.run({...rl,get:()=>fl(e,rl,!0,dh)},e)]),qr=i=>{if(!i||i.length!==1)throw new Error("Pool ops requires 1 input.");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("Invalid input type.")},dl=(i,e,o,t,r)=>{let n=i.length;if(e.kernelShape.length<=2){let s=e.kernelShape[e.kernelShape.length-1],a=e.strides[e.strides.length-1],u=e.pads[e.pads.length/2-1],l=e.pads[e.pads.length-1],f=i[n-1],c="",d="",m="";if(u+l!==0?c=`
+          for (int i = 0; i < ${s}; i++) {
+            x[${n} - 1] = indices[${n} - 1] * ${a} - ${u} + i;
+            if (x[${n} - 1] < 0 || x[${n} - 1] >= ${f}) {
+              pad++;
+              continue;
+            }
+            ${o}
+          }`:c=`
+          for (int i = 0; i < ${s}; i++) {
+            x[${n} - 1] = indices[${n} - 1] * ${a} - ${u} + i;
+            ${o}
+          }`,e.kernelShape.length===2){let y=e.kernelShape[e.kernelShape.length-2],T=e.strides[e.strides.length-2],_=e.pads[e.pads.length/2-2],w=e.pads[e.pads.length-2],v=i[n-2];_+w!==0?d=`
+            for (int j = 0; j < ${y}; j++) {
+              x[${n} - 2] = indices[${n} - 2] * ${T} - ${_} + j;
+              if (x[${n} - 2] < 0 || x[${n} - 2] >= ${v}) {
+                pad+= ${s};
+                continue;
+              }
+          `:d=`
+            for (int j = 0; j < ${y}; j++) {
+              x[${n} - 2] = indices[${n} - 2] * ${T} - ${_} + j;
+            `,m=`
+          }
+        `}return`
+        float process(int indices[${n}]) {
+          int x[${n}];
+          copyVec(indices, x);
+
+          float value = ${r};
+          int pad = 0;
+          ${d}
+          ${c}
+          ${m}
+          ${t}
+          return value;
+        }
+      `}else{let s=A.size(e.kernelShape),a=A.computeStrides(e.kernelShape),u=a.length,l=e.pads.length,f=hh(u),c=Hr(i,"inputDims"),d=Hr(e.pads,"pads"),m=Hr(a,"kernelStrides"),g=Hr(e.strides,"strides"),y=e.pads.reduce((w,v)=>w+v),T="";return y?T=`
+            if (x[j] >= inputDims[j] || x[j] < 0) {
+              pad++;
+              isPad = true;
+              break;
+            }
+          }
+          if (!isPad) {
+            ${o}
+          }`:T=`
+          }
+          ${o}
+        `,`
+        ${f}
+        float process(int indices[${n}]) {
+          int x[${n}];
+          copyVec(indices, x);
+          int offset[${u}];
+          int pads[${l}];
+          int inputDims[${n}];
+          int kernelStrides[${u}];
+          int strides[${u}];
+          ${d}
+          ${c}
+          ${g}
+          ${m}
+
+          float value = ${r};
+          int pad = 0;
+          bool isPad = false;
+          for (int i = 0; i < ${s}; i++) {
+            offsetToIndices(i, kernelStrides, offset);
+            isPad = false;
+            for (int j = ${n} - ${u}; j < ${n}; j++) {
+              x[j] = indices[j] * strides[j - ${n} + ${u}]
+                + offset[j - ${n} + ${u}] - pads[j - 2];
+              ${T}
+          }
+          ${t}
+
+          return value;
+        }
+      `}},Hr=(i,e)=>{let o="";for(let t=0;t<i.length;t++)o+=`
+      ${e}[${t}] = ${i[t]};
+    `;return o},hh=i=>`
+  void offsetToIndices(int offset, int[${i}] strides, out int[${i}] indices) {
+    if (${i} == 0) {
+      return;
+    }
+    for (int i = 0; i < ${i} - 1; ++i) {
+      indices[i] = offset / strides[i];
+      offset -= indices[i] * strides[i];
+    }
+    indices[${i} - 1] = offset;
+  }`});var ye,re,mh,bh,ml,bl,gl,yl,xl,Tl,wl,vl=x(()=>{"use strict";at();rr();U();R();ye=(i,e,o,t,r)=>{bh(e);let n={name:t,inputNames:["A"],inputTypes:[0]};return[i.run({...n,cacheHint:o.cacheKey,get:()=>mh(i,e,o,t,r,n)},e)]},re=i=>{let e=i.attributes.getInts("axes",[]),o=i.attributes.getInt("keepdims",1)===1;return F({axes:e,keepDims:o})},mh=(i,e,o,t,r,n)=>{let s=[],a=e[0].dims.length||1,u=[],l=A.normalizeAxes(o.axes,e[0].dims.length),f=r(e,l),c=f[1];for(let g=0;g<e[0].dims.length;g++)l.indexOf(g)>=0||l.length===0?(o.keepDims&&s.push(1),c=`
+          for(int j${g} = 0; j${g} < ${e[0].dims[g]}; j${g}++) {
+            inputIdx[${g}] = j${g};
+            ${c}
+          }`):(u.push(`inputIdx[${g}] = outputIdx[${s.length}];`),s.push(e[0].dims[g]));let m=`
+      float process(int outputIdx[${s.length||1}]) {
+        float value;                 // final result
+        int inputIdx[${a}];      // addressing input data
+        ${u.join(`
+`)}
+        ${f[0]}       // init ops for reduce max/min
+        ${c}
+        ${f[2]}       // final computation for reduce mean
+        return value;
+      }`;return{...n,output:{dims:s,type:e[0].type,textureType:0},shaderSource:m}},bh=i=>{if(!i||i.length!==1)throw new Error("Reduce op requires 1 input.");if(ee.indexOf(i[0].type)===-1)throw new Error("Invalid input type.")},ml=(i,e,o)=>ye(i,e,o,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),bl=(i,e,o)=>ye(i,e,o,"ReduceMean",(r,n)=>{let s=1;for(let a=0;a<r[0].dims.length;a++)(n.indexOf(a)>=0||n.length===0)&&(s*=r[0].dims[a]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${s}.;`]}),gl=(i,e,o)=>ye(i,e,o,"ReduceMax",(r,n)=>{let s=[];for(let a=0;a<r[0].dims.length;a++)(n.indexOf(a)>=0||n.length===0)&&s.push(`inputIdx[${a}] = 0;`);return[`${s.join(`
+`)}
+value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),yl=(i,e,o)=>ye(i,e,o,"ReduceMin",(r,n)=>{let s=[];for(let a=0;a<r[0].dims.length;a++)(n.indexOf(a)>=0||n.length===0)&&s.push(`inputIdx[${a}] = 0;`);return[`${s.join(`
+`)}
+value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),xl=(i,e,o)=>ye(i,e,o,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),Tl=(i,e,o)=>ye(i,e,o,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),wl=(i,e,o)=>ye(i,e,o,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])});var Il,_l=x(()=>{"use strict";U();Il=(i,e)=>{let o=A.calculateReshapedDims(e[0].dims,e[1].integerData);return i.session.pack?[i.reshapePacked(e[0],o)]:[i.reshapeUnpacked(e[0],o)]}});var Sl,_o,Ol,Al,nr,gh,So,jr,Oo=x(()=>{"use strict";at();X();R();Sl={name:"Upsample",inputNames:["X"],inputTypes:[0]},_o=(i,e,o)=>(So(e,o),[i.run({...Sl,cacheHint:o.cacheKey,get:()=>gh(i,e,o)},e)]),Ol=i=>nr(i,7),Al=i=>nr(i,9),nr=(i,e)=>{let o=e>=10,t=i.attributes.getString("mode","nearest");if(t!=="nearest"&&t!=="linear"&&(e<11||t!=="cubic"))throw new Error(`unrecognized mode: ${t}`);let r=[];e<9&&(r=i.attributes.getFloats("scales"),jr(r,t,o));let n=i.attributes.getFloat("extrapolation_value",0),s=e>10?i.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(s)===-1)throw new Error(`coordinate_transform_mode '${s}' is not supported`);let a=s==="tf_crop_and_resize",u=a,l=t==="nearest"&&e>=11?i.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(l)===-1)throw new Error(`nearest_mode '${l}' is not supported`);let f=i.attributes.getFloat("cubic_coeff_a",-.75),c=i.attributes.getInt("exclude_outside",0)!==0;if(c&&t!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let d=e<11?!0:t==="nearest"&&s==="asymmetric"&&l==="floor",m=0,g=0,y=0;return e>10?i.inputs.length>2?(m=1,g=2,y=3):(g=1,y=2):e===9&&(g=1),F({opset:e,isResize:o,mode:t,scales:r,extrapolationValue:n,coordinateTransformMode:s,useExtrapolation:u,needRoiInput:a,nearestMode:l,cubicCoefficientA:f,excludeOutside:c,useNearest2xOptimization:d,roiInputIdx:m,scalesInputIdx:g,sizesInputIdx:y})},gh=(i,e,o)=>{let t=D(i.session.backend.glContext.version),[r,n]=i.calculateTextureWidthAndHeight(e[0].dims,0),s=e[0].dims.map((y,T)=>Math.floor(y*o.scales[T])),[a,u]=i.calculateTextureWidthAndHeight(s,0),l=s.length,f=new Array(l),c=new Array(l),d=`
+      int output_pitches[${l}];
+      int input_pitches[${l}];
+      `;for(let y=l-1;y>=0;y--)f[y]=y===l-1?1:f[y+1]*s[y+1],c[y]=y===l-1?1:c[y+1]*e[0].dims[y+1],d+=`
+        output_pitches[${y}] = ${f[y]};
+        input_pitches[${y}] = ${c[y]};
+        `;let m=`
+      float getInputFloat(int index) {
+        vec2 coords = offsetToCoords(index, ${r}, ${n});
+        float value = getColorAsFloat(${t.texture2D}(X, coords));
+        return value;
+      }
+      `,g=o.mode==="nearest"?`
+    ${m}
+    float process(int indices[${l}]) {
+      int input_index = 0;
+      int output_index = coordsToOffset(TexCoords, ${a}, ${u});
+
+      ${d}
+
+      int d, m;
+      for (int dim = 0; dim < ${l}; ++dim) {
+        d = output_index / output_pitches[dim];
+        m = output_index - d * output_pitches[dim];
+        output_index = m;
+
+        if (scales[dim] != 1 && d > 0) {
+          int d2 = d / scales[dim];
+          m = d - d2 * scales[dim];
+          d = d2;
+        }
+        input_index += input_pitches[dim] * d;
+      }
+
+      return getInputFloat(input_index);
+    }`:l===4?`
+    ${m}
+    float process(int indices[4]) {
+      int input_index = 0;
+      int output_index = coordsToOffset(TexCoords, ${a}, ${u});
+
+      ${d}
+
+      int m;
+      int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
+      index_of_dim0 = output_index / output_pitches[0];
+      m = output_index - index_of_dim0 * output_pitches[0];
+      index_of_dim1 = m / output_pitches[1];
+      m = m - index_of_dim1 * output_pitches[1];
+      index_of_dim2 = m / output_pitches[2];
+      m = m - index_of_dim2 * output_pitches[2];
+      index_of_dim3 = m;
+
+      int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;
+      index_of_input_dim2 = index_of_dim2 / scales[2];
+      y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];
+      index_of_input_dim3 = index_of_dim3 / scales[3];
+      x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];
+
+      input_index = index_of_dim0 * input_pitches[0] +
+            index_of_dim1 * input_pitches[1] +
+            index_of_input_dim2 * input_pitches[2] +
+            index_of_input_dim3;
+
+      float x00 = getInputFloat(input_index);
+      float x10, x01, x11;
+
+      bool end_of_dim2 = false;
+      if (index_of_input_dim2 == (${e[0].dims[2]} - 1)) {
+        // It's the end in dimension 2
+        x01 = x00;
+        end_of_dim2 = true;
+      } else {
+        x01 = getInputFloat(input_index + input_pitches[2]);
+      }
+
+      if (index_of_input_dim3 == (input_pitches[2] - 1)) {
+        // It's the end in dimension 3
+        x10 = x00;
+        x11 = x01;
+      }
+      else {
+        x10 = getInputFloat(input_index + 1);
+        x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);
+      }
+
+      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);
+      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
+      return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
+    }`:`
+    ${m}
+    float process(int indices[2]) {
+      int input_index = 0;
+      int output_index = coordsToOffset(TexCoords, ${a}, ${u});
+
+      ${d}
+
+      int m;
+      int index_of_dim0, index_of_dim1;
+      index_of_dim0 = output_index / output_pitches[0];
+      m = output_index - index_of_dim0 * output_pitches[0];
+      index_of_dim1 = m;
+
+      int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;
+      index_of_input_dim0 = index_of_dim0 / scales[0];
+      y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];
+      index_of_input_dim1 = index_of_dim1 / scales[1];
+      x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];
+
+      input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;
+
+      float x00 = getInputFloat(input_index);
+      float x10, x01, x11;
+
+      bool end_of_dim0 = false;
+      if (index_of_input_dim0 == (${e[0].dims[0]} - 1)) {
+        // It's the end in dimension 0
+        x01 = x00;
+        end_of_dim0 = true;
+      } else {
+        x01 = getInputFloat(input_index + input_pitches[0]);
+      }
+
+      if (index_of_input_dim1 == (input_pitches[0] - 1)) {
+        // It's the end in dimension 1
+        x10 = x00;
+        x11 = x01;
+      }
+      else {
+        x10 = getInputFloat(input_index + 1);
+        x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);
+      }
+
+      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
+      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
+      return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
+    }`;return{...Sl,output:{dims:s,type:e[0].type,textureType:0},shaderSource:g,variables:[{name:"scales",type:"int",arrayLength:o.scales.length,data:o.scales.map(y=>Math.ceil(y))}]}},So=(i,e)=>{if(!i||e.opset<9&&i.length!==1||e.opset>=9&&e.opset<11&&i.length!==2||e.opset>=11&&i.length<2)throw new Error("invalid inputs.");if(e.scales.length>0&&i[0].dims.length!==e.scales.length)throw new Error("Invalid input shape.");if(i[0].type==="string")throw new Error("Invalid input tensor types.")},jr=(i,e,o)=>{if(o){for(let t of i)if(t<=0)throw new Error("Scale value should be greater than 0.")}else for(let t of i)if(t<1)throw new Error("Scale value should be greater than or equal to 1.");if((e==="linear"||e==="cubic")&&i.length!==2&&(i.length!==4||i[0]!==1||i[1]!==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 ${o?"Resize":"Upsample"} opeartor.`)}});var Ao,Po,Pl,El,yh,xh,Th,wh,Dl=x(()=>{"use strict";X();R();Mt();me();Oo();Ao={name:"Resize",inputNames:["A"],inputTypes:[2]},Po=(i,e,o)=>(So(e,o),[i.run({...Ao,cacheHint:o.cacheKey,get:()=>yh(i,e,o)},e)]),Pl=i=>nr(i,10),El=i=>nr(i,11),yh=(i,e,o)=>{let t=D(i.session.backend.glContext.version),[r,n]=xh(e,o);if(r.every(v=>v===1)&&o.coordinateTransformMode!=="tf_crop_and_resize")return{...Ao,output:{dims:n,type:e[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
+                    vec4 v = ${t.texture2D}(X, TexCoords);
+                    ${t.output} = v;
+                }`};let a=n.length;if(a<2)throw new Error(`output dimension should be at least 2, but got ${a}`);let u=n[a-2],l=n[a-1],f=e[0].dims;if(a!==f.length)throw new Error(`output dimension should match input ${f.length}, but got ${a}`);let c=f[a-2],d=f[a-1],m=r[a-2],g=r[a-1],y="";if(o.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${o.mode}'`);switch(o.coordinateTransformMode){case"asymmetric":y=`
+                    vec4 getSourceFracIndex(ivec4 coords) {
+                        return vec4(coords) / scaleWHWH;
+                    }
+                `;break;case"half_pixel":y=`
+                    vec4 getSourceFracIndex(ivec4 coords) {
+                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
+                    }
+                `;break;case"pytorch_half_pixel":y=`
+                    vec4 getSourceFracIndex(ivec4 coords) {
+                        vec4 fcoords = vec4(coords);
+                        return vec4(
+                            ${l}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
+                            ${u}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
+                            ${l}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
+                            ${u}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
+                          );
+                    }
+                `;break;case"align_corners":y=`
+                    vec4 getSourceFracIndex(ivec4 coords) {
+                        vec4 resized = vec4(${l}.0 - 1.0, ${u}.0 - 1.0, ${l}.0 - 1.0,
+                            ${u}.0 - 1.0);
+                        vec4 original = vec4(${d}.0 - 1.0, ${c}.0 - 1.0, ${d}.0 - 1.0,
+                            ${c}.0 - 1.0);
+                        vec4 new_scale = original / resized;
+                        return vec4(coords) * new_scale;
+                    }
+                `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode:                                 '${o.coordinateTransformMode}'`)}let T=pt(a),_=Vt(),w=`
+            const vec2 inputWH = vec2(${c}.0, ${d}.0);
+            const vec4 scaleWHWH = vec4(float(${m}), float(${g}), float(${m}), float(${g}));
+            ${_}
+            ${y}
+            float getAValue(int x10, int r, int c, int d) {
+                return getChannel(getA(x10, r, c, d), vec2(c, d));
+            }
+            void main() {
+                ${T} rc = getOutputCoords();
+
+                int batch = rc[0];
+                int depth = rc[1];
+
+                // retrieve the 4 coordinates that is used in the 4 packed output values.
+                ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);
+
+                // calculate the source index in fraction
+                vec4 sourceFrac = getSourceFracIndex(coords);
+
+                // get the lower and upper bound of the 4 values that will be packed into one texel.
+                ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));
+                ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));
+                ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
+                ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));
+
+                bool hasNextRow = rc.w < ${u-1};
+                bool hasNextCol = rc.z < ${l-1};
+
+                // pack x00, x01, x10, x11's top-left corner into one vec4 structure
+                vec4 topLeft = vec4(
+                    getAValue(batch, depth, x00.x, x00.y),
+                    hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,
+                    hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,
+                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);
+
+                // pack x00, x01, x10, x11's top-right corner into one vec4 structure
+                vec4 topRight = vec4(
+                    getAValue(batch, depth, x00.x, x00.w),
+                    hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,
+                    hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,
+                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);
+
+                // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure
+                vec4 bottomLeft = vec4(
+                    getAValue(batch, depth, x00.z, x00.y),
+                    hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,
+                    hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,
+                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);
+
+                // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure
+                vec4 bottomRight = vec4(
+                    getAValue(batch, depth, x00.z, x00.w),
+                    hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,
+                    hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,
+                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);
+
+                // calculate the interpolation fraction on u and v direction
+                vec4 frac = vec4(sourceFrac) - floor(sourceFrac);
+                vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));
+
+                vec4 top = mix(topLeft, topRight, clampFrac.ywyw);
+                vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);
+                vec4 newValue = mix(top, bottom, clampFrac.xxzz);
+
+                ${t.output} = vec4(newValue);
+            }
+        `;return{...Ao,output:{dims:n,type:e[0].type,textureType:2},hasMain:!0,shaderSource:w}},xh=(i,e)=>{let t=i[0].dims,r=e.scales,n;if(r.length===0){let a=i[e.scalesInputIdx];if(a&&a.size!==0){if(i[e.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");r=Th(a,e.mode,e.isResize)}else{let u=i[e.sizesInputIdx];if(!u||u.size===0)throw new Error("Either scales or sizes MUST be provided as input.");n=Array.from(u.integerData),r=wh(n,t,e.mode,e.isResize)}}else if(i[e.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let s=n||t.map((a,u)=>Math.floor(a*r[u]));return[r,s]},Th=(i,e,o)=>{let t=Array.from(i.floatData);return jr(t,e,o),t},wh=(i,e,o,t)=>{let r=e.length,n=new Array(r);for(let s=0,a=r;s<a;s++)if(e[s]===0){if(i[s]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");n[s]=1}else n[s]=i[s]/e[s];return jr(n,o,t),n}});var Ll,vh,$l=x(()=>{"use strict";he();Ll=(i,e)=>(vh(e),[new et([e[0].dims.length],"int32",void 0,void 0,new Int32Array(e[0].dims))]),vh=i=>{if(!i||i.length!==1)throw new Error("Shape requires 1 input.")}});var Eo,kl,Bl,Fl,Ih,Nl,_h,Sh,Cl=x(()=>{"use strict";at();rr();U();R();Eo={name:"Slice",inputNames:["A"],inputTypes:[0]},kl=(i,e,o)=>(Ih(e),[i.run({...Eo,cacheHint:o.cacheKey,get:()=>Fl(i,e[0],o)},e)]),Bl=i=>{let e=i.attributes.getInts("starts"),o=i.attributes.getInts("ends"),t=i.attributes.getInts("axes",[]);return F({starts:e,ends:o,axes:t})},Fl=(i,e,o)=>{let t=o.axes.length===0?e.dims.slice(0).map((c,d)=>d):o.axes,r=A.normalizeAxes(t,e.dims.length),n=o.starts.map((c,d)=>c>e.dims[r[d]]-1?e.dims[r[d]]:A.normalizeAxis(c,e.dims[r[d]])),s=o.ends.map((c,d)=>c>e.dims[r[d]]-1?e.dims[r[d]]:A.normalizeAxis(c,e.dims[r[d]])),a=e.dims.slice(),u=[];for(let c=0;c<r.length;c++)a[r[c]]=s[c]-n[c],n[c]>0&&u.push(`outputIdx[${r[c]}] += ${n[c]};`);let f=`
+      float process(int outputIdx[${a.length}]) {
+        ${u.join(`
+      `)}
+        return _A(outputIdx);
+      }`;return{...Eo,output:{dims:a,type:e.type,textureType:0},shaderSource:f}},Ih=i=>{if(!i||i.length!==1)throw new Error("Slice requires 1 input.");if(ee.indexOf(i[0].type)===-1)throw new Error("Invalid input type.")},Nl=(i,e)=>{Sh(e);let o=_h(i,e);return[i.run({...Eo,cacheHint:o.cacheKey,get:()=>Fl(i,e[0],o)},[e[0]])]},_h=(i,e)=>{if(!i.session.isInitializer(e[1].dataId)||!i.session.isInitializer(e[2].dataId)||e.length>=4&&!i.session.isInitializer(e[3].dataId)||e.length>=5&&!i.session.isInitializer(e[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(e.length>=5&&e[4].integerData.some(s=>s!==1))throw new Error("currently non-1 steps is not supported for Slice");let o=Array.from(e[1].integerData),t=Array.from(e[2].integerData),r=e.length>=4?Array.from(e[3].integerData):[],n=`${r};${o};${t}`;return{starts:o,ends:t,axes:r,cacheKey:n}},Sh=i=>{if(!i||i.length<3||i.length>5)throw new Error("Invalid input number.");if(i[1].type!=="int32"||i[1].dims.length!==1)throw new Error("Invalid input type.");if(i[2].type!=="int32"||i[2].dims.length!==1)throw new Error("Invalid input type.");if(i.length>=4&&(i[3].type!=="int32"||i[3].dims.length!==1))throw new Error("Invalid input type.");if(i.length>=5&&(i[4].type!=="int32"||i[4].dims.length!==1))throw new Error("Invalid input type.")}});var Rl,Gl,Ml,Vl,Ul,zl,Wl,Hl,Oh,Ah,Ph,ql,jl=x(()=>{"use strict";at();U();X();R();Wr();Rl={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Gl={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Ml={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Vl=(i,e,o)=>{ql(e);let t=e[0].dims.slice(),r=A.normalizeAxis(o.axis,t.length),n=A.sizeToDimension(t,r),s=A.sizeFromDimension(t,r);return Hl(i,e,o,n,s)},Ul=i=>F({axis:i.attributes.getInt("axis",1)}),zl=i=>F({axis:i.attributes.getInt("axis",-1)}),Wl=(i,e,o)=>{ql(e);let t=e[0].dims.slice(),r=A.normalizeAxis(o.axis,t.length),n=t.length,s=r!==n-1,a=[],u=[],l=[],f;s&&(u=Array.from({length:n}).map((g,y)=>y),u[r]=n-1,u[n-1]=r,u.map(g=>a.push(t[g])),f=F({perm:u}),l=ge(i,e,f));let c=s?A.sizeToDimension(a,n-1):A.sizeToDimension(t,n-1),d=s?A.sizeFromDimension(a,n-1):A.sizeFromDimension(t,n-1),m=Hl(i,s?l:e,o,c,d);return s?ge(i,m,f):m},Hl=(i,e,o,t,r)=>{let n=Oh(i,e[0],t,r,[t]),s=i.run({...Rl,cacheHint:o.cacheKey,get:()=>n},e),a=Ah(i,e[0],t,r,n.output.dims,[t]),u=i.run({...Gl,cacheHint:o.cacheKey,get:()=>a},[e[0],s]),l=Ph(i,e[0],t,r,n.output.dims,a.output.dims);return[i.run({...Ml,cacheHint:o.cacheKey,get:()=>l},[e[0],s,u])]},Oh=(i,e,o,t,r)=>{let[n,s]=i.calculateTextureWidthAndHeight(e.dims,0),a=r.length;if(o<1||t<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(r.length!==1)throw new Error("Dimensionality of the output should be 1");if(r[0]!==o)throw new Error("Shape of the output should be equal to logical row count");let u=D(i.session.backend.glContext.version),l=`
+      float process(int[${a}] indices) {
+        int logical_row_start_offset = indices[0] * ${t};
+
+        float max = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset, ${n},
+        ${s} )));
+        for(int i=1; i<${t}; ++i)
+        {
+          float current = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
+            ${n}, ${s})));
+          if(current > max)
+          max = current;
+        }
+
+        return max;
+      }`;return{...Rl,output:{dims:r,type:e.type,textureType:0},shaderSource:l}},Ah=(i,e,o,t,r,n)=>{let[s,a]=i.calculateTextureWidthAndHeight(e.dims,0),u=n.length;if(o<1||t<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(n.length!==1)throw new Error("Dimensionality of the output should be 1");if(n[0]!==o)throw new Error("Shape of the output should be equal to logical row count");if(r.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(r[0]!==o)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=D(i.session.backend.glContext.version),f=`
+      float process(int[${u}] indices) {
+        int logical_row_start_offset = indices[0] * ${t};
+
+        float norm_factor = 0.0;
+        float max = _Max(indices);
+        for(int i=0; i<${t}; ++i)
+        {
+          norm_factor += exp(getColorAsFloat(${l.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
+            ${s}, ${a}))) - max);
+        }
+
+        return norm_factor;
+      }`;return{...Gl,output:{dims:n,type:e.type,textureType:0},shaderSource:f}},Ph=(i,e,o,t,r,n)=>{let[s,a]=i.calculateTextureWidthAndHeight(e.dims,0),u=e.dims.length;if(o<1||t<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(r.length!==1||n.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(r[0]!==o||n[0]!==o)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=`
+      float process(int[${u}] indices) {
+
+      // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
+      int offset = coordsToOffset(TexCoords, ${s}, ${a});
+
+      //determine the logical row for this index
+      int logical_row_index[1];
+      logical_row_index[0] = offset / ${t};
+
+      float norm_factor = _Norm(logical_row_index);
+
+      // avoid possible division by 0
+      // if norm_facor is 0, all elements are zero
+      // if so, return 0
+      if(norm_factor == 0.0)
+        return 0.0;
+
+      return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
+    }`;return{...Ml,output:{dims:e.dims,type:e.type,textureType:0},shaderSource:l}},ql=i=>{if(!i||i.length!==1)throw new Error("Softmax requires 1 input.");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("Invalid input type")}});var Xl,Kl,Jl,Eh,Dh,Lh,Zl=x(()=>{"use strict";at();U();R();Xl={name:"Split",inputNames:["A"],inputTypes:[0]},Kl=(i,e,o)=>{Lh(e);let t=A.normalizeAxis(o.axis,e[0].dims.length),r=Eh(i,e,t,o),n=[];for(let s=0;s<r;++s)n.push(i.run({...Xl,cacheHint:`${o.cacheKey};${s}`,get:()=>Dh(i,e[0],o,t,s)},e));return n},Jl=i=>{let e=i.attributes.getInt("axis",0),o=i.attributes.getInts("split",[]),t=i.outputs.length;return F({axis:e,split:o,numOutputs:t})},Eh=(i,e,o,t)=>{let[,r]=Je.splitShape(e[0].dims,o,t.split,t.numOutputs);return r.length},Dh=(i,e,o,t,r)=>{let[n,s]=Je.splitShape(e.dims,t,o.split,o.numOutputs),a=s[r],u=n[r],f=`
+      float process(int indices[${u.length}]) {
+        indices[${t}] += ${a};
+        return _A(indices);
+      }
+    `;return{...Xl,cacheHint:`${o.cacheKey}:${r}`,output:{dims:u,type:e.type,textureType:0},shaderSource:f}},Lh=i=>{if(!i||i.length!==1)throw new Error("Split requires one input.");if(i[0].type!=="int8"&&i[0].type!=="uint8"&&i[0].type!=="int16"&&i[0].type!=="uint16"&&i[0].type!=="int32"&&i[0].type!=="uint32"&&i[0].type!=="float32"&&i[0].type!=="float64"&&i[0].type!=="bool")throw new Error("Invalid input type.")}});var Do,Yl,Ql,$h,kh,tf=x(()=>{"use strict";U();Do=(i,e,o)=>{$h(e);let t=A.squeezeShape(e[0].dims,o);return[i.reshapeUnpacked(e[0],t)]},Yl=(i,e)=>(kh(e),Do(i,[e[0]],Array.from(e[1].integerData))),Ql=i=>i.attributes.getInts("axes"),$h=i=>{if(!i||i.length!==1)throw new Error("Squeeze requires 1 input.");if(i[0].type==="string")throw new Error("invalid input tensor types.")},kh=i=>{if(!i||i.length!==2)throw new Error("Squeeze requires 2 inputs.");if(i[1].type!=="int32")throw new Error("Invalid input type.")}});var ef,Bh,Fh,rf=x(()=>{"use strict";X();R();ef=(i,e)=>{Fh(e);let o={name:"Sum",inputNames:e.map((r,n)=>`X${n}`),inputTypes:new Array(e.length).fill(0)};return[i.run({...o,get:()=>Bh(i,e,o)},e)]},Bh=(i,e,o)=>{let t=D(i.session.backend.glContext.version),r=e[0].dims.slice(),s=`
+      void main() {
+        vec4 result = ${e.map((a,u)=>`${t.texture2D}(X${u},TexCoords)`).join(" + ")};
+        ${t.output} = result;
+      }
+    `;return{...o,output:{dims:r,type:e[0].type,textureType:0},hasMain:!0,shaderSource:s}},Fh=i=>{if(!i||i.length===0)throw new Error("Sum requires inputs.");let e=i[0].dims.length;for(let o=1;o<i.length;o++){if(e!==i[o].dims.length)throw new Error("Input shapes are mismatched.");for(let t=0;t<e;t++)if(i[0].dims[t]!==i[o].dims[t])throw new Error("Input shapes are not matched.")}if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("Invalid input type.");for(let o=1;o<i.length;o++)if(i[0].type!==i[o].type)throw new Error("Input types are not matched.")}});var nf,Nh,Ch,of=x(()=>{"use strict";rr();R();nf=(i,e)=>{Ch(e);let o={name:"Tile",inputNames:["A"],inputTypes:[0]};return[i.run({...o,get:()=>Nh(i,e,o)},e)]},Nh=(i,e,o)=>{let t=e[0].dims.slice(),r=new Array(t.length),n=[];for(let u=0;u<t.length;u++)r[u]=t[u]*e[1].numberData[u],n.push(`inputIdx[${u}] = int(mod(float(outputIdx[${u}]), ${t[u]}.));`);let s=r.length,a=`
+      float process(int outputIdx[${s}]) {
+        int inputIdx[${s}];
+        ${n.join(`
+`)}
+        return _A(inputIdx);
+      }
+    `;return{...o,output:{dims:r,type:e[0].type,textureType:0},shaderSource:a}},Ch=i=>{if(!i||i.length!==2)throw new Error("Tile requires 2 input.");if(i[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(i[1].dims[0]!==i[0].dims.length)throw new Error("Invalid input shape.");if(ee.indexOf(i[0].type)===-1)throw new Error("Invalid input type.");if(i[1].type!=="int32"&&i[1].type!=="int16")throw new Error("Invalid repeat type.")}});var Lo,af,sf,Rh,Gh,uf=x(()=>{"use strict";U();Lo=(i,e,o)=>{Rh(e);let t=A.unsqueezeShape(e[0].dims,o);return[i.reshapeUnpacked(e[0],t)]},af=(i,e)=>(Gh(e),Lo(i,[e[0]],Array.from(e[1].integerData))),sf=i=>i.attributes.getInts("axes"),Rh=i=>{if(!i||i.length!==1)throw new Error("Unsqueeze requires 1 input.");if(i[0].type==="string")throw new Error("invalid input tensor types.")},Gh=i=>{if(!i||i.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(i[1].type!=="int32")throw new Error("Invalid input type.")}});var lf,ff=x(()=>{"use strict";xs();$s();Fs();Vs();Vr();_u();Du();ku();Nu();Mu();zu();ju();Zu();Ur();el();hl();vl();_l();Dl();$l();Cl();jl();Zl();tf();rf();of();Wr();ho();uf();Oo();lf=[["Abs","","6+",Us],["Acos","","7+",zs],["Add","","7+",Ts],["And","","7+",ws],["Asin","","7+",Ws],["Atan","","7+",Hs],["AveragePool","","7+",nl,ol],["BatchNormalization","","7+",gs,ys],["Cast","","6+",ks,Bs],["Ceil","","6+",Xs],["Clip","","6-10",co,qs],["Clip","","11+",js],["Concat","","4+",Rs,Ms],["Conv","","1+",To,wo],["ConvTranspose","","1+",vu,Iu],["Cos","","7+",Ks],["Div","","7+",vs],["Dropout","","7+",po],["DepthToSpace","","1+",Pu,Eu],["Equal","","7+",Is],["Elu","","6+",Js,Zs],["Exp","","6+",Ys],["Flatten","","1+",Lu,$u],["Floor","","6+",Qs],["FusedConv","com.microsoft","1+",To,wo],["Gather","","1+",Bu,Fu],["Gemm","","7-10",vo,Ru],["Gemm","","11+",vo,Gu],["GlobalAveragePool","","1+",al,sl],["GlobalMaxPool","","1+",pl],["Greater","","7+",_s],["Identity","","1+",po],["ImageScaler","","1+",Vu,Uu],["InstanceNormalization","","6+",Hu,qu],["LeakyRelu","","6+",tu,eu],["Less","","7+",Ss],["LRN","","1+",Xu,Ku],["Log","","6+",ru],["MatMul","","1+",mu,bu],["MaxPool","","1+",ul,ll],["Mul","","7+",Os],["Neg","","6+",nu],["Not","","1+",ou],["Or","","7+",As],["Pad","","2-10",Io,Yu],["Pad","","11+",Qu,tl],["Pow","","7+",Ps],["PRelu","","7+",Es],["ReduceLogSum","","1+",Tl,re],["ReduceMax","","1+",gl,re],["ReduceMean","","1+",bl,re],["ReduceMin","","1+",yl,re],["ReduceProd","","1+",xl,re],["ReduceSum","","1-12",ml,re],["ReduceSumSquare","","1+",wl,re],["Relu","","6+",iu],["Reshape","","5+",Il],["Resize","","10",Po,Pl],["Resize","","11+",Po,El],["Shape","","1+",Ll],["Sigmoid","","6+",au],["Sin","","7+",su],["Slice","","10+",Nl],["Slice","","1-9",kl,Bl],["Softmax","","1-12",Vl,Ul],["Softmax","","13+",Wl,zl],["Split","","2-12",Kl,Jl],["Sqrt","","6+",uu],["Squeeze","","1-12",Do,Ql],["Squeeze","","13+",Yl],["Sub","","7+",Ds],["Sum","","6+",ef],["Tan","","7+",lu],["Tanh","","6+",fu],["Tile","","6+",nf],["Transpose","","1+",ge,Ou],["Upsample","","7-8",_o,Ol],["Upsample","","9",_o,Al],["Unsqueeze","","1-12",Lo,sf],["Unsqueeze","","13+",af],["Xor","","7+",Ls]]});function pf(i){let e={},o;for(;(o=cf.exec(i))!==null;){let t=o[3].split(",").map(r=>{let n=r.trim().split(" ");return n&&n.length===2?{type:n[0],name:n[1]}:null}).filter(r=>r!==null);e[o[2]]={params:t,body:o[4]}}for(let t in e){let r=Mh.replace("__FUNC__",t),n=new RegExp(r,"gm");for(;(o=n.exec(i))!==null;){let s=o[1],a=o[2],u=o[3].split(","),l=s?`${s} ${a};`:"",f=e[t].body,c="";e[t].params.forEach((m,g)=>{m&&(c+=`${m.type} ${m.name} = ${u[g]};
+`)}),f=`${c}
+ ${f}`,f=f.replace("return",`${a} = `);let d=`
+      ${l}
+      {
+        ${f}
+      }
+      `;i=i.replace(o[0],d)}}return i=i.replace(cf,""),i}var cf,Mh,df=x(()=>{"use strict";cf=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,Mh="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function Be(i,e){let o=[],t=[],r=e!=null&&Array.isArray(e)&&e.length===0,n=e==null||r?null:Vh(e,i).sort(),s=0;for(let a=0;a<i.length;++a){if(n!=null){if(n[s]===a&&i[a]!==1)throw new Error(`Can't squeeze axis ${a} since its dim '${i[a]}' is not 1`);(n[s]==null||n[s]>a)&&i[a]===1&&(o.push(i[a]),t.push(a)),n[s]<=a&&s++}i[a]!==1&&(o.push(i[a]),t.push(a))}return{newShape:o,keptDims:t}}function Vh(i,e){let o=e.length;return i=i==null?e.map((t,r)=>r):[].concat(i),Pe(i.every(t=>t>=-o&&t<o),()=>`All values in axis param must be in range [-${o}, ${o}) but got axis ${i}`),Pe(i.every(Uh),()=>`All values in axis param must be integers but got axis ${i}`),i.map(t=>t<0?o+t:t)}function Uh(i){return i%1===0}function zh(i){if(i.length===0)return 1;let e=i[0];for(let o=1;o<i.length;o++)e*=i[o];return e}function hf(i){let e=Math.ceil(Math.sqrt(i));return[e,Math.ceil(i/e)]}var Xr,$o=x(()=>{"use strict";vt();U();Xr=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,o){let t=this.computeTexture(e,o);return o&&o.isPacked&&(t[0]/=2,t[1]/=2),o&&o.reverseWH?[t[1],t[0]]:t}computeTexture(e,o){let t=o&&o.isPacked;if(e.length===0)return t?[2,2]:[1,1];let r=this.maxTextureSize;if(o&&o.breakAxis!==void 0){let a=o.breakAxis>=e.length?1:e.slice(o.breakAxis).reduce((l,f)=>l*f),u=o.breakAxis<=0?1:e.slice(0,o.breakAxis).reduce((l,f)=>l*f);if(a>r||u>r)z.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${o.breakAxis}`);else return[a,u]}let n=e.slice(0);t&&(r=r*2,n=n.map((a,u)=>u>=n.length-2?n[u]%2===0?n[u]:n[u]+1:n[u]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=Be(n).newShape);let s=zh(n);return n.length<=1&&s<=r?[1,s]:n.length===2&&n[0]<=r&&n[1]<=r?n:n.length===3&&n[0]*n[1]<=r&&n[2]<=r?[n[0]*n[1],n[2]]:n.length===3&&n[0]<=r&&n[1]*n[2]<=r?[n[0],n[1]*n[2]]:n.length===4&&n[0]*n[1]*n[2]<=r&&n[3]<=r?[n[0]*n[1]*n[2],n[3]]:n.length===4&&n[0]<=r&&n[1]*n[2]*n[3]<=r?[n[0],n[1]*n[2]*n[3]]:t?hf(s/4).map(a=>a*2):hf(s)}}});var Kr,mf=x(()=>{"use strict";U();Xt();X();$o();Mt();Kr=class extends Ot{constructor(o){super(o)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSamplingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){let o="offsetToCoords";return{offsetToCoords:new O(`
+      vec2 ${o}(int offset, int width, int height) {
+        int t = offset / width;
+        int s = offset - t*width;
+        vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
+        return coords;
+      }
+      `)}}coordsToOffset(){let o="coordsToOffset";return{coordsToOffset:new O(`
+      int ${o}(vec2 coords, int width, int height) {
+        float s = coords.s * float(width);
+        float t = coords.t * float(height);
+        int offset = int(t) * width + int(s);
+        return offset;
+      }
+      `)}}getOutputSamplingSnippet(){let o=this.context.outputTextureLayout;return o.isPacked?this.getPackedOutputSamplingSnippet(o):this.getUnpackedOutputSamplingSnippet(o)}getPackedOutputSamplingSnippet(o){let t=o.unpackedShape,r=[o.width,o.height],n={},s="getOutputCoords";switch(t.length){case 0:n[s]=this.getOutputScalarCoords();break;case 1:n[s]=this.getOutputPacked1DCoords(t,r);break;case 2:n[s]=this.getOutputPacked2DCoords(t,r);break;case 3:n[s]=this.getOutputPacked3DCoords(t,r);break;default:n[s]=this.getOutputPackedNDCoords(t,r)}let u=`
+      void setOutput(vec4 val) {
+        ${D(this.context.glContext.version).output} = val;
+      }
+    `,l="floatTextureSetRGBA";return n[l]=new O(u),n}getUnpackedOutputSamplingSnippet(o){let t=o.unpackedShape,r=[o.width,o.height],n={},s="getOutputCoords";switch(t.length){case 0:n[s]=this.getOutputScalarCoords();break;case 1:n[s]=this.getOutputUnpacked1DCoords(t,r);break;case 2:n[s]=this.getOutputUnpacked2DCoords(t,r);break;case 3:n[s]=this.getOutputUnpacked3DCoords(t,r);break;case 4:n[s]=this.getOutputUnpacked4DCoords(t,r);break;case 5:n[s]=this.getOutputUnpacked5DCoords(t,r);break;case 6:n[s]=this.getOutputUnpacked6DCoords(t,r);break;default:throw new Error(`Unsupported output dimensionality: ${t.length}`)}let u=`
+        void setOutput(float val) {
+          ${D(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
+        }
+    `,l="floatTextureSetR";return n[l]=new O(u),n}getOutputScalarCoords(){return new O(`
+      int getOutputCoords() {
+        return 0;
+      }
+    `)}getOutputPacked1DCoords(o,t){let r=t,n="";return r[0]===1?(n=`
+          int getOutputCoords() {
+            return 2 * int(TexCoords.y * ${r[1]}.0);
+          }
+        `,new O(n)):r[1]===1?(n=`
+          int getOutputCoords() {
+            return 2 * int(TexCoords.x * ${r[0]}.0);
+          }
+        `,new O(n)):(n=`
+        int getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                 vec2(${r[0]}, ${r[1]}));
+          return 2 * (resTexRC.y * ${r[0]} + resTexRC.x);
+        }
+      `,new O(n))}getOutputPacked2DCoords(o,t){let r="";if(fe.arraysEqual(o,t))return r=`
+        ivec2 getOutputCoords() {
+          return 2 * ivec2(TexCoords.xy * vec2(${t[0]}, ${t[1]}));
+        }
+      `,new O(r);let n=t,s=Math.ceil(o[1]/2);return r=`
+        ivec2 getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${n[0]}, ${n[1]}));
+
+          int index = resTexRC.y * ${n[0]} + resTexRC.x;
+
+          // reverse r and c order for packed texture
+          int r = imod(index, ${s}) * 2;
+          int c = 2 * (index / ${s});
+
+          return ivec2(r, c);
+        }
+      `,new O(r)}getOutputPacked3DCoords(o,t){let r=[t[0],t[1]],n=Math.ceil(o[2]/2),s=n*Math.ceil(o[1]/2),a=`
+        ivec3 getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${r[0]}, ${r[1]}));
+          int index = resTexRC.y * ${r[0]} + resTexRC.x;
+
+          int b = index / ${s};
+          index -= b * ${s};
+
+          // reverse r and c order for packed texture
+          int r = imod(index, ${n}) * 2;
+          int c = 2 * (index / ${n});
+
+          return ivec3(b, r, c);
+        }
+      `;return new O(a)}getOutputPackedNDCoords(o,t){let r=[t[0],t[1]],n=Math.ceil(o[o.length-1]/2),s=n*Math.ceil(o[o.length-2]/2),a=s,u="",l="b, r, c";for(let c=2;c<o.length-1;c++)a*=o[o.length-c-1],u=`
+      int b${c} = index / ${a};
+      index -= b${c} * ${a};
+    `+u,l=`b${c}, `+l;let f=`
+      ivec${o.length} getOutputCoords() {
+        ivec2 resTexRC = ivec2(TexCoords.xy *
+                              vec2(${r[0]}, ${r[1]}));
+        int index = resTexRC.y * ${r[0]} + resTexRC.x;
+
+        ${u}
+
+        int b = index / ${s};
+        index -= b * ${s};
+
+        // reverse r and c order for packed texture
+        int r = imod(index, ${n}) * 2;
+        int c = 2 * (index / ${n});
+
+        return ivec${o.length}(${l});
+      }
+    `;return new O(f)}getOutputUnpacked1DCoords(o,t){let r=`
+        int getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${t[0]}, ${t[1]}));
+          return resTexRC.y * ${t[0]} + resTexRC.x;
+        }
+      `;return new O(r)}getOutputUnpacked2DCoords(o,t){let r=`
+        ivec2 getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${t[0]}, ${t[1]}));
+          int index = resTexRC.y * ${t[0]} + resTexRC.x;
+          int r = index / ${o[1]};
+          int c = index - r * ${o[1]};
+          return ivec2(r, c);
+        }
+      `;return new O(r)}getOutputUnpacked3DCoords(o,t){let r="",n=o.length,s=null;n<2&&(s=[]),s=new Array(n-1),s[n-2]=o[n-1];for(let l=n-3;l>=0;--l)s[l]=s[l+1]*o[l+1];let a=["r","c","d"],u=s.map((l,f)=>{let c=`int ${a[f]} = index / ${l}`,d=f===s.length-1?`int ${a[f+1]} = index - ${a[f]} * ${l}`:`index -= ${a[f]} * ${l}`;return`${c}; ${d};`}).join("");return r=`
+        ivec3 getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${t[0]}, ${t[1]}));
+          int index = resTexRC.y * ${t[0]} + resTexRC.x;
+          ${u}
+          return ivec3(r, c, d);
+        }
+      `,new O(r)}getOutputUnpacked4DCoords(o,t){let r="",n=o.length,s=null;n<2&&(s=[]),s=new Array(n-1),s[n-2]=o[n-1];for(let l=n-3;l>=0;--l)s[l]=s[l+1]*o[l+1];let a=["r","c","d","d2"],u=s.map((l,f)=>{let c=`int ${a[f]} = index / ${l}`,d=f===s.length-1?`int ${a[f+1]} = index - ${a[f]} * ${l}`:`index -= ${a[f]} * ${l}`;return`${c}; ${d};`}).join("");return r=`
+      ivec4 getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${t[0]}, ${t[1]}));
+          int index = resTexRC.y * ${t[0]} + resTexRC.x;
+          ${u}
+          return ivec4(r, c, d, d2);
+        }
+      `,new O(r)}getOutputUnpacked5DCoords(o,t){let r="",n=o.length,s=null;n<2&&(s=[]),s=new Array(n-1),s[n-2]=o[n-1];for(let l=n-3;l>=0;--l)s[l]=s[l+1]*o[l+1];let a=["r","c","d","d2","d3"],u=s.map((l,f)=>{let c=`int ${a[f]} = index / ${l}`,d=f===s.length-1?`int ${a[f+1]} = index - ${a[f]} * ${l}`:`index -= ${a[f]} * ${l}`;return`${c}; ${d};`}).join("");return r=`
+      ivec5 getOutputCoords() {
+          ivec2 resTexRC = ivec2(TexCoords.xy *
+                                vec2(${t[0]}, ${t[1]}));
+          int index = resTexRC.y * ${t[0]} + resTexRC.x;
+          ${u}
+          return ivec5(r, c, d, d2, d3);
+        }
+      `,new O(r)}getOutputUnpacked6DCoords(o,t){let r="",n=o.length,s=null;n<2&&(s=[]),s=new Array(n-1),s[n-2]=o[n-1];for(let l=n-3;l>=0;--l)s[l]=s[l+1]*o[l+1];let a=["r","c","d","d2","d3","d4"],u=s.map((l,f)=>{let c=`int ${a[f]} = index / ${l}`,d=f===s.length-1?`int ${a[f+1]} = index - ${a[f]} * ${l}`:`index -= ${a[f]} * ${l}`;return`${c}; ${d};`}).join("");return r=`
+     ivec6 getOutputCoords() {
+         ivec2 resTexRC = ivec2(TexCoords.xy *
+                               vec2(${t[0]}, ${t[1]}));
+         int index = resTexRC.y * ${t[0]} + resTexRC.x;
+         ${u}
+         return ivec6(r, c, d, d2, d3, d4);
+       }
+     `,new O(r)}getCommonUtilFuncs(){let o={},t="uvFromFlat";o[t]=new O(`
+    vec2 uvFromFlat(int texNumR, int texNumC, int index) {
+      int texC = index / texNumR;
+      int texR = index - texC * texNumR;
+      // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to
+      //       v.
+      return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);
+    }
+    `),t="packedUVfrom1D",o[t]=new O(`
+      vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
+        int texelIndex = index / 2;
+        int texR = texelIndex / texNumC;
+        int texC = texelIndex - texR * texNumC;
+        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
+      }
+      `),t="packedUVfrom2D",o[t]=new O(`
+      vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {
+        int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
+        int texR = texelIndex / texNumC;
+        int texC = texelIndex - texR * texNumC;
+        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
+      }
+      `),t="packedUVfrom3D",o[t]=new O(`
+      vec2 packedUVfrom3D(int texNumR, int texNumC,
+          int texelsInBatch, int texelsInLogicalRow, int b,
+          int row, int col) {
+        int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
+        int texR = index / texNumC;
+        int texC = index - texR * texNumC;
+        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
+      }
+      `),t="sampleTexture";let r=D(this.context.glContext.version);return o[t]=new O(`
+        float sampleTexture(sampler2D textureSampler, vec2 uv) {
+            return ${r.texture2D}(textureSampler, uv).r;
+        }`),o}getInputsSamplingSnippets(){let o={},t=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((r,n)=>{let s=this.context.inputTextureLayouts[n],a=Br(r);s.isPacked?o[a]=this.getPackedSamplerFromInput(a,r,s):o[a]=this.getUnpackedSamplerFromInput(a,r,s);let u=es(r);s.unpackedShape.length<=t.unpackedShape.length&&(s.isPacked?o[u]=this.getPackedSamplerAtOutputCoords(u,s,t,r):o[u]=this.getUnpackedSamplerAtOutputCoords(u,s,t,r))}),o}getPackedSamplerAtOutputCoords(o,t,r,n){let s=t.unpackedShape,a=r.unpackedShape,l=Br(n),f=s.length,c=a.length,d=ct.getBroadcastDims(s,a),m=pt(c),g=c-f,y,T=Rt();f===0?y="":c<2&&d.length>=1?y="coords = 0;":y=d.map(Tt=>`coords.${T[Tt+g]} = 0;`).join(`
+`);let _="";c<2&&f>0?_="coords":_=s.map((Tt,dt)=>`coords.${T[dt+g]}`).join(", ");let w="return outputValue;",L=A.size(s)===1,Q=A.size(a)===1;if(f===1&&!L&&!Q)w=`
+        return vec4(outputValue.xy, outputValue.xy);
+      `;else if(L&&!Q)c===1?w=`
+          return vec4(outputValue.x, outputValue.x, 0., 0.);
+        `:w=`
+          return vec4(outputValue.x);
+        `;else if(d.length){let Tt=f-2,dt=f-1;d.indexOf(Tt)>-1&&d.indexOf(dt)>-1?w="return vec4(outputValue.x);":d.indexOf(Tt)>-1?w="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":d.indexOf(dt)>-1&&(w="return vec4(outputValue.xx, outputValue.zz);")}let lt=`
+        int lastDim = coords.${T[c-1]};
+        coords.${T[c-1]} = coords.${T[c-2]};
+        coords.${T[c-2]} = lastDim;
+      `,Wt=`
+      vec4 ${o}() {
+        ${m} coords = getOutputCoords();
+        ${lt}
+        ${y}
+        vec4 outputValue = ${l}(${_});
+        ${w}
+      }
+    `;return new O(Wt,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(o,t,r,n){let s=[r.width,r.height],a=[t.width,t.height],u=t.unpackedShape.length,l=r.unpackedShape.length,f=t.unpackedShape,c=r.unpackedShape,d=Br(n);if(u===l&&fe.arraysEqual(a,s)){let L=`
+          float ${o}() {
+            return sampleTexture(${n}, TexCoords);
+          }
+        `;return new O(L,["coordinates.sampleTexture"])}let m=pt(l),g=ct.getBroadcastDims(f,c),y=l-u,T,_=Rt();u===0?T="":l<2&&g.length>=1?T="coords = 0;":T=g.map(L=>`coords.${_[L+y]} = 0;`).join(`
+`);let w="";l<2&&u>0?w="coords":w=t.unpackedShape.map((L,B)=>`coords.${_[B+y]}`).join(", ");let v=`
+        float ${o}() {
+          ${m} coords = getOutputCoords();
+          ${T}
+          return ${d}(${w});
+        }
+      `;return new O(v,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(o,t,r){switch(r.unpackedShape.length){case 0:return this.getPackedSamplerScalar(o,t);case 1:return this.getPackedSampler1D(o,t,r);case 2:return this.getPackedSampler2D(o,t,r);case 3:return this.getPackedSampler3D(o,t,r);default:return this.getPackedSamplerND(o,t,r)}}getUnpackedSamplerFromInput(o,t,r){let n=r.unpackedShape;switch(n.length){case 0:return this.getUnpackedSamplerScalar(o,t,r);case 1:return this.getUnpackedSampler1D(o,t,r);case 2:return this.getUnpackedSampler2D(o,t,r);case 3:return this.getUnpackedSampler3D(o,t,r);case 4:return this.getUnpackedSampler4D(o,t,r);case 5:return this.getUnpackedSampler5D(o,t,r);case 6:return this.getUnpackedSampler6D(o,t,r);default:throw new Error(`Unsupported dimension ${n.length}-D`)}}getPackedSamplerScalar(o,t){let r=D(this.context.glContext.version),n=`
+          vec4 ${o}() {
+            return ${r.texture2D}(${t}, halfCR);
+          }
+        `;return new O(n)}getPackedSampler1D(o,t,r){let n=[r.width,r.height],s=[n[1],n[0]],a=D(this.context.glContext.version),l=`vec4 ${o}(int index) {
+      vec2 uv = packedUVfrom1D(
+      ${s[0]}, ${s[1]}, index);
+      return ${a.texture2D}(${t}, uv);
+    }`;return new O(l,["coordinates.packedUVfrom1D"])}getPackedSampler2D(o,t,r){let n=r.unpackedShape,s=[r.width,r.height],a=D(this.context.glContext.version),u=s[0],l=s[1];if(s!=null&&fe.arraysEqual(n,s)){let g=`vec4 ${o}(int row, int col) {
+        vec2 uv = (vec2(col, row) + halfCR) / vec2(${l}.0, ${u}.0);
+        return ${a.texture2D}(${t}, uv);
+      }`;return new O(g)}let f=s,c=Math.ceil(n[1]/2),m=`vec4 ${o}(int row, int col) {
+      vec2 uv = packedUVfrom2D(${f[1]}, ${f[0]}, ${c}, row, col);
+      return ${a.texture2D}(${t}, uv);
+    }`;return new O(m,["coordinates.packedUVfrom2D"])}getPackedSampler3D(o,t,r){let n=r.unpackedShape,s=[r.width,r.height],a=[s[0],s[1]],u=D(this.context.glContext.version);if(n[0]===1){let y=n.slice(1),T=[1,2],_=Ee(n,y),w=["b","row","col"],v=JSON.parse(JSON.stringify(r));v.unpackedShape=_;let L=this.getPackedSamplerFromInput(o,t,v),Q=`${L.routineBody}
+      vec4 ${o}(int b, int row, int col) {
+        return ${o}(${De(w,T)});
+      } `;return new O(Q,L.dependencies)}let l=a[0],f=a[1],c=Math.ceil(n[2]/2),d=c*Math.ceil(n[1]/2),g=`vec4 ${o}(int b, int row, int col) {
+      vec2 uv = packedUVfrom3D(
+        ${f}, ${l}, ${d}, ${c}, b, row, col);
+      return ${u.texture2D}(${t}, uv);}`;return new O(g,["coordinates.packedUVfrom3D"])}getPackedSamplerND(o,t,r){let n=r.unpackedShape,s=n.length,a=[r.width,r.height],u=D(this.context.glContext.version),l=[a[0],a[1]],f=l[1],c=l[0],d=Math.ceil(n[s-1]/2),m=d*Math.ceil(n[s-2]/2),g="int b, int row, int col",y=`b * ${m} + (row / 2) * ${d} + (col / 2)`;for(let w=2;w<s-1;w++)g=`int b${w}, `+g,m*=n[s-w-1],y=`b${w} * ${m} + `+y;let _=`vec4 ${o}(${g}) {
+      int index = ${y};
+      int texR = index / ${c};
+      int texC = index - texR * ${c};
+      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${f});
+      return ${u.texture2D}(${t}, uv);
+    }`;return new O(_)}getUnpackedSamplerScalar(o,t,r){let[n,s]=[r.width,r.height];if(n===1&&s===1){let u=`
+          float ${o}() {
+            return sampleTexture(${t}, halfCR);
+          }
+        `;return new O(u,["coordinates.sampleTexture"])}let a=`
+        float ${o}() {
+          int offset_${t} = coordsToOffset(TexCoords, ${n}, ${s});
+          vec2 uv = uvFromFlat(${n}, ${s}, offset_${t});
+          return sampleTexture(${t}, uv);
+        }
+      `;return new O(a,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(o,t,r){let n=r.width,s=r.height;if(s===1&&n===1){let u=`
+        float ${o}(int index) {
+          return sampleTexture(${t}, halfCR);
+        }
+      `;return new O(u,["coordinates.sampleTexture"])}if(s===1){let u=`
+          float ${o}(int index) {
+            vec2 uv = vec2((float(index) + 0.5) / ${n}.0, 0.5);
+            return sampleTexture(${t}, uv);
+          }
+        `;return new O(u,["coordinates.sampleTexture"])}if(n===1){let u=`
+          float ${o}(int index) {
+            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${s}.0);
+            return sampleTexture(${t}, uv);
+          }
+        `;return new O(u,["coordinates.sampleTexture"])}let a=`
+        float ${o}(int index) {
+          vec2 uv = uvFromFlat(${n}, ${s}, index);
+          return sampleTexture(${t}, uv);
+        }
+      `;return new O(a,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(o,t,r){let n=r.unpackedShape,s=[r.height,r.width];if(s!=null&&fe.arraysEqual(n,s)){let m=s[1],g=s[0],y=`
+          float ${o}(int row, int col) {
+            vec2 uv = (vec2(row, col) + halfCR) / vec2(${m}.0, ${g}.0);
+            return sampleTexture(${t}, uv);
+          }
+        `;return new O(y,["coordinates.sampleTexture"])}let{newShape:a,keptDims:u}=Be(n),l=a;if(l.length<n.length){let m=Ee(n,l),g=JSON.parse(JSON.stringify(r));g.unpackedShape=m;let y=["col","row"],T=`
+          ${this.getUnpackedSamplerFromInput(o,t,g).routineBody}
+          float ${o}(int row, int col) {
+            return ${o}(${De(y,u)});
+          }
+        `;return new O(T,["coordinates.sampleTexture"])}let f=s[1],c=s[0];if(c===1){let m=`
+          float ${o}(int row, int col) {
+            int offset_${t} = coordsToOffset(TexCoords, ${f}, ${c});
+            float index = dot(vec3(row, col, offset_${t}), vec3(${n[1]}, 1, 1));
+            vec2 uv = vec2(0.5, (index + 0.5) / ${f}.0);
+            return sampleTexture(${t}, uv);
+          }
+        `;return new O(m,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(f===1){let m=`
+          float ${o}(int row, int col) {
+            int offset_${t} = coordsToOffset(TexCoords, ${f}, ${c});
+            float index = dot(vec3(row, col, offset_${t}), vec3(${n[1]}, 1, 1));
+            vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);
+            return sampleTexture(${t}, uv);
+          }
+        `;return new O(m,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let d=`
+        float ${o}(int row, int col) {
+          int index = col * ${n[1]} + row;
+          vec2 uv = uvFromFlat(${f}, ${c}, index);
+          return sampleTexture(${t}, uv);
+        }
+      `;return new O(d,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(o,t,r){let n=r.unpackedShape,s=n[1]*n[2],a=n[2],{newShape:u,keptDims:l}=Be(n),f=u;if(f.length<n.length){let g=Ee(n,f),y=["batch","col","row"],T=JSON.parse(JSON.stringify(r));T.unpackedShape=g;let _=this.getUnpackedSamplerFromInput(o,t,T),w=l.reverse(),v=`
+          ${_.routineBody}
+          float ${o}(int batch, int row, int col) {
+            return ${o}(${De(y,w)});
+          }
+        `;return new O(v,_.dependencies)}let c=r.width,d=r.height,m=`
+          float ${o}(int depth, int row, int col) {
+            // Explicitly use integer operations as dot() only works on floats.
+            int index = depth * ${s} + col * ${a} + row;
+            vec2 uv = uvFromFlat(${c}, ${d}, index);
+            return sampleTexture(${t}, uv);
+          }
+      `;return new O(m,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(o,t,r){let n=r.unpackedShape,s=n[3],a=n[2]*s,u=n[1]*a,l=r.width,f=r.height,c=`
+        float ${o}(int row, int col, int depth, int depth2) {
+          int index = row * ${u} + col * ${a} +
+              depth2 * ${s} + depth;
+          vec2 uv = uvFromFlat(${l}, ${f}, index);
+          return sampleTexture(${t}, uv);
+        }
+      `;return new O(c,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(o,t,r){let n=r.unpackedShape,s=n[4],a=n[3]*s,u=n[2]*a,l=n[1]*u,{newShape:f,keptDims:c}=Be(n);if(f.length<n.length){let y=Ee(n,f),T=["row","col","depth","depth2","depth3"],_=JSON.parse(JSON.stringify(r));_.unpackedShape=y;let w=`
+          ${this.getUnpackedSamplerFromInput(o,t,_).routineBody}
+          float ${o}(int row, int col, int depth, int depth2, int depth3) {
+            return ${o}(${De(T,c)});
+          }
+        `;return new O(w,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let d=r.width,m=r.height,g=`
+        float ${o}(int row, int col, int depth, int depth2, int depth3) {
+          int index = row * ${l} + col * ${u} + depth * ${a} +
+          depth3 * ${s} + depth2;
+          vec2 uv = uvFromFlat(${d}, ${m}, index);
+          return sampleTexture(${t}, uv);
+        }
+      `;return new O(g,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(o,t,r){let n=r.unpackedShape,s=n[5],a=n[4]*s,u=n[3]*a,l=n[2]*u,f=n[1]*l,{newShape:c,keptDims:d}=Be(n);if(c.length<n.length){let T=Ee(n,c),_=["row","col","depth","depth2","depth3","depth4"],w=JSON.parse(JSON.stringify(r));w.unpackedShape=T;let v=`
+            ${this.getUnpackedSamplerFromInput(o,t,w).routineBody}
+            float ${o}(int row, int col, int depth,
+              int depth2, int depth3, int depth4) {
+              return ${o}(${De(_,d)});
+            }
+          `;return new O(v,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let m=r.width,g=r.height,y=`
+          float ${o}(int row, int col, int depth,
+            int depth2, int depth3, int depth4) {
+            int index = row * ${f} + col * ${l} + depth * ${u} +
+            depth2 * ${a} + depth3 * ${s} + depth4;
+            vec2 uv = uvFromFlat(${m}, ${g}, index);
+            return sampleTexture(${t}, uv);
+          }
+        `;return new O(y,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let o=this.context.outputTextureLayout,t=o.shape.length,r=o.strides,n=o.width,s=o.height,a=[];for(let l=0;l<t-1;++l)a.push(`
+        c[${l}] = offset / ${r[l]};`),a.push(`
+        offset -= c[${l}] * ${r[l]};`);a.push(`
+        c[${t-1}] = offset;`);let u=`
+      void toVec(vec2 texCoords, out int c[${t}]) {
+        int offset = coordsToOffset(texCoords, ${n}, ${s});
+        ${a.join("")}
+      }
+      void toVec(int offset, out int c[${t}]) {
+        ${a.join("")}
+      }
+    `;return{toVec:new O(u,["coordinates.coordsToOffset"])}}valueFrom(){let o={};return this.context.programInfo.inputNames.forEach((t,r)=>{let n=this.context.inputTextureLayouts[r],a=(n.unpackedShape.length>0?n.unpackedShape:n.shape).length,u=`_${t}`;o[u]=new O(this.getValueFromSingle(t,a,n.width,n.height,!1),[`shapeUtils.indicesToOffset${u}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),u=u+"_T",o[u]=new O(this.getValueFromSingle(t,a,n.width,n.height,!0),[`shapeUtils.indicesToOffset${u}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),o}getValueFromSingle(o,t,r,n,s){let a=`_${o}`;s&&(a=a+"_T");let u=D(this.context.glContext.version);return`
+        float ${a}(int m[${t}]) {
+          int offset = indicesToOffset${a}(m);
+          vec2 coords = offsetToCoords(offset, ${r}, ${n});
+          float value = getColorAsFloat(${u.texture2D}(${o}, coords));
+          return value;
+        }
+        `}getPackedValueFrom(o,t,r,n,s){let a=`_${o}_Pack`;s&&(a=a+"_T");let u=D(this.context.glContext.version);return`
+        vec4 ${a}(int m[${t}]) {
+          int offset = indicesToOffset_${o}(m);
+          vec2 coords = offsetToCoords(offset, ${r}, ${n});
+          return ${u.texture2D}(${o}, coords);
+        }
+        `}}});var Jr,bf=x(()=>{"use strict";Xt();Jr=class i extends Ot{constructor(e){super(e)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new O(`highp vec4 encode(highp float f) {
+        return vec4(f, 0.0, 0.0, 0.0);
+      }
+        `)}}decodeFloat32(){return{decode:new O(`highp float decode(highp vec4 rgba) {
+        return rgba.r;
+      }
+        `)}}encodeUint8(){let e=i.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new O(`
+      highp vec4 encode(highp float f) {
+        highp float F = abs(f);
+        highp float Sign = step(0.0,-f);
+        highp float Exponent = floor(log2(F));
+        highp float Mantissa = (exp2(- Exponent) * F);
+        Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));
+        highp vec4 rgba;
+        rgba[0] = 128.0 * Sign  + floor(Exponent*exp2(-1.0));
+        rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);
+        rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));
+        rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));
+        ${e}
+        rgba = rgba / 255.0; // values need to be normalized to [0,1]
+        return rgba;
+    }
+        `)}}decodeUint8(){let e=i.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new O(`
+        highp float decode(highp vec4 rgba) {
+          rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
+          ${e}
+          highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;
+          highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;
+          highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);
+          highp float Result =  Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
+          return Result;
+      }
+        `)}}static isLittleEndian(){let e=new ArrayBuffer(4),o=new Uint32Array(e),t=new Uint8Array(e);if(o[0]=3735928559,t[0]===239)return!0;if(t[0]===222)return!1;throw new Error("unknown endianness")}}});var Zr,gf=x(()=>{"use strict";Xt();X();Zr=class extends Ot{constructor(e){super(e)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let e=D(this.context.glContext.version);return{setFragColor:new O(`
+        void setFragColor(float value) {
+            ${e.output} = encode(value);
+        }
+        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new O(`
+        float getColorAsFloat(vec4 color) {
+            return decode(color);
+        }
+        `,["encoding.decode"])}}}});var Yr,yf=x(()=>{"use strict";Xt();Yr=class i extends Ot{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,o={};return this.context.programInfo.inputNames.forEach((t,r)=>{let n=this.context.inputTextureLayouts[r].unpackedShape;if(n.length<=e){let s=n.length,a=e-s,u=`bcastIndices_${t}`,l="";for(let c=0;c<s;++c)l+=`
+          realIndices[${c}] = int( mod(float(bcastedIndices[${a+c}]), ${n[c]}.0) );
+          `;let f=`
+        void ${u} (int bcastedIndices[${e}], out int realIndices[${s}]) {
+          ${l}
+        }
+        `;o[u]=new O(f)}}),o}bcastMatmulIndex(){let e=this.context.outputTextureLayout.shape.length,o={};return this.context.programInfo.inputNames.forEach((t,r)=>{let n=this.context.inputTextureLayouts[r].shape;if(!(n.length<2||n.length>e)){let s=n.length,a=e-s,u=`bcastMatmulIndices_${t}`,l="";for(let c=0;c<s-2;++c)l+=`
+          realIndices[${c}] = int( mod(float(bcastedIndices[${a+c}]), ${n[c]}.0) );
+          `;let f=`
+        void ${u}(int bcastedIndices[${e}], out int realIndices[${s}]) {
+          ${l}
+          realIndices[${s-1}] = bcastedIndices[${e-1}];
+          realIndices[${s-2}] = bcastedIndices[${e-2}];
+        }
+        `;o[u]=new O(f)}}),o}indicesToOffset(){let e={};return this.context.programInfo.inputNames.forEach((o,t)=>{let r=this.context.inputTextureLayouts[t].shape,n=this.context.inputTextureLayouts[t].strides,s=r.length,a=`indicesToOffset_${o}`;e[a]=new O(i.indexToOffsetSingle(a,s,n)),a=`indicesToOffset_${o}_T`,e[a]=new O(i.indexToOffsetSingle(a,s,n.slice().reverse()))}),e}static indexToOffsetSingle(e,o,t){let r="";for(let n=o-1;n>=0;--n)r+=`
+        offset += indices[${n}] * ${t[n]};
+        `;return`
+      int ${e}(int indices[${o}]) {
+        int offset = 0;
+        ${r}
+        return offset;
+      }
+      `}offsetToIndices(){let e={};return this.context.programInfo.inputNames.forEach((o,t)=>{let r=this.context.inputTextureLayouts[t].shape,n=this.context.inputTextureLayouts[t].strides,s=r.length,a=`offsetToIndices_${o}`;e[a]=new O(i.offsetToIndicesSingle(a,s,n)),a=`offsetToIndices_${o}_T`,e[a]=new O(i.offsetToIndicesSingle(a,s,n.slice().reverse()))}),e}static offsetToIndicesSingle(e,o,t){let r=[];for(let n=0;n<o-1;++n)r.push(`
+      indices[${n}] = offset / ${t[n]};`),r.push(`
+        offset -= indices[${n}] * ${t[n]};`);return r.push(`
+      indices[${o-1}] = offset;`),`
+      void ${e}(int offset, out int indices[${o}]) {
+        ${r.join("")}
+      }
+      `}incrementIndices(){let e={};return this.context.programInfo.inputNames.forEach((o,t)=>{let r=this.context.inputTextureLayouts[t].shape,n=r.length,s=`incrementIndices_${o}`,a="";for(let l=0;l<n;++l)a+=`
+        shape[${l}] = ${r[l]};`;let u=`
+        void ${s}(int axis, out int indices[${n}]) {
+          int shape[${n}];
+          ${a};
+          for(int i = ${n} -1 ; i >= 0; --i) {
+            if(i > axis) continue;
+            indices[i] += 1;
+            if(indices[i] < shape[i]) {
+              break;
+            }
+            indices[i] = 0;
+          }
+        }
+        `;e[s]=new O(u)}),e}}});var Qr,xf=x(()=>{"use strict";Xt();Qr=class extends Ot{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let o=this.context.outputTextureLayout.shape.length,t={add:"+=",sub:"-=",mul:"*=",div:"/="},r={};for(let n in t){let s=`${n}Vec`,a="";for(let l=0;l<o;++l)a+=`
+          dest[${l}] ${t[n]} src[${l}];
+          `;let u=`
+        void ${s}(int src[${o}], out int dest[${o}]) {
+          ${a}
+        }
+        `;r[s]=new O(u)}return r}copyVec(){let o=this.context.outputTextureLayout.shape.length,t="";for(let n=0;n<o;++n)t+=`
+        dest[${n}] = src[${n}];
+        `;let r=`
+      void copyVec(int src[${o}], out int dest[${o}]) {
+        ${t}
+      }
+      `;return{copyVec:new O(r)}}setVecItem(){let o=this.context.outputTextureLayout.shape.length,t=`
+        if(index < 0)
+            index =${o} + index;
+        if (index == 0)
+            m[0] = value;
+        `;for(let n=1;n<o-1;++n)t+=`
+        else if (index == ${n})
+            m[${n}] = value;
+            `;t+=`
+        else
+            m[${o-1}] = value;
+        `;let r=`
+      void setVecItem(out int m[${o}], int index, int value) {
+        ${t}
+      }
+        `;return{setVecItem:new O(r)}}getVecItem(){let o=this.context.outputTextureLayout.shape.length,t=`
+        if(index < 0)
+            index = ${o} + index;
+        if (index == 0)
+            return m[0];
+      `;for(let n=1;n<o-1;++n)t+=`
+        else if (index == ${n})
+            return m[${n}];
+      `;t+=`
+        else
+            return m[${o-1}];
+        `;let r=`
+      int getVecItem(int m[${o}], int index) {
+        ${t}
+      }
+    `;return{getVecItem:new O(r)}}}});var ko,Tf=x(()=>{"use strict";mf();bf();gf();yf();xf();ko={encoding:Jr,fragcolor:Zr,vec:Qr,shapeUtils:Yr,coordinates:Kr}});var tn,wf=x(()=>{"use strict";Xt();df();Tf();X();tn=class{constructor(e,o,t,r){this.libs={};this.glslLibRoutineDependencyGraph={};this.context=new Rr(e,o,t,r),Object.keys(ko).forEach(s=>{let a=new ko[s](this.context);this.libs[s]=a});let n=this.glslLibRoutineDependencyGraph;for(let s in this.libs){let u=this.libs[s].getFunctions();for(let l in u){let f=s+"."+l,c;n[f]?(c=n[f],c.routineBody=u[l].routineBody):(c=new er(f,u[l].routineBody),n[f]=c);let d=u[l].dependencies;if(d)for(let m=0;m<d.length;++m)if(n[d[m]])c.addDependency(n[d[m]]);else{let g=new er(d[m]);n[d[m]]=g,c.addDependency(g)}}}}preprocess(){let e=this.context.programInfo,o=e.shaderSource;return this.context.programInfo.hasMain||(o=`${o}
+      ${ts(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),o=pf(o),`${Qa(this.context.glContext.version)}
+    ${this.getUniforms(e.inputNames,e.variables)}
+    ${this.getImports(o)}
+    ${o}`}getImports(e){let o=this.selectGlslLibRoutinesToBeIncluded(e);if(o.length===0)return"";let t="";for(let r=0;r<o.length;++r)if(o[r].routineBody)t+=o[r].routineBody+`
+`;else throw new Error(`Missing body for the Glsl Library routine: ${o[r].name}`);return t}selectGlslLibRoutinesToBeIncluded(e){let o=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(t=>{let r=t.split(".")[1];e.indexOf(r)!==-1&&o.push(this.glslLibRoutineDependencyGraph[t])}),Gr.returnOrderedNodes(o)}getUniforms(e,o){let t=[];if(e)for(let r of e)t.push(`uniform sampler2D ${r};`);if(o)for(let r of o)t.push(`uniform ${r.type} ${r.name}${r.arrayLength?`[${r.arrayLength}]`:""};`);return t.join(`
+`)}}});var en,vf=x(()=>{"use strict";$t();vt();wf();X();en=class{constructor(e,o,t){this.profiler=e;this.glContext=o;this.textureLayoutStrategy=t;this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,o){this.repo.set(e,o)}run(e,o,t){this.profiler.event("op",`ProgramManager.run ${e.programInfo.name??"unknown kernel"}`,()=>{let r=this.glContext.gl,n=e.program;r.useProgram(n);try{this.bindOutput(t),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,e.programInfo.variables??[],o)}catch(s){throw z.error("ProgramManager",e.programInfo.shaderSource),s}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,o,t){return this.profiler.event("backend","ProgramManager.build",()=>{let r=new tn(this.glContext,e,o,t),n=r.preprocess(),s=this.compile(n);return{programInfo:e,program:s,uniformLocations:this.getUniformLocations(s,r.context.programInfo.inputNames,r.context.programInfo.variables),attribLocations:this.getAttribLocations(s)}})}compile(e){if(!this.vertexShader){z.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let r=Ya(this.glContext.version);this.vertexShader=this.glContext.compileShader(r,this.glContext.gl.VERTEX_SHADER)}$.debug&&z.verbose("ProrgramManager",`FragShader:
+${e}
+`);let o=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),t=this.glContext.createProgram(this.vertexShader,o);return this.glContext.deleteShader(o),t}bindOutput(e){let o=e.width,t=e.height;z.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${o}/${t}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,o,t)}bindAttributes(e){let o=e.position,t=e.textureCoord;this.glContext.setVertexAttributes(o,t),this.attributesBound=!0}bindUniforms(e,o,t){let r=this.glContext.gl,n=0;for(let{name:s,type:a,location:u,arrayLength:l}of e){let f=o.find(c=>c.name===s)?.data;if(a!=="sampler2D"&&!f)throw new Error(`variable '${s}' does not have data defined in program info`);switch(a){case"sampler2D":this.bindTexture(t[n],u,n),n++;break;case"float":l?r.uniform1fv(u,f):r.uniform1f(u,f);break;case"int":l?r.uniform1iv(u,f):r.uniform1i(u,f);break;default:throw new Error(`Uniform not implemented: ${a}`)}}}bindTexture(e,o,t){this.glContext.bindTextureToUniform(e.texture,t,o)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,o,t){let r=[];if(o)for(let n of o)r.push({name:n,type:"sampler2D",location:this.getUniformLocation(e,n)});if(t)for(let n of t)r.push({...n,location:this.getUniformLocation(e,n.name)});return r}getUniformLocation(e,o){let r=this.glContext.gl.getUniformLocation(e,o);if(r===null)throw new Error(`Uniform ${o} not found.`);return r}getAttribLocation(e,o){return this.glContext.gl.getAttribLocation(e,o)}}});var rn,If=x(()=>{"use strict";vt();Qe();rn=class{constructor(e,o,t,r){this.glContext=e;this.layoutStrategy=o;this.profiler=t;this.config=r;this.pendingRead=new Map;r.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,o,t,r){let n=this.toEncoderType(e),s=this.glContext.getEncoder(n,o.channels||1,r);if(o.isPacked&&r===1)throw new Error("not implemented");let a=o.width,u=o.height,l,f;if(this.config.reuseTextures){l=`${a}x${u}_${s.format}_${s.internalFormat}_${s.textureType}`,f=this.inUseTextures.get(l),f||(f=[],this.inUseTextures.set(l,f));let d=this.idleTextures.get(l);if(d&&d.length>0){let m=d.pop();return f.push(m),r===1&&this.glContext.updateTexture(m,a,u,s,this.toTextureData(e,t)),m}}z.verbose("TextureManager",`Creating new texture of size ${o.width}x${o.height}`);let c=this.glContext.allocateTexture(a,u,s,this.toTextureData(e,t));return this.config.reuseTextures&&(f.push(c),this.textureLookup.set(c,l)),c}readTexture(e,o,t){return t||(t=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let r=e.shape.reduce((s,a)=>s*a)*t,n=this.glContext.readTexture(e.texture,e.width,e.height,r,this.toEncoderType(o),t);return this.toTensorData(o,n)})}async readTextureAsync(e,o,t){let r=e.tensor.dataId;if(t||(t=1),this.pendingRead.has(r)){let n=this.pendingRead.get(r);return new Promise(s=>n?.push(s))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(r,[]);let n=e.shape.reduce((l,f)=>l*f)*t;await this.glContext.createAndWaitForFence();let s=this.glContext.readTexture(e.texture,e.width,e.height,n,this.toEncoderType(o),t),a=this.toTensorData(o,s),u=this.pendingRead.get(r);return this.pendingRead.delete(r),u?.forEach(l=>l(a)),a})}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let o=e.shape.reduce((r,n)=>r*n),t=this.glContext.readTexture(e.texture,e.width,e.height,o*4,"byte",4);return new Float32Array(t.buffer,t.byteOffset,o)})}releaseTexture(e,o){let t;if(this.config.reuseTextures&&(t=this.textureLookup.get(e.texture),t)){o&&this.textureLookup.delete(t);let r=this.inUseTextures.get(t);if(r){let n=r.indexOf(e.texture);if(n!==-1){r.splice(n,1);let s=this.idleTextures.get(t);s||(s=[],this.idleTextures.set(t,s)),s.push(e.texture)}}}(!t||o)&&(z.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,o){switch(e){case"int16":return o instanceof Int16Array?o:Int16Array.from(o);case"int32":return o instanceof Int32Array?o:Int32Array.from(o);case"int8":return o instanceof Int8Array?o:Int8Array.from(o);case"uint16":return o instanceof Uint16Array?o:Uint16Array.from(o);case"uint32":return o instanceof Uint32Array?o:Uint32Array.from(o);case"uint8":case"bool":return o instanceof Uint8Array?o:Uint8Array.from(o);case"float32":return o instanceof Float32Array?o:Float32Array.from(o);case"float64":return o instanceof Float64Array?o:Float64Array.from(o);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,o){if(o)return o instanceof Float32Array?o:new Float32Array(o)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}});var nn,_f=x(()=>{"use strict";vt();Ri();ms();ff();vf();$o();If();nn=class{constructor(e,o){this.backend=e;this.context=o;this.layoutStrategy=new Xr(e.glContext.maxTextureSize),this.programManager=new en(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new rn(e.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:e.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=e.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new Cr(this)}onGraphInitialized(e){let o=e.getValues().filter(t=>t.from===-1&&t.tensor).map(t=>t.tensor.dataId);this.initializers=new Set(o)}isInitializer(e){return this.initializers?this.initializers.has(e):!1}addInitializer(e){this.initializers.add(e)}getTextureData(e,o){return o?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,o,t=!1){z.verbose("WebGLSessionHandler","Storing Texture data in cache"),t?this.packedTextureDataCache.set(e,o):this.unpackedTextureDataCache.set(e,o)}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,o,t){let r=Ci(e,o,lf);return{impl:r.opImpl,context:r.opInit?r.opInit(e,t):e}}}});function Wh(i){let e=0;for(;e<i.length&&i[e]();++e);return e-1}var or,Sf=x(()=>{"use strict";$t();Qe();Qe();Mt();or=class{constructor(e,o){this.frameBufferBound=!1;this.itemsToPoll=[];this.gl=e,this.version=o,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,o,t,r){let n=this.gl,s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);let a=r?t.encode(r,e*o):null;return n.texImage2D(n.TEXTURE_2D,0,t.internalFormat,e,o,0,t.format,t.textureType,a),this.checkError(),s}updateTexture(e,o,t,r,n){let s=this.gl;s.bindTexture(s.TEXTURE_2D,e);let a=r.encode(n,o*t);s.texSubImage2D(s.TEXTURE_2D,0,0,0,o,t,r.format,r.textureType,a),this.checkError()}attachFramebuffer(e,o,t){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,o,t),r.scissor(0,0,o,t)}readTexture(e,o,t,r,n,s){let a=this.gl;s||(s=1),this.frameBufferBound||this.attachFramebuffer(e,o,t);let u=this.getEncoder(n,s),l=u.allocate(o*t);return a.bindTexture(a.TEXTURE_2D,e),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e,0),a.readPixels(0,0,o,t,a.RGBA,u.textureType,l),this.checkError(),u.decode(l,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,o){let t=this.gl;t.vertexAttribPointer(e,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(e),o!==-1&&(t.vertexAttribPointer(o,2,t.FLOAT,!1,20,12),t.enableVertexAttribArray(o)),this.checkError()}createProgram(e,o){let t=this.gl,r=t.createProgram();return t.attachShader(r,e),t.attachShader(r,o),t.linkProgram(r),r}compileShader(e,o){let t=this.gl,r=t.createShader(o);if(!r)throw new Error(`createShader() returned null with type ${o}`);if(t.shaderSource(r,e),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${t.getShaderInfoLog(r)}
+Shader source:
+${e}`);return r}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,o,t){let r=this.gl;r.activeTexture(r.TEXTURE0+o),this.checkError(),r.bindTexture(r.TEXTURE_2D,e),this.checkError(),r.uniform1i(t,o),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if($.debug){let e=this.gl,o=e.getError(),t="";switch(o){case e.NO_ERROR:return;case e.INVALID_ENUM:t="INVALID_ENUM";break;case e.INVALID_VALUE:t="INVALID_VALUE";break;case e.INVALID_OPERATION:t="INVALID_OPERATION";break;case e.INVALID_FRAMEBUFFER_OPERATION:t="INVALID_FRAMEBUFFER_OPERATION";break;case e.OUT_OF_MEMORY:t="OUT_OF_MEMORY";break;case e.CONTEXT_LOST_WEBGL:t="CONTEXT_LOST_WEBGL";break;default:t=`Unknown WebGL Error: ${o.toString(16)}`}throw new Error(t)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,o,t=0){if(this.version===2)return new Fr(this.gl,o);switch(e){case"float":return t===1||this.isRenderFloat32Supported?new Ye(this.gl,o):new Ye(this.gl,o,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new Nr(this.gl,o);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){let e=this.gl;for(let o=0;o<this.maxTextureImageUnits;++o)e.activeTexture(e.TEXTURE0+o),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,o=e.createBuffer();if(!o)throw new Error("createBuffer() returned null");let t=this.createDefaultGeometry();return e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),this.checkError(),o}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(),this.version===1&&!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(){this.version===2?(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,o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o);let t=this.version===2?e.RGBA32F:e.RGBA;e.texImage2D(e.TEXTURE_2D,0,t,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,o,0);let n=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(o),e.deleteFramebuffer(r),n}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){let e=this.gl,o,t,r,n,s;try{o=e.createTexture(),t=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,o);let a=this.version===2?e.RGBA32F:e.RGBA;return e.texImage2D(e.TEXTURE_2D,0,a,1,1,0,e.RGBA,e.FLOAT,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),e.enable(e.BLEND),r=e.createShader(e.VERTEX_SHADER),!r||(e.shaderSource(r,"void main(){}"),e.compileShader(r),n=e.createShader(e.FRAGMENT_SHADER),!n)||(e.shaderSource(n,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),e.compileShader(n),s=e.createProgram(),!s)?!1:(e.attachShader(s,r),e.attachShader(s,n),e.linkProgram(s),e.useProgram(s),e.drawArrays(e.POINTS,0,1),e.getError()===e.NO_ERROR)}finally{e.disable(e.BLEND),s&&e.deleteProgram(s),r&&e.deleteShader(r),n&&e.deleteShader(n),t&&(e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(t)),o&&(e.bindTexture(e.TEXTURE_2D,null),e.deleteTexture(o))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,o=this.disjointTimerQueryWebgl2Extension,t=e.createQuery();return e.beginQuery(o.TIME_ELAPSED_EXT,t),t}else throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,o=this.disjointTimerQueryWebgl2Extension;e.endQuery(o.TIME_ELAPSED_EXT);return}else throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(e){let o=!1,t=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let r=this.gl,n=this.disjointTimerQueryWebgl2Extension;o=r.getQueryParameter(e,r.QUERY_RESULT_AVAILABLE),t=r.getParameter(n.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return o&&!t}getTimerResult(e){let o=0;if(this.version===2){let t=this.gl;o=t.getQueryParameter(e,t.QUERY_RESULT),t.deleteQuery(e)}else throw new Error("WebGL1 profiling currently not supported");return o/1e6}async waitForQueryAndGetTime(e){return await no(()=>this.isTimerResultAvailable(e)),this.getTimerResult(e)}async createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let o,t=e,r=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),r===null?o=()=>!0:o=()=>{let n=t.clientWaitSync(r,0,0);return n===t.ALREADY_SIGNALED||n===t.CONDITION_SATISFIED},{query:r,isFencePassed:o}}async pollFence(e){return new Promise(o=>{this.addItemToPoll(()=>e.isFencePassed(),()=>o())})}pollItems(){let e=Wh(this.itemsToPoll.map(o=>o.isDoneFn));for(let o=0;o<=e;++o){let{resolveFn:t}=this.itemsToPoll[o];t()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,o){this.itemsToPoll.push({isDoneFn:e,resolveFn:o}),!(this.itemsToPoll.length>1)&&await no(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Bo(i){let e;if((!i||i==="webgl2")&&"webgl2"in Fe?e=Fe.webgl2:(!i||i==="webgl")&&"webgl"in Fe&&(e=Fe.webgl),!e)try{let t=qh();e=Of(t,i)}catch{let r=Hh();e=Of(r,i)}i=i||e.version===1?"webgl":"webgl2";let o=e.gl;return Fe[i]=e,o.isContextLost()?(delete Fe[i],Bo(i)):(o.disable(o.DEPTH_TEST),o.disable(o.STENCIL_TEST),o.disable(o.BLEND),o.disable(o.DITHER),o.disable(o.POLYGON_OFFSET_FILL),o.disable(o.SAMPLE_COVERAGE),o.enable(o.SCISSOR_TEST),o.enable(o.CULL_FACE),o.cullFace(o.BACK),e)}function Of(i,e){let o={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},t,r=o;if((!e||e==="webgl2")&&(t=i.getContext("webgl2",r),t))try{return new or(t,2)}catch(n){z.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${n}`)}if((!e||e==="webgl")&&(t=i.getContext("webgl",r)||i.getContext("experimental-webgl",r),t))try{return new or(t,1)}catch(n){z.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${n}`)}throw new Error("WebGL is not supported")}function Hh(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let i=document.createElement("canvas");return i.width=1,i.height=1,i}function qh(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var Fe,Af=x(()=>{"use strict";vt();Sf();Fe={}});var on,Pf=x(()=>{"use strict";$t();vt();_f();Af();on=class{get contextId(){return $.webgl.contextId}set contextId(e){$.webgl.contextId=e}get matmulMaxBatchSize(){return $.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){$.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return $.webgl.textureCacheMode}set textureCacheMode(e){$.webgl.textureCacheMode=e}get pack(){return $.webgl.pack}set pack(e){$.webgl.pack=e}get async(){return $.webgl.async}set async(e){$.webgl.async=e}initialize(){try{return this.glContext=Bo(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),z.setWithEnv($),$.webgl.context||Object.defineProperty($.webgl,"context",{value:this.glContext.gl}),z.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return z.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new nn(this,e)}dispose(){this.glContext.dispose()}}});async function Fo(i){if(i){let e=typeof i=="string"?[i]:i;for(let o of e){let t=Ef.get(o);if(t)return t;let r=await Xh(o);if(r)return r}}else return Fo(["webgl"]);throw new Error("no available backend to use")}async function Xh(i){let e=jh;if(typeof e[i]<"u"&&Kh(e[i])){let o=e[i],t=o.initialize();if(typeof t=="object"&&"then"in t&&(t=await t),t)return Ef.set(i,o),o}}function Kh(i){let e=i;return"initialize"in e&&typeof e.initialize=="function"&&"createSessionHandler"in e&&typeof e.createSessionHandler=="function"&&"dispose"in e&&typeof e.dispose=="function"}var Ef,jh,Df=x(()=>{"use strict";Pf();Ef=new Map,jh={webgl:new on}});var No,an,Lf=x(()=>{"use strict";vt();No=class{constructor(e,o){this.op=e;this.node=o}},an=class{constructor(e,o,t){this.graph=e;this.profiler=t;this.initialize(o)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",()=>{let o=this.graph.getNodes();if(o.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map((t,r)=>new No(t,o[r])),this.reset(),this._starter=[],this._ops.forEach((t,r)=>{let n=!0;for(let s of t.node.inputs)if(!this._values[s]&&this.graph.getInputIndices().indexOf(s)===-1){n=!1;break}n&&this._starter.push(r)})})}reset(){this._values=this.graph.getValues().map(e=>e.tensor)}async execute(e,o){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let t=e.createInferenceHandler(),r=this.graph.getInputIndices();if(o.length!==r.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${o.length} expected: ${r.length}`);o.forEach((f,c)=>{let d=r[c];this._values[d]=f});let n=this._starter.slice(0),s=this.graph.getValues(),a=this.graph.getNodes(),u=0;for(;u<n.length;){let f=n[u++],c=this._ops[f],d=c.node.inputs.map(T=>this._values[T]);if(d.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${c.node}`);let m=d;z.verbose("ExecPlan",`Running op:${c.node.name} (${m.map((T,_)=>`'${c.node.inputs[_]}': ${T.type}[${T.dims.join(",")}]`).join(", ")})`);let g=await this.profiler.event("node",c.node.name,async()=>c.op.impl(t,m,c.op.context));if(g.length!==c.node.outputs.length)throw new Error("the size of output does not match model definition.");g.forEach((T,_)=>{let w=c.node.outputs[_];if(this._values[w])throw new Error(`output [${w}] already has value: op:${c.node.name}`);this._values[w]=T});let y=new Set;g.forEach((T,_)=>{let w=c.node.outputs[_];for(let v of s[w].to){let L=a[v],B=!0;for(let Q of L.inputs)if(!this._values[Q]){B=!1;break}B&&y.add(v)}}),n.push(...y)}let l=[];for(let f=0;f<this.graph.getOutputIndices().length;f++){let c=this.graph.getOutputIndices()[f],d=this._values[c];if(d===void 0)throw new Error(`required output [${c}] does not have value`);c===0?await d.getData():d.data,l.push(d)}return z.verbose("ExecPlan","disposing of inferenceHandler"),t.dispose(),l})}}});var C,Et,ir,$f=x(()=>{"use strict";qe();C=Ie(Ae());he();U();Et=P.experimental.fbs,ir=class i{constructor(e){if(this._attributes=new Map,e!=null){for(let o of e)o instanceof C.onnx.AttributeProto?this._attributes.set(o.name,[i.getValue(o),i.getType(o)]):o instanceof Et.Attribute&&this._attributes.set(o.name(),[i.getValue(o),i.getType(o)]);if(this._attributes.size<e.length)throw new Error("duplicated attribute names")}}set(e,o,t){this._attributes.set(e,[t,o])}delete(e){this._attributes.delete(e)}getFloat(e,o){return this.get(e,"float",o)}getInt(e,o){return this.get(e,"int",o)}getString(e,o){return this.get(e,"string",o)}getTensor(e,o){return this.get(e,"tensor",o)}getFloats(e,o){return this.get(e,"floats",o)}getInts(e,o){return this.get(e,"ints",o)}getStrings(e,o){return this.get(e,"strings",o)}getTensors(e,o){return this.get(e,"tensors",o)}get(e,o,t){let r=this._attributes.get(e);if(r===void 0){if(t!==void 0)return t;throw new Error(`required attribute not found: ${e}`)}if(r[1]!==o)throw new Error(`type mismatch: expected ${o} but got ${r[1]}`);return r[0]}static getType(e){let o=e instanceof C.onnx.AttributeProto?e.type:e.type();switch(o){case C.onnx.AttributeProto.AttributeType.FLOAT:return"float";case C.onnx.AttributeProto.AttributeType.INT:return"int";case C.onnx.AttributeProto.AttributeType.STRING:return"string";case C.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case C.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case C.onnx.AttributeProto.AttributeType.INTS:return"ints";case C.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case C.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${C.onnx.AttributeProto.AttributeType[o]}`)}}static getValue(e){let o=e instanceof C.onnx.AttributeProto?e.type:e.type();if(o===C.onnx.AttributeProto.AttributeType.GRAPH||o===C.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let t=this.getValueNoCheck(e);if(o===C.onnx.AttributeProto.AttributeType.INT&&bt.isLong(t))return bt.longToNumber(t);if(o===C.onnx.AttributeProto.AttributeType.INTS){let r=t,n=new Array(r.length);for(let s=0;s<r.length;s++){let a=r[s];n[s]=bt.longToNumber(a)}return n}if(o===C.onnx.AttributeProto.AttributeType.TENSOR)return e instanceof C.onnx.AttributeProto?et.fromProto(t):et.fromOrtTensor(t);if(o===C.onnx.AttributeProto.AttributeType.TENSORS){if(e instanceof C.onnx.AttributeProto)return t.map(n=>et.fromProto(n));if(e instanceof Et.Attribute)return t.map(n=>et.fromOrtTensor(n))}return o===C.onnx.AttributeProto.AttributeType.STRING&&e instanceof C.onnx.AttributeProto?Ze(t):o===C.onnx.AttributeProto.AttributeType.STRINGS&&e instanceof C.onnx.AttributeProto?t.map(Ze):t}static getValueNoCheck(e){return e instanceof C.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(e):this.getValueNoCheckFromOrtFormat(e)}static getValueNoCheckFromOnnxFormat(e){switch(e.type){case C.onnx.AttributeProto.AttributeType.FLOAT:return e.f;case C.onnx.AttributeProto.AttributeType.INT:return e.i;case C.onnx.AttributeProto.AttributeType.STRING:return e.s;case C.onnx.AttributeProto.AttributeType.TENSOR:return e.t;case C.onnx.AttributeProto.AttributeType.GRAPH:return e.g;case C.onnx.AttributeProto.AttributeType.FLOATS:return e.floats;case C.onnx.AttributeProto.AttributeType.INTS:return e.ints;case C.onnx.AttributeProto.AttributeType.STRINGS:return e.strings;case C.onnx.AttributeProto.AttributeType.TENSORS:return e.tensors;case C.onnx.AttributeProto.AttributeType.GRAPHS:return e.graphs;default:throw new Error(`unsupported attribute type: ${C.onnx.AttributeProto.AttributeType[e.type]}`)}}static getValueNoCheckFromOrtFormat(e){switch(e.type()){case Et.AttributeType.FLOAT:return e.f();case Et.AttributeType.INT:return e.i();case Et.AttributeType.STRING:return e.s();case Et.AttributeType.TENSOR:return e.t();case Et.AttributeType.GRAPH:return e.g();case Et.AttributeType.FLOATS:return e.floatsArray();case Et.AttributeType.INTS:{let o=[];for(let t=0;t<e.intsLength();t++)o.push(e.ints(t));return o}case Et.AttributeType.STRINGS:{let o=[];for(let t=0;t<e.stringsLength();t++)o.push(e.strings(t));return o}case Et.AttributeType.TENSORS:{let o=[];for(let t=0;t<e.tensorsLength();t++)o.push(e.tensors(t));return o}default:throw new Error(`unsupported attribute type: ${Et.AttributeType[e.type()]}`)}}}});var Ro,sn,Go,zt,un,Co,kf=x(()=>{"use strict";$f();qe();Ro=Ie(Ae());he();U();sn=P.experimental.fbs,Go={from:(i,e)=>new Co(i,e)},zt=class{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=st.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}},un=class{constructor(e,o){e instanceof Ro.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new ir(e.attribute)):e instanceof sn.Node&&(this.name=o??e.name(),this.opType=e.opType(),this.attributes=new ir(st.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Co=class{constructor(e,o){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(o),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 Ro.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else if(e instanceof sn.Graph)this.buildGraphFromOrtFormat(e);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(e){let o=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let t=new Map;if(!e.input)throw new Error("missing information in graph: input");let r=[];for(let n of e.input){if(o.has(n.name))throw new Error(`duplicated input name: ${n.name}`);let s=this._allData.push(new zt(n))-1;o.set(n.name,s),r.push(n.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(let n of e.initializer){let s=o.get(n.name);if(s===void 0){let a=new zt;a.type={shape:{dims:st.tensorDimsFromProto(n.dims)},tensorType:st.tensorDataTypeFromProto(n.dataType)},s=this._allData.push(a)-1,o.set(n.name,s)}this._allData[s]._from=-1,this._allData[s].tensor=et.fromProto(n)}for(let n=0;n<this._allData.length;n++)this._allData[n].tensor||(this._allInputIndices.push(n),this._allInputNames.push(r[n]));if(!e.output)throw new Error("missing information in graph: output");for(let n of e.output){if(o.has(n.name))throw new Error(`duplicated output name: ${n.name}`);let s=this._allData.push(new zt(n))-1;o.set(n.name,s),this._allOutputIndices.push(s),this._allOutputNames.push(n.name)}if(!e.node)throw new Error("missing information in graph: node");for(let n of e.node){if(!n.name)for(let a=0;;a++){let u=`unnamed_${n.opType}_${a}`;if(!t.has(u)){n.name=u;break}}if(t.has(n.name))throw new Error(`duplicated node name: ${n.name}`);let s=this._nodes.push(new un(n))-1;t.set(n.name,s)}for(let n=0;n<this._nodes.length;n++){let s=this._nodes[n],a=e.node[n];if(!a.output)throw new Error(`missing output for node: ${a.name}`);for(let u of a.output){let l=o.get(u);if(typeof l>"u"&&(l=this._allData.push(new zt)-1,o.set(u,l)),s.outputs.push(l),this._allData[l]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${l}`);if(this._allData[l]._from=n,a.opType==="Constant"){if(!a.attribute||a.attribute.length!==1||!a.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!a.output||a.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");s.outputs.pop(),s.executeNode=!1,this._allData[l]._from=-1,this._allData[l].tensor=et.fromProto(a.attribute[0].t)}}}for(let n=0;n<this._nodes.length;n++){let s=this._nodes[n],a=e.node[n];if(!a.input)throw new Error(`missing input for node: ${a.name}`);for(let u of a.input){let l=o.get(u);if(typeof l>"u"){if(u===""&&(a.input.length===3||a.input.length===4)&&a.opType==="Resize")continue;throw new Error(`unrecognized input '${u}' for node: ${a.name}`)}s.inputs.push(l),this._allData[l]._to.push(n)}}return!0}buildGraphFromOrtFormat(e){let o=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let t=new Map,r=[];for(let n=0;n<e.inputsLength();n++){let s=e.inputs(n);if(o.has(s))throw new Error(`duplicated input name: ${s}`);for(let a=0;a<e.nodeArgsLength();a++)if(e.nodeArgs(a)?.name()===s){let u=new zt;if(e.nodeArgs(a)?.type()?.valueType()!==sn.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let f=e.nodeArgs(a).type().value(new sn.TensorTypeAndShape),c=st.tensorDataTypeFromProto(f.elemType()),d=f.shape(),m=[];for(let y=0;y<d.dimLength();y++)m.push(bt.longToNumber(d.dim(y).value().dimValue()));u.type={shape:{dims:m},tensorType:c};let g=this._allData.push(u)-1;o.set(s,g),r.push(s)}}for(let n=0;n<e.initializersLength();n++){let s=e.initializers(n),a=o.get(s.name());if(a===void 0){let u=new zt,l=st.tensorDimsFromORTFormat(s),f=st.tensorDataTypeFromProto(s.dataType());u.type={shape:{dims:l},tensorType:f},a=this._allData.push(u)-1,o.set(s.name(),a)}this._allData[a]._from=-1,this._allData[a].tensor=et.fromOrtTensor(s)}for(let n=0;n<this._allData.length;n++)this._allData[n].tensor||(this._allInputIndices.push(n),this._allInputNames.push(r[n]));for(let n=0;n<e.outputsLength();n++){let s=e.outputs(n);if(o.has(s))throw new Error(`duplicated output name: ${s}`);let a=this._allData.push(new zt)-1;o.set(s,a),this._allOutputIndices.push(a),this._allOutputNames.push(s)}if(!e.nodes)throw new Error("missing information in graph: node");for(let n=0;n<e.nodesLength();n++){let s=e.nodes(n),a=s.name();if(!a)for(let l=0;a=`unnamed_${s.opType()}_${l}`,!!t.has(a);l++);if(t.has(a))throw new Error(`duplicated node name: ${a}`);let u=this._nodes.push(new un(s,a))-1;t.set(a,u)}for(let n=0;n<this._nodes.length;n++){let s=this._nodes[n],a=e.nodes(n);if(a==null)throw new Error(`No node exists at index ${n}`);if(a?.outputsLength()===0)throw new Error(`missing output for node: ${a.name}`);for(let u=0;u<a?.outputsLength();u++){let l=a?.outputs(u),f=o.get(l);if(typeof f>"u"&&(f=this._allData.push(new zt)-1,o.set(l,f)),s.outputs.push(f),this._allData[f]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${f}`);if(this._allData[f]._from=n,a.opType()==="Constant"){if(a.attributesLength()!==1||!a.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(a.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");s.outputs.pop(),s.executeNode=!1,this._allData[f]._from=-1,this._allData[f].tensor=et.fromOrtTensor(a.attributes(0).t())}}}for(let n=0;n<this._nodes.length;n++){let s=this._nodes[n],a=e.nodes(n);if(a.inputsLength()===0)throw new Error(`missing input for node: ${a.name}`);for(let u=0;u<a.inputsLength();u++){let l=a.inputs(u),f=o.get(l);if(typeof f>"u")throw new Error(`unrecognized input '${l}' for node: ${a.name()}`);s.inputs.push(f),this._allData[f]._to.push(n)}}}checkIsAcyclic(){let e=new Set;this._allInputIndices.forEach(r=>{this._allData[r]._to.forEach(s=>{e.add(s)})});let o=Array.from(e),t=new Array(this._nodes.length).fill("white");for(;o.length>0;){let r=o.pop();t[r]==="gray"?t[r]="black":(o.push(r),t[r]="gray",this._nodes[r].outputs.forEach(n=>{let s=this._allData[n];if(typeof s.tensor<"u")throw new Error("node outputs should not be initialized");if(s._from!==r)throw new Error("from property of the Value object doesn't match index of Node being processed");s._to.forEach(a=>{if(t[a]==="gray")throw new Error("model graph is cyclic");t[a]==="white"&&o.push(a)})}))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0,o=new Array(this._nodes.length,0),t=0;for(let r=0;r<this._nodes.length;r++)o[r]=t,this._nodes[r].executeNode?(t!==r&&(this._nodes[t]=this._nodes[r]),t++):this._nodes[r].outputs.forEach(n=>{this._allData[n]._from=-2});this._nodes.splice(t,this._nodes.length-t);for(let r=0;r<this._allData.length;r++){let n=this._allData[r];n._from!==void 0&&n._from!==-1&&n._from!==-2&&(n._from=o[n._from]);for(let s=0;s<n._to.length;s++)if(n._to[s]>=0)n._to[s]=o[n._to[s]];else throw new Error("Trying to update a removed node")}e=0;for(let r=0;r<this._allData.length;r++){if(this._allData[r].from===-2&&this._allOutputIndices.indexOf(r+e)===-1){e++,this._allData.splice(r,1),r--;continue}if(e>0){let n=-1;this._allData[r].from!==void 0&&this._allData[r].from!==-1?(n=this._nodes[this._allData[r].from].outputs.indexOf(r+e),n!==-1&&(this._nodes[this._allData[r].from].outputs[n]=r)):(n=this._allInputIndices.indexOf(r+e),n!==-1&&(this._allInputIndices[n]=r)),this._allData[r].to.forEach(s=>{n=this._nodes[s].inputs.indexOf(r+e),n!==-1&&(this._nodes[s].inputs[n]=r)}),this._allData[r].to.length===0&&(n=this._allOutputIndices.indexOf(r+e),n!==-1&&(this._allOutputIndices[n]=r))}}}deleteNode(e){let o=this._nodes[e];if(o.outputs.length>1){for(let a=1;a<o.outputs.length;a++)if(this._allData[o.outputs[a]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}o.executeNode=!1;let t=o.inputs[0],r=o.outputs[0],n=this._allData[r].to;for(let a=0;a<o.inputs.length;a++){let u=this._allData[o.inputs[a]].to.indexOf(e);if(u===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[o.inputs[a]].to.splice(u,1)}this._allData[r]._to=[];let s=this._allOutputIndices.indexOf(r);if(s!==-1&&(this._allOutputIndices[s]=t),n&&n.length>0)for(let a of n){let u=this._nodes[a].inputs.indexOf(r);if(u===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[a].inputs[u]=t,this._allData[t].to.push(a)}}removeAllDropoutNodes(){let e=0;for(let o of this._nodes){if(o.opType==="Dropout"){if(o.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(o.outputs.length!==1&&o.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(o.outputs.length===2&&this._allData[o.outputs[1]]._to.length!==0)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 o of this._nodes)o.opType==="Identity"&&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(e.opType==="Conv"){let o=this._allData[e.outputs[0]]._to;if(o.length===1&&this.isActivation(this._nodes[o[0]])){let t=this._nodes[o[0]];if(t.opType==="Clip")if(t.inputs.length===1)try{e.attributes.set("activation_params","floats",[t.attributes.getFloat("min"),t.attributes.getFloat("max")])}catch{e.attributes.set("activation_params","floats",[pe,de])}else if(t.inputs.length>=3&&this._allData[t.inputs[1]].tensor!==void 0&&this._allData[t.inputs[2]].tensor!==void 0)e.attributes.set("activation_params","floats",[this._allData[t.inputs[1]].tensor.floatData[0],this._allData[t.inputs[2]].tensor.floatData[0]]);else continue;e.attributes.set("activation","string",t.opType),this.deleteNode(o[0])}}}}});var Bf,Jh,ln,Ff=x(()=>{"use strict";Pr();kf();qe();Bf=Ie(Ae());U();Jh=P.experimental.fbs,ln=class{constructor(){}load(e,o,t){let r;if(!t)try{this.loadFromOnnxFormat(e,o);return}catch(n){if(t!==void 0)throw n;r=n}try{this.loadFromOrtFormat(e,o)}catch(n){throw t!==void 0?n:new Error(`Failed to load model as ONNX format: ${r}
+as ORT format: ${n}`)}}loadFromOnnxFormat(e,o){let t=Bf.onnx.ModelProto.decode(e);if(bt.longToNumber(t.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=t.opsetImport.map(n=>({domain:n.domain,version:bt.longToNumber(n.version)})),this._graph=Go.from(t.graph,o)}loadFromOrtFormat(e,o){let t=new b.ByteBuffer(e),r=Jh.InferenceSession.getRootAsInferenceSession(t).model();if(bt.longToNumber(r.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let s=0;s<r.opsetImportLength();s++){let a=r.opsetImport(s);this._opsets.push({domain:a?.domain(),version:bt.longToNumber(a.version())})}this._graph=Go.from(r.graph(),o)}get graph(){return this._graph}get opsets(){return this._opsets}}});var fn,Nf=x(()=>{"use strict";Df();Lf();vt();Ff();fn=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=Or.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,o,t){await this.profiler.event("session","Session.loadModel",async()=>{let r=await Fo(this.backendHint);if(this.sessionHandler=r.createSessionHandler(this.context),this._model=new ln,typeof e=="string"){let n=e.endsWith(".ort");{let a=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(a),n)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{let n=new Uint8Array(e,o||0,t||e.byteLength);this.initialize(n)}})}initialize(e,o){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let t=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,t,o),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new an(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 o=this.normalizeAndValidateInputs(e),t=await this._executionPlan.execute(this.sessionHandler,o);return this.createOutput(t)})}normalizeAndValidateInputs(e){let o=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==o.length)throw new Error(`incorrect input array length: expected ${o.length} but got ${e.length}`)}else{if(e.size!==o.length)throw new Error(`incorrect input map size: expected ${o.length} but got ${e.size}`);let t=new Array(e.size),r=0;for(let n=0;n<o.length;++n){let s=e.get(o[n]);if(!s)throw new Error(`missing input tensor for: '${name}'`);t[r++]=s}e=t}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){let t=this._model.graph.getInputIndices(),r=this._model.graph.getValues(),n=new Array(t.length);for(let s=0;s<t.length;++s){let a=r[t[s]];n[s]=a.type.shape.dims,this.context.graphInputTypes.push(a.type.tensorType),this.context.graphInputDims.push(e[s].dims)}this.validateInputTensorDims(n,e,!0)}else this.validateInputTensorDims(this.context.graphInputDims,e,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,e),e}validateInputTensorTypes(e,o){for(let t=0;t<o.length;t++){let r=e[t],n=o[t].type;if(r!==n)throw new Error(`input tensor[${t}] check failed: expected type '${r}' but got ${n}`)}}validateInputTensorDims(e,o,t){for(let r=0;r<o.length;r++){let n=e[r],s=o[r].dims;if(!this.compareTensorDims(n,s,t))throw new Error(`input tensor[${r}] check failed: expected shape '[${n.join(",")}]' but got [${s.join(",")}]`)}}compareTensorDims(e,o,t){if(e.length!==o.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==o[r]&&(!t||e[r]!==0))return!1;return!0}createOutput(e){let o=this._model.graph.getOutputNames();if(e.length!==o.length)throw new Error("expected number of outputs do not match number of generated outputs");let t=new Map;for(let r=0;r<o.length;++r)t.set(o[r],e[r]);return t}initializeOps(e){let o=e.getNodes();this._ops=new Array(o.length);for(let t=0;t<o.length;t++)this._ops[t]=this.sessionHandler.resolve(o[t],this._model.opsets,e)}}});var cn,Cf=x(()=>{"use strict";$t();he();cn=class{constructor(e){this.session=e;this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,o,t){let r=new Map;for(let a in e)if(Object.hasOwnProperty.call(e,a)){let u=e[a];r.set(a,new et(u.dims,u.type,void 0,void 0,u.data))}let n=await this.session.run(r),s={};return n.forEach((a,u)=>{s[u]=new rt(a.type,a.data,a.dims)}),s}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}});var Rf={};ze(Rf,{onnxjsBackend:()=>Zh});var Mo,Zh,Gf=x(()=>{"use strict";Nf();Cf();Mo=class{async init(){}async createInferenceSessionHandler(e,o){let t=new fn(o);return typeof e=="string"?await t.loadModel(e):await t.loadModel(e),new cn(t)}},Zh=new Mo});var pn=x(()=>{"use strict"});var Uf={};ze(Uf,{default:()=>Yh});var Mf,Vf,Yh,zf=x(()=>{"use strict";Vo();xe();ar();Mf="ort-wasm-proxy-worker",Vf=globalThis.self?.name===Mf;Vf&&(self.onmessage=i=>{let{type:e,in:o}=i.data;try{switch(e){case"init-wasm":dn(o.wasm).then(()=>{hn(o).then(()=>{postMessage({type:e})},t=>{postMessage({type:e,err:t})})},t=>{postMessage({type:e,err:t})});break;case"init-ep":{let{epName:t,env:r}=o;mn(r,t).then(()=>{postMessage({type:e})},n=>{postMessage({type:e,err:n})});break}case"copy-from":{let{buffer:t}=o,r=sr(t);postMessage({type:e,out:r});break}case"create":{let{model:t,options:r}=o;bn(t,r).then(n=>{postMessage({type:e,out:n})},n=>{postMessage({type:e,err:n})});break}case"release":gn(o),postMessage({type:e});break;case"run":{let{sessionId:t,inputIndices:r,inputs:n,outputIndices:s,options:a}=o;yn(t,r,n,s,new Array(s.length).fill(null),a).then(u=>{u.some(l=>l[3]!=="cpu")?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:u},Tn([...n,...u]))},u=>{postMessage({type:e,err:u})});break}case"end-profiling":xn(o),postMessage({type:e});break;default:}}catch(t){postMessage({type:e,err:t})}});Yh=Vf?null:i=>new Worker(i??Dt,{type:"classic",name:Mf})});var Dt,Qh,Hf,tm,em,qf,rm,Wf,jf,Xf,ar=x(()=>{"use strict";pn();Dt=!1?void 0:typeof document<"u"?document.currentScript?.src:typeof self<"u"?self.location?.href:void 0,Qh=!1||typeof location>"u"?void 0:location.origin,Hf=(i,e)=>{try{let o=e??Dt;return(o?new URL(i,o):new URL(i)).origin===Qh}catch{return!1}},tm=(i,e)=>{let o=e??Dt;try{return(o?new URL(i,o):new URL(i)).href}catch{return}},em=(i,e)=>`${e??"./"}${i}`,qf=async i=>{let o=await(await fetch(i,{credentials:"same-origin"})).blob();return URL.createObjectURL(o)},rm=async i=>(await import(/*webpackIgnore:true*/i)).default,Wf=(zf(),hr(Uf)).default,jf=async()=>{if(!Dt)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Hf(Dt))return[void 0,Wf()];let i=await qf(Dt);return[i,Wf(i)]},Xf=async(i,e,o)=>{{let t="ort-wasm-simd-threaded.mjs",r=i??tm(t,e),n=!!1&&o&&r&&!Hf(r,e),s=n?await qf(r):r??em(t,e);return[n?s:void 0,await rm(s)]}}});var Uo,zo,wn,Kf,nm,om,dn,nt,xe=x(()=>{"use strict";ar();zo=!1,wn=!1,Kf=!1,nm=()=>{if(typeof SharedArrayBuffer>"u")return!1;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}},om=()=>{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}},dn=async i=>{if(zo)return Promise.resolve();if(wn)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Kf)throw new Error("previous call to 'initializeWebAssembly()' failed.");wn=!0;let e=i.initTimeout,o=i.numThreads;if(!om())throw new Error("WebAssembly SIMD is not supported in the current environment.");let t=nm();o>1&&!t&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+o+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),i.numThreads=o=1);let r=i.wasmPaths,n=typeof r=="string"?r:void 0,s=r?.mjs,a=s?.href??s,u=r?.wasm,l=u?.href??u,f=i.wasmBinary,[c,d]=await Xf(a,n,o>1),m=!1,g=[];if(e>0&&g.push(new Promise(y=>{setTimeout(()=>{m=!0,y()},e)})),g.push(new Promise((y,T)=>{let _={numThreads:o};f?_.wasmBinary=f:(l||n)&&(_.locateFile=(w,v)=>l??(n??v)+w),d(_).then(w=>{wn=!1,zo=!0,Uo=w,y(),c&&URL.revokeObjectURL(c)},w=>{wn=!1,Kf=!0,T(w)})})),await Promise.race(g),m)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},nt=()=>{if(zo&&Uo)return Uo;throw new Error("WebAssembly is not initialized yet.")}});var ot,ur,Y,vn=x(()=>{"use strict";xe();ot=(i,e)=>{let o=nt(),t=o.lengthBytesUTF8(i)+1,r=o._malloc(t);return o.stringToUTF8(i,r,t),e.push(r),r},ur=(i,e,o,t)=>{if(typeof i=="object"&&i!==null){if(o.has(i))throw new Error("Circular reference in options");o.add(i)}Object.entries(i).forEach(([r,n])=>{let s=e?e+r:r;if(typeof n=="object")ur(n,s+".",o,t);else if(typeof n=="string"||typeof n=="number")t(s,n.toString());else if(typeof n=="boolean")t(s,n?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof n}`)})},Y=i=>{let e=nt(),o=e.stackSave();try{let t=e.stackAlloc(8);e._OrtGetLastError(t,t+4);let r=e.HEAP32[t/4],n=e.HEAPU32[t/4+1],s=n?e.UTF8ToString(n):"";throw new Error(`${i} ERROR_CODE: ${r}, ERROR_MESSAGE: ${s}`)}finally{e.stackRestore(o)}}});var Jf,Zf=x(()=>{"use strict";xe();vn();Jf=i=>{let e=nt(),o=0,t=[],r=i||{};try{if(i?.logSeverityLevel===void 0)r.logSeverityLevel=2;else if(typeof i.logSeverityLevel!="number"||!Number.isInteger(i.logSeverityLevel)||i.logSeverityLevel<0||i.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${i.logSeverityLevel}`);if(i?.logVerbosityLevel===void 0)r.logVerbosityLevel=0;else if(typeof i.logVerbosityLevel!="number"||!Number.isInteger(i.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${i.logVerbosityLevel}`);i?.terminate===void 0&&(r.terminate=!1);let n=0;return i?.tag!==void 0&&(n=ot(i.tag,t)),o=e._OrtCreateRunOptions(r.logSeverityLevel,r.logVerbosityLevel,!!r.terminate,n),o===0&&Y("Can't create run options."),i?.extra!==void 0&&ur(i.extra,"",new WeakSet,(s,a)=>{let u=ot(s,t),l=ot(a,t);e._OrtAddRunConfigEntry(o,u,l)!==0&&Y(`Can't set a run config entry: ${s} - ${a}.`)}),[o,t]}catch(n){throw o!==0&&e._OrtReleaseRunOptions(o),t.forEach(s=>e._free(s)),n}}});var im,am,sm,um,Yf,Qf=x(()=>{"use strict";xe();vn();im=i=>{switch(i){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${i}`)}},am=i=>{switch(i){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${i}`)}},sm=i=>{i.extra||(i.extra={}),i.extra.session||(i.extra.session={});let e=i.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),i.executionProviders&&i.executionProviders.some(o=>(typeof o=="string"?o:o.name)==="webgpu")&&(i.enableMemPattern=!1)},um=(i,e,o)=>{for(let t of e){let r=typeof t=="string"?t:t.name;switch(r){case"webnn":if(r="WEBNN",typeof t!="string"){let a=t?.deviceType;if(a){let u=ot("deviceType",o),l=ot(a,o);nt()._OrtAddSessionConfigEntry(i,u,l)!==0&&Y(`Can't set a session config entry: 'deviceType' - ${a}.`)}}break;case"webgpu":if(r="JS",typeof t!="string"){let s=t;if(s?.preferredLayout){if(s.preferredLayout!=="NCHW"&&s.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${s.preferredLayout}`);let a=ot("preferredLayout",o),u=ot(s.preferredLayout,o);nt()._OrtAddSessionConfigEntry(i,a,u)!==0&&Y(`Can't set a session config entry: 'preferredLayout' - ${s.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${r}`)}let n=ot(r,o);nt()._OrtAppendExecutionProvider(i,n)!==0&&Y(`Can't append execution provider: ${r}.`)}},Yf=i=>{let e=nt(),o=0,t=[],r=i||{};sm(r);try{let n=im(r.graphOptimizationLevel??"all"),s=am(r.executionMode??"sequential"),a=typeof r.logId=="string"?ot(r.logId,t):0,u=r.logSeverityLevel??2;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log serverity level is not valid: ${u}`);let l=r.logVerbosityLevel??0;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log verbosity level is not valid: ${l}`);let f=typeof r.optimizedModelFilePath=="string"?ot(r.optimizedModelFilePath,t):0;if(o=e._OrtCreateSessionOptions(n,!!r.enableCpuMemArena,!!r.enableMemPattern,s,!!r.enableProfiling,0,a,u,l,f),o===0&&Y("Can't create session options."),r.executionProviders&&um(o,r.executionProviders,t),r.enableGraphCapture!==void 0){if(typeof r.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${r.enableGraphCapture}`);let c=ot("enableGraphCapture",t),d=ot(r.enableGraphCapture.toString(),t);e._OrtAddSessionConfigEntry(o,c,d)!==0&&Y(`Can't set a session config entry: 'enableGraphCapture' - ${r.enableGraphCapture}.`)}if(r.freeDimensionOverrides)for(let[c,d]of Object.entries(r.freeDimensionOverrides)){if(typeof c!="string")throw new Error(`free dimension override name must be a string: ${c}`);if(typeof d!="number"||!Number.isInteger(d)||d<0)throw new Error(`free dimension override value must be a non-negative integer: ${d}`);let m=ot(c,t);e._OrtAddFreeDimensionOverride(o,m,d)!==0&&Y(`Can't set a free dimension override: ${c} - ${d}.`)}return r.extra!==void 0&&ur(r.extra,"",new WeakSet,(c,d)=>{let m=ot(c,t),g=ot(d,t);e._OrtAddSessionConfigEntry(o,m,g)!==0&&Y(`Can't set a session config entry: ${c} - ${d}.`)}),[o,t]}catch(n){throw o!==0&&e._OrtReleaseSessionOptions(o),t.forEach(s=>e._free(s)),n}}});var Wo,tc,Ho,ec,rc,In,nc,qo=x(()=>{"use strict";Wo=i=>{switch(i){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: ${i}`)}},tc=i=>{switch(i){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: ${i}`)}},Ho=i=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][i],ec=i=>{switch(i){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array: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: ${i}`)}},rc=i=>{switch(i){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: ${i}`)}},In=i=>i==="float32"||i==="float16"||i==="int32"||i==="int64"||i==="uint32"||i==="uint8"||i==="bool",nc=i=>{switch(i){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: ${i}`)}}});var lr,jo=x(()=>{"use strict";pn();lr=async i=>{if(typeof i=="string")if(!1)try{let{readFile:e}=En("node:fs/promises");return new Uint8Array(await e(i))}catch(e){if(e.code==="ERR_FS_FILE_TOO_LARGE"){let{createReadStream:o}=En("node:fs"),t=o(i),r=[];for await(let n of t)r.push(n);return new Uint8Array(Buffer.concat(r))}throw e}else{let e=await fetch(i);if(!e.ok)throw new Error(`failed to load external data file: ${i}`);let o=e.headers.get("Content-Length"),t=o?parseInt(o,10):0;if(t<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${i}, no response body.`);let r=e.body.getReader(),n;try{n=new ArrayBuffer(t)}catch(a){if(a instanceof RangeError){let u=Math.ceil(t/65536);n=new WebAssembly.Memory({initial:u,maximum:u}).buffer}else throw a}let s=0;for(;;){let{done:a,value:u}=await r.read();if(a)break;let l=u.byteLength;new Uint8Array(n,s,l).set(u),s+=l}return new Uint8Array(n,0,t)}}else return i instanceof Blob?new Uint8Array(await i.arrayBuffer()):i instanceof Uint8Array?i:new Uint8Array(i)}});var lm,hn,mn,Ne,fm,sr,bn,gn,oc,yn,xn,Tn,Vo=x(()=>{"use strict";Zf();Qf();qo();xe();vn();jo();lm=(i,e)=>{nt()._OrtInit(i,e)!==0&&Y("Can't initialize onnxruntime.")},hn=async i=>{lm(i.wasm.numThreads,rc(i.logLevel))},mn=async(i,e)=>{},Ne=new Map,fm=i=>{let e=nt(),o=e.stackSave();try{let t=e.stackAlloc(8);return e._OrtGetInputOutputCount(i,t,t+4)!==0&&Y("Can't get session input/output count."),[e.HEAP32[t/4],e.HEAP32[t/4+1]]}finally{e.stackRestore(o)}},sr=i=>{let e=nt(),o=e._malloc(i.byteLength);if(o===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${i.byteLength}.`);return e.HEAPU8.set(i,o),[o,i.byteLength]},bn=async(i,e)=>{let o,t,r=nt();Array.isArray(i)?[o,t]=i:i.buffer===r.HEAPU8.buffer?[o,t]=[i.byteOffset,i.byteLength]:[o,t]=sr(i);let n=0,s=0,a=0,u=[],l=[],f=[];try{if([s,u]=Yf(e),e?.externalData&&r.mountExternalData){let w=[];for(let v of e.externalData){let L=typeof v=="string"?v:v.path;w.push(lr(typeof v=="string"?v:v.data).then(B=>{r.mountExternalData(L,B)}))}await Promise.all(w)}for(let w of e?.executionProviders??[])if((typeof w=="string"?w:w.name)==="webnn"){if(r.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof w!="string"){let L=w,B=L?.context,Q=L?.gpuDevice,lt=L?.deviceType,Wt=L?.numThreads,Tt=L?.powerPreference;B?r.currentContext=B:Q?r.currentContext=await navigator.ml.createContext(Q):r.currentContext=await navigator.ml.createContext({deviceType:lt,numThreads:Wt,powerPreference:Tt})}else r.currentContext=await navigator.ml.createContext();break}n=await r._OrtCreateSession(o,t,s),n===0&&Y("Can't create a session."),r.currentContext&&(r.currentContext=void 0);let[c,d]=fm(n),m=!!e?.enableGraphCapture,g=[],y=[],T=[];for(let w=0;w<c;w++){let v=r._OrtGetInputName(n,w);v===0&&Y("Can't get an input name."),l.push(v),g.push(r.UTF8ToString(v))}for(let w=0;w<d;w++){let v=r._OrtGetOutputName(n,w);v===0&&Y("Can't get an output name."),f.push(v);let L=r.UTF8ToString(v);y.push(L)}let _=null;return Ne.set(n,[n,l,f,_,m,!1]),[n,g,y]}catch(c){throw l.forEach(d=>r._OrtFree(d)),f.forEach(d=>r._OrtFree(d)),a!==0&&r._OrtReleaseBinding(a),n!==0&&r._OrtReleaseSession(n),c}finally{r._free(o),s!==0&&r._OrtReleaseSessionOptions(s),u.forEach(c=>r._free(c)),r.unmountExternalData?.()}},gn=i=>{let e=nt(),o=Ne.get(i);if(!o)throw new Error(`cannot release session. invalid session id: ${i}`);let[t,r,n,s,a]=o;s&&(a&&e._OrtClearBoundOutputs(s.handle),e._OrtReleaseBinding(s.handle)),e.jsepOnReleaseSession?.(i),r.forEach(u=>e._OrtFree(u)),n.forEach(u=>e._OrtFree(u)),e._OrtReleaseSession(t),Ne.delete(i)},oc=(i,e,o,t,r,n=!1)=>{if(!i){e.push(0);return}let s=nt(),a=i[0],u=i[1],l=i[3],f,c;if(a==="string"&&l==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");if(n&&l!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${r} when enableGraphCapture is true.`);if(l==="gpu-buffer"){let g=i[2].gpuBuffer,y=Ho(Wo(a));c=u.reduce((_,w)=>_*w,1)*y;let T=s.jsepRegisterBuffer;if(!T)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');f=T(t,r,g,c)}else{let g=i[2];if(Array.isArray(g)){c=4*g.length,f=s._malloc(c),o.push(f);let y=f/4;for(let T=0;T<g.length;T++){if(typeof g[T]!="string")throw new TypeError(`tensor data at index ${T} is not a string`);s.HEAPU32[y++]=ot(g[T],o)}}else c=g.byteLength,f=s._malloc(c),o.push(f),s.HEAPU8.set(new Uint8Array(g.buffer,g.byteOffset,c),f)}let d=s.stackSave(),m=s.stackAlloc(4*u.length);try{let g=m/4;u.forEach(T=>s.HEAP32[g++]=T);let y=s._OrtCreateTensor(Wo(a),f,c,m,u.length,nc(l));y===0&&Y(`Can't create tensor for input/output. session=${t}, index=${r}.`),e.push(y)}finally{s.stackRestore(d)}},yn=async(i,e,o,t,r,n)=>{let s=nt(),a=Ne.get(i);if(!a)throw new Error(`cannot run inference. invalid session id: ${i}`);let u=a[0],l=a[1],f=a[2],c=a[3],d=a[4],m=a[5],g=e.length,y=t.length,T=0,_=[],w=[],v=[],L=[],B=s.stackSave(),Q=s.stackAlloc(g*4),lt=s.stackAlloc(g*4),Wt=s.stackAlloc(y*4),Tt=s.stackAlloc(y*4);try{[T,_]=Jf(n);for(let W=0;W<g;W++)oc(o[W],w,L,i,e[W],d);for(let W=0;W<y;W++)oc(r[W],v,L,i,g+t[W],d);let dt=Q/4,k=lt/4,gc=Wt/4,yc=Tt/4;for(let W=0;W<g;W++)s.HEAPU32[dt++]=w[W],s.HEAPU32[k++]=l[e[W]];for(let W=0;W<y;W++)s.HEAPU32[gc++]=v[W],s.HEAPU32[yc++]=f[t[W]];s.jsepOnRunStart?.(u);let Zo;Zo=await s._OrtRun(u,lt,Q,g,Tt,y,Wt,T),Zo!==0&&Y("failed to call OrtRun().");let Ge=[];for(let W=0;W<y;W++){let Me=s.HEAPU32[Wt/4+W];if(Me===v[W]){Ge.push(r[W]);continue}let Yo=s.stackSave(),ne=s.stackAlloc(4*4),cr=!1,wt,Ht=0;try{s._OrtGetTensorData(Me,ne,ne+4,ne+8,ne+12)!==0&&Y(`Can't access output tensor data on index ${W}.`);let pr=ne/4,Qo=s.HEAPU32[pr++];Ht=s.HEAPU32[pr++];let ti=s.HEAPU32[pr++],xc=s.HEAPU32[pr++],Ve=[];for(let gt=0;gt<xc;gt++)Ve.push(s.HEAPU32[ti/4+gt]);s._OrtFree(ti);let Ue=Ve.reduce((gt,yt)=>gt*yt,1);wt=tc(Qo);let ei=c?.outputPreferredLocations[t[W]];if(wt==="string"){if(ei==="gpu-buffer")throw new Error("String tensor is not supported on GPU.");let gt=[],yt=Ht/4;for(let ve=0;ve<Ue;ve++){let ri=s.HEAPU32[yt++],Tc=ve===Ue-1?void 0:s.HEAPU32[yt]-ri;gt.push(s.UTF8ToString(ri,Tc))}Ge.push([wt,Ve,gt,"cpu"])}else if(ei==="gpu-buffer"&&Ue>0){let gt=s.jsepGetBuffer;if(!gt)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let yt=gt(Ht),ve=Ho(Qo);if(ve===void 0||!In(wt))throw new Error(`Unsupported data type: ${wt}`);cr=!0,Ge.push([wt,Ve,{gpuBuffer:yt,download:s.jsepCreateDownloader(yt,Ue*ve,wt),dispose:()=>{s._OrtReleaseTensor(Me)}},"gpu-buffer"])}else{let gt=ec(wt),yt=new gt(Ue);new Uint8Array(yt.buffer,yt.byteOffset,yt.byteLength).set(s.HEAPU8.subarray(Ht,Ht+yt.byteLength)),Ge.push([wt,Ve,yt,"cpu"])}}finally{s.stackRestore(Yo),wt==="string"&&Ht&&s._free(Ht),cr||s._OrtReleaseTensor(Me)}}return c&&!d&&(s._OrtClearBoundOutputs(c.handle),Ne.set(i,[u,l,f,c,d,!1])),Ge}finally{s.stackRestore(B),w.forEach(dt=>s._OrtReleaseTensor(dt)),v.forEach(dt=>s._OrtReleaseTensor(dt)),L.forEach(dt=>s._free(dt)),T!==0&&s._OrtReleaseRunOptions(T),_.forEach(dt=>s._free(dt))}},xn=i=>{let e=nt(),o=Ne.get(i);if(!o)throw new Error("invalid session id");let t=o[0],r=e._OrtEndProfiling(t);r===0&&Y("Can't get an profile file name."),e._OrtFree(r)},Tn=i=>{let e=[];for(let o of i){let t=o[2];!Array.isArray(t)&&"buffer"in t&&e.push(t.buffer)}return e}});var we,Lt,fr,Sn,On,_n,Xo,Ko,Ce,Re,pm,ic,ac,sc,uc,lc,fc,cc,Jo=x(()=>{"use strict";$t();Vo();xe();ar();we=()=>!!$.wasm.proxy&&typeof document<"u",fr=!1,Sn=!1,On=!1,Ko=new Map,Ce=(i,e)=>{let o=Ko.get(i);o?o.push(e):Ko.set(i,[e])},Re=()=>{if(fr||!Sn||On||!Lt)throw new Error("worker not ready")},pm=i=>{switch(i.data.type){case"init-wasm":fr=!1,i.data.err?(On=!0,Xo[1](i.data.err)):(Sn=!0,Xo[0]()),_n&&(URL.revokeObjectURL(_n),_n=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=Ko.get(i.data.type);i.data.err?e.shift()[1](i.data.err):e.shift()[0](i.data.out);break}default:}},ic=async()=>{if(!Sn){if(fr)throw new Error("multiple calls to 'initWasm()' detected.");if(On)throw new Error("previous call to 'initWasm()' failed.");if(fr=!0,we())return new Promise((i,e)=>{Lt?.terminate(),jf().then(([o,t])=>{try{Lt=t,Lt.onerror=n=>e(n),Lt.onmessage=pm,Xo=[i,e];let r={type:"init-wasm",in:$};Lt.postMessage(r),_n=o}catch(r){e(r)}},e)});try{await dn($.wasm),await hn($),Sn=!0}catch(i){throw On=!0,i}finally{fr=!1}}},ac=async i=>{if(we())return Re(),new Promise((e,o)=>{Ce("init-ep",[e,o]);let t={type:"init-ep",in:{epName:i,env:$}};Lt.postMessage(t)});await mn($,i)},sc=async i=>we()?(Re(),new Promise((e,o)=>{Ce("copy-from",[e,o]);let t={type:"copy-from",in:{buffer:i}};Lt.postMessage(t,[i.buffer])})):sr(i),uc=async(i,e)=>{if(we()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Re(),new Promise((o,t)=>{Ce("create",[o,t]);let r={type:"create",in:{model:i,options:{...e}}},n=[];i instanceof Uint8Array&&n.push(i.buffer),Lt.postMessage(r,n)})}else return bn(i,e)},lc=async i=>{if(we())return Re(),new Promise((e,o)=>{Ce("release",[e,o]);let t={type:"release",in:i};Lt.postMessage(t)});gn(i)},fc=async(i,e,o,t,r,n)=>{if(we()){if(o.some(s=>s[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(r.some(s=>s))throw new Error("pre-allocated output tensor is not supported for proxy.");return Re(),new Promise((s,a)=>{Ce("run",[s,a]);let u=o,l={type:"run",in:{sessionId:i,inputIndices:e,inputs:u,outputIndices:t,options:n}};Lt.postMessage(l,Tn(u))})}else return yn(i,e,o,t,r,n)},cc=async i=>{if(we())return Re(),new Promise((e,o)=>{Ce("end-profiling",[e,o]);let t={type:"end-profiling",in:i};Lt.postMessage(t)});xn(i)}});var pc,dm,An,dc=x(()=>{"use strict";$t();Jo();qo();pn();jo();pc=(i,e)=>{switch(i.location){case"cpu":return[i.type,i.dims,i.data,"cpu"];case"gpu-buffer":return[i.type,i.dims,{gpuBuffer:i.gpuBuffer},"gpu-buffer"];default:throw new Error(`invalid data location: ${i.location} for ${e()}`)}},dm=i=>{switch(i[3]){case"cpu":return new rt(i[0],i[2],i[1]);case"gpu-buffer":{let e=i[0];if(!In(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:o,download:t,dispose:r}=i[2];return rt.fromGpuBuffer(o,{dataType:e,dims:i[1],download:t,dispose:r})}default:throw new Error(`invalid data location: ${i[3]}`)}},An=class{async fetchModelAndCopyToWasmMemory(e){return sc(await lr(e))}async loadModel(e,o){Kt();let t;typeof e=="string"?!1?t=await lr(e):t=await this.fetchModelAndCopyToWasmMemory(e):t=e,[this.sessionId,this.inputNames,this.outputNames]=await uc(t,o),Jt()}async dispose(){return lc(this.sessionId)}async run(e,o,t){Kt();let r=[],n=[];Object.entries(e).forEach(d=>{let m=d[0],g=d[1],y=this.inputNames.indexOf(m);if(y===-1)throw new Error(`invalid input '${m}'`);r.push(g),n.push(y)});let s=[],a=[];Object.entries(o).forEach(d=>{let m=d[0],g=d[1],y=this.outputNames.indexOf(m);if(y===-1)throw new Error(`invalid output '${m}'`);s.push(g),a.push(y)});let u=r.map((d,m)=>pc(d,()=>`input "${this.inputNames[n[m]]}"`)),l=s.map((d,m)=>d?pc(d,()=>`output "${this.outputNames[a[m]]}"`):null),f=await fc(this.sessionId,n,u,a,l,t),c={};for(let d=0;d<f.length;d++)c[this.outputNames[a[d]]]=s[d]??dm(f[d]);return Jt(),c}startProfiling(){}endProfiling(){cc(this.sessionId)}}});var hm,Pn,hc=x(()=>{"use strict";$t();Jo();dc();ar();hm=()=>{if((typeof $.wasm.initTimeout!="number"||$.wasm.initTimeout<0)&&($.wasm.initTimeout=0),$.wasm.simd===!1&&console.warn('Deprecated property "env.wasm.simd" is set to false. non-SIMD build is no longer provided, and this setting will be ignored.'),typeof $.wasm.proxy!="boolean"&&($.wasm.proxy=!1),typeof $.wasm.trace!="boolean"&&($.wasm.trace=!1),typeof $.wasm.numThreads!="number"||!Number.isInteger($.wasm.numThreads)||$.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)$.wasm.numThreads=1;else{let i=typeof navigator>"u"?En("node:os").cpus().length:navigator.hardwareConcurrency;$.wasm.numThreads=Math.min(4,Math.ceil((i||1)/2))}$.wasm.wasmPaths===void 0&&Dt&&Dt.indexOf("blob:")!==0&&($.wasm.wasmPaths=Dt.substring(0,Dt.lastIndexOf("/")+1))},Pn=class{async init(e){hm(),await ic(),await ac(e)}async createInferenceSessionHandler(e,o){let t=new An;return await t.loadModel(e,o),Promise.resolve(t)}}});var mc={};ze(mc,{wasmBackend:()=>mm});var mm,bc=x(()=>{"use strict";hc();mm=new Pn});var gm={};ze(gm,{InferenceSession:()=>Si,TRACE:()=>$n,TRACE_FUNC_BEGIN:()=>Kt,TRACE_FUNC_END:()=>Jt,Tensor:()=>rt,TrainingSession:()=>$i,default:()=>bm,env:()=>$,registerBackend:()=>ie});$t();$t();$t();var Bi="1.19.0";var bm=Bn;{let i=(Gf(),hr(Rf)).onnxjsBackend;ie("webgl",i,-10)}{let i=(bc(),hr(mc)).wasmBackend;ie("cpu",i,10),ie("wasm",i,10)}Object.defineProperty($.versions,"web",{value:Bi,enumerable:!0});return hr(gm);})();
+/*! Bundled license information:
+
+long/index.js:
+  (**
+   * @license
+   * Copyright 2009 The Closure Library Authors
+   * Copyright 2020 Daniel Wirtz / The long.js Authors.
+   *
+   * Licensed under the Apache License, Version 2.0 (the "License");
+   * you may not use this file except in compliance with the License.
+   * You may obtain a copy of the License at
+   *
+   *     http://www.apache.org/licenses/LICENSE-2.0
+   *
+   * Unless required by applicable law or agreed to in writing, software
+   * distributed under the License is distributed on an "AS IS" BASIS,
+   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   * See the License for the specific language governing permissions and
+   * limitations under the License.
+   *
+   * SPDX-License-Identifier: Apache-2.0
+   *)
+*/
+typeof exports=="object"&&typeof module=="object"&&(module.exports=ort);
+//# sourceMappingURL=ort.min.js.map