@webex/ladon-ts 5.5.0 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Cisco Ladon-TS
3
3
  * Copyright (c) Cisco Systems, Inc. All rights reserved.
4
- * Build timestamp: April 16, 2025 at 12:19:28 AM UTC
4
+ * Build timestamp: May 19, 2025 at 10:50:08 PM UTC
5
5
  */
6
6
  (function(){"use strict";var _documentCurrentScript=typeof document<"u"?document.currentScript:null;self.document={baseURI:location.origin};const originalConsoleLog=console.log,originalConsoleWarn=console.warn,originalConsoleError=console.error;console.log=(...e)=>{postMessage({type:"log",message:e.join(" "),severity:"log"}),originalConsoleLog(...e)},console.warn=(...e)=>{postMessage({type:"log",message:e.join(" "),severity:"warn"}),originalConsoleWarn(...e)},console.error=(...e)=>{postMessage({type:"log",message:e.join(" "),severity:"error"}),originalConsoleError(...e)};/*!
7
7
  * ONNX Runtime Web v1.20.1
8
8
  * Copyright (c) Microsoft Corporation. All rights reserved.
9
9
  * Licensed under the MIT License.
10
- */var Hd=Object.create,an=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,jd=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty,Co=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,a)=>(typeof require<"u"?require:n)[a]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),O=(e,n)=>()=>(e&&(n=e(e=0)),n),mt=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Or=(e,n)=>{for(var a in n)an(e,a,{get:n[a],enumerable:!0})},Qa=(e,n,a,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of jd(n))!Kd.call(e,p)&&p!==a&&an(e,p,{get:()=>n[p],enumerable:!(i=qd(n,p))||i.enumerable});return e},rr=(e,n,a)=>(a=e!=null?Hd(Xd(e)):{},Qa(!e||!e.__esModule?an(a,"default",{value:e,enumerable:!0}):a,e)),sn=e=>Qa(an({},"__esModule",{value:!0}),e),un,ke,nr,Jd,ln,fn=O(()=>{un=new Map,ke=[],nr=(e,n,a)=>{if(n&&typeof n.init=="function"&&typeof n.createInferenceSessionHandler=="function"){let i=un.get(e);if(i===void 0)un.set(e,{backend:n,priority:a});else{if(i.priority>a)return;if(i.priority===a&&i.backend!==n)throw new Error(`cannot register backend "${e}" using priority ${a}`)}if(a>=0){let p=ke.indexOf(e);p!==-1&&ke.splice(p,1);for(let o=0;o<ke.length;o++)if(un.get(ke[o]).priority<=a){ke.splice(o,0,e);return}ke.push(e)}return}throw new TypeError("not a valid backend")},Jd=async e=>{let n=un.get(e);if(!n)return"backend not found.";if(n.initialized)return n.backend;if(n.aborted)return n.error;{let a=!!n.initPromise;try{return a||(n.initPromise=n.backend.init(e)),await n.initPromise,n.initialized=!0,n.backend}catch(i){return a||(n.error=`${i}`,n.aborted=!0),n.error}finally{delete n.initPromise}}},ln=async e=>{let n=e.executionProviders||[],a=n.map(h=>typeof h=="string"?h:h.name),i=a.length===0?ke:a,p,o=[],s=new Set;for(let h of i){let r=await Jd(h);typeof r=="string"?o.push({name:h,err:r}):(p||(p=r),p===r&&s.add(h))}if(!p)throw new Error(`no available backend found. ERR: ${o.map(h=>`[${h.name}] ${h.err}`).join(", ")}`);for(let{name:h,err:r}of o)a.includes(h)&&console.warn(`removing requested execution provider "${h}" from session options because it is not available: ${r}`);let c=n.filter(h=>s.has(typeof h=="string"?h:h.name));return[p,new Proxy(e,{get:(h,r)=>r==="executionProviders"?c:Reflect.get(h,r)})]}}),ts=O(()=>{fn()}),es,rs=O(()=>{es="1.20.1"}),ns,Gt,No=O(()=>{rs(),ns="warning",Gt={wasm:{},webgl:{},webgpu:{},versions:{common:es},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);ns=e}},get logLevel(){return ns}},Object.defineProperty(Gt,"logLevel",{enumerable:!0})}),z,os=O(()=>{No(),z=Gt}),is,as,ss=O(()=>{is=(e,n)=>{let a=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);a.width=e.dims[3],a.height=e.dims[2];let i=a.getContext("2d");if(i!=null){let p,o;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(p=e.dims[2],o=e.dims[3]):(p=e.dims[3],o=e.dims[2]);let s=(n==null?void 0:n.format)!==void 0?n.format:"RGB",c=n==null?void 0:n.norm,h,r;c===void 0||c.mean===void 0?h=[255,255,255,255]:typeof c.mean=="number"?h=[c.mean,c.mean,c.mean,c.mean]:(h=[c.mean[0],c.mean[1],c.mean[2],0],c.mean[3]!==void 0&&(h[3]=c.mean[3])),c===void 0||c.bias===void 0?r=[0,0,0,0]:typeof c.bias=="number"?r=[c.bias,c.bias,c.bias,c.bias]:(r=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(r[3]=c.bias[3]));let u=o*p,l=0,f=u,g=u*2,b=-1;s==="RGBA"?(l=0,f=u,g=u*2,b=u*3):s==="RGB"?(l=0,f=u,g=u*2):s==="RBG"&&(l=0,g=u,f=u*2);for(let v=0;v<o;v++)for(let S=0;S<p;S++){let P=(e.data[l++]-r[0])*h[0],_=(e.data[f++]-r[1])*h[1],A=(e.data[g++]-r[2])*h[2],L=b===-1?255:(e.data[b++]-r[3])*h[3];i.fillStyle="rgba("+P+","+_+","+A+","+L+")",i.fillRect(S,v,1,1)}if("toDataURL"in a)return a.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},as=(e,n)=>{let a=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),i;if(a!=null){let p,o,s;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(p=e.dims[2],o=e.dims[1],s=e.dims[3]):(p=e.dims[3],o=e.dims[2],s=e.dims[1]);let c=n!==void 0&&n.format!==void 0?n.format:"RGB",h=n==null?void 0:n.norm,r,u;h===void 0||h.mean===void 0?r=[255,255,255,255]:typeof h.mean=="number"?r=[h.mean,h.mean,h.mean,h.mean]:(r=[h.mean[0],h.mean[1],h.mean[2],255],h.mean[3]!==void 0&&(r[3]=h.mean[3])),h===void 0||h.bias===void 0?u=[0,0,0,0]:typeof h.bias=="number"?u=[h.bias,h.bias,h.bias,h.bias]:(u=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(u[3]=h.bias[3]));let l=o*p;if(n!==void 0&&(n.format!==void 0&&s===4&&n.format!=="RGBA"||s===3&&n.format!=="RGB"&&n.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let f=4,g=0,b=1,v=2,S=3,P=0,_=l,A=l*2,L=-1;c==="RGBA"?(P=0,_=l,A=l*2,L=l*3):c==="RGB"?(P=0,_=l,A=l*2):c==="RBG"&&(P=0,A=l,_=l*2),i=a.createImageData(p,o);for(let V=0;V<o*p;g+=f,b+=f,v+=f,S+=f,V++)i.data[g]=(e.data[P++]-u[0])*r[0],i.data[b]=(e.data[_++]-u[1])*r[1],i.data[v]=(e.data[A++]-u[2])*r[2],i.data[S]=L===-1?255:(e.data[L++]-u[3])*r[3]}else throw new Error("Can not access image data");return i}}),Ro,us,ls,fs,cs,ps,ds=O(()=>{cn(),Ro=(e,n)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(n.height===void 0||n.width===void 0)throw new Error("Image height and width must be defined");if(n.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:a,width:i}=n,p=n.norm??{mean:255,bias:0},o,s;typeof p.mean=="number"?o=[p.mean,p.mean,p.mean,p.mean]:o=[p.mean[0],p.mean[1],p.mean[2],p.mean[3]??255],typeof p.bias=="number"?s=[p.bias,p.bias,p.bias,p.bias]:s=[p.bias[0],p.bias[1],p.bias[2],p.bias[3]??0];let c=n.format!==void 0?n.format:"RGBA",h=n.tensorFormat!==void 0&&n.tensorFormat!==void 0?n.tensorFormat:"RGB",r=a*i,u=h==="RGBA"?new Float32Array(r*4):new Float32Array(r*3),l=4,f=0,g=1,b=2,v=3,S=0,P=r,_=r*2,A=-1;c==="RGB"&&(l=3,f=0,g=1,b=2,v=-1),h==="RGBA"?A=r*3:h==="RBG"?(S=0,_=r,P=r*2):h==="BGR"&&(_=0,P=r,S=r*2);for(let L=0;L<r;L++,f+=l,b+=l,g+=l,v+=l)u[S++]=(e[f]+s[0])/o[0],u[P++]=(e[g]+s[1])/o[1],u[_++]=(e[b]+s[2])/o[2],A!==-1&&v!==-1&&(u[A++]=(e[v]+s[3])/o[3]);return h==="RGBA"?new St("float32",u,[1,4,a,i]):new St("float32",u,[1,3,a,i])},us=async(e,n)=>{let a=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,i=typeof ImageData<"u"&&e instanceof ImageData,p=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,o=typeof e=="string",s,c=n??{},h=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},r=u=>typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement||u instanceof OffscreenCanvas?u.getContext("2d"):null;if(a){let u=h();u.width=e.width,u.height=e.height;let l=r(u);if(l!=null){let f=e.height,g=e.width;if(n!==void 0&&n.resizedHeight!==void 0&&n.resizedWidth!==void 0&&(f=n.resizedHeight,g=n.resizedWidth),n!==void 0){if(c=n,n.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");c.tensorFormat="RGBA",c.height=f,c.width=g}else c.tensorFormat="RGBA",c.height=f,c.width=g;l.drawImage(e,0,0),s=l.getImageData(0,0,g,f).data}else throw new Error("Can not access image data")}else if(i){let u,l;if(n!==void 0&&n.resizedWidth!==void 0&&n.resizedHeight!==void 0?(u=n.resizedHeight,l=n.resizedWidth):(u=e.height,l=e.width),n!==void 0&&(c=n),c.format="RGBA",c.height=u,c.width=l,n!==void 0){let f=h();f.width=l,f.height=u;let g=r(f);if(g!=null)g.putImageData(e,0,0),s=g.getImageData(0,0,l,u).data;else throw new Error("Can not access image data")}else s=e.data}else if(p){if(n===void 0)throw new Error("Please provide image config with format for Imagebitmap");let u=h();u.width=e.width,u.height=e.height;let l=r(u);if(l!=null){let f=e.height,g=e.width;return l.drawImage(e,0,0,g,f),s=l.getImageData(0,0,g,f).data,c.height=f,c.width=g,Ro(s,c)}else throw new Error("Can not access image data")}else{if(o)return new Promise((u,l)=>{let f=h(),g=r(f);if(!e||!g)return l();let b=new Image;b.crossOrigin="Anonymous",b.src=e,b.onload=()=>{f.width=b.width,f.height=b.height,g.drawImage(b,0,0,f.width,f.height);let v=g.getImageData(0,0,f.width,f.height);c.height=f.height,c.width=f.width,u(Ro(v.data,c))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Ro(s,c);throw new Error("Input data provided is not supported - aborted tensor creation")},ls=(e,n)=>{let{width:a,height:i,download:p,dispose:o}=n,s=[1,i,a,4];return new St({location:"texture",type:"float32",texture:e,dims:s,download:p,dispose:o})},fs=(e,n)=>{let{dataType:a,dims:i,download:p,dispose:o}=n;return new St({location:"gpu-buffer",type:a??"float32",gpuBuffer:e,dims:i,download:p,dispose:o})},cs=(e,n)=>{let{dataType:a,dims:i,download:p,dispose:o}=n;return new St({location:"ml-tensor",type:a??"float32",mlTensor:e,dims:i,download:p,dispose:o})},ps=(e,n,a)=>new St({location:"cpu-pinned",type:e,data:n,dims:a??[n.length]})}),Be,Sr,hs,ms,bs=O(()=>{Be=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Sr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),hs=!1,ms=()=>{if(!hs){hs=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,n=typeof BigUint64Array<"u"&&BigUint64Array.from,a=typeof Float16Array<"u"&&Float16Array.from;e&&(Be.set("int64",BigInt64Array),Sr.set(BigInt64Array,"int64")),n&&(Be.set("uint64",BigUint64Array),Sr.set(BigUint64Array,"uint64")),a?(Be.set("float16",Float16Array),Sr.set(Float16Array,"float16")):Be.set("float16",Uint16Array)}}}),gs,ys,xs=O(()=>{cn(),gs=e=>{let n=1;for(let a=0;a<e.length;a++){let i=e[a];if(typeof i!="number"||!Number.isSafeInteger(i))throw new TypeError(`dims[${a}] must be an integer, got: ${i}`);if(i<0)throw new RangeError(`dims[${a}] must be a non-negative integer, got: ${i}`);n*=i}return n},ys=(e,n)=>{switch(e.location){case"cpu":return new St(e.type,e.data,n);case"cpu-pinned":return new St({location:"cpu-pinned",data:e.data,type:e.type,dims:n});case"texture":return new St({location:"texture",texture:e.texture,type:e.type,dims:n});case"gpu-buffer":return new St({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:n});case"ml-tensor":return new St({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:n});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),St,cn=O(()=>{ss(),ds(),bs(),xs(),St=class{constructor(e,n,a){ms();let i,p;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,i=e.type,p=e.dims,e.location){case"cpu-pinned":{let s=Be.get(i);if(!s)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(e.data instanceof s))throw new TypeError(`buffer should be of type ${s.name}`);this.cpuData=e.data;break}case"texture":{if(i!=="float32")throw new TypeError(`unsupported type "${i}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break}case"gpu-buffer":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint8"&&i!=="bool"&&i!=="uint4"&&i!=="int4")throw new TypeError(`unsupported type "${i}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}case"ml-tensor":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint64"&&i!=="int8"&&i!=="uint8"&&i!=="bool")throw new TypeError(`unsupported type "${i}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let s,c;if(typeof e=="string")if(i=e,c=a,e==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");s=n}else{let h=Be.get(e);if(h===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(n)){if(e==="float16"&&h===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${h.name} as data.`);e==="uint64"||e==="int64"?s=h.from(n,BigInt):s=h.from(n)}else if(n instanceof h)s=n;else if(n instanceof Uint8ClampedArray)if(e==="uint8")s=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${i} tensor's data must be type of ${h}`)}else if(c=n,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let h=typeof e[0];if(h==="string")i="string",s=e;else if(h==="boolean")i="bool",s=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${h}.`)}else if(e instanceof Uint8ClampedArray)i="uint8",s=Uint8Array.from(e);else{let h=Sr.get(e.constructor);if(h===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);i=h,s=e}if(c===void 0)c=[s.length];else if(!Array.isArray(c))throw new TypeError("A tensor's dims must be a number array");p=c,this.cpuData=s,this.dataLocation="cpu"}let o=gs(p);if(this.cpuData&&o!==this.cpuData.length&&!((i==="uint4"||i==="int4")&&Math.ceil(o/2)===this.cpuData.length))throw new Error(`Tensor's size(${o}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=p,this.size=o}static async fromImage(e,n){return us(e,n)}static fromTexture(e,n){return ls(e,n)}static fromGpuBuffer(e,n){return fs(e,n)}static fromMLTensor(e,n){return cs(e,n)}static fromPinnedBuffer(e,n,a){return ps(e,n,a)}toDataURL(e){return is(this,e)}toImageData(e){return as(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}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{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 n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,e&&this.disposer&&(this.disposer(),this.disposer=void 0),n}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.mlTensorData=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 ys(this,e)}}}),yt,pn=O(()=>{cn(),yt=St}),Ts,ws,Fe,Ce,Go=O(()=>{No(),Ts=(e,n)=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||console.timeStamp(`${e}::ORT::${n}`)},ws=(e,n)=>{var p;let a=((p=new Error().stack)==null?void 0:p.split(/\r\n|\r|\n/g))||[],i=!1;for(let o=0;o<a.length;o++){if(i&&!a[o].includes("TRACE_FUNC")){let s=`FUNC_${e}::${a[o].trim().split(" ")[1]}`;n&&(s+=`::${n}`),Ts("CPU",s);return}a[o].includes("TRACE_FUNC")&&(i=!0)}},Fe=e=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("BEGIN",e)},Ce=e=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("END",e)}}),dn,vs=O(()=>{fn(),pn(),Go(),dn=class Oa{constructor(n){this.handler=n}async run(n,a,i){Fe();let p={},o={};if(typeof n!="object"||n===null||n instanceof yt||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof a=="object"){if(a===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(a instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(a)){if(a.length===0)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let r of a){if(typeof r!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(r)===-1)throw new RangeError(`'fetches' contains invalid output name: ${r}.`);p[r]=null}if(typeof i=="object"&&i!==null)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let r=!1,u=Object.getOwnPropertyNames(a);for(let l of this.outputNames)if(u.indexOf(l)!==-1){let f=a[l];(f===null||f instanceof yt)&&(r=!0,s=!1,p[l]=f)}if(r){if(typeof i=="object"&&i!==null)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else o=a}}else if(typeof a<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let r of this.inputNames)if(typeof n[r]>"u")throw new Error(`input '${r}' is missing in 'feeds'.`);if(s)for(let r of this.outputNames)p[r]=null;let c=await this.handler.run(n,p,o),h={};for(let r in c)if(Object.hasOwnProperty.call(c,r)){let u=c[r];u instanceof yt?h[r]=u:h[r]=new yt(u.type,u.data,u.dims)}return Ce(),h}async release(){return this.handler.dispose()}static async create(n,a,i,p){Fe();let o,s={};if(typeof n=="string"){if(o=n,typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof Uint8Array){if(o=n,typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer){let u=n,l=0,f=n.byteLength;if(typeof a=="object"&&a!==null)s=a;else if(typeof a=="number"){if(l=a,!Number.isSafeInteger(l))throw new RangeError("'byteOffset' must be an integer.");if(l<0||l>=u.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${u.byteLength}).`);if(f=n.byteLength-l,typeof i=="number"){if(f=i,!Number.isSafeInteger(f))throw new RangeError("'byteLength' must be an integer.");if(f<=0||l+f>u.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${u.byteLength-l}].`);if(typeof p=="object"&&p!==null)s=p;else if(typeof p<"u")throw new TypeError("'options' must be an object.")}else if(typeof i<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof a<"u")throw new TypeError("'options' must be an object.");o=new Uint8Array(u,l,f)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[c,h]=await ln(s),r=await c.createInferenceSessionHandler(o,h);return Ce(),new Oa(r)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Yd,Is=O(()=>{vs(),Yd=dn}),_s=O(()=>{}),Os=O(()=>{}),Ss=O(()=>{}),As=O(()=>{}),Zd,hn,Ps=O(()=>{fn(),pn(),Zd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",hn=class Sa{constructor(n,a,i){this.handler=n,this.hasOptimizerModel=a,this.hasEvalModel=i}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(n,a){let i=n.evalModel||"",p=n.optimizerModel||"",o=a||{},[s,c]=await ln(o);if(s.createTrainingSessionHandler){let h=await s.createTrainingSessionHandler(n.checkpointState,n.trainModel,i,p,c);return new Sa(h,!!n.optimizerModel,!!n.evalModel)}else throw new Error(Zd)}typeNarrowingForRunStep(n,a,i,p,o){let s={},c={};if(typeof i!="object"||i===null||i instanceof yt||Array.isArray(i))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let h=!0;if(typeof p=="object"){if(p===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(p instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(p)){if(p.length===0)throw new TypeError("'fetches' cannot be an empty array.");h=!1;for(let r of p){if(typeof r!="string")throw new TypeError("'fetches' must be a string array or an object.");if(a.indexOf(r)===-1)throw new RangeError(`'fetches' contains invalid output name: ${r}.`);s[r]=null}if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else{let r=!1,u=Object.getOwnPropertyNames(p);for(let l of a)if(u.indexOf(l)!==-1){let f=p[l];(f===null||f instanceof yt)&&(r=!0,h=!1,s[l]=f)}if(r){if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else c=p}}else if(typeof p<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let r of n)if(typeof i[r]>"u")throw new Error(`input '${r}' is missing in 'feeds'.`);if(h)for(let r of a)s[r]=null;return[s,c]}convertHandlerReturnTypeToMapOfTensors(n){let a={};for(let i in n)if(Object.hasOwnProperty.call(n,i)){let p=n[i];p instanceof yt?a[i]=p:a[i]=new yt(p.type,p.data,p.dims)}return a}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(n,a,i){let[p,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,n,a,i),s=await this.handler.runTrainStep(n,p,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(n){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(n||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(n,a,i){if(this.hasEvalModel){let[p,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,n,a,i),s=await this.handler.runEvalStep(n,p,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(n=!0){return this.handler.getParametersSize(n)}async loadParametersBuffer(n,a=!0){let i=await this.getParametersSize(a);if(n.length!==4*i)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(n,a)}async getContiguousParameters(n=!0){return this.handler.getContiguousParameters(n)}async release(){return this.handler.dispose()}}}),Qd,Es=O(()=>{Ps(),Qd=hn}),Mo={};Or(Mo,{InferenceSession:()=>Yd,TRACE:()=>Ts,TRACE_FUNC_BEGIN:()=>Fe,TRACE_FUNC_END:()=>Ce,Tensor:()=>yt,TrainingSession:()=>Qd,env:()=>z,registerBackend:()=>nr});var Yt=O(()=>{ts(),os(),Is(),pn(),_s(),Os(),Go(),Ss(),As(),Es()});function _e(e,n,a,i){if(n===void 0)return eh(e);if(a===void 0)mn(e,n);else if(typeof a=="number"&&i===void 0)mn(e,n);else if(typeof a=="string"&&i===void 0)mn(e,a,1,n);else if(typeof a=="string"&&typeof i=="number")mn(e,a,i,n);else throw new TypeError("input is valid")}function eh(e){return{verbose:_e.verbose.bind(null,e),info:_e.info.bind(null,e),warning:_e.warning.bind(null,e),error:_e.error.bind(null,e),fatal:_e.fatal.bind(null,e)}}function mn(e,n,a,i){let p=Ar[i||""]||Ar[""];Ls[e]<Ls[p.minimalSeverity]||(p.logDateTime&&(n=`${new Date().toISOString()}|${n}`),p.logSourceLocation,th[p.provider].log(e,n,i))}var Uo,Vo,Ls,th,$s,Ar,tt,gn,yn,xn,bn,Ut=O(()=>{Uo=class{log(e,n,a){}},Vo=class{log(e,n,a){console.log(`${this.color(e)} ${a?"\x1B[35m"+a+"\x1B[0m ":""}${n}`)}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}`)}}},Ls={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},th={none:new Uo,console:new Vo},$s={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},Ar={"":$s},(e=>{function n(r,u){e("verbose",r,u)}e.verbose=n;function a(r,u){e("info",r,u)}e.info=a;function i(r,u){e("warning",r,u)}e.warning=i;function p(r,u){e("error",r,u)}e.error=p;function o(r,u){e("fatal",r,u)}e.fatal=o;function s(r){Ar={},c("",r||{})}e.reset=s;function c(r,u){if(r==="*")s(u);else{let l=Ar[r]||$s;Ar[r]={provider:u.provider||l.provider,minimalSeverity:u.minimalSeverity||l.minimalSeverity,logDateTime:u.logDateTime===void 0?l.logDateTime:u.logDateTime,logSourceLocation:u.logSourceLocation===void 0?l.logSourceLocation:u.logSourceLocation}}}e.set=c;function h(r){let u={};r.logLevel&&(u.minimalSeverity=r.logLevel),c("",u)}e.setWithEnv=h})(_e||(_e={})),tt=_e,gn=class{constructor(e,n,a,i,p,o){this.category=e,this.name=n,this.startTime=a,this.endCallback=i,this.timer=p,this.ctx=o}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)}},yn=class{constructor(e,n,a,i){this.category=e,this.name=n,this.startTime=a,this.endTime=i}},xn=class{constructor(e,n,a){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=e===void 0?1e4:e,this._flushBatchSize=n===void 0?10:n,this._flushIntervalInMilliseconds=a===void 0?5e3:a}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=bn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,n,a,i){let p=this._started?this.begin(e,n,i):void 0,o=!1,s=a();if(s&&typeof s.then=="function")return o=!0,new Promise((c,h)=>{s.then(async r=>{p&&await p.end(),c(r)},async r=>{p&&await p.end(),h(r)})});if(!o&&p){let c=p.end();if(c&&typeof c.then=="function")return new Promise((h,r)=>{c.then(()=>{h(s)},u=>{r(u)})})}return s}begin(e,n,a){if(!this._started)throw new Error("profiler is not started yet");if(a===void 0){let i=bn();return this.flush(i),new gn(e,n,i,p=>this.endSync(p))}else{let i=a.beginTimer();return new gn(e,n,0,async p=>this.end(p),i,a)}}async end(e){let n=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(e.category,e.name,e.startTime,n)),this.flush(n))}endSync(e){let n=bn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(e.category,e.name,e.startTime,n)),this.flush(n))}logOneEvent(e){tt.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 n=this._flushPointer;this._flushPointer<n+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=bn()}}get started(){return this._started}},bn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function ks(e,n,a){for(let i of a){let p=i[0],o=i[1],s=i[2],c=i[3],h=i[4];if(e.opType===p){for(let r of n)if((r.domain===o||r.domain==="ai.onnx"&&o==="")&&rh(r.version,s))return{opImpl:c,opInit:h}}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${n.map(i=>`${i.domain||"ai.onnx"} v${i.version}`).join(", ")}`)}function rh(e,n){if(n.endsWith("+")){let a=Number.parseInt(n.substring(0,n.length-1),10);return!isNaN(a)&&a<=e}else if(n.split("-").length===2){let a=n.split("-"),i=Number.parseInt(a[0],10),p=Number.parseInt(a[1],10);return!isNaN(i)&&!isNaN(p)&&i<=e&&e<=p}else return Number.parseInt(n,10)===e}var Bs=O(()=>{}),Fs=mt(e=>{e.__esModule=!0;var n=function(){function a(i){if(!i)throw new TypeError("Invalid argument; `value` has no value.");this.value=a.EMPTY,i&&a.isGuid(i)&&(this.value=i)}return a.isGuid=function(i){var p=i.toString();return i&&(i instanceof a||a.validator.test(p))},a.create=function(){return new a([a.gen(2),a.gen(1),a.gen(1),a.gen(1),a.gen(3)].join("-"))},a.createEmpty=function(){return new a("emptyguid")},a.parse=function(i){return new a(i)},a.raw=function(){return[a.gen(2),a.gen(1),a.gen(1),a.gen(1),a.gen(3)].join("-")},a.gen=function(i){for(var p="",o=0;o<i;o++)p+=((1+Math.random())*65536|0).toString(16).substring(1);return p},a.prototype.equals=function(i){return a.isGuid(i)&&this.value===i.toString()},a.prototype.isEmpty=function(){return this.value===a.EMPTY},a.prototype.toString=function(){return this.value},a.prototype.toJSON=function(){return{value:this.value}},a.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),a.EMPTY="00000000-0000-0000-0000-000000000000",a}();e.Guid=n});function rt(e,n,a){this.low=e|0,this.high=n|0,this.unsigned=!!a}function Et(e){return(e&&e.__isLong__)===!0}function Cs(e){var n=Math.clz32(e&-e);return e?31-n:n}function Ne(e,n){var a,i,p;return n?(e>>>=0,(p=0<=e&&e<256)&&(i=Rs[e],i)?i:(a=J(e,0,!0),p&&(Rs[e]=a),a)):(e|=0,(p=-128<=e&&e<128)&&(i=Ns[e],i)?i:(a=J(e,e<0?-1:0,!1),p&&(Ns[e]=a),a))}function zt(e,n){if(isNaN(e))return n?ye:Zt;if(n){if(e<0)return ye;if(e>=Vs)return Hs}else{if(e<=-Ms)return Ct;if(e+1>=Ms)return Ws}return e<0?zt(-e,n).neg():J(e%ir|0,e/ir|0,n)}function J(e,n,a){return new rt(e,n,a)}function Ho(e,n,a){if(e.length===0)throw Error("empty string");if(typeof n=="number"?(a=n,n=!1):n=!!n,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return n?ye:Zt;if(a=a||10,a<2||36<a)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(i===0)return Ho(e.substring(1),n,a).neg();for(var p=zt(Tn(a,8)),o=Zt,s=0;s<e.length;s+=8){var c=Math.min(8,e.length-s),h=parseInt(e.substring(s,s+c),a);if(c<8){var r=zt(Tn(a,c));o=o.mul(r).add(zt(h))}else o=o.mul(p),o=o.add(zt(h))}return o.unsigned=n,o}function Qt(e,n){return typeof e=="number"?zt(e,n):typeof e=="string"?Ho(e,n):J(e.low,e.high,typeof n=="boolean"?n:e.unsigned)}var Vt,Ns,Rs,Tn,Gs,oh,ir,Vs,Ms,Us,Zt,ye,or,zs,Wo,Ws,Hs,Ct,D,xe,qo=O(()=>{Vt=null;try{Vt=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{}rt.prototype.__isLong__,Object.defineProperty(rt.prototype,"__isLong__",{value:!0}),rt.isLong=Et,Ns={},Rs={},rt.fromInt=Ne,rt.fromNumber=zt,rt.fromBits=J,Tn=Math.pow,rt.fromString=Ho,rt.fromValue=Qt,Gs=65536,oh=1<<24,ir=Gs*Gs,Vs=ir*ir,Ms=Vs/2,Us=Ne(oh),Zt=Ne(0),rt.ZERO=Zt,ye=Ne(0,!0),rt.UZERO=ye,or=Ne(1),rt.ONE=or,zs=Ne(1,!0),rt.UONE=zs,Wo=Ne(-1),rt.NEG_ONE=Wo,Ws=J(-1,2147483647,!1),rt.MAX_VALUE=Ws,Hs=J(-1,-1,!0),rt.MAX_UNSIGNED_VALUE=Hs,Ct=J(0,-2147483648,!1),rt.MIN_VALUE=Ct,D=rt.prototype,D.toInt=function(){return this.unsigned?this.low>>>0:this.low},D.toNumber=function(){return this.unsigned?(this.high>>>0)*ir+(this.low>>>0):this.high*ir+(this.low>>>0)},D.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(Ct)){var n=zt(e),a=this.div(n),i=a.mul(n).sub(this);return a.toString(e)+i.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var p=zt(Tn(e,6),this.unsigned),o=this,s="";;){var c=o.div(p),h=o.sub(c.mul(p)).toInt()>>>0,r=h.toString(e);if(o=c,o.isZero())return r+s;for(;r.length<6;)r="0"+r;s=""+r+s}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0},D.getLowBits=function(){return this.low},D.getLowBitsUnsigned=function(){return this.low>>>0},D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ct)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1},D.isZero=function(){return this.high===0&&this.low===0},D.eqz=D.isZero,D.isNegative=function(){return!this.unsigned&&this.high<0},D.isPositive=function(){return this.unsigned||this.high>=0},D.isOdd=function(){return(this.low&1)===1},D.isEven=function(){return(this.low&1)===0},D.equals=function(e){return Et(e)||(e=Qt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},D.eq=D.equals,D.notEquals=function(e){return!this.eq(e)},D.neq=D.notEquals,D.ne=D.notEquals,D.lessThan=function(e){return this.comp(e)<0},D.lt=D.lessThan,D.lessThanOrEqual=function(e){return this.comp(e)<=0},D.lte=D.lessThanOrEqual,D.le=D.lessThanOrEqual,D.greaterThan=function(e){return this.comp(e)>0},D.gt=D.greaterThan,D.greaterThanOrEqual=function(e){return this.comp(e)>=0},D.gte=D.greaterThanOrEqual,D.ge=D.greaterThanOrEqual,D.compare=function(e){if(Et(e)||(e=Qt(e)),this.eq(e))return 0;var n=this.isNegative(),a=e.isNegative();return n&&!a?-1:!n&&a?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},D.comp=D.compare,D.negate=function(){return!this.unsigned&&this.eq(Ct)?Ct:this.not().add(or)},D.neg=D.negate,D.add=function(e){Et(e)||(e=Qt(e));var n=this.high>>>16,a=this.high&65535,i=this.low>>>16,p=this.low&65535,o=e.high>>>16,s=e.high&65535,c=e.low>>>16,h=e.low&65535,r=0,u=0,l=0,f=0;return f+=p+h,l+=f>>>16,f&=65535,l+=i+c,u+=l>>>16,l&=65535,u+=a+s,r+=u>>>16,u&=65535,r+=n+o,r&=65535,J(l<<16|f,r<<16|u,this.unsigned)},D.subtract=function(e){return Et(e)||(e=Qt(e)),this.add(e.neg())},D.sub=D.subtract,D.multiply=function(e){if(this.isZero())return this;if(Et(e)||(e=Qt(e)),Vt){var n=Vt.mul(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?ye:Zt;if(this.eq(Ct))return e.isOdd()?Ct:Zt;if(e.eq(Ct))return this.isOdd()?Ct:Zt;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(Us)&&e.lt(Us))return zt(this.toNumber()*e.toNumber(),this.unsigned);var a=this.high>>>16,i=this.high&65535,p=this.low>>>16,o=this.low&65535,s=e.high>>>16,c=e.high&65535,h=e.low>>>16,r=e.low&65535,u=0,l=0,f=0,g=0;return g+=o*r,f+=g>>>16,g&=65535,f+=p*r,l+=f>>>16,f&=65535,f+=o*h,l+=f>>>16,f&=65535,l+=i*r,u+=l>>>16,l&=65535,l+=p*h,u+=l>>>16,l&=65535,l+=o*c,u+=l>>>16,l&=65535,u+=a*r+i*h+p*c+o*s,u&=65535,J(f<<16|g,u<<16|l,this.unsigned)},D.mul=D.multiply,D.divide=function(e){if(Et(e)||(e=Qt(e)),e.isZero())throw Error("division by zero");if(Vt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?Vt.div_u:Vt.div_s)(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ye:Zt;var a,i,p;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return ye;if(e.gt(this.shru(1)))return zs;p=ye}else{if(this.eq(Ct)){if(e.eq(or)||e.eq(Wo))return Ct;if(e.eq(Ct))return or;var o=this.shr(1);return a=o.div(e).shl(1),a.eq(Zt)?e.isNegative()?or:Wo:(i=this.sub(e.mul(a)),p=a.add(i.div(e)),p)}else if(e.eq(Ct))return this.unsigned?ye:Zt;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();p=Zt}for(i=this;i.gte(e);){a=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(a)/Math.LN2),c=s<=48?1:Tn(2,s-48),h=zt(a),r=h.mul(e);r.isNegative()||r.gt(i);)a-=c,h=zt(a,this.unsigned),r=h.mul(e);h.isZero()&&(h=or),p=p.add(h),i=i.sub(r)}return p},D.div=D.divide,D.modulo=function(e){if(Et(e)||(e=Qt(e)),Vt){var n=(this.unsigned?Vt.rem_u:Vt.rem_s)(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},D.mod=D.modulo,D.rem=D.modulo,D.not=function(){return J(~this.low,~this.high,this.unsigned)},D.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},D.clz=D.countLeadingZeros,D.countTrailingZeros=function(){return this.low?Cs(this.low):Cs(this.high)+32},D.ctz=D.countTrailingZeros,D.and=function(e){return Et(e)||(e=Qt(e)),J(this.low&e.low,this.high&e.high,this.unsigned)},D.or=function(e){return Et(e)||(e=Qt(e)),J(this.low|e.low,this.high|e.high,this.unsigned)},D.xor=function(e){return Et(e)||(e=Qt(e)),J(this.low^e.low,this.high^e.high,this.unsigned)},D.shiftLeft=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):J(0,this.low<<e-32,this.unsigned)},D.shl=D.shiftLeft,D.shiftRight=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):J(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},D.shr=D.shiftRight,D.shiftRightUnsigned=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?J(this.high,0,this.unsigned):J(this.high>>>e-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.rotateLeft=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?J(this.high,this.low,this.unsigned):e<32?(n=32-e,J(this.low<<e|this.high>>>n,this.high<<e|this.low>>>n,this.unsigned)):(e-=32,n=32-e,J(this.high<<e|this.low>>>n,this.low<<e|this.high>>>n,this.unsigned))},D.rotl=D.rotateLeft,D.rotateRight=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?J(this.high,this.low,this.unsigned):e<32?(n=32-e,J(this.high<<n|this.low>>>e,this.low<<n|this.high>>>e,this.unsigned)):(e-=32,n=32-e,J(this.low<<n|this.high>>>e,this.high<<n|this.low>>>e,this.unsigned))},D.rotr=D.rotateRight,D.toSigned=function(){return this.unsigned?J(this.low,this.high,!1):this},D.toUnsigned=function(){return this.unsigned?this:J(this.low,this.high,!0)},D.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},D.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]},D.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]},rt.fromBytes=function(e,n,a){return a?rt.fromBytesLE(e,n):rt.fromBytesBE(e,n)},rt.fromBytesLE=function(e,n){return new rt(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},rt.fromBytesBE=function(e,n){return new rt(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},xe=rt}),w,wn=O(()=>{w={},w.Offset,w.Table,w.SIZEOF_SHORT=2,w.SIZEOF_INT=4,w.FILE_IDENTIFIER_LENGTH=4,w.SIZE_PREFIX_LENGTH=4,w.Encoding={UTF8_BYTES:1,UTF16_STRING:2},w.int32=new Int32Array(2),w.float32=new Float32Array(w.int32.buffer),w.float64=new Float64Array(w.int32.buffer),w.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,w.Long=function(e,n){this.low=e|0,this.high=n|0},w.Long.create=function(e,n){return e==0&&n==0?w.Long.ZERO:new w.Long(e,n)},w.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296},w.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},w.Long.ZERO=new w.Long(0,0),w.Builder=function(e){if(e)var n=e;else var n=1024;this.bb=w.ByteBuffer.allocate(n),this.space=n,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},w.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},w.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},w.Builder.prototype.dataBuffer=function(){return this.bb},w.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},w.Builder.prototype.prep=function(e,n){e>this.minalign&&(this.minalign=e);for(var a=~(this.bb.capacity()-this.space+n)+1&e-1;this.space<a+e+n;){var i=this.bb.capacity();this.bb=w.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(a)},w.Builder.prototype.pad=function(e){for(var n=0;n<e;n++)this.bb.writeInt8(--this.space,0)},w.Builder.prototype.writeInt8=function(e){this.bb.writeInt8(this.space-=1,e)},w.Builder.prototype.writeInt16=function(e){this.bb.writeInt16(this.space-=2,e)},w.Builder.prototype.writeInt32=function(e){this.bb.writeInt32(this.space-=4,e)},w.Builder.prototype.writeInt64=function(e){this.bb.writeInt64(this.space-=8,e)},w.Builder.prototype.writeFloat32=function(e){this.bb.writeFloat32(this.space-=4,e)},w.Builder.prototype.writeFloat64=function(e){this.bb.writeFloat64(this.space-=8,e)},w.Builder.prototype.addInt8=function(e){this.prep(1,0),this.writeInt8(e)},w.Builder.prototype.addInt16=function(e){this.prep(2,0),this.writeInt16(e)},w.Builder.prototype.addInt32=function(e){this.prep(4,0),this.writeInt32(e)},w.Builder.prototype.addInt64=function(e){this.prep(8,0),this.writeInt64(e)},w.Builder.prototype.addFloat32=function(e){this.prep(4,0),this.writeFloat32(e)},w.Builder.prototype.addFloat64=function(e){this.prep(8,0),this.writeFloat64(e)},w.Builder.prototype.addFieldInt8=function(e,n,a){(this.force_defaults||n!=a)&&(this.addInt8(n),this.slot(e))},w.Builder.prototype.addFieldInt16=function(e,n,a){(this.force_defaults||n!=a)&&(this.addInt16(n),this.slot(e))},w.Builder.prototype.addFieldInt32=function(e,n,a){(this.force_defaults||n!=a)&&(this.addInt32(n),this.slot(e))},w.Builder.prototype.addFieldInt64=function(e,n,a){(this.force_defaults||!n.equals(a))&&(this.addInt64(n),this.slot(e))},w.Builder.prototype.addFieldFloat32=function(e,n,a){(this.force_defaults||n!=a)&&(this.addFloat32(n),this.slot(e))},w.Builder.prototype.addFieldFloat64=function(e,n,a){(this.force_defaults||n!=a)&&(this.addFloat64(n),this.slot(e))},w.Builder.prototype.addFieldOffset=function(e,n,a){(this.force_defaults||n!=a)&&(this.addOffset(n),this.slot(e))},w.Builder.prototype.addFieldStruct=function(e,n,a){n!=a&&(this.nested(n),this.slot(e))},w.Builder.prototype.nested=function(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},w.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},w.Builder.prototype.slot=function(e){this.vtable[e]=this.offset()},w.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},w.Builder.growByteBuffer=function(e){var n=e.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var a=n<<1,i=w.ByteBuffer.allocate(a);return i.setPosition(a-n),i.bytes().set(e.bytes(),a-n),i},w.Builder.prototype.addOffset=function(e){this.prep(w.SIZEOF_INT,0),this.writeInt32(this.offset()-e+w.SIZEOF_INT)},w.Builder.prototype.startObject=function(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(var n=0;n<e;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()},w.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var e=this.offset(),n=this.vtable_in_use-1;n>=0&&this.vtable[n]==0;n--);for(var a=n+1;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);var i=2;this.addInt16(e-this.object_start);var p=(a+i)*w.SIZEOF_SHORT;this.addInt16(p);var o=0,s=this.space;t:for(n=0;n<this.vtables.length;n++){var c=this.bb.capacity()-this.vtables[n];if(p==this.bb.readInt16(c)){for(var h=w.SIZEOF_SHORT;h<p;h+=w.SIZEOF_SHORT)if(this.bb.readInt16(s+h)!=this.bb.readInt16(c+h))continue t;o=this.vtables[n];break}}return o?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,o-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e},w.Builder.prototype.finish=function(e,n,a){var i=a?w.SIZE_PREFIX_LENGTH:0;if(n){var p=n;if(this.prep(this.minalign,w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH+i),p.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var o=w.FILE_IDENTIFIER_LENGTH-1;o>=0;o--)this.writeInt8(p.charCodeAt(o))}this.prep(this.minalign,w.SIZEOF_INT+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},w.Builder.prototype.finishSizePrefixed=function(e,n){this.finish(e,n,!0)},w.Builder.prototype.requiredField=function(e,n){var a=this.bb.capacity()-e,i=a-this.bb.readInt32(a),p=this.bb.readInt16(i+n)!=0;if(!p)throw new Error("FlatBuffers: field "+n+" must be set")},w.Builder.prototype.startVector=function(e,n,a){this.notNested(),this.vector_num_elems=n,this.prep(w.SIZEOF_INT,e*n),this.prep(a,e*n)},w.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},w.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var n=e;else for(var n=[],a=0;a<e.length;){var i,p=e.charCodeAt(a++);if(p<55296||p>=56320)i=p;else{var o=e.charCodeAt(a++);i=(p<<10)+o+-56613888}i<128?n.push(i):(i<2048?n.push(i>>6&31|192):(i<65536?n.push(i>>12&15|224):n.push(i>>18&7|240,i>>12&63|128),n.push(i>>6&63|128)),n.push(i&63|128))}this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length);for(var a=0,s=this.space,c=this.bb.bytes();a<n.length;a++)c[s++]=n[a];return this.endVector()},w.Builder.prototype.createLong=function(e,n){return w.Long.create(e,n)},w.ByteBuffer=function(e){this.bytes_=e,this.position_=0},w.ByteBuffer.allocate=function(e){return new w.ByteBuffer(new Uint8Array(e))},w.ByteBuffer.prototype.clear=function(){this.position_=0},w.ByteBuffer.prototype.bytes=function(){return this.bytes_},w.ByteBuffer.prototype.position=function(){return this.position_},w.ByteBuffer.prototype.setPosition=function(e){this.position_=e},w.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},w.ByteBuffer.prototype.readInt8=function(e){return this.readUint8(e)<<24>>24},w.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},w.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},w.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},w.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},w.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},w.ByteBuffer.prototype.readInt64=function(e){return new w.Long(this.readInt32(e),this.readInt32(e+4))},w.ByteBuffer.prototype.readUint64=function(e){return new w.Long(this.readUint32(e),this.readUint32(e+4))},w.ByteBuffer.prototype.readFloat32=function(e){return w.int32[0]=this.readInt32(e),w.float32[0]},w.ByteBuffer.prototype.readFloat64=function(e){return w.int32[w.isLittleEndian?0:1]=this.readInt32(e),w.int32[w.isLittleEndian?1:0]=this.readInt32(e+4),w.float64[0]},w.ByteBuffer.prototype.writeInt8=function(e,n){this.bytes_[e]=n},w.ByteBuffer.prototype.writeUint8=function(e,n){this.bytes_[e]=n},w.ByteBuffer.prototype.writeInt16=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8},w.ByteBuffer.prototype.writeUint16=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8},w.ByteBuffer.prototype.writeInt32=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24},w.ByteBuffer.prototype.writeUint32=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24},w.ByteBuffer.prototype.writeInt64=function(e,n){this.writeInt32(e,n.low),this.writeInt32(e+4,n.high)},w.ByteBuffer.prototype.writeUint64=function(e,n){this.writeUint32(e,n.low),this.writeUint32(e+4,n.high)},w.ByteBuffer.prototype.writeFloat32=function(e,n){w.float32[0]=n,this.writeInt32(e,w.int32[0])},w.ByteBuffer.prototype.writeFloat64=function(e,n){w.float64[0]=n,this.writeInt32(e,w.int32[w.isLittleEndian?0:1]),this.writeInt32(e+4,w.int32[w.isLittleEndian?1:0])},w.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var e="",n=0;n<w.FILE_IDENTIFIER_LENGTH;n++)e+=String.fromCharCode(this.readInt8(this.position_+w.SIZEOF_INT+n));return e},w.ByteBuffer.prototype.__offset=function(e,n){var a=e-this.readInt32(e);return n<this.readInt16(a)?this.readInt16(a+n):0},w.ByteBuffer.prototype.__union=function(e,n){return e.bb_pos=n+this.readInt32(n),e.bb=this,e},w.ByteBuffer.prototype.__string=function(e,n){e+=this.readInt32(e);var a=this.readInt32(e),i="",p=0;if(e+=w.SIZEOF_INT,n===w.Encoding.UTF8_BYTES)return this.bytes_.subarray(e,e+a);for(;p<a;){var o,s=this.readUint8(e+p++);if(s<192)o=s;else{var c=this.readUint8(e+p++);if(s<224)o=(s&31)<<6|c&63;else{var h=this.readUint8(e+p++);if(s<240)o=(s&15)<<12|(c&63)<<6|h&63;else{var r=this.readUint8(e+p++);o=(s&7)<<18|(c&63)<<12|(h&63)<<6|r&63}}}o<65536?i+=String.fromCharCode(o):(o-=65536,i+=String.fromCharCode((o>>10)+55296,(o&1023)+56320))}return i},w.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},w.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+w.SIZEOF_INT},w.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},w.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var n=0;n<w.FILE_IDENTIFIER_LENGTH;n++)if(e.charCodeAt(n)!=this.readInt8(this.position_+w.SIZEOF_INT+n))return!1;return!0},w.ByteBuffer.prototype.createLong=function(e,n){return w.Long.create(e,n)}}),F,Pr=O(()=>{wn(),(e=>{(n=>{(a=>{(i=>(i[i.UNDEFINED=0]="UNDEFINED",i[i.FLOAT=1]="FLOAT",i[i.INT=2]="INT",i[i.STRING=3]="STRING",i[i.TENSOR=4]="TENSOR",i[i.GRAPH=5]="GRAPH",i[i.FLOATS=6]="FLOATS",i[i.INTS=7]="INTS",i[i.STRINGS=8]="STRINGS",i[i.TENSORS=9]="TENSORS",i[i.GRAPHS=10]="GRAPHS",i[i.SPARSE_TENSOR=11]="SPARSE_TENSOR",i[i.SPARSE_TENSORS=12]="SPARSE_TENSORS"))(a.AttributeType||(a.AttributeType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.VALUE=1]="VALUE",i[i.PARAM=2]="PARAM"))(a.DimensionValueType||(a.DimensionValueType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{(i=>(i[i.UNDEFINED=0]="UNDEFINED",i[i.FLOAT=1]="FLOAT",i[i.UINT8=2]="UINT8",i[i.INT8=3]="INT8",i[i.UINT16=4]="UINT16",i[i.INT16=5]="INT16",i[i.INT32=6]="INT32",i[i.INT64=7]="INT64",i[i.STRING=8]="STRING",i[i.BOOL=9]="BOOL",i[i.FLOAT16=10]="FLOAT16",i[i.DOUBLE=11]="DOUBLE",i[i.UINT32=12]="UINT32",i[i.UINT64=13]="UINT64",i[i.COMPLEX64=14]="COMPLEX64",i[i.COMPLEX128=15]="COMPLEX128",i[i.BFLOAT16=16]="BFLOAT16",i[i.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",i[i.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",i[i.FLOAT8E5M2=19]="FLOAT8E5M2",i[i.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"))(a.TensorDataType||(a.TensorDataType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{(i=>(i[i.Primitive=0]="Primitive",i[i.Fused=1]="Fused"))(a.NodeType||(a.NodeType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{(i=>(i[i.NONE=0]="NONE",i[i.tensor_type=1]="tensor_type",i[i.sequence_type=2]="sequence_type",i[i.map_type=3]="map_type"))(a.TypeInfoValue||(a.TypeInfoValue={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsShape(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsShape(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}dim(o,s){let c=this.bb.__offset(this.bb_pos,4);return c?(s||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}dimLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}static startShape(o){o.startObject(1)}static addDim(o,s){o.addFieldOffset(0,s,0)}static createDimVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startDimVector(o,s){o.startVector(4,s,4)}static endShape(o){return o.endObject()}static createShape(o,s){return i.startShape(o),i.addDim(o,s),i.endShape(o)}}a.Shape=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsDimension(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimension(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}value(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}denotation(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}static startDimension(o){o.startObject(2)}static addValue(o,s){o.addFieldOffset(0,s,0)}static addDenotation(o,s){o.addFieldOffset(1,s,0)}static endDimension(o){return o.endObject()}static createDimension(o,s,c){return i.startDimension(o),i.addValue(o,s),i.addDenotation(o,c),i.endDimension(o)}}a.Dimension=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsDimensionValue(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimensionValue(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}dimType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt8(this.bb_pos+o):0}dimValue(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}dimParam(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}static startDimensionValue(o){o.startObject(3)}static addDimType(o,s){o.addFieldInt8(0,s,0)}static addDimValue(o,s){o.addFieldInt64(1,s,o.createLong(0,0))}static addDimParam(o,s){o.addFieldOffset(2,s,0)}static endDimensionValue(o){return o.endObject()}static createDimensionValue(o,s,c,h){return i.startDimensionValue(o),i.addDimType(o,s),i.addDimValue(o,c),i.addDimParam(o,h),i.endDimensionValue(o)}}a.DimensionValue=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTensorTypeAndShape(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensorTypeAndShape(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}elemType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}shape(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startTensorTypeAndShape(o){o.startObject(2)}static addElemType(o,s){o.addFieldInt32(0,s,0)}static addShape(o,s){o.addFieldOffset(1,s,0)}static endTensorTypeAndShape(o){return o.endObject()}static createTensorTypeAndShape(o,s,c){return i.startTensorTypeAndShape(o),i.addElemType(o,s),i.addShape(o,c),i.endTensorTypeAndShape(o)}}a.TensorTypeAndShape=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsMapType(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsMapType(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}keyType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}valueType(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startMapType(o){o.startObject(2)}static addKeyType(o,s){o.addFieldInt32(0,s,0)}static addValueType(o,s){o.addFieldOffset(1,s,0)}static endMapType(o){return o.endObject()}static createMapType(o,s,c){return i.startMapType(o),i.addKeyType(o,s),i.addValueType(o,c),i.endMapType(o)}}a.MapType=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSequenceType(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSequenceType(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}elemType(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSequenceType(o){o.startObject(1)}static addElemType(o,s){o.addFieldOffset(0,s,0)}static endSequenceType(o){return o.endObject()}static createSequenceType(o,s){return i.startSequenceType(o),i.addElemType(o,s),i.endSequenceType(o)}}a.SequenceType=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,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(o,s,c,h){return o.prep(4,12),o.writeInt32(h),o.writeInt32(c),o.writeInt32(s),o.offset()}}a.EdgeEnd=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsNodeEdge(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNodeEdge(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}nodeIndex(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readUint32(this.bb_pos+o):0}inputEdges(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+o*12,this.bb):null}inputEdgesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}outputEdges(o,s){let c=this.bb.__offset(this.bb_pos,8);return c?(s||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+o*12,this.bb):null}outputEdgesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNodeEdge(o){o.startObject(3)}static addNodeIndex(o,s){o.addFieldInt32(0,s,0)}static addInputEdges(o,s){o.addFieldOffset(1,s,0)}static startInputEdgesVector(o,s){o.startVector(12,s,4)}static addOutputEdges(o,s){o.addFieldOffset(2,s,0)}static startOutputEdgesVector(o,s){o.startVector(12,s,4)}static endNodeEdge(o){return o.endObject()}static createNodeEdge(o,s,c,h){return i.startNodeEdge(o),i.addNodeIndex(o,s),i.addInputEdges(o,c),i.addOutputEdges(o,h),i.endNodeEdge(o)}}a.NodeEdge=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsNode(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNode(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}domain(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}sinceVersion(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}index(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readUint32(this.bb_pos+o):0}opType(o){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,o):null}type(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.readInt32(this.bb_pos+o):0}executionProviderType(o){let s=this.bb.__offset(this.bb_pos,18);return s?this.bb.__string(this.bb_pos+s,o):null}inputs(o,s){let c=this.bb.__offset(this.bb_pos,20);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,s){let c=this.bb.__offset(this.bb_pos,22);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}attributes(o,s){let c=this.bb.__offset(this.bb_pos,24);return c?(s||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}attributesLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCounts(o){let s=this.bb.__offset(this.bb_pos,26);return s?this.bb.readInt32(this.bb.__vector(this.bb_pos+s)+o*4):0}inputArgCountsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCountsArray(){let o=this.bb.__offset(this.bb_pos,26);return o?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}implicitInputs(o,s){let c=this.bb.__offset(this.bb_pos,28);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}implicitInputsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNode(o){o.startObject(13)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addDomain(o,s){o.addFieldOffset(2,s,0)}static addSinceVersion(o,s){o.addFieldInt32(3,s,0)}static addIndex(o,s){o.addFieldInt32(4,s,0)}static addOpType(o,s){o.addFieldOffset(5,s,0)}static addType(o,s){o.addFieldInt32(6,s,0)}static addExecutionProviderType(o,s){o.addFieldOffset(7,s,0)}static addInputs(o,s){o.addFieldOffset(8,s,0)}static createInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInputsVector(o,s){o.startVector(4,s,4)}static addOutputs(o,s){o.addFieldOffset(9,s,0)}static createOutputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOutputsVector(o,s){o.startVector(4,s,4)}static addAttributes(o,s){o.addFieldOffset(10,s,0)}static createAttributesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startAttributesVector(o,s){o.startVector(4,s,4)}static addInputArgCounts(o,s){o.addFieldOffset(11,s,0)}static createInputArgCountsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addInt32(s[c]);return o.endVector()}static startInputArgCountsVector(o,s){o.startVector(4,s,4)}static addImplicitInputs(o,s){o.addFieldOffset(12,s,0)}static createImplicitInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startImplicitInputsVector(o,s){o.startVector(4,s,4)}static endNode(o){return o.endObject()}static createNode(o,s,c,h,r,u,l,f,g,b,v,S,P,_){return i.startNode(o),i.addName(o,s),i.addDocString(o,c),i.addDomain(o,h),i.addSinceVersion(o,r),i.addIndex(o,u),i.addOpType(o,l),i.addType(o,f),i.addExecutionProviderType(o,g),i.addInputs(o,b),i.addOutputs(o,v),i.addAttributes(o,S),i.addInputArgCounts(o,P),i.addImplicitInputs(o,_),i.endNode(o)}}a.Node=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsValueInfo(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsValueInfo(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}type(o){let s=this.bb.__offset(this.bb_pos,8);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startValueInfo(o){o.startObject(3)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addType(o,s){o.addFieldOffset(2,s,0)}static endValueInfo(o){return o.endObject()}static createValueInfo(o,s,c,h){return i.startValueInfo(o),i.addName(o,s),i.addDocString(o,c),i.addType(o,h),i.endValueInfo(o)}}a.ValueInfo=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTypeInfo(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTypeInfo(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}denotation(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}valueType(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readUint8(this.bb_pos+o):0}value(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__union(o,this.bb_pos+s):null}static startTypeInfo(o){o.startObject(3)}static addDenotation(o,s){o.addFieldOffset(0,s,0)}static addValueType(o,s){o.addFieldInt8(1,s,0)}static addValue(o,s){o.addFieldOffset(2,s,0)}static endTypeInfo(o){return o.endObject()}static createTypeInfo(o,s,c,h){return i.startTypeInfo(o),i.addDenotation(o,s),i.addValueType(o,c),i.addValue(o,h),i.endTypeInfo(o)}}a.TypeInfo=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsOperatorSetId(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsOperatorSetId(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}domain(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}version(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}static startOperatorSetId(o){o.startObject(2)}static addDomain(o,s){o.addFieldOffset(0,s,0)}static addVersion(o,s){o.addFieldInt64(1,s,o.createLong(0,0))}static endOperatorSetId(o){return o.endObject()}static createOperatorSetId(o,s,c){return i.startOperatorSetId(o),i.addDomain(o,s),i.addVersion(o,c),i.endOperatorSetId(o)}}a.OperatorSetId=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTensor(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensor(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}dims(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}dataType(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}rawData(o){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.readUint8(this.bb.__vector(this.bb_pos+s)+o):0}rawDataLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}rawDataArray(){let o=this.bb.__offset(this.bb_pos,12);return o?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}stringData(o,s){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}stringDataLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}static startTensor(o){o.startObject(6)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addDims(o,s){o.addFieldOffset(2,s,0)}static createDimsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startDimsVector(o,s){o.startVector(8,s,8)}static addDataType(o,s){o.addFieldInt32(3,s,0)}static addRawData(o,s){o.addFieldOffset(4,s,0)}static createRawDataVector(o,s){o.startVector(1,s.length,1);for(let c=s.length-1;c>=0;c--)o.addInt8(s[c]);return o.endVector()}static startRawDataVector(o,s){o.startVector(1,s,1)}static addStringData(o,s){o.addFieldOffset(5,s,0)}static createStringDataVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startStringDataVector(o,s){o.startVector(4,s,4)}static endTensor(o){return o.endObject()}static createTensor(o,s,c,h,r,u,l){return i.startTensor(o),i.addName(o,s),i.addDocString(o,c),i.addDims(o,h),i.addDataType(o,r),i.addRawData(o,u),i.addStringData(o,l),i.endTensor(o)}}a.Tensor=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSparseTensor(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSparseTensor(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}values(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}indices(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}dims(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSparseTensor(o){o.startObject(3)}static addValues(o,s){o.addFieldOffset(0,s,0)}static addIndices(o,s){o.addFieldOffset(1,s,0)}static addDims(o,s){o.addFieldOffset(2,s,0)}static createDimsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startDimsVector(o,s){o.startVector(8,s,8)}static endSparseTensor(o){return o.endObject()}static createSparseTensor(o,s,c,h){return i.startSparseTensor(o),i.addValues(o,s),i.addIndices(o,c),i.addDims(o,h),i.endSparseTensor(o)}}a.SparseTensor=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsAttribute(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsAttribute(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}type(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt32(this.bb_pos+o):0}f(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readFloat32(this.bb_pos+o):0}i(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}s(o){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,o):null}t(o){let s=this.bb.__offset(this.bb_pos,16);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}g(o){let s=this.bb.__offset(this.bb_pos,18);return s?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}floats(o){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.readFloat32(this.bb.__vector(this.bb_pos+s)+o*4):0}floatsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}floatsArray(){let o=this.bb.__offset(this.bb_pos,20);return o?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}ints(o){let s=this.bb.__offset(this.bb_pos,22);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}intsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}strings(o,s){let c=this.bb.__offset(this.bb_pos,24);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}stringsLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}tensors(o,s){let c=this.bb.__offset(this.bb_pos,26);return c?(s||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}tensorsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}graphs(o,s){let c=this.bb.__offset(this.bb_pos,28);return c?(s||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}graphsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startAttribute(o){o.startObject(13)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addType(o,s){o.addFieldInt32(2,s,0)}static addF(o,s){o.addFieldFloat32(3,s,0)}static addI(o,s){o.addFieldInt64(4,s,o.createLong(0,0))}static addS(o,s){o.addFieldOffset(5,s,0)}static addT(o,s){o.addFieldOffset(6,s,0)}static addG(o,s){o.addFieldOffset(7,s,0)}static addFloats(o,s){o.addFieldOffset(8,s,0)}static createFloatsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addFloat32(s[c]);return o.endVector()}static startFloatsVector(o,s){o.startVector(4,s,4)}static addInts(o,s){o.addFieldOffset(9,s,0)}static createIntsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startIntsVector(o,s){o.startVector(8,s,8)}static addStrings(o,s){o.addFieldOffset(10,s,0)}static createStringsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startStringsVector(o,s){o.startVector(4,s,4)}static addTensors(o,s){o.addFieldOffset(11,s,0)}static createTensorsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startTensorsVector(o,s){o.startVector(4,s,4)}static addGraphs(o,s){o.addFieldOffset(12,s,0)}static createGraphsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startGraphsVector(o,s){o.startVector(4,s,4)}static endAttribute(o){return o.endObject()}static createAttribute(o,s,c,h,r,u,l,f,g,b,v,S,P,_){return i.startAttribute(o),i.addName(o,s),i.addDocString(o,c),i.addType(o,h),i.addF(o,r),i.addI(o,u),i.addS(o,l),i.addT(o,f),i.addG(o,g),i.addFloats(o,b),i.addInts(o,v),i.addStrings(o,S),i.addTensors(o,P),i.addGraphs(o,_),i.endAttribute(o)}}a.Attribute=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsGraph(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsGraph(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}initializers(o,s){let c=this.bb.__offset(this.bb_pos,4);return c?(s||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}initializersLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeArgs(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodeArgsLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}nodes(o,s){let c=this.bb.__offset(this.bb_pos,8);return c?(s||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}maxNodeIndex(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readUint32(this.bb_pos+o):0}nodeEdges(o,s){let c=this.bb.__offset(this.bb_pos,12);return c?(s||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodeEdgesLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}inputs(o,s){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,s){let c=this.bb.__offset(this.bb_pos,16);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.__vector_len(this.bb_pos+o):0}sparseInitializers(o,s){let c=this.bb.__offset(this.bb_pos,18);return c?(s||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}sparseInitializersLength(){let o=this.bb.__offset(this.bb_pos,18);return o?this.bb.__vector_len(this.bb_pos+o):0}static startGraph(o){o.startObject(8)}static addInitializers(o,s){o.addFieldOffset(0,s,0)}static createInitializersVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInitializersVector(o,s){o.startVector(4,s,4)}static addNodeArgs(o,s){o.addFieldOffset(1,s,0)}static createNodeArgsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodeArgsVector(o,s){o.startVector(4,s,4)}static addNodes(o,s){o.addFieldOffset(2,s,0)}static createNodesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodesVector(o,s){o.startVector(4,s,4)}static addMaxNodeIndex(o,s){o.addFieldInt32(3,s,0)}static addNodeEdges(o,s){o.addFieldOffset(4,s,0)}static createNodeEdgesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodeEdgesVector(o,s){o.startVector(4,s,4)}static addInputs(o,s){o.addFieldOffset(5,s,0)}static createInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInputsVector(o,s){o.startVector(4,s,4)}static addOutputs(o,s){o.addFieldOffset(6,s,0)}static createOutputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOutputsVector(o,s){o.startVector(4,s,4)}static addSparseInitializers(o,s){o.addFieldOffset(7,s,0)}static createSparseInitializersVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startSparseInitializersVector(o,s){o.startVector(4,s,4)}static endGraph(o){return o.endObject()}static createGraph(o,s,c,h,r,u,l,f,g){return i.startGraph(o),i.addInitializers(o,s),i.addNodeArgs(o,c),i.addNodes(o,h),i.addMaxNodeIndex(o,r),i.addNodeEdges(o,u),i.addInputs(o,l),i.addOutputs(o,f),i.addSparseInitializers(o,g),i.endGraph(o)}}a.Graph=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsModel(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsModel(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}irVersion(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}opsetImport(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}opsetImportLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}producerName(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}producerVersion(o){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.__string(this.bb_pos+s,o):null}domain(o){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.__string(this.bb_pos+s,o):null}modelVersion(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}docString(o){let s=this.bb.__offset(this.bb_pos,16);return s?this.bb.__string(this.bb_pos+s,o):null}graph(o){let s=this.bb.__offset(this.bb_pos,18);return s?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}graphDocString(o){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.__string(this.bb_pos+s,o):null}static startModel(o){o.startObject(9)}static addIrVersion(o,s){o.addFieldInt64(0,s,o.createLong(0,0))}static addOpsetImport(o,s){o.addFieldOffset(1,s,0)}static createOpsetImportVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOpsetImportVector(o,s){o.startVector(4,s,4)}static addProducerName(o,s){o.addFieldOffset(2,s,0)}static addProducerVersion(o,s){o.addFieldOffset(3,s,0)}static addDomain(o,s){o.addFieldOffset(4,s,0)}static addModelVersion(o,s){o.addFieldInt64(5,s,o.createLong(0,0))}static addDocString(o,s){o.addFieldOffset(6,s,0)}static addGraph(o,s){o.addFieldOffset(7,s,0)}static addGraphDocString(o,s){o.addFieldOffset(8,s,0)}static endModel(o){return o.endObject()}static createModel(o,s,c,h,r,u,l,f,g,b){return i.startModel(o),i.addIrVersion(o,s),i.addOpsetImport(o,c),i.addProducerName(o,h),i.addProducerVersion(o,r),i.addDomain(o,u),i.addModelVersion(o,l),i.addDocString(o,f),i.addGraph(o,g),i.addGraphDocString(o,b),i.endModel(o)}}a.Model=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsKernelCreateInfos(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsKernelCreateInfos(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}nodeIndices(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readUint32(this.bb.__vector(this.bb_pos+s)+o*4):0}nodeIndicesLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeIndicesArray(){let o=this.bb.__offset(this.bb_pos,4);return o?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}kernelDefHashes(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readUint64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startKernelCreateInfos(o){o.startObject(2)}static addNodeIndices(o,s){o.addFieldOffset(0,s,0)}static createNodeIndicesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addInt32(s[c]);return o.endVector()}static startNodeIndicesVector(o,s){o.startVector(4,s,4)}static addKernelDefHashes(o,s){o.addFieldOffset(1,s,0)}static createKernelDefHashesVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startKernelDefHashesVector(o,s){o.startVector(8,s,8)}static endKernelCreateInfos(o){return o.endObject()}static createKernelCreateInfos(o,s,c){return i.startKernelCreateInfos(o),i.addNodeIndices(o,s),i.addKernelDefHashes(o,c),i.endKernelCreateInfos(o)}}a.KernelCreateInfos=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSubGraphSessionState(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSubGraphSessionState(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}graphId(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}sessionState(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSubGraphSessionState(o){o.startObject(2)}static addGraphId(o,s){o.addFieldOffset(0,s,0)}static addSessionState(o,s){o.addFieldOffset(1,s,0)}static endSubGraphSessionState(o){let s=o.endObject();return o.requiredField(s,4),s}static createSubGraphSessionState(o,s,c){return i.startSubGraphSessionState(o),i.addGraphId(o,s),i.addSessionState(o,c),i.endSubGraphSessionState(o)}}a.SubGraphSessionState=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSessionState(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSessionState(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}kernels(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}subGraphSessionStates(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}subGraphSessionStatesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSessionState(o){o.startObject(2)}static addKernels(o,s){o.addFieldOffset(0,s,0)}static addSubGraphSessionStates(o,s){o.addFieldOffset(1,s,0)}static createSubGraphSessionStatesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startSubGraphSessionStatesVector(o,s){o.startVector(4,s,4)}static endSessionState(o){return o.endObject()}static createSessionState(o,s,c){return i.startSessionState(o),i.addKernels(o,s),i.addSubGraphSessionStates(o,c),i.endSessionState(o)}}a.SessionState=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(a=>{class i{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsInferenceSession(o,s){return(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsInferenceSession(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new i).__init(o.readInt32(o.position())+o.position(),o)}static bufferHasIdentifier(o){return o.__has_identifier("ORTM")}ortVersion(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}model(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}sessionState(o){let s=this.bb.__offset(this.bb_pos,8);return s?(o||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startInferenceSession(o){o.startObject(3)}static addOrtVersion(o,s){o.addFieldOffset(0,s,0)}static addModel(o,s){o.addFieldOffset(1,s,0)}static addSessionState(o,s){o.addFieldOffset(2,s,0)}static endInferenceSession(o){return o.endObject()}static finishInferenceSessionBuffer(o,s){o.finish(s,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(o,s){o.finish(s,"ORTM",!0)}static createInferenceSession(o,s,c,h){return i.startInferenceSession(o),i.addOrtVersion(o,s),i.addModel(o,c),i.addSessionState(o,h),i.endInferenceSession(o)}}a.InferenceSession=i})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={}))}),js=mt((e,n)=>{n.exports=a;function a(i,p){for(var o=new Array(arguments.length-1),s=0,c=2,h=!0;c<arguments.length;)o[s++]=arguments[c++];return new Promise(function(r,u){o[s]=function(l){if(h)if(h=!1,l)u(l);else{for(var f=new Array(arguments.length-1),g=0;g<f.length;)f[g++]=arguments[g];r.apply(null,f)}};try{i.apply(p||null,o)}catch(l){h&&(h=!1,u(l))}})}}),Ys=mt(e=>{var n=e;n.length=function(s){var c=s.length;if(!c)return 0;for(var h=0;--c%4>1&&s.charAt(c)==="=";)++h;return Math.ceil(s.length*3)/4-h};var a=new Array(64),i=new Array(123);for(p=0;p<64;)i[a[p]=p<26?p+65:p<52?p+71:p<62?p-4:p-59|43]=p++;var p;n.encode=function(s,c,h){for(var r=null,u=[],l=0,f=0,g;c<h;){var b=s[c++];switch(f){case 0:u[l++]=a[b>>2],g=(b&3)<<4,f=1;break;case 1:u[l++]=a[g|b>>4],g=(b&15)<<2,f=2;break;case 2:u[l++]=a[g|b>>6],u[l++]=a[b&63],f=0;break}l>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,u)),l=0)}return f&&(u[l++]=a[g],u[l++]=61,f===1&&(u[l++]=61)),r?(l&&r.push(String.fromCharCode.apply(String,u.slice(0,l))),r.join("")):String.fromCharCode.apply(String,u.slice(0,l))};var o="invalid encoding";n.decode=function(s,c,h){for(var r=h,u=0,l,f=0;f<s.length;){var g=s.charCodeAt(f++);if(g===61&&u>1)break;if((g=i[g])===void 0)throw Error(o);switch(u){case 0:l=g,u=1;break;case 1:c[h++]=l<<2|(g&48)>>4,l=g,u=2;break;case 2:c[h++]=(l&15)<<4|(g&60)>>2,l=g,u=3;break;case 3:c[h++]=(l&3)<<6|g,u=0;break}}if(u===1)throw Error(o);return h-r},n.test=function(s){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)}}),Qs=mt((e,n)=>{n.exports=a;function a(){this._listeners={}}a.prototype.on=function(i,p,o){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:p,ctx:o||this}),this},a.prototype.off=function(i,p){if(i===void 0)this._listeners={};else if(p===void 0)this._listeners[i]=[];else for(var o=this._listeners[i],s=0;s<o.length;)o[s].fn===p?o.splice(s,1):++s;return this},a.prototype.emit=function(i){var p=this._listeners[i];if(p){for(var o=[],s=1;s<arguments.length;)o.push(arguments[s++]);for(s=0;s<p.length;)p[s].fn.apply(p[s++].ctx,o)}return this}}),au=mt((e,n)=>{n.exports=a(a);function a(c){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),r=new Uint8Array(h.buffer),u=r[3]===128;function l(v,S,P){h[0]=v,S[P]=r[0],S[P+1]=r[1],S[P+2]=r[2],S[P+3]=r[3]}function f(v,S,P){h[0]=v,S[P]=r[3],S[P+1]=r[2],S[P+2]=r[1],S[P+3]=r[0]}c.writeFloatLE=u?l:f,c.writeFloatBE=u?f:l;function g(v,S){return r[0]=v[S],r[1]=v[S+1],r[2]=v[S+2],r[3]=v[S+3],h[0]}function b(v,S){return r[3]=v[S],r[2]=v[S+1],r[1]=v[S+2],r[0]=v[S+3],h[0]}c.readFloatLE=u?g:b,c.readFloatBE=u?b:g}():function(){function h(u,l,f,g){var b=l<0?1:0;if(b&&(l=-l),l===0)u(1/l>0?0:2147483648,f,g);else if(isNaN(l))u(2143289344,f,g);else if(l>34028234663852886e22)u((b<<31|2139095040)>>>0,f,g);else if(l<11754943508222875e-54)u((b<<31|Math.round(l/1401298464324817e-60))>>>0,f,g);else{var v=Math.floor(Math.log(l)/Math.LN2),S=Math.round(l*Math.pow(2,-v)*8388608)&8388607;u((b<<31|v+127<<23|S)>>>0,f,g)}}c.writeFloatLE=h.bind(null,i),c.writeFloatBE=h.bind(null,p);function r(u,l,f){var g=u(l,f),b=(g>>31)*2+1,v=g>>>23&255,S=g&8388607;return v===255?S?NaN:b*(1/0):v===0?b*1401298464324817e-60*S:b*Math.pow(2,v-150)*(S+8388608)}c.readFloatLE=r.bind(null,o),c.readFloatBE=r.bind(null,s)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),r=new Uint8Array(h.buffer),u=r[7]===128;function l(v,S,P){h[0]=v,S[P]=r[0],S[P+1]=r[1],S[P+2]=r[2],S[P+3]=r[3],S[P+4]=r[4],S[P+5]=r[5],S[P+6]=r[6],S[P+7]=r[7]}function f(v,S,P){h[0]=v,S[P]=r[7],S[P+1]=r[6],S[P+2]=r[5],S[P+3]=r[4],S[P+4]=r[3],S[P+5]=r[2],S[P+6]=r[1],S[P+7]=r[0]}c.writeDoubleLE=u?l:f,c.writeDoubleBE=u?f:l;function g(v,S){return r[0]=v[S],r[1]=v[S+1],r[2]=v[S+2],r[3]=v[S+3],r[4]=v[S+4],r[5]=v[S+5],r[6]=v[S+6],r[7]=v[S+7],h[0]}function b(v,S){return r[7]=v[S],r[6]=v[S+1],r[5]=v[S+2],r[4]=v[S+3],r[3]=v[S+4],r[2]=v[S+5],r[1]=v[S+6],r[0]=v[S+7],h[0]}c.readDoubleLE=u?g:b,c.readDoubleBE=u?b:g}():function(){function h(u,l,f,g,b,v){var S=g<0?1:0;if(S&&(g=-g),g===0)u(0,b,v+l),u(1/g>0?0:2147483648,b,v+f);else if(isNaN(g))u(0,b,v+l),u(2146959360,b,v+f);else if(g>17976931348623157e292)u(0,b,v+l),u((S<<31|2146435072)>>>0,b,v+f);else{var P;if(g<22250738585072014e-324)P=g/5e-324,u(P>>>0,b,v+l),u((S<<31|P/4294967296)>>>0,b,v+f);else{var _=Math.floor(Math.log(g)/Math.LN2);_===1024&&(_=1023),P=g*Math.pow(2,-_),u(P*4503599627370496>>>0,b,v+l),u((S<<31|_+1023<<20|P*1048576&1048575)>>>0,b,v+f)}}}c.writeDoubleLE=h.bind(null,i,0,4),c.writeDoubleBE=h.bind(null,p,4,0);function r(u,l,f,g,b){var v=u(g,b+l),S=u(g,b+f),P=(S>>31)*2+1,_=S>>>20&2047,A=4294967296*(S&1048575)+v;return _===2047?A?NaN:P*(1/0):_===0?P*5e-324*A:P*Math.pow(2,_-1075)*(A+4503599627370496)}c.readDoubleLE=r.bind(null,o,0,4),c.readDoubleBE=r.bind(null,s,4,0)}(),c}function i(c,h,r){h[r]=c&255,h[r+1]=c>>>8&255,h[r+2]=c>>>16&255,h[r+3]=c>>>24}function p(c,h,r){h[r]=c>>>24,h[r+1]=c>>>16&255,h[r+2]=c>>>8&255,h[r+3]=c&255}function o(c,h){return(c[h]|c[h+1]<<8|c[h+2]<<16|c[h+3]<<24)>>>0}function s(c,h){return(c[h]<<24|c[h+1]<<16|c[h+2]<<8|c[h+3])>>>0}}),su=mt((exports,module)=>{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(e){}return null}}),lu=mt(e=>{var n=e;n.length=function(a){for(var i=0,p=0,o=0;o<a.length;++o)p=a.charCodeAt(o),p<128?i+=1:p<2048?i+=2:(p&64512)===55296&&(a.charCodeAt(o+1)&64512)===56320?(++o,i+=4):i+=3;return i},n.read=function(a,i,p){var o=p-i;if(o<1)return"";for(var s=null,c=[],h=0,r;i<p;)r=a[i++],r<128?c[h++]=r:r>191&&r<224?c[h++]=(r&31)<<6|a[i++]&63:r>239&&r<365?(r=((r&7)<<18|(a[i++]&63)<<12|(a[i++]&63)<<6|a[i++]&63)-65536,c[h++]=55296+(r>>10),c[h++]=56320+(r&1023)):c[h++]=(r&15)<<12|(a[i++]&63)<<6|a[i++]&63,h>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,c)),h=0);return s?(h&&s.push(String.fromCharCode.apply(String,c.slice(0,h))),s.join("")):String.fromCharCode.apply(String,c.slice(0,h))},n.write=function(a,i,p){for(var o=p,s,c,h=0;h<a.length;++h)s=a.charCodeAt(h),s<128?i[p++]=s:s<2048?(i[p++]=s>>6|192,i[p++]=s&63|128):(s&64512)===55296&&((c=a.charCodeAt(h+1))&64512)===56320?(s=65536+((s&1023)<<10)+(c&1023),++h,i[p++]=s>>18|240,i[p++]=s>>12&63|128,i[p++]=s>>6&63|128,i[p++]=s&63|128):(i[p++]=s>>12|224,i[p++]=s>>6&63|128,i[p++]=s&63|128);return p-o}}),cu=mt((e,n)=>{n.exports=a;function a(i,p,o){var s=o||8192,c=s>>>1,h=null,r=s;return function(u){if(u<1||u>c)return i(u);r+u>s&&(h=i(s),r=0);var l=p.call(h,r,r+=u);return r&7&&(r=(r|7)+1),l}}}),du=mt((e,n)=>{n.exports=i;var a=Se();function i(c,h){this.lo=c>>>0,this.hi=h>>>0}var p=i.zero=new i(0,0);p.toNumber=function(){return 0},p.zzEncode=p.zzDecode=function(){return this},p.length=function(){return 1};var o=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(c){if(c===0)return p;var h=c<0;h&&(c=-c);var r=c>>>0,u=(c-r)/4294967296>>>0;return h&&(u=~u>>>0,r=~r>>>0,++r>4294967295&&(r=0,++u>4294967295&&(u=0))),new i(r,u)},i.from=function(c){if(typeof c=="number")return i.fromNumber(c);if(a.isString(c))if(a.Long)c=a.Long.fromString(c);else return i.fromNumber(parseInt(c,10));return c.low||c.high?new i(c.low>>>0,c.high>>>0):p},i.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var h=~this.lo+1>>>0,r=~this.hi>>>0;return h||(r=r+1>>>0),-(h+r*4294967296)}return this.lo+this.hi*4294967296},i.prototype.toLong=function(c){return a.Long?new a.Long(this.lo|0,this.hi|0,!!c):{low:this.lo|0,high:this.hi|0,unsigned:!!c}};var s=String.prototype.charCodeAt;i.fromHash=function(c){return c===o?p:new i((s.call(c,0)|s.call(c,1)<<8|s.call(c,2)<<16|s.call(c,3)<<24)>>>0,(s.call(c,4)|s.call(c,5)<<8|s.call(c,6)<<16|s.call(c,7)<<24)>>>0)},i.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)},i.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},i.prototype.zzDecode=function(){var c=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},i.prototype.length=function(){var c=this.lo,h=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?h===0?c<16384?c<128?1:2:c<2097152?3:4:h<16384?h<128?5:6:h<2097152?7:8:r<128?9:10}}),Se=mt(e=>{var n=e;n.asPromise=js(),n.base64=Ys(),n.EventEmitter=Qs(),n.float=au(),n.inquire=su(),n.utf8=lu(),n.pool=cu(),n.LongBits=du(),n.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),n.global=n.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||e,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(p){return typeof p=="number"&&isFinite(p)&&Math.floor(p)===p},n.isString=function(p){return typeof p=="string"||p instanceof String},n.isObject=function(p){return p&&typeof p=="object"},n.isset=n.isSet=function(p,o){var s=p[o];return s!=null&&p.hasOwnProperty(o)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},n.Buffer=function(){try{var p=n.inquire("buffer").Buffer;return p.prototype.utf8Write?p:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(p){return typeof p=="number"?n.Buffer?n._Buffer_allocUnsafe(p):new n.Array(p):n.Buffer?n._Buffer_from(p):typeof Uint8Array>"u"?p:new Uint8Array(p)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(p){return p?n.LongBits.from(p).toHash():n.LongBits.zeroHash},n.longFromHash=function(p,o){var s=n.LongBits.fromHash(p);return n.Long?n.Long.fromBits(s.lo,s.hi,o):s.toNumber(!!o)};function a(p,o,s){for(var c=Object.keys(o),h=0;h<c.length;++h)(p[c[h]]===void 0||!s)&&(p[c[h]]=o[c[h]]);return p}n.merge=a,n.lcFirst=function(p){return p.charAt(0).toLowerCase()+p.substring(1)};function i(p){function o(s,c){if(!(this instanceof o))return new o(s,c);Object.defineProperty(this,"message",{get:function(){return s}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),c&&a(this,c)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return p},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}n.newError=i,n.ProtocolError=i("ProtocolError"),n.oneOfGetter=function(p){for(var o={},s=0;s<p.length;++s)o[p[s]]=1;return function(){for(var c=Object.keys(this),h=c.length-1;h>-1;--h)if(o[c[h]]===1&&this[c[h]]!==void 0&&this[c[h]]!==null)return c[h]}},n.oneOfSetter=function(p){return function(o){for(var s=0;s<p.length;++s)p[s]!==o&&delete this[p[s]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var p=n.Buffer;if(!p){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=p.from!==Uint8Array.from&&p.from||function(o,s){return new p(o,s)},n._Buffer_allocUnsafe=p.allocUnsafe||function(o){return new p(o)}}}),ei=mt((e,n)=>{n.exports=u;var a=Se(),i,p=a.LongBits,o=a.base64,s=a.utf8;function c(_,A,L){this.fn=_,this.len=A,this.next=void 0,this.val=L}function h(){}function r(_){this.head=_.head,this.tail=_.tail,this.len=_.len,this.next=_.states}function u(){this.len=0,this.head=new c(h,0,0),this.tail=this.head,this.states=null}var l=function(){return a.Buffer?function(){return(u.create=function(){return new i})()}:function(){return new u}};u.create=l(),u.alloc=function(_){return new a.Array(_)},a.Array!==Array&&(u.alloc=a.pool(u.alloc,a.Array.prototype.subarray)),u.prototype._push=function(_,A,L){return this.tail=this.tail.next=new c(_,A,L),this.len+=A,this};function f(_,A,L){A[L]=_&255}function g(_,A,L){for(;_>127;)A[L++]=_&127|128,_>>>=7;A[L]=_}function b(_,A){this.len=_,this.next=void 0,this.val=A}b.prototype=Object.create(c.prototype),b.prototype.fn=g,u.prototype.uint32=function(_){return this.len+=(this.tail=this.tail.next=new b((_=_>>>0)<128?1:_<16384?2:_<2097152?3:_<268435456?4:5,_)).len,this},u.prototype.int32=function(_){return _<0?this._push(v,10,p.fromNumber(_)):this.uint32(_)},u.prototype.sint32=function(_){return this.uint32((_<<1^_>>31)>>>0)};function v(_,A,L){for(;_.hi;)A[L++]=_.lo&127|128,_.lo=(_.lo>>>7|_.hi<<25)>>>0,_.hi>>>=7;for(;_.lo>127;)A[L++]=_.lo&127|128,_.lo=_.lo>>>7;A[L++]=_.lo}u.prototype.uint64=function(_){var A=p.from(_);return this._push(v,A.length(),A)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(_){var A=p.from(_).zzEncode();return this._push(v,A.length(),A)},u.prototype.bool=function(_){return this._push(f,1,_?1:0)};function S(_,A,L){A[L]=_&255,A[L+1]=_>>>8&255,A[L+2]=_>>>16&255,A[L+3]=_>>>24}u.prototype.fixed32=function(_){return this._push(S,4,_>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(_){var A=p.from(_);return this._push(S,4,A.lo)._push(S,4,A.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(_){return this._push(a.float.writeFloatLE,4,_)},u.prototype.double=function(_){return this._push(a.float.writeDoubleLE,8,_)};var P=a.Array.prototype.set?function(_,A,L){A.set(_,L)}:function(_,A,L){for(var V=0;V<_.length;++V)A[L+V]=_[V]};u.prototype.bytes=function(_){var A=_.length>>>0;if(!A)return this._push(f,1,0);if(a.isString(_)){var L=u.alloc(A=o.length(_));o.decode(_,L,0),_=L}return this.uint32(A)._push(P,A,_)},u.prototype.string=function(_){var A=s.length(_);return A?this.uint32(A)._push(s.write,A,_):this._push(f,1,0)},u.prototype.fork=function(){return this.states=new r(this),this.head=this.tail=new c(h,0,0),this.len=0,this},u.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 c(h,0,0),this.len=0),this},u.prototype.ldelim=function(){var _=this.head,A=this.tail,L=this.len;return this.reset().uint32(L),L&&(this.tail.next=_.next,this.tail=A,this.len+=L),this},u.prototype.finish=function(){for(var _=this.head.next,A=this.constructor.alloc(this.len),L=0;_;)_.fn(_.val,A,L),L+=_.len,_=_.next;return A},u._configure=function(_){i=_,u.create=l(),i._configure()}}),vu=mt((e,n)=>{n.exports=p;var a=ei();(p.prototype=Object.create(a.prototype)).constructor=p;var i=Se();function p(){a.call(this)}p._configure=function(){p.alloc=i._Buffer_allocUnsafe,p.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&i.Buffer.prototype.set.name==="set"?function(s,c,h){c.set(s,h)}:function(s,c,h){if(s.copy)s.copy(c,h,0,s.length);else for(var r=0;r<s.length;)c[h++]=s[r++]}},p.prototype.bytes=function(s){i.isString(s)&&(s=i._Buffer_from(s,"base64"));var c=s.length>>>0;return this.uint32(c),c&&this._push(p.writeBytesBuffer,c,s),this};function o(s,c,h){s.length<40?i.utf8.write(s,c,h):c.utf8Write?c.utf8Write(s,h):c.write(s,h)}p.prototype.string=function(s){var c=i.Buffer.byteLength(s);return this.uint32(c),c&&this._push(o,c,s),this},p._configure()}),oi=mt((e,n)=>{n.exports=c;var a=Se(),i,p=a.LongBits,o=a.utf8;function s(g,b){return RangeError("index out of range: "+g.pos+" + "+(b||1)+" > "+g.len)}function c(g){this.buf=g,this.pos=0,this.len=g.length}var h=typeof Uint8Array<"u"?function(g){if(g instanceof Uint8Array||Array.isArray(g))return new c(g);throw Error("illegal buffer")}:function(g){if(Array.isArray(g))return new c(g);throw Error("illegal buffer")},r=function(){return a.Buffer?function(g){return(c.create=function(b){return a.Buffer.isBuffer(b)?new i(b):h(b)})(g)}:h};c.create=r(),c.prototype._slice=a.Array.prototype.subarray||a.Array.prototype.slice,c.prototype.uint32=function(){var g=4294967295;return function(){if(g=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(g=(g|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return g;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return g}}(),c.prototype.int32=function(){return this.uint32()|0},c.prototype.sint32=function(){var g=this.uint32();return g>>>1^-(g&1)|0};function u(){var g=new p(0,0),b=0;if(this.len-this.pos>4){for(;b<4;++b)if(g.lo=(g.lo|(this.buf[this.pos]&127)<<b*7)>>>0,this.buf[this.pos++]<128)return g;if(g.lo=(g.lo|(this.buf[this.pos]&127)<<28)>>>0,g.hi=(g.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return g;b=0}else{for(;b<3;++b){if(this.pos>=this.len)throw s(this);if(g.lo=(g.lo|(this.buf[this.pos]&127)<<b*7)>>>0,this.buf[this.pos++]<128)return g}return g.lo=(g.lo|(this.buf[this.pos++]&127)<<b*7)>>>0,g}if(this.len-this.pos>4){for(;b<5;++b)if(g.hi=(g.hi|(this.buf[this.pos]&127)<<b*7+3)>>>0,this.buf[this.pos++]<128)return g}else for(;b<5;++b){if(this.pos>=this.len)throw s(this);if(g.hi=(g.hi|(this.buf[this.pos]&127)<<b*7+3)>>>0,this.buf[this.pos++]<128)return g}throw Error("invalid varint encoding")}c.prototype.bool=function(){return this.uint32()!==0};function l(g,b){return(g[b-4]|g[b-3]<<8|g[b-2]<<16|g[b-1]<<24)>>>0}c.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)|0};function f(){if(this.pos+8>this.len)throw s(this,8);return new p(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}c.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var g=a.float.readFloatLE(this.buf,this.pos);return this.pos+=4,g},c.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var g=a.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,g},c.prototype.bytes=function(){var g=this.uint32(),b=this.pos,v=this.pos+g;if(v>this.len)throw s(this,g);if(this.pos+=g,Array.isArray(this.buf))return this.buf.slice(b,v);if(b===v){var S=a.Buffer;return S?S.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,b,v)},c.prototype.string=function(){var g=this.bytes();return o.read(g,0,g.length)},c.prototype.skip=function(g){if(typeof g=="number"){if(this.pos+g>this.len)throw s(this,g);this.pos+=g}else do if(this.pos>=this.len)throw s(this);while(this.buf[this.pos++]&128);return this},c.prototype.skipType=function(g){switch(g){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(g=this.uint32()&7)!==4;)this.skipType(g);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+g+" at offset "+this.pos)}return this},c._configure=function(g){i=g,c.create=r(),i._configure();var b=a.Long?"toLong":"toNumber";a.merge(c.prototype,{int64:function(){return u.call(this)[b](!1)},uint64:function(){return u.call(this)[b](!0)},sint64:function(){return u.call(this).zzDecode()[b](!1)},fixed64:function(){return f.call(this)[b](!0)},sfixed64:function(){return f.call(this)[b](!1)}})}}),Lu=mt((e,n)=>{n.exports=p;var a=oi();(p.prototype=Object.create(a.prototype)).constructor=p;var i=Se();function p(o){a.call(this,o)}p._configure=function(){i.Buffer&&(p.prototype._slice=i.Buffer.prototype.slice)},p.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},p._configure()}),ku=mt((e,n)=>{n.exports=i;var a=Se();(i.prototype=Object.create(a.EventEmitter.prototype)).constructor=i;function i(p,o,s){if(typeof p!="function")throw TypeError("rpcImpl must be a function");a.EventEmitter.call(this),this.rpcImpl=p,this.requestDelimited=!!o,this.responseDelimited=!!s}i.prototype.rpcCall=function p(o,s,c,h,r){if(!h)throw TypeError("request must be specified");var u=this;if(!r)return a.asPromise(p,u,o,s,c,h);if(!u.rpcImpl){setTimeout(function(){r(Error("already ended"))},0);return}try{return u.rpcImpl(o,s[u.requestDelimited?"encodeDelimited":"encode"](h).finish(),function(l,f){if(l)return u.emit("error",l,o),r(l);if(f===null){u.end(!0);return}if(!(f instanceof c))try{f=c[u.responseDelimited?"decodeDelimited":"decode"](f)}catch(g){return u.emit("error",g,o),r(g)}return u.emit("data",f,o),r(null,f)})}catch(l){u.emit("error",l,o),setTimeout(function(){r(l)},0);return}},i.prototype.end=function(p){return this.rpcImpl&&(p||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),Fu=mt(e=>{var n=e;n.Service=ku()}),Nu=mt((e,n)=>{n.exports={}}),Mu=mt(e=>{var n=e;n.build="minimal",n.Writer=ei(),n.BufferWriter=vu(),n.Reader=oi(),n.BufferReader=Lu(),n.util=Se(),n.rpc=Fu(),n.roots=Nu(),n.configure=a;function a(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}a()}),Vu=mt((e,n)=>{n.exports=Mu()}),sr=mt((e,n)=>{var a=Vu(),i=a.Reader,p=a.Writer,o=a.util,s=a.roots.default||(a.roots.default={});s.onnx=function(){var c={};return c.Version=function(){var h={},r=Object.create(h);return r[h[0]="_START_VERSION"]=0,r[h[1]="IR_VERSION_2017_10_10"]=1,r[h[2]="IR_VERSION_2017_10_30"]=2,r[h[3]="IR_VERSION_2017_11_3"]=3,r[h[4]="IR_VERSION_2019_1_22"]=4,r[h[5]="IR_VERSION_2019_3_18"]=5,r[h[6]="IR_VERSION_2019_9_19"]=6,r[h[7]="IR_VERSION_2020_5_8"]=7,r[h[8]="IR_VERSION_2021_7_30"]=8,r[h[9]="IR_VERSION"]=9,r}(),c.AttributeProto=function(){function h(r){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.refAttrName="",h.prototype.docString="",h.prototype.type=0,h.prototype.f=0,h.prototype.i=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.s=o.newBuffer([]),h.prototype.t=null,h.prototype.g=null,h.prototype.sparseTensor=null,h.prototype.tp=null,h.prototype.floats=o.emptyArray,h.prototype.ints=o.emptyArray,h.prototype.strings=o.emptyArray,h.prototype.tensors=o.emptyArray,h.prototype.graphs=o.emptyArray,h.prototype.sparseTensors=o.emptyArray,h.prototype.typeProtos=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.f!=null&&Object.hasOwnProperty.call(r,"f")&&u.uint32(21).float(r.f),r.i!=null&&Object.hasOwnProperty.call(r,"i")&&u.uint32(24).int64(r.i),r.s!=null&&Object.hasOwnProperty.call(r,"s")&&u.uint32(34).bytes(r.s),r.t!=null&&Object.hasOwnProperty.call(r,"t")&&s.onnx.TensorProto.encode(r.t,u.uint32(42).fork()).ldelim(),r.g!=null&&Object.hasOwnProperty.call(r,"g")&&s.onnx.GraphProto.encode(r.g,u.uint32(50).fork()).ldelim(),r.floats!=null&&r.floats.length){u.uint32(58).fork();for(var l=0;l<r.floats.length;++l)u.float(r.floats[l]);u.ldelim()}if(r.ints!=null&&r.ints.length){u.uint32(66).fork();for(var l=0;l<r.ints.length;++l)u.int64(r.ints[l]);u.ldelim()}if(r.strings!=null&&r.strings.length)for(var l=0;l<r.strings.length;++l)u.uint32(74).bytes(r.strings[l]);if(r.tensors!=null&&r.tensors.length)for(var l=0;l<r.tensors.length;++l)s.onnx.TensorProto.encode(r.tensors[l],u.uint32(82).fork()).ldelim();if(r.graphs!=null&&r.graphs.length)for(var l=0;l<r.graphs.length;++l)s.onnx.GraphProto.encode(r.graphs[l],u.uint32(90).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(106).string(r.docString),r.tp!=null&&Object.hasOwnProperty.call(r,"tp")&&s.onnx.TypeProto.encode(r.tp,u.uint32(114).fork()).ldelim(),r.typeProtos!=null&&r.typeProtos.length)for(var l=0;l<r.typeProtos.length;++l)s.onnx.TypeProto.encode(r.typeProtos[l],u.uint32(122).fork()).ldelim();if(r.type!=null&&Object.hasOwnProperty.call(r,"type")&&u.uint32(160).int32(r.type),r.refAttrName!=null&&Object.hasOwnProperty.call(r,"refAttrName")&&u.uint32(170).string(r.refAttrName),r.sparseTensor!=null&&Object.hasOwnProperty.call(r,"sparseTensor")&&s.onnx.SparseTensorProto.encode(r.sparseTensor,u.uint32(178).fork()).ldelim(),r.sparseTensors!=null&&r.sparseTensors.length)for(var l=0;l<r.sparseTensors.length;++l)s.onnx.SparseTensorProto.encode(r.sparseTensors[l],u.uint32(186).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.AttributeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 21:{f.refAttrName=r.string();break}case 13:{f.docString=r.string();break}case 20:{f.type=r.int32();break}case 2:{f.f=r.float();break}case 3:{f.i=r.int64();break}case 4:{f.s=r.bytes();break}case 5:{f.t=s.onnx.TensorProto.decode(r,r.uint32());break}case 6:{f.g=s.onnx.GraphProto.decode(r,r.uint32());break}case 22:{f.sparseTensor=s.onnx.SparseTensorProto.decode(r,r.uint32());break}case 14:{f.tp=s.onnx.TypeProto.decode(r,r.uint32());break}case 7:{if(f.floats&&f.floats.length||(f.floats=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.floats.push(r.float());else f.floats.push(r.float());break}case 8:{if(f.ints&&f.ints.length||(f.ints=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.ints.push(r.int64());else f.ints.push(r.int64());break}case 9:{f.strings&&f.strings.length||(f.strings=[]),f.strings.push(r.bytes());break}case 10:{f.tensors&&f.tensors.length||(f.tensors=[]),f.tensors.push(s.onnx.TensorProto.decode(r,r.uint32()));break}case 11:{f.graphs&&f.graphs.length||(f.graphs=[]),f.graphs.push(s.onnx.GraphProto.decode(r,r.uint32()));break}case 23:{f.sparseTensors&&f.sparseTensors.length||(f.sparseTensors=[]),f.sparseTensors.push(s.onnx.SparseTensorProto.decode(r,r.uint32()));break}case 15:{f.typeProtos&&f.typeProtos.length||(f.typeProtos=[]),f.typeProtos.push(s.onnx.TypeProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.refAttrName!=null&&r.hasOwnProperty("refAttrName")&&!o.isString(r.refAttrName))return"refAttrName: string expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.type!=null&&r.hasOwnProperty("type"))switch(r.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(r.f!=null&&r.hasOwnProperty("f")&&typeof r.f!="number")return"f: number expected";if(r.i!=null&&r.hasOwnProperty("i")&&!o.isInteger(r.i)&&!(r.i&&o.isInteger(r.i.low)&&o.isInteger(r.i.high)))return"i: integer|Long expected";if(r.s!=null&&r.hasOwnProperty("s")&&!(r.s&&typeof r.s.length=="number"||o.isString(r.s)))return"s: buffer expected";if(r.t!=null&&r.hasOwnProperty("t")){var u=s.onnx.TensorProto.verify(r.t);if(u)return"t."+u}if(r.g!=null&&r.hasOwnProperty("g")){var u=s.onnx.GraphProto.verify(r.g);if(u)return"g."+u}if(r.sparseTensor!=null&&r.hasOwnProperty("sparseTensor")){var u=s.onnx.SparseTensorProto.verify(r.sparseTensor);if(u)return"sparseTensor."+u}if(r.tp!=null&&r.hasOwnProperty("tp")){var u=s.onnx.TypeProto.verify(r.tp);if(u)return"tp."+u}if(r.floats!=null&&r.hasOwnProperty("floats")){if(!Array.isArray(r.floats))return"floats: array expected";for(var l=0;l<r.floats.length;++l)if(typeof r.floats[l]!="number")return"floats: number[] expected"}if(r.ints!=null&&r.hasOwnProperty("ints")){if(!Array.isArray(r.ints))return"ints: array expected";for(var l=0;l<r.ints.length;++l)if(!o.isInteger(r.ints[l])&&!(r.ints[l]&&o.isInteger(r.ints[l].low)&&o.isInteger(r.ints[l].high)))return"ints: integer|Long[] expected"}if(r.strings!=null&&r.hasOwnProperty("strings")){if(!Array.isArray(r.strings))return"strings: array expected";for(var l=0;l<r.strings.length;++l)if(!(r.strings[l]&&typeof r.strings[l].length=="number"||o.isString(r.strings[l])))return"strings: buffer[] expected"}if(r.tensors!=null&&r.hasOwnProperty("tensors")){if(!Array.isArray(r.tensors))return"tensors: array expected";for(var l=0;l<r.tensors.length;++l){var u=s.onnx.TensorProto.verify(r.tensors[l]);if(u)return"tensors."+u}}if(r.graphs!=null&&r.hasOwnProperty("graphs")){if(!Array.isArray(r.graphs))return"graphs: array expected";for(var l=0;l<r.graphs.length;++l){var u=s.onnx.GraphProto.verify(r.graphs[l]);if(u)return"graphs."+u}}if(r.sparseTensors!=null&&r.hasOwnProperty("sparseTensors")){if(!Array.isArray(r.sparseTensors))return"sparseTensors: array expected";for(var l=0;l<r.sparseTensors.length;++l){var u=s.onnx.SparseTensorProto.verify(r.sparseTensors[l]);if(u)return"sparseTensors."+u}}if(r.typeProtos!=null&&r.hasOwnProperty("typeProtos")){if(!Array.isArray(r.typeProtos))return"typeProtos: array expected";for(var l=0;l<r.typeProtos.length;++l){var u=s.onnx.TypeProto.verify(r.typeProtos[l]);if(u)return"typeProtos."+u}}return null},h.fromObject=function(r){if(r instanceof s.onnx.AttributeProto)return r;var u=new s.onnx.AttributeProto;switch(r.name!=null&&(u.name=String(r.name)),r.refAttrName!=null&&(u.refAttrName=String(r.refAttrName)),r.docString!=null&&(u.docString=String(r.docString)),r.type){default:if(typeof r.type=="number"){u.type=r.type;break}break;case"UNDEFINED":case 0:u.type=0;break;case"FLOAT":case 1:u.type=1;break;case"INT":case 2:u.type=2;break;case"STRING":case 3:u.type=3;break;case"TENSOR":case 4:u.type=4;break;case"GRAPH":case 5:u.type=5;break;case"SPARSE_TENSOR":case 11:u.type=11;break;case"TYPE_PROTO":case 13:u.type=13;break;case"FLOATS":case 6:u.type=6;break;case"INTS":case 7:u.type=7;break;case"STRINGS":case 8:u.type=8;break;case"TENSORS":case 9:u.type=9;break;case"GRAPHS":case 10:u.type=10;break;case"SPARSE_TENSORS":case 12:u.type=12;break;case"TYPE_PROTOS":case 14:u.type=14;break}if(r.f!=null&&(u.f=Number(r.f)),r.i!=null&&(o.Long?(u.i=o.Long.fromValue(r.i)).unsigned=!1:typeof r.i=="string"?u.i=parseInt(r.i,10):typeof r.i=="number"?u.i=r.i:typeof r.i=="object"&&(u.i=new o.LongBits(r.i.low>>>0,r.i.high>>>0).toNumber())),r.s!=null&&(typeof r.s=="string"?o.base64.decode(r.s,u.s=o.newBuffer(o.base64.length(r.s)),0):r.s.length>=0&&(u.s=r.s)),r.t!=null){if(typeof r.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");u.t=s.onnx.TensorProto.fromObject(r.t)}if(r.g!=null){if(typeof r.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");u.g=s.onnx.GraphProto.fromObject(r.g)}if(r.sparseTensor!=null){if(typeof r.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");u.sparseTensor=s.onnx.SparseTensorProto.fromObject(r.sparseTensor)}if(r.tp!=null){if(typeof r.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");u.tp=s.onnx.TypeProto.fromObject(r.tp)}if(r.floats){if(!Array.isArray(r.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");u.floats=[];for(var l=0;l<r.floats.length;++l)u.floats[l]=Number(r.floats[l])}if(r.ints){if(!Array.isArray(r.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");u.ints=[];for(var l=0;l<r.ints.length;++l)o.Long?(u.ints[l]=o.Long.fromValue(r.ints[l])).unsigned=!1:typeof r.ints[l]=="string"?u.ints[l]=parseInt(r.ints[l],10):typeof r.ints[l]=="number"?u.ints[l]=r.ints[l]:typeof r.ints[l]=="object"&&(u.ints[l]=new o.LongBits(r.ints[l].low>>>0,r.ints[l].high>>>0).toNumber())}if(r.strings){if(!Array.isArray(r.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");u.strings=[];for(var l=0;l<r.strings.length;++l)typeof r.strings[l]=="string"?o.base64.decode(r.strings[l],u.strings[l]=o.newBuffer(o.base64.length(r.strings[l])),0):r.strings[l].length>=0&&(u.strings[l]=r.strings[l])}if(r.tensors){if(!Array.isArray(r.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");u.tensors=[];for(var l=0;l<r.tensors.length;++l){if(typeof r.tensors[l]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");u.tensors[l]=s.onnx.TensorProto.fromObject(r.tensors[l])}}if(r.graphs){if(!Array.isArray(r.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");u.graphs=[];for(var l=0;l<r.graphs.length;++l){if(typeof r.graphs[l]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");u.graphs[l]=s.onnx.GraphProto.fromObject(r.graphs[l])}}if(r.sparseTensors){if(!Array.isArray(r.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");u.sparseTensors=[];for(var l=0;l<r.sparseTensors.length;++l){if(typeof r.sparseTensors[l]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");u.sparseTensors[l]=s.onnx.SparseTensorProto.fromObject(r.sparseTensors[l])}}if(r.typeProtos){if(!Array.isArray(r.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");u.typeProtos=[];for(var l=0;l<r.typeProtos.length;++l){if(typeof r.typeProtos[l]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");u.typeProtos[l]=s.onnx.TypeProto.fromObject(r.typeProtos[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.floats=[],l.ints=[],l.strings=[],l.tensors=[],l.graphs=[],l.typeProtos=[],l.sparseTensors=[]),u.defaults){if(l.name="",l.f=0,o.Long){var f=new o.Long(0,0,!1);l.i=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.i=u.longs===String?"0":0;u.bytes===String?l.s="":(l.s=[],u.bytes!==Array&&(l.s=o.newBuffer(l.s))),l.t=null,l.g=null,l.docString="",l.tp=null,l.type=u.enums===String?"UNDEFINED":0,l.refAttrName="",l.sparseTensor=null}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.f!=null&&r.hasOwnProperty("f")&&(l.f=u.json&&!isFinite(r.f)?String(r.f):r.f),r.i!=null&&r.hasOwnProperty("i")&&(typeof r.i=="number"?l.i=u.longs===String?String(r.i):r.i:l.i=u.longs===String?o.Long.prototype.toString.call(r.i):u.longs===Number?new o.LongBits(r.i.low>>>0,r.i.high>>>0).toNumber():r.i),r.s!=null&&r.hasOwnProperty("s")&&(l.s=u.bytes===String?o.base64.encode(r.s,0,r.s.length):u.bytes===Array?Array.prototype.slice.call(r.s):r.s),r.t!=null&&r.hasOwnProperty("t")&&(l.t=s.onnx.TensorProto.toObject(r.t,u)),r.g!=null&&r.hasOwnProperty("g")&&(l.g=s.onnx.GraphProto.toObject(r.g,u)),r.floats&&r.floats.length){l.floats=[];for(var g=0;g<r.floats.length;++g)l.floats[g]=u.json&&!isFinite(r.floats[g])?String(r.floats[g]):r.floats[g]}if(r.ints&&r.ints.length){l.ints=[];for(var g=0;g<r.ints.length;++g)typeof r.ints[g]=="number"?l.ints[g]=u.longs===String?String(r.ints[g]):r.ints[g]:l.ints[g]=u.longs===String?o.Long.prototype.toString.call(r.ints[g]):u.longs===Number?new o.LongBits(r.ints[g].low>>>0,r.ints[g].high>>>0).toNumber():r.ints[g]}if(r.strings&&r.strings.length){l.strings=[];for(var g=0;g<r.strings.length;++g)l.strings[g]=u.bytes===String?o.base64.encode(r.strings[g],0,r.strings[g].length):u.bytes===Array?Array.prototype.slice.call(r.strings[g]):r.strings[g]}if(r.tensors&&r.tensors.length){l.tensors=[];for(var g=0;g<r.tensors.length;++g)l.tensors[g]=s.onnx.TensorProto.toObject(r.tensors[g],u)}if(r.graphs&&r.graphs.length){l.graphs=[];for(var g=0;g<r.graphs.length;++g)l.graphs[g]=s.onnx.GraphProto.toObject(r.graphs[g],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.tp!=null&&r.hasOwnProperty("tp")&&(l.tp=s.onnx.TypeProto.toObject(r.tp,u)),r.typeProtos&&r.typeProtos.length){l.typeProtos=[];for(var g=0;g<r.typeProtos.length;++g)l.typeProtos[g]=s.onnx.TypeProto.toObject(r.typeProtos[g],u)}if(r.type!=null&&r.hasOwnProperty("type")&&(l.type=u.enums===String?s.onnx.AttributeProto.AttributeType[r.type]===void 0?r.type:s.onnx.AttributeProto.AttributeType[r.type]:r.type),r.refAttrName!=null&&r.hasOwnProperty("refAttrName")&&(l.refAttrName=r.refAttrName),r.sparseTensor!=null&&r.hasOwnProperty("sparseTensor")&&(l.sparseTensor=s.onnx.SparseTensorProto.toObject(r.sparseTensor,u)),r.sparseTensors&&r.sparseTensors.length){l.sparseTensors=[];for(var g=0;g<r.sparseTensors.length;++g)l.sparseTensors[g]=s.onnx.SparseTensorProto.toObject(r.sparseTensors[g],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.AttributeProto"},h.AttributeType=function(){var r={},u=Object.create(r);return u[r[0]="UNDEFINED"]=0,u[r[1]="FLOAT"]=1,u[r[2]="INT"]=2,u[r[3]="STRING"]=3,u[r[4]="TENSOR"]=4,u[r[5]="GRAPH"]=5,u[r[11]="SPARSE_TENSOR"]=11,u[r[13]="TYPE_PROTO"]=13,u[r[6]="FLOATS"]=6,u[r[7]="INTS"]=7,u[r[8]="STRINGS"]=8,u[r[9]="TENSORS"]=9,u[r[10]="GRAPHS"]=10,u[r[12]="SPARSE_TENSORS"]=12,u[r[14]="TYPE_PROTOS"]=14,u}(),h}(),c.ValueInfoProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.type=null,h.prototype.docString="",h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.type!=null&&Object.hasOwnProperty.call(r,"type")&&s.onnx.TypeProto.encode(r.type,u.uint32(18).fork()).ldelim(),r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(26).string(r.docString),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.ValueInfoProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 2:{f.type=s.onnx.TypeProto.decode(r,r.uint32());break}case 3:{f.docString=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.type!=null&&r.hasOwnProperty("type")){var u=s.onnx.TypeProto.verify(r.type);if(u)return"type."+u}return r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString)?"docString: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.ValueInfoProto)return r;var u=new s.onnx.ValueInfoProto;if(r.name!=null&&(u.name=String(r.name)),r.type!=null){if(typeof r.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");u.type=s.onnx.TypeProto.fromObject(r.type)}return r.docString!=null&&(u.docString=String(r.docString)),u},h.toObject=function(r,u){u||(u={});var l={};return u.defaults&&(l.name="",l.type=null,l.docString=""),r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.type!=null&&r.hasOwnProperty("type")&&(l.type=s.onnx.TypeProto.toObject(r.type,u)),r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.ValueInfoProto"},h}(),c.NodeProto=function(){function h(r){if(this.input=[],this.output=[],this.attribute=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.name="",h.prototype.opType="",h.prototype.domain="",h.prototype.attribute=o.emptyArray,h.prototype.docString="",h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)u.uint32(10).string(r.input[l]);if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)u.uint32(18).string(r.output[l]);if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(26).string(r.name),r.opType!=null&&Object.hasOwnProperty.call(r,"opType")&&u.uint32(34).string(r.opType),r.attribute!=null&&r.attribute.length)for(var l=0;l<r.attribute.length;++l)s.onnx.AttributeProto.encode(r.attribute[l],u.uint32(42).fork()).ldelim();return r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(50).string(r.docString),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(58).string(r.domain),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.NodeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.input&&f.input.length||(f.input=[]),f.input.push(r.string());break}case 2:{f.output&&f.output.length||(f.output=[]),f.output.push(r.string());break}case 3:{f.name=r.string();break}case 4:{f.opType=r.string();break}case 7:{f.domain=r.string();break}case 5:{f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(s.onnx.AttributeProto.decode(r,r.uint32()));break}case 6:{f.docString=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u)if(!o.isString(r.input[u]))return"input: string[] expected"}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u)if(!o.isString(r.output[u]))return"output: string[] expected"}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.opType!=null&&r.hasOwnProperty("opType")&&!o.isString(r.opType))return"opType: string expected";if(r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain))return"domain: string expected";if(r.attribute!=null&&r.hasOwnProperty("attribute")){if(!Array.isArray(r.attribute))return"attribute: array expected";for(var u=0;u<r.attribute.length;++u){var l=s.onnx.AttributeProto.verify(r.attribute[u]);if(l)return"attribute."+l}}return r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString)?"docString: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.NodeProto)return r;var u=new s.onnx.NodeProto;if(r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.NodeProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l)u.input[l]=String(r.input[l])}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.NodeProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l)u.output[l]=String(r.output[l])}if(r.name!=null&&(u.name=String(r.name)),r.opType!=null&&(u.opType=String(r.opType)),r.domain!=null&&(u.domain=String(r.domain)),r.attribute){if(!Array.isArray(r.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");u.attribute=[];for(var l=0;l<r.attribute.length;++l){if(typeof r.attribute[l]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");u.attribute[l]=s.onnx.AttributeProto.fromObject(r.attribute[l])}}return r.docString!=null&&(u.docString=String(r.docString)),u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.input=[],l.output=[],l.attribute=[]),u.defaults&&(l.name="",l.opType="",l.docString="",l.domain=""),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=r.input[f]}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=r.output[f]}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.opType!=null&&r.hasOwnProperty("opType")&&(l.opType=r.opType),r.attribute&&r.attribute.length){l.attribute=[];for(var f=0;f<r.attribute.length;++f)l.attribute[f]=s.onnx.AttributeProto.toObject(r.attribute[f],u)}return r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.NodeProto"},h}(),c.TrainingInfoProto=function(){function h(r){if(this.initializationBinding=[],this.updateBinding=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.initialization=null,h.prototype.algorithm=null,h.prototype.initializationBinding=o.emptyArray,h.prototype.updateBinding=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.initialization!=null&&Object.hasOwnProperty.call(r,"initialization")&&s.onnx.GraphProto.encode(r.initialization,u.uint32(10).fork()).ldelim(),r.algorithm!=null&&Object.hasOwnProperty.call(r,"algorithm")&&s.onnx.GraphProto.encode(r.algorithm,u.uint32(18).fork()).ldelim(),r.initializationBinding!=null&&r.initializationBinding.length)for(var l=0;l<r.initializationBinding.length;++l)s.onnx.StringStringEntryProto.encode(r.initializationBinding[l],u.uint32(26).fork()).ldelim();if(r.updateBinding!=null&&r.updateBinding.length)for(var l=0;l<r.updateBinding.length;++l)s.onnx.StringStringEntryProto.encode(r.updateBinding[l],u.uint32(34).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TrainingInfoProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.initialization=s.onnx.GraphProto.decode(r,r.uint32());break}case 2:{f.algorithm=s.onnx.GraphProto.decode(r,r.uint32());break}case 3:{f.initializationBinding&&f.initializationBinding.length||(f.initializationBinding=[]),f.initializationBinding.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 4:{f.updateBinding&&f.updateBinding.length||(f.updateBinding=[]),f.updateBinding.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.initialization!=null&&r.hasOwnProperty("initialization")){var u=s.onnx.GraphProto.verify(r.initialization);if(u)return"initialization."+u}if(r.algorithm!=null&&r.hasOwnProperty("algorithm")){var u=s.onnx.GraphProto.verify(r.algorithm);if(u)return"algorithm."+u}if(r.initializationBinding!=null&&r.hasOwnProperty("initializationBinding")){if(!Array.isArray(r.initializationBinding))return"initializationBinding: array expected";for(var l=0;l<r.initializationBinding.length;++l){var u=s.onnx.StringStringEntryProto.verify(r.initializationBinding[l]);if(u)return"initializationBinding."+u}}if(r.updateBinding!=null&&r.hasOwnProperty("updateBinding")){if(!Array.isArray(r.updateBinding))return"updateBinding: array expected";for(var l=0;l<r.updateBinding.length;++l){var u=s.onnx.StringStringEntryProto.verify(r.updateBinding[l]);if(u)return"updateBinding."+u}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TrainingInfoProto)return r;var u=new s.onnx.TrainingInfoProto;if(r.initialization!=null){if(typeof r.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");u.initialization=s.onnx.GraphProto.fromObject(r.initialization)}if(r.algorithm!=null){if(typeof r.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");u.algorithm=s.onnx.GraphProto.fromObject(r.algorithm)}if(r.initializationBinding){if(!Array.isArray(r.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");u.initializationBinding=[];for(var l=0;l<r.initializationBinding.length;++l){if(typeof r.initializationBinding[l]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");u.initializationBinding[l]=s.onnx.StringStringEntryProto.fromObject(r.initializationBinding[l])}}if(r.updateBinding){if(!Array.isArray(r.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");u.updateBinding=[];for(var l=0;l<r.updateBinding.length;++l){if(typeof r.updateBinding[l]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");u.updateBinding[l]=s.onnx.StringStringEntryProto.fromObject(r.updateBinding[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.initializationBinding=[],l.updateBinding=[]),u.defaults&&(l.initialization=null,l.algorithm=null),r.initialization!=null&&r.hasOwnProperty("initialization")&&(l.initialization=s.onnx.GraphProto.toObject(r.initialization,u)),r.algorithm!=null&&r.hasOwnProperty("algorithm")&&(l.algorithm=s.onnx.GraphProto.toObject(r.algorithm,u)),r.initializationBinding&&r.initializationBinding.length){l.initializationBinding=[];for(var f=0;f<r.initializationBinding.length;++f)l.initializationBinding[f]=s.onnx.StringStringEntryProto.toObject(r.initializationBinding[f],u)}if(r.updateBinding&&r.updateBinding.length){l.updateBinding=[];for(var f=0;f<r.updateBinding.length;++f)l.updateBinding[f]=s.onnx.StringStringEntryProto.toObject(r.updateBinding[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TrainingInfoProto"},h}(),c.ModelProto=function(){function h(r){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.irVersion=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.opsetImport=o.emptyArray,h.prototype.producerName="",h.prototype.producerVersion="",h.prototype.domain="",h.prototype.modelVersion=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.docString="",h.prototype.graph=null,h.prototype.metadataProps=o.emptyArray,h.prototype.trainingInfo=o.emptyArray,h.prototype.functions=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.irVersion!=null&&Object.hasOwnProperty.call(r,"irVersion")&&u.uint32(8).int64(r.irVersion),r.producerName!=null&&Object.hasOwnProperty.call(r,"producerName")&&u.uint32(18).string(r.producerName),r.producerVersion!=null&&Object.hasOwnProperty.call(r,"producerVersion")&&u.uint32(26).string(r.producerVersion),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(34).string(r.domain),r.modelVersion!=null&&Object.hasOwnProperty.call(r,"modelVersion")&&u.uint32(40).int64(r.modelVersion),r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(50).string(r.docString),r.graph!=null&&Object.hasOwnProperty.call(r,"graph")&&s.onnx.GraphProto.encode(r.graph,u.uint32(58).fork()).ldelim(),r.opsetImport!=null&&r.opsetImport.length)for(var l=0;l<r.opsetImport.length;++l)s.onnx.OperatorSetIdProto.encode(r.opsetImport[l],u.uint32(66).fork()).ldelim();if(r.metadataProps!=null&&r.metadataProps.length)for(var l=0;l<r.metadataProps.length;++l)s.onnx.StringStringEntryProto.encode(r.metadataProps[l],u.uint32(114).fork()).ldelim();if(r.trainingInfo!=null&&r.trainingInfo.length)for(var l=0;l<r.trainingInfo.length;++l)s.onnx.TrainingInfoProto.encode(r.trainingInfo[l],u.uint32(162).fork()).ldelim();if(r.functions!=null&&r.functions.length)for(var l=0;l<r.functions.length;++l)s.onnx.FunctionProto.encode(r.functions[l],u.uint32(202).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.ModelProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.irVersion=r.int64();break}case 8:{f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(s.onnx.OperatorSetIdProto.decode(r,r.uint32()));break}case 2:{f.producerName=r.string();break}case 3:{f.producerVersion=r.string();break}case 4:{f.domain=r.string();break}case 5:{f.modelVersion=r.int64();break}case 6:{f.docString=r.string();break}case 7:{f.graph=s.onnx.GraphProto.decode(r,r.uint32());break}case 14:{f.metadataProps&&f.metadataProps.length||(f.metadataProps=[]),f.metadataProps.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 20:{f.trainingInfo&&f.trainingInfo.length||(f.trainingInfo=[]),f.trainingInfo.push(s.onnx.TrainingInfoProto.decode(r,r.uint32()));break}case 25:{f.functions&&f.functions.length||(f.functions=[]),f.functions.push(s.onnx.FunctionProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.irVersion!=null&&r.hasOwnProperty("irVersion")&&!o.isInteger(r.irVersion)&&!(r.irVersion&&o.isInteger(r.irVersion.low)&&o.isInteger(r.irVersion.high)))return"irVersion: integer|Long expected";if(r.opsetImport!=null&&r.hasOwnProperty("opsetImport")){if(!Array.isArray(r.opsetImport))return"opsetImport: array expected";for(var u=0;u<r.opsetImport.length;++u){var l=s.onnx.OperatorSetIdProto.verify(r.opsetImport[u]);if(l)return"opsetImport."+l}}if(r.producerName!=null&&r.hasOwnProperty("producerName")&&!o.isString(r.producerName))return"producerName: string expected";if(r.producerVersion!=null&&r.hasOwnProperty("producerVersion")&&!o.isString(r.producerVersion))return"producerVersion: string expected";if(r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain))return"domain: string expected";if(r.modelVersion!=null&&r.hasOwnProperty("modelVersion")&&!o.isInteger(r.modelVersion)&&!(r.modelVersion&&o.isInteger(r.modelVersion.low)&&o.isInteger(r.modelVersion.high)))return"modelVersion: integer|Long expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.graph!=null&&r.hasOwnProperty("graph")){var l=s.onnx.GraphProto.verify(r.graph);if(l)return"graph."+l}if(r.metadataProps!=null&&r.hasOwnProperty("metadataProps")){if(!Array.isArray(r.metadataProps))return"metadataProps: array expected";for(var u=0;u<r.metadataProps.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.metadataProps[u]);if(l)return"metadataProps."+l}}if(r.trainingInfo!=null&&r.hasOwnProperty("trainingInfo")){if(!Array.isArray(r.trainingInfo))return"trainingInfo: array expected";for(var u=0;u<r.trainingInfo.length;++u){var l=s.onnx.TrainingInfoProto.verify(r.trainingInfo[u]);if(l)return"trainingInfo."+l}}if(r.functions!=null&&r.hasOwnProperty("functions")){if(!Array.isArray(r.functions))return"functions: array expected";for(var u=0;u<r.functions.length;++u){var l=s.onnx.FunctionProto.verify(r.functions[u]);if(l)return"functions."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.ModelProto)return r;var u=new s.onnx.ModelProto;if(r.irVersion!=null&&(o.Long?(u.irVersion=o.Long.fromValue(r.irVersion)).unsigned=!1:typeof r.irVersion=="string"?u.irVersion=parseInt(r.irVersion,10):typeof r.irVersion=="number"?u.irVersion=r.irVersion:typeof r.irVersion=="object"&&(u.irVersion=new o.LongBits(r.irVersion.low>>>0,r.irVersion.high>>>0).toNumber())),r.opsetImport){if(!Array.isArray(r.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");u.opsetImport=[];for(var l=0;l<r.opsetImport.length;++l){if(typeof r.opsetImport[l]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");u.opsetImport[l]=s.onnx.OperatorSetIdProto.fromObject(r.opsetImport[l])}}if(r.producerName!=null&&(u.producerName=String(r.producerName)),r.producerVersion!=null&&(u.producerVersion=String(r.producerVersion)),r.domain!=null&&(u.domain=String(r.domain)),r.modelVersion!=null&&(o.Long?(u.modelVersion=o.Long.fromValue(r.modelVersion)).unsigned=!1:typeof r.modelVersion=="string"?u.modelVersion=parseInt(r.modelVersion,10):typeof r.modelVersion=="number"?u.modelVersion=r.modelVersion:typeof r.modelVersion=="object"&&(u.modelVersion=new o.LongBits(r.modelVersion.low>>>0,r.modelVersion.high>>>0).toNumber())),r.docString!=null&&(u.docString=String(r.docString)),r.graph!=null){if(typeof r.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");u.graph=s.onnx.GraphProto.fromObject(r.graph)}if(r.metadataProps){if(!Array.isArray(r.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");u.metadataProps=[];for(var l=0;l<r.metadataProps.length;++l){if(typeof r.metadataProps[l]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");u.metadataProps[l]=s.onnx.StringStringEntryProto.fromObject(r.metadataProps[l])}}if(r.trainingInfo){if(!Array.isArray(r.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");u.trainingInfo=[];for(var l=0;l<r.trainingInfo.length;++l){if(typeof r.trainingInfo[l]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");u.trainingInfo[l]=s.onnx.TrainingInfoProto.fromObject(r.trainingInfo[l])}}if(r.functions){if(!Array.isArray(r.functions))throw TypeError(".onnx.ModelProto.functions: array expected");u.functions=[];for(var l=0;l<r.functions.length;++l){if(typeof r.functions[l]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");u.functions[l]=s.onnx.FunctionProto.fromObject(r.functions[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.opsetImport=[],l.metadataProps=[],l.trainingInfo=[],l.functions=[]),u.defaults){if(o.Long){var f=new o.Long(0,0,!1);l.irVersion=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.irVersion=u.longs===String?"0":0;if(l.producerName="",l.producerVersion="",l.domain="",o.Long){var f=new o.Long(0,0,!1);l.modelVersion=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.modelVersion=u.longs===String?"0":0;l.docString="",l.graph=null}if(r.irVersion!=null&&r.hasOwnProperty("irVersion")&&(typeof r.irVersion=="number"?l.irVersion=u.longs===String?String(r.irVersion):r.irVersion:l.irVersion=u.longs===String?o.Long.prototype.toString.call(r.irVersion):u.longs===Number?new o.LongBits(r.irVersion.low>>>0,r.irVersion.high>>>0).toNumber():r.irVersion),r.producerName!=null&&r.hasOwnProperty("producerName")&&(l.producerName=r.producerName),r.producerVersion!=null&&r.hasOwnProperty("producerVersion")&&(l.producerVersion=r.producerVersion),r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.modelVersion!=null&&r.hasOwnProperty("modelVersion")&&(typeof r.modelVersion=="number"?l.modelVersion=u.longs===String?String(r.modelVersion):r.modelVersion:l.modelVersion=u.longs===String?o.Long.prototype.toString.call(r.modelVersion):u.longs===Number?new o.LongBits(r.modelVersion.low>>>0,r.modelVersion.high>>>0).toNumber():r.modelVersion),r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.graph!=null&&r.hasOwnProperty("graph")&&(l.graph=s.onnx.GraphProto.toObject(r.graph,u)),r.opsetImport&&r.opsetImport.length){l.opsetImport=[];for(var g=0;g<r.opsetImport.length;++g)l.opsetImport[g]=s.onnx.OperatorSetIdProto.toObject(r.opsetImport[g],u)}if(r.metadataProps&&r.metadataProps.length){l.metadataProps=[];for(var g=0;g<r.metadataProps.length;++g)l.metadataProps[g]=s.onnx.StringStringEntryProto.toObject(r.metadataProps[g],u)}if(r.trainingInfo&&r.trainingInfo.length){l.trainingInfo=[];for(var g=0;g<r.trainingInfo.length;++g)l.trainingInfo[g]=s.onnx.TrainingInfoProto.toObject(r.trainingInfo[g],u)}if(r.functions&&r.functions.length){l.functions=[];for(var g=0;g<r.functions.length;++g)l.functions[g]=s.onnx.FunctionProto.toObject(r.functions[g],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.ModelProto"},h}(),c.StringStringEntryProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.key="",h.prototype.value="",h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.key!=null&&Object.hasOwnProperty.call(r,"key")&&u.uint32(10).string(r.key),r.value!=null&&Object.hasOwnProperty.call(r,"value")&&u.uint32(18).string(r.value),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.StringStringEntryProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.key=r.string();break}case 2:{f.value=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){return typeof r!="object"||r===null?"object expected":r.key!=null&&r.hasOwnProperty("key")&&!o.isString(r.key)?"key: string expected":r.value!=null&&r.hasOwnProperty("value")&&!o.isString(r.value)?"value: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.StringStringEntryProto)return r;var u=new s.onnx.StringStringEntryProto;return r.key!=null&&(u.key=String(r.key)),r.value!=null&&(u.value=String(r.value)),u},h.toObject=function(r,u){u||(u={});var l={};return u.defaults&&(l.key="",l.value=""),r.key!=null&&r.hasOwnProperty("key")&&(l.key=r.key),r.value!=null&&r.hasOwnProperty("value")&&(l.value=r.value),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.StringStringEntryProto"},h}(),c.TensorAnnotation=function(){function h(r){if(this.quantParameterTensorNames=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.tensorName="",h.prototype.quantParameterTensorNames=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.tensorName!=null&&Object.hasOwnProperty.call(r,"tensorName")&&u.uint32(10).string(r.tensorName),r.quantParameterTensorNames!=null&&r.quantParameterTensorNames.length)for(var l=0;l<r.quantParameterTensorNames.length;++l)s.onnx.StringStringEntryProto.encode(r.quantParameterTensorNames[l],u.uint32(18).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorAnnotation;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.tensorName=r.string();break}case 2:{f.quantParameterTensorNames&&f.quantParameterTensorNames.length||(f.quantParameterTensorNames=[]),f.quantParameterTensorNames.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.tensorName!=null&&r.hasOwnProperty("tensorName")&&!o.isString(r.tensorName))return"tensorName: string expected";if(r.quantParameterTensorNames!=null&&r.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(r.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var u=0;u<r.quantParameterTensorNames.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.quantParameterTensorNames[u]);if(l)return"quantParameterTensorNames."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorAnnotation)return r;var u=new s.onnx.TensorAnnotation;if(r.tensorName!=null&&(u.tensorName=String(r.tensorName)),r.quantParameterTensorNames){if(!Array.isArray(r.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");u.quantParameterTensorNames=[];for(var l=0;l<r.quantParameterTensorNames.length;++l){if(typeof r.quantParameterTensorNames[l]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");u.quantParameterTensorNames[l]=s.onnx.StringStringEntryProto.fromObject(r.quantParameterTensorNames[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.quantParameterTensorNames=[]),u.defaults&&(l.tensorName=""),r.tensorName!=null&&r.hasOwnProperty("tensorName")&&(l.tensorName=r.tensorName),r.quantParameterTensorNames&&r.quantParameterTensorNames.length){l.quantParameterTensorNames=[];for(var f=0;f<r.quantParameterTensorNames.length;++f)l.quantParameterTensorNames[f]=s.onnx.StringStringEntryProto.toObject(r.quantParameterTensorNames[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorAnnotation"},h}(),c.GraphProto=function(){function h(r){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.node=o.emptyArray,h.prototype.name="",h.prototype.initializer=o.emptyArray,h.prototype.sparseInitializer=o.emptyArray,h.prototype.docString="",h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.valueInfo=o.emptyArray,h.prototype.quantizationAnnotation=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.node!=null&&r.node.length)for(var l=0;l<r.node.length;++l)s.onnx.NodeProto.encode(r.node[l],u.uint32(10).fork()).ldelim();if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(18).string(r.name),r.initializer!=null&&r.initializer.length)for(var l=0;l<r.initializer.length;++l)s.onnx.TensorProto.encode(r.initializer[l],u.uint32(42).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(82).string(r.docString),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)s.onnx.ValueInfoProto.encode(r.input[l],u.uint32(90).fork()).ldelim();if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)s.onnx.ValueInfoProto.encode(r.output[l],u.uint32(98).fork()).ldelim();if(r.valueInfo!=null&&r.valueInfo.length)for(var l=0;l<r.valueInfo.length;++l)s.onnx.ValueInfoProto.encode(r.valueInfo[l],u.uint32(106).fork()).ldelim();if(r.quantizationAnnotation!=null&&r.quantizationAnnotation.length)for(var l=0;l<r.quantizationAnnotation.length;++l)s.onnx.TensorAnnotation.encode(r.quantizationAnnotation[l],u.uint32(114).fork()).ldelim();if(r.sparseInitializer!=null&&r.sparseInitializer.length)for(var l=0;l<r.sparseInitializer.length;++l)s.onnx.SparseTensorProto.encode(r.sparseInitializer[l],u.uint32(122).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.GraphProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.node&&f.node.length||(f.node=[]),f.node.push(s.onnx.NodeProto.decode(r,r.uint32()));break}case 2:{f.name=r.string();break}case 5:{f.initializer&&f.initializer.length||(f.initializer=[]),f.initializer.push(s.onnx.TensorProto.decode(r,r.uint32()));break}case 15:{f.sparseInitializer&&f.sparseInitializer.length||(f.sparseInitializer=[]),f.sparseInitializer.push(s.onnx.SparseTensorProto.decode(r,r.uint32()));break}case 10:{f.docString=r.string();break}case 11:{f.input&&f.input.length||(f.input=[]),f.input.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 12:{f.output&&f.output.length||(f.output=[]),f.output.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 13:{f.valueInfo&&f.valueInfo.length||(f.valueInfo=[]),f.valueInfo.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 14:{f.quantizationAnnotation&&f.quantizationAnnotation.length||(f.quantizationAnnotation=[]),f.quantizationAnnotation.push(s.onnx.TensorAnnotation.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.node!=null&&r.hasOwnProperty("node")){if(!Array.isArray(r.node))return"node: array expected";for(var u=0;u<r.node.length;++u){var l=s.onnx.NodeProto.verify(r.node[u]);if(l)return"node."+l}}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.initializer!=null&&r.hasOwnProperty("initializer")){if(!Array.isArray(r.initializer))return"initializer: array expected";for(var u=0;u<r.initializer.length;++u){var l=s.onnx.TensorProto.verify(r.initializer[u]);if(l)return"initializer."+l}}if(r.sparseInitializer!=null&&r.hasOwnProperty("sparseInitializer")){if(!Array.isArray(r.sparseInitializer))return"sparseInitializer: array expected";for(var u=0;u<r.sparseInitializer.length;++u){var l=s.onnx.SparseTensorProto.verify(r.sparseInitializer[u]);if(l)return"sparseInitializer."+l}}if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u){var l=s.onnx.ValueInfoProto.verify(r.input[u]);if(l)return"input."+l}}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u){var l=s.onnx.ValueInfoProto.verify(r.output[u]);if(l)return"output."+l}}if(r.valueInfo!=null&&r.hasOwnProperty("valueInfo")){if(!Array.isArray(r.valueInfo))return"valueInfo: array expected";for(var u=0;u<r.valueInfo.length;++u){var l=s.onnx.ValueInfoProto.verify(r.valueInfo[u]);if(l)return"valueInfo."+l}}if(r.quantizationAnnotation!=null&&r.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(r.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var u=0;u<r.quantizationAnnotation.length;++u){var l=s.onnx.TensorAnnotation.verify(r.quantizationAnnotation[u]);if(l)return"quantizationAnnotation."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.GraphProto)return r;var u=new s.onnx.GraphProto;if(r.node){if(!Array.isArray(r.node))throw TypeError(".onnx.GraphProto.node: array expected");u.node=[];for(var l=0;l<r.node.length;++l){if(typeof r.node[l]!="object")throw TypeError(".onnx.GraphProto.node: object expected");u.node[l]=s.onnx.NodeProto.fromObject(r.node[l])}}if(r.name!=null&&(u.name=String(r.name)),r.initializer){if(!Array.isArray(r.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");u.initializer=[];for(var l=0;l<r.initializer.length;++l){if(typeof r.initializer[l]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");u.initializer[l]=s.onnx.TensorProto.fromObject(r.initializer[l])}}if(r.sparseInitializer){if(!Array.isArray(r.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");u.sparseInitializer=[];for(var l=0;l<r.sparseInitializer.length;++l){if(typeof r.sparseInitializer[l]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");u.sparseInitializer[l]=s.onnx.SparseTensorProto.fromObject(r.sparseInitializer[l])}}if(r.docString!=null&&(u.docString=String(r.docString)),r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.GraphProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l){if(typeof r.input[l]!="object")throw TypeError(".onnx.GraphProto.input: object expected");u.input[l]=s.onnx.ValueInfoProto.fromObject(r.input[l])}}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.GraphProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l){if(typeof r.output[l]!="object")throw TypeError(".onnx.GraphProto.output: object expected");u.output[l]=s.onnx.ValueInfoProto.fromObject(r.output[l])}}if(r.valueInfo){if(!Array.isArray(r.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");u.valueInfo=[];for(var l=0;l<r.valueInfo.length;++l){if(typeof r.valueInfo[l]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");u.valueInfo[l]=s.onnx.ValueInfoProto.fromObject(r.valueInfo[l])}}if(r.quantizationAnnotation){if(!Array.isArray(r.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");u.quantizationAnnotation=[];for(var l=0;l<r.quantizationAnnotation.length;++l){if(typeof r.quantizationAnnotation[l]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");u.quantizationAnnotation[l]=s.onnx.TensorAnnotation.fromObject(r.quantizationAnnotation[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.node=[],l.initializer=[],l.input=[],l.output=[],l.valueInfo=[],l.quantizationAnnotation=[],l.sparseInitializer=[]),u.defaults&&(l.name="",l.docString=""),r.node&&r.node.length){l.node=[];for(var f=0;f<r.node.length;++f)l.node[f]=s.onnx.NodeProto.toObject(r.node[f],u)}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.initializer&&r.initializer.length){l.initializer=[];for(var f=0;f<r.initializer.length;++f)l.initializer[f]=s.onnx.TensorProto.toObject(r.initializer[f],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=s.onnx.ValueInfoProto.toObject(r.input[f],u)}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=s.onnx.ValueInfoProto.toObject(r.output[f],u)}if(r.valueInfo&&r.valueInfo.length){l.valueInfo=[];for(var f=0;f<r.valueInfo.length;++f)l.valueInfo[f]=s.onnx.ValueInfoProto.toObject(r.valueInfo[f],u)}if(r.quantizationAnnotation&&r.quantizationAnnotation.length){l.quantizationAnnotation=[];for(var f=0;f<r.quantizationAnnotation.length;++f)l.quantizationAnnotation[f]=s.onnx.TensorAnnotation.toObject(r.quantizationAnnotation[f],u)}if(r.sparseInitializer&&r.sparseInitializer.length){l.sparseInitializer=[];for(var f=0;f<r.sparseInitializer.length;++f)l.sparseInitializer[f]=s.onnx.SparseTensorProto.toObject(r.sparseInitializer[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.GraphProto"},h}(),c.TensorProto=function(){function h(r){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.dims=o.emptyArray,h.prototype.dataType=0,h.prototype.segment=null,h.prototype.floatData=o.emptyArray,h.prototype.int32Data=o.emptyArray,h.prototype.stringData=o.emptyArray,h.prototype.int64Data=o.emptyArray,h.prototype.name="",h.prototype.docString="",h.prototype.rawData=o.newBuffer([]),h.prototype.externalData=o.emptyArray,h.prototype.dataLocation=0,h.prototype.doubleData=o.emptyArray,h.prototype.uint64Data=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.dims!=null&&r.dims.length){u.uint32(10).fork();for(var l=0;l<r.dims.length;++l)u.int64(r.dims[l]);u.ldelim()}if(r.dataType!=null&&Object.hasOwnProperty.call(r,"dataType")&&u.uint32(16).int32(r.dataType),r.segment!=null&&Object.hasOwnProperty.call(r,"segment")&&s.onnx.TensorProto.Segment.encode(r.segment,u.uint32(26).fork()).ldelim(),r.floatData!=null&&r.floatData.length){u.uint32(34).fork();for(var l=0;l<r.floatData.length;++l)u.float(r.floatData[l]);u.ldelim()}if(r.int32Data!=null&&r.int32Data.length){u.uint32(42).fork();for(var l=0;l<r.int32Data.length;++l)u.int32(r.int32Data[l]);u.ldelim()}if(r.stringData!=null&&r.stringData.length)for(var l=0;l<r.stringData.length;++l)u.uint32(50).bytes(r.stringData[l]);if(r.int64Data!=null&&r.int64Data.length){u.uint32(58).fork();for(var l=0;l<r.int64Data.length;++l)u.int64(r.int64Data[l]);u.ldelim()}if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(66).string(r.name),r.rawData!=null&&Object.hasOwnProperty.call(r,"rawData")&&u.uint32(74).bytes(r.rawData),r.doubleData!=null&&r.doubleData.length){u.uint32(82).fork();for(var l=0;l<r.doubleData.length;++l)u.double(r.doubleData[l]);u.ldelim()}if(r.uint64Data!=null&&r.uint64Data.length){u.uint32(90).fork();for(var l=0;l<r.uint64Data.length;++l)u.uint64(r.uint64Data[l]);u.ldelim()}if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(98).string(r.docString),r.externalData!=null&&r.externalData.length)for(var l=0;l<r.externalData.length;++l)s.onnx.StringStringEntryProto.encode(r.externalData[l],u.uint32(106).fork()).ldelim();return r.dataLocation!=null&&Object.hasOwnProperty.call(r,"dataLocation")&&u.uint32(112).int32(r.dataLocation),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{if(f.dims&&f.dims.length||(f.dims=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.dims.push(r.int64());else f.dims.push(r.int64());break}case 2:{f.dataType=r.int32();break}case 3:{f.segment=s.onnx.TensorProto.Segment.decode(r,r.uint32());break}case 4:{if(f.floatData&&f.floatData.length||(f.floatData=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.floatData.push(r.float());else f.floatData.push(r.float());break}case 5:{if(f.int32Data&&f.int32Data.length||(f.int32Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.int32Data.push(r.int32());else f.int32Data.push(r.int32());break}case 6:{f.stringData&&f.stringData.length||(f.stringData=[]),f.stringData.push(r.bytes());break}case 7:{if(f.int64Data&&f.int64Data.length||(f.int64Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.int64Data.push(r.int64());else f.int64Data.push(r.int64());break}case 8:{f.name=r.string();break}case 12:{f.docString=r.string();break}case 9:{f.rawData=r.bytes();break}case 13:{f.externalData&&f.externalData.length||(f.externalData=[]),f.externalData.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 14:{f.dataLocation=r.int32();break}case 10:{if(f.doubleData&&f.doubleData.length||(f.doubleData=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.doubleData.push(r.double());else f.doubleData.push(r.double());break}case 11:{if(f.uint64Data&&f.uint64Data.length||(f.uint64Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.uint64Data.push(r.uint64());else f.uint64Data.push(r.uint64());break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.dims!=null&&r.hasOwnProperty("dims")){if(!Array.isArray(r.dims))return"dims: array expected";for(var u=0;u<r.dims.length;++u)if(!o.isInteger(r.dims[u])&&!(r.dims[u]&&o.isInteger(r.dims[u].low)&&o.isInteger(r.dims[u].high)))return"dims: integer|Long[] expected"}if(r.dataType!=null&&r.hasOwnProperty("dataType")&&!o.isInteger(r.dataType))return"dataType: integer expected";if(r.segment!=null&&r.hasOwnProperty("segment")){var l=s.onnx.TensorProto.Segment.verify(r.segment);if(l)return"segment."+l}if(r.floatData!=null&&r.hasOwnProperty("floatData")){if(!Array.isArray(r.floatData))return"floatData: array expected";for(var u=0;u<r.floatData.length;++u)if(typeof r.floatData[u]!="number")return"floatData: number[] expected"}if(r.int32Data!=null&&r.hasOwnProperty("int32Data")){if(!Array.isArray(r.int32Data))return"int32Data: array expected";for(var u=0;u<r.int32Data.length;++u)if(!o.isInteger(r.int32Data[u]))return"int32Data: integer[] expected"}if(r.stringData!=null&&r.hasOwnProperty("stringData")){if(!Array.isArray(r.stringData))return"stringData: array expected";for(var u=0;u<r.stringData.length;++u)if(!(r.stringData[u]&&typeof r.stringData[u].length=="number"||o.isString(r.stringData[u])))return"stringData: buffer[] expected"}if(r.int64Data!=null&&r.hasOwnProperty("int64Data")){if(!Array.isArray(r.int64Data))return"int64Data: array expected";for(var u=0;u<r.int64Data.length;++u)if(!o.isInteger(r.int64Data[u])&&!(r.int64Data[u]&&o.isInteger(r.int64Data[u].low)&&o.isInteger(r.int64Data[u].high)))return"int64Data: integer|Long[] expected"}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.rawData!=null&&r.hasOwnProperty("rawData")&&!(r.rawData&&typeof r.rawData.length=="number"||o.isString(r.rawData)))return"rawData: buffer expected";if(r.externalData!=null&&r.hasOwnProperty("externalData")){if(!Array.isArray(r.externalData))return"externalData: array expected";for(var u=0;u<r.externalData.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.externalData[u]);if(l)return"externalData."+l}}if(r.dataLocation!=null&&r.hasOwnProperty("dataLocation"))switch(r.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:break}if(r.doubleData!=null&&r.hasOwnProperty("doubleData")){if(!Array.isArray(r.doubleData))return"doubleData: array expected";for(var u=0;u<r.doubleData.length;++u)if(typeof r.doubleData[u]!="number")return"doubleData: number[] expected"}if(r.uint64Data!=null&&r.hasOwnProperty("uint64Data")){if(!Array.isArray(r.uint64Data))return"uint64Data: array expected";for(var u=0;u<r.uint64Data.length;++u)if(!o.isInteger(r.uint64Data[u])&&!(r.uint64Data[u]&&o.isInteger(r.uint64Data[u].low)&&o.isInteger(r.uint64Data[u].high)))return"uint64Data: integer|Long[] expected"}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorProto)return r;var u=new s.onnx.TensorProto;if(r.dims){if(!Array.isArray(r.dims))throw TypeError(".onnx.TensorProto.dims: array expected");u.dims=[];for(var l=0;l<r.dims.length;++l)o.Long?(u.dims[l]=o.Long.fromValue(r.dims[l])).unsigned=!1:typeof r.dims[l]=="string"?u.dims[l]=parseInt(r.dims[l],10):typeof r.dims[l]=="number"?u.dims[l]=r.dims[l]:typeof r.dims[l]=="object"&&(u.dims[l]=new o.LongBits(r.dims[l].low>>>0,r.dims[l].high>>>0).toNumber())}if(r.dataType!=null&&(u.dataType=r.dataType|0),r.segment!=null){if(typeof r.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");u.segment=s.onnx.TensorProto.Segment.fromObject(r.segment)}if(r.floatData){if(!Array.isArray(r.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");u.floatData=[];for(var l=0;l<r.floatData.length;++l)u.floatData[l]=Number(r.floatData[l])}if(r.int32Data){if(!Array.isArray(r.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");u.int32Data=[];for(var l=0;l<r.int32Data.length;++l)u.int32Data[l]=r.int32Data[l]|0}if(r.stringData){if(!Array.isArray(r.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");u.stringData=[];for(var l=0;l<r.stringData.length;++l)typeof r.stringData[l]=="string"?o.base64.decode(r.stringData[l],u.stringData[l]=o.newBuffer(o.base64.length(r.stringData[l])),0):r.stringData[l].length>=0&&(u.stringData[l]=r.stringData[l])}if(r.int64Data){if(!Array.isArray(r.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");u.int64Data=[];for(var l=0;l<r.int64Data.length;++l)o.Long?(u.int64Data[l]=o.Long.fromValue(r.int64Data[l])).unsigned=!1:typeof r.int64Data[l]=="string"?u.int64Data[l]=parseInt(r.int64Data[l],10):typeof r.int64Data[l]=="number"?u.int64Data[l]=r.int64Data[l]:typeof r.int64Data[l]=="object"&&(u.int64Data[l]=new o.LongBits(r.int64Data[l].low>>>0,r.int64Data[l].high>>>0).toNumber())}if(r.name!=null&&(u.name=String(r.name)),r.docString!=null&&(u.docString=String(r.docString)),r.rawData!=null&&(typeof r.rawData=="string"?o.base64.decode(r.rawData,u.rawData=o.newBuffer(o.base64.length(r.rawData)),0):r.rawData.length>=0&&(u.rawData=r.rawData)),r.externalData){if(!Array.isArray(r.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");u.externalData=[];for(var l=0;l<r.externalData.length;++l){if(typeof r.externalData[l]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");u.externalData[l]=s.onnx.StringStringEntryProto.fromObject(r.externalData[l])}}switch(r.dataLocation){default:if(typeof r.dataLocation=="number"){u.dataLocation=r.dataLocation;break}break;case"DEFAULT":case 0:u.dataLocation=0;break;case"EXTERNAL":case 1:u.dataLocation=1;break}if(r.doubleData){if(!Array.isArray(r.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");u.doubleData=[];for(var l=0;l<r.doubleData.length;++l)u.doubleData[l]=Number(r.doubleData[l])}if(r.uint64Data){if(!Array.isArray(r.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");u.uint64Data=[];for(var l=0;l<r.uint64Data.length;++l)o.Long?(u.uint64Data[l]=o.Long.fromValue(r.uint64Data[l])).unsigned=!0:typeof r.uint64Data[l]=="string"?u.uint64Data[l]=parseInt(r.uint64Data[l],10):typeof r.uint64Data[l]=="number"?u.uint64Data[l]=r.uint64Data[l]:typeof r.uint64Data[l]=="object"&&(u.uint64Data[l]=new o.LongBits(r.uint64Data[l].low>>>0,r.uint64Data[l].high>>>0).toNumber(!0))}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dims=[],l.floatData=[],l.int32Data=[],l.stringData=[],l.int64Data=[],l.doubleData=[],l.uint64Data=[],l.externalData=[]),u.defaults&&(l.dataType=0,l.segment=null,l.name="",u.bytes===String?l.rawData="":(l.rawData=[],u.bytes!==Array&&(l.rawData=o.newBuffer(l.rawData))),l.docString="",l.dataLocation=u.enums===String?"DEFAULT":0),r.dims&&r.dims.length){l.dims=[];for(var f=0;f<r.dims.length;++f)typeof r.dims[f]=="number"?l.dims[f]=u.longs===String?String(r.dims[f]):r.dims[f]:l.dims[f]=u.longs===String?o.Long.prototype.toString.call(r.dims[f]):u.longs===Number?new o.LongBits(r.dims[f].low>>>0,r.dims[f].high>>>0).toNumber():r.dims[f]}if(r.dataType!=null&&r.hasOwnProperty("dataType")&&(l.dataType=r.dataType),r.segment!=null&&r.hasOwnProperty("segment")&&(l.segment=s.onnx.TensorProto.Segment.toObject(r.segment,u)),r.floatData&&r.floatData.length){l.floatData=[];for(var f=0;f<r.floatData.length;++f)l.floatData[f]=u.json&&!isFinite(r.floatData[f])?String(r.floatData[f]):r.floatData[f]}if(r.int32Data&&r.int32Data.length){l.int32Data=[];for(var f=0;f<r.int32Data.length;++f)l.int32Data[f]=r.int32Data[f]}if(r.stringData&&r.stringData.length){l.stringData=[];for(var f=0;f<r.stringData.length;++f)l.stringData[f]=u.bytes===String?o.base64.encode(r.stringData[f],0,r.stringData[f].length):u.bytes===Array?Array.prototype.slice.call(r.stringData[f]):r.stringData[f]}if(r.int64Data&&r.int64Data.length){l.int64Data=[];for(var f=0;f<r.int64Data.length;++f)typeof r.int64Data[f]=="number"?l.int64Data[f]=u.longs===String?String(r.int64Data[f]):r.int64Data[f]:l.int64Data[f]=u.longs===String?o.Long.prototype.toString.call(r.int64Data[f]):u.longs===Number?new o.LongBits(r.int64Data[f].low>>>0,r.int64Data[f].high>>>0).toNumber():r.int64Data[f]}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.rawData!=null&&r.hasOwnProperty("rawData")&&(l.rawData=u.bytes===String?o.base64.encode(r.rawData,0,r.rawData.length):u.bytes===Array?Array.prototype.slice.call(r.rawData):r.rawData),r.doubleData&&r.doubleData.length){l.doubleData=[];for(var f=0;f<r.doubleData.length;++f)l.doubleData[f]=u.json&&!isFinite(r.doubleData[f])?String(r.doubleData[f]):r.doubleData[f]}if(r.uint64Data&&r.uint64Data.length){l.uint64Data=[];for(var f=0;f<r.uint64Data.length;++f)typeof r.uint64Data[f]=="number"?l.uint64Data[f]=u.longs===String?String(r.uint64Data[f]):r.uint64Data[f]:l.uint64Data[f]=u.longs===String?o.Long.prototype.toString.call(r.uint64Data[f]):u.longs===Number?new o.LongBits(r.uint64Data[f].low>>>0,r.uint64Data[f].high>>>0).toNumber(!0):r.uint64Data[f]}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.externalData&&r.externalData.length){l.externalData=[];for(var f=0;f<r.externalData.length;++f)l.externalData[f]=s.onnx.StringStringEntryProto.toObject(r.externalData[f],u)}return r.dataLocation!=null&&r.hasOwnProperty("dataLocation")&&(l.dataLocation=u.enums===String?s.onnx.TensorProto.DataLocation[r.dataLocation]===void 0?r.dataLocation:s.onnx.TensorProto.DataLocation[r.dataLocation]:r.dataLocation),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorProto"},h.DataType=function(){var r={},u=Object.create(r);return u[r[0]="UNDEFINED"]=0,u[r[1]="FLOAT"]=1,u[r[2]="UINT8"]=2,u[r[3]="INT8"]=3,u[r[4]="UINT16"]=4,u[r[5]="INT16"]=5,u[r[6]="INT32"]=6,u[r[7]="INT64"]=7,u[r[8]="STRING"]=8,u[r[9]="BOOL"]=9,u[r[10]="FLOAT16"]=10,u[r[11]="DOUBLE"]=11,u[r[12]="UINT32"]=12,u[r[13]="UINT64"]=13,u[r[14]="COMPLEX64"]=14,u[r[15]="COMPLEX128"]=15,u[r[16]="BFLOAT16"]=16,u[r[17]="FLOAT8E4M3FN"]=17,u[r[18]="FLOAT8E4M3FNUZ"]=18,u[r[19]="FLOAT8E5M2"]=19,u[r[20]="FLOAT8E5M2FNUZ"]=20,u}(),h.Segment=function(){function r(u){if(u)for(var l=Object.keys(u),f=0;f<l.length;++f)u[l[f]]!=null&&(this[l[f]]=u[l[f]])}return r.prototype.begin=o.Long?o.Long.fromBits(0,0,!1):0,r.prototype.end=o.Long?o.Long.fromBits(0,0,!1):0,r.create=function(u){return new r(u)},r.encode=function(u,l){return l||(l=p.create()),u.begin!=null&&Object.hasOwnProperty.call(u,"begin")&&l.uint32(8).int64(u.begin),u.end!=null&&Object.hasOwnProperty.call(u,"end")&&l.uint32(16).int64(u.end),l},r.encodeDelimited=function(u,l){return this.encode(u,l).ldelim()},r.decode=function(u,l){u instanceof i||(u=i.create(u));for(var f=l===void 0?u.len:u.pos+l,g=new s.onnx.TensorProto.Segment;u.pos<f;){var b=u.uint32();switch(b>>>3){case 1:{g.begin=u.int64();break}case 2:{g.end=u.int64();break}default:u.skipType(b&7);break}}return g},r.decodeDelimited=function(u){return u instanceof i||(u=new i(u)),this.decode(u,u.uint32())},r.verify=function(u){return typeof u!="object"||u===null?"object expected":u.begin!=null&&u.hasOwnProperty("begin")&&!o.isInteger(u.begin)&&!(u.begin&&o.isInteger(u.begin.low)&&o.isInteger(u.begin.high))?"begin: integer|Long expected":u.end!=null&&u.hasOwnProperty("end")&&!o.isInteger(u.end)&&!(u.end&&o.isInteger(u.end.low)&&o.isInteger(u.end.high))?"end: integer|Long expected":null},r.fromObject=function(u){if(u instanceof s.onnx.TensorProto.Segment)return u;var l=new s.onnx.TensorProto.Segment;return u.begin!=null&&(o.Long?(l.begin=o.Long.fromValue(u.begin)).unsigned=!1:typeof u.begin=="string"?l.begin=parseInt(u.begin,10):typeof u.begin=="number"?l.begin=u.begin:typeof u.begin=="object"&&(l.begin=new o.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber())),u.end!=null&&(o.Long?(l.end=o.Long.fromValue(u.end)).unsigned=!1:typeof u.end=="string"?l.end=parseInt(u.end,10):typeof u.end=="number"?l.end=u.end:typeof u.end=="object"&&(l.end=new o.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber())),l},r.toObject=function(u,l){l||(l={});var f={};if(l.defaults){if(o.Long){var g=new o.Long(0,0,!1);f.begin=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else f.begin=l.longs===String?"0":0;if(o.Long){var g=new o.Long(0,0,!1);f.end=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else f.end=l.longs===String?"0":0}return u.begin!=null&&u.hasOwnProperty("begin")&&(typeof u.begin=="number"?f.begin=l.longs===String?String(u.begin):u.begin:f.begin=l.longs===String?o.Long.prototype.toString.call(u.begin):l.longs===Number?new o.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber():u.begin),u.end!=null&&u.hasOwnProperty("end")&&(typeof u.end=="number"?f.end=l.longs===String?String(u.end):u.end:f.end=l.longs===String?o.Long.prototype.toString.call(u.end):l.longs===Number?new o.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber():u.end),f},r.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},r.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TensorProto.Segment"},r}(),h.DataLocation=function(){var r={},u=Object.create(r);return u[r[0]="DEFAULT"]=0,u[r[1]="EXTERNAL"]=1,u}(),h}(),c.SparseTensorProto=function(){function h(r){if(this.dims=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.values=null,h.prototype.indices=null,h.prototype.dims=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.values!=null&&Object.hasOwnProperty.call(r,"values")&&s.onnx.TensorProto.encode(r.values,u.uint32(10).fork()).ldelim(),r.indices!=null&&Object.hasOwnProperty.call(r,"indices")&&s.onnx.TensorProto.encode(r.indices,u.uint32(18).fork()).ldelim(),r.dims!=null&&r.dims.length){u.uint32(26).fork();for(var l=0;l<r.dims.length;++l)u.int64(r.dims[l]);u.ldelim()}return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.SparseTensorProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.values=s.onnx.TensorProto.decode(r,r.uint32());break}case 2:{f.indices=s.onnx.TensorProto.decode(r,r.uint32());break}case 3:{if(f.dims&&f.dims.length||(f.dims=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.dims.push(r.int64());else f.dims.push(r.int64());break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.values!=null&&r.hasOwnProperty("values")){var u=s.onnx.TensorProto.verify(r.values);if(u)return"values."+u}if(r.indices!=null&&r.hasOwnProperty("indices")){var u=s.onnx.TensorProto.verify(r.indices);if(u)return"indices."+u}if(r.dims!=null&&r.hasOwnProperty("dims")){if(!Array.isArray(r.dims))return"dims: array expected";for(var l=0;l<r.dims.length;++l)if(!o.isInteger(r.dims[l])&&!(r.dims[l]&&o.isInteger(r.dims[l].low)&&o.isInteger(r.dims[l].high)))return"dims: integer|Long[] expected"}return null},h.fromObject=function(r){if(r instanceof s.onnx.SparseTensorProto)return r;var u=new s.onnx.SparseTensorProto;if(r.values!=null){if(typeof r.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");u.values=s.onnx.TensorProto.fromObject(r.values)}if(r.indices!=null){if(typeof r.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");u.indices=s.onnx.TensorProto.fromObject(r.indices)}if(r.dims){if(!Array.isArray(r.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");u.dims=[];for(var l=0;l<r.dims.length;++l)o.Long?(u.dims[l]=o.Long.fromValue(r.dims[l])).unsigned=!1:typeof r.dims[l]=="string"?u.dims[l]=parseInt(r.dims[l],10):typeof r.dims[l]=="number"?u.dims[l]=r.dims[l]:typeof r.dims[l]=="object"&&(u.dims[l]=new o.LongBits(r.dims[l].low>>>0,r.dims[l].high>>>0).toNumber())}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dims=[]),u.defaults&&(l.values=null,l.indices=null),r.values!=null&&r.hasOwnProperty("values")&&(l.values=s.onnx.TensorProto.toObject(r.values,u)),r.indices!=null&&r.hasOwnProperty("indices")&&(l.indices=s.onnx.TensorProto.toObject(r.indices,u)),r.dims&&r.dims.length){l.dims=[];for(var f=0;f<r.dims.length;++f)typeof r.dims[f]=="number"?l.dims[f]=u.longs===String?String(r.dims[f]):r.dims[f]:l.dims[f]=u.longs===String?o.Long.prototype.toString.call(r.dims[f]):u.longs===Number?new o.LongBits(r.dims[f].low>>>0,r.dims[f].high>>>0).toNumber():r.dims[f]}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.SparseTensorProto"},h}(),c.TensorShapeProto=function(){function h(r){if(this.dim=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.dim=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.dim!=null&&r.dim.length)for(var l=0;l<r.dim.length;++l)s.onnx.TensorShapeProto.Dimension.encode(r.dim[l],u.uint32(10).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorShapeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.dim&&f.dim.length||(f.dim=[]),f.dim.push(s.onnx.TensorShapeProto.Dimension.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.dim!=null&&r.hasOwnProperty("dim")){if(!Array.isArray(r.dim))return"dim: array expected";for(var u=0;u<r.dim.length;++u){var l=s.onnx.TensorShapeProto.Dimension.verify(r.dim[u]);if(l)return"dim."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorShapeProto)return r;var u=new s.onnx.TensorShapeProto;if(r.dim){if(!Array.isArray(r.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");u.dim=[];for(var l=0;l<r.dim.length;++l){if(typeof r.dim[l]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");u.dim[l]=s.onnx.TensorShapeProto.Dimension.fromObject(r.dim[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dim=[]),r.dim&&r.dim.length){l.dim=[];for(var f=0;f<r.dim.length;++f)l.dim[f]=s.onnx.TensorShapeProto.Dimension.toObject(r.dim[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorShapeProto"},h.Dimension=function(){function r(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}r.prototype.dimValue=null,r.prototype.dimParam=null,r.prototype.denotation="";var u;return Object.defineProperty(r.prototype,"value",{get:o.oneOfGetter(u=["dimValue","dimParam"]),set:o.oneOfSetter(u)}),r.create=function(l){return new r(l)},r.encode=function(l,f){return f||(f=p.create()),l.dimValue!=null&&Object.hasOwnProperty.call(l,"dimValue")&&f.uint32(8).int64(l.dimValue),l.dimParam!=null&&Object.hasOwnProperty.call(l,"dimParam")&&f.uint32(18).string(l.dimParam),l.denotation!=null&&Object.hasOwnProperty.call(l,"denotation")&&f.uint32(26).string(l.denotation),f},r.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},r.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TensorShapeProto.Dimension;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.dimValue=l.int64();break}case 2:{b.dimParam=l.string();break}case 3:{b.denotation=l.string();break}default:l.skipType(v&7);break}}return b},r.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},r.verify=function(l){if(typeof l!="object"||l===null)return"object expected";var f={};if(l.dimValue!=null&&l.hasOwnProperty("dimValue")&&(f.value=1,!o.isInteger(l.dimValue)&&!(l.dimValue&&o.isInteger(l.dimValue.low)&&o.isInteger(l.dimValue.high))))return"dimValue: integer|Long expected";if(l.dimParam!=null&&l.hasOwnProperty("dimParam")){if(f.value===1)return"value: multiple values";if(f.value=1,!o.isString(l.dimParam))return"dimParam: string expected"}return l.denotation!=null&&l.hasOwnProperty("denotation")&&!o.isString(l.denotation)?"denotation: string expected":null},r.fromObject=function(l){if(l instanceof s.onnx.TensorShapeProto.Dimension)return l;var f=new s.onnx.TensorShapeProto.Dimension;return l.dimValue!=null&&(o.Long?(f.dimValue=o.Long.fromValue(l.dimValue)).unsigned=!1:typeof l.dimValue=="string"?f.dimValue=parseInt(l.dimValue,10):typeof l.dimValue=="number"?f.dimValue=l.dimValue:typeof l.dimValue=="object"&&(f.dimValue=new o.LongBits(l.dimValue.low>>>0,l.dimValue.high>>>0).toNumber())),l.dimParam!=null&&(f.dimParam=String(l.dimParam)),l.denotation!=null&&(f.denotation=String(l.denotation)),f},r.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.denotation=""),l.dimValue!=null&&l.hasOwnProperty("dimValue")&&(typeof l.dimValue=="number"?g.dimValue=f.longs===String?String(l.dimValue):l.dimValue:g.dimValue=f.longs===String?o.Long.prototype.toString.call(l.dimValue):f.longs===Number?new o.LongBits(l.dimValue.low>>>0,l.dimValue.high>>>0).toNumber():l.dimValue,f.oneofs&&(g.value="dimValue")),l.dimParam!=null&&l.hasOwnProperty("dimParam")&&(g.dimParam=l.dimParam,f.oneofs&&(g.value="dimParam")),l.denotation!=null&&l.hasOwnProperty("denotation")&&(g.denotation=l.denotation),g},r.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},r.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TensorShapeProto.Dimension"},r}(),h}(),c.TypeProto=function(){function h(u){if(u)for(var l=Object.keys(u),f=0;f<l.length;++f)u[l[f]]!=null&&(this[l[f]]=u[l[f]])}h.prototype.tensorType=null,h.prototype.sequenceType=null,h.prototype.mapType=null,h.prototype.optionalType=null,h.prototype.sparseTensorType=null,h.prototype.denotation="";var r;return Object.defineProperty(h.prototype,"value",{get:o.oneOfGetter(r=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:o.oneOfSetter(r)}),h.create=function(u){return new h(u)},h.encode=function(u,l){return l||(l=p.create()),u.tensorType!=null&&Object.hasOwnProperty.call(u,"tensorType")&&s.onnx.TypeProto.Tensor.encode(u.tensorType,l.uint32(10).fork()).ldelim(),u.sequenceType!=null&&Object.hasOwnProperty.call(u,"sequenceType")&&s.onnx.TypeProto.Sequence.encode(u.sequenceType,l.uint32(34).fork()).ldelim(),u.mapType!=null&&Object.hasOwnProperty.call(u,"mapType")&&s.onnx.TypeProto.Map.encode(u.mapType,l.uint32(42).fork()).ldelim(),u.denotation!=null&&Object.hasOwnProperty.call(u,"denotation")&&l.uint32(50).string(u.denotation),u.sparseTensorType!=null&&Object.hasOwnProperty.call(u,"sparseTensorType")&&s.onnx.TypeProto.SparseTensor.encode(u.sparseTensorType,l.uint32(66).fork()).ldelim(),u.optionalType!=null&&Object.hasOwnProperty.call(u,"optionalType")&&s.onnx.TypeProto.Optional.encode(u.optionalType,l.uint32(74).fork()).ldelim(),l},h.encodeDelimited=function(u,l){return this.encode(u,l).ldelim()},h.decode=function(u,l){u instanceof i||(u=i.create(u));for(var f=l===void 0?u.len:u.pos+l,g=new s.onnx.TypeProto;u.pos<f;){var b=u.uint32();switch(b>>>3){case 1:{g.tensorType=s.onnx.TypeProto.Tensor.decode(u,u.uint32());break}case 4:{g.sequenceType=s.onnx.TypeProto.Sequence.decode(u,u.uint32());break}case 5:{g.mapType=s.onnx.TypeProto.Map.decode(u,u.uint32());break}case 9:{g.optionalType=s.onnx.TypeProto.Optional.decode(u,u.uint32());break}case 8:{g.sparseTensorType=s.onnx.TypeProto.SparseTensor.decode(u,u.uint32());break}case 6:{g.denotation=u.string();break}default:u.skipType(b&7);break}}return g},h.decodeDelimited=function(u){return u instanceof i||(u=new i(u)),this.decode(u,u.uint32())},h.verify=function(u){if(typeof u!="object"||u===null)return"object expected";var l={};if(u.tensorType!=null&&u.hasOwnProperty("tensorType")){l.value=1;{var f=s.onnx.TypeProto.Tensor.verify(u.tensorType);if(f)return"tensorType."+f}}if(u.sequenceType!=null&&u.hasOwnProperty("sequenceType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Sequence.verify(u.sequenceType);if(f)return"sequenceType."+f}}if(u.mapType!=null&&u.hasOwnProperty("mapType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Map.verify(u.mapType);if(f)return"mapType."+f}}if(u.optionalType!=null&&u.hasOwnProperty("optionalType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Optional.verify(u.optionalType);if(f)return"optionalType."+f}}if(u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.SparseTensor.verify(u.sparseTensorType);if(f)return"sparseTensorType."+f}}return u.denotation!=null&&u.hasOwnProperty("denotation")&&!o.isString(u.denotation)?"denotation: string expected":null},h.fromObject=function(u){if(u instanceof s.onnx.TypeProto)return u;var l=new s.onnx.TypeProto;if(u.tensorType!=null){if(typeof u.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");l.tensorType=s.onnx.TypeProto.Tensor.fromObject(u.tensorType)}if(u.sequenceType!=null){if(typeof u.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");l.sequenceType=s.onnx.TypeProto.Sequence.fromObject(u.sequenceType)}if(u.mapType!=null){if(typeof u.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");l.mapType=s.onnx.TypeProto.Map.fromObject(u.mapType)}if(u.optionalType!=null){if(typeof u.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");l.optionalType=s.onnx.TypeProto.Optional.fromObject(u.optionalType)}if(u.sparseTensorType!=null){if(typeof u.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");l.sparseTensorType=s.onnx.TypeProto.SparseTensor.fromObject(u.sparseTensorType)}return u.denotation!=null&&(l.denotation=String(u.denotation)),l},h.toObject=function(u,l){l||(l={});var f={};return l.defaults&&(f.denotation=""),u.tensorType!=null&&u.hasOwnProperty("tensorType")&&(f.tensorType=s.onnx.TypeProto.Tensor.toObject(u.tensorType,l),l.oneofs&&(f.value="tensorType")),u.sequenceType!=null&&u.hasOwnProperty("sequenceType")&&(f.sequenceType=s.onnx.TypeProto.Sequence.toObject(u.sequenceType,l),l.oneofs&&(f.value="sequenceType")),u.mapType!=null&&u.hasOwnProperty("mapType")&&(f.mapType=s.onnx.TypeProto.Map.toObject(u.mapType,l),l.oneofs&&(f.value="mapType")),u.denotation!=null&&u.hasOwnProperty("denotation")&&(f.denotation=u.denotation),u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")&&(f.sparseTensorType=s.onnx.TypeProto.SparseTensor.toObject(u.sparseTensorType,l),l.oneofs&&(f.value="sparseTensorType")),u.optionalType!=null&&u.hasOwnProperty("optionalType")&&(f.optionalType=s.onnx.TypeProto.Optional.toObject(u.optionalType,l),l.oneofs&&(f.value="optionalType")),f},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto"},h.Tensor=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&f.uint32(8).int32(l.elemType),l.shape!=null&&Object.hasOwnProperty.call(l,"shape")&&s.onnx.TensorShapeProto.encode(l.shape,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Tensor;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=l.int32();break}case 2:{b.shape=s.onnx.TensorShapeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")&&!o.isInteger(l.elemType))return"elemType: integer expected";if(l.shape!=null&&l.hasOwnProperty("shape")){var f=s.onnx.TensorShapeProto.verify(l.shape);if(f)return"shape."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Tensor)return l;var f=new s.onnx.TypeProto.Tensor;if(l.elemType!=null&&(f.elemType=l.elemType|0),l.shape!=null){if(typeof l.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");f.shape=s.onnx.TensorShapeProto.fromObject(l.shape)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=l.elemType),l.shape!=null&&l.hasOwnProperty("shape")&&(g.shape=s.onnx.TensorShapeProto.toObject(l.shape,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Tensor"},u}(),h.Sequence=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&s.onnx.TypeProto.encode(l.elemType,f.uint32(10).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Sequence;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")){var f=s.onnx.TypeProto.verify(l.elemType);if(f)return"elemType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Sequence)return l;var f=new s.onnx.TypeProto.Sequence;if(l.elemType!=null){if(typeof l.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");f.elemType=s.onnx.TypeProto.fromObject(l.elemType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=s.onnx.TypeProto.toObject(l.elemType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Sequence"},u}(),h.Map=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.keyType=0,u.prototype.valueType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.keyType!=null&&Object.hasOwnProperty.call(l,"keyType")&&f.uint32(8).int32(l.keyType),l.valueType!=null&&Object.hasOwnProperty.call(l,"valueType")&&s.onnx.TypeProto.encode(l.valueType,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Map;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.keyType=l.int32();break}case 2:{b.valueType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.keyType!=null&&l.hasOwnProperty("keyType")&&!o.isInteger(l.keyType))return"keyType: integer expected";if(l.valueType!=null&&l.hasOwnProperty("valueType")){var f=s.onnx.TypeProto.verify(l.valueType);if(f)return"valueType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Map)return l;var f=new s.onnx.TypeProto.Map;if(l.keyType!=null&&(f.keyType=l.keyType|0),l.valueType!=null){if(typeof l.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");f.valueType=s.onnx.TypeProto.fromObject(l.valueType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.keyType=0,g.valueType=null),l.keyType!=null&&l.hasOwnProperty("keyType")&&(g.keyType=l.keyType),l.valueType!=null&&l.hasOwnProperty("valueType")&&(g.valueType=s.onnx.TypeProto.toObject(l.valueType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Map"},u}(),h.Optional=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&s.onnx.TypeProto.encode(l.elemType,f.uint32(10).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Optional;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")){var f=s.onnx.TypeProto.verify(l.elemType);if(f)return"elemType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Optional)return l;var f=new s.onnx.TypeProto.Optional;if(l.elemType!=null){if(typeof l.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");f.elemType=s.onnx.TypeProto.fromObject(l.elemType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=s.onnx.TypeProto.toObject(l.elemType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Optional"},u}(),h.SparseTensor=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&f.uint32(8).int32(l.elemType),l.shape!=null&&Object.hasOwnProperty.call(l,"shape")&&s.onnx.TensorShapeProto.encode(l.shape,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof i||(l=i.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.SparseTensor;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=l.int32();break}case 2:{b.shape=s.onnx.TensorShapeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof i||(l=new i(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")&&!o.isInteger(l.elemType))return"elemType: integer expected";if(l.shape!=null&&l.hasOwnProperty("shape")){var f=s.onnx.TensorShapeProto.verify(l.shape);if(f)return"shape."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.SparseTensor)return l;var f=new s.onnx.TypeProto.SparseTensor;if(l.elemType!=null&&(f.elemType=l.elemType|0),l.shape!=null){if(typeof l.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");f.shape=s.onnx.TensorShapeProto.fromObject(l.shape)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=l.elemType),l.shape!=null&&l.hasOwnProperty("shape")&&(g.shape=s.onnx.TensorShapeProto.toObject(l.shape,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.SparseTensor"},u}(),h}(),c.OperatorSetIdProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.domain="",h.prototype.version=o.Long?o.Long.fromBits(0,0,!1):0,h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(10).string(r.domain),r.version!=null&&Object.hasOwnProperty.call(r,"version")&&u.uint32(16).int64(r.version),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.OperatorSetIdProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.domain=r.string();break}case 2:{f.version=r.int64();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){return typeof r!="object"||r===null?"object expected":r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain)?"domain: string expected":r.version!=null&&r.hasOwnProperty("version")&&!o.isInteger(r.version)&&!(r.version&&o.isInteger(r.version.low)&&o.isInteger(r.version.high))?"version: integer|Long expected":null},h.fromObject=function(r){if(r instanceof s.onnx.OperatorSetIdProto)return r;var u=new s.onnx.OperatorSetIdProto;return r.domain!=null&&(u.domain=String(r.domain)),r.version!=null&&(o.Long?(u.version=o.Long.fromValue(r.version)).unsigned=!1:typeof r.version=="string"?u.version=parseInt(r.version,10):typeof r.version=="number"?u.version=r.version:typeof r.version=="object"&&(u.version=new o.LongBits(r.version.low>>>0,r.version.high>>>0).toNumber())),u},h.toObject=function(r,u){u||(u={});var l={};if(u.defaults)if(l.domain="",o.Long){var f=new o.Long(0,0,!1);l.version=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.version=u.longs===String?"0":0;return r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.version!=null&&r.hasOwnProperty("version")&&(typeof r.version=="number"?l.version=u.longs===String?String(r.version):r.version:l.version=u.longs===String?o.Long.prototype.toString.call(r.version):u.longs===Number?new o.LongBits(r.version.low>>>0,r.version.high>>>0).toNumber():r.version),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.OperatorSetIdProto"},h}(),c.OperatorStatus=function(){var h={},r=Object.create(h);return r[h[0]="EXPERIMENTAL"]=0,r[h[1]="STABLE"]=1,r}(),c.FunctionProto=function(){function h(r){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.attribute=o.emptyArray,h.prototype.attributeProto=o.emptyArray,h.prototype.node=o.emptyArray,h.prototype.docString="",h.prototype.opsetImport=o.emptyArray,h.prototype.domain="",h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)u.uint32(34).string(r.input[l]);if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)u.uint32(42).string(r.output[l]);if(r.attribute!=null&&r.attribute.length)for(var l=0;l<r.attribute.length;++l)u.uint32(50).string(r.attribute[l]);if(r.node!=null&&r.node.length)for(var l=0;l<r.node.length;++l)s.onnx.NodeProto.encode(r.node[l],u.uint32(58).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(66).string(r.docString),r.opsetImport!=null&&r.opsetImport.length)for(var l=0;l<r.opsetImport.length;++l)s.onnx.OperatorSetIdProto.encode(r.opsetImport[l],u.uint32(74).fork()).ldelim();if(r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(82).string(r.domain),r.attributeProto!=null&&r.attributeProto.length)for(var l=0;l<r.attributeProto.length;++l)s.onnx.AttributeProto.encode(r.attributeProto[l],u.uint32(90).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof i||(r=i.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.FunctionProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 4:{f.input&&f.input.length||(f.input=[]),f.input.push(r.string());break}case 5:{f.output&&f.output.length||(f.output=[]),f.output.push(r.string());break}case 6:{f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(r.string());break}case 11:{f.attributeProto&&f.attributeProto.length||(f.attributeProto=[]),f.attributeProto.push(s.onnx.AttributeProto.decode(r,r.uint32()));break}case 7:{f.node&&f.node.length||(f.node=[]),f.node.push(s.onnx.NodeProto.decode(r,r.uint32()));break}case 8:{f.docString=r.string();break}case 9:{f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(s.onnx.OperatorSetIdProto.decode(r,r.uint32()));break}case 10:{f.domain=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof i||(r=new i(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u)if(!o.isString(r.input[u]))return"input: string[] expected"}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u)if(!o.isString(r.output[u]))return"output: string[] expected"}if(r.attribute!=null&&r.hasOwnProperty("attribute")){if(!Array.isArray(r.attribute))return"attribute: array expected";for(var u=0;u<r.attribute.length;++u)if(!o.isString(r.attribute[u]))return"attribute: string[] expected"}if(r.attributeProto!=null&&r.hasOwnProperty("attributeProto")){if(!Array.isArray(r.attributeProto))return"attributeProto: array expected";for(var u=0;u<r.attributeProto.length;++u){var l=s.onnx.AttributeProto.verify(r.attributeProto[u]);if(l)return"attributeProto."+l}}if(r.node!=null&&r.hasOwnProperty("node")){if(!Array.isArray(r.node))return"node: array expected";for(var u=0;u<r.node.length;++u){var l=s.onnx.NodeProto.verify(r.node[u]);if(l)return"node."+l}}if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.opsetImport!=null&&r.hasOwnProperty("opsetImport")){if(!Array.isArray(r.opsetImport))return"opsetImport: array expected";for(var u=0;u<r.opsetImport.length;++u){var l=s.onnx.OperatorSetIdProto.verify(r.opsetImport[u]);if(l)return"opsetImport."+l}}return r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain)?"domain: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.FunctionProto)return r;var u=new s.onnx.FunctionProto;if(r.name!=null&&(u.name=String(r.name)),r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.FunctionProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l)u.input[l]=String(r.input[l])}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.FunctionProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l)u.output[l]=String(r.output[l])}if(r.attribute){if(!Array.isArray(r.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");u.attribute=[];for(var l=0;l<r.attribute.length;++l)u.attribute[l]=String(r.attribute[l])}if(r.attributeProto){if(!Array.isArray(r.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");u.attributeProto=[];for(var l=0;l<r.attributeProto.length;++l){if(typeof r.attributeProto[l]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");u.attributeProto[l]=s.onnx.AttributeProto.fromObject(r.attributeProto[l])}}if(r.node){if(!Array.isArray(r.node))throw TypeError(".onnx.FunctionProto.node: array expected");u.node=[];for(var l=0;l<r.node.length;++l){if(typeof r.node[l]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");u.node[l]=s.onnx.NodeProto.fromObject(r.node[l])}}if(r.docString!=null&&(u.docString=String(r.docString)),r.opsetImport){if(!Array.isArray(r.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");u.opsetImport=[];for(var l=0;l<r.opsetImport.length;++l){if(typeof r.opsetImport[l]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");u.opsetImport[l]=s.onnx.OperatorSetIdProto.fromObject(r.opsetImport[l])}}return r.domain!=null&&(u.domain=String(r.domain)),u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.input=[],l.output=[],l.attribute=[],l.node=[],l.opsetImport=[],l.attributeProto=[]),u.defaults&&(l.name="",l.docString="",l.domain=""),r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=r.input[f]}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=r.output[f]}if(r.attribute&&r.attribute.length){l.attribute=[];for(var f=0;f<r.attribute.length;++f)l.attribute[f]=r.attribute[f]}if(r.node&&r.node.length){l.node=[];for(var f=0;f<r.node.length;++f)l.node[f]=s.onnx.NodeProto.toObject(r.node[f],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.opsetImport&&r.opsetImport.length){l.opsetImport=[];for(var f=0;f<r.opsetImport.length;++f)l.opsetImport[f]=s.onnx.OperatorSetIdProto.toObject(r.opsetImport[f],u)}if(r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.attributeProto&&r.attributeProto.length){l.attributeProto=[];for(var f=0;f<r.attributeProto.length;++f)l.attributeProto[f]=s.onnx.AttributeProto.toObject(r.attributeProto[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.FunctionProto"},h}(),c}(),n.exports=s});function ur(e,n){if(!e)throw new Error(typeof n=="string"?n:n())}function kr(e){return new TextDecoder().decode(e)}var ot,Me,ai,kt,Sn,At,Rt,B,$r,Ue,Ve,ze,Y=O(()=>{wn(),qo(),ot=rr(sr()),We(),Me=class{static arraysEqual(e,n){if(e.length!==n.length)return!1;for(let a=0;a<e.length;a++)if(e[a]!==n[a])return!1;return!0}},ai=class{static preprocessInputShapes(e,n){let a=e.length===1?[1,e[0]]:e,i=n.length===1?[n[0],1]:n;return[a,i]}static postprocessOutputShape(e,n,a){n===1&&e.splice(e.length-2,1),a===1&&e.pop()}static calcMatMulShape(e,n){return e[1]!==n[0]?void 0:[e[0],n[1]]}},kt=class ve{static calcShape(n,a,i=!1){let p=n.length,o=a.length;if(p===0)return a;if(o===0)return n;let s=Math.max(n.length,a.length),c=new Array(s);if(i){if(p<2||o<2)return;let h=ai.calcMatMulShape([n[p-2],n[p-1]],[a[o-2],a[o-1]]);if(h===void 0)return;[c[s-2],c[s-1]]=h}for(let h=i?3:1;h<=s;h++){let r=p-h<0?1:n[p-h],u=o-h<0?1:a[o-h];if(r!==u&&r>1&&u>1)return;c[s-h]=Math.max(r,u)}return c}static index(n,a){let i=new Array(a.length);return ve.fillIndex(n,a,i),i}static fillIndex(n,a,i){let p=n.length-a.length;for(let o=0;o<a.length;o++)i[o]=n[p+o]%a[o]}static calc(n,a,i,p,o){let s=ve.calcShape(n.dims,a.dims);if(s){if(p&&!B.areEqual(s,n.dims))return;let c=B.size(s),h=p?n:new bt(s,o||n.type);if(s.length===0)h.set([],i(n.get([]),a.get([])));else{let r=new Array(s.length),u=new Array(n.dims.length),l=new Array(a.dims.length),f=0,g=0,b=!1,v=!1;n.dims.length===0&&(f=n.get([]),b=!0),a.dims.length===0&&(g=a.get([]),v=!0);let S;for(let P=0;P<c;P++){S=P;for(let _=s.length-1;_>=0;_--)r[_]=S%s[_],S=Math.floor(S/s[_]);b||(ve.fillIndex(r,n.dims,u),f=n.get(u)),v||(ve.fillIndex(r,a.dims,l),g=a.get(l)),h.set(r,i(f,g))}}return h}}static isValidBroadcast(n,a){let i=n.length,p=a.length;if(i>p)return!1;for(let o=1;o<=i;o++)if(n[i-o]!==1&&n[i-o]!==a[p-o])return!1;return!0}static getBroadcastDims(n,a){let i=n.length,p=[];for(let o=0;o<i;o++){let s=i-1-o,c=n[s]||1;(a[a.length-1-o]||1)>1&&c===1&&p.unshift(s)}return p}},Sn=class{static getShapeOfGemmResult(e,n,a,i,p){if(e.length!==2||a.length!==2)throw new Error("shape need to be of size 2");let o,s,c;n?(o=e[1],s=e[0]):(o=e[0],s=e[1]);let h=-1;if(i?(c=a[0],h=1):(c=a[1],h=0),a[h]!==s)throw new Error("dimension mismatch");if(o<=0||c<=0||s<=0)throw new Error("invalid shape specified");if(p&&!kt.isValidBroadcast(p,[o,c]))throw new Error("gemm: invalid bias shape for broadcast");return[o,c,s]}},At=class rn{static tensorDataTypeFromProto(n){switch(n){case ot.onnx.TensorProto.DataType.INT8:return"int8";case ot.onnx.TensorProto.DataType.UINT8:return"uint8";case ot.onnx.TensorProto.DataType.BOOL:return"bool";case ot.onnx.TensorProto.DataType.INT16:return"int16";case ot.onnx.TensorProto.DataType.UINT16:return"uint16";case ot.onnx.TensorProto.DataType.INT32:return"int32";case ot.onnx.TensorProto.DataType.UINT32:return"uint32";case ot.onnx.TensorProto.DataType.FLOAT:return"float32";case ot.onnx.TensorProto.DataType.DOUBLE:return"float64";case ot.onnx.TensorProto.DataType.STRING:return"string";case ot.onnx.TensorProto.DataType.INT64:return"int32";case ot.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${ot.onnx.TensorProto.DataType[n]}`)}}static tensorDataTypeStringToEnum(n){switch(n){case"int8":return ot.onnx.TensorProto.DataType.INT8;case"uint8":return ot.onnx.TensorProto.DataType.UINT8;case"bool":return ot.onnx.TensorProto.DataType.BOOL;case"int16":return ot.onnx.TensorProto.DataType.INT16;case"uint16":return ot.onnx.TensorProto.DataType.UINT16;case"int32":return ot.onnx.TensorProto.DataType.INT32;case"uint32":return ot.onnx.TensorProto.DataType.UINT32;case"float32":return ot.onnx.TensorProto.DataType.FLOAT;case"float64":return ot.onnx.TensorProto.DataType.DOUBLE;case"string":return ot.onnx.TensorProto.DataType.STRING;case"int64":return ot.onnx.TensorProto.DataType.INT64;case"uint64":return ot.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${n}`)}}static tensorDimsFromProto(n){return n.map(a=>xe.isLong(a)?a.toNumber():a)}static tensorValueTypeFromProto(n){return{tensorType:rn.tensorDataTypeFromProto(n.elemType),shape:{dims:rn.tensorDimsFromProto(n.shape.dim.map(a=>a.dimValue))}}}static tensorDimsFromORTFormat(n){let a=[];for(let i=0;i<n.dimsLength();i++)a.push(Rt.longToNumber(n.dims(i)));return a}static tensorAttributesFromORTFormat(n){let a=[];for(let i=0;i<n.attributesLength();i++)a.push(n.attributes(i));return a}},Rt=class{static longToNumber(e,n){return xe.isLong(e)?e.toNumber():e instanceof w.Long?xe.fromValue({low:e.low,high:e.high,unsigned:n??!1}).toNumber():e}static isLong(e){return xe.isLong(e)||e instanceof w.Long}},B=class ee{static size(n){return ee.getSizeFromDimensionRange(n,0,n.length)}static sizeFromDimension(n,a){if(a<0||a>n.length)throw new Error(`invalid dimension of ${a} for sizeFromDimension as Tensor has ${n.length} dimensions.`);return ee.getSizeFromDimensionRange(n,a,n.length)}static sizeToDimension(n,a){if(a<0||a>n.length)throw new Error(`invalid dimension of ${a} for sizeToDimension as Tensor has ${n.length} dimensions.`);return ee.getSizeFromDimensionRange(n,0,a)}static getSizeFromDimensionRange(n,a,i){let p=1;for(let o=a;o<i;o++){if(n[o]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");p*=n[o]}return p}static computeStrides(n){let a=n.length;if(a===0)return[];if(a===1)return[1];let i=new Array(a);i[a-1]=1,i[a-2]=n[a-1];for(let p=a-3;p>=0;--p)i[p]=i[p+1]*n[p+1];return i}static transpose(n){return n.slice().reverse()}static indicesToOffset(n,a,i){i===void 0&&(i=n.length);let p=0;for(let o=0;o<i;++o)p+=a[o]*n[o];return p}static offsetToIndices(n,a){let i=a.length;if(i===0)return[];if(i===1)return[n*a[0]];let p=new Array(a.length);for(let o=0;o<p.length-1;++o)p[o]=Math.floor(n/a[o]),n-=p[o]*a[o];return p[p.length-1]=n,p}static normalizeAxis(n,a){if(n<-a&&n>=a)throw new Error("unsupported axis for this operation.");return n<0?n+a:n}static normalizeAxes(n,a){return n.map(i=>this.normalizeAxis(i,a))}static incrementIndex(n,a,i){if(a.length===0||n.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(i===void 0)i=a.length;else if(i<=0||i>a.length)throw new Error("Incorrect axis to increment on");for(let p=i-1;p>=0&&(n[p]++,!(n[p]<a[p]));--p)n[p]=0}static calculateReshapedDims(n,a){if(a.length===0){if(n.length===0||ee.size(n)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}let i=a.length,p=new Array(i),o=-1,s=1;for(let h=0;h<i;h++){if(a[h]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(a[h]===-1){if(o!==-1)throw new Error("at most one dimension in shape hints can be -1");o=h}else{if(a[h]===0){if(h>=n.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");p[h]=n[h]}else p[h]=a[h];s*=p[h]}}let c=ee.size(n);if(o!==-1){if(c%s!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${n}] Output shape: [${a}]`);p[o]=c/s}else if(s!==c)throw new Error("reshapedDims and originalDims don't have matching sizes");return p}static sortBasedOnPerm(n,a){return a?a.map(i=>n[i]):n.slice().reverse()}static padShape(n,a){let i=n.length;return n.map((p,o)=>p+a[o]+a[o+i])}static areEqual(n,a){return n.length!==a.length?!1:n.every((i,p)=>i===a[p])}static validateDimsAndCalcSize(n){if(n.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let a=1;for(let i of n){if(!Number.isInteger(i))throw new TypeError(`Invalid shape: ${i} is not an integer`);if(i<0||i>2147483647)throw new TypeError(`Invalid shape: length ${i} is not allowed`);a*=i}return a}static flattenShape(n,a){a<0&&(a+=n.length);let i=n.reduce((o,s)=>o*s,1),p=n.slice(a).reduce((o,s)=>o*s,1);return[i/p,p]}static squeezeShape(n,a){let i=new Array;a=ee.normalizeAxes(a,n.length);for(let p=0;p<n.length;p++){let o=a.indexOf(p)>=0;if(o&&n[p]!==1)throw new Error("squeeze an axis of size different than 1");(a.length===0&&n[p]>1||a.length>0&&!o)&&i.push(n[p])}return i}static unsqueezeShape(n,a){let i=new Array(n.length+a.length);i.fill(0);for(let o=0;o<a.length;o++){let s=ee.normalizeAxis(a[o],i.length);if(s>=i.length)throw new Error("'axes' has an out of range axis");if(i[s]!==0)throw new Error("'axes' has a duplicate axis");i[s]=1}let p=0;for(let o=0;o<i.length;o++)i[o]===0&&(i[o]=n[p++]);if(p!==n.length)throw new Error("the unsqueezed dimension could not be established");return i}},$r=class Ea{static splitShape(n,a,i,p){if(i.length===0){if(!p)throw new Error("need to know number of outputs when the 'split' attribute is not specified");Ea.determineSplit(n[a],p,i)}let o=[],s=[0];for(let c=0;c<i.length;++c){c!==0&&s.push(s[c-1]+i[c-1]);let h=n.slice();h[a]=i[c],o.push(h)}return[o,s]}static determineSplit(n,a,i){if(n%a!==0)throw new Error("cannot split tensor to equal sized parts");for(let p=0;p<a;++p)i.push(n/a)}},Ue=class Oe{static adjustPoolAttributes(n,a,i,p,o,s){if(!n&&i.length!==a.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(n)for(let c=0;c<a.length-2;c++)c>=i.length?i.push(a[c+2]):i[c]=a[c+2];for(let c=0;c<i.length;c++)if(c<p.length){if(p[c]<0)throw new Error("strides should be greater than or equal to 1")}else p.push(1);for(let c=0;c<i.length;c++)if(c<o.length){if(o[c]<0)throw new Error("dilations should be greater than or equal to 1")}else o.push(1);for(let c=0;c<i.length*2;c++)if(c<s.length){if(s[c]<0)throw new Error("pad should be greater than or equal to 1")}else s.push(0);for(let c=0;c<i.length;c++){if(i[c]<=0)throw new Error("kernel shapes need to be greater than 0");if(s[c]>=i[c]||s[c+i.length]>=i[c])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(n,a,i,p,o,s){if(s){if(o.length!==2*(n.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(a.length!==n.length-2)throw new Error("length of strides should be the length of data dimensions");if(p.length!==n.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let c=0;c<n.length-2;c++)Oe.adjustPadAndReturnShape(n[c+2],a[c],i[c],p[c],o,c,c+n.length-2,s)}}static computePoolOutputShape(n,a,i,p,o,s,c){if(a.length<=0)throw new Error("input shape must be of size greater than 0");let h=[a[0],a[1]];return Oe.computeShapeHelper(n,a,h,i,p,o,s,c),h}static computeConvOutputShape(n,a,i,p,o,s,c){if(n.length<=0||a.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let h=[n[0],a[0]];return Oe.computeShapeHelper(!1,n,h,i,p,o,s,c),h}static computeShapeHelper(n,a,i,p,o,s,c,h){if(n)for(let r=0;r<a.length-2;r++)i.push(1);else for(let r=0;r<a.length-2;r++)i.push(Oe.adjustPadAndReturnShape(a[r+2],p[r],o[r],s[r],c,r,r+a.length-2,h))}static adjustPadAndReturnShape(n,a,i,p,o,s,c,h){let r=i*(p-1)+1;if(h&&h!=="NOTSET")switch(h){case"VALID":return o[s]=0,o[c]=0,Math.floor((n-r)/a+1);case"SAME_LOWER":case"SAME_UPPER":if(i!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let u=((n+a-1)/a-1)*a+p-n;return o[s]=Math.floor(h==="SAME_LOWER"?(u+1)/2:u/2),o[c]=u-o[s],Math.floor((n+u-p)/a+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((n+o[s]+o[c]-r)/a+1)}},Ve=-34028234663852886e22,ze=34028234663852886e22});function hh(e){switch(e){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${e}`)}}function Wu(e){switch(e){case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.BOOL:return 1;case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT16:return 2;case H.onnx.TensorProto.DataType.FLOAT:case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.UINT32:return 4;case H.onnx.TensorProto.DataType.INT64:case H.onnx.TensorProto.DataType.DOUBLE:case H.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${H.onnx.TensorProto.DataType[e]}`)}}function mh(e,n){return new(ju(n))(e)}function ju(e){switch(e){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function ui(e,n){if(n===H.onnx.TensorProto.DataType.INT64||n===si.TensorDataType.INT64){if(e.greaterThanOrEqual(2147483648)||e.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(n===H.onnx.TensorProto.DataType.UINT32||n===si.TensorDataType.UINT32||n===H.onnx.TensorProto.DataType.UINT64||n===si.TensorDataType.UINT64){if(e.greaterThanOrEqual(4294967296)||e.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${H.onnx.TensorProto.DataType[n]}`);return e.toNumber()}function Hu(e,n,a){switch(n){case H.onnx.TensorProto.DataType.BOOL:case H.onnx.TensorProto.DataType.UINT8:return e.getUint8(a);case H.onnx.TensorProto.DataType.INT8:return e.getInt8(a);case H.onnx.TensorProto.DataType.UINT16:return e.getUint16(a,!0);case H.onnx.TensorProto.DataType.INT16:return e.getInt16(a,!0);case H.onnx.TensorProto.DataType.FLOAT:return e.getFloat32(a,!0);case H.onnx.TensorProto.DataType.INT32:return e.getInt32(a,!0);case H.onnx.TensorProto.DataType.UINT32:return e.getUint32(a,!0);case H.onnx.TensorProto.DataType.INT64:return ui(xe.fromBits(e.getUint32(a,!0),e.getUint32(a+4,!0),!1),n);case H.onnx.TensorProto.DataType.DOUBLE:return e.getFloat64(a,!0);case H.onnx.TensorProto.DataType.UINT64:return ui(xe.fromBits(e.getUint32(a,!0),e.getUint32(a+4,!0),!0),n);default:throw new Error(`cannot read from DataView for type ${H.onnx.TensorProto.DataType[n]}`)}}var qu,H,si,bt,We=O(()=>{qu=rr(Fs()),qo(),Pr(),H=rr(sr()),Y(),si=F.experimental.fbs,bt=class wr{constructor(n,a,i,p,o,s=qu.Guid.create()){this.dims=n,this.type=a,this.dataProvider=i,this.asyncDataProvider=p,this.cache=o,this.dataId=s,this.size=B.validateDimsAndCalcSize(n);let c=this.size,h=i===void 0&&p===void 0&&o===void 0;if(o!==void 0&&o.length!==c)throw new RangeError("Input dims doesn't match data length.");if(a==="string"){if(o!==void 0&&(!Array.isArray(o)||!o.every(r=>typeof r=="string")))throw new TypeError("cache should be a string array");h&&(this.cache=new Array(c))}else{if(o!==void 0){let r=ju(a);if(!(o instanceof r))throw new TypeError(`cache should be type ${r.name}`)}if(h){let r=new ArrayBuffer(c*hh(a));this.cache=mh(r,a)}}}get data(){if(this.cache===void 0){let n=this.dataProvider(this.dataId);if(n.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=n}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(n){return this.data[B.indicesToOffset(n,this.strides)]}set(n,a){this.data[B.indicesToOffset(n,this.strides)]=a}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=B.computeStrides(this.dims)),this._strides}static fromProto(n){if(!n)throw new Error("cannot construct Value from an empty tensor");let a=At.tensorDataTypeFromProto(n.dataType),i=At.tensorDimsFromProto(n.dims),p=new wr(i,a);if(a==="string")n.stringData.forEach((o,s)=>{p.data[s]=kr(o)});else if(n.rawData&&typeof n.rawData.byteLength=="number"&&n.rawData.byteLength>0){let o=p.data,s=new DataView(n.rawData.buffer,n.rawData.byteOffset,n.rawData.byteLength),c=Wu(n.dataType),h=n.rawData.byteLength/c;if(n.rawData.byteLength%c!==0)throw new Error("invalid buffer length");if(o.length!==h)throw new Error("buffer length mismatch");for(let r=0;r<h;r++){let u=Hu(s,n.dataType,r*c);o[r]=u}}else{let o;switch(n.dataType){case H.onnx.TensorProto.DataType.FLOAT:o=n.floatData;break;case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.INT16:case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.BOOL:o=n.int32Data;break;case H.onnx.TensorProto.DataType.INT64:o=n.int64Data;break;case H.onnx.TensorProto.DataType.DOUBLE:o=n.doubleData;break;case H.onnx.TensorProto.DataType.UINT32:case H.onnx.TensorProto.DataType.UINT64:o=n.uint64Data;break;default:throw new Error("unspecific error")}if(o==null)throw new Error("failed to populate data from a tensorproto value");let s=p.data;if(s.length!==o.length)throw new Error("array length mismatch");for(let c=0;c<o.length;c++){let h=o[c];xe.isLong(h)?s[c]=ui(h,n.dataType):s[c]=h}}return p}static fromData(n,a,i){return new wr(a,i,void 0,void 0,n)}static fromOrtTensor(n){if(!n)throw new Error("cannot construct Value from an empty tensor");let a=At.tensorDimsFromORTFormat(n),i=At.tensorDataTypeFromProto(n.dataType()),p=new wr(a,i);if(i==="string")for(let o=0;o<n.stringDataLength();o++)p.data[o]=n.stringData(o);else if(n.rawDataArray()&&typeof n.rawDataLength()=="number"&&n.rawDataLength()>0){let o=p.data,s=new DataView(n.rawDataArray().buffer,n.rawDataArray().byteOffset,n.rawDataLength()),c=Wu(n.dataType()),h=n.rawDataLength()/c;if(n.rawDataLength()%c!==0)throw new Error("invalid buffer length");if(o.length!==h)throw new Error("buffer length mismatch");for(let r=0;r<h;r++){let u=Hu(s,n.dataType(),r*c);o[r]=u}}return p}}});function G(e){return e===1?bh:gh}function Xu(e){let n=G(e);return`${n.version}
10
+ */var Hd=Object.create,an=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,jd=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty,Co=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,i)=>(typeof require<"u"?require:n)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),O=(e,n)=>()=>(e&&(n=e(e=0)),n),mt=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Or=(e,n)=>{for(var i in n)an(e,i,{get:n[i],enumerable:!0})},Qa=(e,n,i,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of jd(n))!Kd.call(e,p)&&p!==i&&an(e,p,{get:()=>n[p],enumerable:!(a=qd(n,p))||a.enumerable});return e},rr=(e,n,i)=>(i=e!=null?Hd(Xd(e)):{},Qa(!e||!e.__esModule?an(i,"default",{value:e,enumerable:!0}):i,e)),sn=e=>Qa(an({},"__esModule",{value:!0}),e),un,ke,nr,Jd,ln,fn=O(()=>{un=new Map,ke=[],nr=(e,n,i)=>{if(n&&typeof n.init=="function"&&typeof n.createInferenceSessionHandler=="function"){let a=un.get(e);if(a===void 0)un.set(e,{backend:n,priority:i});else{if(a.priority>i)return;if(a.priority===i&&a.backend!==n)throw new Error(`cannot register backend "${e}" using priority ${i}`)}if(i>=0){let p=ke.indexOf(e);p!==-1&&ke.splice(p,1);for(let o=0;o<ke.length;o++)if(un.get(ke[o]).priority<=i){ke.splice(o,0,e);return}ke.push(e)}return}throw new TypeError("not a valid backend")},Jd=async e=>{let n=un.get(e);if(!n)return"backend not found.";if(n.initialized)return n.backend;if(n.aborted)return n.error;{let i=!!n.initPromise;try{return i||(n.initPromise=n.backend.init(e)),await n.initPromise,n.initialized=!0,n.backend}catch(a){return i||(n.error=`${a}`,n.aborted=!0),n.error}finally{delete n.initPromise}}},ln=async e=>{let n=e.executionProviders||[],i=n.map(h=>typeof h=="string"?h:h.name),a=i.length===0?ke:i,p,o=[],s=new Set;for(let h of a){let r=await Jd(h);typeof r=="string"?o.push({name:h,err:r}):(p||(p=r),p===r&&s.add(h))}if(!p)throw new Error(`no available backend found. ERR: ${o.map(h=>`[${h.name}] ${h.err}`).join(", ")}`);for(let{name:h,err:r}of o)i.includes(h)&&console.warn(`removing requested execution provider "${h}" from session options because it is not available: ${r}`);let c=n.filter(h=>s.has(typeof h=="string"?h:h.name));return[p,new Proxy(e,{get:(h,r)=>r==="executionProviders"?c:Reflect.get(h,r)})]}}),ts=O(()=>{fn()}),es,rs=O(()=>{es="1.20.1"}),ns,Gt,No=O(()=>{rs(),ns="warning",Gt={wasm:{},webgl:{},webgpu:{},versions:{common:es},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);ns=e}},get logLevel(){return ns}},Object.defineProperty(Gt,"logLevel",{enumerable:!0})}),z,os=O(()=>{No(),z=Gt}),is,as,ss=O(()=>{is=(e,n)=>{let i=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);i.width=e.dims[3],i.height=e.dims[2];let a=i.getContext("2d");if(a!=null){let p,o;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(p=e.dims[2],o=e.dims[3]):(p=e.dims[3],o=e.dims[2]);let s=(n==null?void 0:n.format)!==void 0?n.format:"RGB",c=n==null?void 0:n.norm,h,r;c===void 0||c.mean===void 0?h=[255,255,255,255]:typeof c.mean=="number"?h=[c.mean,c.mean,c.mean,c.mean]:(h=[c.mean[0],c.mean[1],c.mean[2],0],c.mean[3]!==void 0&&(h[3]=c.mean[3])),c===void 0||c.bias===void 0?r=[0,0,0,0]:typeof c.bias=="number"?r=[c.bias,c.bias,c.bias,c.bias]:(r=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(r[3]=c.bias[3]));let u=o*p,l=0,f=u,g=u*2,b=-1;s==="RGBA"?(l=0,f=u,g=u*2,b=u*3):s==="RGB"?(l=0,f=u,g=u*2):s==="RBG"&&(l=0,g=u,f=u*2);for(let v=0;v<o;v++)for(let S=0;S<p;S++){let P=(e.data[l++]-r[0])*h[0],_=(e.data[f++]-r[1])*h[1],A=(e.data[g++]-r[2])*h[2],L=b===-1?255:(e.data[b++]-r[3])*h[3];a.fillStyle="rgba("+P+","+_+","+A+","+L+")",a.fillRect(S,v,1,1)}if("toDataURL"in i)return i.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},as=(e,n)=>{let i=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),a;if(i!=null){let p,o,s;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(p=e.dims[2],o=e.dims[1],s=e.dims[3]):(p=e.dims[3],o=e.dims[2],s=e.dims[1]);let c=n!==void 0&&n.format!==void 0?n.format:"RGB",h=n==null?void 0:n.norm,r,u;h===void 0||h.mean===void 0?r=[255,255,255,255]:typeof h.mean=="number"?r=[h.mean,h.mean,h.mean,h.mean]:(r=[h.mean[0],h.mean[1],h.mean[2],255],h.mean[3]!==void 0&&(r[3]=h.mean[3])),h===void 0||h.bias===void 0?u=[0,0,0,0]:typeof h.bias=="number"?u=[h.bias,h.bias,h.bias,h.bias]:(u=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(u[3]=h.bias[3]));let l=o*p;if(n!==void 0&&(n.format!==void 0&&s===4&&n.format!=="RGBA"||s===3&&n.format!=="RGB"&&n.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let f=4,g=0,b=1,v=2,S=3,P=0,_=l,A=l*2,L=-1;c==="RGBA"?(P=0,_=l,A=l*2,L=l*3):c==="RGB"?(P=0,_=l,A=l*2):c==="RBG"&&(P=0,A=l,_=l*2),a=i.createImageData(p,o);for(let M=0;M<o*p;g+=f,b+=f,v+=f,S+=f,M++)a.data[g]=(e.data[P++]-u[0])*r[0],a.data[b]=(e.data[_++]-u[1])*r[1],a.data[v]=(e.data[A++]-u[2])*r[2],a.data[S]=L===-1?255:(e.data[L++]-u[3])*r[3]}else throw new Error("Can not access image data");return a}}),Ro,us,ls,fs,cs,ps,ds=O(()=>{cn(),Ro=(e,n)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(n.height===void 0||n.width===void 0)throw new Error("Image height and width must be defined");if(n.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:i,width:a}=n,p=n.norm??{mean:255,bias:0},o,s;typeof p.mean=="number"?o=[p.mean,p.mean,p.mean,p.mean]:o=[p.mean[0],p.mean[1],p.mean[2],p.mean[3]??255],typeof p.bias=="number"?s=[p.bias,p.bias,p.bias,p.bias]:s=[p.bias[0],p.bias[1],p.bias[2],p.bias[3]??0];let c=n.format!==void 0?n.format:"RGBA",h=n.tensorFormat!==void 0&&n.tensorFormat!==void 0?n.tensorFormat:"RGB",r=i*a,u=h==="RGBA"?new Float32Array(r*4):new Float32Array(r*3),l=4,f=0,g=1,b=2,v=3,S=0,P=r,_=r*2,A=-1;c==="RGB"&&(l=3,f=0,g=1,b=2,v=-1),h==="RGBA"?A=r*3:h==="RBG"?(S=0,_=r,P=r*2):h==="BGR"&&(_=0,P=r,S=r*2);for(let L=0;L<r;L++,f+=l,b+=l,g+=l,v+=l)u[S++]=(e[f]+s[0])/o[0],u[P++]=(e[g]+s[1])/o[1],u[_++]=(e[b]+s[2])/o[2],A!==-1&&v!==-1&&(u[A++]=(e[v]+s[3])/o[3]);return h==="RGBA"?new St("float32",u,[1,4,i,a]):new St("float32",u,[1,3,i,a])},us=async(e,n)=>{let i=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,a=typeof ImageData<"u"&&e instanceof ImageData,p=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,o=typeof e=="string",s,c=n??{},h=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},r=u=>typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement||u instanceof OffscreenCanvas?u.getContext("2d"):null;if(i){let u=h();u.width=e.width,u.height=e.height;let l=r(u);if(l!=null){let f=e.height,g=e.width;if(n!==void 0&&n.resizedHeight!==void 0&&n.resizedWidth!==void 0&&(f=n.resizedHeight,g=n.resizedWidth),n!==void 0){if(c=n,n.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");c.tensorFormat="RGBA",c.height=f,c.width=g}else c.tensorFormat="RGBA",c.height=f,c.width=g;l.drawImage(e,0,0),s=l.getImageData(0,0,g,f).data}else throw new Error("Can not access image data")}else if(a){let u,l;if(n!==void 0&&n.resizedWidth!==void 0&&n.resizedHeight!==void 0?(u=n.resizedHeight,l=n.resizedWidth):(u=e.height,l=e.width),n!==void 0&&(c=n),c.format="RGBA",c.height=u,c.width=l,n!==void 0){let f=h();f.width=l,f.height=u;let g=r(f);if(g!=null)g.putImageData(e,0,0),s=g.getImageData(0,0,l,u).data;else throw new Error("Can not access image data")}else s=e.data}else if(p){if(n===void 0)throw new Error("Please provide image config with format for Imagebitmap");let u=h();u.width=e.width,u.height=e.height;let l=r(u);if(l!=null){let f=e.height,g=e.width;return l.drawImage(e,0,0,g,f),s=l.getImageData(0,0,g,f).data,c.height=f,c.width=g,Ro(s,c)}else throw new Error("Can not access image data")}else{if(o)return new Promise((u,l)=>{let f=h(),g=r(f);if(!e||!g)return l();let b=new Image;b.crossOrigin="Anonymous",b.src=e,b.onload=()=>{f.width=b.width,f.height=b.height,g.drawImage(b,0,0,f.width,f.height);let v=g.getImageData(0,0,f.width,f.height);c.height=f.height,c.width=f.width,u(Ro(v.data,c))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Ro(s,c);throw new Error("Input data provided is not supported - aborted tensor creation")},ls=(e,n)=>{let{width:i,height:a,download:p,dispose:o}=n,s=[1,a,i,4];return new St({location:"texture",type:"float32",texture:e,dims:s,download:p,dispose:o})},fs=(e,n)=>{let{dataType:i,dims:a,download:p,dispose:o}=n;return new St({location:"gpu-buffer",type:i??"float32",gpuBuffer:e,dims:a,download:p,dispose:o})},cs=(e,n)=>{let{dataType:i,dims:a,download:p,dispose:o}=n;return new St({location:"ml-tensor",type:i??"float32",mlTensor:e,dims:a,download:p,dispose:o})},ps=(e,n,i)=>new St({location:"cpu-pinned",type:e,data:n,dims:i??[n.length]})}),Be,Sr,hs,ms,bs=O(()=>{Be=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Sr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),hs=!1,ms=()=>{if(!hs){hs=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,n=typeof BigUint64Array<"u"&&BigUint64Array.from,i=typeof Float16Array<"u"&&Float16Array.from;e&&(Be.set("int64",BigInt64Array),Sr.set(BigInt64Array,"int64")),n&&(Be.set("uint64",BigUint64Array),Sr.set(BigUint64Array,"uint64")),i?(Be.set("float16",Float16Array),Sr.set(Float16Array,"float16")):Be.set("float16",Uint16Array)}}}),gs,ys,xs=O(()=>{cn(),gs=e=>{let n=1;for(let i=0;i<e.length;i++){let a=e[i];if(typeof a!="number"||!Number.isSafeInteger(a))throw new TypeError(`dims[${i}] must be an integer, got: ${a}`);if(a<0)throw new RangeError(`dims[${i}] must be a non-negative integer, got: ${a}`);n*=a}return n},ys=(e,n)=>{switch(e.location){case"cpu":return new St(e.type,e.data,n);case"cpu-pinned":return new St({location:"cpu-pinned",data:e.data,type:e.type,dims:n});case"texture":return new St({location:"texture",texture:e.texture,type:e.type,dims:n});case"gpu-buffer":return new St({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:n});case"ml-tensor":return new St({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:n});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),St,cn=O(()=>{ss(),ds(),bs(),xs(),St=class{constructor(e,n,i){ms();let a,p;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,a=e.type,p=e.dims,e.location){case"cpu-pinned":{let s=Be.get(a);if(!s)throw new TypeError(`unsupported type "${a}" to create tensor from pinned buffer`);if(!(e.data instanceof s))throw new TypeError(`buffer should be of type ${s.name}`);this.cpuData=e.data;break}case"texture":{if(a!=="float32")throw new TypeError(`unsupported type "${a}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break}case"gpu-buffer":{if(a!=="float32"&&a!=="float16"&&a!=="int32"&&a!=="int64"&&a!=="uint32"&&a!=="uint8"&&a!=="bool"&&a!=="uint4"&&a!=="int4")throw new TypeError(`unsupported type "${a}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}case"ml-tensor":{if(a!=="float32"&&a!=="float16"&&a!=="int32"&&a!=="int64"&&a!=="uint32"&&a!=="uint64"&&a!=="int8"&&a!=="uint8"&&a!=="bool")throw new TypeError(`unsupported type "${a}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let s,c;if(typeof e=="string")if(a=e,c=i,e==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");s=n}else{let h=Be.get(e);if(h===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(n)){if(e==="float16"&&h===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${h.name} as data.`);e==="uint64"||e==="int64"?s=h.from(n,BigInt):s=h.from(n)}else if(n instanceof h)s=n;else if(n instanceof Uint8ClampedArray)if(e==="uint8")s=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${a} tensor's data must be type of ${h}`)}else if(c=n,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let h=typeof e[0];if(h==="string")a="string",s=e;else if(h==="boolean")a="bool",s=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${h}.`)}else if(e instanceof Uint8ClampedArray)a="uint8",s=Uint8Array.from(e);else{let h=Sr.get(e.constructor);if(h===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);a=h,s=e}if(c===void 0)c=[s.length];else if(!Array.isArray(c))throw new TypeError("A tensor's dims must be a number array");p=c,this.cpuData=s,this.dataLocation="cpu"}let o=gs(p);if(this.cpuData&&o!==this.cpuData.length&&!((a==="uint4"||a==="int4")&&Math.ceil(o/2)===this.cpuData.length))throw new Error(`Tensor's size(${o}) does not match data length(${this.cpuData.length}).`);this.type=a,this.dims=p,this.size=o}static async fromImage(e,n){return us(e,n)}static fromTexture(e,n){return ls(e,n)}static fromGpuBuffer(e,n){return fs(e,n)}static fromMLTensor(e,n){return cs(e,n)}static fromPinnedBuffer(e,n,i){return ps(e,n,i)}toDataURL(e){return is(this,e)}toImageData(e){return as(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}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{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 n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,e&&this.disposer&&(this.disposer(),this.disposer=void 0),n}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.mlTensorData=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 ys(this,e)}}}),yt,pn=O(()=>{cn(),yt=St}),Ts,ws,Fe,Ce,Go=O(()=>{No(),Ts=(e,n)=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||console.timeStamp(`${e}::ORT::${n}`)},ws=(e,n)=>{var p;let i=((p=new Error().stack)==null?void 0:p.split(/\r\n|\r|\n/g))||[],a=!1;for(let o=0;o<i.length;o++){if(a&&!i[o].includes("TRACE_FUNC")){let s=`FUNC_${e}::${i[o].trim().split(" ")[1]}`;n&&(s+=`::${n}`),Ts("CPU",s);return}i[o].includes("TRACE_FUNC")&&(a=!0)}},Fe=e=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("BEGIN",e)},Ce=e=>{(typeof Gt.trace>"u"?!Gt.wasm.trace:!Gt.trace)||ws("END",e)}}),dn,vs=O(()=>{fn(),pn(),Go(),dn=class Oa{constructor(n){this.handler=n}async run(n,i,a){Fe();let p={},o={};if(typeof n!="object"||n===null||n instanceof yt||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof i=="object"){if(i===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(i instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(i)){if(i.length===0)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let r of i){if(typeof r!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(r)===-1)throw new RangeError(`'fetches' contains invalid output name: ${r}.`);p[r]=null}if(typeof a=="object"&&a!==null)o=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else{let r=!1,u=Object.getOwnPropertyNames(i);for(let l of this.outputNames)if(u.indexOf(l)!==-1){let f=i[l];(f===null||f instanceof yt)&&(r=!0,s=!1,p[l]=f)}if(r){if(typeof a=="object"&&a!==null)o=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else o=i}}else if(typeof i<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let r of this.inputNames)if(typeof n[r]>"u")throw new Error(`input '${r}' is missing in 'feeds'.`);if(s)for(let r of this.outputNames)p[r]=null;let c=await this.handler.run(n,p,o),h={};for(let r in c)if(Object.hasOwnProperty.call(c,r)){let u=c[r];u instanceof yt?h[r]=u:h[r]=new yt(u.type,u.data,u.dims)}return Ce(),h}async release(){return this.handler.dispose()}static async create(n,i,a,p){Fe();let o,s={};if(typeof n=="string"){if(o=n,typeof i=="object"&&i!==null)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof Uint8Array){if(o=n,typeof i=="object"&&i!==null)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer){let u=n,l=0,f=n.byteLength;if(typeof i=="object"&&i!==null)s=i;else if(typeof i=="number"){if(l=i,!Number.isSafeInteger(l))throw new RangeError("'byteOffset' must be an integer.");if(l<0||l>=u.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${u.byteLength}).`);if(f=n.byteLength-l,typeof a=="number"){if(f=a,!Number.isSafeInteger(f))throw new RangeError("'byteLength' must be an integer.");if(f<=0||l+f>u.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${u.byteLength-l}].`);if(typeof p=="object"&&p!==null)s=p;else if(typeof p<"u")throw new TypeError("'options' must be an object.")}else if(typeof a<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof i<"u")throw new TypeError("'options' must be an object.");o=new Uint8Array(u,l,f)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[c,h]=await ln(s),r=await c.createInferenceSessionHandler(o,h);return Ce(),new Oa(r)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Yd,Is=O(()=>{vs(),Yd=dn}),_s=O(()=>{}),Os=O(()=>{}),Ss=O(()=>{}),As=O(()=>{}),Zd,hn,Ps=O(()=>{fn(),pn(),Zd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",hn=class Sa{constructor(n,i,a){this.handler=n,this.hasOptimizerModel=i,this.hasEvalModel=a}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(n,i){let a=n.evalModel||"",p=n.optimizerModel||"",o=i||{},[s,c]=await ln(o);if(s.createTrainingSessionHandler){let h=await s.createTrainingSessionHandler(n.checkpointState,n.trainModel,a,p,c);return new Sa(h,!!n.optimizerModel,!!n.evalModel)}else throw new Error(Zd)}typeNarrowingForRunStep(n,i,a,p,o){let s={},c={};if(typeof a!="object"||a===null||a instanceof yt||Array.isArray(a))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let h=!0;if(typeof p=="object"){if(p===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(p instanceof yt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(p)){if(p.length===0)throw new TypeError("'fetches' cannot be an empty array.");h=!1;for(let r of p){if(typeof r!="string")throw new TypeError("'fetches' must be a string array or an object.");if(i.indexOf(r)===-1)throw new RangeError(`'fetches' contains invalid output name: ${r}.`);s[r]=null}if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else{let r=!1,u=Object.getOwnPropertyNames(p);for(let l of i)if(u.indexOf(l)!==-1){let f=p[l];(f===null||f instanceof yt)&&(r=!0,h=!1,s[l]=f)}if(r){if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else c=p}}else if(typeof p<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let r of n)if(typeof a[r]>"u")throw new Error(`input '${r}' is missing in 'feeds'.`);if(h)for(let r of i)s[r]=null;return[s,c]}convertHandlerReturnTypeToMapOfTensors(n){let i={};for(let a in n)if(Object.hasOwnProperty.call(n,a)){let p=n[a];p instanceof yt?i[a]=p:i[a]=new yt(p.type,p.data,p.dims)}return i}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(n,i,a){let[p,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,n,i,a),s=await this.handler.runTrainStep(n,p,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(n){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(n||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(n,i,a){if(this.hasEvalModel){let[p,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,n,i,a),s=await this.handler.runEvalStep(n,p,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(n=!0){return this.handler.getParametersSize(n)}async loadParametersBuffer(n,i=!0){let a=await this.getParametersSize(i);if(n.length!==4*a)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(n,i)}async getContiguousParameters(n=!0){return this.handler.getContiguousParameters(n)}async release(){return this.handler.dispose()}}}),Qd,Es=O(()=>{Ps(),Qd=hn}),Mo={};Or(Mo,{InferenceSession:()=>Yd,TRACE:()=>Ts,TRACE_FUNC_BEGIN:()=>Fe,TRACE_FUNC_END:()=>Ce,Tensor:()=>yt,TrainingSession:()=>Qd,env:()=>z,registerBackend:()=>nr});var Yt=O(()=>{ts(),os(),Is(),pn(),_s(),Os(),Go(),Ss(),As(),Es()});function _e(e,n,i,a){if(n===void 0)return eh(e);if(i===void 0)mn(e,n);else if(typeof i=="number"&&a===void 0)mn(e,n);else if(typeof i=="string"&&a===void 0)mn(e,i,1,n);else if(typeof i=="string"&&typeof a=="number")mn(e,i,a,n);else throw new TypeError("input is valid")}function eh(e){return{verbose:_e.verbose.bind(null,e),info:_e.info.bind(null,e),warning:_e.warning.bind(null,e),error:_e.error.bind(null,e),fatal:_e.fatal.bind(null,e)}}function mn(e,n,i,a){let p=Ar[a||""]||Ar[""];Ls[e]<Ls[p.minimalSeverity]||(p.logDateTime&&(n=`${new Date().toISOString()}|${n}`),p.logSourceLocation,th[p.provider].log(e,n,a))}var Uo,Vo,Ls,th,$s,Ar,tt,gn,yn,xn,bn,Ut=O(()=>{Uo=class{log(e,n,i){}},Vo=class{log(e,n,i){console.log(`${this.color(e)} ${i?"\x1B[35m"+i+"\x1B[0m ":""}${n}`)}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}`)}}},Ls={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},th={none:new Uo,console:new Vo},$s={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},Ar={"":$s},(e=>{function n(r,u){e("verbose",r,u)}e.verbose=n;function i(r,u){e("info",r,u)}e.info=i;function a(r,u){e("warning",r,u)}e.warning=a;function p(r,u){e("error",r,u)}e.error=p;function o(r,u){e("fatal",r,u)}e.fatal=o;function s(r){Ar={},c("",r||{})}e.reset=s;function c(r,u){if(r==="*")s(u);else{let l=Ar[r]||$s;Ar[r]={provider:u.provider||l.provider,minimalSeverity:u.minimalSeverity||l.minimalSeverity,logDateTime:u.logDateTime===void 0?l.logDateTime:u.logDateTime,logSourceLocation:u.logSourceLocation===void 0?l.logSourceLocation:u.logSourceLocation}}}e.set=c;function h(r){let u={};r.logLevel&&(u.minimalSeverity=r.logLevel),c("",u)}e.setWithEnv=h})(_e||(_e={})),tt=_e,gn=class{constructor(e,n,i,a,p,o){this.category=e,this.name=n,this.startTime=i,this.endCallback=a,this.timer=p,this.ctx=o}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)}},yn=class{constructor(e,n,i,a){this.category=e,this.name=n,this.startTime=i,this.endTime=a}},xn=class{constructor(e,n,i){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=e===void 0?1e4:e,this._flushBatchSize=n===void 0?10:n,this._flushIntervalInMilliseconds=i===void 0?5e3:i}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=bn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,n,i,a){let p=this._started?this.begin(e,n,a):void 0,o=!1,s=i();if(s&&typeof s.then=="function")return o=!0,new Promise((c,h)=>{s.then(async r=>{p&&await p.end(),c(r)},async r=>{p&&await p.end(),h(r)})});if(!o&&p){let c=p.end();if(c&&typeof c.then=="function")return new Promise((h,r)=>{c.then(()=>{h(s)},u=>{r(u)})})}return s}begin(e,n,i){if(!this._started)throw new Error("profiler is not started yet");if(i===void 0){let a=bn();return this.flush(a),new gn(e,n,a,p=>this.endSync(p))}else{let a=i.beginTimer();return new gn(e,n,0,async p=>this.end(p),a,i)}}async end(e){let n=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(e.category,e.name,e.startTime,n)),this.flush(n))}endSync(e){let n=bn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(e.category,e.name,e.startTime,n)),this.flush(n))}logOneEvent(e){tt.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 n=this._flushPointer;this._flushPointer<n+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=bn()}}get started(){return this._started}},bn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function ks(e,n,i){for(let a of i){let p=a[0],o=a[1],s=a[2],c=a[3],h=a[4];if(e.opType===p){for(let r of n)if((r.domain===o||r.domain==="ai.onnx"&&o==="")&&rh(r.version,s))return{opImpl:c,opInit:h}}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${n.map(a=>`${a.domain||"ai.onnx"} v${a.version}`).join(", ")}`)}function rh(e,n){if(n.endsWith("+")){let i=Number.parseInt(n.substring(0,n.length-1),10);return!isNaN(i)&&i<=e}else if(n.split("-").length===2){let i=n.split("-"),a=Number.parseInt(i[0],10),p=Number.parseInt(i[1],10);return!isNaN(a)&&!isNaN(p)&&a<=e&&e<=p}else return Number.parseInt(n,10)===e}var Bs=O(()=>{}),Fs=mt(e=>{e.__esModule=!0;var n=function(){function i(a){if(!a)throw new TypeError("Invalid argument; `value` has no value.");this.value=i.EMPTY,a&&i.isGuid(a)&&(this.value=a)}return i.isGuid=function(a){var p=a.toString();return a&&(a instanceof i||i.validator.test(p))},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(a){return new i(a)},i.raw=function(){return[i.gen(2),i.gen(1),i.gen(1),i.gen(1),i.gen(3)].join("-")},i.gen=function(a){for(var p="",o=0;o<a;o++)p+=((1+Math.random())*65536|0).toString(16).substring(1);return p},i.prototype.equals=function(a){return i.isGuid(a)&&this.value===a.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}();e.Guid=n});function rt(e,n,i){this.low=e|0,this.high=n|0,this.unsigned=!!i}function Et(e){return(e&&e.__isLong__)===!0}function Cs(e){var n=Math.clz32(e&-e);return e?31-n:n}function Ne(e,n){var i,a,p;return n?(e>>>=0,(p=0<=e&&e<256)&&(a=Rs[e],a)?a:(i=J(e,0,!0),p&&(Rs[e]=i),i)):(e|=0,(p=-128<=e&&e<128)&&(a=Ns[e],a)?a:(i=J(e,e<0?-1:0,!1),p&&(Ns[e]=i),i))}function zt(e,n){if(isNaN(e))return n?ye:Zt;if(n){if(e<0)return ye;if(e>=Vs)return Hs}else{if(e<=-Ms)return Ct;if(e+1>=Ms)return Ws}return e<0?zt(-e,n).neg():J(e%ir|0,e/ir|0,n)}function J(e,n,i){return new rt(e,n,i)}function Ho(e,n,i){if(e.length===0)throw Error("empty string");if(typeof n=="number"?(i=n,n=!1):n=!!n,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return n?ye:Zt;if(i=i||10,i<2||36<i)throw RangeError("radix");var a;if((a=e.indexOf("-"))>0)throw Error("interior hyphen");if(a===0)return Ho(e.substring(1),n,i).neg();for(var p=zt(Tn(i,8)),o=Zt,s=0;s<e.length;s+=8){var c=Math.min(8,e.length-s),h=parseInt(e.substring(s,s+c),i);if(c<8){var r=zt(Tn(i,c));o=o.mul(r).add(zt(h))}else o=o.mul(p),o=o.add(zt(h))}return o.unsigned=n,o}function Qt(e,n){return typeof e=="number"?zt(e,n):typeof e=="string"?Ho(e,n):J(e.low,e.high,typeof n=="boolean"?n:e.unsigned)}var Vt,Ns,Rs,Tn,Gs,oh,ir,Vs,Ms,Us,Zt,ye,or,zs,Wo,Ws,Hs,Ct,D,xe,qo=O(()=>{Vt=null;try{Vt=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{}rt.prototype.__isLong__,Object.defineProperty(rt.prototype,"__isLong__",{value:!0}),rt.isLong=Et,Ns={},Rs={},rt.fromInt=Ne,rt.fromNumber=zt,rt.fromBits=J,Tn=Math.pow,rt.fromString=Ho,rt.fromValue=Qt,Gs=65536,oh=1<<24,ir=Gs*Gs,Vs=ir*ir,Ms=Vs/2,Us=Ne(oh),Zt=Ne(0),rt.ZERO=Zt,ye=Ne(0,!0),rt.UZERO=ye,or=Ne(1),rt.ONE=or,zs=Ne(1,!0),rt.UONE=zs,Wo=Ne(-1),rt.NEG_ONE=Wo,Ws=J(-1,2147483647,!1),rt.MAX_VALUE=Ws,Hs=J(-1,-1,!0),rt.MAX_UNSIGNED_VALUE=Hs,Ct=J(0,-2147483648,!1),rt.MIN_VALUE=Ct,D=rt.prototype,D.toInt=function(){return this.unsigned?this.low>>>0:this.low},D.toNumber=function(){return this.unsigned?(this.high>>>0)*ir+(this.low>>>0):this.high*ir+(this.low>>>0)},D.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(Ct)){var n=zt(e),i=this.div(n),a=i.mul(n).sub(this);return i.toString(e)+a.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var p=zt(Tn(e,6),this.unsigned),o=this,s="";;){var c=o.div(p),h=o.sub(c.mul(p)).toInt()>>>0,r=h.toString(e);if(o=c,o.isZero())return r+s;for(;r.length<6;)r="0"+r;s=""+r+s}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0},D.getLowBits=function(){return this.low},D.getLowBitsUnsigned=function(){return this.low>>>0},D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ct)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1},D.isZero=function(){return this.high===0&&this.low===0},D.eqz=D.isZero,D.isNegative=function(){return!this.unsigned&&this.high<0},D.isPositive=function(){return this.unsigned||this.high>=0},D.isOdd=function(){return(this.low&1)===1},D.isEven=function(){return(this.low&1)===0},D.equals=function(e){return Et(e)||(e=Qt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},D.eq=D.equals,D.notEquals=function(e){return!this.eq(e)},D.neq=D.notEquals,D.ne=D.notEquals,D.lessThan=function(e){return this.comp(e)<0},D.lt=D.lessThan,D.lessThanOrEqual=function(e){return this.comp(e)<=0},D.lte=D.lessThanOrEqual,D.le=D.lessThanOrEqual,D.greaterThan=function(e){return this.comp(e)>0},D.gt=D.greaterThan,D.greaterThanOrEqual=function(e){return this.comp(e)>=0},D.gte=D.greaterThanOrEqual,D.ge=D.greaterThanOrEqual,D.compare=function(e){if(Et(e)||(e=Qt(e)),this.eq(e))return 0;var n=this.isNegative(),i=e.isNegative();return n&&!i?-1:!n&&i?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},D.comp=D.compare,D.negate=function(){return!this.unsigned&&this.eq(Ct)?Ct:this.not().add(or)},D.neg=D.negate,D.add=function(e){Et(e)||(e=Qt(e));var n=this.high>>>16,i=this.high&65535,a=this.low>>>16,p=this.low&65535,o=e.high>>>16,s=e.high&65535,c=e.low>>>16,h=e.low&65535,r=0,u=0,l=0,f=0;return f+=p+h,l+=f>>>16,f&=65535,l+=a+c,u+=l>>>16,l&=65535,u+=i+s,r+=u>>>16,u&=65535,r+=n+o,r&=65535,J(l<<16|f,r<<16|u,this.unsigned)},D.subtract=function(e){return Et(e)||(e=Qt(e)),this.add(e.neg())},D.sub=D.subtract,D.multiply=function(e){if(this.isZero())return this;if(Et(e)||(e=Qt(e)),Vt){var n=Vt.mul(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?ye:Zt;if(this.eq(Ct))return e.isOdd()?Ct:Zt;if(e.eq(Ct))return this.isOdd()?Ct:Zt;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(Us)&&e.lt(Us))return zt(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,a=this.high&65535,p=this.low>>>16,o=this.low&65535,s=e.high>>>16,c=e.high&65535,h=e.low>>>16,r=e.low&65535,u=0,l=0,f=0,g=0;return g+=o*r,f+=g>>>16,g&=65535,f+=p*r,l+=f>>>16,f&=65535,f+=o*h,l+=f>>>16,f&=65535,l+=a*r,u+=l>>>16,l&=65535,l+=p*h,u+=l>>>16,l&=65535,l+=o*c,u+=l>>>16,l&=65535,u+=i*r+a*h+p*c+o*s,u&=65535,J(f<<16|g,u<<16|l,this.unsigned)},D.mul=D.multiply,D.divide=function(e){if(Et(e)||(e=Qt(e)),e.isZero())throw Error("division by zero");if(Vt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?Vt.div_u:Vt.div_s)(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ye:Zt;var i,a,p;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return ye;if(e.gt(this.shru(1)))return zs;p=ye}else{if(this.eq(Ct)){if(e.eq(or)||e.eq(Wo))return Ct;if(e.eq(Ct))return or;var o=this.shr(1);return i=o.div(e).shl(1),i.eq(Zt)?e.isNegative()?or:Wo:(a=this.sub(e.mul(i)),p=i.add(a.div(e)),p)}else if(e.eq(Ct))return this.unsigned?ye:Zt;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();p=Zt}for(a=this;a.gte(e);){i=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(i)/Math.LN2),c=s<=48?1:Tn(2,s-48),h=zt(i),r=h.mul(e);r.isNegative()||r.gt(a);)i-=c,h=zt(i,this.unsigned),r=h.mul(e);h.isZero()&&(h=or),p=p.add(h),a=a.sub(r)}return p},D.div=D.divide,D.modulo=function(e){if(Et(e)||(e=Qt(e)),Vt){var n=(this.unsigned?Vt.rem_u:Vt.rem_s)(this.low,this.high,e.low,e.high);return J(n,Vt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},D.mod=D.modulo,D.rem=D.modulo,D.not=function(){return J(~this.low,~this.high,this.unsigned)},D.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},D.clz=D.countLeadingZeros,D.countTrailingZeros=function(){return this.low?Cs(this.low):Cs(this.high)+32},D.ctz=D.countTrailingZeros,D.and=function(e){return Et(e)||(e=Qt(e)),J(this.low&e.low,this.high&e.high,this.unsigned)},D.or=function(e){return Et(e)||(e=Qt(e)),J(this.low|e.low,this.high|e.high,this.unsigned)},D.xor=function(e){return Et(e)||(e=Qt(e)),J(this.low^e.low,this.high^e.high,this.unsigned)},D.shiftLeft=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):J(0,this.low<<e-32,this.unsigned)},D.shl=D.shiftLeft,D.shiftRight=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):J(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},D.shr=D.shiftRight,D.shiftRightUnsigned=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?J(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?J(this.high,0,this.unsigned):J(this.high>>>e-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.rotateLeft=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?J(this.high,this.low,this.unsigned):e<32?(n=32-e,J(this.low<<e|this.high>>>n,this.high<<e|this.low>>>n,this.unsigned)):(e-=32,n=32-e,J(this.high<<e|this.low>>>n,this.low<<e|this.high>>>n,this.unsigned))},D.rotl=D.rotateLeft,D.rotateRight=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?J(this.high,this.low,this.unsigned):e<32?(n=32-e,J(this.high<<n|this.low>>>e,this.low<<n|this.high>>>e,this.unsigned)):(e-=32,n=32-e,J(this.low<<n|this.high>>>e,this.high<<n|this.low>>>e,this.unsigned))},D.rotr=D.rotateRight,D.toSigned=function(){return this.unsigned?J(this.low,this.high,!1):this},D.toUnsigned=function(){return this.unsigned?this:J(this.low,this.high,!0)},D.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},D.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]},D.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]},rt.fromBytes=function(e,n,i){return i?rt.fromBytesLE(e,n):rt.fromBytesBE(e,n)},rt.fromBytesLE=function(e,n){return new rt(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},rt.fromBytesBE=function(e,n){return new rt(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},xe=rt}),w,wn=O(()=>{w={},w.Offset,w.Table,w.SIZEOF_SHORT=2,w.SIZEOF_INT=4,w.FILE_IDENTIFIER_LENGTH=4,w.SIZE_PREFIX_LENGTH=4,w.Encoding={UTF8_BYTES:1,UTF16_STRING:2},w.int32=new Int32Array(2),w.float32=new Float32Array(w.int32.buffer),w.float64=new Float64Array(w.int32.buffer),w.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,w.Long=function(e,n){this.low=e|0,this.high=n|0},w.Long.create=function(e,n){return e==0&&n==0?w.Long.ZERO:new w.Long(e,n)},w.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296},w.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},w.Long.ZERO=new w.Long(0,0),w.Builder=function(e){if(e)var n=e;else var n=1024;this.bb=w.ByteBuffer.allocate(n),this.space=n,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},w.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},w.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},w.Builder.prototype.dataBuffer=function(){return this.bb},w.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},w.Builder.prototype.prep=function(e,n){e>this.minalign&&(this.minalign=e);for(var i=~(this.bb.capacity()-this.space+n)+1&e-1;this.space<i+e+n;){var a=this.bb.capacity();this.bb=w.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-a}this.pad(i)},w.Builder.prototype.pad=function(e){for(var n=0;n<e;n++)this.bb.writeInt8(--this.space,0)},w.Builder.prototype.writeInt8=function(e){this.bb.writeInt8(this.space-=1,e)},w.Builder.prototype.writeInt16=function(e){this.bb.writeInt16(this.space-=2,e)},w.Builder.prototype.writeInt32=function(e){this.bb.writeInt32(this.space-=4,e)},w.Builder.prototype.writeInt64=function(e){this.bb.writeInt64(this.space-=8,e)},w.Builder.prototype.writeFloat32=function(e){this.bb.writeFloat32(this.space-=4,e)},w.Builder.prototype.writeFloat64=function(e){this.bb.writeFloat64(this.space-=8,e)},w.Builder.prototype.addInt8=function(e){this.prep(1,0),this.writeInt8(e)},w.Builder.prototype.addInt16=function(e){this.prep(2,0),this.writeInt16(e)},w.Builder.prototype.addInt32=function(e){this.prep(4,0),this.writeInt32(e)},w.Builder.prototype.addInt64=function(e){this.prep(8,0),this.writeInt64(e)},w.Builder.prototype.addFloat32=function(e){this.prep(4,0),this.writeFloat32(e)},w.Builder.prototype.addFloat64=function(e){this.prep(8,0),this.writeFloat64(e)},w.Builder.prototype.addFieldInt8=function(e,n,i){(this.force_defaults||n!=i)&&(this.addInt8(n),this.slot(e))},w.Builder.prototype.addFieldInt16=function(e,n,i){(this.force_defaults||n!=i)&&(this.addInt16(n),this.slot(e))},w.Builder.prototype.addFieldInt32=function(e,n,i){(this.force_defaults||n!=i)&&(this.addInt32(n),this.slot(e))},w.Builder.prototype.addFieldInt64=function(e,n,i){(this.force_defaults||!n.equals(i))&&(this.addInt64(n),this.slot(e))},w.Builder.prototype.addFieldFloat32=function(e,n,i){(this.force_defaults||n!=i)&&(this.addFloat32(n),this.slot(e))},w.Builder.prototype.addFieldFloat64=function(e,n,i){(this.force_defaults||n!=i)&&(this.addFloat64(n),this.slot(e))},w.Builder.prototype.addFieldOffset=function(e,n,i){(this.force_defaults||n!=i)&&(this.addOffset(n),this.slot(e))},w.Builder.prototype.addFieldStruct=function(e,n,i){n!=i&&(this.nested(n),this.slot(e))},w.Builder.prototype.nested=function(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},w.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},w.Builder.prototype.slot=function(e){this.vtable[e]=this.offset()},w.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},w.Builder.growByteBuffer=function(e){var n=e.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var i=n<<1,a=w.ByteBuffer.allocate(i);return a.setPosition(i-n),a.bytes().set(e.bytes(),i-n),a},w.Builder.prototype.addOffset=function(e){this.prep(w.SIZEOF_INT,0),this.writeInt32(this.offset()-e+w.SIZEOF_INT)},w.Builder.prototype.startObject=function(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(var n=0;n<e;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()},w.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var e=this.offset(),n=this.vtable_in_use-1;n>=0&&this.vtable[n]==0;n--);for(var i=n+1;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);var a=2;this.addInt16(e-this.object_start);var p=(i+a)*w.SIZEOF_SHORT;this.addInt16(p);var o=0,s=this.space;t:for(n=0;n<this.vtables.length;n++){var c=this.bb.capacity()-this.vtables[n];if(p==this.bb.readInt16(c)){for(var h=w.SIZEOF_SHORT;h<p;h+=w.SIZEOF_SHORT)if(this.bb.readInt16(s+h)!=this.bb.readInt16(c+h))continue t;o=this.vtables[n];break}}return o?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,o-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e},w.Builder.prototype.finish=function(e,n,i){var a=i?w.SIZE_PREFIX_LENGTH:0;if(n){var p=n;if(this.prep(this.minalign,w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH+a),p.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var o=w.FILE_IDENTIFIER_LENGTH-1;o>=0;o--)this.writeInt8(p.charCodeAt(o))}this.prep(this.minalign,w.SIZEOF_INT+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},w.Builder.prototype.finishSizePrefixed=function(e,n){this.finish(e,n,!0)},w.Builder.prototype.requiredField=function(e,n){var i=this.bb.capacity()-e,a=i-this.bb.readInt32(i),p=this.bb.readInt16(a+n)!=0;if(!p)throw new Error("FlatBuffers: field "+n+" must be set")},w.Builder.prototype.startVector=function(e,n,i){this.notNested(),this.vector_num_elems=n,this.prep(w.SIZEOF_INT,e*n),this.prep(i,e*n)},w.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},w.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var n=e;else for(var n=[],i=0;i<e.length;){var a,p=e.charCodeAt(i++);if(p<55296||p>=56320)a=p;else{var o=e.charCodeAt(i++);a=(p<<10)+o+-56613888}a<128?n.push(a):(a<2048?n.push(a>>6&31|192):(a<65536?n.push(a>>12&15|224):n.push(a>>18&7|240,a>>12&63|128),n.push(a>>6&63|128)),n.push(a&63|128))}this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length);for(var i=0,s=this.space,c=this.bb.bytes();i<n.length;i++)c[s++]=n[i];return this.endVector()},w.Builder.prototype.createLong=function(e,n){return w.Long.create(e,n)},w.ByteBuffer=function(e){this.bytes_=e,this.position_=0},w.ByteBuffer.allocate=function(e){return new w.ByteBuffer(new Uint8Array(e))},w.ByteBuffer.prototype.clear=function(){this.position_=0},w.ByteBuffer.prototype.bytes=function(){return this.bytes_},w.ByteBuffer.prototype.position=function(){return this.position_},w.ByteBuffer.prototype.setPosition=function(e){this.position_=e},w.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},w.ByteBuffer.prototype.readInt8=function(e){return this.readUint8(e)<<24>>24},w.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},w.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},w.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},w.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},w.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},w.ByteBuffer.prototype.readInt64=function(e){return new w.Long(this.readInt32(e),this.readInt32(e+4))},w.ByteBuffer.prototype.readUint64=function(e){return new w.Long(this.readUint32(e),this.readUint32(e+4))},w.ByteBuffer.prototype.readFloat32=function(e){return w.int32[0]=this.readInt32(e),w.float32[0]},w.ByteBuffer.prototype.readFloat64=function(e){return w.int32[w.isLittleEndian?0:1]=this.readInt32(e),w.int32[w.isLittleEndian?1:0]=this.readInt32(e+4),w.float64[0]},w.ByteBuffer.prototype.writeInt8=function(e,n){this.bytes_[e]=n},w.ByteBuffer.prototype.writeUint8=function(e,n){this.bytes_[e]=n},w.ByteBuffer.prototype.writeInt16=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8},w.ByteBuffer.prototype.writeUint16=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8},w.ByteBuffer.prototype.writeInt32=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24},w.ByteBuffer.prototype.writeUint32=function(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24},w.ByteBuffer.prototype.writeInt64=function(e,n){this.writeInt32(e,n.low),this.writeInt32(e+4,n.high)},w.ByteBuffer.prototype.writeUint64=function(e,n){this.writeUint32(e,n.low),this.writeUint32(e+4,n.high)},w.ByteBuffer.prototype.writeFloat32=function(e,n){w.float32[0]=n,this.writeInt32(e,w.int32[0])},w.ByteBuffer.prototype.writeFloat64=function(e,n){w.float64[0]=n,this.writeInt32(e,w.int32[w.isLittleEndian?0:1]),this.writeInt32(e+4,w.int32[w.isLittleEndian?1:0])},w.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var e="",n=0;n<w.FILE_IDENTIFIER_LENGTH;n++)e+=String.fromCharCode(this.readInt8(this.position_+w.SIZEOF_INT+n));return e},w.ByteBuffer.prototype.__offset=function(e,n){var i=e-this.readInt32(e);return n<this.readInt16(i)?this.readInt16(i+n):0},w.ByteBuffer.prototype.__union=function(e,n){return e.bb_pos=n+this.readInt32(n),e.bb=this,e},w.ByteBuffer.prototype.__string=function(e,n){e+=this.readInt32(e);var i=this.readInt32(e),a="",p=0;if(e+=w.SIZEOF_INT,n===w.Encoding.UTF8_BYTES)return this.bytes_.subarray(e,e+i);for(;p<i;){var o,s=this.readUint8(e+p++);if(s<192)o=s;else{var c=this.readUint8(e+p++);if(s<224)o=(s&31)<<6|c&63;else{var h=this.readUint8(e+p++);if(s<240)o=(s&15)<<12|(c&63)<<6|h&63;else{var r=this.readUint8(e+p++);o=(s&7)<<18|(c&63)<<12|(h&63)<<6|r&63}}}o<65536?a+=String.fromCharCode(o):(o-=65536,a+=String.fromCharCode((o>>10)+55296,(o&1023)+56320))}return a},w.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},w.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+w.SIZEOF_INT},w.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},w.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=w.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var n=0;n<w.FILE_IDENTIFIER_LENGTH;n++)if(e.charCodeAt(n)!=this.readInt8(this.position_+w.SIZEOF_INT+n))return!1;return!0},w.ByteBuffer.prototype.createLong=function(e,n){return w.Long.create(e,n)}}),F,Pr=O(()=>{wn(),(e=>{(n=>{(i=>{(a=>(a[a.UNDEFINED=0]="UNDEFINED",a[a.FLOAT=1]="FLOAT",a[a.INT=2]="INT",a[a.STRING=3]="STRING",a[a.TENSOR=4]="TENSOR",a[a.GRAPH=5]="GRAPH",a[a.FLOATS=6]="FLOATS",a[a.INTS=7]="INTS",a[a.STRINGS=8]="STRINGS",a[a.TENSORS=9]="TENSORS",a[a.GRAPHS=10]="GRAPHS",a[a.SPARSE_TENSOR=11]="SPARSE_TENSOR",a[a.SPARSE_TENSORS=12]="SPARSE_TENSORS"))(i.AttributeType||(i.AttributeType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{(a=>(a[a.UNKNOWN=0]="UNKNOWN",a[a.VALUE=1]="VALUE",a[a.PARAM=2]="PARAM"))(i.DimensionValueType||(i.DimensionValueType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{(a=>(a[a.UNDEFINED=0]="UNDEFINED",a[a.FLOAT=1]="FLOAT",a[a.UINT8=2]="UINT8",a[a.INT8=3]="INT8",a[a.UINT16=4]="UINT16",a[a.INT16=5]="INT16",a[a.INT32=6]="INT32",a[a.INT64=7]="INT64",a[a.STRING=8]="STRING",a[a.BOOL=9]="BOOL",a[a.FLOAT16=10]="FLOAT16",a[a.DOUBLE=11]="DOUBLE",a[a.UINT32=12]="UINT32",a[a.UINT64=13]="UINT64",a[a.COMPLEX64=14]="COMPLEX64",a[a.COMPLEX128=15]="COMPLEX128",a[a.BFLOAT16=16]="BFLOAT16",a[a.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",a[a.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",a[a.FLOAT8E5M2=19]="FLOAT8E5M2",a[a.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"))(i.TensorDataType||(i.TensorDataType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{(a=>(a[a.Primitive=0]="Primitive",a[a.Fused=1]="Fused"))(i.NodeType||(i.NodeType={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{(a=>(a[a.NONE=0]="NONE",a[a.tensor_type=1]="tensor_type",a[a.sequence_type=2]="sequence_type",a[a.map_type=3]="map_type"))(i.TypeInfoValue||(i.TypeInfoValue={}))})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsShape(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsShape(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}dim(o,s){let c=this.bb.__offset(this.bb_pos,4);return c?(s||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}dimLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}static startShape(o){o.startObject(1)}static addDim(o,s){o.addFieldOffset(0,s,0)}static createDimVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startDimVector(o,s){o.startVector(4,s,4)}static endShape(o){return o.endObject()}static createShape(o,s){return a.startShape(o),a.addDim(o,s),a.endShape(o)}}i.Shape=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsDimension(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimension(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}value(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}denotation(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}static startDimension(o){o.startObject(2)}static addValue(o,s){o.addFieldOffset(0,s,0)}static addDenotation(o,s){o.addFieldOffset(1,s,0)}static endDimension(o){return o.endObject()}static createDimension(o,s,c){return a.startDimension(o),a.addValue(o,s),a.addDenotation(o,c),a.endDimension(o)}}i.Dimension=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsDimensionValue(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsDimensionValue(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}dimType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt8(this.bb_pos+o):0}dimValue(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}dimParam(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}static startDimensionValue(o){o.startObject(3)}static addDimType(o,s){o.addFieldInt8(0,s,0)}static addDimValue(o,s){o.addFieldInt64(1,s,o.createLong(0,0))}static addDimParam(o,s){o.addFieldOffset(2,s,0)}static endDimensionValue(o){return o.endObject()}static createDimensionValue(o,s,c,h){return a.startDimensionValue(o),a.addDimType(o,s),a.addDimValue(o,c),a.addDimParam(o,h),a.endDimensionValue(o)}}i.DimensionValue=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTensorTypeAndShape(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensorTypeAndShape(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}elemType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}shape(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startTensorTypeAndShape(o){o.startObject(2)}static addElemType(o,s){o.addFieldInt32(0,s,0)}static addShape(o,s){o.addFieldOffset(1,s,0)}static endTensorTypeAndShape(o){return o.endObject()}static createTensorTypeAndShape(o,s,c){return a.startTensorTypeAndShape(o),a.addElemType(o,s),a.addShape(o,c),a.endTensorTypeAndShape(o)}}i.TensorTypeAndShape=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsMapType(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsMapType(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}keyType(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt32(this.bb_pos+o):0}valueType(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startMapType(o){o.startObject(2)}static addKeyType(o,s){o.addFieldInt32(0,s,0)}static addValueType(o,s){o.addFieldOffset(1,s,0)}static endMapType(o){return o.endObject()}static createMapType(o,s,c){return a.startMapType(o),a.addKeyType(o,s),a.addValueType(o,c),a.endMapType(o)}}i.MapType=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSequenceType(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSequenceType(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}elemType(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSequenceType(o){o.startObject(1)}static addElemType(o,s){o.addFieldOffset(0,s,0)}static endSequenceType(o){return o.endObject()}static createSequenceType(o,s){return a.startSequenceType(o),a.addElemType(o,s),a.endSequenceType(o)}}i.SequenceType=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,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(o,s,c,h){return o.prep(4,12),o.writeInt32(h),o.writeInt32(c),o.writeInt32(s),o.offset()}}i.EdgeEnd=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsNodeEdge(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNodeEdge(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}nodeIndex(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readUint32(this.bb_pos+o):0}inputEdges(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+o*12,this.bb):null}inputEdgesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}outputEdges(o,s){let c=this.bb.__offset(this.bb_pos,8);return c?(s||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+o*12,this.bb):null}outputEdgesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNodeEdge(o){o.startObject(3)}static addNodeIndex(o,s){o.addFieldInt32(0,s,0)}static addInputEdges(o,s){o.addFieldOffset(1,s,0)}static startInputEdgesVector(o,s){o.startVector(12,s,4)}static addOutputEdges(o,s){o.addFieldOffset(2,s,0)}static startOutputEdgesVector(o,s){o.startVector(12,s,4)}static endNodeEdge(o){return o.endObject()}static createNodeEdge(o,s,c,h){return a.startNodeEdge(o),a.addNodeIndex(o,s),a.addInputEdges(o,c),a.addOutputEdges(o,h),a.endNodeEdge(o)}}i.NodeEdge=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsNode(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsNode(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}domain(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}sinceVersion(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}index(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readUint32(this.bb_pos+o):0}opType(o){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,o):null}type(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.readInt32(this.bb_pos+o):0}executionProviderType(o){let s=this.bb.__offset(this.bb_pos,18);return s?this.bb.__string(this.bb_pos+s,o):null}inputs(o,s){let c=this.bb.__offset(this.bb_pos,20);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,s){let c=this.bb.__offset(this.bb_pos,22);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}attributes(o,s){let c=this.bb.__offset(this.bb_pos,24);return c?(s||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}attributesLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCounts(o){let s=this.bb.__offset(this.bb_pos,26);return s?this.bb.readInt32(this.bb.__vector(this.bb_pos+s)+o*4):0}inputArgCountsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}inputArgCountsArray(){let o=this.bb.__offset(this.bb_pos,26);return o?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}implicitInputs(o,s){let c=this.bb.__offset(this.bb_pos,28);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}implicitInputsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startNode(o){o.startObject(13)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addDomain(o,s){o.addFieldOffset(2,s,0)}static addSinceVersion(o,s){o.addFieldInt32(3,s,0)}static addIndex(o,s){o.addFieldInt32(4,s,0)}static addOpType(o,s){o.addFieldOffset(5,s,0)}static addType(o,s){o.addFieldInt32(6,s,0)}static addExecutionProviderType(o,s){o.addFieldOffset(7,s,0)}static addInputs(o,s){o.addFieldOffset(8,s,0)}static createInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInputsVector(o,s){o.startVector(4,s,4)}static addOutputs(o,s){o.addFieldOffset(9,s,0)}static createOutputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOutputsVector(o,s){o.startVector(4,s,4)}static addAttributes(o,s){o.addFieldOffset(10,s,0)}static createAttributesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startAttributesVector(o,s){o.startVector(4,s,4)}static addInputArgCounts(o,s){o.addFieldOffset(11,s,0)}static createInputArgCountsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addInt32(s[c]);return o.endVector()}static startInputArgCountsVector(o,s){o.startVector(4,s,4)}static addImplicitInputs(o,s){o.addFieldOffset(12,s,0)}static createImplicitInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startImplicitInputsVector(o,s){o.startVector(4,s,4)}static endNode(o){return o.endObject()}static createNode(o,s,c,h,r,u,l,f,g,b,v,S,P,_){return a.startNode(o),a.addName(o,s),a.addDocString(o,c),a.addDomain(o,h),a.addSinceVersion(o,r),a.addIndex(o,u),a.addOpType(o,l),a.addType(o,f),a.addExecutionProviderType(o,g),a.addInputs(o,b),a.addOutputs(o,v),a.addAttributes(o,S),a.addInputArgCounts(o,P),a.addImplicitInputs(o,_),a.endNode(o)}}i.Node=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsValueInfo(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsValueInfo(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}type(o){let s=this.bb.__offset(this.bb_pos,8);return s?(o||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startValueInfo(o){o.startObject(3)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addType(o,s){o.addFieldOffset(2,s,0)}static endValueInfo(o){return o.endObject()}static createValueInfo(o,s,c,h){return a.startValueInfo(o),a.addName(o,s),a.addDocString(o,c),a.addType(o,h),a.endValueInfo(o)}}i.ValueInfo=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTypeInfo(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTypeInfo(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}denotation(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}valueType(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readUint8(this.bb_pos+o):0}value(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__union(o,this.bb_pos+s):null}static startTypeInfo(o){o.startObject(3)}static addDenotation(o,s){o.addFieldOffset(0,s,0)}static addValueType(o,s){o.addFieldInt8(1,s,0)}static addValue(o,s){o.addFieldOffset(2,s,0)}static endTypeInfo(o){return o.endObject()}static createTypeInfo(o,s,c,h){return a.startTypeInfo(o),a.addDenotation(o,s),a.addValueType(o,c),a.addValue(o,h),a.endTypeInfo(o)}}i.TypeInfo=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsOperatorSetId(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsOperatorSetId(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}domain(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}version(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}static startOperatorSetId(o){o.startObject(2)}static addDomain(o,s){o.addFieldOffset(0,s,0)}static addVersion(o,s){o.addFieldInt64(1,s,o.createLong(0,0))}static endOperatorSetId(o){return o.endObject()}static createOperatorSetId(o,s,c){return a.startOperatorSetId(o),a.addDomain(o,s),a.addVersion(o,c),a.endOperatorSetId(o)}}i.OperatorSetId=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsTensor(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsTensor(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}dims(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}dataType(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readInt32(this.bb_pos+o):0}rawData(o){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.readUint8(this.bb.__vector(this.bb_pos+s)+o):0}rawDataLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}rawDataArray(){let o=this.bb.__offset(this.bb_pos,12);return o?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}stringData(o,s){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}stringDataLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}static startTensor(o){o.startObject(6)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addDims(o,s){o.addFieldOffset(2,s,0)}static createDimsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startDimsVector(o,s){o.startVector(8,s,8)}static addDataType(o,s){o.addFieldInt32(3,s,0)}static addRawData(o,s){o.addFieldOffset(4,s,0)}static createRawDataVector(o,s){o.startVector(1,s.length,1);for(let c=s.length-1;c>=0;c--)o.addInt8(s[c]);return o.endVector()}static startRawDataVector(o,s){o.startVector(1,s,1)}static addStringData(o,s){o.addFieldOffset(5,s,0)}static createStringDataVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startStringDataVector(o,s){o.startVector(4,s,4)}static endTensor(o){return o.endObject()}static createTensor(o,s,c,h,r,u,l){return a.startTensor(o),a.addName(o,s),a.addDocString(o,c),a.addDims(o,h),a.addDataType(o,r),a.addRawData(o,u),a.addStringData(o,l),a.endTensor(o)}}i.Tensor=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSparseTensor(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSparseTensor(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}values(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}indices(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}dims(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}dimsLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSparseTensor(o){o.startObject(3)}static addValues(o,s){o.addFieldOffset(0,s,0)}static addIndices(o,s){o.addFieldOffset(1,s,0)}static addDims(o,s){o.addFieldOffset(2,s,0)}static createDimsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startDimsVector(o,s){o.startVector(8,s,8)}static endSparseTensor(o){return o.endObject()}static createSparseTensor(o,s,c,h){return a.startSparseTensor(o),a.addValues(o,s),a.addIndices(o,c),a.addDims(o,h),a.endSparseTensor(o)}}i.SparseTensor=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsAttribute(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsAttribute(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}name(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}docString(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,o):null}type(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt32(this.bb_pos+o):0}f(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readFloat32(this.bb_pos+o):0}i(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}s(o){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,o):null}t(o){let s=this.bb.__offset(this.bb_pos,16);return s?(o||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}g(o){let s=this.bb.__offset(this.bb_pos,18);return s?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}floats(o){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.readFloat32(this.bb.__vector(this.bb_pos+s)+o*4):0}floatsLength(){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__vector_len(this.bb_pos+o):0}floatsArray(){let o=this.bb.__offset(this.bb_pos,20);return o?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}ints(o){let s=this.bb.__offset(this.bb_pos,22);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}intsLength(){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.__vector_len(this.bb_pos+o):0}strings(o,s){let c=this.bb.__offset(this.bb_pos,24);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}stringsLength(){let o=this.bb.__offset(this.bb_pos,24);return o?this.bb.__vector_len(this.bb_pos+o):0}tensors(o,s){let c=this.bb.__offset(this.bb_pos,26);return c?(s||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}tensorsLength(){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.__vector_len(this.bb_pos+o):0}graphs(o,s){let c=this.bb.__offset(this.bb_pos,28);return c?(s||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}graphsLength(){let o=this.bb.__offset(this.bb_pos,28);return o?this.bb.__vector_len(this.bb_pos+o):0}static startAttribute(o){o.startObject(13)}static addName(o,s){o.addFieldOffset(0,s,0)}static addDocString(o,s){o.addFieldOffset(1,s,0)}static addType(o,s){o.addFieldInt32(2,s,0)}static addF(o,s){o.addFieldFloat32(3,s,0)}static addI(o,s){o.addFieldInt64(4,s,o.createLong(0,0))}static addS(o,s){o.addFieldOffset(5,s,0)}static addT(o,s){o.addFieldOffset(6,s,0)}static addG(o,s){o.addFieldOffset(7,s,0)}static addFloats(o,s){o.addFieldOffset(8,s,0)}static createFloatsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addFloat32(s[c]);return o.endVector()}static startFloatsVector(o,s){o.startVector(4,s,4)}static addInts(o,s){o.addFieldOffset(9,s,0)}static createIntsVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startIntsVector(o,s){o.startVector(8,s,8)}static addStrings(o,s){o.addFieldOffset(10,s,0)}static createStringsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startStringsVector(o,s){o.startVector(4,s,4)}static addTensors(o,s){o.addFieldOffset(11,s,0)}static createTensorsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startTensorsVector(o,s){o.startVector(4,s,4)}static addGraphs(o,s){o.addFieldOffset(12,s,0)}static createGraphsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startGraphsVector(o,s){o.startVector(4,s,4)}static endAttribute(o){return o.endObject()}static createAttribute(o,s,c,h,r,u,l,f,g,b,v,S,P,_){return a.startAttribute(o),a.addName(o,s),a.addDocString(o,c),a.addType(o,h),a.addF(o,r),a.addI(o,u),a.addS(o,l),a.addT(o,f),a.addG(o,g),a.addFloats(o,b),a.addInts(o,v),a.addStrings(o,S),a.addTensors(o,P),a.addGraphs(o,_),a.endAttribute(o)}}i.Attribute=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsGraph(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsGraph(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}initializers(o,s){let c=this.bb.__offset(this.bb_pos,4);return c?(s||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}initializersLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeArgs(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodeArgsLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}nodes(o,s){let c=this.bb.__offset(this.bb_pos,8);return c?(s||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodesLength(){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__vector_len(this.bb_pos+o):0}maxNodeIndex(){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.readUint32(this.bb_pos+o):0}nodeEdges(o,s){let c=this.bb.__offset(this.bb_pos,12);return c?(s||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}nodeEdgesLength(){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__vector_len(this.bb_pos+o):0}inputs(o,s){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}inputsLength(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__vector_len(this.bb_pos+o):0}outputs(o,s){let c=this.bb.__offset(this.bb_pos,16);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+o*4,s):null}outputsLength(){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.__vector_len(this.bb_pos+o):0}sparseInitializers(o,s){let c=this.bb.__offset(this.bb_pos,18);return c?(s||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}sparseInitializersLength(){let o=this.bb.__offset(this.bb_pos,18);return o?this.bb.__vector_len(this.bb_pos+o):0}static startGraph(o){o.startObject(8)}static addInitializers(o,s){o.addFieldOffset(0,s,0)}static createInitializersVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInitializersVector(o,s){o.startVector(4,s,4)}static addNodeArgs(o,s){o.addFieldOffset(1,s,0)}static createNodeArgsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodeArgsVector(o,s){o.startVector(4,s,4)}static addNodes(o,s){o.addFieldOffset(2,s,0)}static createNodesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodesVector(o,s){o.startVector(4,s,4)}static addMaxNodeIndex(o,s){o.addFieldInt32(3,s,0)}static addNodeEdges(o,s){o.addFieldOffset(4,s,0)}static createNodeEdgesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startNodeEdgesVector(o,s){o.startVector(4,s,4)}static addInputs(o,s){o.addFieldOffset(5,s,0)}static createInputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startInputsVector(o,s){o.startVector(4,s,4)}static addOutputs(o,s){o.addFieldOffset(6,s,0)}static createOutputsVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOutputsVector(o,s){o.startVector(4,s,4)}static addSparseInitializers(o,s){o.addFieldOffset(7,s,0)}static createSparseInitializersVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startSparseInitializersVector(o,s){o.startVector(4,s,4)}static endGraph(o){return o.endObject()}static createGraph(o,s,c,h,r,u,l,f,g){return a.startGraph(o),a.addInitializers(o,s),a.addNodeArgs(o,c),a.addNodes(o,h),a.addMaxNodeIndex(o,r),a.addNodeEdges(o,u),a.addInputs(o,l),a.addOutputs(o,f),a.addSparseInitializers(o,g),a.endGraph(o)}}i.Graph=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsModel(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsModel(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}irVersion(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}opsetImport(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}opsetImportLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}producerName(o){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,o):null}producerVersion(o){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.__string(this.bb_pos+s,o):null}domain(o){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.__string(this.bb_pos+s,o):null}modelVersion(){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.readInt64(this.bb_pos+o):this.bb.createLong(0,0)}docString(o){let s=this.bb.__offset(this.bb_pos,16);return s?this.bb.__string(this.bb_pos+s,o):null}graph(o){let s=this.bb.__offset(this.bb_pos,18);return s?(o||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}graphDocString(o){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.__string(this.bb_pos+s,o):null}static startModel(o){o.startObject(9)}static addIrVersion(o,s){o.addFieldInt64(0,s,o.createLong(0,0))}static addOpsetImport(o,s){o.addFieldOffset(1,s,0)}static createOpsetImportVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startOpsetImportVector(o,s){o.startVector(4,s,4)}static addProducerName(o,s){o.addFieldOffset(2,s,0)}static addProducerVersion(o,s){o.addFieldOffset(3,s,0)}static addDomain(o,s){o.addFieldOffset(4,s,0)}static addModelVersion(o,s){o.addFieldInt64(5,s,o.createLong(0,0))}static addDocString(o,s){o.addFieldOffset(6,s,0)}static addGraph(o,s){o.addFieldOffset(7,s,0)}static addGraphDocString(o,s){o.addFieldOffset(8,s,0)}static endModel(o){return o.endObject()}static createModel(o,s,c,h,r,u,l,f,g,b){return a.startModel(o),a.addIrVersion(o,s),a.addOpsetImport(o,c),a.addProducerName(o,h),a.addProducerVersion(o,r),a.addDomain(o,u),a.addModelVersion(o,l),a.addDocString(o,f),a.addGraph(o,g),a.addGraphDocString(o,b),a.endModel(o)}}i.Model=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsKernelCreateInfos(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsKernelCreateInfos(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}nodeIndices(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readUint32(this.bb.__vector(this.bb_pos+s)+o*4):0}nodeIndicesLength(){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__vector_len(this.bb_pos+o):0}nodeIndicesArray(){let o=this.bb.__offset(this.bb_pos,4);return o?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+o),this.bb.__vector_len(this.bb_pos+o)):null}kernelDefHashes(o){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readUint64(this.bb.__vector(this.bb_pos+s)+o*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startKernelCreateInfos(o){o.startObject(2)}static addNodeIndices(o,s){o.addFieldOffset(0,s,0)}static createNodeIndicesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addInt32(s[c]);return o.endVector()}static startNodeIndicesVector(o,s){o.startVector(4,s,4)}static addKernelDefHashes(o,s){o.addFieldOffset(1,s,0)}static createKernelDefHashesVector(o,s){o.startVector(8,s.length,8);for(let c=s.length-1;c>=0;c--)o.addInt64(s[c]);return o.endVector()}static startKernelDefHashesVector(o,s){o.startVector(8,s,8)}static endKernelCreateInfos(o){return o.endObject()}static createKernelCreateInfos(o,s,c){return a.startKernelCreateInfos(o),a.addNodeIndices(o,s),a.addKernelDefHashes(o,c),a.endKernelCreateInfos(o)}}i.KernelCreateInfos=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSubGraphSessionState(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSubGraphSessionState(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}graphId(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}sessionState(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSubGraphSessionState(o){o.startObject(2)}static addGraphId(o,s){o.addFieldOffset(0,s,0)}static addSessionState(o,s){o.addFieldOffset(1,s,0)}static endSubGraphSessionState(o){let s=o.endObject();return o.requiredField(s,4),s}static createSubGraphSessionState(o,s,c){return a.startSubGraphSessionState(o),a.addGraphId(o,s),a.addSessionState(o,c),a.endSubGraphSessionState(o)}}i.SubGraphSessionState=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsSessionState(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsSessionState(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}kernels(o){let s=this.bb.__offset(this.bb_pos,4);return s?(o||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}subGraphSessionStates(o,s){let c=this.bb.__offset(this.bb_pos,6);return c?(s||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+o*4),this.bb):null}subGraphSessionStatesLength(){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__vector_len(this.bb_pos+o):0}static startSessionState(o){o.startObject(2)}static addKernels(o,s){o.addFieldOffset(0,s,0)}static addSubGraphSessionStates(o,s){o.addFieldOffset(1,s,0)}static createSubGraphSessionStatesVector(o,s){o.startVector(4,s.length,4);for(let c=s.length-1;c>=0;c--)o.addOffset(s[c]);return o.endVector()}static startSubGraphSessionStatesVector(o,s){o.startVector(4,s,4)}static endSessionState(o){return o.endObject()}static createSessionState(o,s,c){return a.startSessionState(o),a.addKernels(o,s),a.addSubGraphSessionStates(o,c),a.endSessionState(o)}}i.SessionState=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={})),(e=>{(n=>{(i=>{class a{constructor(){this.bb=null,this.bb_pos=0}__init(o,s){return this.bb_pos=o,this.bb=s,this}static getRootAsInferenceSession(o,s){return(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static getSizePrefixedRootAsInferenceSession(o,s){return o.setPosition(o.position()+w.SIZE_PREFIX_LENGTH),(s||new a).__init(o.readInt32(o.position())+o.position(),o)}static bufferHasIdentifier(o){return o.__has_identifier("ORTM")}ortVersion(o){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,o):null}model(o){let s=this.bb.__offset(this.bb_pos,6);return s?(o||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}sessionState(o){let s=this.bb.__offset(this.bb_pos,8);return s?(o||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startInferenceSession(o){o.startObject(3)}static addOrtVersion(o,s){o.addFieldOffset(0,s,0)}static addModel(o,s){o.addFieldOffset(1,s,0)}static addSessionState(o,s){o.addFieldOffset(2,s,0)}static endInferenceSession(o){return o.endObject()}static finishInferenceSessionBuffer(o,s){o.finish(s,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(o,s){o.finish(s,"ORTM",!0)}static createInferenceSession(o,s,c,h){return a.startInferenceSession(o),a.addOrtVersion(o,s),a.addModel(o,c),a.addSessionState(o,h),a.endInferenceSession(o)}}i.InferenceSession=a})(n.fbs||(n.fbs={}))})(e.experimental||(e.experimental={}))})(F||(F={}))}),js=mt((e,n)=>{n.exports=i;function i(a,p){for(var o=new Array(arguments.length-1),s=0,c=2,h=!0;c<arguments.length;)o[s++]=arguments[c++];return new Promise(function(r,u){o[s]=function(l){if(h)if(h=!1,l)u(l);else{for(var f=new Array(arguments.length-1),g=0;g<f.length;)f[g++]=arguments[g];r.apply(null,f)}};try{a.apply(p||null,o)}catch(l){h&&(h=!1,u(l))}})}}),Ys=mt(e=>{var n=e;n.length=function(s){var c=s.length;if(!c)return 0;for(var h=0;--c%4>1&&s.charAt(c)==="=";)++h;return Math.ceil(s.length*3)/4-h};var i=new Array(64),a=new Array(123);for(p=0;p<64;)a[i[p]=p<26?p+65:p<52?p+71:p<62?p-4:p-59|43]=p++;var p;n.encode=function(s,c,h){for(var r=null,u=[],l=0,f=0,g;c<h;){var b=s[c++];switch(f){case 0:u[l++]=i[b>>2],g=(b&3)<<4,f=1;break;case 1:u[l++]=i[g|b>>4],g=(b&15)<<2,f=2;break;case 2:u[l++]=i[g|b>>6],u[l++]=i[b&63],f=0;break}l>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,u)),l=0)}return f&&(u[l++]=i[g],u[l++]=61,f===1&&(u[l++]=61)),r?(l&&r.push(String.fromCharCode.apply(String,u.slice(0,l))),r.join("")):String.fromCharCode.apply(String,u.slice(0,l))};var o="invalid encoding";n.decode=function(s,c,h){for(var r=h,u=0,l,f=0;f<s.length;){var g=s.charCodeAt(f++);if(g===61&&u>1)break;if((g=a[g])===void 0)throw Error(o);switch(u){case 0:l=g,u=1;break;case 1:c[h++]=l<<2|(g&48)>>4,l=g,u=2;break;case 2:c[h++]=(l&15)<<4|(g&60)>>2,l=g,u=3;break;case 3:c[h++]=(l&3)<<6|g,u=0;break}}if(u===1)throw Error(o);return h-r},n.test=function(s){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)}}),Qs=mt((e,n)=>{n.exports=i;function i(){this._listeners={}}i.prototype.on=function(a,p,o){return(this._listeners[a]||(this._listeners[a]=[])).push({fn:p,ctx:o||this}),this},i.prototype.off=function(a,p){if(a===void 0)this._listeners={};else if(p===void 0)this._listeners[a]=[];else for(var o=this._listeners[a],s=0;s<o.length;)o[s].fn===p?o.splice(s,1):++s;return this},i.prototype.emit=function(a){var p=this._listeners[a];if(p){for(var o=[],s=1;s<arguments.length;)o.push(arguments[s++]);for(s=0;s<p.length;)p[s].fn.apply(p[s++].ctx,o)}return this}}),au=mt((e,n)=>{n.exports=i(i);function i(c){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),r=new Uint8Array(h.buffer),u=r[3]===128;function l(v,S,P){h[0]=v,S[P]=r[0],S[P+1]=r[1],S[P+2]=r[2],S[P+3]=r[3]}function f(v,S,P){h[0]=v,S[P]=r[3],S[P+1]=r[2],S[P+2]=r[1],S[P+3]=r[0]}c.writeFloatLE=u?l:f,c.writeFloatBE=u?f:l;function g(v,S){return r[0]=v[S],r[1]=v[S+1],r[2]=v[S+2],r[3]=v[S+3],h[0]}function b(v,S){return r[3]=v[S],r[2]=v[S+1],r[1]=v[S+2],r[0]=v[S+3],h[0]}c.readFloatLE=u?g:b,c.readFloatBE=u?b:g}():function(){function h(u,l,f,g){var b=l<0?1:0;if(b&&(l=-l),l===0)u(1/l>0?0:2147483648,f,g);else if(isNaN(l))u(2143289344,f,g);else if(l>34028234663852886e22)u((b<<31|2139095040)>>>0,f,g);else if(l<11754943508222875e-54)u((b<<31|Math.round(l/1401298464324817e-60))>>>0,f,g);else{var v=Math.floor(Math.log(l)/Math.LN2),S=Math.round(l*Math.pow(2,-v)*8388608)&8388607;u((b<<31|v+127<<23|S)>>>0,f,g)}}c.writeFloatLE=h.bind(null,a),c.writeFloatBE=h.bind(null,p);function r(u,l,f){var g=u(l,f),b=(g>>31)*2+1,v=g>>>23&255,S=g&8388607;return v===255?S?NaN:b*(1/0):v===0?b*1401298464324817e-60*S:b*Math.pow(2,v-150)*(S+8388608)}c.readFloatLE=r.bind(null,o),c.readFloatBE=r.bind(null,s)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),r=new Uint8Array(h.buffer),u=r[7]===128;function l(v,S,P){h[0]=v,S[P]=r[0],S[P+1]=r[1],S[P+2]=r[2],S[P+3]=r[3],S[P+4]=r[4],S[P+5]=r[5],S[P+6]=r[6],S[P+7]=r[7]}function f(v,S,P){h[0]=v,S[P]=r[7],S[P+1]=r[6],S[P+2]=r[5],S[P+3]=r[4],S[P+4]=r[3],S[P+5]=r[2],S[P+6]=r[1],S[P+7]=r[0]}c.writeDoubleLE=u?l:f,c.writeDoubleBE=u?f:l;function g(v,S){return r[0]=v[S],r[1]=v[S+1],r[2]=v[S+2],r[3]=v[S+3],r[4]=v[S+4],r[5]=v[S+5],r[6]=v[S+6],r[7]=v[S+7],h[0]}function b(v,S){return r[7]=v[S],r[6]=v[S+1],r[5]=v[S+2],r[4]=v[S+3],r[3]=v[S+4],r[2]=v[S+5],r[1]=v[S+6],r[0]=v[S+7],h[0]}c.readDoubleLE=u?g:b,c.readDoubleBE=u?b:g}():function(){function h(u,l,f,g,b,v){var S=g<0?1:0;if(S&&(g=-g),g===0)u(0,b,v+l),u(1/g>0?0:2147483648,b,v+f);else if(isNaN(g))u(0,b,v+l),u(2146959360,b,v+f);else if(g>17976931348623157e292)u(0,b,v+l),u((S<<31|2146435072)>>>0,b,v+f);else{var P;if(g<22250738585072014e-324)P=g/5e-324,u(P>>>0,b,v+l),u((S<<31|P/4294967296)>>>0,b,v+f);else{var _=Math.floor(Math.log(g)/Math.LN2);_===1024&&(_=1023),P=g*Math.pow(2,-_),u(P*4503599627370496>>>0,b,v+l),u((S<<31|_+1023<<20|P*1048576&1048575)>>>0,b,v+f)}}}c.writeDoubleLE=h.bind(null,a,0,4),c.writeDoubleBE=h.bind(null,p,4,0);function r(u,l,f,g,b){var v=u(g,b+l),S=u(g,b+f),P=(S>>31)*2+1,_=S>>>20&2047,A=4294967296*(S&1048575)+v;return _===2047?A?NaN:P*(1/0):_===0?P*5e-324*A:P*Math.pow(2,_-1075)*(A+4503599627370496)}c.readDoubleLE=r.bind(null,o,0,4),c.readDoubleBE=r.bind(null,s,4,0)}(),c}function a(c,h,r){h[r]=c&255,h[r+1]=c>>>8&255,h[r+2]=c>>>16&255,h[r+3]=c>>>24}function p(c,h,r){h[r]=c>>>24,h[r+1]=c>>>16&255,h[r+2]=c>>>8&255,h[r+3]=c&255}function o(c,h){return(c[h]|c[h+1]<<8|c[h+2]<<16|c[h+3]<<24)>>>0}function s(c,h){return(c[h]<<24|c[h+1]<<16|c[h+2]<<8|c[h+3])>>>0}}),su=mt((exports,module)=>{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(e){}return null}}),lu=mt(e=>{var n=e;n.length=function(i){for(var a=0,p=0,o=0;o<i.length;++o)p=i.charCodeAt(o),p<128?a+=1:p<2048?a+=2:(p&64512)===55296&&(i.charCodeAt(o+1)&64512)===56320?(++o,a+=4):a+=3;return a},n.read=function(i,a,p){var o=p-a;if(o<1)return"";for(var s=null,c=[],h=0,r;a<p;)r=i[a++],r<128?c[h++]=r:r>191&&r<224?c[h++]=(r&31)<<6|i[a++]&63:r>239&&r<365?(r=((r&7)<<18|(i[a++]&63)<<12|(i[a++]&63)<<6|i[a++]&63)-65536,c[h++]=55296+(r>>10),c[h++]=56320+(r&1023)):c[h++]=(r&15)<<12|(i[a++]&63)<<6|i[a++]&63,h>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,c)),h=0);return s?(h&&s.push(String.fromCharCode.apply(String,c.slice(0,h))),s.join("")):String.fromCharCode.apply(String,c.slice(0,h))},n.write=function(i,a,p){for(var o=p,s,c,h=0;h<i.length;++h)s=i.charCodeAt(h),s<128?a[p++]=s:s<2048?(a[p++]=s>>6|192,a[p++]=s&63|128):(s&64512)===55296&&((c=i.charCodeAt(h+1))&64512)===56320?(s=65536+((s&1023)<<10)+(c&1023),++h,a[p++]=s>>18|240,a[p++]=s>>12&63|128,a[p++]=s>>6&63|128,a[p++]=s&63|128):(a[p++]=s>>12|224,a[p++]=s>>6&63|128,a[p++]=s&63|128);return p-o}}),cu=mt((e,n)=>{n.exports=i;function i(a,p,o){var s=o||8192,c=s>>>1,h=null,r=s;return function(u){if(u<1||u>c)return a(u);r+u>s&&(h=a(s),r=0);var l=p.call(h,r,r+=u);return r&7&&(r=(r|7)+1),l}}}),du=mt((e,n)=>{n.exports=a;var i=Se();function a(c,h){this.lo=c>>>0,this.hi=h>>>0}var p=a.zero=new a(0,0);p.toNumber=function(){return 0},p.zzEncode=p.zzDecode=function(){return this},p.length=function(){return 1};var o=a.zeroHash="\0\0\0\0\0\0\0\0";a.fromNumber=function(c){if(c===0)return p;var h=c<0;h&&(c=-c);var r=c>>>0,u=(c-r)/4294967296>>>0;return h&&(u=~u>>>0,r=~r>>>0,++r>4294967295&&(r=0,++u>4294967295&&(u=0))),new a(r,u)},a.from=function(c){if(typeof c=="number")return a.fromNumber(c);if(i.isString(c))if(i.Long)c=i.Long.fromString(c);else return a.fromNumber(parseInt(c,10));return c.low||c.high?new a(c.low>>>0,c.high>>>0):p},a.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var h=~this.lo+1>>>0,r=~this.hi>>>0;return h||(r=r+1>>>0),-(h+r*4294967296)}return this.lo+this.hi*4294967296},a.prototype.toLong=function(c){return i.Long?new i.Long(this.lo|0,this.hi|0,!!c):{low:this.lo|0,high:this.hi|0,unsigned:!!c}};var s=String.prototype.charCodeAt;a.fromHash=function(c){return c===o?p:new a((s.call(c,0)|s.call(c,1)<<8|s.call(c,2)<<16|s.call(c,3)<<24)>>>0,(s.call(c,4)|s.call(c,5)<<8|s.call(c,6)<<16|s.call(c,7)<<24)>>>0)},a.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)},a.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},a.prototype.zzDecode=function(){var c=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},a.prototype.length=function(){var c=this.lo,h=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?h===0?c<16384?c<128?1:2:c<2097152?3:4:h<16384?h<128?5:6:h<2097152?7:8:r<128?9:10}}),Se=mt(e=>{var n=e;n.asPromise=js(),n.base64=Ys(),n.EventEmitter=Qs(),n.float=au(),n.inquire=su(),n.utf8=lu(),n.pool=cu(),n.LongBits=du(),n.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),n.global=n.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||e,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(p){return typeof p=="number"&&isFinite(p)&&Math.floor(p)===p},n.isString=function(p){return typeof p=="string"||p instanceof String},n.isObject=function(p){return p&&typeof p=="object"},n.isset=n.isSet=function(p,o){var s=p[o];return s!=null&&p.hasOwnProperty(o)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},n.Buffer=function(){try{var p=n.inquire("buffer").Buffer;return p.prototype.utf8Write?p:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(p){return typeof p=="number"?n.Buffer?n._Buffer_allocUnsafe(p):new n.Array(p):n.Buffer?n._Buffer_from(p):typeof Uint8Array>"u"?p:new Uint8Array(p)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(p){return p?n.LongBits.from(p).toHash():n.LongBits.zeroHash},n.longFromHash=function(p,o){var s=n.LongBits.fromHash(p);return n.Long?n.Long.fromBits(s.lo,s.hi,o):s.toNumber(!!o)};function i(p,o,s){for(var c=Object.keys(o),h=0;h<c.length;++h)(p[c[h]]===void 0||!s)&&(p[c[h]]=o[c[h]]);return p}n.merge=i,n.lcFirst=function(p){return p.charAt(0).toLowerCase()+p.substring(1)};function a(p){function o(s,c){if(!(this instanceof o))return new o(s,c);Object.defineProperty(this,"message",{get:function(){return s}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),c&&i(this,c)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return p},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}n.newError=a,n.ProtocolError=a("ProtocolError"),n.oneOfGetter=function(p){for(var o={},s=0;s<p.length;++s)o[p[s]]=1;return function(){for(var c=Object.keys(this),h=c.length-1;h>-1;--h)if(o[c[h]]===1&&this[c[h]]!==void 0&&this[c[h]]!==null)return c[h]}},n.oneOfSetter=function(p){return function(o){for(var s=0;s<p.length;++s)p[s]!==o&&delete this[p[s]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var p=n.Buffer;if(!p){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=p.from!==Uint8Array.from&&p.from||function(o,s){return new p(o,s)},n._Buffer_allocUnsafe=p.allocUnsafe||function(o){return new p(o)}}}),ei=mt((e,n)=>{n.exports=u;var i=Se(),a,p=i.LongBits,o=i.base64,s=i.utf8;function c(_,A,L){this.fn=_,this.len=A,this.next=void 0,this.val=L}function h(){}function r(_){this.head=_.head,this.tail=_.tail,this.len=_.len,this.next=_.states}function u(){this.len=0,this.head=new c(h,0,0),this.tail=this.head,this.states=null}var l=function(){return i.Buffer?function(){return(u.create=function(){return new a})()}:function(){return new u}};u.create=l(),u.alloc=function(_){return new i.Array(_)},i.Array!==Array&&(u.alloc=i.pool(u.alloc,i.Array.prototype.subarray)),u.prototype._push=function(_,A,L){return this.tail=this.tail.next=new c(_,A,L),this.len+=A,this};function f(_,A,L){A[L]=_&255}function g(_,A,L){for(;_>127;)A[L++]=_&127|128,_>>>=7;A[L]=_}function b(_,A){this.len=_,this.next=void 0,this.val=A}b.prototype=Object.create(c.prototype),b.prototype.fn=g,u.prototype.uint32=function(_){return this.len+=(this.tail=this.tail.next=new b((_=_>>>0)<128?1:_<16384?2:_<2097152?3:_<268435456?4:5,_)).len,this},u.prototype.int32=function(_){return _<0?this._push(v,10,p.fromNumber(_)):this.uint32(_)},u.prototype.sint32=function(_){return this.uint32((_<<1^_>>31)>>>0)};function v(_,A,L){for(;_.hi;)A[L++]=_.lo&127|128,_.lo=(_.lo>>>7|_.hi<<25)>>>0,_.hi>>>=7;for(;_.lo>127;)A[L++]=_.lo&127|128,_.lo=_.lo>>>7;A[L++]=_.lo}u.prototype.uint64=function(_){var A=p.from(_);return this._push(v,A.length(),A)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(_){var A=p.from(_).zzEncode();return this._push(v,A.length(),A)},u.prototype.bool=function(_){return this._push(f,1,_?1:0)};function S(_,A,L){A[L]=_&255,A[L+1]=_>>>8&255,A[L+2]=_>>>16&255,A[L+3]=_>>>24}u.prototype.fixed32=function(_){return this._push(S,4,_>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(_){var A=p.from(_);return this._push(S,4,A.lo)._push(S,4,A.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(_){return this._push(i.float.writeFloatLE,4,_)},u.prototype.double=function(_){return this._push(i.float.writeDoubleLE,8,_)};var P=i.Array.prototype.set?function(_,A,L){A.set(_,L)}:function(_,A,L){for(var M=0;M<_.length;++M)A[L+M]=_[M]};u.prototype.bytes=function(_){var A=_.length>>>0;if(!A)return this._push(f,1,0);if(i.isString(_)){var L=u.alloc(A=o.length(_));o.decode(_,L,0),_=L}return this.uint32(A)._push(P,A,_)},u.prototype.string=function(_){var A=s.length(_);return A?this.uint32(A)._push(s.write,A,_):this._push(f,1,0)},u.prototype.fork=function(){return this.states=new r(this),this.head=this.tail=new c(h,0,0),this.len=0,this},u.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 c(h,0,0),this.len=0),this},u.prototype.ldelim=function(){var _=this.head,A=this.tail,L=this.len;return this.reset().uint32(L),L&&(this.tail.next=_.next,this.tail=A,this.len+=L),this},u.prototype.finish=function(){for(var _=this.head.next,A=this.constructor.alloc(this.len),L=0;_;)_.fn(_.val,A,L),L+=_.len,_=_.next;return A},u._configure=function(_){a=_,u.create=l(),a._configure()}}),vu=mt((e,n)=>{n.exports=p;var i=ei();(p.prototype=Object.create(i.prototype)).constructor=p;var a=Se();function p(){i.call(this)}p._configure=function(){p.alloc=a._Buffer_allocUnsafe,p.writeBytesBuffer=a.Buffer&&a.Buffer.prototype instanceof Uint8Array&&a.Buffer.prototype.set.name==="set"?function(s,c,h){c.set(s,h)}:function(s,c,h){if(s.copy)s.copy(c,h,0,s.length);else for(var r=0;r<s.length;)c[h++]=s[r++]}},p.prototype.bytes=function(s){a.isString(s)&&(s=a._Buffer_from(s,"base64"));var c=s.length>>>0;return this.uint32(c),c&&this._push(p.writeBytesBuffer,c,s),this};function o(s,c,h){s.length<40?a.utf8.write(s,c,h):c.utf8Write?c.utf8Write(s,h):c.write(s,h)}p.prototype.string=function(s){var c=a.Buffer.byteLength(s);return this.uint32(c),c&&this._push(o,c,s),this},p._configure()}),oi=mt((e,n)=>{n.exports=c;var i=Se(),a,p=i.LongBits,o=i.utf8;function s(g,b){return RangeError("index out of range: "+g.pos+" + "+(b||1)+" > "+g.len)}function c(g){this.buf=g,this.pos=0,this.len=g.length}var h=typeof Uint8Array<"u"?function(g){if(g instanceof Uint8Array||Array.isArray(g))return new c(g);throw Error("illegal buffer")}:function(g){if(Array.isArray(g))return new c(g);throw Error("illegal buffer")},r=function(){return i.Buffer?function(g){return(c.create=function(b){return i.Buffer.isBuffer(b)?new a(b):h(b)})(g)}:h};c.create=r(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=function(){var g=4294967295;return function(){if(g=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(g=(g|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(g=(g|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return g;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return g}}(),c.prototype.int32=function(){return this.uint32()|0},c.prototype.sint32=function(){var g=this.uint32();return g>>>1^-(g&1)|0};function u(){var g=new p(0,0),b=0;if(this.len-this.pos>4){for(;b<4;++b)if(g.lo=(g.lo|(this.buf[this.pos]&127)<<b*7)>>>0,this.buf[this.pos++]<128)return g;if(g.lo=(g.lo|(this.buf[this.pos]&127)<<28)>>>0,g.hi=(g.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return g;b=0}else{for(;b<3;++b){if(this.pos>=this.len)throw s(this);if(g.lo=(g.lo|(this.buf[this.pos]&127)<<b*7)>>>0,this.buf[this.pos++]<128)return g}return g.lo=(g.lo|(this.buf[this.pos++]&127)<<b*7)>>>0,g}if(this.len-this.pos>4){for(;b<5;++b)if(g.hi=(g.hi|(this.buf[this.pos]&127)<<b*7+3)>>>0,this.buf[this.pos++]<128)return g}else for(;b<5;++b){if(this.pos>=this.len)throw s(this);if(g.hi=(g.hi|(this.buf[this.pos]&127)<<b*7+3)>>>0,this.buf[this.pos++]<128)return g}throw Error("invalid varint encoding")}c.prototype.bool=function(){return this.uint32()!==0};function l(g,b){return(g[b-4]|g[b-3]<<8|g[b-2]<<16|g[b-1]<<24)>>>0}c.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)|0};function f(){if(this.pos+8>this.len)throw s(this,8);return new p(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}c.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var g=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,g},c.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var g=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,g},c.prototype.bytes=function(){var g=this.uint32(),b=this.pos,v=this.pos+g;if(v>this.len)throw s(this,g);if(this.pos+=g,Array.isArray(this.buf))return this.buf.slice(b,v);if(b===v){var S=i.Buffer;return S?S.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,b,v)},c.prototype.string=function(){var g=this.bytes();return o.read(g,0,g.length)},c.prototype.skip=function(g){if(typeof g=="number"){if(this.pos+g>this.len)throw s(this,g);this.pos+=g}else do if(this.pos>=this.len)throw s(this);while(this.buf[this.pos++]&128);return this},c.prototype.skipType=function(g){switch(g){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(g=this.uint32()&7)!==4;)this.skipType(g);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+g+" at offset "+this.pos)}return this},c._configure=function(g){a=g,c.create=r(),a._configure();var b=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return u.call(this)[b](!1)},uint64:function(){return u.call(this)[b](!0)},sint64:function(){return u.call(this).zzDecode()[b](!1)},fixed64:function(){return f.call(this)[b](!0)},sfixed64:function(){return f.call(this)[b](!1)}})}}),Lu=mt((e,n)=>{n.exports=p;var i=oi();(p.prototype=Object.create(i.prototype)).constructor=p;var a=Se();function p(o){i.call(this,o)}p._configure=function(){a.Buffer&&(p.prototype._slice=a.Buffer.prototype.slice)},p.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},p._configure()}),ku=mt((e,n)=>{n.exports=a;var i=Se();(a.prototype=Object.create(i.EventEmitter.prototype)).constructor=a;function a(p,o,s){if(typeof p!="function")throw TypeError("rpcImpl must be a function");i.EventEmitter.call(this),this.rpcImpl=p,this.requestDelimited=!!o,this.responseDelimited=!!s}a.prototype.rpcCall=function p(o,s,c,h,r){if(!h)throw TypeError("request must be specified");var u=this;if(!r)return i.asPromise(p,u,o,s,c,h);if(!u.rpcImpl){setTimeout(function(){r(Error("already ended"))},0);return}try{return u.rpcImpl(o,s[u.requestDelimited?"encodeDelimited":"encode"](h).finish(),function(l,f){if(l)return u.emit("error",l,o),r(l);if(f===null){u.end(!0);return}if(!(f instanceof c))try{f=c[u.responseDelimited?"decodeDelimited":"decode"](f)}catch(g){return u.emit("error",g,o),r(g)}return u.emit("data",f,o),r(null,f)})}catch(l){u.emit("error",l,o),setTimeout(function(){r(l)},0);return}},a.prototype.end=function(p){return this.rpcImpl&&(p||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),Fu=mt(e=>{var n=e;n.Service=ku()}),Nu=mt((e,n)=>{n.exports={}}),Mu=mt(e=>{var n=e;n.build="minimal",n.Writer=ei(),n.BufferWriter=vu(),n.Reader=oi(),n.BufferReader=Lu(),n.util=Se(),n.rpc=Fu(),n.roots=Nu(),n.configure=i;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}i()}),Vu=mt((e,n)=>{n.exports=Mu()}),sr=mt((e,n)=>{var i=Vu(),a=i.Reader,p=i.Writer,o=i.util,s=i.roots.default||(i.roots.default={});s.onnx=function(){var c={};return c.Version=function(){var h={},r=Object.create(h);return r[h[0]="_START_VERSION"]=0,r[h[1]="IR_VERSION_2017_10_10"]=1,r[h[2]="IR_VERSION_2017_10_30"]=2,r[h[3]="IR_VERSION_2017_11_3"]=3,r[h[4]="IR_VERSION_2019_1_22"]=4,r[h[5]="IR_VERSION_2019_3_18"]=5,r[h[6]="IR_VERSION_2019_9_19"]=6,r[h[7]="IR_VERSION_2020_5_8"]=7,r[h[8]="IR_VERSION_2021_7_30"]=8,r[h[9]="IR_VERSION"]=9,r}(),c.AttributeProto=function(){function h(r){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.refAttrName="",h.prototype.docString="",h.prototype.type=0,h.prototype.f=0,h.prototype.i=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.s=o.newBuffer([]),h.prototype.t=null,h.prototype.g=null,h.prototype.sparseTensor=null,h.prototype.tp=null,h.prototype.floats=o.emptyArray,h.prototype.ints=o.emptyArray,h.prototype.strings=o.emptyArray,h.prototype.tensors=o.emptyArray,h.prototype.graphs=o.emptyArray,h.prototype.sparseTensors=o.emptyArray,h.prototype.typeProtos=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.f!=null&&Object.hasOwnProperty.call(r,"f")&&u.uint32(21).float(r.f),r.i!=null&&Object.hasOwnProperty.call(r,"i")&&u.uint32(24).int64(r.i),r.s!=null&&Object.hasOwnProperty.call(r,"s")&&u.uint32(34).bytes(r.s),r.t!=null&&Object.hasOwnProperty.call(r,"t")&&s.onnx.TensorProto.encode(r.t,u.uint32(42).fork()).ldelim(),r.g!=null&&Object.hasOwnProperty.call(r,"g")&&s.onnx.GraphProto.encode(r.g,u.uint32(50).fork()).ldelim(),r.floats!=null&&r.floats.length){u.uint32(58).fork();for(var l=0;l<r.floats.length;++l)u.float(r.floats[l]);u.ldelim()}if(r.ints!=null&&r.ints.length){u.uint32(66).fork();for(var l=0;l<r.ints.length;++l)u.int64(r.ints[l]);u.ldelim()}if(r.strings!=null&&r.strings.length)for(var l=0;l<r.strings.length;++l)u.uint32(74).bytes(r.strings[l]);if(r.tensors!=null&&r.tensors.length)for(var l=0;l<r.tensors.length;++l)s.onnx.TensorProto.encode(r.tensors[l],u.uint32(82).fork()).ldelim();if(r.graphs!=null&&r.graphs.length)for(var l=0;l<r.graphs.length;++l)s.onnx.GraphProto.encode(r.graphs[l],u.uint32(90).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(106).string(r.docString),r.tp!=null&&Object.hasOwnProperty.call(r,"tp")&&s.onnx.TypeProto.encode(r.tp,u.uint32(114).fork()).ldelim(),r.typeProtos!=null&&r.typeProtos.length)for(var l=0;l<r.typeProtos.length;++l)s.onnx.TypeProto.encode(r.typeProtos[l],u.uint32(122).fork()).ldelim();if(r.type!=null&&Object.hasOwnProperty.call(r,"type")&&u.uint32(160).int32(r.type),r.refAttrName!=null&&Object.hasOwnProperty.call(r,"refAttrName")&&u.uint32(170).string(r.refAttrName),r.sparseTensor!=null&&Object.hasOwnProperty.call(r,"sparseTensor")&&s.onnx.SparseTensorProto.encode(r.sparseTensor,u.uint32(178).fork()).ldelim(),r.sparseTensors!=null&&r.sparseTensors.length)for(var l=0;l<r.sparseTensors.length;++l)s.onnx.SparseTensorProto.encode(r.sparseTensors[l],u.uint32(186).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.AttributeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 21:{f.refAttrName=r.string();break}case 13:{f.docString=r.string();break}case 20:{f.type=r.int32();break}case 2:{f.f=r.float();break}case 3:{f.i=r.int64();break}case 4:{f.s=r.bytes();break}case 5:{f.t=s.onnx.TensorProto.decode(r,r.uint32());break}case 6:{f.g=s.onnx.GraphProto.decode(r,r.uint32());break}case 22:{f.sparseTensor=s.onnx.SparseTensorProto.decode(r,r.uint32());break}case 14:{f.tp=s.onnx.TypeProto.decode(r,r.uint32());break}case 7:{if(f.floats&&f.floats.length||(f.floats=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.floats.push(r.float());else f.floats.push(r.float());break}case 8:{if(f.ints&&f.ints.length||(f.ints=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.ints.push(r.int64());else f.ints.push(r.int64());break}case 9:{f.strings&&f.strings.length||(f.strings=[]),f.strings.push(r.bytes());break}case 10:{f.tensors&&f.tensors.length||(f.tensors=[]),f.tensors.push(s.onnx.TensorProto.decode(r,r.uint32()));break}case 11:{f.graphs&&f.graphs.length||(f.graphs=[]),f.graphs.push(s.onnx.GraphProto.decode(r,r.uint32()));break}case 23:{f.sparseTensors&&f.sparseTensors.length||(f.sparseTensors=[]),f.sparseTensors.push(s.onnx.SparseTensorProto.decode(r,r.uint32()));break}case 15:{f.typeProtos&&f.typeProtos.length||(f.typeProtos=[]),f.typeProtos.push(s.onnx.TypeProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.refAttrName!=null&&r.hasOwnProperty("refAttrName")&&!o.isString(r.refAttrName))return"refAttrName: string expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.type!=null&&r.hasOwnProperty("type"))switch(r.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(r.f!=null&&r.hasOwnProperty("f")&&typeof r.f!="number")return"f: number expected";if(r.i!=null&&r.hasOwnProperty("i")&&!o.isInteger(r.i)&&!(r.i&&o.isInteger(r.i.low)&&o.isInteger(r.i.high)))return"i: integer|Long expected";if(r.s!=null&&r.hasOwnProperty("s")&&!(r.s&&typeof r.s.length=="number"||o.isString(r.s)))return"s: buffer expected";if(r.t!=null&&r.hasOwnProperty("t")){var u=s.onnx.TensorProto.verify(r.t);if(u)return"t."+u}if(r.g!=null&&r.hasOwnProperty("g")){var u=s.onnx.GraphProto.verify(r.g);if(u)return"g."+u}if(r.sparseTensor!=null&&r.hasOwnProperty("sparseTensor")){var u=s.onnx.SparseTensorProto.verify(r.sparseTensor);if(u)return"sparseTensor."+u}if(r.tp!=null&&r.hasOwnProperty("tp")){var u=s.onnx.TypeProto.verify(r.tp);if(u)return"tp."+u}if(r.floats!=null&&r.hasOwnProperty("floats")){if(!Array.isArray(r.floats))return"floats: array expected";for(var l=0;l<r.floats.length;++l)if(typeof r.floats[l]!="number")return"floats: number[] expected"}if(r.ints!=null&&r.hasOwnProperty("ints")){if(!Array.isArray(r.ints))return"ints: array expected";for(var l=0;l<r.ints.length;++l)if(!o.isInteger(r.ints[l])&&!(r.ints[l]&&o.isInteger(r.ints[l].low)&&o.isInteger(r.ints[l].high)))return"ints: integer|Long[] expected"}if(r.strings!=null&&r.hasOwnProperty("strings")){if(!Array.isArray(r.strings))return"strings: array expected";for(var l=0;l<r.strings.length;++l)if(!(r.strings[l]&&typeof r.strings[l].length=="number"||o.isString(r.strings[l])))return"strings: buffer[] expected"}if(r.tensors!=null&&r.hasOwnProperty("tensors")){if(!Array.isArray(r.tensors))return"tensors: array expected";for(var l=0;l<r.tensors.length;++l){var u=s.onnx.TensorProto.verify(r.tensors[l]);if(u)return"tensors."+u}}if(r.graphs!=null&&r.hasOwnProperty("graphs")){if(!Array.isArray(r.graphs))return"graphs: array expected";for(var l=0;l<r.graphs.length;++l){var u=s.onnx.GraphProto.verify(r.graphs[l]);if(u)return"graphs."+u}}if(r.sparseTensors!=null&&r.hasOwnProperty("sparseTensors")){if(!Array.isArray(r.sparseTensors))return"sparseTensors: array expected";for(var l=0;l<r.sparseTensors.length;++l){var u=s.onnx.SparseTensorProto.verify(r.sparseTensors[l]);if(u)return"sparseTensors."+u}}if(r.typeProtos!=null&&r.hasOwnProperty("typeProtos")){if(!Array.isArray(r.typeProtos))return"typeProtos: array expected";for(var l=0;l<r.typeProtos.length;++l){var u=s.onnx.TypeProto.verify(r.typeProtos[l]);if(u)return"typeProtos."+u}}return null},h.fromObject=function(r){if(r instanceof s.onnx.AttributeProto)return r;var u=new s.onnx.AttributeProto;switch(r.name!=null&&(u.name=String(r.name)),r.refAttrName!=null&&(u.refAttrName=String(r.refAttrName)),r.docString!=null&&(u.docString=String(r.docString)),r.type){default:if(typeof r.type=="number"){u.type=r.type;break}break;case"UNDEFINED":case 0:u.type=0;break;case"FLOAT":case 1:u.type=1;break;case"INT":case 2:u.type=2;break;case"STRING":case 3:u.type=3;break;case"TENSOR":case 4:u.type=4;break;case"GRAPH":case 5:u.type=5;break;case"SPARSE_TENSOR":case 11:u.type=11;break;case"TYPE_PROTO":case 13:u.type=13;break;case"FLOATS":case 6:u.type=6;break;case"INTS":case 7:u.type=7;break;case"STRINGS":case 8:u.type=8;break;case"TENSORS":case 9:u.type=9;break;case"GRAPHS":case 10:u.type=10;break;case"SPARSE_TENSORS":case 12:u.type=12;break;case"TYPE_PROTOS":case 14:u.type=14;break}if(r.f!=null&&(u.f=Number(r.f)),r.i!=null&&(o.Long?(u.i=o.Long.fromValue(r.i)).unsigned=!1:typeof r.i=="string"?u.i=parseInt(r.i,10):typeof r.i=="number"?u.i=r.i:typeof r.i=="object"&&(u.i=new o.LongBits(r.i.low>>>0,r.i.high>>>0).toNumber())),r.s!=null&&(typeof r.s=="string"?o.base64.decode(r.s,u.s=o.newBuffer(o.base64.length(r.s)),0):r.s.length>=0&&(u.s=r.s)),r.t!=null){if(typeof r.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");u.t=s.onnx.TensorProto.fromObject(r.t)}if(r.g!=null){if(typeof r.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");u.g=s.onnx.GraphProto.fromObject(r.g)}if(r.sparseTensor!=null){if(typeof r.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");u.sparseTensor=s.onnx.SparseTensorProto.fromObject(r.sparseTensor)}if(r.tp!=null){if(typeof r.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");u.tp=s.onnx.TypeProto.fromObject(r.tp)}if(r.floats){if(!Array.isArray(r.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");u.floats=[];for(var l=0;l<r.floats.length;++l)u.floats[l]=Number(r.floats[l])}if(r.ints){if(!Array.isArray(r.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");u.ints=[];for(var l=0;l<r.ints.length;++l)o.Long?(u.ints[l]=o.Long.fromValue(r.ints[l])).unsigned=!1:typeof r.ints[l]=="string"?u.ints[l]=parseInt(r.ints[l],10):typeof r.ints[l]=="number"?u.ints[l]=r.ints[l]:typeof r.ints[l]=="object"&&(u.ints[l]=new o.LongBits(r.ints[l].low>>>0,r.ints[l].high>>>0).toNumber())}if(r.strings){if(!Array.isArray(r.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");u.strings=[];for(var l=0;l<r.strings.length;++l)typeof r.strings[l]=="string"?o.base64.decode(r.strings[l],u.strings[l]=o.newBuffer(o.base64.length(r.strings[l])),0):r.strings[l].length>=0&&(u.strings[l]=r.strings[l])}if(r.tensors){if(!Array.isArray(r.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");u.tensors=[];for(var l=0;l<r.tensors.length;++l){if(typeof r.tensors[l]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");u.tensors[l]=s.onnx.TensorProto.fromObject(r.tensors[l])}}if(r.graphs){if(!Array.isArray(r.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");u.graphs=[];for(var l=0;l<r.graphs.length;++l){if(typeof r.graphs[l]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");u.graphs[l]=s.onnx.GraphProto.fromObject(r.graphs[l])}}if(r.sparseTensors){if(!Array.isArray(r.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");u.sparseTensors=[];for(var l=0;l<r.sparseTensors.length;++l){if(typeof r.sparseTensors[l]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");u.sparseTensors[l]=s.onnx.SparseTensorProto.fromObject(r.sparseTensors[l])}}if(r.typeProtos){if(!Array.isArray(r.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");u.typeProtos=[];for(var l=0;l<r.typeProtos.length;++l){if(typeof r.typeProtos[l]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");u.typeProtos[l]=s.onnx.TypeProto.fromObject(r.typeProtos[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.floats=[],l.ints=[],l.strings=[],l.tensors=[],l.graphs=[],l.typeProtos=[],l.sparseTensors=[]),u.defaults){if(l.name="",l.f=0,o.Long){var f=new o.Long(0,0,!1);l.i=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.i=u.longs===String?"0":0;u.bytes===String?l.s="":(l.s=[],u.bytes!==Array&&(l.s=o.newBuffer(l.s))),l.t=null,l.g=null,l.docString="",l.tp=null,l.type=u.enums===String?"UNDEFINED":0,l.refAttrName="",l.sparseTensor=null}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.f!=null&&r.hasOwnProperty("f")&&(l.f=u.json&&!isFinite(r.f)?String(r.f):r.f),r.i!=null&&r.hasOwnProperty("i")&&(typeof r.i=="number"?l.i=u.longs===String?String(r.i):r.i:l.i=u.longs===String?o.Long.prototype.toString.call(r.i):u.longs===Number?new o.LongBits(r.i.low>>>0,r.i.high>>>0).toNumber():r.i),r.s!=null&&r.hasOwnProperty("s")&&(l.s=u.bytes===String?o.base64.encode(r.s,0,r.s.length):u.bytes===Array?Array.prototype.slice.call(r.s):r.s),r.t!=null&&r.hasOwnProperty("t")&&(l.t=s.onnx.TensorProto.toObject(r.t,u)),r.g!=null&&r.hasOwnProperty("g")&&(l.g=s.onnx.GraphProto.toObject(r.g,u)),r.floats&&r.floats.length){l.floats=[];for(var g=0;g<r.floats.length;++g)l.floats[g]=u.json&&!isFinite(r.floats[g])?String(r.floats[g]):r.floats[g]}if(r.ints&&r.ints.length){l.ints=[];for(var g=0;g<r.ints.length;++g)typeof r.ints[g]=="number"?l.ints[g]=u.longs===String?String(r.ints[g]):r.ints[g]:l.ints[g]=u.longs===String?o.Long.prototype.toString.call(r.ints[g]):u.longs===Number?new o.LongBits(r.ints[g].low>>>0,r.ints[g].high>>>0).toNumber():r.ints[g]}if(r.strings&&r.strings.length){l.strings=[];for(var g=0;g<r.strings.length;++g)l.strings[g]=u.bytes===String?o.base64.encode(r.strings[g],0,r.strings[g].length):u.bytes===Array?Array.prototype.slice.call(r.strings[g]):r.strings[g]}if(r.tensors&&r.tensors.length){l.tensors=[];for(var g=0;g<r.tensors.length;++g)l.tensors[g]=s.onnx.TensorProto.toObject(r.tensors[g],u)}if(r.graphs&&r.graphs.length){l.graphs=[];for(var g=0;g<r.graphs.length;++g)l.graphs[g]=s.onnx.GraphProto.toObject(r.graphs[g],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.tp!=null&&r.hasOwnProperty("tp")&&(l.tp=s.onnx.TypeProto.toObject(r.tp,u)),r.typeProtos&&r.typeProtos.length){l.typeProtos=[];for(var g=0;g<r.typeProtos.length;++g)l.typeProtos[g]=s.onnx.TypeProto.toObject(r.typeProtos[g],u)}if(r.type!=null&&r.hasOwnProperty("type")&&(l.type=u.enums===String?s.onnx.AttributeProto.AttributeType[r.type]===void 0?r.type:s.onnx.AttributeProto.AttributeType[r.type]:r.type),r.refAttrName!=null&&r.hasOwnProperty("refAttrName")&&(l.refAttrName=r.refAttrName),r.sparseTensor!=null&&r.hasOwnProperty("sparseTensor")&&(l.sparseTensor=s.onnx.SparseTensorProto.toObject(r.sparseTensor,u)),r.sparseTensors&&r.sparseTensors.length){l.sparseTensors=[];for(var g=0;g<r.sparseTensors.length;++g)l.sparseTensors[g]=s.onnx.SparseTensorProto.toObject(r.sparseTensors[g],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.AttributeProto"},h.AttributeType=function(){var r={},u=Object.create(r);return u[r[0]="UNDEFINED"]=0,u[r[1]="FLOAT"]=1,u[r[2]="INT"]=2,u[r[3]="STRING"]=3,u[r[4]="TENSOR"]=4,u[r[5]="GRAPH"]=5,u[r[11]="SPARSE_TENSOR"]=11,u[r[13]="TYPE_PROTO"]=13,u[r[6]="FLOATS"]=6,u[r[7]="INTS"]=7,u[r[8]="STRINGS"]=8,u[r[9]="TENSORS"]=9,u[r[10]="GRAPHS"]=10,u[r[12]="SPARSE_TENSORS"]=12,u[r[14]="TYPE_PROTOS"]=14,u}(),h}(),c.ValueInfoProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.type=null,h.prototype.docString="",h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.type!=null&&Object.hasOwnProperty.call(r,"type")&&s.onnx.TypeProto.encode(r.type,u.uint32(18).fork()).ldelim(),r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(26).string(r.docString),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.ValueInfoProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 2:{f.type=s.onnx.TypeProto.decode(r,r.uint32());break}case 3:{f.docString=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.type!=null&&r.hasOwnProperty("type")){var u=s.onnx.TypeProto.verify(r.type);if(u)return"type."+u}return r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString)?"docString: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.ValueInfoProto)return r;var u=new s.onnx.ValueInfoProto;if(r.name!=null&&(u.name=String(r.name)),r.type!=null){if(typeof r.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");u.type=s.onnx.TypeProto.fromObject(r.type)}return r.docString!=null&&(u.docString=String(r.docString)),u},h.toObject=function(r,u){u||(u={});var l={};return u.defaults&&(l.name="",l.type=null,l.docString=""),r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.type!=null&&r.hasOwnProperty("type")&&(l.type=s.onnx.TypeProto.toObject(r.type,u)),r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.ValueInfoProto"},h}(),c.NodeProto=function(){function h(r){if(this.input=[],this.output=[],this.attribute=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.name="",h.prototype.opType="",h.prototype.domain="",h.prototype.attribute=o.emptyArray,h.prototype.docString="",h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)u.uint32(10).string(r.input[l]);if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)u.uint32(18).string(r.output[l]);if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(26).string(r.name),r.opType!=null&&Object.hasOwnProperty.call(r,"opType")&&u.uint32(34).string(r.opType),r.attribute!=null&&r.attribute.length)for(var l=0;l<r.attribute.length;++l)s.onnx.AttributeProto.encode(r.attribute[l],u.uint32(42).fork()).ldelim();return r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(50).string(r.docString),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(58).string(r.domain),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.NodeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.input&&f.input.length||(f.input=[]),f.input.push(r.string());break}case 2:{f.output&&f.output.length||(f.output=[]),f.output.push(r.string());break}case 3:{f.name=r.string();break}case 4:{f.opType=r.string();break}case 7:{f.domain=r.string();break}case 5:{f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(s.onnx.AttributeProto.decode(r,r.uint32()));break}case 6:{f.docString=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u)if(!o.isString(r.input[u]))return"input: string[] expected"}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u)if(!o.isString(r.output[u]))return"output: string[] expected"}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.opType!=null&&r.hasOwnProperty("opType")&&!o.isString(r.opType))return"opType: string expected";if(r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain))return"domain: string expected";if(r.attribute!=null&&r.hasOwnProperty("attribute")){if(!Array.isArray(r.attribute))return"attribute: array expected";for(var u=0;u<r.attribute.length;++u){var l=s.onnx.AttributeProto.verify(r.attribute[u]);if(l)return"attribute."+l}}return r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString)?"docString: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.NodeProto)return r;var u=new s.onnx.NodeProto;if(r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.NodeProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l)u.input[l]=String(r.input[l])}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.NodeProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l)u.output[l]=String(r.output[l])}if(r.name!=null&&(u.name=String(r.name)),r.opType!=null&&(u.opType=String(r.opType)),r.domain!=null&&(u.domain=String(r.domain)),r.attribute){if(!Array.isArray(r.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");u.attribute=[];for(var l=0;l<r.attribute.length;++l){if(typeof r.attribute[l]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");u.attribute[l]=s.onnx.AttributeProto.fromObject(r.attribute[l])}}return r.docString!=null&&(u.docString=String(r.docString)),u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.input=[],l.output=[],l.attribute=[]),u.defaults&&(l.name="",l.opType="",l.docString="",l.domain=""),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=r.input[f]}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=r.output[f]}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.opType!=null&&r.hasOwnProperty("opType")&&(l.opType=r.opType),r.attribute&&r.attribute.length){l.attribute=[];for(var f=0;f<r.attribute.length;++f)l.attribute[f]=s.onnx.AttributeProto.toObject(r.attribute[f],u)}return r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.NodeProto"},h}(),c.TrainingInfoProto=function(){function h(r){if(this.initializationBinding=[],this.updateBinding=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.initialization=null,h.prototype.algorithm=null,h.prototype.initializationBinding=o.emptyArray,h.prototype.updateBinding=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.initialization!=null&&Object.hasOwnProperty.call(r,"initialization")&&s.onnx.GraphProto.encode(r.initialization,u.uint32(10).fork()).ldelim(),r.algorithm!=null&&Object.hasOwnProperty.call(r,"algorithm")&&s.onnx.GraphProto.encode(r.algorithm,u.uint32(18).fork()).ldelim(),r.initializationBinding!=null&&r.initializationBinding.length)for(var l=0;l<r.initializationBinding.length;++l)s.onnx.StringStringEntryProto.encode(r.initializationBinding[l],u.uint32(26).fork()).ldelim();if(r.updateBinding!=null&&r.updateBinding.length)for(var l=0;l<r.updateBinding.length;++l)s.onnx.StringStringEntryProto.encode(r.updateBinding[l],u.uint32(34).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TrainingInfoProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.initialization=s.onnx.GraphProto.decode(r,r.uint32());break}case 2:{f.algorithm=s.onnx.GraphProto.decode(r,r.uint32());break}case 3:{f.initializationBinding&&f.initializationBinding.length||(f.initializationBinding=[]),f.initializationBinding.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 4:{f.updateBinding&&f.updateBinding.length||(f.updateBinding=[]),f.updateBinding.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.initialization!=null&&r.hasOwnProperty("initialization")){var u=s.onnx.GraphProto.verify(r.initialization);if(u)return"initialization."+u}if(r.algorithm!=null&&r.hasOwnProperty("algorithm")){var u=s.onnx.GraphProto.verify(r.algorithm);if(u)return"algorithm."+u}if(r.initializationBinding!=null&&r.hasOwnProperty("initializationBinding")){if(!Array.isArray(r.initializationBinding))return"initializationBinding: array expected";for(var l=0;l<r.initializationBinding.length;++l){var u=s.onnx.StringStringEntryProto.verify(r.initializationBinding[l]);if(u)return"initializationBinding."+u}}if(r.updateBinding!=null&&r.hasOwnProperty("updateBinding")){if(!Array.isArray(r.updateBinding))return"updateBinding: array expected";for(var l=0;l<r.updateBinding.length;++l){var u=s.onnx.StringStringEntryProto.verify(r.updateBinding[l]);if(u)return"updateBinding."+u}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TrainingInfoProto)return r;var u=new s.onnx.TrainingInfoProto;if(r.initialization!=null){if(typeof r.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");u.initialization=s.onnx.GraphProto.fromObject(r.initialization)}if(r.algorithm!=null){if(typeof r.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");u.algorithm=s.onnx.GraphProto.fromObject(r.algorithm)}if(r.initializationBinding){if(!Array.isArray(r.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");u.initializationBinding=[];for(var l=0;l<r.initializationBinding.length;++l){if(typeof r.initializationBinding[l]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");u.initializationBinding[l]=s.onnx.StringStringEntryProto.fromObject(r.initializationBinding[l])}}if(r.updateBinding){if(!Array.isArray(r.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");u.updateBinding=[];for(var l=0;l<r.updateBinding.length;++l){if(typeof r.updateBinding[l]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");u.updateBinding[l]=s.onnx.StringStringEntryProto.fromObject(r.updateBinding[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.initializationBinding=[],l.updateBinding=[]),u.defaults&&(l.initialization=null,l.algorithm=null),r.initialization!=null&&r.hasOwnProperty("initialization")&&(l.initialization=s.onnx.GraphProto.toObject(r.initialization,u)),r.algorithm!=null&&r.hasOwnProperty("algorithm")&&(l.algorithm=s.onnx.GraphProto.toObject(r.algorithm,u)),r.initializationBinding&&r.initializationBinding.length){l.initializationBinding=[];for(var f=0;f<r.initializationBinding.length;++f)l.initializationBinding[f]=s.onnx.StringStringEntryProto.toObject(r.initializationBinding[f],u)}if(r.updateBinding&&r.updateBinding.length){l.updateBinding=[];for(var f=0;f<r.updateBinding.length;++f)l.updateBinding[f]=s.onnx.StringStringEntryProto.toObject(r.updateBinding[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TrainingInfoProto"},h}(),c.ModelProto=function(){function h(r){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.irVersion=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.opsetImport=o.emptyArray,h.prototype.producerName="",h.prototype.producerVersion="",h.prototype.domain="",h.prototype.modelVersion=o.Long?o.Long.fromBits(0,0,!1):0,h.prototype.docString="",h.prototype.graph=null,h.prototype.metadataProps=o.emptyArray,h.prototype.trainingInfo=o.emptyArray,h.prototype.functions=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.irVersion!=null&&Object.hasOwnProperty.call(r,"irVersion")&&u.uint32(8).int64(r.irVersion),r.producerName!=null&&Object.hasOwnProperty.call(r,"producerName")&&u.uint32(18).string(r.producerName),r.producerVersion!=null&&Object.hasOwnProperty.call(r,"producerVersion")&&u.uint32(26).string(r.producerVersion),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(34).string(r.domain),r.modelVersion!=null&&Object.hasOwnProperty.call(r,"modelVersion")&&u.uint32(40).int64(r.modelVersion),r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(50).string(r.docString),r.graph!=null&&Object.hasOwnProperty.call(r,"graph")&&s.onnx.GraphProto.encode(r.graph,u.uint32(58).fork()).ldelim(),r.opsetImport!=null&&r.opsetImport.length)for(var l=0;l<r.opsetImport.length;++l)s.onnx.OperatorSetIdProto.encode(r.opsetImport[l],u.uint32(66).fork()).ldelim();if(r.metadataProps!=null&&r.metadataProps.length)for(var l=0;l<r.metadataProps.length;++l)s.onnx.StringStringEntryProto.encode(r.metadataProps[l],u.uint32(114).fork()).ldelim();if(r.trainingInfo!=null&&r.trainingInfo.length)for(var l=0;l<r.trainingInfo.length;++l)s.onnx.TrainingInfoProto.encode(r.trainingInfo[l],u.uint32(162).fork()).ldelim();if(r.functions!=null&&r.functions.length)for(var l=0;l<r.functions.length;++l)s.onnx.FunctionProto.encode(r.functions[l],u.uint32(202).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.ModelProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.irVersion=r.int64();break}case 8:{f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(s.onnx.OperatorSetIdProto.decode(r,r.uint32()));break}case 2:{f.producerName=r.string();break}case 3:{f.producerVersion=r.string();break}case 4:{f.domain=r.string();break}case 5:{f.modelVersion=r.int64();break}case 6:{f.docString=r.string();break}case 7:{f.graph=s.onnx.GraphProto.decode(r,r.uint32());break}case 14:{f.metadataProps&&f.metadataProps.length||(f.metadataProps=[]),f.metadataProps.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 20:{f.trainingInfo&&f.trainingInfo.length||(f.trainingInfo=[]),f.trainingInfo.push(s.onnx.TrainingInfoProto.decode(r,r.uint32()));break}case 25:{f.functions&&f.functions.length||(f.functions=[]),f.functions.push(s.onnx.FunctionProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.irVersion!=null&&r.hasOwnProperty("irVersion")&&!o.isInteger(r.irVersion)&&!(r.irVersion&&o.isInteger(r.irVersion.low)&&o.isInteger(r.irVersion.high)))return"irVersion: integer|Long expected";if(r.opsetImport!=null&&r.hasOwnProperty("opsetImport")){if(!Array.isArray(r.opsetImport))return"opsetImport: array expected";for(var u=0;u<r.opsetImport.length;++u){var l=s.onnx.OperatorSetIdProto.verify(r.opsetImport[u]);if(l)return"opsetImport."+l}}if(r.producerName!=null&&r.hasOwnProperty("producerName")&&!o.isString(r.producerName))return"producerName: string expected";if(r.producerVersion!=null&&r.hasOwnProperty("producerVersion")&&!o.isString(r.producerVersion))return"producerVersion: string expected";if(r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain))return"domain: string expected";if(r.modelVersion!=null&&r.hasOwnProperty("modelVersion")&&!o.isInteger(r.modelVersion)&&!(r.modelVersion&&o.isInteger(r.modelVersion.low)&&o.isInteger(r.modelVersion.high)))return"modelVersion: integer|Long expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.graph!=null&&r.hasOwnProperty("graph")){var l=s.onnx.GraphProto.verify(r.graph);if(l)return"graph."+l}if(r.metadataProps!=null&&r.hasOwnProperty("metadataProps")){if(!Array.isArray(r.metadataProps))return"metadataProps: array expected";for(var u=0;u<r.metadataProps.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.metadataProps[u]);if(l)return"metadataProps."+l}}if(r.trainingInfo!=null&&r.hasOwnProperty("trainingInfo")){if(!Array.isArray(r.trainingInfo))return"trainingInfo: array expected";for(var u=0;u<r.trainingInfo.length;++u){var l=s.onnx.TrainingInfoProto.verify(r.trainingInfo[u]);if(l)return"trainingInfo."+l}}if(r.functions!=null&&r.hasOwnProperty("functions")){if(!Array.isArray(r.functions))return"functions: array expected";for(var u=0;u<r.functions.length;++u){var l=s.onnx.FunctionProto.verify(r.functions[u]);if(l)return"functions."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.ModelProto)return r;var u=new s.onnx.ModelProto;if(r.irVersion!=null&&(o.Long?(u.irVersion=o.Long.fromValue(r.irVersion)).unsigned=!1:typeof r.irVersion=="string"?u.irVersion=parseInt(r.irVersion,10):typeof r.irVersion=="number"?u.irVersion=r.irVersion:typeof r.irVersion=="object"&&(u.irVersion=new o.LongBits(r.irVersion.low>>>0,r.irVersion.high>>>0).toNumber())),r.opsetImport){if(!Array.isArray(r.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");u.opsetImport=[];for(var l=0;l<r.opsetImport.length;++l){if(typeof r.opsetImport[l]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");u.opsetImport[l]=s.onnx.OperatorSetIdProto.fromObject(r.opsetImport[l])}}if(r.producerName!=null&&(u.producerName=String(r.producerName)),r.producerVersion!=null&&(u.producerVersion=String(r.producerVersion)),r.domain!=null&&(u.domain=String(r.domain)),r.modelVersion!=null&&(o.Long?(u.modelVersion=o.Long.fromValue(r.modelVersion)).unsigned=!1:typeof r.modelVersion=="string"?u.modelVersion=parseInt(r.modelVersion,10):typeof r.modelVersion=="number"?u.modelVersion=r.modelVersion:typeof r.modelVersion=="object"&&(u.modelVersion=new o.LongBits(r.modelVersion.low>>>0,r.modelVersion.high>>>0).toNumber())),r.docString!=null&&(u.docString=String(r.docString)),r.graph!=null){if(typeof r.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");u.graph=s.onnx.GraphProto.fromObject(r.graph)}if(r.metadataProps){if(!Array.isArray(r.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");u.metadataProps=[];for(var l=0;l<r.metadataProps.length;++l){if(typeof r.metadataProps[l]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");u.metadataProps[l]=s.onnx.StringStringEntryProto.fromObject(r.metadataProps[l])}}if(r.trainingInfo){if(!Array.isArray(r.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");u.trainingInfo=[];for(var l=0;l<r.trainingInfo.length;++l){if(typeof r.trainingInfo[l]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");u.trainingInfo[l]=s.onnx.TrainingInfoProto.fromObject(r.trainingInfo[l])}}if(r.functions){if(!Array.isArray(r.functions))throw TypeError(".onnx.ModelProto.functions: array expected");u.functions=[];for(var l=0;l<r.functions.length;++l){if(typeof r.functions[l]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");u.functions[l]=s.onnx.FunctionProto.fromObject(r.functions[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.opsetImport=[],l.metadataProps=[],l.trainingInfo=[],l.functions=[]),u.defaults){if(o.Long){var f=new o.Long(0,0,!1);l.irVersion=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.irVersion=u.longs===String?"0":0;if(l.producerName="",l.producerVersion="",l.domain="",o.Long){var f=new o.Long(0,0,!1);l.modelVersion=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.modelVersion=u.longs===String?"0":0;l.docString="",l.graph=null}if(r.irVersion!=null&&r.hasOwnProperty("irVersion")&&(typeof r.irVersion=="number"?l.irVersion=u.longs===String?String(r.irVersion):r.irVersion:l.irVersion=u.longs===String?o.Long.prototype.toString.call(r.irVersion):u.longs===Number?new o.LongBits(r.irVersion.low>>>0,r.irVersion.high>>>0).toNumber():r.irVersion),r.producerName!=null&&r.hasOwnProperty("producerName")&&(l.producerName=r.producerName),r.producerVersion!=null&&r.hasOwnProperty("producerVersion")&&(l.producerVersion=r.producerVersion),r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.modelVersion!=null&&r.hasOwnProperty("modelVersion")&&(typeof r.modelVersion=="number"?l.modelVersion=u.longs===String?String(r.modelVersion):r.modelVersion:l.modelVersion=u.longs===String?o.Long.prototype.toString.call(r.modelVersion):u.longs===Number?new o.LongBits(r.modelVersion.low>>>0,r.modelVersion.high>>>0).toNumber():r.modelVersion),r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.graph!=null&&r.hasOwnProperty("graph")&&(l.graph=s.onnx.GraphProto.toObject(r.graph,u)),r.opsetImport&&r.opsetImport.length){l.opsetImport=[];for(var g=0;g<r.opsetImport.length;++g)l.opsetImport[g]=s.onnx.OperatorSetIdProto.toObject(r.opsetImport[g],u)}if(r.metadataProps&&r.metadataProps.length){l.metadataProps=[];for(var g=0;g<r.metadataProps.length;++g)l.metadataProps[g]=s.onnx.StringStringEntryProto.toObject(r.metadataProps[g],u)}if(r.trainingInfo&&r.trainingInfo.length){l.trainingInfo=[];for(var g=0;g<r.trainingInfo.length;++g)l.trainingInfo[g]=s.onnx.TrainingInfoProto.toObject(r.trainingInfo[g],u)}if(r.functions&&r.functions.length){l.functions=[];for(var g=0;g<r.functions.length;++g)l.functions[g]=s.onnx.FunctionProto.toObject(r.functions[g],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.ModelProto"},h}(),c.StringStringEntryProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.key="",h.prototype.value="",h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.key!=null&&Object.hasOwnProperty.call(r,"key")&&u.uint32(10).string(r.key),r.value!=null&&Object.hasOwnProperty.call(r,"value")&&u.uint32(18).string(r.value),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.StringStringEntryProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.key=r.string();break}case 2:{f.value=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){return typeof r!="object"||r===null?"object expected":r.key!=null&&r.hasOwnProperty("key")&&!o.isString(r.key)?"key: string expected":r.value!=null&&r.hasOwnProperty("value")&&!o.isString(r.value)?"value: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.StringStringEntryProto)return r;var u=new s.onnx.StringStringEntryProto;return r.key!=null&&(u.key=String(r.key)),r.value!=null&&(u.value=String(r.value)),u},h.toObject=function(r,u){u||(u={});var l={};return u.defaults&&(l.key="",l.value=""),r.key!=null&&r.hasOwnProperty("key")&&(l.key=r.key),r.value!=null&&r.hasOwnProperty("value")&&(l.value=r.value),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.StringStringEntryProto"},h}(),c.TensorAnnotation=function(){function h(r){if(this.quantParameterTensorNames=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.tensorName="",h.prototype.quantParameterTensorNames=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.tensorName!=null&&Object.hasOwnProperty.call(r,"tensorName")&&u.uint32(10).string(r.tensorName),r.quantParameterTensorNames!=null&&r.quantParameterTensorNames.length)for(var l=0;l<r.quantParameterTensorNames.length;++l)s.onnx.StringStringEntryProto.encode(r.quantParameterTensorNames[l],u.uint32(18).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorAnnotation;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.tensorName=r.string();break}case 2:{f.quantParameterTensorNames&&f.quantParameterTensorNames.length||(f.quantParameterTensorNames=[]),f.quantParameterTensorNames.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.tensorName!=null&&r.hasOwnProperty("tensorName")&&!o.isString(r.tensorName))return"tensorName: string expected";if(r.quantParameterTensorNames!=null&&r.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(r.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var u=0;u<r.quantParameterTensorNames.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.quantParameterTensorNames[u]);if(l)return"quantParameterTensorNames."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorAnnotation)return r;var u=new s.onnx.TensorAnnotation;if(r.tensorName!=null&&(u.tensorName=String(r.tensorName)),r.quantParameterTensorNames){if(!Array.isArray(r.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");u.quantParameterTensorNames=[];for(var l=0;l<r.quantParameterTensorNames.length;++l){if(typeof r.quantParameterTensorNames[l]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");u.quantParameterTensorNames[l]=s.onnx.StringStringEntryProto.fromObject(r.quantParameterTensorNames[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.quantParameterTensorNames=[]),u.defaults&&(l.tensorName=""),r.tensorName!=null&&r.hasOwnProperty("tensorName")&&(l.tensorName=r.tensorName),r.quantParameterTensorNames&&r.quantParameterTensorNames.length){l.quantParameterTensorNames=[];for(var f=0;f<r.quantParameterTensorNames.length;++f)l.quantParameterTensorNames[f]=s.onnx.StringStringEntryProto.toObject(r.quantParameterTensorNames[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorAnnotation"},h}(),c.GraphProto=function(){function h(r){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.node=o.emptyArray,h.prototype.name="",h.prototype.initializer=o.emptyArray,h.prototype.sparseInitializer=o.emptyArray,h.prototype.docString="",h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.valueInfo=o.emptyArray,h.prototype.quantizationAnnotation=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.node!=null&&r.node.length)for(var l=0;l<r.node.length;++l)s.onnx.NodeProto.encode(r.node[l],u.uint32(10).fork()).ldelim();if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(18).string(r.name),r.initializer!=null&&r.initializer.length)for(var l=0;l<r.initializer.length;++l)s.onnx.TensorProto.encode(r.initializer[l],u.uint32(42).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(82).string(r.docString),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)s.onnx.ValueInfoProto.encode(r.input[l],u.uint32(90).fork()).ldelim();if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)s.onnx.ValueInfoProto.encode(r.output[l],u.uint32(98).fork()).ldelim();if(r.valueInfo!=null&&r.valueInfo.length)for(var l=0;l<r.valueInfo.length;++l)s.onnx.ValueInfoProto.encode(r.valueInfo[l],u.uint32(106).fork()).ldelim();if(r.quantizationAnnotation!=null&&r.quantizationAnnotation.length)for(var l=0;l<r.quantizationAnnotation.length;++l)s.onnx.TensorAnnotation.encode(r.quantizationAnnotation[l],u.uint32(114).fork()).ldelim();if(r.sparseInitializer!=null&&r.sparseInitializer.length)for(var l=0;l<r.sparseInitializer.length;++l)s.onnx.SparseTensorProto.encode(r.sparseInitializer[l],u.uint32(122).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.GraphProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.node&&f.node.length||(f.node=[]),f.node.push(s.onnx.NodeProto.decode(r,r.uint32()));break}case 2:{f.name=r.string();break}case 5:{f.initializer&&f.initializer.length||(f.initializer=[]),f.initializer.push(s.onnx.TensorProto.decode(r,r.uint32()));break}case 15:{f.sparseInitializer&&f.sparseInitializer.length||(f.sparseInitializer=[]),f.sparseInitializer.push(s.onnx.SparseTensorProto.decode(r,r.uint32()));break}case 10:{f.docString=r.string();break}case 11:{f.input&&f.input.length||(f.input=[]),f.input.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 12:{f.output&&f.output.length||(f.output=[]),f.output.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 13:{f.valueInfo&&f.valueInfo.length||(f.valueInfo=[]),f.valueInfo.push(s.onnx.ValueInfoProto.decode(r,r.uint32()));break}case 14:{f.quantizationAnnotation&&f.quantizationAnnotation.length||(f.quantizationAnnotation=[]),f.quantizationAnnotation.push(s.onnx.TensorAnnotation.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.node!=null&&r.hasOwnProperty("node")){if(!Array.isArray(r.node))return"node: array expected";for(var u=0;u<r.node.length;++u){var l=s.onnx.NodeProto.verify(r.node[u]);if(l)return"node."+l}}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.initializer!=null&&r.hasOwnProperty("initializer")){if(!Array.isArray(r.initializer))return"initializer: array expected";for(var u=0;u<r.initializer.length;++u){var l=s.onnx.TensorProto.verify(r.initializer[u]);if(l)return"initializer."+l}}if(r.sparseInitializer!=null&&r.hasOwnProperty("sparseInitializer")){if(!Array.isArray(r.sparseInitializer))return"sparseInitializer: array expected";for(var u=0;u<r.sparseInitializer.length;++u){var l=s.onnx.SparseTensorProto.verify(r.sparseInitializer[u]);if(l)return"sparseInitializer."+l}}if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u){var l=s.onnx.ValueInfoProto.verify(r.input[u]);if(l)return"input."+l}}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u){var l=s.onnx.ValueInfoProto.verify(r.output[u]);if(l)return"output."+l}}if(r.valueInfo!=null&&r.hasOwnProperty("valueInfo")){if(!Array.isArray(r.valueInfo))return"valueInfo: array expected";for(var u=0;u<r.valueInfo.length;++u){var l=s.onnx.ValueInfoProto.verify(r.valueInfo[u]);if(l)return"valueInfo."+l}}if(r.quantizationAnnotation!=null&&r.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(r.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var u=0;u<r.quantizationAnnotation.length;++u){var l=s.onnx.TensorAnnotation.verify(r.quantizationAnnotation[u]);if(l)return"quantizationAnnotation."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.GraphProto)return r;var u=new s.onnx.GraphProto;if(r.node){if(!Array.isArray(r.node))throw TypeError(".onnx.GraphProto.node: array expected");u.node=[];for(var l=0;l<r.node.length;++l){if(typeof r.node[l]!="object")throw TypeError(".onnx.GraphProto.node: object expected");u.node[l]=s.onnx.NodeProto.fromObject(r.node[l])}}if(r.name!=null&&(u.name=String(r.name)),r.initializer){if(!Array.isArray(r.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");u.initializer=[];for(var l=0;l<r.initializer.length;++l){if(typeof r.initializer[l]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");u.initializer[l]=s.onnx.TensorProto.fromObject(r.initializer[l])}}if(r.sparseInitializer){if(!Array.isArray(r.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");u.sparseInitializer=[];for(var l=0;l<r.sparseInitializer.length;++l){if(typeof r.sparseInitializer[l]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");u.sparseInitializer[l]=s.onnx.SparseTensorProto.fromObject(r.sparseInitializer[l])}}if(r.docString!=null&&(u.docString=String(r.docString)),r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.GraphProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l){if(typeof r.input[l]!="object")throw TypeError(".onnx.GraphProto.input: object expected");u.input[l]=s.onnx.ValueInfoProto.fromObject(r.input[l])}}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.GraphProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l){if(typeof r.output[l]!="object")throw TypeError(".onnx.GraphProto.output: object expected");u.output[l]=s.onnx.ValueInfoProto.fromObject(r.output[l])}}if(r.valueInfo){if(!Array.isArray(r.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");u.valueInfo=[];for(var l=0;l<r.valueInfo.length;++l){if(typeof r.valueInfo[l]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");u.valueInfo[l]=s.onnx.ValueInfoProto.fromObject(r.valueInfo[l])}}if(r.quantizationAnnotation){if(!Array.isArray(r.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");u.quantizationAnnotation=[];for(var l=0;l<r.quantizationAnnotation.length;++l){if(typeof r.quantizationAnnotation[l]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");u.quantizationAnnotation[l]=s.onnx.TensorAnnotation.fromObject(r.quantizationAnnotation[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.node=[],l.initializer=[],l.input=[],l.output=[],l.valueInfo=[],l.quantizationAnnotation=[],l.sparseInitializer=[]),u.defaults&&(l.name="",l.docString=""),r.node&&r.node.length){l.node=[];for(var f=0;f<r.node.length;++f)l.node[f]=s.onnx.NodeProto.toObject(r.node[f],u)}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.initializer&&r.initializer.length){l.initializer=[];for(var f=0;f<r.initializer.length;++f)l.initializer[f]=s.onnx.TensorProto.toObject(r.initializer[f],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=s.onnx.ValueInfoProto.toObject(r.input[f],u)}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=s.onnx.ValueInfoProto.toObject(r.output[f],u)}if(r.valueInfo&&r.valueInfo.length){l.valueInfo=[];for(var f=0;f<r.valueInfo.length;++f)l.valueInfo[f]=s.onnx.ValueInfoProto.toObject(r.valueInfo[f],u)}if(r.quantizationAnnotation&&r.quantizationAnnotation.length){l.quantizationAnnotation=[];for(var f=0;f<r.quantizationAnnotation.length;++f)l.quantizationAnnotation[f]=s.onnx.TensorAnnotation.toObject(r.quantizationAnnotation[f],u)}if(r.sparseInitializer&&r.sparseInitializer.length){l.sparseInitializer=[];for(var f=0;f<r.sparseInitializer.length;++f)l.sparseInitializer[f]=s.onnx.SparseTensorProto.toObject(r.sparseInitializer[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.GraphProto"},h}(),c.TensorProto=function(){function h(r){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.dims=o.emptyArray,h.prototype.dataType=0,h.prototype.segment=null,h.prototype.floatData=o.emptyArray,h.prototype.int32Data=o.emptyArray,h.prototype.stringData=o.emptyArray,h.prototype.int64Data=o.emptyArray,h.prototype.name="",h.prototype.docString="",h.prototype.rawData=o.newBuffer([]),h.prototype.externalData=o.emptyArray,h.prototype.dataLocation=0,h.prototype.doubleData=o.emptyArray,h.prototype.uint64Data=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.dims!=null&&r.dims.length){u.uint32(10).fork();for(var l=0;l<r.dims.length;++l)u.int64(r.dims[l]);u.ldelim()}if(r.dataType!=null&&Object.hasOwnProperty.call(r,"dataType")&&u.uint32(16).int32(r.dataType),r.segment!=null&&Object.hasOwnProperty.call(r,"segment")&&s.onnx.TensorProto.Segment.encode(r.segment,u.uint32(26).fork()).ldelim(),r.floatData!=null&&r.floatData.length){u.uint32(34).fork();for(var l=0;l<r.floatData.length;++l)u.float(r.floatData[l]);u.ldelim()}if(r.int32Data!=null&&r.int32Data.length){u.uint32(42).fork();for(var l=0;l<r.int32Data.length;++l)u.int32(r.int32Data[l]);u.ldelim()}if(r.stringData!=null&&r.stringData.length)for(var l=0;l<r.stringData.length;++l)u.uint32(50).bytes(r.stringData[l]);if(r.int64Data!=null&&r.int64Data.length){u.uint32(58).fork();for(var l=0;l<r.int64Data.length;++l)u.int64(r.int64Data[l]);u.ldelim()}if(r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(66).string(r.name),r.rawData!=null&&Object.hasOwnProperty.call(r,"rawData")&&u.uint32(74).bytes(r.rawData),r.doubleData!=null&&r.doubleData.length){u.uint32(82).fork();for(var l=0;l<r.doubleData.length;++l)u.double(r.doubleData[l]);u.ldelim()}if(r.uint64Data!=null&&r.uint64Data.length){u.uint32(90).fork();for(var l=0;l<r.uint64Data.length;++l)u.uint64(r.uint64Data[l]);u.ldelim()}if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(98).string(r.docString),r.externalData!=null&&r.externalData.length)for(var l=0;l<r.externalData.length;++l)s.onnx.StringStringEntryProto.encode(r.externalData[l],u.uint32(106).fork()).ldelim();return r.dataLocation!=null&&Object.hasOwnProperty.call(r,"dataLocation")&&u.uint32(112).int32(r.dataLocation),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{if(f.dims&&f.dims.length||(f.dims=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.dims.push(r.int64());else f.dims.push(r.int64());break}case 2:{f.dataType=r.int32();break}case 3:{f.segment=s.onnx.TensorProto.Segment.decode(r,r.uint32());break}case 4:{if(f.floatData&&f.floatData.length||(f.floatData=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.floatData.push(r.float());else f.floatData.push(r.float());break}case 5:{if(f.int32Data&&f.int32Data.length||(f.int32Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.int32Data.push(r.int32());else f.int32Data.push(r.int32());break}case 6:{f.stringData&&f.stringData.length||(f.stringData=[]),f.stringData.push(r.bytes());break}case 7:{if(f.int64Data&&f.int64Data.length||(f.int64Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.int64Data.push(r.int64());else f.int64Data.push(r.int64());break}case 8:{f.name=r.string();break}case 12:{f.docString=r.string();break}case 9:{f.rawData=r.bytes();break}case 13:{f.externalData&&f.externalData.length||(f.externalData=[]),f.externalData.push(s.onnx.StringStringEntryProto.decode(r,r.uint32()));break}case 14:{f.dataLocation=r.int32();break}case 10:{if(f.doubleData&&f.doubleData.length||(f.doubleData=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.doubleData.push(r.double());else f.doubleData.push(r.double());break}case 11:{if(f.uint64Data&&f.uint64Data.length||(f.uint64Data=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.uint64Data.push(r.uint64());else f.uint64Data.push(r.uint64());break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.dims!=null&&r.hasOwnProperty("dims")){if(!Array.isArray(r.dims))return"dims: array expected";for(var u=0;u<r.dims.length;++u)if(!o.isInteger(r.dims[u])&&!(r.dims[u]&&o.isInteger(r.dims[u].low)&&o.isInteger(r.dims[u].high)))return"dims: integer|Long[] expected"}if(r.dataType!=null&&r.hasOwnProperty("dataType")&&!o.isInteger(r.dataType))return"dataType: integer expected";if(r.segment!=null&&r.hasOwnProperty("segment")){var l=s.onnx.TensorProto.Segment.verify(r.segment);if(l)return"segment."+l}if(r.floatData!=null&&r.hasOwnProperty("floatData")){if(!Array.isArray(r.floatData))return"floatData: array expected";for(var u=0;u<r.floatData.length;++u)if(typeof r.floatData[u]!="number")return"floatData: number[] expected"}if(r.int32Data!=null&&r.hasOwnProperty("int32Data")){if(!Array.isArray(r.int32Data))return"int32Data: array expected";for(var u=0;u<r.int32Data.length;++u)if(!o.isInteger(r.int32Data[u]))return"int32Data: integer[] expected"}if(r.stringData!=null&&r.hasOwnProperty("stringData")){if(!Array.isArray(r.stringData))return"stringData: array expected";for(var u=0;u<r.stringData.length;++u)if(!(r.stringData[u]&&typeof r.stringData[u].length=="number"||o.isString(r.stringData[u])))return"stringData: buffer[] expected"}if(r.int64Data!=null&&r.hasOwnProperty("int64Data")){if(!Array.isArray(r.int64Data))return"int64Data: array expected";for(var u=0;u<r.int64Data.length;++u)if(!o.isInteger(r.int64Data[u])&&!(r.int64Data[u]&&o.isInteger(r.int64Data[u].low)&&o.isInteger(r.int64Data[u].high)))return"int64Data: integer|Long[] expected"}if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.rawData!=null&&r.hasOwnProperty("rawData")&&!(r.rawData&&typeof r.rawData.length=="number"||o.isString(r.rawData)))return"rawData: buffer expected";if(r.externalData!=null&&r.hasOwnProperty("externalData")){if(!Array.isArray(r.externalData))return"externalData: array expected";for(var u=0;u<r.externalData.length;++u){var l=s.onnx.StringStringEntryProto.verify(r.externalData[u]);if(l)return"externalData."+l}}if(r.dataLocation!=null&&r.hasOwnProperty("dataLocation"))switch(r.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:break}if(r.doubleData!=null&&r.hasOwnProperty("doubleData")){if(!Array.isArray(r.doubleData))return"doubleData: array expected";for(var u=0;u<r.doubleData.length;++u)if(typeof r.doubleData[u]!="number")return"doubleData: number[] expected"}if(r.uint64Data!=null&&r.hasOwnProperty("uint64Data")){if(!Array.isArray(r.uint64Data))return"uint64Data: array expected";for(var u=0;u<r.uint64Data.length;++u)if(!o.isInteger(r.uint64Data[u])&&!(r.uint64Data[u]&&o.isInteger(r.uint64Data[u].low)&&o.isInteger(r.uint64Data[u].high)))return"uint64Data: integer|Long[] expected"}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorProto)return r;var u=new s.onnx.TensorProto;if(r.dims){if(!Array.isArray(r.dims))throw TypeError(".onnx.TensorProto.dims: array expected");u.dims=[];for(var l=0;l<r.dims.length;++l)o.Long?(u.dims[l]=o.Long.fromValue(r.dims[l])).unsigned=!1:typeof r.dims[l]=="string"?u.dims[l]=parseInt(r.dims[l],10):typeof r.dims[l]=="number"?u.dims[l]=r.dims[l]:typeof r.dims[l]=="object"&&(u.dims[l]=new o.LongBits(r.dims[l].low>>>0,r.dims[l].high>>>0).toNumber())}if(r.dataType!=null&&(u.dataType=r.dataType|0),r.segment!=null){if(typeof r.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");u.segment=s.onnx.TensorProto.Segment.fromObject(r.segment)}if(r.floatData){if(!Array.isArray(r.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");u.floatData=[];for(var l=0;l<r.floatData.length;++l)u.floatData[l]=Number(r.floatData[l])}if(r.int32Data){if(!Array.isArray(r.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");u.int32Data=[];for(var l=0;l<r.int32Data.length;++l)u.int32Data[l]=r.int32Data[l]|0}if(r.stringData){if(!Array.isArray(r.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");u.stringData=[];for(var l=0;l<r.stringData.length;++l)typeof r.stringData[l]=="string"?o.base64.decode(r.stringData[l],u.stringData[l]=o.newBuffer(o.base64.length(r.stringData[l])),0):r.stringData[l].length>=0&&(u.stringData[l]=r.stringData[l])}if(r.int64Data){if(!Array.isArray(r.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");u.int64Data=[];for(var l=0;l<r.int64Data.length;++l)o.Long?(u.int64Data[l]=o.Long.fromValue(r.int64Data[l])).unsigned=!1:typeof r.int64Data[l]=="string"?u.int64Data[l]=parseInt(r.int64Data[l],10):typeof r.int64Data[l]=="number"?u.int64Data[l]=r.int64Data[l]:typeof r.int64Data[l]=="object"&&(u.int64Data[l]=new o.LongBits(r.int64Data[l].low>>>0,r.int64Data[l].high>>>0).toNumber())}if(r.name!=null&&(u.name=String(r.name)),r.docString!=null&&(u.docString=String(r.docString)),r.rawData!=null&&(typeof r.rawData=="string"?o.base64.decode(r.rawData,u.rawData=o.newBuffer(o.base64.length(r.rawData)),0):r.rawData.length>=0&&(u.rawData=r.rawData)),r.externalData){if(!Array.isArray(r.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");u.externalData=[];for(var l=0;l<r.externalData.length;++l){if(typeof r.externalData[l]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");u.externalData[l]=s.onnx.StringStringEntryProto.fromObject(r.externalData[l])}}switch(r.dataLocation){default:if(typeof r.dataLocation=="number"){u.dataLocation=r.dataLocation;break}break;case"DEFAULT":case 0:u.dataLocation=0;break;case"EXTERNAL":case 1:u.dataLocation=1;break}if(r.doubleData){if(!Array.isArray(r.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");u.doubleData=[];for(var l=0;l<r.doubleData.length;++l)u.doubleData[l]=Number(r.doubleData[l])}if(r.uint64Data){if(!Array.isArray(r.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");u.uint64Data=[];for(var l=0;l<r.uint64Data.length;++l)o.Long?(u.uint64Data[l]=o.Long.fromValue(r.uint64Data[l])).unsigned=!0:typeof r.uint64Data[l]=="string"?u.uint64Data[l]=parseInt(r.uint64Data[l],10):typeof r.uint64Data[l]=="number"?u.uint64Data[l]=r.uint64Data[l]:typeof r.uint64Data[l]=="object"&&(u.uint64Data[l]=new o.LongBits(r.uint64Data[l].low>>>0,r.uint64Data[l].high>>>0).toNumber(!0))}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dims=[],l.floatData=[],l.int32Data=[],l.stringData=[],l.int64Data=[],l.doubleData=[],l.uint64Data=[],l.externalData=[]),u.defaults&&(l.dataType=0,l.segment=null,l.name="",u.bytes===String?l.rawData="":(l.rawData=[],u.bytes!==Array&&(l.rawData=o.newBuffer(l.rawData))),l.docString="",l.dataLocation=u.enums===String?"DEFAULT":0),r.dims&&r.dims.length){l.dims=[];for(var f=0;f<r.dims.length;++f)typeof r.dims[f]=="number"?l.dims[f]=u.longs===String?String(r.dims[f]):r.dims[f]:l.dims[f]=u.longs===String?o.Long.prototype.toString.call(r.dims[f]):u.longs===Number?new o.LongBits(r.dims[f].low>>>0,r.dims[f].high>>>0).toNumber():r.dims[f]}if(r.dataType!=null&&r.hasOwnProperty("dataType")&&(l.dataType=r.dataType),r.segment!=null&&r.hasOwnProperty("segment")&&(l.segment=s.onnx.TensorProto.Segment.toObject(r.segment,u)),r.floatData&&r.floatData.length){l.floatData=[];for(var f=0;f<r.floatData.length;++f)l.floatData[f]=u.json&&!isFinite(r.floatData[f])?String(r.floatData[f]):r.floatData[f]}if(r.int32Data&&r.int32Data.length){l.int32Data=[];for(var f=0;f<r.int32Data.length;++f)l.int32Data[f]=r.int32Data[f]}if(r.stringData&&r.stringData.length){l.stringData=[];for(var f=0;f<r.stringData.length;++f)l.stringData[f]=u.bytes===String?o.base64.encode(r.stringData[f],0,r.stringData[f].length):u.bytes===Array?Array.prototype.slice.call(r.stringData[f]):r.stringData[f]}if(r.int64Data&&r.int64Data.length){l.int64Data=[];for(var f=0;f<r.int64Data.length;++f)typeof r.int64Data[f]=="number"?l.int64Data[f]=u.longs===String?String(r.int64Data[f]):r.int64Data[f]:l.int64Data[f]=u.longs===String?o.Long.prototype.toString.call(r.int64Data[f]):u.longs===Number?new o.LongBits(r.int64Data[f].low>>>0,r.int64Data[f].high>>>0).toNumber():r.int64Data[f]}if(r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.rawData!=null&&r.hasOwnProperty("rawData")&&(l.rawData=u.bytes===String?o.base64.encode(r.rawData,0,r.rawData.length):u.bytes===Array?Array.prototype.slice.call(r.rawData):r.rawData),r.doubleData&&r.doubleData.length){l.doubleData=[];for(var f=0;f<r.doubleData.length;++f)l.doubleData[f]=u.json&&!isFinite(r.doubleData[f])?String(r.doubleData[f]):r.doubleData[f]}if(r.uint64Data&&r.uint64Data.length){l.uint64Data=[];for(var f=0;f<r.uint64Data.length;++f)typeof r.uint64Data[f]=="number"?l.uint64Data[f]=u.longs===String?String(r.uint64Data[f]):r.uint64Data[f]:l.uint64Data[f]=u.longs===String?o.Long.prototype.toString.call(r.uint64Data[f]):u.longs===Number?new o.LongBits(r.uint64Data[f].low>>>0,r.uint64Data[f].high>>>0).toNumber(!0):r.uint64Data[f]}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.externalData&&r.externalData.length){l.externalData=[];for(var f=0;f<r.externalData.length;++f)l.externalData[f]=s.onnx.StringStringEntryProto.toObject(r.externalData[f],u)}return r.dataLocation!=null&&r.hasOwnProperty("dataLocation")&&(l.dataLocation=u.enums===String?s.onnx.TensorProto.DataLocation[r.dataLocation]===void 0?r.dataLocation:s.onnx.TensorProto.DataLocation[r.dataLocation]:r.dataLocation),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorProto"},h.DataType=function(){var r={},u=Object.create(r);return u[r[0]="UNDEFINED"]=0,u[r[1]="FLOAT"]=1,u[r[2]="UINT8"]=2,u[r[3]="INT8"]=3,u[r[4]="UINT16"]=4,u[r[5]="INT16"]=5,u[r[6]="INT32"]=6,u[r[7]="INT64"]=7,u[r[8]="STRING"]=8,u[r[9]="BOOL"]=9,u[r[10]="FLOAT16"]=10,u[r[11]="DOUBLE"]=11,u[r[12]="UINT32"]=12,u[r[13]="UINT64"]=13,u[r[14]="COMPLEX64"]=14,u[r[15]="COMPLEX128"]=15,u[r[16]="BFLOAT16"]=16,u[r[17]="FLOAT8E4M3FN"]=17,u[r[18]="FLOAT8E4M3FNUZ"]=18,u[r[19]="FLOAT8E5M2"]=19,u[r[20]="FLOAT8E5M2FNUZ"]=20,u}(),h.Segment=function(){function r(u){if(u)for(var l=Object.keys(u),f=0;f<l.length;++f)u[l[f]]!=null&&(this[l[f]]=u[l[f]])}return r.prototype.begin=o.Long?o.Long.fromBits(0,0,!1):0,r.prototype.end=o.Long?o.Long.fromBits(0,0,!1):0,r.create=function(u){return new r(u)},r.encode=function(u,l){return l||(l=p.create()),u.begin!=null&&Object.hasOwnProperty.call(u,"begin")&&l.uint32(8).int64(u.begin),u.end!=null&&Object.hasOwnProperty.call(u,"end")&&l.uint32(16).int64(u.end),l},r.encodeDelimited=function(u,l){return this.encode(u,l).ldelim()},r.decode=function(u,l){u instanceof a||(u=a.create(u));for(var f=l===void 0?u.len:u.pos+l,g=new s.onnx.TensorProto.Segment;u.pos<f;){var b=u.uint32();switch(b>>>3){case 1:{g.begin=u.int64();break}case 2:{g.end=u.int64();break}default:u.skipType(b&7);break}}return g},r.decodeDelimited=function(u){return u instanceof a||(u=new a(u)),this.decode(u,u.uint32())},r.verify=function(u){return typeof u!="object"||u===null?"object expected":u.begin!=null&&u.hasOwnProperty("begin")&&!o.isInteger(u.begin)&&!(u.begin&&o.isInteger(u.begin.low)&&o.isInteger(u.begin.high))?"begin: integer|Long expected":u.end!=null&&u.hasOwnProperty("end")&&!o.isInteger(u.end)&&!(u.end&&o.isInteger(u.end.low)&&o.isInteger(u.end.high))?"end: integer|Long expected":null},r.fromObject=function(u){if(u instanceof s.onnx.TensorProto.Segment)return u;var l=new s.onnx.TensorProto.Segment;return u.begin!=null&&(o.Long?(l.begin=o.Long.fromValue(u.begin)).unsigned=!1:typeof u.begin=="string"?l.begin=parseInt(u.begin,10):typeof u.begin=="number"?l.begin=u.begin:typeof u.begin=="object"&&(l.begin=new o.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber())),u.end!=null&&(o.Long?(l.end=o.Long.fromValue(u.end)).unsigned=!1:typeof u.end=="string"?l.end=parseInt(u.end,10):typeof u.end=="number"?l.end=u.end:typeof u.end=="object"&&(l.end=new o.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber())),l},r.toObject=function(u,l){l||(l={});var f={};if(l.defaults){if(o.Long){var g=new o.Long(0,0,!1);f.begin=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else f.begin=l.longs===String?"0":0;if(o.Long){var g=new o.Long(0,0,!1);f.end=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else f.end=l.longs===String?"0":0}return u.begin!=null&&u.hasOwnProperty("begin")&&(typeof u.begin=="number"?f.begin=l.longs===String?String(u.begin):u.begin:f.begin=l.longs===String?o.Long.prototype.toString.call(u.begin):l.longs===Number?new o.LongBits(u.begin.low>>>0,u.begin.high>>>0).toNumber():u.begin),u.end!=null&&u.hasOwnProperty("end")&&(typeof u.end=="number"?f.end=l.longs===String?String(u.end):u.end:f.end=l.longs===String?o.Long.prototype.toString.call(u.end):l.longs===Number?new o.LongBits(u.end.low>>>0,u.end.high>>>0).toNumber():u.end),f},r.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},r.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TensorProto.Segment"},r}(),h.DataLocation=function(){var r={},u=Object.create(r);return u[r[0]="DEFAULT"]=0,u[r[1]="EXTERNAL"]=1,u}(),h}(),c.SparseTensorProto=function(){function h(r){if(this.dims=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.values=null,h.prototype.indices=null,h.prototype.dims=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.values!=null&&Object.hasOwnProperty.call(r,"values")&&s.onnx.TensorProto.encode(r.values,u.uint32(10).fork()).ldelim(),r.indices!=null&&Object.hasOwnProperty.call(r,"indices")&&s.onnx.TensorProto.encode(r.indices,u.uint32(18).fork()).ldelim(),r.dims!=null&&r.dims.length){u.uint32(26).fork();for(var l=0;l<r.dims.length;++l)u.int64(r.dims[l]);u.ldelim()}return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.SparseTensorProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.values=s.onnx.TensorProto.decode(r,r.uint32());break}case 2:{f.indices=s.onnx.TensorProto.decode(r,r.uint32());break}case 3:{if(f.dims&&f.dims.length||(f.dims=[]),(g&7)===2)for(var b=r.uint32()+r.pos;r.pos<b;)f.dims.push(r.int64());else f.dims.push(r.int64());break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.values!=null&&r.hasOwnProperty("values")){var u=s.onnx.TensorProto.verify(r.values);if(u)return"values."+u}if(r.indices!=null&&r.hasOwnProperty("indices")){var u=s.onnx.TensorProto.verify(r.indices);if(u)return"indices."+u}if(r.dims!=null&&r.hasOwnProperty("dims")){if(!Array.isArray(r.dims))return"dims: array expected";for(var l=0;l<r.dims.length;++l)if(!o.isInteger(r.dims[l])&&!(r.dims[l]&&o.isInteger(r.dims[l].low)&&o.isInteger(r.dims[l].high)))return"dims: integer|Long[] expected"}return null},h.fromObject=function(r){if(r instanceof s.onnx.SparseTensorProto)return r;var u=new s.onnx.SparseTensorProto;if(r.values!=null){if(typeof r.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");u.values=s.onnx.TensorProto.fromObject(r.values)}if(r.indices!=null){if(typeof r.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");u.indices=s.onnx.TensorProto.fromObject(r.indices)}if(r.dims){if(!Array.isArray(r.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");u.dims=[];for(var l=0;l<r.dims.length;++l)o.Long?(u.dims[l]=o.Long.fromValue(r.dims[l])).unsigned=!1:typeof r.dims[l]=="string"?u.dims[l]=parseInt(r.dims[l],10):typeof r.dims[l]=="number"?u.dims[l]=r.dims[l]:typeof r.dims[l]=="object"&&(u.dims[l]=new o.LongBits(r.dims[l].low>>>0,r.dims[l].high>>>0).toNumber())}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dims=[]),u.defaults&&(l.values=null,l.indices=null),r.values!=null&&r.hasOwnProperty("values")&&(l.values=s.onnx.TensorProto.toObject(r.values,u)),r.indices!=null&&r.hasOwnProperty("indices")&&(l.indices=s.onnx.TensorProto.toObject(r.indices,u)),r.dims&&r.dims.length){l.dims=[];for(var f=0;f<r.dims.length;++f)typeof r.dims[f]=="number"?l.dims[f]=u.longs===String?String(r.dims[f]):r.dims[f]:l.dims[f]=u.longs===String?o.Long.prototype.toString.call(r.dims[f]):u.longs===Number?new o.LongBits(r.dims[f].low>>>0,r.dims[f].high>>>0).toNumber():r.dims[f]}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.SparseTensorProto"},h}(),c.TensorShapeProto=function(){function h(r){if(this.dim=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.dim=o.emptyArray,h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.dim!=null&&r.dim.length)for(var l=0;l<r.dim.length;++l)s.onnx.TensorShapeProto.Dimension.encode(r.dim[l],u.uint32(10).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.TensorShapeProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.dim&&f.dim.length||(f.dim=[]),f.dim.push(s.onnx.TensorShapeProto.Dimension.decode(r,r.uint32()));break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.dim!=null&&r.hasOwnProperty("dim")){if(!Array.isArray(r.dim))return"dim: array expected";for(var u=0;u<r.dim.length;++u){var l=s.onnx.TensorShapeProto.Dimension.verify(r.dim[u]);if(l)return"dim."+l}}return null},h.fromObject=function(r){if(r instanceof s.onnx.TensorShapeProto)return r;var u=new s.onnx.TensorShapeProto;if(r.dim){if(!Array.isArray(r.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");u.dim=[];for(var l=0;l<r.dim.length;++l){if(typeof r.dim[l]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");u.dim[l]=s.onnx.TensorShapeProto.Dimension.fromObject(r.dim[l])}}return u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.dim=[]),r.dim&&r.dim.length){l.dim=[];for(var f=0;f<r.dim.length;++f)l.dim[f]=s.onnx.TensorShapeProto.Dimension.toObject(r.dim[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.TensorShapeProto"},h.Dimension=function(){function r(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}r.prototype.dimValue=null,r.prototype.dimParam=null,r.prototype.denotation="";var u;return Object.defineProperty(r.prototype,"value",{get:o.oneOfGetter(u=["dimValue","dimParam"]),set:o.oneOfSetter(u)}),r.create=function(l){return new r(l)},r.encode=function(l,f){return f||(f=p.create()),l.dimValue!=null&&Object.hasOwnProperty.call(l,"dimValue")&&f.uint32(8).int64(l.dimValue),l.dimParam!=null&&Object.hasOwnProperty.call(l,"dimParam")&&f.uint32(18).string(l.dimParam),l.denotation!=null&&Object.hasOwnProperty.call(l,"denotation")&&f.uint32(26).string(l.denotation),f},r.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},r.decode=function(l,f){l instanceof a||(l=a.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TensorShapeProto.Dimension;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.dimValue=l.int64();break}case 2:{b.dimParam=l.string();break}case 3:{b.denotation=l.string();break}default:l.skipType(v&7);break}}return b},r.decodeDelimited=function(l){return l instanceof a||(l=new a(l)),this.decode(l,l.uint32())},r.verify=function(l){if(typeof l!="object"||l===null)return"object expected";var f={};if(l.dimValue!=null&&l.hasOwnProperty("dimValue")&&(f.value=1,!o.isInteger(l.dimValue)&&!(l.dimValue&&o.isInteger(l.dimValue.low)&&o.isInteger(l.dimValue.high))))return"dimValue: integer|Long expected";if(l.dimParam!=null&&l.hasOwnProperty("dimParam")){if(f.value===1)return"value: multiple values";if(f.value=1,!o.isString(l.dimParam))return"dimParam: string expected"}return l.denotation!=null&&l.hasOwnProperty("denotation")&&!o.isString(l.denotation)?"denotation: string expected":null},r.fromObject=function(l){if(l instanceof s.onnx.TensorShapeProto.Dimension)return l;var f=new s.onnx.TensorShapeProto.Dimension;return l.dimValue!=null&&(o.Long?(f.dimValue=o.Long.fromValue(l.dimValue)).unsigned=!1:typeof l.dimValue=="string"?f.dimValue=parseInt(l.dimValue,10):typeof l.dimValue=="number"?f.dimValue=l.dimValue:typeof l.dimValue=="object"&&(f.dimValue=new o.LongBits(l.dimValue.low>>>0,l.dimValue.high>>>0).toNumber())),l.dimParam!=null&&(f.dimParam=String(l.dimParam)),l.denotation!=null&&(f.denotation=String(l.denotation)),f},r.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.denotation=""),l.dimValue!=null&&l.hasOwnProperty("dimValue")&&(typeof l.dimValue=="number"?g.dimValue=f.longs===String?String(l.dimValue):l.dimValue:g.dimValue=f.longs===String?o.Long.prototype.toString.call(l.dimValue):f.longs===Number?new o.LongBits(l.dimValue.low>>>0,l.dimValue.high>>>0).toNumber():l.dimValue,f.oneofs&&(g.value="dimValue")),l.dimParam!=null&&l.hasOwnProperty("dimParam")&&(g.dimParam=l.dimParam,f.oneofs&&(g.value="dimParam")),l.denotation!=null&&l.hasOwnProperty("denotation")&&(g.denotation=l.denotation),g},r.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},r.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TensorShapeProto.Dimension"},r}(),h}(),c.TypeProto=function(){function h(u){if(u)for(var l=Object.keys(u),f=0;f<l.length;++f)u[l[f]]!=null&&(this[l[f]]=u[l[f]])}h.prototype.tensorType=null,h.prototype.sequenceType=null,h.prototype.mapType=null,h.prototype.optionalType=null,h.prototype.sparseTensorType=null,h.prototype.denotation="";var r;return Object.defineProperty(h.prototype,"value",{get:o.oneOfGetter(r=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:o.oneOfSetter(r)}),h.create=function(u){return new h(u)},h.encode=function(u,l){return l||(l=p.create()),u.tensorType!=null&&Object.hasOwnProperty.call(u,"tensorType")&&s.onnx.TypeProto.Tensor.encode(u.tensorType,l.uint32(10).fork()).ldelim(),u.sequenceType!=null&&Object.hasOwnProperty.call(u,"sequenceType")&&s.onnx.TypeProto.Sequence.encode(u.sequenceType,l.uint32(34).fork()).ldelim(),u.mapType!=null&&Object.hasOwnProperty.call(u,"mapType")&&s.onnx.TypeProto.Map.encode(u.mapType,l.uint32(42).fork()).ldelim(),u.denotation!=null&&Object.hasOwnProperty.call(u,"denotation")&&l.uint32(50).string(u.denotation),u.sparseTensorType!=null&&Object.hasOwnProperty.call(u,"sparseTensorType")&&s.onnx.TypeProto.SparseTensor.encode(u.sparseTensorType,l.uint32(66).fork()).ldelim(),u.optionalType!=null&&Object.hasOwnProperty.call(u,"optionalType")&&s.onnx.TypeProto.Optional.encode(u.optionalType,l.uint32(74).fork()).ldelim(),l},h.encodeDelimited=function(u,l){return this.encode(u,l).ldelim()},h.decode=function(u,l){u instanceof a||(u=a.create(u));for(var f=l===void 0?u.len:u.pos+l,g=new s.onnx.TypeProto;u.pos<f;){var b=u.uint32();switch(b>>>3){case 1:{g.tensorType=s.onnx.TypeProto.Tensor.decode(u,u.uint32());break}case 4:{g.sequenceType=s.onnx.TypeProto.Sequence.decode(u,u.uint32());break}case 5:{g.mapType=s.onnx.TypeProto.Map.decode(u,u.uint32());break}case 9:{g.optionalType=s.onnx.TypeProto.Optional.decode(u,u.uint32());break}case 8:{g.sparseTensorType=s.onnx.TypeProto.SparseTensor.decode(u,u.uint32());break}case 6:{g.denotation=u.string();break}default:u.skipType(b&7);break}}return g},h.decodeDelimited=function(u){return u instanceof a||(u=new a(u)),this.decode(u,u.uint32())},h.verify=function(u){if(typeof u!="object"||u===null)return"object expected";var l={};if(u.tensorType!=null&&u.hasOwnProperty("tensorType")){l.value=1;{var f=s.onnx.TypeProto.Tensor.verify(u.tensorType);if(f)return"tensorType."+f}}if(u.sequenceType!=null&&u.hasOwnProperty("sequenceType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Sequence.verify(u.sequenceType);if(f)return"sequenceType."+f}}if(u.mapType!=null&&u.hasOwnProperty("mapType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Map.verify(u.mapType);if(f)return"mapType."+f}}if(u.optionalType!=null&&u.hasOwnProperty("optionalType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.Optional.verify(u.optionalType);if(f)return"optionalType."+f}}if(u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")){if(l.value===1)return"value: multiple values";l.value=1;{var f=s.onnx.TypeProto.SparseTensor.verify(u.sparseTensorType);if(f)return"sparseTensorType."+f}}return u.denotation!=null&&u.hasOwnProperty("denotation")&&!o.isString(u.denotation)?"denotation: string expected":null},h.fromObject=function(u){if(u instanceof s.onnx.TypeProto)return u;var l=new s.onnx.TypeProto;if(u.tensorType!=null){if(typeof u.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");l.tensorType=s.onnx.TypeProto.Tensor.fromObject(u.tensorType)}if(u.sequenceType!=null){if(typeof u.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");l.sequenceType=s.onnx.TypeProto.Sequence.fromObject(u.sequenceType)}if(u.mapType!=null){if(typeof u.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");l.mapType=s.onnx.TypeProto.Map.fromObject(u.mapType)}if(u.optionalType!=null){if(typeof u.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");l.optionalType=s.onnx.TypeProto.Optional.fromObject(u.optionalType)}if(u.sparseTensorType!=null){if(typeof u.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");l.sparseTensorType=s.onnx.TypeProto.SparseTensor.fromObject(u.sparseTensorType)}return u.denotation!=null&&(l.denotation=String(u.denotation)),l},h.toObject=function(u,l){l||(l={});var f={};return l.defaults&&(f.denotation=""),u.tensorType!=null&&u.hasOwnProperty("tensorType")&&(f.tensorType=s.onnx.TypeProto.Tensor.toObject(u.tensorType,l),l.oneofs&&(f.value="tensorType")),u.sequenceType!=null&&u.hasOwnProperty("sequenceType")&&(f.sequenceType=s.onnx.TypeProto.Sequence.toObject(u.sequenceType,l),l.oneofs&&(f.value="sequenceType")),u.mapType!=null&&u.hasOwnProperty("mapType")&&(f.mapType=s.onnx.TypeProto.Map.toObject(u.mapType,l),l.oneofs&&(f.value="mapType")),u.denotation!=null&&u.hasOwnProperty("denotation")&&(f.denotation=u.denotation),u.sparseTensorType!=null&&u.hasOwnProperty("sparseTensorType")&&(f.sparseTensorType=s.onnx.TypeProto.SparseTensor.toObject(u.sparseTensorType,l),l.oneofs&&(f.value="sparseTensorType")),u.optionalType!=null&&u.hasOwnProperty("optionalType")&&(f.optionalType=s.onnx.TypeProto.Optional.toObject(u.optionalType,l),l.oneofs&&(f.value="optionalType")),f},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto"},h.Tensor=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&f.uint32(8).int32(l.elemType),l.shape!=null&&Object.hasOwnProperty.call(l,"shape")&&s.onnx.TensorShapeProto.encode(l.shape,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof a||(l=a.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Tensor;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=l.int32();break}case 2:{b.shape=s.onnx.TensorShapeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof a||(l=new a(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")&&!o.isInteger(l.elemType))return"elemType: integer expected";if(l.shape!=null&&l.hasOwnProperty("shape")){var f=s.onnx.TensorShapeProto.verify(l.shape);if(f)return"shape."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Tensor)return l;var f=new s.onnx.TypeProto.Tensor;if(l.elemType!=null&&(f.elemType=l.elemType|0),l.shape!=null){if(typeof l.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");f.shape=s.onnx.TensorShapeProto.fromObject(l.shape)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=l.elemType),l.shape!=null&&l.hasOwnProperty("shape")&&(g.shape=s.onnx.TensorShapeProto.toObject(l.shape,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Tensor"},u}(),h.Sequence=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&s.onnx.TypeProto.encode(l.elemType,f.uint32(10).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof a||(l=a.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Sequence;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof a||(l=new a(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")){var f=s.onnx.TypeProto.verify(l.elemType);if(f)return"elemType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Sequence)return l;var f=new s.onnx.TypeProto.Sequence;if(l.elemType!=null){if(typeof l.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");f.elemType=s.onnx.TypeProto.fromObject(l.elemType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=s.onnx.TypeProto.toObject(l.elemType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Sequence"},u}(),h.Map=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.keyType=0,u.prototype.valueType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.keyType!=null&&Object.hasOwnProperty.call(l,"keyType")&&f.uint32(8).int32(l.keyType),l.valueType!=null&&Object.hasOwnProperty.call(l,"valueType")&&s.onnx.TypeProto.encode(l.valueType,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof a||(l=a.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Map;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.keyType=l.int32();break}case 2:{b.valueType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof a||(l=new a(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.keyType!=null&&l.hasOwnProperty("keyType")&&!o.isInteger(l.keyType))return"keyType: integer expected";if(l.valueType!=null&&l.hasOwnProperty("valueType")){var f=s.onnx.TypeProto.verify(l.valueType);if(f)return"valueType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Map)return l;var f=new s.onnx.TypeProto.Map;if(l.keyType!=null&&(f.keyType=l.keyType|0),l.valueType!=null){if(typeof l.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");f.valueType=s.onnx.TypeProto.fromObject(l.valueType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.keyType=0,g.valueType=null),l.keyType!=null&&l.hasOwnProperty("keyType")&&(g.keyType=l.keyType),l.valueType!=null&&l.hasOwnProperty("valueType")&&(g.valueType=s.onnx.TypeProto.toObject(l.valueType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Map"},u}(),h.Optional=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&s.onnx.TypeProto.encode(l.elemType,f.uint32(10).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof a||(l=a.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.Optional;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=s.onnx.TypeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof a||(l=new a(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")){var f=s.onnx.TypeProto.verify(l.elemType);if(f)return"elemType."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.Optional)return l;var f=new s.onnx.TypeProto.Optional;if(l.elemType!=null){if(typeof l.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");f.elemType=s.onnx.TypeProto.fromObject(l.elemType)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=s.onnx.TypeProto.toObject(l.elemType,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.Optional"},u}(),h.SparseTensor=function(){function u(l){if(l)for(var f=Object.keys(l),g=0;g<f.length;++g)l[f[g]]!=null&&(this[f[g]]=l[f[g]])}return u.prototype.elemType=0,u.prototype.shape=null,u.create=function(l){return new u(l)},u.encode=function(l,f){return f||(f=p.create()),l.elemType!=null&&Object.hasOwnProperty.call(l,"elemType")&&f.uint32(8).int32(l.elemType),l.shape!=null&&Object.hasOwnProperty.call(l,"shape")&&s.onnx.TensorShapeProto.encode(l.shape,f.uint32(18).fork()).ldelim(),f},u.encodeDelimited=function(l,f){return this.encode(l,f).ldelim()},u.decode=function(l,f){l instanceof a||(l=a.create(l));for(var g=f===void 0?l.len:l.pos+f,b=new s.onnx.TypeProto.SparseTensor;l.pos<g;){var v=l.uint32();switch(v>>>3){case 1:{b.elemType=l.int32();break}case 2:{b.shape=s.onnx.TensorShapeProto.decode(l,l.uint32());break}default:l.skipType(v&7);break}}return b},u.decodeDelimited=function(l){return l instanceof a||(l=new a(l)),this.decode(l,l.uint32())},u.verify=function(l){if(typeof l!="object"||l===null)return"object expected";if(l.elemType!=null&&l.hasOwnProperty("elemType")&&!o.isInteger(l.elemType))return"elemType: integer expected";if(l.shape!=null&&l.hasOwnProperty("shape")){var f=s.onnx.TensorShapeProto.verify(l.shape);if(f)return"shape."+f}return null},u.fromObject=function(l){if(l instanceof s.onnx.TypeProto.SparseTensor)return l;var f=new s.onnx.TypeProto.SparseTensor;if(l.elemType!=null&&(f.elemType=l.elemType|0),l.shape!=null){if(typeof l.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");f.shape=s.onnx.TensorShapeProto.fromObject(l.shape)}return f},u.toObject=function(l,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),l.elemType!=null&&l.hasOwnProperty("elemType")&&(g.elemType=l.elemType),l.shape!=null&&l.hasOwnProperty("shape")&&(g.shape=s.onnx.TensorShapeProto.toObject(l.shape,f)),g},u.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},u.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto.SparseTensor"},u}(),h}(),c.OperatorSetIdProto=function(){function h(r){if(r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.domain="",h.prototype.version=o.Long?o.Long.fromBits(0,0,!1):0,h.create=function(r){return new h(r)},h.encode=function(r,u){return u||(u=p.create()),r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(10).string(r.domain),r.version!=null&&Object.hasOwnProperty.call(r,"version")&&u.uint32(16).int64(r.version),u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.OperatorSetIdProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.domain=r.string();break}case 2:{f.version=r.int64();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){return typeof r!="object"||r===null?"object expected":r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain)?"domain: string expected":r.version!=null&&r.hasOwnProperty("version")&&!o.isInteger(r.version)&&!(r.version&&o.isInteger(r.version.low)&&o.isInteger(r.version.high))?"version: integer|Long expected":null},h.fromObject=function(r){if(r instanceof s.onnx.OperatorSetIdProto)return r;var u=new s.onnx.OperatorSetIdProto;return r.domain!=null&&(u.domain=String(r.domain)),r.version!=null&&(o.Long?(u.version=o.Long.fromValue(r.version)).unsigned=!1:typeof r.version=="string"?u.version=parseInt(r.version,10):typeof r.version=="number"?u.version=r.version:typeof r.version=="object"&&(u.version=new o.LongBits(r.version.low>>>0,r.version.high>>>0).toNumber())),u},h.toObject=function(r,u){u||(u={});var l={};if(u.defaults)if(l.domain="",o.Long){var f=new o.Long(0,0,!1);l.version=u.longs===String?f.toString():u.longs===Number?f.toNumber():f}else l.version=u.longs===String?"0":0;return r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.version!=null&&r.hasOwnProperty("version")&&(typeof r.version=="number"?l.version=u.longs===String?String(r.version):r.version:l.version=u.longs===String?o.Long.prototype.toString.call(r.version):u.longs===Number?new o.LongBits(r.version.low>>>0,r.version.high>>>0).toNumber():r.version),l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.OperatorSetIdProto"},h}(),c.OperatorStatus=function(){var h={},r=Object.create(h);return r[h[0]="EXPERIMENTAL"]=0,r[h[1]="STABLE"]=1,r}(),c.FunctionProto=function(){function h(r){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],r)for(var u=Object.keys(r),l=0;l<u.length;++l)r[u[l]]!=null&&(this[u[l]]=r[u[l]])}return h.prototype.name="",h.prototype.input=o.emptyArray,h.prototype.output=o.emptyArray,h.prototype.attribute=o.emptyArray,h.prototype.attributeProto=o.emptyArray,h.prototype.node=o.emptyArray,h.prototype.docString="",h.prototype.opsetImport=o.emptyArray,h.prototype.domain="",h.create=function(r){return new h(r)},h.encode=function(r,u){if(u||(u=p.create()),r.name!=null&&Object.hasOwnProperty.call(r,"name")&&u.uint32(10).string(r.name),r.input!=null&&r.input.length)for(var l=0;l<r.input.length;++l)u.uint32(34).string(r.input[l]);if(r.output!=null&&r.output.length)for(var l=0;l<r.output.length;++l)u.uint32(42).string(r.output[l]);if(r.attribute!=null&&r.attribute.length)for(var l=0;l<r.attribute.length;++l)u.uint32(50).string(r.attribute[l]);if(r.node!=null&&r.node.length)for(var l=0;l<r.node.length;++l)s.onnx.NodeProto.encode(r.node[l],u.uint32(58).fork()).ldelim();if(r.docString!=null&&Object.hasOwnProperty.call(r,"docString")&&u.uint32(66).string(r.docString),r.opsetImport!=null&&r.opsetImport.length)for(var l=0;l<r.opsetImport.length;++l)s.onnx.OperatorSetIdProto.encode(r.opsetImport[l],u.uint32(74).fork()).ldelim();if(r.domain!=null&&Object.hasOwnProperty.call(r,"domain")&&u.uint32(82).string(r.domain),r.attributeProto!=null&&r.attributeProto.length)for(var l=0;l<r.attributeProto.length;++l)s.onnx.AttributeProto.encode(r.attributeProto[l],u.uint32(90).fork()).ldelim();return u},h.encodeDelimited=function(r,u){return this.encode(r,u).ldelim()},h.decode=function(r,u){r instanceof a||(r=a.create(r));for(var l=u===void 0?r.len:r.pos+u,f=new s.onnx.FunctionProto;r.pos<l;){var g=r.uint32();switch(g>>>3){case 1:{f.name=r.string();break}case 4:{f.input&&f.input.length||(f.input=[]),f.input.push(r.string());break}case 5:{f.output&&f.output.length||(f.output=[]),f.output.push(r.string());break}case 6:{f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(r.string());break}case 11:{f.attributeProto&&f.attributeProto.length||(f.attributeProto=[]),f.attributeProto.push(s.onnx.AttributeProto.decode(r,r.uint32()));break}case 7:{f.node&&f.node.length||(f.node=[]),f.node.push(s.onnx.NodeProto.decode(r,r.uint32()));break}case 8:{f.docString=r.string();break}case 9:{f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(s.onnx.OperatorSetIdProto.decode(r,r.uint32()));break}case 10:{f.domain=r.string();break}default:r.skipType(g&7);break}}return f},h.decodeDelimited=function(r){return r instanceof a||(r=new a(r)),this.decode(r,r.uint32())},h.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.name!=null&&r.hasOwnProperty("name")&&!o.isString(r.name))return"name: string expected";if(r.input!=null&&r.hasOwnProperty("input")){if(!Array.isArray(r.input))return"input: array expected";for(var u=0;u<r.input.length;++u)if(!o.isString(r.input[u]))return"input: string[] expected"}if(r.output!=null&&r.hasOwnProperty("output")){if(!Array.isArray(r.output))return"output: array expected";for(var u=0;u<r.output.length;++u)if(!o.isString(r.output[u]))return"output: string[] expected"}if(r.attribute!=null&&r.hasOwnProperty("attribute")){if(!Array.isArray(r.attribute))return"attribute: array expected";for(var u=0;u<r.attribute.length;++u)if(!o.isString(r.attribute[u]))return"attribute: string[] expected"}if(r.attributeProto!=null&&r.hasOwnProperty("attributeProto")){if(!Array.isArray(r.attributeProto))return"attributeProto: array expected";for(var u=0;u<r.attributeProto.length;++u){var l=s.onnx.AttributeProto.verify(r.attributeProto[u]);if(l)return"attributeProto."+l}}if(r.node!=null&&r.hasOwnProperty("node")){if(!Array.isArray(r.node))return"node: array expected";for(var u=0;u<r.node.length;++u){var l=s.onnx.NodeProto.verify(r.node[u]);if(l)return"node."+l}}if(r.docString!=null&&r.hasOwnProperty("docString")&&!o.isString(r.docString))return"docString: string expected";if(r.opsetImport!=null&&r.hasOwnProperty("opsetImport")){if(!Array.isArray(r.opsetImport))return"opsetImport: array expected";for(var u=0;u<r.opsetImport.length;++u){var l=s.onnx.OperatorSetIdProto.verify(r.opsetImport[u]);if(l)return"opsetImport."+l}}return r.domain!=null&&r.hasOwnProperty("domain")&&!o.isString(r.domain)?"domain: string expected":null},h.fromObject=function(r){if(r instanceof s.onnx.FunctionProto)return r;var u=new s.onnx.FunctionProto;if(r.name!=null&&(u.name=String(r.name)),r.input){if(!Array.isArray(r.input))throw TypeError(".onnx.FunctionProto.input: array expected");u.input=[];for(var l=0;l<r.input.length;++l)u.input[l]=String(r.input[l])}if(r.output){if(!Array.isArray(r.output))throw TypeError(".onnx.FunctionProto.output: array expected");u.output=[];for(var l=0;l<r.output.length;++l)u.output[l]=String(r.output[l])}if(r.attribute){if(!Array.isArray(r.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");u.attribute=[];for(var l=0;l<r.attribute.length;++l)u.attribute[l]=String(r.attribute[l])}if(r.attributeProto){if(!Array.isArray(r.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");u.attributeProto=[];for(var l=0;l<r.attributeProto.length;++l){if(typeof r.attributeProto[l]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");u.attributeProto[l]=s.onnx.AttributeProto.fromObject(r.attributeProto[l])}}if(r.node){if(!Array.isArray(r.node))throw TypeError(".onnx.FunctionProto.node: array expected");u.node=[];for(var l=0;l<r.node.length;++l){if(typeof r.node[l]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");u.node[l]=s.onnx.NodeProto.fromObject(r.node[l])}}if(r.docString!=null&&(u.docString=String(r.docString)),r.opsetImport){if(!Array.isArray(r.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");u.opsetImport=[];for(var l=0;l<r.opsetImport.length;++l){if(typeof r.opsetImport[l]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");u.opsetImport[l]=s.onnx.OperatorSetIdProto.fromObject(r.opsetImport[l])}}return r.domain!=null&&(u.domain=String(r.domain)),u},h.toObject=function(r,u){u||(u={});var l={};if((u.arrays||u.defaults)&&(l.input=[],l.output=[],l.attribute=[],l.node=[],l.opsetImport=[],l.attributeProto=[]),u.defaults&&(l.name="",l.docString="",l.domain=""),r.name!=null&&r.hasOwnProperty("name")&&(l.name=r.name),r.input&&r.input.length){l.input=[];for(var f=0;f<r.input.length;++f)l.input[f]=r.input[f]}if(r.output&&r.output.length){l.output=[];for(var f=0;f<r.output.length;++f)l.output[f]=r.output[f]}if(r.attribute&&r.attribute.length){l.attribute=[];for(var f=0;f<r.attribute.length;++f)l.attribute[f]=r.attribute[f]}if(r.node&&r.node.length){l.node=[];for(var f=0;f<r.node.length;++f)l.node[f]=s.onnx.NodeProto.toObject(r.node[f],u)}if(r.docString!=null&&r.hasOwnProperty("docString")&&(l.docString=r.docString),r.opsetImport&&r.opsetImport.length){l.opsetImport=[];for(var f=0;f<r.opsetImport.length;++f)l.opsetImport[f]=s.onnx.OperatorSetIdProto.toObject(r.opsetImport[f],u)}if(r.domain!=null&&r.hasOwnProperty("domain")&&(l.domain=r.domain),r.attributeProto&&r.attributeProto.length){l.attributeProto=[];for(var f=0;f<r.attributeProto.length;++f)l.attributeProto[f]=s.onnx.AttributeProto.toObject(r.attributeProto[f],u)}return l},h.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},h.getTypeUrl=function(r){return r===void 0&&(r="type.googleapis.com"),r+"/onnx.FunctionProto"},h}(),c}(),n.exports=s});function ur(e,n){if(!e)throw new Error(typeof n=="string"?n:n())}function kr(e){return new TextDecoder().decode(e)}var ot,Me,ai,kt,Sn,At,Rt,B,$r,Ue,Ve,ze,Y=O(()=>{wn(),qo(),ot=rr(sr()),We(),Me=class{static arraysEqual(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==n[i])return!1;return!0}},ai=class{static preprocessInputShapes(e,n){let i=e.length===1?[1,e[0]]:e,a=n.length===1?[n[0],1]:n;return[i,a]}static postprocessOutputShape(e,n,i){n===1&&e.splice(e.length-2,1),i===1&&e.pop()}static calcMatMulShape(e,n){return e[1]!==n[0]?void 0:[e[0],n[1]]}},kt=class ve{static calcShape(n,i,a=!1){let p=n.length,o=i.length;if(p===0)return i;if(o===0)return n;let s=Math.max(n.length,i.length),c=new Array(s);if(a){if(p<2||o<2)return;let h=ai.calcMatMulShape([n[p-2],n[p-1]],[i[o-2],i[o-1]]);if(h===void 0)return;[c[s-2],c[s-1]]=h}for(let h=a?3:1;h<=s;h++){let r=p-h<0?1:n[p-h],u=o-h<0?1:i[o-h];if(r!==u&&r>1&&u>1)return;c[s-h]=Math.max(r,u)}return c}static index(n,i){let a=new Array(i.length);return ve.fillIndex(n,i,a),a}static fillIndex(n,i,a){let p=n.length-i.length;for(let o=0;o<i.length;o++)a[o]=n[p+o]%i[o]}static calc(n,i,a,p,o){let s=ve.calcShape(n.dims,i.dims);if(s){if(p&&!B.areEqual(s,n.dims))return;let c=B.size(s),h=p?n:new bt(s,o||n.type);if(s.length===0)h.set([],a(n.get([]),i.get([])));else{let r=new Array(s.length),u=new Array(n.dims.length),l=new Array(i.dims.length),f=0,g=0,b=!1,v=!1;n.dims.length===0&&(f=n.get([]),b=!0),i.dims.length===0&&(g=i.get([]),v=!0);let S;for(let P=0;P<c;P++){S=P;for(let _=s.length-1;_>=0;_--)r[_]=S%s[_],S=Math.floor(S/s[_]);b||(ve.fillIndex(r,n.dims,u),f=n.get(u)),v||(ve.fillIndex(r,i.dims,l),g=i.get(l)),h.set(r,a(f,g))}}return h}}static isValidBroadcast(n,i){let a=n.length,p=i.length;if(a>p)return!1;for(let o=1;o<=a;o++)if(n[a-o]!==1&&n[a-o]!==i[p-o])return!1;return!0}static getBroadcastDims(n,i){let a=n.length,p=[];for(let o=0;o<a;o++){let s=a-1-o,c=n[s]||1;(i[i.length-1-o]||1)>1&&c===1&&p.unshift(s)}return p}},Sn=class{static getShapeOfGemmResult(e,n,i,a,p){if(e.length!==2||i.length!==2)throw new Error("shape need to be of size 2");let o,s,c;n?(o=e[1],s=e[0]):(o=e[0],s=e[1]);let h=-1;if(a?(c=i[0],h=1):(c=i[1],h=0),i[h]!==s)throw new Error("dimension mismatch");if(o<=0||c<=0||s<=0)throw new Error("invalid shape specified");if(p&&!kt.isValidBroadcast(p,[o,c]))throw new Error("gemm: invalid bias shape for broadcast");return[o,c,s]}},At=class rn{static tensorDataTypeFromProto(n){switch(n){case ot.onnx.TensorProto.DataType.INT8:return"int8";case ot.onnx.TensorProto.DataType.UINT8:return"uint8";case ot.onnx.TensorProto.DataType.BOOL:return"bool";case ot.onnx.TensorProto.DataType.INT16:return"int16";case ot.onnx.TensorProto.DataType.UINT16:return"uint16";case ot.onnx.TensorProto.DataType.INT32:return"int32";case ot.onnx.TensorProto.DataType.UINT32:return"uint32";case ot.onnx.TensorProto.DataType.FLOAT:return"float32";case ot.onnx.TensorProto.DataType.DOUBLE:return"float64";case ot.onnx.TensorProto.DataType.STRING:return"string";case ot.onnx.TensorProto.DataType.INT64:return"int32";case ot.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${ot.onnx.TensorProto.DataType[n]}`)}}static tensorDataTypeStringToEnum(n){switch(n){case"int8":return ot.onnx.TensorProto.DataType.INT8;case"uint8":return ot.onnx.TensorProto.DataType.UINT8;case"bool":return ot.onnx.TensorProto.DataType.BOOL;case"int16":return ot.onnx.TensorProto.DataType.INT16;case"uint16":return ot.onnx.TensorProto.DataType.UINT16;case"int32":return ot.onnx.TensorProto.DataType.INT32;case"uint32":return ot.onnx.TensorProto.DataType.UINT32;case"float32":return ot.onnx.TensorProto.DataType.FLOAT;case"float64":return ot.onnx.TensorProto.DataType.DOUBLE;case"string":return ot.onnx.TensorProto.DataType.STRING;case"int64":return ot.onnx.TensorProto.DataType.INT64;case"uint64":return ot.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${n}`)}}static tensorDimsFromProto(n){return n.map(i=>xe.isLong(i)?i.toNumber():i)}static tensorValueTypeFromProto(n){return{tensorType:rn.tensorDataTypeFromProto(n.elemType),shape:{dims:rn.tensorDimsFromProto(n.shape.dim.map(i=>i.dimValue))}}}static tensorDimsFromORTFormat(n){let i=[];for(let a=0;a<n.dimsLength();a++)i.push(Rt.longToNumber(n.dims(a)));return i}static tensorAttributesFromORTFormat(n){let i=[];for(let a=0;a<n.attributesLength();a++)i.push(n.attributes(a));return i}},Rt=class{static longToNumber(e,n){return xe.isLong(e)?e.toNumber():e instanceof w.Long?xe.fromValue({low:e.low,high:e.high,unsigned:n??!1}).toNumber():e}static isLong(e){return xe.isLong(e)||e instanceof w.Long}},B=class ee{static size(n){return ee.getSizeFromDimensionRange(n,0,n.length)}static sizeFromDimension(n,i){if(i<0||i>n.length)throw new Error(`invalid dimension of ${i} for sizeFromDimension as Tensor has ${n.length} dimensions.`);return ee.getSizeFromDimensionRange(n,i,n.length)}static sizeToDimension(n,i){if(i<0||i>n.length)throw new Error(`invalid dimension of ${i} for sizeToDimension as Tensor has ${n.length} dimensions.`);return ee.getSizeFromDimensionRange(n,0,i)}static getSizeFromDimensionRange(n,i,a){let p=1;for(let o=i;o<a;o++){if(n[o]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");p*=n[o]}return p}static computeStrides(n){let i=n.length;if(i===0)return[];if(i===1)return[1];let a=new Array(i);a[i-1]=1,a[i-2]=n[i-1];for(let p=i-3;p>=0;--p)a[p]=a[p+1]*n[p+1];return a}static transpose(n){return n.slice().reverse()}static indicesToOffset(n,i,a){a===void 0&&(a=n.length);let p=0;for(let o=0;o<a;++o)p+=i[o]*n[o];return p}static offsetToIndices(n,i){let a=i.length;if(a===0)return[];if(a===1)return[n*i[0]];let p=new Array(i.length);for(let o=0;o<p.length-1;++o)p[o]=Math.floor(n/i[o]),n-=p[o]*i[o];return p[p.length-1]=n,p}static normalizeAxis(n,i){if(n<-i&&n>=i)throw new Error("unsupported axis for this operation.");return n<0?n+i:n}static normalizeAxes(n,i){return n.map(a=>this.normalizeAxis(a,i))}static incrementIndex(n,i,a){if(i.length===0||n.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(a===void 0)a=i.length;else if(a<=0||a>i.length)throw new Error("Incorrect axis to increment on");for(let p=a-1;p>=0&&(n[p]++,!(n[p]<i[p]));--p)n[p]=0}static calculateReshapedDims(n,i){if(i.length===0){if(n.length===0||ee.size(n)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}let a=i.length,p=new Array(a),o=-1,s=1;for(let h=0;h<a;h++){if(i[h]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(i[h]===-1){if(o!==-1)throw new Error("at most one dimension in shape hints can be -1");o=h}else{if(i[h]===0){if(h>=n.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");p[h]=n[h]}else p[h]=i[h];s*=p[h]}}let c=ee.size(n);if(o!==-1){if(c%s!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${n}] Output shape: [${i}]`);p[o]=c/s}else if(s!==c)throw new Error("reshapedDims and originalDims don't have matching sizes");return p}static sortBasedOnPerm(n,i){return i?i.map(a=>n[a]):n.slice().reverse()}static padShape(n,i){let a=n.length;return n.map((p,o)=>p+i[o]+i[o+a])}static areEqual(n,i){return n.length!==i.length?!1:n.every((a,p)=>a===i[p])}static validateDimsAndCalcSize(n){if(n.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let i=1;for(let a of n){if(!Number.isInteger(a))throw new TypeError(`Invalid shape: ${a} is not an integer`);if(a<0||a>2147483647)throw new TypeError(`Invalid shape: length ${a} is not allowed`);i*=a}return i}static flattenShape(n,i){i<0&&(i+=n.length);let a=n.reduce((o,s)=>o*s,1),p=n.slice(i).reduce((o,s)=>o*s,1);return[a/p,p]}static squeezeShape(n,i){let a=new Array;i=ee.normalizeAxes(i,n.length);for(let p=0;p<n.length;p++){let o=i.indexOf(p)>=0;if(o&&n[p]!==1)throw new Error("squeeze an axis of size different than 1");(i.length===0&&n[p]>1||i.length>0&&!o)&&a.push(n[p])}return a}static unsqueezeShape(n,i){let a=new Array(n.length+i.length);a.fill(0);for(let o=0;o<i.length;o++){let s=ee.normalizeAxis(i[o],a.length);if(s>=a.length)throw new Error("'axes' has an out of range axis");if(a[s]!==0)throw new Error("'axes' has a duplicate axis");a[s]=1}let p=0;for(let o=0;o<a.length;o++)a[o]===0&&(a[o]=n[p++]);if(p!==n.length)throw new Error("the unsqueezed dimension could not be established");return a}},$r=class Ea{static splitShape(n,i,a,p){if(a.length===0){if(!p)throw new Error("need to know number of outputs when the 'split' attribute is not specified");Ea.determineSplit(n[i],p,a)}let o=[],s=[0];for(let c=0;c<a.length;++c){c!==0&&s.push(s[c-1]+a[c-1]);let h=n.slice();h[i]=a[c],o.push(h)}return[o,s]}static determineSplit(n,i,a){if(n%i!==0)throw new Error("cannot split tensor to equal sized parts");for(let p=0;p<i;++p)a.push(n/i)}},Ue=class Oe{static adjustPoolAttributes(n,i,a,p,o,s){if(!n&&a.length!==i.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(n)for(let c=0;c<i.length-2;c++)c>=a.length?a.push(i[c+2]):a[c]=i[c+2];for(let c=0;c<a.length;c++)if(c<p.length){if(p[c]<0)throw new Error("strides should be greater than or equal to 1")}else p.push(1);for(let c=0;c<a.length;c++)if(c<o.length){if(o[c]<0)throw new Error("dilations should be greater than or equal to 1")}else o.push(1);for(let c=0;c<a.length*2;c++)if(c<s.length){if(s[c]<0)throw new Error("pad should be greater than or equal to 1")}else s.push(0);for(let c=0;c<a.length;c++){if(a[c]<=0)throw new Error("kernel shapes need to be greater than 0");if(s[c]>=a[c]||s[c+a.length]>=a[c])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(n,i,a,p,o,s){if(s){if(o.length!==2*(n.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(i.length!==n.length-2)throw new Error("length of strides should be the length of data dimensions");if(p.length!==n.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let c=0;c<n.length-2;c++)Oe.adjustPadAndReturnShape(n[c+2],i[c],a[c],p[c],o,c,c+n.length-2,s)}}static computePoolOutputShape(n,i,a,p,o,s,c){if(i.length<=0)throw new Error("input shape must be of size greater than 0");let h=[i[0],i[1]];return Oe.computeShapeHelper(n,i,h,a,p,o,s,c),h}static computeConvOutputShape(n,i,a,p,o,s,c){if(n.length<=0||i.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let h=[n[0],i[0]];return Oe.computeShapeHelper(!1,n,h,a,p,o,s,c),h}static computeShapeHelper(n,i,a,p,o,s,c,h){if(n)for(let r=0;r<i.length-2;r++)a.push(1);else for(let r=0;r<i.length-2;r++)a.push(Oe.adjustPadAndReturnShape(i[r+2],p[r],o[r],s[r],c,r,r+i.length-2,h))}static adjustPadAndReturnShape(n,i,a,p,o,s,c,h){let r=a*(p-1)+1;if(h&&h!=="NOTSET")switch(h){case"VALID":return o[s]=0,o[c]=0,Math.floor((n-r)/i+1);case"SAME_LOWER":case"SAME_UPPER":if(a!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let u=((n+i-1)/i-1)*i+p-n;return o[s]=Math.floor(h==="SAME_LOWER"?(u+1)/2:u/2),o[c]=u-o[s],Math.floor((n+u-p)/i+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((n+o[s]+o[c]-r)/i+1)}},Ve=-34028234663852886e22,ze=34028234663852886e22});function hh(e){switch(e){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${e}`)}}function Wu(e){switch(e){case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.BOOL:return 1;case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT16:return 2;case H.onnx.TensorProto.DataType.FLOAT:case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.UINT32:return 4;case H.onnx.TensorProto.DataType.INT64:case H.onnx.TensorProto.DataType.DOUBLE:case H.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${H.onnx.TensorProto.DataType[e]}`)}}function mh(e,n){return new(ju(n))(e)}function ju(e){switch(e){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function ui(e,n){if(n===H.onnx.TensorProto.DataType.INT64||n===si.TensorDataType.INT64){if(e.greaterThanOrEqual(2147483648)||e.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(n===H.onnx.TensorProto.DataType.UINT32||n===si.TensorDataType.UINT32||n===H.onnx.TensorProto.DataType.UINT64||n===si.TensorDataType.UINT64){if(e.greaterThanOrEqual(4294967296)||e.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${H.onnx.TensorProto.DataType[n]}`);return e.toNumber()}function Hu(e,n,i){switch(n){case H.onnx.TensorProto.DataType.BOOL:case H.onnx.TensorProto.DataType.UINT8:return e.getUint8(i);case H.onnx.TensorProto.DataType.INT8:return e.getInt8(i);case H.onnx.TensorProto.DataType.UINT16:return e.getUint16(i,!0);case H.onnx.TensorProto.DataType.INT16:return e.getInt16(i,!0);case H.onnx.TensorProto.DataType.FLOAT:return e.getFloat32(i,!0);case H.onnx.TensorProto.DataType.INT32:return e.getInt32(i,!0);case H.onnx.TensorProto.DataType.UINT32:return e.getUint32(i,!0);case H.onnx.TensorProto.DataType.INT64:return ui(xe.fromBits(e.getUint32(i,!0),e.getUint32(i+4,!0),!1),n);case H.onnx.TensorProto.DataType.DOUBLE:return e.getFloat64(i,!0);case H.onnx.TensorProto.DataType.UINT64:return ui(xe.fromBits(e.getUint32(i,!0),e.getUint32(i+4,!0),!0),n);default:throw new Error(`cannot read from DataView for type ${H.onnx.TensorProto.DataType[n]}`)}}var qu,H,si,bt,We=O(()=>{qu=rr(Fs()),qo(),Pr(),H=rr(sr()),Y(),si=F.experimental.fbs,bt=class wr{constructor(n,i,a,p,o,s=qu.Guid.create()){this.dims=n,this.type=i,this.dataProvider=a,this.asyncDataProvider=p,this.cache=o,this.dataId=s,this.size=B.validateDimsAndCalcSize(n);let c=this.size,h=a===void 0&&p===void 0&&o===void 0;if(o!==void 0&&o.length!==c)throw new RangeError("Input dims doesn't match data length.");if(i==="string"){if(o!==void 0&&(!Array.isArray(o)||!o.every(r=>typeof r=="string")))throw new TypeError("cache should be a string array");h&&(this.cache=new Array(c))}else{if(o!==void 0){let r=ju(i);if(!(o instanceof r))throw new TypeError(`cache should be type ${r.name}`)}if(h){let r=new ArrayBuffer(c*hh(i));this.cache=mh(r,i)}}}get data(){if(this.cache===void 0){let n=this.dataProvider(this.dataId);if(n.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=n}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(n){return this.data[B.indicesToOffset(n,this.strides)]}set(n,i){this.data[B.indicesToOffset(n,this.strides)]=i}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=B.computeStrides(this.dims)),this._strides}static fromProto(n){if(!n)throw new Error("cannot construct Value from an empty tensor");let i=At.tensorDataTypeFromProto(n.dataType),a=At.tensorDimsFromProto(n.dims),p=new wr(a,i);if(i==="string")n.stringData.forEach((o,s)=>{p.data[s]=kr(o)});else if(n.rawData&&typeof n.rawData.byteLength=="number"&&n.rawData.byteLength>0){let o=p.data,s=new DataView(n.rawData.buffer,n.rawData.byteOffset,n.rawData.byteLength),c=Wu(n.dataType),h=n.rawData.byteLength/c;if(n.rawData.byteLength%c!==0)throw new Error("invalid buffer length");if(o.length!==h)throw new Error("buffer length mismatch");for(let r=0;r<h;r++){let u=Hu(s,n.dataType,r*c);o[r]=u}}else{let o;switch(n.dataType){case H.onnx.TensorProto.DataType.FLOAT:o=n.floatData;break;case H.onnx.TensorProto.DataType.INT32:case H.onnx.TensorProto.DataType.INT16:case H.onnx.TensorProto.DataType.UINT16:case H.onnx.TensorProto.DataType.INT8:case H.onnx.TensorProto.DataType.UINT8:case H.onnx.TensorProto.DataType.BOOL:o=n.int32Data;break;case H.onnx.TensorProto.DataType.INT64:o=n.int64Data;break;case H.onnx.TensorProto.DataType.DOUBLE:o=n.doubleData;break;case H.onnx.TensorProto.DataType.UINT32:case H.onnx.TensorProto.DataType.UINT64:o=n.uint64Data;break;default:throw new Error("unspecific error")}if(o==null)throw new Error("failed to populate data from a tensorproto value");let s=p.data;if(s.length!==o.length)throw new Error("array length mismatch");for(let c=0;c<o.length;c++){let h=o[c];xe.isLong(h)?s[c]=ui(h,n.dataType):s[c]=h}}return p}static fromData(n,i,a){return new wr(i,a,void 0,void 0,n)}static fromOrtTensor(n){if(!n)throw new Error("cannot construct Value from an empty tensor");let i=At.tensorDimsFromORTFormat(n),a=At.tensorDataTypeFromProto(n.dataType()),p=new wr(i,a);if(a==="string")for(let o=0;o<n.stringDataLength();o++)p.data[o]=n.stringData(o);else if(n.rawDataArray()&&typeof n.rawDataLength()=="number"&&n.rawDataLength()>0){let o=p.data,s=new DataView(n.rawDataArray().buffer,n.rawDataArray().byteOffset,n.rawDataLength()),c=Wu(n.dataType()),h=n.rawDataLength()/c;if(n.rawDataLength()%c!==0)throw new Error("invalid buffer length");if(o.length!==h)throw new Error("buffer length mismatch");for(let r=0;r<h;r++){let u=Hu(s,n.dataType(),r*c);o[r]=u}}return p}}});function G(e){return e===1?bh:gh}function Xu(e){let n=G(e);return`${n.version}
11
11
  precision highp float;
12
12
  ${n.attribute} vec3 position;
13
13
  ${n.attribute} vec2 textureCoord;
@@ -50,14 +50,14 @@
50
50
  return x - y * (x / y);
51
51
  }
52
52
 
53
- `}function Ju(e,n){let a=G(e);return`
53
+ `}function Ju(e,n){let i=G(e);return`
54
54
  void main() {
55
55
  int indices[${n}];
56
56
  toVec(TexCoords, indices);
57
57
  vec4 result = vec4(process(indices));
58
- ${a.output} = result;
58
+ ${i.output} = result;
59
59
  }
60
- `}var bh,gh,ut=O(()=>{bh={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},gh={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),j=O(()=>{});async function li(e,n=i=>0,a){return new Promise((i,p)=>{let o=0,s=()=>{if(e()){i();return}o++;let c=n(o);setTimeout(s,c)};s()})}function An(e){return ur(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)}function Yu(e){return ur(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)+"AtOutCoords"}function lr(e,n){let a=JSON.parse(JSON.stringify(e));return a=n,a}function fr(e,n){return n.map(a=>e[a]).join(", ")}function Bt(e){if(e<=1)return"int";if(e===2)return"ivec2";if(e===3)return"ivec3";if(e===4)return"ivec4";if(e===5)return"ivec5";if(e===6)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function ne(e=6){return["x","y","z","w","u","v"].slice(0,e)}var pe=O(()=>{Y()});function yh(e,n){return ne(n).map(a=>`${e}.${a}`)}function cr(e,n){return n===1?[e]:yh(e,n)}function de(){return`
60
+ `}var bh,gh,ut=O(()=>{bh={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},gh={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),j=O(()=>{});async function li(e,n=a=>0,i){return new Promise((a,p)=>{let o=0,s=()=>{if(e()){a();return}o++;let c=n(o);setTimeout(s,c)};s()})}function An(e){return ur(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)}function Yu(e){return ur(typeof e<"u"&&e.length!==0,()=>"empty string found for sampler name"),"get"+e.charAt(0).toUpperCase()+e.slice(1)+"AtOutCoords"}function lr(e,n){let i=JSON.parse(JSON.stringify(e));return i=n,i}function fr(e,n){return n.map(i=>e[i]).join(", ")}function Bt(e){if(e<=1)return"int";if(e===2)return"ivec2";if(e===3)return"ivec3";if(e===4)return"ivec4";if(e===5)return"ivec5";if(e===6)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function ne(e=6){return["x","y","z","w","u","v"].slice(0,e)}var pe=O(()=>{Y()});function yh(e,n){return ne(n).map(i=>`${e}.${i}`)}function cr(e,n){return n===1?[e]:yh(e,n)}function de(){return`
61
61
  float getChannel(vec4 frag, int dim) {
62
62
  int modCoord = imod(dim, 2);
63
63
  return modCoord == 0 ? frag.r : frag.g;
@@ -69,33 +69,33 @@
69
69
  (modCoord.y == 0. ? frag.r : frag.g) :
70
70
  (modCoord.y == 0. ? frag.b : frag.a);
71
71
  }
72
- `}var He=O(()=>{pe()});function Th(e,n,a){if(e===0)return"false";if(e===1)return`rc > ${n[0]}`;let i="";for(let p=e-2;p<e;p++)i+=`${a[p]} >= ${n[p-e+2]}`,p<e-1&&(i+="||");return i}function wh(e,n){let a=e.length;if(a===0)return"getA(), 0, 0, 0";if(a===1)return`getA(rc),
72
+ `}var He=O(()=>{pe()});function Th(e,n,i){if(e===0)return"false";if(e===1)return`rc > ${n[0]}`;let a="";for(let p=e-2;p<e;p++)a+=`${i[p]} >= ${n[p-e+2]}`,p<e-1&&(a+="||");return a}function wh(e,n){let i=e.length;if(i===0)return"getA(), 0, 0, 0";if(i===1)return`getA(rc),
73
73
  rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),
74
- 0, 0`;let i="r, c",p="r, cp1",o="rp1, c",s="rp1, cp1",c="";if(a>2)for(let h=0;h<a-2;++h)c=c+`${n[h]},`;return`getA(${c}${i}),
74
+ 0, 0`;let a="r, c",p="r, cp1",o="rp1, c",s="rp1, cp1",c="";if(i>2)for(let h=0;h<i-2;++h)c=c+`${n[h]},`;return`getA(${c}${a}),
75
75
  rEdge ? 0. : getA(${c}${o}),
76
76
  cEdge ? 0. : getA(${c}${p}),
77
- rEdge || cEdge ? 0. : getA(${c}${s})`}function vh(e,n,a,i){return e===0||e===1?"":`
77
+ rEdge || cEdge ? 0. : getA(${c}${s})`}function vh(e,n,i,a){return e===0||e===1?"":`
78
78
  int r = ${n[e-2]};
79
79
  int c = ${n[e-1]};
80
80
  int rp1 = ${n[e-2]} + 1;
81
81
  int cp1 = ${n[e-1]} + 1;
82
- bool rEdge = rp1 >= ${i};
83
- bool cEdge = cp1 >= ${a};
84
- `}var Zu,xh,Qu,tl=O(()=>{ut(),j(),pe(),He(),Zu={name:"pack",inputNames:["A"],inputTypes:[1]},xh=(e,n)=>{let a=G(e.session.backend.glContext.version),i=n.dims,p=i.length,o=n.dims.length,s=Bt(o),c=cr("rc",o),h=vh(o,c,i[i.length-2],i[i.length-1]),r;p===0?r=[1,1]:p===1?r=[i[0],1]:r=[i[o-1],i[o-2]];let u=Th(o,r,c),l=wh(i,c),f=`
82
+ bool rEdge = rp1 >= ${a};
83
+ bool cEdge = cp1 >= ${i};
84
+ `}var Zu,xh,Qu,tl=O(()=>{ut(),j(),pe(),He(),Zu={name:"pack",inputNames:["A"],inputTypes:[1]},xh=(e,n)=>{let i=G(e.session.backend.glContext.version),a=n.dims,p=a.length,o=n.dims.length,s=Bt(o),c=cr("rc",o),h=vh(o,c,a[a.length-2],a[a.length-1]),r;p===0?r=[1,1]:p===1?r=[a[0],1]:r=[a[o-1],a[o-2]];let u=Th(o,r,c),l=wh(a,c),f=`
85
85
  void main() {
86
86
  ${s} rc = getOutputCoords();
87
87
 
88
88
  if(${u}) {
89
- ${a.output} = vec4(0);
89
+ ${i.output} = vec4(0);
90
90
  } else {
91
91
  ${h}
92
92
 
93
- ${a.output} = vec4(${l});
93
+ ${i.output} = vec4(${l});
94
94
  }
95
95
  }
96
- `;return{...Zu,hasMain:!0,output:{dims:n.dims,type:n.type,textureType:2},shaderSource:f}},Qu=(e,n)=>({...Zu,get:()=>xh(e,n)})});function fi(e){if(e.length===0)return[1,1,1];let n=1;for(let a=0;a<e.length-2;++a)n*=e[a];return[n,e.length>1?e[e.length-2]:1,e[e.length-1]]}function rl(e,n){let a=!1;return e.length===0||n.length===0?a=!0:e.length<2||n.length<2?a=e[e.length-1]===n[n.length-1]:a=e[e.length-1]===n[n.length-1]&&e[e.length-2]===n[n.length-2],a}function Oh(e){let n=B.computeStrides(e),a=["b","r","c"],i="index";return`
96
+ `;return{...Zu,hasMain:!0,output:{dims:n.dims,type:n.type,textureType:2},shaderSource:f}},Qu=(e,n)=>({...Zu,get:()=>xh(e,n)})});function fi(e){if(e.length===0)return[1,1,1];let n=1;for(let i=0;i<e.length-2;++i)n*=e[i];return[n,e.length>1?e[e.length-2]:1,e[e.length-1]]}function rl(e,n){let i=!1;return e.length===0||n.length===0?i=!0:e.length<2||n.length<2?i=e[e.length-1]===n[n.length-1]:i=e[e.length-1]===n[n.length-1]&&e[e.length-2]===n[n.length-2],i}function Oh(e){let n=B.computeStrides(e),i=["b","r","c"],a="index";return`
97
97
  ivec3 inputCoordsFromReshapedOutCoords(int index) {
98
- ${n.map((p,o)=>{let s=`int ${a[o]} = ${i} / ${p}`,c=o===n.length-1?`int ${a[o+1]} = ${i} - ${a[o]} * ${p}`:`index -= ${a[o]} * ${p}`;return`${s}; ${c};`}).join("")}
98
+ ${n.map((p,o)=>{let s=`int ${i[o]} = ${a} / ${p}`,c=o===n.length-1?`int ${i[o+1]} = ${a} - ${i[o]} * ${p}`:`index -= ${i[o]} * ${p}`;return`${s}; ${c};`}).join("")}
99
99
  return ivec3(b, r, c);
100
100
  }
101
101
  `}function Sh(e){let n=B.computeStrides(e);return`
@@ -103,7 +103,7 @@
103
103
  // reverse y, z order
104
104
  return coords.x * ${n[0]} + coords.z * ${n[1]} + coords.y;
105
105
  }
106
- `}var Ih,_h,el,nl=O(()=>{Y(),ut(),j(),He(),Ih=e=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${e}`}),_h=(e,n,a,i)=>{let p=n.dims,o=i,s="";for(let r=0;r<4;r++){let u="";switch(r){case 0:u="outputCoords = rc;";break;case 1:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:u="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}s+=`
106
+ `}var Ih,_h,el,nl=O(()=>{Y(),ut(),j(),He(),Ih=e=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${e}`}),_h=(e,n,i,a)=>{let p=n.dims,o=a,s="";for(let r=0;r<4;r++){let u="";switch(r){case 0:u="outputCoords = rc;";break;case 1:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:u="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:u="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}s+=`
107
107
  ${u}
108
108
  ${r>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
109
109
  int flattenedIndex = getFlattenedIndex(outputCoords);
@@ -131,7 +131,7 @@
131
131
  ${s}
132
132
  ${c.output} = result;
133
133
  }
134
- `;return{...a,output:{dims:o,type:n.type,textureType:2},shaderSource:h,hasMain:!0}},el=(e,n,a)=>{let i=Ih(a);return{...i,get:()=>_h(e,n,i,a)}}}),ci,ol=O(()=>{ut(),j(),ci=(e,n)=>{let a=n.shape,i=G(e.session.backend.glContext.version),p=`
134
+ `;return{...i,output:{dims:o,type:n.type,textureType:2},shaderSource:h,hasMain:!0}},el=(e,n,i)=>{let a=Ih(i);return{...a,get:()=>_h(e,n,a,i)}}}),ci,ol=O(()=>{ut(),j(),ci=(e,n)=>{let i=n.shape,a=G(e.session.backend.glContext.version),p=`
135
135
  const float FLOAT_MAX = 1.70141184e38;
136
136
  const float FLOAT_MIN = 1.17549435e-38;
137
137
 
@@ -176,9 +176,9 @@
176
176
  }
177
177
 
178
178
  void main() {
179
- float value = ${i.texture2D}(X,TexCoords).r;
180
- ${i.output} = encodeAsUint8(value);
181
- }`,o={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:a,type:n.tensor.type,textureType:3},shaderSource:p,hasMain:!0};return e.executeProgram(o,[n.tensor])}});function Ph(e,n){if(e===1)return"rc";let a="";for(let i=0;i<e;i++)a+=n[i],i<e-1&&(a+=",");return a}var il,Ah,al,sl=O(()=>{ut(),j(),pe(),He(),il={name:"unpack",inputNames:["A"],inputTypes:[2]},Ah=(e,n)=>{let a=n.dims.length,i=cr("rc",a),p=i.slice(-2),o=Bt(a),s=de(),c=n.dims.length===0?"":Ph(a,i),h=a<=1?"rc":`vec2(${p.join(",")})`,r=G(e.session.backend.glContext.version),u=`
179
+ float value = ${a.texture2D}(X,TexCoords).r;
180
+ ${a.output} = encodeAsUint8(value);
181
+ }`,o={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:i,type:n.tensor.type,textureType:3},shaderSource:p,hasMain:!0};return e.executeProgram(o,[n.tensor])}});function Ph(e,n){if(e===1)return"rc";let i="";for(let a=0;a<e;a++)i+=n[a],a<e-1&&(i+=",");return i}var il,Ah,al,sl=O(()=>{ut(),j(),pe(),He(),il={name:"unpack",inputNames:["A"],inputTypes:[2]},Ah=(e,n)=>{let i=n.dims.length,a=cr("rc",i),p=a.slice(-2),o=Bt(i),s=de(),c=n.dims.length===0?"":Ph(i,a),h=i<=1?"rc":`vec2(${p.join(",")})`,r=G(e.session.backend.glContext.version),u=`
182
182
  ${s}
183
183
  void main() {
184
184
  ${o} rc = getOutputCoords();
@@ -188,16 +188,16 @@
188
188
 
189
189
  ${r.output} = vec4(getChannel(packedInput, ${h}), 0, 0, 0);
190
190
  }
191
- `;return{...il,hasMain:!0,output:{dims:n.dims,type:n.type,textureType:0},shaderSource:u}},al=(e,n)=>({...il,get:()=>Ah(e,n)})}),Pn,Br,En,Fr=O(()=>{Ut(),Pn=class{constructor(e,n=1){if(n===1)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=n;else if(n===4)this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(e,n){let a,i;return e.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),i=new Float32Array(e)),n*this.channelSize>e.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),i=e,a=this.allocate(n*this.channelSize),i.forEach((p,o)=>a[o]=p)):(i=e,a=i),a}allocate(e){return new Float32Array(e*4)}decode(e,n){return this.channelSize===1?e.filter((a,i)=>i%4===0).subarray(0,n):e.subarray(0,n)}},Br=class{constructor(e,n=1,a){if(n!==1&&n!==4)throw new Error(`Invalid number of channels: ${n}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=n,this.textureType=a||e.FLOAT}encode(e,n){let a=e;return this.channelSize===1&&(tt.verbose("Encoder","Exploding into a larger array"),a=this.allocate(n),e.forEach((i,p)=>a[p*4]=i)),a}allocate(e){return new Float32Array(e*4)}decode(e,n){return this.channelSize===1?e.filter((a,i)=>i%4===0).subarray(0,n):e.subarray(0,n)}},En=class{constructor(e,n=1){if(this.channelSize=4,n===1)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=n;else if(n===4)this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(e,n){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,n){if(e instanceof Uint8Array)return e.subarray(0,n);throw new Error(`Invalid array type: ${e.constructor}`)}}}),Cr,ul,pi,ll=O(()=>{Y(),j(),Cr=(e,n,a)=>{let i=a===0||a===1?1:4,p=a===2,o=a===1||a===2,s=a===4?n.length-1:void 0,c=a===4?n.map((h,r)=>r===n.length-1?h*4:h):void 0;return pi(e,n,i,c,{isPacked:p,reverseWH:o,breakAxis:s})},ul=(e,n,a)=>{let i=Cr(e,n,a);return[i.width,i.height]},pi=(e,n,a=1,i,p)=>{let o=!!(p&&p.isPacked),[s,c]=e.computeTextureWH(o&&i||n,p),h=n.length,r=n.slice(0);if(h===0&&(r=[1]),a===1)i=n;else if(o){if(a!==4)throw new Error("a packed texture must be 4-channel");i=n,h>0&&(r[h-1]=Math.ceil(r[h-1]/2)),h>1&&(r[h-2]=Math.ceil(r[h-2]/2))}else if(!i)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:c,channels:a,isPacked:o,shape:r,strides:B.computeStrides(r),unpackedShape:i,reversedWH:p&&p.reverseWH}}}),Dh,Dn,cl=O(()=>{Ut(),We(),Y(),tl(),nl(),ol(),sl(),Fr(),ll(),j(),Dh=(e,n)=>{let a=n.map(p=>`${p.unpackedShape.join(",")};${p.width}x${p.height}`).join("_"),i=e.name;return e.cacheHint&&(i+="["+e.cacheHint+"]"),i+=":"+a,i},Dn=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,n){return ul(this.session.layoutStrategy,e,n)}executeProgram(e,n){if(n.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 a=[];for(let h=0;h<e.inputNames.length;++h)a[h]=this.getOrCreateTextureData(n[h],e.inputTypes[h]);let i=Dh(e,a),p=this.session.programManager.getArtifact(i),o=p?p.programInfo:typeof e.get=="function"?e.get():e,s=Cr(this.session.layoutStrategy,o.output.dims,o.output.textureType),c=this.createTextureData(s,o.output.type);return p||(p=this.session.programManager.build(o,a,c),this.session.programManager.setArtifact(i,p)),this.runProgram(p,a,c),c}run(e,n){return this.executeProgram(e,n).tensor}runProgram(e,n,a){for(let i=0;i<n.length;++i)if(!!n[i].isPacked!=(e.programInfo.inputTypes[i]===2))throw new Error(`input[${i}] property packed inconsistent`);if(!!a.isPacked!=(e.programInfo.output.textureType===2))throw new Error("output property packed inconsistent");this.session.programManager.run(e,n,a)}getOrCreateTextureData(e,n){let a=this.getTextureData(e.dataId,n===2);if(!a&&(a=this.getTextureData(e.dataId,n!==2),a))return n===2?this.pack(a):this.unpack(a);if(!a){let i=Cr(this.session.layoutStrategy,e.dims,n);if(n===4){let p=e.dims;if(p.length===4){let o=[p[0],Math.ceil(p[1]*p[2]*p[3]/4)],s=Cr(this.session.layoutStrategy,o,n),c=e.numberData;if(p[1]*p[2]*p[3]%4!==0){let h=p[0],r=p[1]*p[2]*p[3],u=Math.ceil(r*1/4)*4,l=h*u;c=new Float32Array(l);for(let f=0;f<h;++f){let g=f*r,b=f*u+f%1*r;c.set(e.numberData.subarray(g,g+r),b)}}return this.createTextureData(s,e.type,c,e,1)}}if(n===2){let p=pi(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),o=this.createTextureData(p,e.type,e.numberData,e,1);a=this.pack(o)}else a=this.createTextureData(i,e.type,e.numberData,e,1)}return a}createTextureDataFromLayoutBindTensor(e,n,a,i){return this.createTextureData(e,n,a,i,1)}createTextureData(e,n,a,i,p){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);let o=this.session.textureManager.createTextureFromLayout(n,e,a,p);return this.createTextureDataFromTexture(e,n,o,i)}reshapeUnpacked(e,n){let a=this.getOrCreateTextureData(e,0),i={channels:a.channels,height:a.height,width:a.width,shape:n.length!==0?n:[1],strides:B.computeStrides(n),unpackedShape:n};return this.createTextureDataFromTexture(i,e.type,a.texture).tensor}reshapePacked(e,n){let a=this.getOrCreateTextureData(e,2);if(rl(e.dims,n)){let c={channels:a.channels,height:a.height,width:a.width,shape:n.length!==0?n:[1],strides:B.computeStrides(n),unpackedShape:n,isPacked:!0};return this.createTextureDataFromTexture(c,e.type,a.texture).tensor}let i=fi(e.dims),p=fi(n),o=this.reshapePacked(e,i),s=this.run(el(this,o,p),[o]);return this.reshapePacked(s,n)}cast(e,n){let a=this.getOrCreateTextureData(e,0);return this.createTextureDataFromTexture(a,n,a.texture).tensor}createTextureDataFromTexture(e,n,a,i,p){let o={...e,tensor:i||new bt(e.unpackedShape,n,s=>this.readTexture(o),async s=>this.readTextureAsync(o),void 0,p),texture:a};return this.setTextureData(o.tensor.dataId,o,e.isPacked),o}getTextureData(e,n=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,n):n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,a=!1){this.session.isInitializer(e)?this.session.setTextureData(e,n,a):(a?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,n)}isTextureLayoutCached(e,n=!1){return!!this.getTextureData(e.dataId,n)}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(ci(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(ci(this,e))}pack(e){return this.executeProgram(Qu(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(al(this,e.tensor),[e.tensor])}}}),di,W,It=O(()=>{di=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}},W=e=>new di(e)}),pl,dl,hl,Lh,$h,ml=O(()=>{It(),ut(),j(),pl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},dl=(e,n,a)=>($h(n),[e.run({...pl,cacheHint:a.cacheKey,get:()=>Lh(e,n,a)},n)]),hl=e=>{let n=e.attributes.getFloat("epsilon",1e-5),a=e.attributes.getFloat("momentum",.9),i=e.attributes.getInt("spatial",1);return W({epsilon:n,momentum:a,spatial:i})},Lh=(e,n,a)=>{let i=G(e.session.backend.glContext.version),p=n[0].dims.length,[o,s]=e.calculateTextureWidthAndHeight(n[1].dims,0),c=`
191
+ `;return{...il,hasMain:!0,output:{dims:n.dims,type:n.type,textureType:0},shaderSource:u}},al=(e,n)=>({...il,get:()=>Ah(e,n)})}),Pn,Br,En,Fr=O(()=>{Ut(),Pn=class{constructor(e,n=1){if(n===1)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=n;else if(n===4)this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(e,n){let i,a;return e.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),a=new Float32Array(e)),n*this.channelSize>e.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),a=e,i=this.allocate(n*this.channelSize),a.forEach((p,o)=>i[o]=p)):(a=e,i=a),i}allocate(e){return new Float32Array(e*4)}decode(e,n){return this.channelSize===1?e.filter((i,a)=>a%4===0).subarray(0,n):e.subarray(0,n)}},Br=class{constructor(e,n=1,i){if(n!==1&&n!==4)throw new Error(`Invalid number of channels: ${n}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=n,this.textureType=i||e.FLOAT}encode(e,n){let i=e;return this.channelSize===1&&(tt.verbose("Encoder","Exploding into a larger array"),i=this.allocate(n),e.forEach((a,p)=>i[p*4]=a)),i}allocate(e){return new Float32Array(e*4)}decode(e,n){return this.channelSize===1?e.filter((i,a)=>a%4===0).subarray(0,n):e.subarray(0,n)}},En=class{constructor(e,n=1){if(this.channelSize=4,n===1)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=n;else if(n===4)this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=n;else throw new Error(`Invalid number of channels: ${n}`)}encode(e,n){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,n){if(e instanceof Uint8Array)return e.subarray(0,n);throw new Error(`Invalid array type: ${e.constructor}`)}}}),Cr,ul,pi,ll=O(()=>{Y(),j(),Cr=(e,n,i)=>{let a=i===0||i===1?1:4,p=i===2,o=i===1||i===2,s=i===4?n.length-1:void 0,c=i===4?n.map((h,r)=>r===n.length-1?h*4:h):void 0;return pi(e,n,a,c,{isPacked:p,reverseWH:o,breakAxis:s})},ul=(e,n,i)=>{let a=Cr(e,n,i);return[a.width,a.height]},pi=(e,n,i=1,a,p)=>{let o=!!(p&&p.isPacked),[s,c]=e.computeTextureWH(o&&a||n,p),h=n.length,r=n.slice(0);if(h===0&&(r=[1]),i===1)a=n;else if(o){if(i!==4)throw new Error("a packed texture must be 4-channel");a=n,h>0&&(r[h-1]=Math.ceil(r[h-1]/2)),h>1&&(r[h-2]=Math.ceil(r[h-2]/2))}else if(!a)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:c,channels:i,isPacked:o,shape:r,strides:B.computeStrides(r),unpackedShape:a,reversedWH:p&&p.reverseWH}}}),Dh,Dn,cl=O(()=>{Ut(),We(),Y(),tl(),nl(),ol(),sl(),Fr(),ll(),j(),Dh=(e,n)=>{let i=n.map(p=>`${p.unpackedShape.join(",")};${p.width}x${p.height}`).join("_"),a=e.name;return e.cacheHint&&(a+="["+e.cacheHint+"]"),a+=":"+i,a},Dn=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,n){return ul(this.session.layoutStrategy,e,n)}executeProgram(e,n){if(n.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 i=[];for(let h=0;h<e.inputNames.length;++h)i[h]=this.getOrCreateTextureData(n[h],e.inputTypes[h]);let a=Dh(e,i),p=this.session.programManager.getArtifact(a),o=p?p.programInfo:typeof e.get=="function"?e.get():e,s=Cr(this.session.layoutStrategy,o.output.dims,o.output.textureType),c=this.createTextureData(s,o.output.type);return p||(p=this.session.programManager.build(o,i,c),this.session.programManager.setArtifact(a,p)),this.runProgram(p,i,c),c}run(e,n){return this.executeProgram(e,n).tensor}runProgram(e,n,i){for(let a=0;a<n.length;++a)if(!!n[a].isPacked!=(e.programInfo.inputTypes[a]===2))throw new Error(`input[${a}] property packed inconsistent`);if(!!i.isPacked!=(e.programInfo.output.textureType===2))throw new Error("output property packed inconsistent");this.session.programManager.run(e,n,i)}getOrCreateTextureData(e,n){let i=this.getTextureData(e.dataId,n===2);if(!i&&(i=this.getTextureData(e.dataId,n!==2),i))return n===2?this.pack(i):this.unpack(i);if(!i){let a=Cr(this.session.layoutStrategy,e.dims,n);if(n===4){let p=e.dims;if(p.length===4){let o=[p[0],Math.ceil(p[1]*p[2]*p[3]/4)],s=Cr(this.session.layoutStrategy,o,n),c=e.numberData;if(p[1]*p[2]*p[3]%4!==0){let h=p[0],r=p[1]*p[2]*p[3],u=Math.ceil(r*1/4)*4,l=h*u;c=new Float32Array(l);for(let f=0;f<h;++f){let g=f*r,b=f*u+f%1*r;c.set(e.numberData.subarray(g,g+r),b)}}return this.createTextureData(s,e.type,c,e,1)}}if(n===2){let p=pi(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),o=this.createTextureData(p,e.type,e.numberData,e,1);i=this.pack(o)}else i=this.createTextureData(a,e.type,e.numberData,e,1)}return i}createTextureDataFromLayoutBindTensor(e,n,i,a){return this.createTextureData(e,n,i,a,1)}createTextureData(e,n,i,a,p){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);let o=this.session.textureManager.createTextureFromLayout(n,e,i,p);return this.createTextureDataFromTexture(e,n,o,a)}reshapeUnpacked(e,n){let i=this.getOrCreateTextureData(e,0),a={channels:i.channels,height:i.height,width:i.width,shape:n.length!==0?n:[1],strides:B.computeStrides(n),unpackedShape:n};return this.createTextureDataFromTexture(a,e.type,i.texture).tensor}reshapePacked(e,n){let i=this.getOrCreateTextureData(e,2);if(rl(e.dims,n)){let c={channels:i.channels,height:i.height,width:i.width,shape:n.length!==0?n:[1],strides:B.computeStrides(n),unpackedShape:n,isPacked:!0};return this.createTextureDataFromTexture(c,e.type,i.texture).tensor}let a=fi(e.dims),p=fi(n),o=this.reshapePacked(e,a),s=this.run(el(this,o,p),[o]);return this.reshapePacked(s,n)}cast(e,n){let i=this.getOrCreateTextureData(e,0);return this.createTextureDataFromTexture(i,n,i.texture).tensor}createTextureDataFromTexture(e,n,i,a,p){let o={...e,tensor:a||new bt(e.unpackedShape,n,s=>this.readTexture(o),async s=>this.readTextureAsync(o),void 0,p),texture:i};return this.setTextureData(o.tensor.dataId,o,e.isPacked),o}getTextureData(e,n=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,n):n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,i=!1){this.session.isInitializer(e)?this.session.setTextureData(e,n,i):(i?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,n)}isTextureLayoutCached(e,n=!1){return!!this.getTextureData(e.dataId,n)}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(ci(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(ci(this,e))}pack(e){return this.executeProgram(Qu(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(al(this,e.tensor),[e.tensor])}}}),di,W,It=O(()=>{di=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}},W=e=>new di(e)}),pl,dl,hl,Lh,$h,ml=O(()=>{It(),ut(),j(),pl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},dl=(e,n,i)=>($h(n),[e.run({...pl,cacheHint:i.cacheKey,get:()=>Lh(e,n,i)},n)]),hl=e=>{let n=e.attributes.getFloat("epsilon",1e-5),i=e.attributes.getFloat("momentum",.9),a=e.attributes.getInt("spatial",1);return W({epsilon:n,momentum:i,spatial:a})},Lh=(e,n,i)=>{let a=G(e.session.backend.glContext.version),p=n[0].dims.length,[o,s]=e.calculateTextureWidthAndHeight(n[1].dims,0),c=`
192
192
  float process(int[${p}] indices) {
193
193
  vec2 position = offsetToCoords(indices[1], ${o}, ${s});
194
- float scale = getColorAsFloat(${i.texture2D}(Scale, position));
195
- float mean = getColorAsFloat(${i.texture2D}(Mean, position));
196
- float variance = getColorAsFloat(${i.texture2D}(Variance, position));
197
- float b = getColorAsFloat(${i.texture2D}(B, position));
194
+ float scale = getColorAsFloat(${a.texture2D}(Scale, position));
195
+ float mean = getColorAsFloat(${a.texture2D}(Mean, position));
196
+ float variance = getColorAsFloat(${a.texture2D}(Variance, position));
197
+ float b = getColorAsFloat(${a.texture2D}(B, position));
198
198
 
199
- return scale * ( (_A(indices) - mean) / sqrt(variance + float(${a.epsilon})) ) + b;
200
- }`;return{...pl,output:{dims:n[0].dims,type:n[0].type,textureType:0},shaderSource:c}},$h=e=>{if(!e||e.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let n=e[0],a=e[1],i=e[2],p=e[3],o=e[4];if(n.dims.length<3||a.dims.length!==1||i.dims.length!==1||p.dims.length!==1||o.dims.length!==1)throw new Error("invalid input shape.");if(a.dims[0]!==n.dims[1]||i.dims[0]!==n.dims[1]||p.dims[0]!==n.dims[1]||o.dims[0]!==n.dims[1])throw new Error("invalid input shape.");if(n.type!=="float32"&&n.type!=="float64"||a.type!=="float32"&&a.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||p.type!=="float32"&&p.type!=="float64"||o.type!=="float32"&&o.type!=="float64")throw new Error("invalid input tensor types.")}}),Ln,Ht,k,Nr,$n,Te=O(()=>{Ln=class{constructor(e,n,a,i){this.glContext=e,this.programInfo=n,this.inputTextureLayouts=a,this.outputTextureLayout=i}},Ht=class{constructor(e){this.context=e}},k=class{constructor(e,n){this.routineBody=e,this.dependencies=n}},Nr=class{constructor(e,n,a){this.name=e,a?this.dependencies=a:this.dependencies=[],n&&(this.routineBody=n)}addDependency(e){e&&this.dependencies.push(e)}},$n=class{static returnOrderedNodes(e){if(!e||e.length===0)return[];if(e.length===1)return e;let n=new Set,a=new Set,i=new Array;return this.createOrderedNodes(e,n,a,i),i}static createOrderedNodes(e,n,a,i){for(let p=0;p<e.length;++p)this.dfsTraverse(e[p],n,a,i)}static dfsTraverse(e,n,a,i){if(!e||a.has(e.name))return;if(n.has(e.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");n.add(e.name);let p=e.dependencies;if(p&&p.length>0)for(let o=0;o<p.length;++o)this.dfsTraverse(p[o],n,a,i);i.push(e),a.add(e.name),n.delete(e.name)}}});function Bh(){let e="add_";return{body:`
199
+ return scale * ( (_A(indices) - mean) / sqrt(variance + float(${i.epsilon})) ) + b;
200
+ }`;return{...pl,output:{dims:n[0].dims,type:n[0].type,textureType:0},shaderSource:c}},$h=e=>{if(!e||e.length!==5)throw new Error("BatchNormalization requires 5 inputs.");let n=e[0],i=e[1],a=e[2],p=e[3],o=e[4];if(n.dims.length<3||i.dims.length!==1||a.dims.length!==1||p.dims.length!==1||o.dims.length!==1)throw new Error("invalid input shape.");if(i.dims[0]!==n.dims[1]||a.dims[0]!==n.dims[1]||p.dims[0]!==n.dims[1]||o.dims[0]!==n.dims[1])throw new Error("invalid input shape.");if(n.type!=="float32"&&n.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||a.type!=="float32"&&a.type!=="float64"||p.type!=="float32"&&p.type!=="float64"||o.type!=="float32"&&o.type!=="float64")throw new Error("invalid input tensor types.")}}),Ln,Ht,k,Nr,$n,Te=O(()=>{Ln=class{constructor(e,n,i,a){this.glContext=e,this.programInfo=n,this.inputTextureLayouts=i,this.outputTextureLayout=a}},Ht=class{constructor(e){this.context=e}},k=class{constructor(e,n){this.routineBody=e,this.dependencies=n}},Nr=class{constructor(e,n,i){this.name=e,i?this.dependencies=i:this.dependencies=[],n&&(this.routineBody=n)}addDependency(e){e&&this.dependencies.push(e)}},$n=class{static returnOrderedNodes(e){if(!e||e.length===0)return[];if(e.length===1)return e;let n=new Set,i=new Set,a=new Array;return this.createOrderedNodes(e,n,i,a),a}static createOrderedNodes(e,n,i,a){for(let p=0;p<e.length;++p)this.dfsTraverse(e[p],n,i,a)}static dfsTraverse(e,n,i,a){if(!e||i.has(e.name))return;if(n.has(e.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");n.add(e.name);let p=e.dependencies;if(p&&p.length>0)for(let o=0;o<p.length;++o)this.dfsTraverse(p[o],n,i,a);a.push(e),i.add(e.name),n.delete(e.name)}}});function Bh(){let e="add_";return{body:`
201
201
  float ${e}(float a, float b) {
202
202
  return a + b;
203
203
  }
@@ -307,43 +307,43 @@
307
307
  vec4 ${n}(vec4 v1, vec4 v2) {
308
308
  return ${e}(v1, v2);
309
309
  }
310
- `,name:n,type:0}}var qt,jh,bl,gl,yl,xl,Tl,wl,vl,Il,_l,Ol,Sl,Al,Pl=O(()=>{Y(),Te(),ut(),j(),qt=(e,n,a,i=n[0].type,p)=>{let o=e.session.pack?2:0;return{name:a.name,inputNames:["A","B"],inputTypes:[o,o],cacheHint:p,get:()=>jh(e,n,a,i)}},jh=(e,n,a,i=n[0].type)=>{let p=e.session.pack?2:0,o=!B.areEqual(n[0].dims,n[1].dims),s=n[0].dims,c=e.session.pack;if(o){let u=kt.calcShape(n[0].dims,n[1].dims,!1);if(!u)throw new Error("Can't perform binary op on the given tensors");s=u;let l=s.length,f=n[0].dims.length!==0?n[0].dims.length:1,g=n[1].dims.length!==0?n[1].dims.length:1,b=n[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",v=n[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",S=G(e.session.backend.glContext.version),P=c?`
311
- ${a.body}
310
+ `,name:n,type:0}}var qt,jh,bl,gl,yl,xl,Tl,wl,vl,Il,_l,Ol,Sl,Al,Pl=O(()=>{Y(),Te(),ut(),j(),qt=(e,n,i,a=n[0].type,p)=>{let o=e.session.pack?2:0;return{name:i.name,inputNames:["A","B"],inputTypes:[o,o],cacheHint:p,get:()=>jh(e,n,i,a)}},jh=(e,n,i,a=n[0].type)=>{let p=e.session.pack?2:0,o=!B.areEqual(n[0].dims,n[1].dims),s=n[0].dims,c=e.session.pack;if(o){let u=kt.calcShape(n[0].dims,n[1].dims,!1);if(!u)throw new Error("Can't perform binary op on the given tensors");s=u;let l=s.length,f=n[0].dims.length!==0?n[0].dims.length:1,g=n[1].dims.length!==0?n[1].dims.length:1,b=n[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",v=n[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",S=G(e.session.backend.glContext.version),P=c?`
311
+ ${i.body}
312
312
  void main() {
313
313
  vec4 a = getAAtOutCoords();
314
314
  vec4 b = getBAtOutCoords();
315
- vec4 result = ${a.name}(a, b);
315
+ vec4 result = ${i.name}(a, b);
316
316
  ${S.output} = result;
317
317
  }`:`
318
- ${a.body}
318
+ ${i.body}
319
319
  float process(int indices[${l}]) {
320
320
  int aindices[${f}];
321
321
  int bindices[${g}];
322
322
  ${b}
323
323
  ${v}
324
- return ${a.name}(_A(aindices), _B(bindices));
325
- }`;return{name:a.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:s,type:i,textureType:p},shaderSource:P,hasMain:c}}let h=G(e.session.backend.glContext.version),r=`
326
- ${a.body}
324
+ return ${i.name}(_A(aindices), _B(bindices));
325
+ }`;return{name:i.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:s,type:a,textureType:p},shaderSource:P,hasMain:c}}let h=G(e.session.backend.glContext.version),r=`
326
+ ${i.body}
327
327
  void main() {
328
328
  vec4 v1 = ${h.texture2D}(A, TexCoords);
329
329
  vec4 v2 = ${h.texture2D}(B, TexCoords);
330
- vec4 result = ${a.name}(v1, v2);
330
+ vec4 result = ${i.name}(v1, v2);
331
331
  ${h.output} = result;
332
332
  }
333
- `;return{name:a.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:n[0].dims,type:i,textureType:p},shaderSource:r,hasMain:!0}},bl=(e,n)=>[e.run(qt(e,n,Bh()),n)],gl=(e,n)=>[e.run(qt(e,n,Uh(),"bool"),n)],yl=(e,n)=>[e.run(qt(e,n,Fh()),n)],xl=(e,n)=>[e.run(qt(e,n,Rh(),"bool"),n)],Tl=(e,n)=>[e.run(qt(e,n,Gh(),"bool"),n)],wl=(e,n)=>[e.run(qt(e,n,Mh(),"bool"),n)],vl=(e,n)=>[e.run(qt(e,n,Ch()),n)],Il=(e,n)=>[e.run(qt(e,n,Vh(),"bool"),n)],_l=(e,n)=>[e.run(qt(e,n,Wh()),n)],Ol=(e,n)=>[e.run(qt(e,n,Hh()),n)],Sl=(e,n)=>[e.run(qt(e,n,Nh()),n)],Al=(e,n)=>[e.run(qt(e,n,zh(),"bool"),n)]}),El,Dl,Kh,Ll=O(()=>{Y(),El=(e,n,a)=>(Kh(n),[e.cast(n[0],a)]),Dl=e=>At.tensorDataTypeFromProto(e.attributes.getInt("to")),Kh=e=>{if(!e||e.length!==1)throw new Error("Cast requires 1 input.");if(e[0].type==="string")throw new Error("Invalid input type.")}}),Jh,Yh,$l,kn,kl=O(()=>{ut(),j(),pe(),He(),Jh=(e,n)=>({name:"Concat (packed)",inputNames:Array.from({length:e},(a,i)=>`X${i}`),inputTypes:Array(e).fill(2),cacheHint:n}),Yh=(e,n,a,i)=>{let p=a[0].dims.slice();if(i>=p.length||i<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=p.length+i);let o=p.slice(0);for(let V=1;V<a.length;V++){let ft=a[V].dims.slice();for(let lt=0;lt<p.length;lt++)if(lt===i)o[i]+=ft[lt];else if(p[lt]!==ft[lt])throw new Error("non concat dimensions must match")}let s=o.length,c=cr("coords",s),h=Bt(s),r=de(),u=a.map(V=>V.dims),l=ne(s),f=new Array(u.length-1);f[0]=u[0][i];for(let V=1;V<f.length;V++)f[V]=f[V-1]+u[V][i];let g=l[i],b=l.slice(-2),v=l.join(),S=`if (${g} < ${f[0]}) {
333
+ `;return{name:i.name,inputNames:["A","B"],inputTypes:[p,p],output:{dims:n[0].dims,type:a,textureType:p},shaderSource:r,hasMain:!0}},bl=(e,n)=>[e.run(qt(e,n,Bh()),n)],gl=(e,n)=>[e.run(qt(e,n,Uh(),"bool"),n)],yl=(e,n)=>[e.run(qt(e,n,Fh()),n)],xl=(e,n)=>[e.run(qt(e,n,Rh(),"bool"),n)],Tl=(e,n)=>[e.run(qt(e,n,Gh(),"bool"),n)],wl=(e,n)=>[e.run(qt(e,n,Mh(),"bool"),n)],vl=(e,n)=>[e.run(qt(e,n,Ch()),n)],Il=(e,n)=>[e.run(qt(e,n,Vh(),"bool"),n)],_l=(e,n)=>[e.run(qt(e,n,Wh()),n)],Ol=(e,n)=>[e.run(qt(e,n,Hh()),n)],Sl=(e,n)=>[e.run(qt(e,n,Nh()),n)],Al=(e,n)=>[e.run(qt(e,n,zh(),"bool"),n)]}),El,Dl,Kh,Ll=O(()=>{Y(),El=(e,n,i)=>(Kh(n),[e.cast(n[0],i)]),Dl=e=>At.tensorDataTypeFromProto(e.attributes.getInt("to")),Kh=e=>{if(!e||e.length!==1)throw new Error("Cast requires 1 input.");if(e[0].type==="string")throw new Error("Invalid input type.")}}),Jh,Yh,$l,kn,kl=O(()=>{ut(),j(),pe(),He(),Jh=(e,n)=>({name:"Concat (packed)",inputNames:Array.from({length:e},(i,a)=>`X${a}`),inputTypes:Array(e).fill(2),cacheHint:n}),Yh=(e,n,i,a)=>{let p=i[0].dims.slice();if(a>=p.length||a<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");a<0&&(a=p.length+a);let o=p.slice(0);for(let M=1;M<i.length;M++){let ft=i[M].dims.slice();for(let lt=0;lt<p.length;lt++)if(lt===a)o[a]+=ft[lt];else if(p[lt]!==ft[lt])throw new Error("non concat dimensions must match")}let s=o.length,c=cr("coords",s),h=Bt(s),r=de(),u=i.map(M=>M.dims),l=ne(s),f=new Array(u.length-1);f[0]=u[0][a];for(let M=1;M<f.length;M++)f[M]=f[M-1]+u[M][a];let g=l[a],b=l.slice(-2),v=l.join(),S=`if (${g} < ${f[0]}) {
334
334
  return getChannel(
335
335
  getX0(${v}), vec2(${b.join()}));
336
- }`;for(let V=1;V<f.length;V++){let ft=f[V-1];S+=`
337
- if (${g} < ${f[V]} && ${g} >= ${f[V-1]}) {
336
+ }`;for(let M=1;M<f.length;M++){let ft=f[M-1];S+=`
337
+ if (${g} < ${f[M]} && ${g} >= ${f[M-1]}) {
338
338
  return getChannel(
339
- getX${V}(${kn(l,g,ft)}),
339
+ getX${M}(${kn(l,g,ft)}),
340
340
  vec2(${kn(b,g,ft)}));
341
341
  }`}let P=f.length,_=f[f.length-1];S+=`
342
342
  return getChannel(
343
343
  getX${P}(${kn(l,g,_)}),
344
344
  vec2(${kn(b,g,_)}));`;let A=G(e.session.backend.glContext.version),L=`
345
345
  ${r}
346
- float getValue(${l.map(V=>"int "+V)}) {
346
+ float getValue(${l.map(M=>"int "+M)}) {
347
347
  ${S}
348
348
  }
349
349
 
@@ -372,24 +372,24 @@
372
372
  }
373
373
  ${A.output} = result;
374
374
  }
375
- `;return{...n,output:{dims:o,type:a[0].type,textureType:2},shaderSource:L,hasMain:!0}},$l=(e,n,a)=>{let i=Jh(n.length,a.cacheKey);return{...i,get:()=>Yh(e,i,n,a.axis)}},kn=(e,n,a)=>{let i=e.indexOf(n);return e.map((p,o)=>o===i?`${p} - ${a}`:p).join()}}),Bl,Zh,Qh,tm,Fl,em,rm,nm,Cl,om,Nl=O(()=>{It(),j(),kl(),Bl=(e,n,a)=>(om(n),e.session.pack&&n[0].dims.length>1?[e.run($l(e,n,a),n)]:[e.run(tm(e,n,a),n)]),Zh=(e,n)=>({name:"Concat",inputNames:Array.from({length:e},(a,i)=>`X${i}`),inputTypes:Array(e).fill(0),cacheHint:n}),Qh=(e,n,a,i)=>{let p=a[0].dims.slice();if(i>=p.length||i<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");i<0&&(i=p.length+i);let o=p.slice(0);for(let g=1;g<a.length;g++){let b=a[g].dims.slice();for(let v=0;v<p.length;v++)if(v===i)o[i]+=b[v];else if(p[v]!==b[v])throw new Error("non concat dimensions must match")}let s=o.length,c=new Array(a.length),h=0;for(let g=0;g<c.length;++g)h+=a[g].dims[i],c[g]=h;let r="";a.length<5?r=Fl(c):r=em(c);let u=rm(a.length,s),l=nm(c),f=`
375
+ `;return{...n,output:{dims:o,type:i[0].type,textureType:2},shaderSource:L,hasMain:!0}},$l=(e,n,i)=>{let a=Jh(n.length,i.cacheKey);return{...a,get:()=>Yh(e,a,n,i.axis)}},kn=(e,n,i)=>{let a=e.indexOf(n);return e.map((p,o)=>o===a?`${p} - ${i}`:p).join()}}),Bl,Zh,Qh,tm,Fl,em,rm,nm,Cl,om,Nl=O(()=>{It(),j(),kl(),Bl=(e,n,i)=>(om(n),e.session.pack&&n[0].dims.length>1?[e.run($l(e,n,i),n)]:[e.run(tm(e,n,i),n)]),Zh=(e,n)=>({name:"Concat",inputNames:Array.from({length:e},(i,a)=>`X${a}`),inputTypes:Array(e).fill(0),cacheHint:n}),Qh=(e,n,i,a)=>{let p=i[0].dims.slice();if(a>=p.length||a<-1*p.length)throw new Error("axis specified for concat doesn't match input dimensionality");a<0&&(a=p.length+a);let o=p.slice(0);for(let g=1;g<i.length;g++){let b=i[g].dims.slice();for(let v=0;v<p.length;v++)if(v===a)o[a]+=b[v];else if(p[v]!==b[v])throw new Error("non concat dimensions must match")}let s=o.length,c=new Array(i.length),h=0;for(let g=0;g<c.length;++g)h+=i[g].dims[a],c[g]=h;let r="";i.length<5?r=Fl(c):r=em(c);let u=rm(i.length,s),l=nm(c),f=`
376
376
  ${u}
377
377
  ${l}
378
378
  ${r}
379
379
  float process(int indices[${s}]) {
380
- int textureIndex = getTextureWhereDataResides (indices[${i}]);
380
+ int textureIndex = getTextureWhereDataResides (indices[${a}]);
381
381
 
382
382
  if(textureIndex != 0) {
383
- indices[${i}] = indices[${i}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
383
+ indices[${a}] = indices[${a}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
384
384
  }
385
385
 
386
386
  return fetchDataFromCorrectTexture(textureIndex, indices);
387
- }`;return{...n,output:{dims:o,type:a[0].type,textureType:0},shaderSource:f}},tm=(e,n,a)=>{let i=Zh(n.length,a.cacheKey);return{...i,get:()=>Qh(e,i,n,a.axis)}},Fl=e=>`int getTextureWhereDataResides(int index) {
388
- ${e.map((n,a)=>`if(index<${n}) {return ${a};}
387
+ }`;return{...n,output:{dims:o,type:i[0].type,textureType:0},shaderSource:f}},tm=(e,n,i)=>{let a=Zh(n.length,i.cacheKey);return{...a,get:()=>Qh(e,a,n,i.axis)}},Fl=e=>`int getTextureWhereDataResides(int index) {
388
+ ${e.map((n,i)=>`if(index<${n}) {return ${i};}
389
389
  `).join("")}
390
- }`,em=e=>Fl(e),rm=(e,n)=>{let a=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${n}]) {`];for(let i=0;i<e;++i)i===0?a.push(` if (textureIndex == ${i}) { return _X${i}(indices); }`):i===e-1?a.push(` else { return _X${i}(indices); }`):a.push(` else if (textureIndex == ${i}) { return _X${i}(indices); }`);return a.push(" }"),a.join(`
391
- `)},nm=e=>{let n=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let a=0;a<e.length;++a)a===0?n.push(` if (index == ${a}) { return ${e[a]}; }`):a===e.length-1?n.push(` else { return ${e[a]}; }`):n.push(` else if (index == ${a}) { return ${e[a]}; }`);return n.push(" }"),n.join(`
392
- `)},Cl=e=>W({axis:e.attributes.getInt("axis")}),om=e=>{if(!e||e.length<1)throw new Error("too few inputs");let n=e[0].type,a=e[0].dims.length;if(n==="string")throw new Error("string tensor is not supported yet");for(let i of e){if(i.type!==n)throw new Error("input tensors should be one type");if(i.dims.length!==a)throw new Error("input tensors should have the same shape")}}});function im(){return jt("abs")}function am(){return jt("acos")}function sm(){return jt("asin")}function um(){return jt("atan")}function lm(){return jt("ceil")}function fm(){return jt("cos")}function cm(e){let n="elu";return{body:`
390
+ }`,em=e=>Fl(e),rm=(e,n)=>{let i=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${n}]) {`];for(let a=0;a<e;++a)a===0?i.push(` if (textureIndex == ${a}) { return _X${a}(indices); }`):a===e-1?i.push(` else { return _X${a}(indices); }`):i.push(` else if (textureIndex == ${a}) { return _X${a}(indices); }`);return i.push(" }"),i.join(`
391
+ `)},nm=e=>{let n=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let i=0;i<e.length;++i)i===0?n.push(` if (index == ${i}) { return ${e[i]}; }`):i===e.length-1?n.push(` else { return ${e[i]}; }`):n.push(` else if (index == ${i}) { return ${e[i]}; }`);return n.push(" }"),n.join(`
392
+ `)},Cl=e=>W({axis:e.attributes.getInt("axis")}),om=e=>{if(!e||e.length<1)throw new Error("too few inputs");let n=e[0].type,i=e[0].dims.length;if(n==="string")throw new Error("string tensor is not supported yet");for(let a of e){if(a.type!==n)throw new Error("input tensors should be one type");if(a.dims.length!==i)throw new Error("input tensors should have the same shape")}}});function im(){return jt("abs")}function am(){return jt("acos")}function sm(){return jt("asin")}function um(){return jt("atan")}function lm(){return jt("ceil")}function fm(){return jt("cos")}function cm(e){let n="elu";return{body:`
393
393
  const float alpha = float(${e});
394
394
 
395
395
  float ${n}_(float a) {
@@ -398,17 +398,17 @@
398
398
  vec4 ${n}_(vec4 v) {
399
399
  return vec4(${n}_(v.x), ${n}_(v.y), ${n}_(v.z), ${n}_(v.w));
400
400
  }
401
- `,name:n,type:0}}function pm(){return jt("exp")}function dm(){return jt("floor")}function hi(e,n){let a="clip";return{body:`
401
+ `,name:n,type:0}}function pm(){return jt("exp")}function dm(){return jt("floor")}function hi(e,n){let i="clip";return{body:`
402
402
  const float min = float(${e});
403
403
  const float max = float(${n});
404
404
 
405
- float ${a}_(float a) {
405
+ float ${i}_(float a) {
406
406
  return clamp(a, min, max);
407
407
  }
408
- vec4 ${a}_(vec4 v) {
408
+ vec4 ${i}_(vec4 v) {
409
409
  return clamp(v, min, max);
410
410
  }
411
- `,name:a,type:0}}function hm(){let e="indentity";return{body:`
411
+ `,name:i,type:0}}function hm(){let e="indentity";return{body:`
412
412
  float ${e}_(float a) {
413
413
  return a;
414
414
  }
@@ -476,16 +476,16 @@
476
476
  vec4 ${e}_(vec4 v) {
477
477
  return ${e}(v);
478
478
  }
479
- `,name:e,type:0}}var Im,dt,Rl,Gl,Ml,Ul,gi,Vl,zl,_m,Wl,Hl,ql,jl,Xl,Kl,yi,Jl,Yl,Zl,Ql,tf,ef,rf,nf,of,af,sf,xi=O(()=>{It(),Y(),Te(),ut(),j(),Im=(e,n,a,i)=>{let p=e.session.pack?2:0,o=G(e.session.backend.glContext.version);return{...n,output:{dims:a.dims,type:a.type,textureType:p},shaderSource:`
480
- ${i.body}
479
+ `,name:e,type:0}}var Im,dt,Rl,Gl,Ml,Ul,gi,Vl,zl,_m,Wl,Hl,ql,jl,Xl,Kl,yi,Jl,Yl,Zl,Ql,tf,ef,rf,nf,of,af,sf,xi=O(()=>{It(),Y(),Te(),ut(),j(),Im=(e,n,i,a)=>{let p=e.session.pack?2:0,o=G(e.session.backend.glContext.version);return{...n,output:{dims:i.dims,type:i.type,textureType:p},shaderSource:`
480
+ ${a.body}
481
481
  void main() {
482
482
  vec4 v = ${o.texture2D}(A, TexCoords);
483
- v = ${i.name}_(v);
483
+ v = ${a.name}_(v);
484
484
  ${o.output} = v;
485
485
  }
486
- `,hasMain:!0}},dt=(e,n,a,i)=>{let p=e.session.pack?2:0,o={name:a.name,inputTypes:[p],inputNames:["A"],cacheHint:i};return{...o,get:()=>Im(e,o,n,a)}},Rl=(e,n)=>[e.run(dt(e,n[0],im()),n)],Gl=(e,n)=>[e.run(dt(e,n[0],am()),n)],Ml=(e,n)=>[e.run(dt(e,n[0],sm()),n)],Ul=(e,n)=>[e.run(dt(e,n[0],um()),n)],gi=(e,n,a)=>[e.run(dt(e,n[0],hi(a.min,a.max),a.cacheKey),n)],Vl=e=>W({min:e.attributes.getFloat("min",Ve),max:e.attributes.getFloat("max",ze)}),zl=(e,n)=>{let a=_m(e,n);return gi(e,[n[0]],a)},_m=(e,n)=>{if(n.length>=3&&(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let a=n.length>=3?n[1].numberData[0]:Ve,i=n.length>=3?n[2].numberData[0]:ze;return W({min:a,max:i})},Wl=(e,n)=>[e.run(dt(e,n[0],lm()),n)],Hl=(e,n)=>[e.run(dt(e,n[0],fm()),n)],ql=(e,n,a)=>[e.run(dt(e,n[0],cm(a.alpha),a.cacheKey),n)],jl=e=>W({alpha:e.attributes.getFloat("alpha",1)}),Xl=(e,n)=>[e.run(dt(e,n[0],pm()),n)],Kl=(e,n)=>[e.run(dt(e,n[0],dm()),n)],yi=(e,n)=>[e.run(dt(e,n[0],hm()),n)],Jl=(e,n,a)=>[e.run(dt(e,n[0],mm(a.alpha),a.cacheKey),n)],Yl=e=>W({alpha:e.attributes.getFloat("alpha",.01)}),Zl=(e,n)=>[e.run(dt(e,n[0],bm()),n)],Ql=(e,n)=>[e.run(dt(e,n[0],gm()),n)],tf=(e,n)=>[e.run(dt(e,n[0],ym()),n)],ef=(e,n)=>[e.run(dt(e,n[0],mi()),n)],rf=(e,n)=>[e.run(dt(e,n[0],bi()),n)],nf=(e,n)=>[e.run(dt(e,n[0],xm()),n)],of=(e,n)=>[e.run(dt(e,n[0],Tm()),n)],af=(e,n)=>[e.run(dt(e,n[0],wm()),n)],sf=(e,n)=>[e.run(dt(e,n[0],vm()),n)]});function he(e){let n;switch(e.activation){case"Relu":n=mi();break;case"Sigmoid":n=bi();break;case"Clip":n=hi(e.clipMin,e.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let a=n.name,i=n.body,p=`value = ${a}_(value);`;return{activationFunction:i,applyActivation:p}}var pr,qe=O(()=>{Y(),xi(),pr=e=>{let n=e.getString("activation","");if(n==="Clip"){let[a,i]=e.getFloats("activation_params",[Ve,ze]);return{activation:n,clipMax:i,clipMin:a,activationCacheKey:`${n}:${a},${i}`}}return{activation:n,activationCacheKey:n}}}),Sm,Am,uf,lf=O(()=>{Ut(),ut(),j(),Bn(),qe(),Sm=(e,n)=>({name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),Am=(e,n,a,i)=>{let p=n.length>2?"value += getBias(output_channel);":"",o=n[0].dims.slice(),s=n[1].dims.slice(),c=s[0]/i.group;tt.verbose("GroupedConv",`autpPad:${i.autoPad}, dilations:${i.dilations}, group:${i.group}, kernelShape:${i.kernelShape}, pads:${i.pads}, strides:${i.strides}`);let h=dr(o,s,i.dilations,i.pads,i.strides),r=G(e.session.backend.glContext.version),{activationFunction:u,applyActivation:l}=he(i),f=`
487
- const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]});
488
- const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]});
486
+ `,hasMain:!0}},dt=(e,n,i,a)=>{let p=e.session.pack?2:0,o={name:i.name,inputTypes:[p],inputNames:["A"],cacheHint:a};return{...o,get:()=>Im(e,o,n,i)}},Rl=(e,n)=>[e.run(dt(e,n[0],im()),n)],Gl=(e,n)=>[e.run(dt(e,n[0],am()),n)],Ml=(e,n)=>[e.run(dt(e,n[0],sm()),n)],Ul=(e,n)=>[e.run(dt(e,n[0],um()),n)],gi=(e,n,i)=>[e.run(dt(e,n[0],hi(i.min,i.max),i.cacheKey),n)],Vl=e=>W({min:e.attributes.getFloat("min",Ve),max:e.attributes.getFloat("max",ze)}),zl=(e,n)=>{let i=_m(e,n);return gi(e,[n[0]],i)},_m=(e,n)=>{if(n.length>=3&&(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let i=n.length>=3?n[1].numberData[0]:Ve,a=n.length>=3?n[2].numberData[0]:ze;return W({min:i,max:a})},Wl=(e,n)=>[e.run(dt(e,n[0],lm()),n)],Hl=(e,n)=>[e.run(dt(e,n[0],fm()),n)],ql=(e,n,i)=>[e.run(dt(e,n[0],cm(i.alpha),i.cacheKey),n)],jl=e=>W({alpha:e.attributes.getFloat("alpha",1)}),Xl=(e,n)=>[e.run(dt(e,n[0],pm()),n)],Kl=(e,n)=>[e.run(dt(e,n[0],dm()),n)],yi=(e,n)=>[e.run(dt(e,n[0],hm()),n)],Jl=(e,n,i)=>[e.run(dt(e,n[0],mm(i.alpha),i.cacheKey),n)],Yl=e=>W({alpha:e.attributes.getFloat("alpha",.01)}),Zl=(e,n)=>[e.run(dt(e,n[0],bm()),n)],Ql=(e,n)=>[e.run(dt(e,n[0],gm()),n)],tf=(e,n)=>[e.run(dt(e,n[0],ym()),n)],ef=(e,n)=>[e.run(dt(e,n[0],mi()),n)],rf=(e,n)=>[e.run(dt(e,n[0],bi()),n)],nf=(e,n)=>[e.run(dt(e,n[0],xm()),n)],of=(e,n)=>[e.run(dt(e,n[0],Tm()),n)],af=(e,n)=>[e.run(dt(e,n[0],wm()),n)],sf=(e,n)=>[e.run(dt(e,n[0],vm()),n)]});function he(e){let n;switch(e.activation){case"Relu":n=mi();break;case"Sigmoid":n=bi();break;case"Clip":n=hi(e.clipMin,e.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let i=n.name,a=n.body,p=`value = ${i}_(value);`;return{activationFunction:a,applyActivation:p}}var pr,qe=O(()=>{Y(),xi(),pr=e=>{let n=e.getString("activation","");if(n==="Clip"){let[i,a]=e.getFloats("activation_params",[Ve,ze]);return{activation:n,clipMax:a,clipMin:i,activationCacheKey:`${n}:${i},${a}`}}return{activation:n,activationCacheKey:n}}}),Sm,Am,uf,lf=O(()=>{Ut(),ut(),j(),Bn(),qe(),Sm=(e,n)=>({name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),Am=(e,n,i,a)=>{let p=n.length>2?"value += getBias(output_channel);":"",o=n[0].dims.slice(),s=n[1].dims.slice(),c=s[0]/a.group;tt.verbose("GroupedConv",`autpPad:${a.autoPad}, dilations:${a.dilations}, group:${a.group}, kernelShape:${a.kernelShape}, pads:${a.pads}, strides:${a.strides}`);let h=dr(o,s,a.dilations,a.pads,a.strides),r=G(e.session.backend.glContext.version),{activationFunction:u,applyActivation:l}=he(a),f=`
487
+ const ivec2 strides = ivec2(${a.strides[0]}, ${a.strides[1]});
488
+ const ivec2 pads = ivec2(${a.pads[0]}, ${a.pads[1]});
489
489
  ${u}
490
490
  void main() {
491
491
  ivec4 coords = getOutputCoords();
@@ -498,14 +498,14 @@
498
498
  for (int wInChannel = 0; wInChannel < ${s[1]}; wInChannel++) {
499
499
  int input_channel = group_id * ${s[1]} + wInChannel;
500
500
  for (int wHeight = 0; wHeight < ${s[2]}; wHeight++) {
501
- int xHeight = xRCCorner.x + wHeight * ${i.dilations[0]};
501
+ int xHeight = xRCCorner.x + wHeight * ${a.dilations[0]};
502
502
 
503
503
  if (xHeight < 0 || xHeight >= ${o[2]}) {
504
504
  continue;
505
505
  }
506
506
 
507
507
  for (int wWidth = 0; wWidth < ${s[3]}; wWidth++) {
508
- int xWidth = xRCCorner.y + wWidth * ${i.dilations[1]};
508
+ int xWidth = xRCCorner.y + wWidth * ${a.dilations[1]};
509
509
  if (xWidth < 0 || xWidth >= ${o[3]}) {
510
510
  continue;
511
511
  }
@@ -520,7 +520,7 @@
520
520
  ${l}
521
521
  ${r.output} = vec4(value, .0, .0, .0);
522
522
  }
523
- `;return{...a,output:{dims:h,type:n[0].type,textureType:0},shaderSource:f,hasMain:!0}},uf=(e,n,a)=>{let i=Sm(n.length>2,a.cacheKey);return{...i,get:()=>Am(e,n,i,a)}}}),Pm,Em,ff,cf=O(()=>{ut(),j(),He(),Pm=e=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:e}),Em=(e,n,a,i,p,o)=>{let s=a.dims,c=i.dims,h=2,r=3,u=p.length,l=[c[1]*c[2]*c[3],p[2]*p[3]],f=c[2]*c[3],g=de(),b=G(e.session.backend.glContext.version),v="";for(let P=0;P<=1;P++)for(let _=0;_<=1;_++)v+=`
523
+ `;return{...i,output:{dims:h,type:n[0].type,textureType:0},shaderSource:f,hasMain:!0}},uf=(e,n,i)=>{let a=Sm(n.length>2,i.cacheKey);return{...a,get:()=>Am(e,n,a,i)}}}),Pm,Em,ff,cf=O(()=>{ut(),j(),He(),Pm=e=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:e}),Em=(e,n,i,a,p,o)=>{let s=i.dims,c=a.dims,h=2,r=3,u=p.length,l=[c[1]*c[2]*c[3],p[2]*p[3]],f=c[2]*c[3],g=de(),b=G(e.session.backend.glContext.version),v="";for(let P=0;P<=1;P++)for(let _=0;_<=1;_++)v+=`
524
524
  blockIndex = rc.x + ${_};
525
525
  pos = rc.y + ${P};
526
526
 
@@ -556,7 +556,7 @@
556
556
  ${v}
557
557
  ${b.output} = result;
558
558
  }
559
- `;return{...n,output:{dims:l,type:a.type,textureType:2},shaderSource:S,hasMain:!0}},ff=(e,n,a,i,p)=>{let o=Pm(p.cacheKey);return{...o,get:()=>Em(e,o,n,a,i,p)}}});function Lm(e,n,a){let i=n[0].dims,p=n[1].dims,o=kt.calcShape(i,p,!0);if(!o)throw new Error("Can't use matmul on the given tensors");let s=Bt(o.length),c=ne(),{activationFunction:h,applyActivation:r}=he(a),u=n.length>2,l=u?"value += getBiasForMatmul();":"",f=u?`${wi(s,c,n[2].dims,o,!1)}`:"",g=o.length,b=i.length,v=p.length,S=i[i.length-1],P=`
559
+ `;return{...n,output:{dims:l,type:i.type,textureType:2},shaderSource:S,hasMain:!0}},ff=(e,n,i,a,p)=>{let o=Pm(p.cacheKey);return{...o,get:()=>Em(e,o,n,i,a,p)}}});function Lm(e,n,i){let a=n[0].dims,p=n[1].dims,o=kt.calcShape(a,p,!0);if(!o)throw new Error("Can't use matmul on the given tensors");let s=Bt(o.length),c=ne(),{activationFunction:h,applyActivation:r}=he(i),u=n.length>2,l=u?"value += getBiasForMatmul();":"",f=u?`${wi(s,c,n[2].dims,o,!1)}`:"",g=o.length,b=a.length,v=p.length,S=a[a.length-1],P=`
560
560
  ${h}
561
561
  ${f}
562
562
  float process(int indices[${g}]) {
@@ -574,8 +574,8 @@
574
574
  ${l}
575
575
  ${r}
576
576
  return value;
577
- }`;return{...e,output:{dims:o,type:n[0].type,textureType:0},shaderSource:P}}function Ti(e,n){let a=Dm(e.length>2,n.activationCacheKey);return{...a,get:()=>Lm(a,e,n)}}function wi(e,n,a,i,p){let o="",s=a.length,c=i.length,h=c-s;c<2&&s>0?o="coords":o=a.map((f,g)=>`coords.${n[g+h]}`).join(", ");let r=kt.getBroadcastDims(a,i).map(f=>`coords.${n[f+h]} = 0;`).join(`
578
- `),u=B.size(a)===1,l="vec4(outputValue.xx, outputValue.yy)";return u&&(l="vec4(outputValue.x)"),p?`
577
+ }`;return{...e,output:{dims:o,type:n[0].type,textureType:0},shaderSource:P}}function Ti(e,n){let i=Dm(e.length>2,n.activationCacheKey);return{...i,get:()=>Lm(i,e,n)}}function wi(e,n,i,a,p){let o="",s=i.length,c=a.length,h=c-s;c<2&&s>0?o="coords":o=i.map((f,g)=>`coords.${n[g+h]}`).join(", ");let r=kt.getBroadcastDims(i,a).map(f=>`coords.${n[f+h]} = 0;`).join(`
578
+ `),u=B.size(i)===1,l="vec4(outputValue.xx, outputValue.yy)";return u&&(l="vec4(outputValue.x)"),p?`
579
579
  vec4 getBiasForMatmul() {
580
580
  ${e} coords = getOutputCoords();
581
581
  ${r}
@@ -586,7 +586,7 @@ float getBiasForMatmul() {
586
586
  ${e} coords = getOutputCoords();
587
587
  ${r}
588
588
  return getBias(coords.x);
589
- }`}var pf,df,Dm,$m,Fn=O(()=>{Y(),j(),pe(),qe(),vi(),pf=(e,n,a)=>($m(n),e.session.pack?[e.run(Cn(e,n,a),n)]:[e.run(Ti(n,a),n)]),df=e=>pr(e.attributes),Dm=(e,n)=>({name:"MatMul",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),$m=e=>{if(!e||e.length!==2)throw new Error("MatMul requires 2 inputs.");if(e[0].dims[e[0].dims.length-1]!==e[1].dims[e[1].dims.length-2])throw new Error("shared dimension does not match.");if(e[0].type!=="float32"&&e[0].type!=="float64"||e[1].type!=="float32"&&e[1].type!=="float64")throw new Error("inputs should be float type");if(e[0].type!==e[1].type)throw new Error("inputs types should match")}});function Fm(e,n,a,i){let p=[],o=[],s=a[0].dims,c=a[1].dims,h=s.length,r=c.length,u=i.length,l=u-h,f=u-r;p=s.map((_,A)=>`coords.${n[A+l]}`),p[h-1]="i*2",p.join(", "),o=c.map((_,A)=>`coords.${n[A+f]}`),o[r-2]="i*2",o.join(", ");let g=kt.getBroadcastDims(s,i),b=kt.getBroadcastDims(c,i),v=g.map(_=>`coords.${n[_+l]} = 0;`).join(`
589
+ }`}var pf,df,Dm,$m,Fn=O(()=>{Y(),j(),pe(),qe(),vi(),pf=(e,n,i)=>($m(n),e.session.pack?[e.run(Cn(e,n,i),n)]:[e.run(Ti(n,i),n)]),df=e=>pr(e.attributes),Dm=(e,n)=>({name:"MatMul",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),$m=e=>{if(!e||e.length!==2)throw new Error("MatMul requires 2 inputs.");if(e[0].dims[e[0].dims.length-1]!==e[1].dims[e[1].dims.length-2])throw new Error("shared dimension does not match.");if(e[0].type!=="float32"&&e[0].type!=="float64"||e[1].type!=="float32"&&e[1].type!=="float64")throw new Error("inputs should be float type");if(e[0].type!==e[1].type)throw new Error("inputs types should match")}});function Fm(e,n,i,a){let p=[],o=[],s=i[0].dims,c=i[1].dims,h=s.length,r=c.length,u=a.length,l=u-h,f=u-r;p=s.map((_,A)=>`coords.${n[A+l]}`),p[h-1]="i*2",p.join(", "),o=c.map((_,A)=>`coords.${n[A+f]}`),o[r-2]="i*2",o.join(", ");let g=kt.getBroadcastDims(s,a),b=kt.getBroadcastDims(c,a),v=g.map(_=>`coords.${n[_+l]} = 0;`).join(`
590
590
  `),S=b.map(_=>`coords.${n[_+f]} = 0;`).join(`
591
591
  `),P=`int lastDim = coords.${n[u-1]};
592
592
  coords.${n[u-1]} = coords.${n[u-2]};
@@ -605,11 +605,11 @@ vec4 getBAtOutCoordsMatmul(int i) {
605
605
  ${S}
606
606
  vec4 outputValue = getB(${o});
607
607
  return outputValue;
608
- }`}function Cm(e,n){let a="";for(let i=0;i<n-2;i++)a+=`rc.${e[i]}, `;return a+=`rc.${e[n-2]}, i*2`,a}function Nm(e,n){let a="";for(let i=0;i<n-2;i++)a+=`rc.${e[i]}, `;return a+=`i*2, rc.${e[n-1]}`,a}var km,Bm,Cn,vi=O(()=>{Y(),ut(),j(),pe(),qe(),Fn(),km=(e,n)=>({name:"MatMul (packed)",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[2,2,2]:[2,2],cacheHint:n}),Bm=(e,n,a,i)=>{let p=a.length>2,o=p?"value += getBiasForMatmul();":"",s=a[0].dims,c=a[1].dims,h=kt.calcShape(s,c,!0),r=!B.areEqual(a[0].dims,a[1].dims);if(!h)throw new Error("Can't use matmul on the given tensors");let u=s[s.length-1],l=Math.ceil(u/2),f=s.length,g=c.length,b=G(e.session.backend.glContext.version),v=Bt(h.length),S=h.length,P=ne(),{activationFunction:_,applyActivation:A}=he(i),L=p?`${wi(v,P,a[2].dims,h,!0)}`:"",V=r?`${Fm(v,P,a,h)}`:"",ft=r?"getAAtOutCoordsMatmul(i)":`getA(${Cm(P,f)})`,lt=r?"getBAtOutCoordsMatmul(i)":`getB(${Nm(P,g)})`,Nt=r?"":`${v} rc =
608
+ }`}function Cm(e,n){let i="";for(let a=0;a<n-2;a++)i+=`rc.${e[a]}, `;return i+=`rc.${e[n-2]}, i*2`,i}function Nm(e,n){let i="";for(let a=0;a<n-2;a++)i+=`rc.${e[a]}, `;return i+=`i*2, rc.${e[n-1]}`,i}var km,Bm,Cn,vi=O(()=>{Y(),ut(),j(),pe(),qe(),Fn(),km=(e,n)=>({name:"MatMul (packed)",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[2,2,2]:[2,2],cacheHint:n}),Bm=(e,n,i,a)=>{let p=i.length>2,o=p?"value += getBiasForMatmul();":"",s=i[0].dims,c=i[1].dims,h=kt.calcShape(s,c,!0),r=!B.areEqual(i[0].dims,i[1].dims);if(!h)throw new Error("Can't use matmul on the given tensors");let u=s[s.length-1],l=Math.ceil(u/2),f=s.length,g=c.length,b=G(e.session.backend.glContext.version),v=Bt(h.length),S=h.length,P=ne(),{activationFunction:_,applyActivation:A}=he(a),L=p?`${wi(v,P,i[2].dims,h,!0)}`:"",M=r?`${Fm(v,P,i,h)}`:"",ft=r?"getAAtOutCoordsMatmul(i)":`getA(${Cm(P,f)})`,lt=r?"getBAtOutCoordsMatmul(i)":`getB(${Nm(P,g)})`,Nt=r?"":`${v} rc =
609
609
  getOutputCoords(); int lastDim = rc.${P[S-1]}; rc.${P[S-1]} =
610
610
  rc.${P[S-2]}; rc.${P[S-2]} = lastDim;
611
611
  `,Q=`
612
- ${V}
612
+ ${M}
613
613
  ${L}
614
614
  ${_}
615
615
  void main() {
@@ -626,7 +626,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
626
626
  ${o}
627
627
  ${A}
628
628
  ${b.output} = value;
629
- }`;return{...n,output:{dims:h,type:a[0].type,textureType:2},shaderSource:Q,hasMain:!0}},Cn=(e,n,a)=>{let i=km(n.length>2,a.activationCacheKey);return{...i,get:()=>Bm(e,i,n,a)}}}),hf,mf=O(()=>{Bn(),cf(),vi(),hf=(e,n,a)=>{let i=n[0].dims,p=n[1].dims,o=dr(i,p,a.dilations,a.pads,a.strides),s=e.run(ff(e,n[0],n[1],o,a),[n[0]]),c=e.reshapePacked(n[1],[p[0],p[1]*p[2]*p[3]]),h=n.length===3?[c,s,n[2]]:[c,s],r=e.run(Cn(e,h,a),h);return e.reshapePacked(r,o)}}),Rm,Gm,bf,Ii,_i=O(()=>{j(),Rm=e=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:e}),Gm=(e,n,a,i,p,o)=>{let s=a.dims,c=i.dims,h=p.length,r=Ii(s,c,p,4),u=`
629
+ }`;return{...n,output:{dims:h,type:i[0].type,textureType:2},shaderSource:Q,hasMain:!0}},Cn=(e,n,i)=>{let a=km(n.length>2,i.activationCacheKey);return{...a,get:()=>Bm(e,a,n,i)}}}),hf,mf=O(()=>{Bn(),cf(),vi(),hf=(e,n,i)=>{let a=n[0].dims,p=n[1].dims,o=dr(a,p,i.dilations,i.pads,i.strides),s=e.run(ff(e,n[0],n[1],o,i),[n[0]]),c=e.reshapePacked(n[1],[p[0],p[1]*p[2]*p[3]]),h=n.length===3?[c,s,n[2]]:[c,s],r=e.run(Cn(e,h,i),h);return e.reshapePacked(r,o)}}),Rm,Gm,bf,Ii,_i=O(()=>{j(),Rm=e=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:e}),Gm=(e,n,i,a,p,o)=>{let s=i.dims,c=a.dims,h=p.length,r=Ii(s,c,p,4),u=`
630
630
  const int XC = ${s[1]};
631
631
  const int XH = ${s[2]};
632
632
  const int XW = ${s[3]};
@@ -670,7 +670,7 @@ vec4 getBAtOutCoordsMatmul(int i) {
670
670
  }
671
671
  return value;
672
672
  }
673
- `;return{...n,output:{dims:r,type:a.type,textureType:4},shaderSource:u}},bf=(e,n,a,i,p)=>{let o=Rm(p.cacheKey);return{...o,get:()=>Gm(e,o,n,a,i,p)}},Ii=(e,n,a,i=4)=>[a[0],a[2],a[3],Math.ceil(e[1]*n[2]*n[3]/i)]}),Mm,Um,gf,yf=O(()=>{Y(),ut(),j(),qe(),_i(),Mm=(e,n)=>({name:"ConvDotProduct",inputNames:e?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:e?[0,4,0]:[0,4],cacheKey:n.activationCacheKey}),Um=(e,n,a,i,p)=>{let o=a[0].dims,s=a[1].dims,c=[s[0],Math.ceil(o[1]*s[2]*s[3]/4)],h=Ii(o,s,i),[r,u]=e.calculateTextureWidthAndHeight(c,4),l=B.computeStrides(h),[f,g]=e.calculateTextureWidthAndHeight(h,4),b=i.length,v=a.length<3?"0.0":"_B(b)",S=Math.ceil(o[1]*s[2]*s[3]/4),{activationFunction:P,applyActivation:_}=he(p),A=G(e.session.backend.glContext.version),L=`
673
+ `;return{...n,output:{dims:r,type:i.type,textureType:4},shaderSource:u}},bf=(e,n,i,a,p)=>{let o=Rm(p.cacheKey);return{...o,get:()=>Gm(e,o,n,i,a,p)}},Ii=(e,n,i,a=4)=>[i[0],i[2],i[3],Math.ceil(e[1]*n[2]*n[3]/a)]}),Mm,Um,gf,yf=O(()=>{Y(),ut(),j(),qe(),_i(),Mm=(e,n)=>({name:"ConvDotProduct",inputNames:e?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:e?[0,4,0]:[0,4],cacheKey:n.activationCacheKey}),Um=(e,n,i,a,p)=>{let o=i[0].dims,s=i[1].dims,c=[s[0],Math.ceil(o[1]*s[2]*s[3]/4)],h=Ii(o,s,a),[r,u]=e.calculateTextureWidthAndHeight(c,4),l=B.computeStrides(h),[f,g]=e.calculateTextureWidthAndHeight(h,4),b=a.length,v=i.length<3?"0.0":"_B(b)",S=Math.ceil(o[1]*s[2]*s[3]/4),{activationFunction:P,applyActivation:_}=he(p),A=G(e.session.backend.glContext.version),L=`
674
674
  ${P}
675
675
  float process(int indices[${b}]) {
676
676
  int b[1];
@@ -691,9 +691,9 @@ float process(int indices[${b}]) {
691
691
  }
692
692
  ${_}
693
693
  return value;
694
- }`;return{...n,output:{dims:i,type:a[0].type,textureType:0},shaderSource:L}},gf=(e,n,a,i)=>{let p=Mm(n.length>2,i);return{...p,get:()=>Um(e,p,n,a,i)}}}),dr,Oi,Vm,zm,Wm,Hm,Si,qm,Bn=O(()=>{It(),Y(),lf(),mf(),yf(),qe(),_i(),Fn(),dr=(e,n,a,i,p)=>{let o=e[0],s=e.slice(2),c=s.length,h=n[0],r=n.slice(2).map((l,f)=>l+(l-1)*(a[f]-1)),u=s.map((l,f)=>l+i[f]+i[f+c]).map((l,f)=>Math.floor((l-r[f]+p[f])/p[f]));return[o,h].concat(...u)},Oi=(e,n,a)=>(qm(n,a),Vm(e,n,a)),Vm=(e,n,a)=>{let i=Hm(a,n),p=e.session.pack,o=i.kernelShape[0]===1&&i.kernelShape[1]===1;return i.group>1?[e.run(uf(e,n,i),n)]:o&&p?[zm(e,n,i)]:p&&n[0].dims.length===4&&n[0].dims[0]===1&&!o?[hf(e,n,i)]:[Wm(e,n,i)]},zm=(e,n,a)=>{let i=n[0].dims,p=n[1].dims,o=dr(i,p,a.dilations,a.pads,a.strides),s=e.reshapeUnpacked(n[0],[i[1],i[2]*i[3]]),c=e.reshapeUnpacked(n[1],[p[0],p[1]]),h=n.length>2?[c,s,n[2]]:[c,s],r=e.run(Ti(h,a),h);return e.reshapeUnpacked(r,o)},Wm=(e,n,a)=>{let i=n[0].dims,p=n[1].dims,o=dr(i,p,a.dilations,a.pads,a.strides),s=e.run(bf(e,n[0],n[1],o,a),[n[0]]),c=n.length===3?[s,n[1],n[2]]:[s,n[1]];return e.run(gf(e,n,o,a),c)},Hm=(e,n)=>{let a=e.kernelShape.slice();if(e.kernelShape.length===0)for(let o=2;o<n[1].dims.length;++o)a.push(n[1].dims[o]);let i=e.pads.slice();Ue.adjustPadsBasedOnAutoPad(n[0].dims,e.strides,e.dilations,a,i,e.autoPad);let p=Object.assign({},e);return Object.assign(p,{kernelShape:a,pads:i,cacheKey:e.cacheKey}),p},Si=e=>{let n=e.attributes,a=pr(n),i=n.getString("auto_pad","NOTSET"),p=n.getInts("dilations",[1,1]),o=n.getInt("group",1),s=n.getInts("kernel_shape",[]),c=n.getInts("pads",[0,0,0,0]),h=n.getInts("strides",[1,1]);return W({autoPad:i,dilations:p,group:o,kernelShape:s,pads:c,strides:h,...a})},qm=(e,n)=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(e[0].dims.length!==4||e[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let a=e[0].dims[1],i=e[1].dims[1]*n.group;if(a!==i)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(e.length===3&&(e[2].dims.length!==1||e[1].dims[0]!==e[2].dims[0]))throw new Error("invalid bias");let p=e[0].dims.length-2;if(n.dilations.length!==p)throw new Error(`dilations should be ${p}D`);if(n.strides.length!==p)throw new Error(`strides should be ${p}D`);if(n.pads.length!==p*2)throw new Error(`pads should be ${p*2}D`);if(n.kernelShape.length!==0&&n.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(e[0].type!=="float32"||e[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(e.length===3&&e[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}}),jm,Xm,Km,xf,Jm,Ym,Zm,Qm,tb,eb,Tf,rb,wf=O(()=>{It(),ut(),j(),qe(),jm=(e,n,a,i,p,o)=>(e-1)*n+a+(i-1)*p+1-o,Xm=(e,n,a,i,p)=>{let o=Math.floor(e/2);n==="SAME_UPPER"?(a[i]=o,a[p]=e-o):n==="SAME_LOWER"&&(a[i]=e-o,a[p]=o)},Km=(e,n,a,i,p,o,s,c)=>{let h=e.length-2,r=c.length===0;for(let u=0;u<h;++u){let l=r?e[u+2]*o[u]:c[u],f=jm(e[u+2],o[u],p[u],n[u],a[u],l);Xm(f,i,p,u,u+h),r&&c.push(o[u]*(e[u+2]-1)+s[u]+(n[u]-1)*a[u]+1-p[u]-p[u+h])}},xf=(e,n,a)=>(rb(n,a),Jm(e,n,a)),Jm=(e,n,a)=>{let i=eb(a,n);return[tb(e,n,i)]},Ym=(e,n)=>({name:"ConvTranspose",inputNames:e?["X","W","B"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),Zm=(e,n,a,i)=>{let p=n.length>2?"getB(output_channel)":"0.0",o=n[0].dims,s=n[1].dims,c=s[1],h=s[0]/i.group,r=[n[0].dims[0],n[1].dims[1]*i.group,...i.outputShape],u=G(e.session.backend.glContext.version),{activationFunction:l,applyActivation:f}=he(i),g=`
695
- const ivec2 strides = ivec2(${i.strides[0]}, ${i.strides[1]});
696
- const ivec2 pads = ivec2(${i.pads[0]}, ${i.pads[1]});
694
+ }`;return{...n,output:{dims:a,type:i[0].type,textureType:0},shaderSource:L}},gf=(e,n,i,a)=>{let p=Mm(n.length>2,a);return{...p,get:()=>Um(e,p,n,i,a)}}}),dr,Oi,Vm,zm,Wm,Hm,Si,qm,Bn=O(()=>{It(),Y(),lf(),mf(),yf(),qe(),_i(),Fn(),dr=(e,n,i,a,p)=>{let o=e[0],s=e.slice(2),c=s.length,h=n[0],r=n.slice(2).map((l,f)=>l+(l-1)*(i[f]-1)),u=s.map((l,f)=>l+a[f]+a[f+c]).map((l,f)=>Math.floor((l-r[f]+p[f])/p[f]));return[o,h].concat(...u)},Oi=(e,n,i)=>(qm(n,i),Vm(e,n,i)),Vm=(e,n,i)=>{let a=Hm(i,n),p=e.session.pack,o=a.kernelShape[0]===1&&a.kernelShape[1]===1;return a.group>1?[e.run(uf(e,n,a),n)]:o&&p?[zm(e,n,a)]:p&&n[0].dims.length===4&&n[0].dims[0]===1&&!o?[hf(e,n,a)]:[Wm(e,n,a)]},zm=(e,n,i)=>{let a=n[0].dims,p=n[1].dims,o=dr(a,p,i.dilations,i.pads,i.strides),s=e.reshapeUnpacked(n[0],[a[1],a[2]*a[3]]),c=e.reshapeUnpacked(n[1],[p[0],p[1]]),h=n.length>2?[c,s,n[2]]:[c,s],r=e.run(Ti(h,i),h);return e.reshapeUnpacked(r,o)},Wm=(e,n,i)=>{let a=n[0].dims,p=n[1].dims,o=dr(a,p,i.dilations,i.pads,i.strides),s=e.run(bf(e,n[0],n[1],o,i),[n[0]]),c=n.length===3?[s,n[1],n[2]]:[s,n[1]];return e.run(gf(e,n,o,i),c)},Hm=(e,n)=>{let i=e.kernelShape.slice();if(e.kernelShape.length===0)for(let o=2;o<n[1].dims.length;++o)i.push(n[1].dims[o]);let a=e.pads.slice();Ue.adjustPadsBasedOnAutoPad(n[0].dims,e.strides,e.dilations,i,a,e.autoPad);let p=Object.assign({},e);return Object.assign(p,{kernelShape:i,pads:a,cacheKey:e.cacheKey}),p},Si=e=>{let n=e.attributes,i=pr(n),a=n.getString("auto_pad","NOTSET"),p=n.getInts("dilations",[1,1]),o=n.getInt("group",1),s=n.getInts("kernel_shape",[]),c=n.getInts("pads",[0,0,0,0]),h=n.getInts("strides",[1,1]);return W({autoPad:a,dilations:p,group:o,kernelShape:s,pads:c,strides:h,...i})},qm=(e,n)=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(e[0].dims.length!==4||e[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let i=e[0].dims[1],a=e[1].dims[1]*n.group;if(i!==a)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(e.length===3&&(e[2].dims.length!==1||e[1].dims[0]!==e[2].dims[0]))throw new Error("invalid bias");let p=e[0].dims.length-2;if(n.dilations.length!==p)throw new Error(`dilations should be ${p}D`);if(n.strides.length!==p)throw new Error(`strides should be ${p}D`);if(n.pads.length!==p*2)throw new Error(`pads should be ${p*2}D`);if(n.kernelShape.length!==0&&n.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(e[0].type!=="float32"||e[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(e.length===3&&e[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}}),jm,Xm,Km,xf,Jm,Ym,Zm,Qm,tb,eb,Tf,rb,wf=O(()=>{It(),ut(),j(),qe(),jm=(e,n,i,a,p,o)=>(e-1)*n+i+(a-1)*p+1-o,Xm=(e,n,i,a,p)=>{let o=Math.floor(e/2);n==="SAME_UPPER"?(i[a]=o,i[p]=e-o):n==="SAME_LOWER"&&(i[a]=e-o,i[p]=o)},Km=(e,n,i,a,p,o,s,c)=>{let h=e.length-2,r=c.length===0;for(let u=0;u<h;++u){let l=r?e[u+2]*o[u]:c[u],f=jm(e[u+2],o[u],p[u],n[u],i[u],l);Xm(f,a,p,u,u+h),r&&c.push(o[u]*(e[u+2]-1)+s[u]+(n[u]-1)*i[u]+1-p[u]-p[u+h])}},xf=(e,n,i)=>(rb(n,i),Jm(e,n,i)),Jm=(e,n,i)=>{let a=eb(i,n);return[tb(e,n,a)]},Ym=(e,n)=>({name:"ConvTranspose",inputNames:e?["X","W","B"]:["X","W"],inputTypes:e?[0,0,0]:[0,0],cacheHint:n}),Zm=(e,n,i,a)=>{let p=n.length>2?"getB(output_channel)":"0.0",o=n[0].dims,s=n[1].dims,c=s[1],h=s[0]/a.group,r=[n[0].dims[0],n[1].dims[1]*a.group,...a.outputShape],u=G(e.session.backend.glContext.version),{activationFunction:l,applyActivation:f}=he(a),g=`
695
+ const ivec2 strides = ivec2(${a.strides[0]}, ${a.strides[1]});
696
+ const ivec2 pads = ivec2(${a.pads[0]}, ${a.pads[1]});
697
697
  ${l}
698
698
  void main() {
699
699
  ivec4 coords = getOutputCoords();
@@ -710,7 +710,7 @@ float process(int indices[${b}]) {
710
710
  int input_channel = group_id * ${h} + inChannelOffset;
711
711
  for (int wWOff = 0; wWOff < ${s[2]}; wWOff++) {
712
712
  for (int wHOff = 0; wHOff < ${s[3]}; wHOff++) {
713
- ivec2 wOff = ivec2(wWOff * ${i.dilations[0]}, wHOff * ${i.dilations[1]});
713
+ ivec2 wOff = ivec2(wWOff * ${a.dilations[0]}, wHOff * ${a.dilations[1]});
714
714
  ivec2 wLoc = loc - wOff;
715
715
  ivec2 wLocIn = wLoc / strides;
716
716
  if (
@@ -728,14 +728,14 @@ float process(int indices[${b}]) {
728
728
  ${f}
729
729
  ${u.output} = vec4(value, .0, .0, .0);
730
730
  }
731
- `;return{...a,output:{dims:r,type:n[0].type,textureType:0},shaderSource:g,hasMain:!0}},Qm=(e,n,a)=>{let i=Ym(n.length>2,a.cacheKey);return{...i,get:()=>Zm(e,n,i,a)}},tb=(e,n,a)=>e.run(Qm(e,n,a),n),eb=(e,n)=>{let a=e.kernelShape.slice();if(e.kernelShape.length===0)for(let c=2;c<n[1].dims.length;++c)a.push(n[1].dims[c]);let i=e.pads.slice(),p=e.outputShape.slice(),o=n[0].dims;Km(o,a,e.dilations,e.autoPad,i,e.strides,e.outputPadding,p);let s=Object.assign({},e);return Object.assign(s,{kernelShape:a,pads:i,outputShape:p,cacheKey:e.cacheKey}),s},Tf=e=>{let n=e.attributes,a=pr(n),i=n.getString("auto_pad","NOTSET"),p=n.getInts("dilations",[1,1]),o=n.getInt("group",1),s=n.getInts("kernel_shape",[]),c=n.getInts("output_padding",[0,0]),h=n.getInts("output_shape",[]),r=n.getInts("pads",[0,0,0,0]),u=n.getInts("strides",[1,1]);return W({autoPad:i,dilations:p,group:o,kernelShape:s,outputPadding:c,outputShape:h,pads:r,strides:u,...a})},rb=(e,n)=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(e[0].dims.length!==4||e[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let a=e[0].dims[1],i=e[1].dims[0];if(a!==i)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let p=e[1].dims[1]*n.group;if(e.length===3&&(e[2].dims.length!==1||e[2].dims[0]!==p))throw new Error("invalid bias");let o=e[0].dims.length-2;if(n.dilations.length!==o)throw new Error(`dilations should be ${o}D`);if(n.strides.length!==o)throw new Error(`strides should be ${o}D`);if(n.pads.length!==o*2)throw new Error(`pads should be ${o*2}D`);if(n.outputPadding.length!==o)throw new Error(`output_padding should be ${o}D`);if(n.kernelShape.length!==0&&n.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(n.outputShape.length!==0&&n.outputShape.length!==e[0].dims.length-2)throw new Error("invalid output shape");if(e[0].type!=="float32"||e[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(e.length===3&&e[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}}),vf,je,If,nb,_f,ob,ib,ab,Nn=O(()=>{It(),Y(),j(),vf={name:"Transpose",inputNames:["A"],inputTypes:[0]},je=(e,n,a)=>(ab(n),[e.run({...vf,cacheHint:a.cacheKey,get:()=>nb(e,n[0],a.perm)},n)]),If=e=>W({perm:e.attributes.getInts("perm",[])}),nb=(e,n,a)=>{let i=n.dims;a=_f(i,a);let p=ob(i,a),o=i.length,s=`
732
- ${ib("perm",a,o)}
731
+ `;return{...i,output:{dims:r,type:n[0].type,textureType:0},shaderSource:g,hasMain:!0}},Qm=(e,n,i)=>{let a=Ym(n.length>2,i.cacheKey);return{...a,get:()=>Zm(e,n,a,i)}},tb=(e,n,i)=>e.run(Qm(e,n,i),n),eb=(e,n)=>{let i=e.kernelShape.slice();if(e.kernelShape.length===0)for(let c=2;c<n[1].dims.length;++c)i.push(n[1].dims[c]);let a=e.pads.slice(),p=e.outputShape.slice(),o=n[0].dims;Km(o,i,e.dilations,e.autoPad,a,e.strides,e.outputPadding,p);let s=Object.assign({},e);return Object.assign(s,{kernelShape:i,pads:a,outputShape:p,cacheKey:e.cacheKey}),s},Tf=e=>{let n=e.attributes,i=pr(n),a=n.getString("auto_pad","NOTSET"),p=n.getInts("dilations",[1,1]),o=n.getInt("group",1),s=n.getInts("kernel_shape",[]),c=n.getInts("output_padding",[0,0]),h=n.getInts("output_shape",[]),r=n.getInts("pads",[0,0,0,0]),u=n.getInts("strides",[1,1]);return W({autoPad:a,dilations:p,group:o,kernelShape:s,outputPadding:c,outputShape:h,pads:r,strides:u,...i})},rb=(e,n)=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(e[0].dims.length!==4||e[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");let i=e[0].dims[1],a=e[1].dims[0];if(i!==a)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let p=e[1].dims[1]*n.group;if(e.length===3&&(e[2].dims.length!==1||e[2].dims[0]!==p))throw new Error("invalid bias");let o=e[0].dims.length-2;if(n.dilations.length!==o)throw new Error(`dilations should be ${o}D`);if(n.strides.length!==o)throw new Error(`strides should be ${o}D`);if(n.pads.length!==o*2)throw new Error(`pads should be ${o*2}D`);if(n.outputPadding.length!==o)throw new Error(`output_padding should be ${o}D`);if(n.kernelShape.length!==0&&n.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(n.outputShape.length!==0&&n.outputShape.length!==e[0].dims.length-2)throw new Error("invalid output shape");if(e[0].type!=="float32"||e[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(e.length===3&&e[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}}),vf,je,If,nb,_f,ob,ib,ab,Nn=O(()=>{It(),Y(),j(),vf={name:"Transpose",inputNames:["A"],inputTypes:[0]},je=(e,n,i)=>(ab(n),[e.run({...vf,cacheHint:i.cacheKey,get:()=>nb(e,n[0],i.perm)},n)]),If=e=>W({perm:e.attributes.getInts("perm",[])}),nb=(e,n,i)=>{let a=n.dims;i=_f(a,i);let p=ob(a,i),o=a.length,s=`
732
+ ${ib("perm",i,o)}
733
733
  float process(int indices[${o}]) {
734
734
  int a[${o}];
735
735
  perm(a, indices);
736
736
  return _A(a);
737
- }`;return{...vf,output:{dims:p,type:n.type,textureType:0},shaderSource:s}},_f=(e,n)=>(n&&n.length!==e.length&&(n=[...e.keys()].reverse()),n),ob=(e,n)=>(n=_f(e,n),B.sortBasedOnPerm(e,n)),ib=(e,n,a)=>{let i=[];i.push(`void ${e}(out int a[${a}], int src[${a}]) {`);for(let p=0;p<a;++p)i.push(` a[${n[p]}]=src[${p}];`);return i.push(" }"),i.join(`
738
- `)},ab=e=>{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}}),Of,Sf,sb,Af=O(()=>{Nn(),Of=(e,n,a)=>{sb(n);let i=a.blocksize,p=i*i,o=a.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],s=a.mode==="DCR"?[n[0].dims[0],i,i,n[0].dims[1]/p,n[0].dims[2],n[0].dims[3]]:[n[0].dims[0],n[0].dims[1]/p,i,i,n[0].dims[2],n[0].dims[3]],c=e.reshapeUnpacked(n[0],s),h={perm:o,cacheKey:`${o}`},[r]=je(e,[c],h),u=[n[0].dims[0],n[0].dims[1]/p,n[0].dims[2]*i,n[0].dims[3]*i];return[e.reshapeUnpacked(r,u)]},Sf=e=>{let n=e.attributes.getInt("blocksize");if(n<1)throw new Error(`blocksize must be >= 1, but got : ${n} for DepthToSpace`);let a=e.attributes.getString("mode","DCR");if(a!=="DCR"&&a!=="CRD")throw new Error(`unrecognized mode: ${a} for DepthToSpace`);return{mode:a,blocksize:n}},sb=e=>{if(e.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${e.length}`);if(e[0].type==="string"||e[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}}),Pf,Ef,ub,Df=O(()=>{Y(),Pf=(e,n,a)=>{ub(n,a);let i=B.flattenShape(n[0].dims,a);return[e.reshapeUnpacked(n[0],i)]},Ef=e=>e.attributes.getInt("axis",1),ub=(e,n)=>{if(!e||e.length!==1)throw new Error("Flatten requires 1 input.");let a=e[0].dims.length;if(a===0)throw new Error("scalar tensor is not supported.");if(n<-a||n>a)throw new Error("Invalid axis");if(e[0].type==="string")throw new Error("string tensor is not supported.")}}),Pe,Rr=O(()=>{Pe=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),Lf,$f,lb,fb,cb,pb,kf=O(()=>{It(),Rr(),Y(),j(),Lf=(e,n,a)=>(pb(n,a.axis),[e.run(cb(e,n,a),n)]),$f=e=>W({axis:e.attributes.getInt("axis",0)}),lb={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},fb=(e,n,a,i)=>{let p=a[0].dims.slice(),o=a[1].dims.slice(),s=new Array(p.length+o.length-1);i=B.normalizeAxis(i,p.length);let c=[];for(let f=0;f<s.length;f++)f<i?(s[f]=p[f],c.push(`inputIdx[${f}] = outputIdx[${f}];`)):f<i+o.length?(s[f]=o[f-i],c.push(`indexDataIdx[${f-i}] = outputIdx[${f}];`)):(s[f]=p[f-o.length+1],c.push(`inputIdx[${f-o.length+1}] = outputIdx[${f}];`));let h=s.length||1,r=p.length,u=o.length||1,l=`
737
+ }`;return{...vf,output:{dims:p,type:n.type,textureType:0},shaderSource:s}},_f=(e,n)=>(n&&n.length!==e.length&&(n=[...e.keys()].reverse()),n),ob=(e,n)=>(n=_f(e,n),B.sortBasedOnPerm(e,n)),ib=(e,n,i)=>{let a=[];a.push(`void ${e}(out int a[${i}], int src[${i}]) {`);for(let p=0;p<i;++p)a.push(` a[${n[p]}]=src[${p}];`);return a.push(" }"),a.join(`
738
+ `)},ab=e=>{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}}),Of,Sf,sb,Af=O(()=>{Nn(),Of=(e,n,i)=>{sb(n);let a=i.blocksize,p=a*a,o=i.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],s=i.mode==="DCR"?[n[0].dims[0],a,a,n[0].dims[1]/p,n[0].dims[2],n[0].dims[3]]:[n[0].dims[0],n[0].dims[1]/p,a,a,n[0].dims[2],n[0].dims[3]],c=e.reshapeUnpacked(n[0],s),h={perm:o,cacheKey:`${o}`},[r]=je(e,[c],h),u=[n[0].dims[0],n[0].dims[1]/p,n[0].dims[2]*a,n[0].dims[3]*a];return[e.reshapeUnpacked(r,u)]},Sf=e=>{let n=e.attributes.getInt("blocksize");if(n<1)throw new Error(`blocksize must be >= 1, but got : ${n} for DepthToSpace`);let i=e.attributes.getString("mode","DCR");if(i!=="DCR"&&i!=="CRD")throw new Error(`unrecognized mode: ${i} for DepthToSpace`);return{mode:i,blocksize:n}},sb=e=>{if(e.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${e.length}`);if(e[0].type==="string"||e[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}}),Pf,Ef,ub,Df=O(()=>{Y(),Pf=(e,n,i)=>{ub(n,i);let a=B.flattenShape(n[0].dims,i);return[e.reshapeUnpacked(n[0],a)]},Ef=e=>e.attributes.getInt("axis",1),ub=(e,n)=>{if(!e||e.length!==1)throw new Error("Flatten requires 1 input.");let i=e[0].dims.length;if(i===0)throw new Error("scalar tensor is not supported.");if(n<-i||n>i)throw new Error("Invalid axis");if(e[0].type==="string")throw new Error("string tensor is not supported.")}}),Pe,Rr=O(()=>{Pe=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),Lf,$f,lb,fb,cb,pb,kf=O(()=>{It(),Rr(),Y(),j(),Lf=(e,n,i)=>(pb(n,i.axis),[e.run(cb(e,n,i),n)]),$f=e=>W({axis:e.attributes.getInt("axis",0)}),lb={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},fb=(e,n,i,a)=>{let p=i[0].dims.slice(),o=i[1].dims.slice(),s=new Array(p.length+o.length-1);a=B.normalizeAxis(a,p.length);let c=[];for(let f=0;f<s.length;f++)f<a?(s[f]=p[f],c.push(`inputIdx[${f}] = outputIdx[${f}];`)):f<a+o.length?(s[f]=o[f-a],c.push(`indexDataIdx[${f-a}] = outputIdx[${f}];`)):(s[f]=p[f-o.length+1],c.push(`inputIdx[${f-o.length+1}] = outputIdx[${f}];`));let h=s.length||1,r=p.length,u=o.length||1,l=`
739
739
  float process(int outputIdx[${h}]) {
740
740
  int inputIdx[${r}];
741
741
  int indexDataIdx[${u}];
@@ -743,9 +743,9 @@ float process(int indices[${b}]) {
743
743
  ${c.join(`
744
744
  `)}
745
745
  int idx = int(_B(indexDataIdx));
746
- inputIdx[${i}] = idx < 0 ? idx + ${p[i]} : idx;
746
+ inputIdx[${a}] = idx < 0 ? idx + ${p[a]} : idx;
747
747
  return _A(inputIdx);
748
- }`;return{...n,output:{dims:s,type:a[0].type,textureType:0},shaderSource:l}},cb=(e,n,a)=>{let i={...lb,cacheHint:a.cacheKey};return{...i,get:()=>fb(e,i,n,a.axis)}},pb=(e,n)=>{if(!e||e.length!==2)throw new Error("Gather requires 2 inputs.");let a=e[0].dims.length;if(a<1)throw new Error("Invalid input shape.");if(n<-a||n>a-1)throw new Error("Invalid axis.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invaid input type.");if(e[1].type!=="int32"&&e[1].type!=="int16")throw new Error("Invaid input type.")}}),Ai,Bf,Ff,Cf,db,hb,mb,Nf=O(()=>{It(),Y(),j(),Ai=(e,n,a)=>(mb(n,a),[e.run(db(n,a),n)]),Bf=(e,n)=>{let a=e.attributes.getInt("transA",0)!==0,i=e.attributes.getInt("transB",0)!==0,p=e.attributes.getFloat("alpha",1),o=e.attributes.getFloat("beta",1);return W({transA:a,transB:i,alpha:p,beta:o,isOptionalC:n})},Ff=e=>Bf(e,!1),Cf=e=>Bf(e,!0),db=(e,n)=>{let a={name:"Gemm",inputNames:e.length===3?["A","B","C"]:["A","B"],inputTypes:e.length===3?[0,0,0]:[0,0],key:n.cacheKey};return{...a,get:()=>hb(a,e,n)}},hb=(e,n,a)=>{let i=n[0].dims.slice(),p=n[1].dims.slice(),[o,s]=Sn.getShapeOfGemmResult(i,a.transA,p,a.transB,n.length===3?n[2].dims:void 0),c=[o,s];if(!c)throw new Error("Can't use gemm on the given tensors");let h=i[i.length-1],r="";a.transA&&(h=i[0]),a.transA&&a.transB?r="value += _A_T(a) * _B_T(b);":a.transA&&!a.transB?r="value += _A_T(a) * _B(b);":!a.transA&&a.transB?r="value += _A(a) * _B_T(b);":!a.transA&&!a.transB&&(r="value += _A(a) * _B(b);");let u=c.length,l=n.length===3?`int c[${n[2].dims.length}];`:"",f=n.length===3?"bcastIndices_C(indices, c);":"",g=n.length===3?"value += beta * _C(c);":"",b=`
748
+ }`;return{...n,output:{dims:s,type:i[0].type,textureType:0},shaderSource:l}},cb=(e,n,i)=>{let a={...lb,cacheHint:i.cacheKey};return{...a,get:()=>fb(e,a,n,i.axis)}},pb=(e,n)=>{if(!e||e.length!==2)throw new Error("Gather requires 2 inputs.");let i=e[0].dims.length;if(i<1)throw new Error("Invalid input shape.");if(n<-i||n>i-1)throw new Error("Invalid axis.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invaid input type.");if(e[1].type!=="int32"&&e[1].type!=="int16")throw new Error("Invaid input type.")}}),Ai,Bf,Ff,Cf,db,hb,mb,Nf=O(()=>{It(),Y(),j(),Ai=(e,n,i)=>(mb(n,i),[e.run(db(n,i),n)]),Bf=(e,n)=>{let i=e.attributes.getInt("transA",0)!==0,a=e.attributes.getInt("transB",0)!==0,p=e.attributes.getFloat("alpha",1),o=e.attributes.getFloat("beta",1);return W({transA:i,transB:a,alpha:p,beta:o,isOptionalC:n})},Ff=e=>Bf(e,!1),Cf=e=>Bf(e,!0),db=(e,n)=>{let i={name:"Gemm",inputNames:e.length===3?["A","B","C"]:["A","B"],inputTypes:e.length===3?[0,0,0]:[0,0],key:n.cacheKey};return{...i,get:()=>hb(i,e,n)}},hb=(e,n,i)=>{let a=n[0].dims.slice(),p=n[1].dims.slice(),[o,s]=Sn.getShapeOfGemmResult(a,i.transA,p,i.transB,n.length===3?n[2].dims:void 0),c=[o,s];if(!c)throw new Error("Can't use gemm on the given tensors");let h=a[a.length-1],r="";i.transA&&(h=a[0]),i.transA&&i.transB?r="value += _A_T(a) * _B_T(b);":i.transA&&!i.transB?r="value += _A_T(a) * _B(b);":!i.transA&&i.transB?r="value += _A(a) * _B_T(b);":!i.transA&&!i.transB&&(r="value += _A(a) * _B(b);");let u=c.length,l=n.length===3?`int c[${n[2].dims.length}];`:"",f=n.length===3?"bcastIndices_C(indices, c);":"",g=n.length===3?"value += beta * _C(c);":"",b=`
749
749
  float process(int indices[${u}]) {
750
750
  int a[${u}];
751
751
  int b[${u}];
@@ -765,21 +765,21 @@ float process(int indices[${b}]) {
765
765
  value = value * alpha;
766
766
  ${g}
767
767
  return value;
768
- }`;return{...e,output:{dims:c,type:n[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:a.alpha},{name:"beta",type:"float",data:a.beta}],shaderSource:b}},mb=(e,n)=>{if(!e)throw new Error("Input is missing");if(n.isOptionalC&&(e.length<2||e.length>3))throw new Error("Invaid input shape.");if(!n.isOptionalC&&e.length!==3)throw new Error("Gemm requires 3 inputs");if(e.length===3&&e[2].dims.length!==1&&e[2].dims.length!==2)throw new Error("Invalid input shape of C");if(e[0].type!=="float32"&&e[0].type!=="float64"||e[1].type!=="float32"&&e[1].type!=="float64"||e.length===3&&e[2].type!=="float32"&&e[2].type!=="float64")throw new Error("Invalid input type.");if(e[0].type!==e[1].type||e.length===3&&e[0].type!==e[2].type)throw new Error("Input types are mismatched")}}),Rf,Gf,bb,gb,yb,xb,Tb,Mf=O(()=>{It(),j(),Rf=(e,n,a)=>(Tb(n),[e.run(yb(e,n,a),n)]),Gf=e=>{let n=e.attributes.getFloat("scale"),a=e.attributes.getFloats("bias");return W({scale:n,bias:a})},bb={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},gb=(e,n,a,i)=>{let p=a[0].dims.slice(),o=p.length,s=`
769
- ${xb(i.bias.length)}
768
+ }`;return{...e,output:{dims:c,type:n[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:i.alpha},{name:"beta",type:"float",data:i.beta}],shaderSource:b}},mb=(e,n)=>{if(!e)throw new Error("Input is missing");if(n.isOptionalC&&(e.length<2||e.length>3))throw new Error("Invaid input shape.");if(!n.isOptionalC&&e.length!==3)throw new Error("Gemm requires 3 inputs");if(e.length===3&&e[2].dims.length!==1&&e[2].dims.length!==2)throw new Error("Invalid input shape of C");if(e[0].type!=="float32"&&e[0].type!=="float64"||e[1].type!=="float32"&&e[1].type!=="float64"||e.length===3&&e[2].type!=="float32"&&e[2].type!=="float64")throw new Error("Invalid input type.");if(e[0].type!==e[1].type||e.length===3&&e[0].type!==e[2].type)throw new Error("Input types are mismatched")}}),Rf,Gf,bb,gb,yb,xb,Tb,Mf=O(()=>{It(),j(),Rf=(e,n,i)=>(Tb(n),[e.run(yb(e,n,i),n)]),Gf=e=>{let n=e.attributes.getFloat("scale"),i=e.attributes.getFloats("bias");return W({scale:n,bias:i})},bb={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},gb=(e,n,i,a)=>{let p=i[0].dims.slice(),o=p.length,s=`
769
+ ${xb(a.bias.length)}
770
770
  float process(int indices[${o}]) {
771
771
  return _X(indices) * scale + getBias(bias, indices[1]);
772
- }`;return{...n,output:{dims:p,type:a[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:i.bias.length,data:i.bias},{name:"scale",type:"float",data:i.scale}],shaderSource:s}},yb=(e,n,a)=>{let i={...bb,cacheHint:a.cacheKey};return{...i,get:()=>gb(e,i,n,a)}},xb=e=>{let n=[`float getBias(float bias[${e}], int channel) {`];for(let a=0;a<e;++a)a===0?n.push(` if (channel == ${a}) { return bias[${a}]; }`):a===e-1?n.push(` else { return bias[${a}]; }`):n.push(` else if (channel == ${a}) { return bias[${a}]; }`);return n.push(" }"),n.join(`
773
- `)},Tb=e=>{if(!e||e.length!==1)throw new Error("ImageScaler requires 1 input.");if(e[0].dims.length!==4)throw new Error("Invalid input shape.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")}}),Vf,zf,Uf,wb,vb,Ib,_b,Ob,Sb,Wf=O(()=>{ut(),j(),Vf=(e,n,a)=>{Sb(n);let i=e.run(vb(n[0]),n);return[e.run(Ob(e,n[0],a,i.dims),[n[0],i,n[1],n[2]])]},zf=e=>e.attributes.getFloat("epsilon",1e-5),Uf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},wb=(e,n)=>{let a=n.dims.slice(),i=a[1],p=a[2]*a[3],o=[a[0],i],s=`
772
+ }`;return{...n,output:{dims:p,type:i[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:a.bias.length,data:a.bias},{name:"scale",type:"float",data:a.scale}],shaderSource:s}},yb=(e,n,i)=>{let a={...bb,cacheHint:i.cacheKey};return{...a,get:()=>gb(e,a,n,i)}},xb=e=>{let n=[`float getBias(float bias[${e}], int channel) {`];for(let i=0;i<e;++i)i===0?n.push(` if (channel == ${i}) { return bias[${i}]; }`):i===e-1?n.push(` else { return bias[${i}]; }`):n.push(` else if (channel == ${i}) { return bias[${i}]; }`);return n.push(" }"),n.join(`
773
+ `)},Tb=e=>{if(!e||e.length!==1)throw new Error("ImageScaler requires 1 input.");if(e[0].dims.length!==4)throw new Error("Invalid input shape.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")}}),Vf,zf,Uf,wb,vb,Ib,_b,Ob,Sb,Wf=O(()=>{ut(),j(),Vf=(e,n,i)=>{Sb(n);let a=e.run(vb(n[0]),n);return[e.run(Ob(e,n[0],i,a.dims),[n[0],a,n[1],n[2]])]},zf=e=>e.attributes.getFloat("epsilon",1e-5),Uf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},wb=(e,n)=>{let i=n.dims.slice(),a=i[1],p=i[2]*i[3],o=[i[0],a],s=`
774
774
  vec4 process(int[2] indices) {
775
775
  vec4 v = vec4(0.0);
776
776
  int a[4];
777
777
  a[0] = indices[0];
778
778
  a[1] = indices[1];
779
779
  float temp = 0.0;
780
- for(int a2=0; a2<${a[2]}; a2++) {
780
+ for(int a2=0; a2<${i[2]}; a2++) {
781
781
  a[2] = a2;
782
- for(int a3=0; a3<${a[3]}; a3++) {
782
+ for(int a3=0; a3<${i[3]}; a3++) {
783
783
  a[3] = a3;
784
784
  float x = _X(a);
785
785
  temp += x;
@@ -787,9 +787,9 @@ float process(int indices[${b}]) {
787
787
  }
788
788
  float mean = temp / float(${p});
789
789
  temp = 0.0;
790
- for(int a2=0; a2<${a[2]}; a2++) {
790
+ for(int a2=0; a2<${i[2]}; a2++) {
791
791
  a[2] = a2;
792
- for(int a3=0; a3<${a[3]}; a3++) {
792
+ for(int a3=0; a3<${i[3]}; a3++) {
793
793
  a[3] = a3;
794
794
  float x = _X(a);
795
795
  temp += (x - mean) * (x - mean);
@@ -799,7 +799,7 @@ float process(int indices[${b}]) {
799
799
  v.g = temp / float(${p});
800
800
 
801
801
  return v;
802
- }`;return{...e,output:{dims:o,type:n.type,textureType:4},shaderSource:s}},vb=e=>({...Uf,get:()=>wb(Uf,e)}),Ib={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},_b=(e,n,a,i,p)=>{let o=G(e.session.backend.glContext.version),[s,c]=e.calculateTextureWidthAndHeight(p,4),[h,r]=[s/4,c],u=`
802
+ }`;return{...e,output:{dims:o,type:n.type,textureType:4},shaderSource:s}},vb=e=>({...Uf,get:()=>wb(Uf,e)}),Ib={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},_b=(e,n,i,a,p)=>{let o=G(e.session.backend.glContext.version),[s,c]=e.calculateTextureWidthAndHeight(p,4),[h,r]=[s/4,c],u=`
803
803
  vec4 get_MeanAndVariance(int[2] mv) {
804
804
  int offset = indicesToOffset_MeanAndVariance(mv);
805
805
  vec2 coords = offsetToCoords(offset, ${h}, ${r});
@@ -820,41 +820,41 @@ float process(int indices[${b}]) {
820
820
  float b = _B(sb);
821
821
 
822
822
  return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
823
- }`;return{...n,output:{dims:a.dims,type:a.type,textureType:0},variables:[{name:"epsilon",type:"float",data:i}],shaderSource:u}},Ob=(e,n,a,i)=>{let p={...Ib,cacheHint:`${a}`};return{...p,get:()=>_b(e,p,n,a,i)}},Sb=e=>{if(!e||e.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let n=e[0],a=e[1],i=e[2];if(n.dims.length<3||a.dims.length!==1||i.dims.length!==1)throw new Error("Invalid input shape.");if(a.dims[0]!==n.dims[1]||i.dims[0]!==n.dims[1])throw new Error("Input shapes are mismatched.");if(n.type!=="float32"&&n.type!=="float64"||a.type!=="float32"&&a.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("Invalid input type.");if(e[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function Ab(e,n){let a=e[0].dims[1],i=e[0].dims.length,p=-Math.floor((n.size-1)/2),o=Math.ceil((n.size-1)/2),s=`float(${n.alpha}) / float(${n.size})`,c=`float(${n.bias})`,h=`float(${n.beta})`,r=`
824
- float process(int indices[${i}]) {
823
+ }`;return{...n,output:{dims:i.dims,type:i.type,textureType:0},variables:[{name:"epsilon",type:"float",data:a}],shaderSource:u}},Ob=(e,n,i,a)=>{let p={...Ib,cacheHint:`${i}`};return{...p,get:()=>_b(e,p,n,i,a)}},Sb=e=>{if(!e||e.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");let n=e[0],i=e[1],a=e[2];if(n.dims.length<3||i.dims.length!==1||a.dims.length!==1)throw new Error("Invalid input shape.");if(i.dims[0]!==n.dims[1]||a.dims[0]!==n.dims[1])throw new Error("Input shapes are mismatched.");if(n.type!=="float32"&&n.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||a.type!=="float32"&&a.type!=="float64")throw new Error("Invalid input type.");if(e[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}});function Ab(e,n){let i=e[0].dims[1],a=e[0].dims.length,p=-Math.floor((n.size-1)/2),o=Math.ceil((n.size-1)/2),s=`float(${n.alpha}) / float(${n.size})`,c=`float(${n.bias})`,h=`float(${n.beta})`,r=`
824
+ float process(int indices[${a}]) {
825
825
  int c = indices[1];
826
826
  float x = _X(indices);
827
827
  float square_sum = 0.0;
828
828
 
829
829
  for (int i = ${p}; i <= ${o}; i++) {
830
830
  int idx = c + i;
831
- if (c >= 0 && c < ${a}) {
831
+ if (c >= 0 && c < ${i}) {
832
832
  indices[1] = idx;
833
833
  float j = _X(indices);
834
834
  square_sum += j * j;
835
835
  }
836
836
  }
837
837
  return x / pow(${c} + ${s} * square_sum, ${h});
838
- }`;return{...jf,cacheHint:n.cacheKey,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:r}}function Pb(e,n){return{...jf,cacheHint:n.cacheKey,get:()=>Ab(e,n)}}var Hf,qf,jf,Eb,Xf=O(()=>{It(),j(),Hf=(e,n,a)=>(Eb(n),[e.run(Pb(n,a),n)]),qf=e=>{let n=e.attributes.getFloat("alpha",1e-4),a=e.attributes.getFloat("beta",.75),i=e.attributes.getFloat("bias",1),p=e.attributes.getInt("size");return W({alpha:n,beta:a,bias:i,size:p})},jf={name:"LRN",inputNames:["X"],inputTypes:[0]},Eb=e=>{if(!e||e.length!==1)throw new Error("LRN requires 1 input.");if(e[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(e[0].type!=="float32")throw new Error("input should be float type")}}),Db,Pi,Kf,Jf,Yf,Lb,$b,kb,Bb,Fb,Cb,Nb,Rb,Zf=O(()=>{It(),Y(),ut(),j(),Db={name:"Pad",inputNames:["A"],inputTypes:[0]},Pi=(e,n,a)=>(kb(n),[e.run({...Db,cacheHint:a.cacheKey,get:()=>$b(e,n[0],a)},n)]),Kf=e=>{let n=e.attributes.getString("mode","constant"),a=e.attributes.getFloat("value",0),i=e.attributes.getInts("pads");return W({mode:n,value:a,pads:i})},Jf=(e,n,a)=>{Bb(n);let i=Lb(e,n,a);return Pi(e,[n[0]],i)},Yf=e=>e.attributes.getString("mode","constant"),Lb=(e,n,a)=>{if(!e.session.isInitializer(n[1].dataId)||n.length>=3&&!e.session.isInitializer(n[2].dataId))throw new Error("dynamic pad attributes are not allowed");let i=Array.from(n[1].integerData),p=n.length>=3?n[2].floatData[0]:0;return W({mode:a,pads:i,value:p})},$b=(e,n,a)=>{let i=B.padShape(n.dims.slice(),a.pads),p=i.length,o=`
839
- ${Fb(e,n,a)}
838
+ }`;return{...jf,cacheHint:n.cacheKey,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:r}}function Pb(e,n){return{...jf,cacheHint:n.cacheKey,get:()=>Ab(e,n)}}var Hf,qf,jf,Eb,Xf=O(()=>{It(),j(),Hf=(e,n,i)=>(Eb(n),[e.run(Pb(n,i),n)]),qf=e=>{let n=e.attributes.getFloat("alpha",1e-4),i=e.attributes.getFloat("beta",.75),a=e.attributes.getFloat("bias",1),p=e.attributes.getInt("size");return W({alpha:n,beta:i,bias:a,size:p})},jf={name:"LRN",inputNames:["X"],inputTypes:[0]},Eb=e=>{if(!e||e.length!==1)throw new Error("LRN requires 1 input.");if(e[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(e[0].type!=="float32")throw new Error("input should be float type")}}),Db,Pi,Kf,Jf,Yf,Lb,$b,kb,Bb,Fb,Cb,Nb,Rb,Zf=O(()=>{It(),Y(),ut(),j(),Db={name:"Pad",inputNames:["A"],inputTypes:[0]},Pi=(e,n,i)=>(kb(n),[e.run({...Db,cacheHint:i.cacheKey,get:()=>$b(e,n[0],i)},n)]),Kf=e=>{let n=e.attributes.getString("mode","constant"),i=e.attributes.getFloat("value",0),a=e.attributes.getInts("pads");return W({mode:n,value:i,pads:a})},Jf=(e,n,i)=>{Bb(n);let a=Lb(e,n,i);return Pi(e,[n[0]],a)},Yf=e=>e.attributes.getString("mode","constant"),Lb=(e,n,i)=>{if(!e.session.isInitializer(n[1].dataId)||n.length>=3&&!e.session.isInitializer(n[2].dataId))throw new Error("dynamic pad attributes are not allowed");let a=Array.from(n[1].integerData),p=n.length>=3?n[2].floatData[0]:0;return W({mode:i,pads:a,value:p})},$b=(e,n,i)=>{let a=B.padShape(n.dims.slice(),i.pads),p=a.length,o=`
839
+ ${Fb(e,n,i)}
840
840
  float process(int[${p}] indices) {
841
841
  return padA(indices);
842
- }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:i,type:n.type,textureType:0},shaderSource:o}},kb=e=>{if(!e||e.length!==1)throw new Error("Pad requires 1 input");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")},Bb=e=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(e[1].type!=="int32")throw new Error("Invalid input type.");if(e.length>=3&&e[2].type==="string")throw new Error("Invalid input type.")},Fb=(e,n,a)=>{let i=G(e.session.backend.glContext.version),[p,o]=e.calculateTextureWidthAndHeight(n.dims,0),s=B.computeStrides(n.dims);switch(a.mode){case"constant":return Cb(i,n.dims,s,p,o,a.pads,a.value);case"reflect":return Nb(i,n.dims,s,p,o,a.pads);case"edge":return Rb(i,n.dims,s,p,o,a.pads);default:throw new Error("Invalid mode")}},Cb=(e,n,a,i,p,o,s)=>{let c=n.length,h="";for(let r=c-1;r>=0;--r)h+=`
842
+ }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:a,type:n.type,textureType:0},shaderSource:o}},kb=e=>{if(!e||e.length!==1)throw new Error("Pad requires 1 input");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")},Bb=e=>{if(!e||e.length!==2&&e.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(e[1].type!=="int32")throw new Error("Invalid input type.");if(e.length>=3&&e[2].type==="string")throw new Error("Invalid input type.")},Fb=(e,n,i)=>{let a=G(e.session.backend.glContext.version),[p,o]=e.calculateTextureWidthAndHeight(n.dims,0),s=B.computeStrides(n.dims);switch(i.mode){case"constant":return Cb(a,n.dims,s,p,o,i.pads,i.value);case"reflect":return Nb(a,n.dims,s,p,o,i.pads);case"edge":return Rb(a,n.dims,s,p,o,i.pads);default:throw new Error("Invalid mode")}},Cb=(e,n,i,a,p,o,s)=>{let c=n.length,h="";for(let r=c-1;r>=0;--r)h+=`
843
843
  k = m[${r}] - ${o[r]};
844
844
  if (k < 0) return constant;
845
845
  if (k >= ${n[r]}) return constant;
846
- offset += k * ${a[r]};
846
+ offset += k * ${i[r]};
847
847
  `;return`
848
848
  float padA(int m[${c}]) {
849
849
  const float constant = float(${s});
850
850
  int offset = 0;
851
851
  int k = 0;
852
852
  ${h}
853
- vec2 coords = offsetToCoords(offset, ${i}, ${p});
853
+ vec2 coords = offsetToCoords(offset, ${a}, ${p});
854
854
  float value = getColorAsFloat(${e.texture2D}(A, coords));
855
855
  return value;
856
856
  }
857
- `},Nb=(e,n,a,i,p,o)=>{let s=n.length,c="";for(let h=s-1;h>=0;--h)c+=`
857
+ `},Nb=(e,n,i,a,p,o)=>{let s=n.length,c="";for(let h=s-1;h>=0;--h)c+=`
858
858
  k = m[${h}] - ${o[h]};
859
859
  if (k < 0) { k = -k; }
860
860
  {
@@ -862,48 +862,48 @@ float process(int indices[${b}]) {
862
862
  k = int( mod( float(k), float(_2n_1) ) ) ;
863
863
  if(k >= ${n[h]}) { k = _2n_1 - k; }
864
864
  }
865
- offset += k * ${a[h]};
865
+ offset += k * ${i[h]};
866
866
  `;return`
867
867
  float padA(int m[${s}]) {
868
868
  int offset = 0;
869
869
  int k = 0;
870
870
  ${c}
871
- vec2 coords = offsetToCoords(offset, ${i}, ${p});
871
+ vec2 coords = offsetToCoords(offset, ${a}, ${p});
872
872
  float value = getColorAsFloat(${e.texture2D}(A, coords));
873
873
  return value;
874
874
  }
875
- `},Rb=(e,n,a,i,p,o)=>{let s=n.length,c="";for(let h=s-1;h>=0;--h)c+=`
875
+ `},Rb=(e,n,i,a,p,o)=>{let s=n.length,c="";for(let h=s-1;h>=0;--h)c+=`
876
876
  k = m[${h}] - ${o[h]};
877
877
  if (k < 0) k = 0;
878
878
  if (k >= ${n[h]}) k = ${n[h]-1};
879
- offset += k * ${a[h]};
879
+ offset += k * ${i[h]};
880
880
  `;return`
881
881
  float padA(int m[${s}]) {
882
882
  int offset = 0;
883
883
  int k = 0;
884
884
  ${c}
885
- vec2 coords = offsetToCoords(offset, ${i}, ${p});
885
+ vec2 coords = offsetToCoords(offset, ${a}, ${p});
886
886
  float value = getColorAsFloat(${e.texture2D}(A, coords));
887
887
  return value;
888
888
  }
889
- `}}),tc,ec,rc,nc,oc,ic,ac,sc,uc,Gb,Qf,lc,Gn,fc,Rn,Mb,cc=O(()=>{It(),Y(),j(),tc=(e,n,a)=>{Gn(n);let i={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:a.cacheKey};return[e.run({...i,get:()=>rc(n,i,!1,a)},n)]},ec=e=>{let n=e.attributes.getString("auto_pad","NOTSET"),a=e.attributes.getInt("ceil_mode",0),i=e.attributes.getInt("count_include_pad",0)!==0,p=e.attributes.getInts("kernel_shape"),o=e.attributes.getInts("strides",[]),s=e.attributes.getInts("pads",[]);if(a!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return W({autoPad:n,ceilMode:a,countIncludePad:i,kernelShape:p,strides:o,pads:s})},rc=(e,n,a,i)=>{let[p,o]=uc(e,i,a),s=B.size(p.kernelShape),c="value += _X(x);",h="";p.countIncludePad?h+=`value /= float(${s});`:h+=`value /= float(${s} - pad);`;let r=`
889
+ `}}),tc,ec,rc,nc,oc,ic,ac,sc,uc,Gb,Qf,lc,Gn,fc,Rn,Mb,cc=O(()=>{It(),Y(),j(),tc=(e,n,i)=>{Gn(n);let a={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:i.cacheKey};return[e.run({...a,get:()=>rc(n,a,!1,i)},n)]},ec=e=>{let n=e.attributes.getString("auto_pad","NOTSET"),i=e.attributes.getInt("ceil_mode",0),a=e.attributes.getInt("count_include_pad",0)!==0,p=e.attributes.getInts("kernel_shape"),o=e.attributes.getInts("strides",[]),s=e.attributes.getInts("pads",[]);if(i!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return W({autoPad:n,ceilMode:i,countIncludePad:a,kernelShape:p,strides:o,pads:s})},rc=(e,n,i,a)=>{let[p,o]=uc(e,a,i),s=B.size(p.kernelShape),c="value += _X(x);",h="";p.countIncludePad?h+=`value /= float(${s});`:h+=`value /= float(${s} - pad);`;let r=`
890
890
  ${fc(e[0].dims,p,c,h,"0.0")}
891
- `;return{...n,output:{dims:o,type:e[0].type,textureType:0},shaderSource:r}},nc=(e,n,a)=>{Gn(n);let i={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${a.countIncludePad}`};return[e.run({...i,get:()=>rc(n,i,!0,a)},n)]},oc=e=>{let n=e.attributes.getInt("count_include_pad",0)!==0;return W({autoPad:"",ceilMode:0,countIncludePad:n,kernelShape:[],strides:[],pads:[]})},ic=(e,n,a)=>{Gn(n);let i={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:a.cacheKey};return[e.run({...i,get:()=>sc(n,i,!1,a)},n)]},ac=e=>{let n=e.attributes.getString("auto_pad","NOTSET"),a=e.attributes.getInt("ceil_mode",0),i=e.attributes.getInts("kernel_shape"),p=e.attributes.getInts("strides",[]),o=e.attributes.getInts("pads",[]),s=e.attributes.getInt("storage_order",0),c=e.attributes.getInts("dilations",[]);if(s!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(a!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return W({autoPad:n,ceilMode:a,countIncludePad:!1,kernelShape:i,strides:p,pads:o,storageOrder:s,dilations:c})},sc=(e,n,a,i)=>{let[p,o]=uc(e,i,a),s=`
891
+ `;return{...n,output:{dims:o,type:e[0].type,textureType:0},shaderSource:r}},nc=(e,n,i)=>{Gn(n);let a={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${i.countIncludePad}`};return[e.run({...a,get:()=>rc(n,a,!0,i)},n)]},oc=e=>{let n=e.attributes.getInt("count_include_pad",0)!==0;return W({autoPad:"",ceilMode:0,countIncludePad:n,kernelShape:[],strides:[],pads:[]})},ic=(e,n,i)=>{Gn(n);let a={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:i.cacheKey};return[e.run({...a,get:()=>sc(n,a,!1,i)},n)]},ac=e=>{let n=e.attributes.getString("auto_pad","NOTSET"),i=e.attributes.getInt("ceil_mode",0),a=e.attributes.getInts("kernel_shape"),p=e.attributes.getInts("strides",[]),o=e.attributes.getInts("pads",[]),s=e.attributes.getInt("storage_order",0),c=e.attributes.getInts("dilations",[]);if(s!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(i!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return W({autoPad:n,ceilMode:i,countIncludePad:!1,kernelShape:a,strides:p,pads:o,storageOrder:s,dilations:c})},sc=(e,n,i,a)=>{let[p,o]=uc(e,a,i),s=`
892
892
  value = max(_X(x), value);
893
893
  `,c="",h=`
894
894
  ${fc(e[0].dims,p,s,c,"-1e5")}
895
- `;return{...n,output:{dims:o,type:e[0].type,textureType:0},shaderSource:h}},uc=(e,n,a)=>{let i=e[0].dims.slice(),p=Object.hasOwnProperty.call(n,"dilations"),o=n.kernelShape.slice(),s=n.strides.slice(),c=p?n.dilations.slice():[],h=n.pads.slice();Ue.adjustPoolAttributes(a,i,o,s,c,h);let r=Ue.computePoolOutputShape(a,i,s,c,o,h,n.autoPad),u=Object.assign({},n);return p?Object.assign(u,{kernelShape:o,strides:s,pads:h,dilations:c,cacheKey:n.cacheKey}):Object.assign(u,{kernelShape:o,strides:s,pads:h,cacheKey:n.cacheKey}),[u,r]},Gb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Qf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},lc=(e,n)=>(Gn(n),[e.run({...Qf,get:()=>sc(n,Qf,!0,Gb)},n)]),Gn=e=>{if(!e||e.length!==1)throw new Error("Pool ops requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")},fc=(e,n,a,i,p)=>{let o=e.length;if(n.kernelShape.length<=2){let s=n.kernelShape[n.kernelShape.length-1],c=n.strides[n.strides.length-1],h=n.pads[n.pads.length/2-1],r=n.pads[n.pads.length-1],u=e[o-1],l="",f="",g="";if(h+r!==0?l=`
895
+ `;return{...n,output:{dims:o,type:e[0].type,textureType:0},shaderSource:h}},uc=(e,n,i)=>{let a=e[0].dims.slice(),p=Object.hasOwnProperty.call(n,"dilations"),o=n.kernelShape.slice(),s=n.strides.slice(),c=p?n.dilations.slice():[],h=n.pads.slice();Ue.adjustPoolAttributes(i,a,o,s,c,h);let r=Ue.computePoolOutputShape(i,a,s,c,o,h,n.autoPad),u=Object.assign({},n);return p?Object.assign(u,{kernelShape:o,strides:s,pads:h,dilations:c,cacheKey:n.cacheKey}):Object.assign(u,{kernelShape:o,strides:s,pads:h,cacheKey:n.cacheKey}),[u,r]},Gb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Qf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},lc=(e,n)=>(Gn(n),[e.run({...Qf,get:()=>sc(n,Qf,!0,Gb)},n)]),Gn=e=>{if(!e||e.length!==1)throw new Error("Pool ops requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.")},fc=(e,n,i,a,p)=>{let o=e.length;if(n.kernelShape.length<=2){let s=n.kernelShape[n.kernelShape.length-1],c=n.strides[n.strides.length-1],h=n.pads[n.pads.length/2-1],r=n.pads[n.pads.length-1],u=e[o-1],l="",f="",g="";if(h+r!==0?l=`
896
896
  for (int i = 0; i < ${s}; i++) {
897
897
  x[${o} - 1] = indices[${o} - 1] * ${c} - ${h} + i;
898
898
  if (x[${o} - 1] < 0 || x[${o} - 1] >= ${u}) {
899
899
  pad++;
900
900
  continue;
901
901
  }
902
- ${a}
902
+ ${i}
903
903
  }`:l=`
904
904
  for (int i = 0; i < ${s}; i++) {
905
905
  x[${o} - 1] = indices[${o} - 1] * ${c} - ${h} + i;
906
- ${a}
906
+ ${i}
907
907
  }`,n.kernelShape.length===2){let b=n.kernelShape[n.kernelShape.length-2],v=n.strides[n.strides.length-2],S=n.pads[n.pads.length/2-2],P=n.pads[n.pads.length-2],_=e[o-2];S+P!==0?f=`
908
908
  for (int j = 0; j < ${b}; j++) {
909
909
  x[${o} - 2] = indices[${o} - 2] * ${v} - ${S} + j;
@@ -926,7 +926,7 @@ float process(int indices[${b}]) {
926
926
  ${f}
927
927
  ${l}
928
928
  ${g}
929
- ${i}
929
+ ${a}
930
930
  return value;
931
931
  }
932
932
  `}else{let s=B.size(n.kernelShape),c=B.computeStrides(n.kernelShape),h=c.length,r=n.pads.length,u=Mb(h),l=Rn(e,"inputDims"),f=Rn(n.pads,"pads"),g=Rn(c,"kernelStrides"),b=Rn(n.strides,"strides"),v=n.pads.reduce((P,_)=>P+_),S="";return v?S=`
@@ -937,10 +937,10 @@ float process(int indices[${b}]) {
937
937
  }
938
938
  }
939
939
  if (!isPad) {
940
- ${a}
940
+ ${i}
941
941
  }`:S=`
942
942
  }
943
- ${a}
943
+ ${i}
944
944
  `,`
945
945
  ${u}
946
946
  float process(int indices[${o}]) {
@@ -967,13 +967,13 @@ float process(int indices[${b}]) {
967
967
  + offset[j - ${o} + ${h}] - pads[j - 2];
968
968
  ${S}
969
969
  }
970
- ${i}
970
+ ${a}
971
971
 
972
972
  return value;
973
973
  }
974
- `}},Rn=(e,n)=>{let a="";for(let i=0;i<e.length;i++)a+=`
975
- ${n}[${i}] = ${e[i]};
976
- `;return a},Mb=e=>`
974
+ `}},Rn=(e,n)=>{let i="";for(let a=0;a<e.length;a++)i+=`
975
+ ${n}[${a}] = ${e[a]};
976
+ `;return i},Mb=e=>`
977
977
  void offsetToIndices(int offset, int[${e}] strides, out int[${e}] indices) {
978
978
  if (${e} == 0) {
979
979
  return;
@@ -983,7 +983,7 @@ float process(int indices[${b}]) {
983
983
  offset -= indices[i] * strides[i];
984
984
  }
985
985
  indices[${e} - 1] = offset;
986
- }`}),Xe,Ee,Ub,Vb,pc,dc,hc,mc,bc,gc,yc,xc=O(()=>{It(),Rr(),Y(),j(),Xe=(e,n,a,i,p)=>{Vb(n);let o={name:i,inputNames:["A"],inputTypes:[0]};return[e.run({...o,cacheHint:a.cacheKey,get:()=>Ub(e,n,a,i,p,o)},n)]},Ee=e=>{let n=e.attributes.getInts("axes",[]),a=e.attributes.getInt("keepdims",1)===1;return W({axes:n,keepDims:a})},Ub=(e,n,a,i,p,o)=>{let s=[],c=n[0].dims.length||1,h=[],r=B.normalizeAxes(a.axes,n[0].dims.length),u=p(n,r),l=u[1];for(let g=0;g<n[0].dims.length;g++)r.indexOf(g)>=0||r.length===0?(a.keepDims&&s.push(1),l=`
986
+ }`}),Xe,Ee,Ub,Vb,pc,dc,hc,mc,bc,gc,yc,xc=O(()=>{It(),Rr(),Y(),j(),Xe=(e,n,i,a,p)=>{Vb(n);let o={name:a,inputNames:["A"],inputTypes:[0]};return[e.run({...o,cacheHint:i.cacheKey,get:()=>Ub(e,n,i,a,p,o)},n)]},Ee=e=>{let n=e.attributes.getInts("axes",[]),i=e.attributes.getInt("keepdims",1)===1;return W({axes:n,keepDims:i})},Ub=(e,n,i,a,p,o)=>{let s=[],c=n[0].dims.length||1,h=[],r=B.normalizeAxes(i.axes,n[0].dims.length),u=p(n,r),l=u[1];for(let g=0;g<n[0].dims.length;g++)r.indexOf(g)>=0||r.length===0?(i.keepDims&&s.push(1),l=`
987
987
  for(int j${g} = 0; j${g} < ${n[0].dims[g]}; j${g}++) {
988
988
  inputIdx[${g}] = j${g};
989
989
  ${l}
@@ -997,11 +997,11 @@ float process(int indices[${b}]) {
997
997
  ${l}
998
998
  ${u[2]} // final computation for reduce mean
999
999
  return value;
1000
- }`;return{...o,output:{dims:s,type:n[0].type,textureType:0},shaderSource:f}},Vb=e=>{if(!e||e.length!==1)throw new Error("Reduce op requires 1 input.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},pc=(e,n,a)=>Xe(e,n,a,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),dc=(e,n,a)=>Xe(e,n,a,"ReduceMean",(i,p)=>{let o=1;for(let s=0;s<i[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&(o*=i[0].dims[s]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${o}.;`]}),hc=(e,n,a)=>Xe(e,n,a,"ReduceMax",(i,p)=>{let o=[];for(let s=0;s<i[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&o.push(`inputIdx[${s}] = 0;`);return[`${o.join(`
1000
+ }`;return{...o,output:{dims:s,type:n[0].type,textureType:0},shaderSource:f}},Vb=e=>{if(!e||e.length!==1)throw new Error("Reduce op requires 1 input.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},pc=(e,n,i)=>Xe(e,n,i,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),dc=(e,n,i)=>Xe(e,n,i,"ReduceMean",(a,p)=>{let o=1;for(let s=0;s<a[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&(o*=a[0].dims[s]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${o}.;`]}),hc=(e,n,i)=>Xe(e,n,i,"ReduceMax",(a,p)=>{let o=[];for(let s=0;s<a[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&o.push(`inputIdx[${s}] = 0;`);return[`${o.join(`
1001
1001
  `)}
1002
- value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),mc=(e,n,a)=>Xe(e,n,a,"ReduceMin",(i,p)=>{let o=[];for(let s=0;s<i[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&o.push(`inputIdx[${s}] = 0;`);return[`${o.join(`
1002
+ value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),mc=(e,n,i)=>Xe(e,n,i,"ReduceMin",(a,p)=>{let o=[];for(let s=0;s<a[0].dims.length;s++)(p.indexOf(s)>=0||p.length===0)&&o.push(`inputIdx[${s}] = 0;`);return[`${o.join(`
1003
1003
  `)}
1004
- value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(e,n,a,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),gc=(e,n,a)=>Xe(e,n,a,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),yc=(e,n,a)=>Xe(e,n,a,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),Tc,wc=O(()=>{Y(),Tc=(e,n)=>{let a=B.calculateReshapedDims(n[0].dims,n[1].integerData);return e.session.pack?[e.reshapePacked(n[0],a)]:[e.reshapeUnpacked(n[0],a)]}}),vc,Ei,Ic,_c,Gr,zb,Di,Mn,Li=O(()=>{It(),ut(),j(),vc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Ei=(e,n,a)=>(Di(n,a),[e.run({...vc,cacheHint:a.cacheKey,get:()=>zb(e,n,a)},n)]),Ic=e=>Gr(e,7),_c=e=>Gr(e,9),Gr=(e,n)=>{let a=n>=10,i=e.attributes.getString("mode","nearest");if(i!=="nearest"&&i!=="linear"&&(n<11||i!=="cubic"))throw new Error(`unrecognized mode: ${i}`);let p=[];n<9&&(p=e.attributes.getFloats("scales"),Mn(p,i,a));let o=e.attributes.getFloat("extrapolation_value",0),s=n>10?e.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 c=s==="tf_crop_and_resize",h=c,r=i==="nearest"&&n>=11?e.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(r)===-1)throw new Error(`nearest_mode '${r}' is not supported`);let u=e.attributes.getFloat("cubic_coeff_a",-.75),l=e.attributes.getInt("exclude_outside",0)!==0;if(l&&i!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let f=n<11?!0:i==="nearest"&&s==="asymmetric"&&r==="floor",g=0,b=0,v=0;return n>10?e.inputs.length>2?(g=1,b=2,v=3):(b=1,v=2):n===9&&(b=1),W({opset:n,isResize:a,mode:i,scales:p,extrapolationValue:o,coordinateTransformMode:s,useExtrapolation:h,needRoiInput:c,nearestMode:r,cubicCoefficientA:u,excludeOutside:l,useNearest2xOptimization:f,roiInputIdx:g,scalesInputIdx:b,sizesInputIdx:v})},zb=(e,n,a)=>{let i=G(e.session.backend.glContext.version),[p,o]=e.calculateTextureWidthAndHeight(n[0].dims,0),s=n[0].dims.map((v,S)=>Math.floor(v*a.scales[S])),[c,h]=e.calculateTextureWidthAndHeight(s,0),r=s.length,u=new Array(r),l=new Array(r),f=`
1004
+ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,i)=>Xe(e,n,i,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),gc=(e,n,i)=>Xe(e,n,i,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),yc=(e,n,i)=>Xe(e,n,i,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),Tc,wc=O(()=>{Y(),Tc=(e,n)=>{let i=B.calculateReshapedDims(n[0].dims,n[1].integerData);return e.session.pack?[e.reshapePacked(n[0],i)]:[e.reshapeUnpacked(n[0],i)]}}),vc,Ei,Ic,_c,Gr,zb,Di,Mn,Li=O(()=>{It(),ut(),j(),vc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Ei=(e,n,i)=>(Di(n,i),[e.run({...vc,cacheHint:i.cacheKey,get:()=>zb(e,n,i)},n)]),Ic=e=>Gr(e,7),_c=e=>Gr(e,9),Gr=(e,n)=>{let i=n>=10,a=e.attributes.getString("mode","nearest");if(a!=="nearest"&&a!=="linear"&&(n<11||a!=="cubic"))throw new Error(`unrecognized mode: ${a}`);let p=[];n<9&&(p=e.attributes.getFloats("scales"),Mn(p,a,i));let o=e.attributes.getFloat("extrapolation_value",0),s=n>10?e.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 c=s==="tf_crop_and_resize",h=c,r=a==="nearest"&&n>=11?e.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(r)===-1)throw new Error(`nearest_mode '${r}' is not supported`);let u=e.attributes.getFloat("cubic_coeff_a",-.75),l=e.attributes.getInt("exclude_outside",0)!==0;if(l&&a!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let f=n<11?!0:a==="nearest"&&s==="asymmetric"&&r==="floor",g=0,b=0,v=0;return n>10?e.inputs.length>2?(g=1,b=2,v=3):(b=1,v=2):n===9&&(b=1),W({opset:n,isResize:i,mode:a,scales:p,extrapolationValue:o,coordinateTransformMode:s,useExtrapolation:h,needRoiInput:c,nearestMode:r,cubicCoefficientA:u,excludeOutside:l,useNearest2xOptimization:f,roiInputIdx:g,scalesInputIdx:b,sizesInputIdx:v})},zb=(e,n,i)=>{let a=G(e.session.backend.glContext.version),[p,o]=e.calculateTextureWidthAndHeight(n[0].dims,0),s=n[0].dims.map((v,S)=>Math.floor(v*i.scales[S])),[c,h]=e.calculateTextureWidthAndHeight(s,0),r=s.length,u=new Array(r),l=new Array(r),f=`
1005
1005
  int output_pitches[${r}];
1006
1006
  int input_pitches[${r}];
1007
1007
  `;for(let v=r-1;v>=0;v--)u[v]=v===r-1?1:u[v+1]*s[v+1],l[v]=v===r-1?1:l[v+1]*n[0].dims[v+1],f+=`
@@ -1010,10 +1010,10 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1010
1010
  `;let g=`
1011
1011
  float getInputFloat(int index) {
1012
1012
  vec2 coords = offsetToCoords(index, ${p}, ${o});
1013
- float value = getColorAsFloat(${i.texture2D}(X, coords));
1013
+ float value = getColorAsFloat(${a.texture2D}(X, coords));
1014
1014
  return value;
1015
1015
  }
1016
- `,b=a.mode==="nearest"?`
1016
+ `,b=i.mode==="nearest"?`
1017
1017
  ${g}
1018
1018
  float process(int indices[${r}]) {
1019
1019
  int input_index = 0;
@@ -1137,10 +1137,10 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1137
1137
  float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
1138
1138
  float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
1139
1139
  return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
1140
- }`;return{...vc,output:{dims:s,type:n[0].type,textureType:0},shaderSource:b,variables:[{name:"scales",type:"int",arrayLength:a.scales.length,data:a.scales.map(v=>Math.ceil(v))}]}},Di=(e,n)=>{if(!e||n.opset<9&&e.length!==1||n.opset>=9&&n.opset<11&&e.length!==2||n.opset>=11&&e.length<2)throw new Error("invalid inputs.");if(n.scales.length>0&&e[0].dims.length!==n.scales.length)throw new Error("Invalid input shape.");if(e[0].type==="string")throw new Error("Invalid input tensor types.")},Mn=(e,n,a)=>{if(a){for(let i of e)if(i<=0)throw new Error("Scale value should be greater than 0.")}else for(let i of e)if(i<1)throw new Error("Scale value should be greater than or equal to 1.");if((n==="linear"||n==="cubic")&&e.length!==2&&(e.length!==4||e[0]!==1||e[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 ${a?"Resize":"Upsample"} opeartor.`)}}),$i,ki,Oc,Sc,Wb,Hb,qb,jb,Ac=O(()=>{ut(),j(),pe(),He(),Li(),$i={name:"Resize",inputNames:["A"],inputTypes:[2]},ki=(e,n,a)=>(Di(n,a),[e.run({...$i,cacheHint:a.cacheKey,get:()=>Wb(e,n,a)},n)]),Oc=e=>Gr(e,10),Sc=e=>Gr(e,11),Wb=(e,n,a)=>{let i=G(e.session.backend.glContext.version),[p,o]=Hb(n,a);if(p.every(_=>_===1)&&a.coordinateTransformMode!=="tf_crop_and_resize")return{...$i,output:{dims:o,type:n[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
1141
- vec4 v = ${i.texture2D}(X, TexCoords);
1142
- ${i.output} = v;
1143
- }`};let s=o.length;if(s<2)throw new Error(`output dimension should be at least 2, but got ${s}`);let c=o[s-2],h=o[s-1],r=n[0].dims;if(s!==r.length)throw new Error(`output dimension should match input ${r.length}, but got ${s}`);let u=r[s-2],l=r[s-1],f=p[s-2],g=p[s-1],b="";if(a.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${a.mode}'`);switch(a.coordinateTransformMode){case"asymmetric":b=`
1140
+ }`;return{...vc,output:{dims:s,type:n[0].type,textureType:0},shaderSource:b,variables:[{name:"scales",type:"int",arrayLength:i.scales.length,data:i.scales.map(v=>Math.ceil(v))}]}},Di=(e,n)=>{if(!e||n.opset<9&&e.length!==1||n.opset>=9&&n.opset<11&&e.length!==2||n.opset>=11&&e.length<2)throw new Error("invalid inputs.");if(n.scales.length>0&&e[0].dims.length!==n.scales.length)throw new Error("Invalid input shape.");if(e[0].type==="string")throw new Error("Invalid input tensor types.")},Mn=(e,n,i)=>{if(i){for(let a of e)if(a<=0)throw new Error("Scale value should be greater than 0.")}else for(let a of e)if(a<1)throw new Error("Scale value should be greater than or equal to 1.");if((n==="linear"||n==="cubic")&&e.length!==2&&(e.length!==4||e[0]!==1||e[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 ${i?"Resize":"Upsample"} opeartor.`)}}),$i,ki,Oc,Sc,Wb,Hb,qb,jb,Ac=O(()=>{ut(),j(),pe(),He(),Li(),$i={name:"Resize",inputNames:["A"],inputTypes:[2]},ki=(e,n,i)=>(Di(n,i),[e.run({...$i,cacheHint:i.cacheKey,get:()=>Wb(e,n,i)},n)]),Oc=e=>Gr(e,10),Sc=e=>Gr(e,11),Wb=(e,n,i)=>{let a=G(e.session.backend.glContext.version),[p,o]=Hb(n,i);if(p.every(_=>_===1)&&i.coordinateTransformMode!=="tf_crop_and_resize")return{...$i,output:{dims:o,type:n[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
1141
+ vec4 v = ${a.texture2D}(X, TexCoords);
1142
+ ${a.output} = v;
1143
+ }`};let s=o.length;if(s<2)throw new Error(`output dimension should be at least 2, but got ${s}`);let c=o[s-2],h=o[s-1],r=n[0].dims;if(s!==r.length)throw new Error(`output dimension should match input ${r.length}, but got ${s}`);let u=r[s-2],l=r[s-1],f=p[s-2],g=p[s-1],b="";if(i.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${i.mode}'`);switch(i.coordinateTransformMode){case"asymmetric":b=`
1144
1144
  vec4 getSourceFracIndex(ivec4 coords) {
1145
1145
  return vec4(coords) / scaleWHWH;
1146
1146
  }
@@ -1167,7 +1167,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1167
1167
  vec4 new_scale = original / resized;
1168
1168
  return vec4(coords) * new_scale;
1169
1169
  }
1170
- `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${a.coordinateTransformMode}'`)}let v=Bt(s),S=de(),P=`
1170
+ `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${i.coordinateTransformMode}'`)}let v=Bt(s),S=de(),P=`
1171
1171
  const vec2 inputWH = vec2(${u}.0, ${l}.0);
1172
1172
  const vec4 scaleWHWH = vec4(float(${f}), float(${g}), float(${f}), float(${g}));
1173
1173
  ${S}
@@ -1232,20 +1232,20 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1232
1232
  vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);
1233
1233
  vec4 newValue = mix(top, bottom, clampFrac.xxzz);
1234
1234
 
1235
- ${i.output} = vec4(newValue);
1235
+ ${a.output} = vec4(newValue);
1236
1236
  }
1237
- `;return{...$i,output:{dims:o,type:n[0].type,textureType:2},hasMain:!0,shaderSource:P}},Hb=(e,n)=>{let a=e[0].dims,i=n.scales,p;if(i.length===0){let s=e[n.scalesInputIdx];if(s&&s.size!==0){if(e[n.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");i=qb(s,n.mode,n.isResize)}else{let c=e[n.sizesInputIdx];if(!c||c.size===0)throw new Error("Either scales or sizes MUST be provided as input.");p=Array.from(c.integerData),i=jb(p,a,n.mode,n.isResize)}}else if(e[n.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let o=p||a.map((s,c)=>Math.floor(s*i[c]));return[i,o]},qb=(e,n,a)=>{let i=Array.from(e.floatData);return Mn(i,n,a),i},jb=(e,n,a,i)=>{let p=n.length,o=new Array(p);for(let s=0,c=p;s<c;s++)if(n[s]===0){if(e[s]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");o[s]=1}else o[s]=e[s]/n[s];return Mn(o,a,i),o}}),Pc,Xb,Ec=O(()=>{We(),Pc=(e,n)=>(Xb(n),[new bt([n[0].dims.length],"int32",void 0,void 0,new Int32Array(n[0].dims))]),Xb=e=>{if(!e||e.length!==1)throw new Error("Shape requires 1 input.")}}),Bi,Dc,Lc,$c,Kb,kc,Jb,Yb,Bc=O(()=>{It(),Rr(),Y(),j(),Bi={name:"Slice",inputNames:["A"],inputTypes:[0]},Dc=(e,n,a)=>(Kb(n),[e.run({...Bi,cacheHint:a.cacheKey,get:()=>$c(e,n[0],a)},n)]),Lc=e=>{let n=e.attributes.getInts("starts"),a=e.attributes.getInts("ends"),i=e.attributes.getInts("axes",[]);return W({starts:n,ends:a,axes:i})},$c=(e,n,a)=>{let i=a.axes.length===0?n.dims.slice(0).map((u,l)=>l):a.axes,p=B.normalizeAxes(i,n.dims.length),o=a.starts.map((u,l)=>u>n.dims[p[l]]-1?n.dims[p[l]]:B.normalizeAxis(u,n.dims[p[l]])),s=a.ends.map((u,l)=>u>n.dims[p[l]]-1?n.dims[p[l]]:B.normalizeAxis(u,n.dims[p[l]])),c=n.dims.slice(),h=[];for(let u=0;u<p.length;u++)c[p[u]]=s[u]-o[u],o[u]>0&&h.push(`outputIdx[${p[u]}] += ${o[u]};`);let r=`
1237
+ `;return{...$i,output:{dims:o,type:n[0].type,textureType:2},hasMain:!0,shaderSource:P}},Hb=(e,n)=>{let i=e[0].dims,a=n.scales,p;if(a.length===0){let s=e[n.scalesInputIdx];if(s&&s.size!==0){if(e[n.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");a=qb(s,n.mode,n.isResize)}else{let c=e[n.sizesInputIdx];if(!c||c.size===0)throw new Error("Either scales or sizes MUST be provided as input.");p=Array.from(c.integerData),a=jb(p,i,n.mode,n.isResize)}}else if(e[n.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let o=p||i.map((s,c)=>Math.floor(s*a[c]));return[a,o]},qb=(e,n,i)=>{let a=Array.from(e.floatData);return Mn(a,n,i),a},jb=(e,n,i,a)=>{let p=n.length,o=new Array(p);for(let s=0,c=p;s<c;s++)if(n[s]===0){if(e[s]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");o[s]=1}else o[s]=e[s]/n[s];return Mn(o,i,a),o}}),Pc,Xb,Ec=O(()=>{We(),Pc=(e,n)=>(Xb(n),[new bt([n[0].dims.length],"int32",void 0,void 0,new Int32Array(n[0].dims))]),Xb=e=>{if(!e||e.length!==1)throw new Error("Shape requires 1 input.")}}),Bi,Dc,Lc,$c,Kb,kc,Jb,Yb,Bc=O(()=>{It(),Rr(),Y(),j(),Bi={name:"Slice",inputNames:["A"],inputTypes:[0]},Dc=(e,n,i)=>(Kb(n),[e.run({...Bi,cacheHint:i.cacheKey,get:()=>$c(e,n[0],i)},n)]),Lc=e=>{let n=e.attributes.getInts("starts"),i=e.attributes.getInts("ends"),a=e.attributes.getInts("axes",[]);return W({starts:n,ends:i,axes:a})},$c=(e,n,i)=>{let a=i.axes.length===0?n.dims.slice(0).map((u,l)=>l):i.axes,p=B.normalizeAxes(a,n.dims.length),o=i.starts.map((u,l)=>u>n.dims[p[l]]-1?n.dims[p[l]]:B.normalizeAxis(u,n.dims[p[l]])),s=i.ends.map((u,l)=>u>n.dims[p[l]]-1?n.dims[p[l]]:B.normalizeAxis(u,n.dims[p[l]])),c=n.dims.slice(),h=[];for(let u=0;u<p.length;u++)c[p[u]]=s[u]-o[u],o[u]>0&&h.push(`outputIdx[${p[u]}] += ${o[u]};`);let r=`
1238
1238
  float process(int outputIdx[${c.length}]) {
1239
1239
  ${h.join(`
1240
1240
  `)}
1241
1241
  return _A(outputIdx);
1242
- }`;return{...Bi,output:{dims:c,type:n.type,textureType:0},shaderSource:r}},Kb=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},kc=(e,n)=>{Yb(n);let a=Jb(e,n);return[e.run({...Bi,cacheHint:a.cacheKey,get:()=>$c(e,n[0],a)},[n[0]])]},Jb=(e,n)=>{if(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)||n.length>=4&&!e.session.isInitializer(n[3].dataId)||n.length>=5&&!e.session.isInitializer(n[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(n.length>=5&&n[4].integerData.some(s=>s!==1))throw new Error("currently non-1 steps is not supported for Slice");let a=Array.from(n[1].integerData),i=Array.from(n[2].integerData),p=n.length>=4?Array.from(n[3].integerData):[],o=`${p};${a};${i}`;return{starts:a,ends:i,axes:p,cacheKey:o}},Yb=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}}),Fc,Cc,Nc,Rc,Gc,Mc,Uc,Vc,Zb,Qb,tg,zc,Wc=O(()=>{It(),Y(),ut(),j(),Nn(),Fc={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Cc={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Nc={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Rc=(e,n,a)=>{zc(n);let i=n[0].dims.slice(),p=B.normalizeAxis(a.axis,i.length),o=B.sizeToDimension(i,p),s=B.sizeFromDimension(i,p);return Vc(e,n,a,o,s)},Gc=e=>W({axis:e.attributes.getInt("axis",1)}),Mc=e=>W({axis:e.attributes.getInt("axis",-1)}),Uc=(e,n,a)=>{zc(n);let i=n[0].dims.slice(),p=B.normalizeAxis(a.axis,i.length),o=i.length,s=p!==o-1,c=[],h=[],r=[],u;s&&(h=Array.from({length:o}).map((b,v)=>v),h[p]=o-1,h[o-1]=p,h.map(b=>c.push(i[b])),u=W({perm:h}),r=je(e,n,u));let l=s?B.sizeToDimension(c,o-1):B.sizeToDimension(i,o-1),f=s?B.sizeFromDimension(c,o-1):B.sizeFromDimension(i,o-1),g=Vc(e,s?r:n,a,l,f);return s?je(e,g,u):g},Vc=(e,n,a,i,p)=>{let o=Zb(e,n[0],i,p,[i]),s=e.run({...Fc,cacheHint:a.cacheKey,get:()=>o},n),c=Qb(e,n[0],i,p,o.output.dims,[i]),h=e.run({...Cc,cacheHint:a.cacheKey,get:()=>c},[n[0],s]),r=tg(e,n[0],i,p,o.output.dims,c.output.dims);return[e.run({...Nc,cacheHint:a.cacheKey,get:()=>r},[n[0],s,h])]},Zb=(e,n,a,i,p)=>{let[o,s]=e.calculateTextureWidthAndHeight(n.dims,0),c=p.length;if(a<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(p.length!==1)throw new Error("Dimensionality of the output should be 1");if(p[0]!==a)throw new Error("Shape of the output should be equal to logical row count");let h=G(e.session.backend.glContext.version),r=`
1242
+ }`;return{...Bi,output:{dims:c,type:n.type,textureType:0},shaderSource:r}},Kb=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")},kc=(e,n)=>{Yb(n);let i=Jb(e,n);return[e.run({...Bi,cacheHint:i.cacheKey,get:()=>$c(e,n[0],i)},[n[0]])]},Jb=(e,n)=>{if(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)||n.length>=4&&!e.session.isInitializer(n[3].dataId)||n.length>=5&&!e.session.isInitializer(n[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(n.length>=5&&n[4].integerData.some(s=>s!==1))throw new Error("currently non-1 steps is not supported for Slice");let i=Array.from(n[1].integerData),a=Array.from(n[2].integerData),p=n.length>=4?Array.from(n[3].integerData):[],o=`${p};${i};${a}`;return{starts:i,ends:a,axes:p,cacheKey:o}},Yb=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}}),Fc,Cc,Nc,Rc,Gc,Mc,Uc,Vc,Zb,Qb,tg,zc,Wc=O(()=>{It(),Y(),ut(),j(),Nn(),Fc={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Cc={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Nc={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Rc=(e,n,i)=>{zc(n);let a=n[0].dims.slice(),p=B.normalizeAxis(i.axis,a.length),o=B.sizeToDimension(a,p),s=B.sizeFromDimension(a,p);return Vc(e,n,i,o,s)},Gc=e=>W({axis:e.attributes.getInt("axis",1)}),Mc=e=>W({axis:e.attributes.getInt("axis",-1)}),Uc=(e,n,i)=>{zc(n);let a=n[0].dims.slice(),p=B.normalizeAxis(i.axis,a.length),o=a.length,s=p!==o-1,c=[],h=[],r=[],u;s&&(h=Array.from({length:o}).map((b,v)=>v),h[p]=o-1,h[o-1]=p,h.map(b=>c.push(a[b])),u=W({perm:h}),r=je(e,n,u));let l=s?B.sizeToDimension(c,o-1):B.sizeToDimension(a,o-1),f=s?B.sizeFromDimension(c,o-1):B.sizeFromDimension(a,o-1),g=Vc(e,s?r:n,i,l,f);return s?je(e,g,u):g},Vc=(e,n,i,a,p)=>{let o=Zb(e,n[0],a,p,[a]),s=e.run({...Fc,cacheHint:i.cacheKey,get:()=>o},n),c=Qb(e,n[0],a,p,o.output.dims,[a]),h=e.run({...Cc,cacheHint:i.cacheKey,get:()=>c},[n[0],s]),r=tg(e,n[0],a,p,o.output.dims,c.output.dims);return[e.run({...Nc,cacheHint:i.cacheKey,get:()=>r},[n[0],s,h])]},Zb=(e,n,i,a,p)=>{let[o,s]=e.calculateTextureWidthAndHeight(n.dims,0),c=p.length;if(i<1||a<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(p.length!==1)throw new Error("Dimensionality of the output should be 1");if(p[0]!==i)throw new Error("Shape of the output should be equal to logical row count");let h=G(e.session.backend.glContext.version),r=`
1243
1243
  float process(int[${c}] indices) {
1244
- int logical_row_start_offset = indices[0] * ${i};
1244
+ int logical_row_start_offset = indices[0] * ${a};
1245
1245
 
1246
1246
  float max = getColorAsFloat(${h.texture2D}(A, offsetToCoords(logical_row_start_offset, ${o},
1247
1247
  ${s} )));
1248
- for(int i=1; i<${i}; ++i)
1248
+ for(int i=1; i<${a}; ++i)
1249
1249
  {
1250
1250
  float current = getColorAsFloat(${h.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1251
1251
  ${o}, ${s})));
@@ -1254,20 +1254,20 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1254
1254
  }
1255
1255
 
1256
1256
  return max;
1257
- }`;return{...Fc,output:{dims:p,type:n.type,textureType:0},shaderSource:r}},Qb=(e,n,a,i,p,o)=>{let[s,c]=e.calculateTextureWidthAndHeight(n.dims,0),h=o.length;if(a<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(o.length!==1)throw new Error("Dimensionality of the output should be 1");if(o[0]!==a)throw new Error("Shape of the output should be equal to logical row count");if(p.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==a)throw new Error("Shape of the intermediate results should be equal to logical row count");let r=G(e.session.backend.glContext.version),u=`
1257
+ }`;return{...Fc,output:{dims:p,type:n.type,textureType:0},shaderSource:r}},Qb=(e,n,i,a,p,o)=>{let[s,c]=e.calculateTextureWidthAndHeight(n.dims,0),h=o.length;if(i<1||a<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(o.length!==1)throw new Error("Dimensionality of the output should be 1");if(o[0]!==i)throw new Error("Shape of the output should be equal to logical row count");if(p.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==i)throw new Error("Shape of the intermediate results should be equal to logical row count");let r=G(e.session.backend.glContext.version),u=`
1258
1258
  float process(int[${h}] indices) {
1259
- int logical_row_start_offset = indices[0] * ${i};
1259
+ int logical_row_start_offset = indices[0] * ${a};
1260
1260
 
1261
1261
  float norm_factor = 0.0;
1262
1262
  float max = _Max(indices);
1263
- for(int i=0; i<${i}; ++i)
1263
+ for(int i=0; i<${a}; ++i)
1264
1264
  {
1265
1265
  norm_factor += exp(getColorAsFloat(${r.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1266
1266
  ${s}, ${c}))) - max);
1267
1267
  }
1268
1268
 
1269
1269
  return norm_factor;
1270
- }`;return{...Cc,output:{dims:o,type:n.type,textureType:0},shaderSource:u}},tg=(e,n,a,i,p,o)=>{let[s,c]=e.calculateTextureWidthAndHeight(n.dims,0),h=n.dims.length;if(a<1||i<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(p.length!==1||o.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==a||o[0]!==a)throw new Error("Shape of the intermediate results should be equal to logical row count");let r=`
1270
+ }`;return{...Cc,output:{dims:o,type:n.type,textureType:0},shaderSource:u}},tg=(e,n,i,a,p,o)=>{let[s,c]=e.calculateTextureWidthAndHeight(n.dims,0),h=n.dims.length;if(i<1||a<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(p.length!==1||o.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(p[0]!==i||o[0]!==i)throw new Error("Shape of the intermediate results should be equal to logical row count");let r=`
1271
1271
  float process(int[${h}] indices) {
1272
1272
 
1273
1273
  // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
@@ -1275,7 +1275,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1275
1275
 
1276
1276
  //determine the logical row for this index
1277
1277
  int logical_row_index[1];
1278
- logical_row_index[0] = offset / ${i};
1278
+ logical_row_index[0] = offset / ${a};
1279
1279
 
1280
1280
  float norm_factor = _Norm(logical_row_index);
1281
1281
 
@@ -1286,31 +1286,31 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1286
1286
  return 0.0;
1287
1287
 
1288
1288
  return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
1289
- }`;return{...Nc,output:{dims:n.dims,type:n.type,textureType:0},shaderSource:r}},zc=e=>{if(!e||e.length!==1)throw new Error("Softmax requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type")}}),Hc,qc,jc,eg,rg,ng,Xc=O(()=>{It(),Y(),j(),Hc={name:"Split",inputNames:["A"],inputTypes:[0]},qc=(e,n,a)=>{ng(n);let i=B.normalizeAxis(a.axis,n[0].dims.length),p=eg(e,n,i,a),o=[];for(let s=0;s<p;++s)o.push(e.run({...Hc,cacheHint:`${a.cacheKey};${s}`,get:()=>rg(e,n[0],a,i,s)},n));return o},jc=e=>{let n=e.attributes.getInt("axis",0),a=e.attributes.getInts("split",[]),i=e.outputs.length;return W({axis:n,split:a,numOutputs:i})},eg=(e,n,a,i)=>{let[,p]=$r.splitShape(n[0].dims,a,i.split,i.numOutputs);return p.length},rg=(e,n,a,i,p)=>{let[o,s]=$r.splitShape(n.dims,i,a.split,a.numOutputs),c=s[p],h=o[p],r=`
1289
+ }`;return{...Nc,output:{dims:n.dims,type:n.type,textureType:0},shaderSource:r}},zc=e=>{if(!e||e.length!==1)throw new Error("Softmax requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type")}}),Hc,qc,jc,eg,rg,ng,Xc=O(()=>{It(),Y(),j(),Hc={name:"Split",inputNames:["A"],inputTypes:[0]},qc=(e,n,i)=>{ng(n);let a=B.normalizeAxis(i.axis,n[0].dims.length),p=eg(e,n,a,i),o=[];for(let s=0;s<p;++s)o.push(e.run({...Hc,cacheHint:`${i.cacheKey};${s}`,get:()=>rg(e,n[0],i,a,s)},n));return o},jc=e=>{let n=e.attributes.getInt("axis",0),i=e.attributes.getInts("split",[]),a=e.outputs.length;return W({axis:n,split:i,numOutputs:a})},eg=(e,n,i,a)=>{let[,p]=$r.splitShape(n[0].dims,i,a.split,a.numOutputs);return p.length},rg=(e,n,i,a,p)=>{let[o,s]=$r.splitShape(n.dims,a,i.split,i.numOutputs),c=s[p],h=o[p],r=`
1290
1290
  float process(int indices[${h.length}]) {
1291
- indices[${i}] += ${c};
1291
+ indices[${a}] += ${c};
1292
1292
  return _A(indices);
1293
1293
  }
1294
- `;return{...Hc,cacheHint:`${a.cacheKey}:${p}`,output:{dims:h,type:n.type,textureType:0},shaderSource:r}},ng=e=>{if(!e||e.length!==1)throw new Error("Split requires one input.");if(e[0].type!=="int8"&&e[0].type!=="uint8"&&e[0].type!=="int16"&&e[0].type!=="uint16"&&e[0].type!=="int32"&&e[0].type!=="uint32"&&e[0].type!=="float32"&&e[0].type!=="float64"&&e[0].type!=="bool")throw new Error("Invalid input type.")}}),Fi,Kc,Jc,og,ig,Yc=O(()=>{Y(),Fi=(e,n,a)=>{og(n);let i=B.squeezeShape(n[0].dims,a);return[e.reshapeUnpacked(n[0],i)]},Kc=(e,n)=>(ig(n),Fi(e,[n[0]],Array.from(n[1].integerData))),Jc=e=>e.attributes.getInts("axes"),og=e=>{if(!e||e.length!==1)throw new Error("Squeeze requires 1 input.");if(e[0].type==="string")throw new Error("invalid input tensor types.")},ig=e=>{if(!e||e.length!==2)throw new Error("Squeeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),Zc,ag,sg,Qc=O(()=>{ut(),j(),Zc=(e,n)=>{sg(n);let a={name:"Sum",inputNames:n.map((i,p)=>`X${p}`),inputTypes:new Array(n.length).fill(0)};return[e.run({...a,get:()=>ag(e,n,a)},n)]},ag=(e,n,a)=>{let i=G(e.session.backend.glContext.version),p=n[0].dims.slice(),o=`
1294
+ `;return{...Hc,cacheHint:`${i.cacheKey}:${p}`,output:{dims:h,type:n.type,textureType:0},shaderSource:r}},ng=e=>{if(!e||e.length!==1)throw new Error("Split requires one input.");if(e[0].type!=="int8"&&e[0].type!=="uint8"&&e[0].type!=="int16"&&e[0].type!=="uint16"&&e[0].type!=="int32"&&e[0].type!=="uint32"&&e[0].type!=="float32"&&e[0].type!=="float64"&&e[0].type!=="bool")throw new Error("Invalid input type.")}}),Fi,Kc,Jc,og,ig,Yc=O(()=>{Y(),Fi=(e,n,i)=>{og(n);let a=B.squeezeShape(n[0].dims,i);return[e.reshapeUnpacked(n[0],a)]},Kc=(e,n)=>(ig(n),Fi(e,[n[0]],Array.from(n[1].integerData))),Jc=e=>e.attributes.getInts("axes"),og=e=>{if(!e||e.length!==1)throw new Error("Squeeze requires 1 input.");if(e[0].type==="string")throw new Error("invalid input tensor types.")},ig=e=>{if(!e||e.length!==2)throw new Error("Squeeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),Zc,ag,sg,Qc=O(()=>{ut(),j(),Zc=(e,n)=>{sg(n);let i={name:"Sum",inputNames:n.map((a,p)=>`X${p}`),inputTypes:new Array(n.length).fill(0)};return[e.run({...i,get:()=>ag(e,n,i)},n)]},ag=(e,n,i)=>{let a=G(e.session.backend.glContext.version),p=n[0].dims.slice(),o=`
1295
1295
  void main() {
1296
- vec4 result = ${n.map((s,c)=>`${i.texture2D}(X${c},TexCoords)`).join(" + ")};
1297
- ${i.output} = result;
1296
+ vec4 result = ${n.map((s,c)=>`${a.texture2D}(X${c},TexCoords)`).join(" + ")};
1297
+ ${a.output} = result;
1298
1298
  }
1299
- `;return{...a,output:{dims:p,type:n[0].type,textureType:0},hasMain:!0,shaderSource:o}},sg=e=>{if(!e||e.length===0)throw new Error("Sum requires inputs.");let n=e[0].dims.length;for(let a=1;a<e.length;a++){if(n!==e[a].dims.length)throw new Error("Input shapes are mismatched.");for(let i=0;i<n;i++)if(e[0].dims[i]!==e[a].dims[i])throw new Error("Input shapes are not matched.")}if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.");for(let a=1;a<e.length;a++)if(e[0].type!==e[a].type)throw new Error("Input types are not matched.")}}),tp,ug,lg,ep=O(()=>{Rr(),j(),tp=(e,n)=>{lg(n);let a={name:"Tile",inputNames:["A"],inputTypes:[0]};return[e.run({...a,get:()=>ug(e,n,a)},n)]},ug=(e,n,a)=>{let i=n[0].dims.slice(),p=new Array(i.length),o=[];for(let h=0;h<i.length;h++)p[h]=i[h]*n[1].numberData[h],o.push(`inputIdx[${h}] = int(mod(float(outputIdx[${h}]), ${i[h]}.));`);let s=p.length,c=`
1299
+ `;return{...i,output:{dims:p,type:n[0].type,textureType:0},hasMain:!0,shaderSource:o}},sg=e=>{if(!e||e.length===0)throw new Error("Sum requires inputs.");let n=e[0].dims.length;for(let i=1;i<e.length;i++){if(n!==e[i].dims.length)throw new Error("Input shapes are mismatched.");for(let a=0;a<n;a++)if(e[0].dims[a]!==e[i].dims[a])throw new Error("Input shapes are not matched.")}if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("Invalid input type.");for(let i=1;i<e.length;i++)if(e[0].type!==e[i].type)throw new Error("Input types are not matched.")}}),tp,ug,lg,ep=O(()=>{Rr(),j(),tp=(e,n)=>{lg(n);let i={name:"Tile",inputNames:["A"],inputTypes:[0]};return[e.run({...i,get:()=>ug(e,n,i)},n)]},ug=(e,n,i)=>{let a=n[0].dims.slice(),p=new Array(a.length),o=[];for(let h=0;h<a.length;h++)p[h]=a[h]*n[1].numberData[h],o.push(`inputIdx[${h}] = int(mod(float(outputIdx[${h}]), ${a[h]}.));`);let s=p.length,c=`
1300
1300
  float process(int outputIdx[${s}]) {
1301
1301
  int inputIdx[${s}];
1302
1302
  ${o.join(`
1303
1303
  `)}
1304
1304
  return _A(inputIdx);
1305
1305
  }
1306
- `;return{...a,output:{dims:p,type:n[0].type,textureType:0},shaderSource:c}},lg=e=>{if(!e||e.length!==2)throw new Error("Tile requires 2 input.");if(e[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(e[1].dims[0]!==e[0].dims.length)throw new Error("Invalid input shape.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.");if(e[1].type!=="int32"&&e[1].type!=="int16")throw new Error("Invalid repeat type.")}}),Ci,rp,np,fg,cg,op=O(()=>{Y(),Ci=(e,n,a)=>{fg(n);let i=B.unsqueezeShape(n[0].dims,a);return[e.reshapeUnpacked(n[0],i)]},rp=(e,n)=>(cg(n),Ci(e,[n[0]],Array.from(n[1].integerData))),np=e=>e.attributes.getInts("axes"),fg=e=>{if(!e||e.length!==1)throw new Error("Unsqueeze requires 1 input.");if(e[0].type==="string")throw new Error("invalid input tensor types.")},cg=e=>{if(!e||e.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),ip,ap=O(()=>{ml(),Pl(),Ll(),Nl(),Bn(),wf(),Af(),Df(),kf(),Nf(),Mf(),Wf(),Xf(),Fn(),Zf(),cc(),xc(),wc(),Ac(),Ec(),Bc(),Wc(),Xc(),Yc(),Qc(),ep(),Nn(),xi(),op(),Li(),ip=[["Abs","","6+",Rl],["Acos","","7+",Gl],["Add","","7+",bl],["And","","7+",gl],["Asin","","7+",Ml],["Atan","","7+",Ul],["AveragePool","","7+",tc,ec],["BatchNormalization","","7+",dl,hl],["Cast","","6+",El,Dl],["Ceil","","6+",Wl],["Clip","","6-10",gi,Vl],["Clip","","11+",zl],["Concat","","4+",Bl,Cl],["Conv","","1+",Oi,Si],["ConvTranspose","","1+",xf,Tf],["Cos","","7+",Hl],["Div","","7+",yl],["Dropout","","7+",yi],["DepthToSpace","","1+",Of,Sf],["Equal","","7+",xl],["Elu","","6+",ql,jl],["Exp","","6+",Xl],["Flatten","","1+",Pf,Ef],["Floor","","6+",Kl],["FusedConv","com.microsoft","1+",Oi,Si],["Gather","","1+",Lf,$f],["Gemm","","7-10",Ai,Ff],["Gemm","","11+",Ai,Cf],["GlobalAveragePool","","1+",nc,oc],["GlobalMaxPool","","1+",lc],["Greater","","7+",Tl],["Identity","","1+",yi],["ImageScaler","","1+",Rf,Gf],["InstanceNormalization","","6+",Vf,zf],["LeakyRelu","","6+",Jl,Yl],["Less","","7+",wl],["LRN","","1+",Hf,qf],["Log","","6+",Zl],["MatMul","","1+",pf,df],["MaxPool","","1+",ic,ac],["Mul","","7+",vl],["Neg","","6+",Ql],["Not","","1+",tf],["Or","","7+",Il],["Pad","","2-10",Pi,Kf],["Pad","","11+",Jf,Yf],["Pow","","7+",_l],["PRelu","","7+",Ol],["ReduceLogSum","","1+",gc,Ee],["ReduceMax","","1+",hc,Ee],["ReduceMean","","1+",dc,Ee],["ReduceMin","","1+",mc,Ee],["ReduceProd","","1+",bc,Ee],["ReduceSum","","1-12",pc,Ee],["ReduceSumSquare","","1+",yc,Ee],["Relu","","6+",ef],["Reshape","","5+",Tc],["Resize","","10",ki,Oc],["Resize","","11+",ki,Sc],["Shape","","1+",Pc],["Sigmoid","","6+",rf],["Sin","","7+",nf],["Slice","","10+",kc],["Slice","","1-9",Dc,Lc],["Softmax","","1-12",Rc,Gc],["Softmax","","13+",Uc,Mc],["Split","","2-12",qc,jc],["Sqrt","","6+",of],["Squeeze","","1-12",Fi,Jc],["Squeeze","","13+",Kc],["Sub","","7+",Sl],["Sum","","6+",Zc],["Tan","","7+",af],["Tanh","","6+",sf],["Tile","","6+",tp],["Transpose","","1+",je,If],["Upsample","","7-8",Ei,Ic],["Upsample","","9",Ei,_c],["Unsqueeze","","1-12",Ci,np],["Unsqueeze","","13+",rp],["Xor","","7+",Al]]});function up(e){let n={},a;for(;(a=sp.exec(e))!==null;){let i=a[3].split(",").map(p=>{let o=p.trim().split(" ");return o&&o.length===2?{type:o[0],name:o[1]}:null}).filter(p=>p!==null);n[a[2]]={params:i,body:a[4]}}for(let i in n){let p=pg.replace("__FUNC__",i),o=new RegExp(p,"gm");for(;(a=o.exec(e))!==null;){let s=a[1],c=a[2],h=a[3].split(","),r=s?`${s} ${c};`:"",u=n[i].body,l="";n[i].params.forEach((g,b)=>{g&&(l+=`${g.type} ${g.name} = ${h[b]};
1306
+ `;return{...i,output:{dims:p,type:n[0].type,textureType:0},shaderSource:c}},lg=e=>{if(!e||e.length!==2)throw new Error("Tile requires 2 input.");if(e[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(e[1].dims[0]!==e[0].dims.length)throw new Error("Invalid input shape.");if(Pe.indexOf(e[0].type)===-1)throw new Error("Invalid input type.");if(e[1].type!=="int32"&&e[1].type!=="int16")throw new Error("Invalid repeat type.")}}),Ci,rp,np,fg,cg,op=O(()=>{Y(),Ci=(e,n,i)=>{fg(n);let a=B.unsqueezeShape(n[0].dims,i);return[e.reshapeUnpacked(n[0],a)]},rp=(e,n)=>(cg(n),Ci(e,[n[0]],Array.from(n[1].integerData))),np=e=>e.attributes.getInts("axes"),fg=e=>{if(!e||e.length!==1)throw new Error("Unsqueeze requires 1 input.");if(e[0].type==="string")throw new Error("invalid input tensor types.")},cg=e=>{if(!e||e.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(e[1].type!=="int32")throw new Error("Invalid input type.")}}),ip,ap=O(()=>{ml(),Pl(),Ll(),Nl(),Bn(),wf(),Af(),Df(),kf(),Nf(),Mf(),Wf(),Xf(),Fn(),Zf(),cc(),xc(),wc(),Ac(),Ec(),Bc(),Wc(),Xc(),Yc(),Qc(),ep(),Nn(),xi(),op(),Li(),ip=[["Abs","","6+",Rl],["Acos","","7+",Gl],["Add","","7+",bl],["And","","7+",gl],["Asin","","7+",Ml],["Atan","","7+",Ul],["AveragePool","","7+",tc,ec],["BatchNormalization","","7+",dl,hl],["Cast","","6+",El,Dl],["Ceil","","6+",Wl],["Clip","","6-10",gi,Vl],["Clip","","11+",zl],["Concat","","4+",Bl,Cl],["Conv","","1+",Oi,Si],["ConvTranspose","","1+",xf,Tf],["Cos","","7+",Hl],["Div","","7+",yl],["Dropout","","7+",yi],["DepthToSpace","","1+",Of,Sf],["Equal","","7+",xl],["Elu","","6+",ql,jl],["Exp","","6+",Xl],["Flatten","","1+",Pf,Ef],["Floor","","6+",Kl],["FusedConv","com.microsoft","1+",Oi,Si],["Gather","","1+",Lf,$f],["Gemm","","7-10",Ai,Ff],["Gemm","","11+",Ai,Cf],["GlobalAveragePool","","1+",nc,oc],["GlobalMaxPool","","1+",lc],["Greater","","7+",Tl],["Identity","","1+",yi],["ImageScaler","","1+",Rf,Gf],["InstanceNormalization","","6+",Vf,zf],["LeakyRelu","","6+",Jl,Yl],["Less","","7+",wl],["LRN","","1+",Hf,qf],["Log","","6+",Zl],["MatMul","","1+",pf,df],["MaxPool","","1+",ic,ac],["Mul","","7+",vl],["Neg","","6+",Ql],["Not","","1+",tf],["Or","","7+",Il],["Pad","","2-10",Pi,Kf],["Pad","","11+",Jf,Yf],["Pow","","7+",_l],["PRelu","","7+",Ol],["ReduceLogSum","","1+",gc,Ee],["ReduceMax","","1+",hc,Ee],["ReduceMean","","1+",dc,Ee],["ReduceMin","","1+",mc,Ee],["ReduceProd","","1+",bc,Ee],["ReduceSum","","1-12",pc,Ee],["ReduceSumSquare","","1+",yc,Ee],["Relu","","6+",ef],["Reshape","","5+",Tc],["Resize","","10",ki,Oc],["Resize","","11+",ki,Sc],["Shape","","1+",Pc],["Sigmoid","","6+",rf],["Sin","","7+",nf],["Slice","","10+",kc],["Slice","","1-9",Dc,Lc],["Softmax","","1-12",Rc,Gc],["Softmax","","13+",Uc,Mc],["Split","","2-12",qc,jc],["Sqrt","","6+",of],["Squeeze","","1-12",Fi,Jc],["Squeeze","","13+",Kc],["Sub","","7+",Sl],["Sum","","6+",Zc],["Tan","","7+",af],["Tanh","","6+",sf],["Tile","","6+",tp],["Transpose","","1+",je,If],["Upsample","","7-8",Ei,Ic],["Upsample","","9",Ei,_c],["Unsqueeze","","1-12",Ci,np],["Unsqueeze","","13+",rp],["Xor","","7+",Al]]});function up(e){let n={},i;for(;(i=sp.exec(e))!==null;){let a=i[3].split(",").map(p=>{let o=p.trim().split(" ");return o&&o.length===2?{type:o[0],name:o[1]}:null}).filter(p=>p!==null);n[i[2]]={params:a,body:i[4]}}for(let a in n){let p=pg.replace("__FUNC__",a),o=new RegExp(p,"gm");for(;(i=o.exec(e))!==null;){let s=i[1],c=i[2],h=i[3].split(","),r=s?`${s} ${c};`:"",u=n[a].body,l="";n[a].params.forEach((g,b)=>{g&&(l+=`${g.type} ${g.name} = ${h[b]};
1307
1307
  `)}),u=`${l}
1308
1308
  ${u}`,u=u.replace("return",`${c} = `);let f=`
1309
1309
  ${r}
1310
1310
  {
1311
1311
  ${u}
1312
1312
  }
1313
- `;e=e.replace(a[0],f)}}return e=e.replace(sp,""),e}var sp,pg,lp=O(()=>{sp=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,pg="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function hr(e,n){let a=[],i=[];for(let p=0;p<e.length;++p)e[p]!==1&&(a.push(e[p]),i.push(p));return{newShape:a,keptDims:i}}function mg(e){if(e.length===0)return 1;let n=e[0];for(let a=1;a<e.length;a++)n*=e[a];return n}function fp(e){let n=Math.ceil(Math.sqrt(e));return[n,Math.ceil(e/n)]}var Un,Ni=O(()=>{Ut(),Y(),Un=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,n){let a=this.computeTexture(e,n);return n&&n.isPacked&&(a[0]/=2,a[1]/=2),n&&n.reverseWH?[a[1],a[0]]:a}computeTexture(e,n){let a=n&&n.isPacked;if(e.length===0)return a?[2,2]:[1,1];let i=this.maxTextureSize;if(n&&n.breakAxis!==void 0){let s=n.breakAxis>=e.length?1:e.slice(n.breakAxis).reduce((h,r)=>h*r),c=n.breakAxis<=0?1:e.slice(0,n.breakAxis).reduce((h,r)=>h*r);if(s>i||c>i)tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${n.breakAxis}`);else return[s,c]}let p=e.slice(0);a&&(i=i*2,p=p.map((s,c)=>c>=p.length-2?p[c]%2===0?p[c]:p[c]+1:p[c]),p.length===1&&(p=[2,p[0]])),p.length!==2&&(p=hr(p).newShape);let o=mg(p);return p.length<=1&&o<=i?[1,o]:p.length===2&&p[0]<=i&&p[1]<=i?p:p.length===3&&p[0]*p[1]<=i&&p[2]<=i?[p[0]*p[1],p[2]]:p.length===3&&p[0]<=i&&p[1]*p[2]<=i?[p[0],p[1]*p[2]]:p.length===4&&p[0]*p[1]*p[2]<=i&&p[3]<=i?[p[0]*p[1]*p[2],p[3]]:p.length===4&&p[0]<=i&&p[1]*p[2]*p[3]<=i?[p[0],p[1]*p[2]*p[3]]:a?fp(o/4).map(s=>s*2):fp(o)}}}),Vn,cp=O(()=>{Y(),Te(),ut(),Ni(),pe(),Vn=class extends Ht{constructor(e){super(e)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSamplingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){let e="offsetToCoords";return{offsetToCoords:new k(`
1313
+ `;e=e.replace(i[0],f)}}return e=e.replace(sp,""),e}var sp,pg,lp=O(()=>{sp=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,pg="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function hr(e,n){let i=[],a=[];for(let p=0;p<e.length;++p)e[p]!==1&&(i.push(e[p]),a.push(p));return{newShape:i,keptDims:a}}function mg(e){if(e.length===0)return 1;let n=e[0];for(let i=1;i<e.length;i++)n*=e[i];return n}function fp(e){let n=Math.ceil(Math.sqrt(e));return[n,Math.ceil(e/n)]}var Un,Ni=O(()=>{Ut(),Y(),Un=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,n){let i=this.computeTexture(e,n);return n&&n.isPacked&&(i[0]/=2,i[1]/=2),n&&n.reverseWH?[i[1],i[0]]:i}computeTexture(e,n){let i=n&&n.isPacked;if(e.length===0)return i?[2,2]:[1,1];let a=this.maxTextureSize;if(n&&n.breakAxis!==void 0){let s=n.breakAxis>=e.length?1:e.slice(n.breakAxis).reduce((h,r)=>h*r),c=n.breakAxis<=0?1:e.slice(0,n.breakAxis).reduce((h,r)=>h*r);if(s>a||c>a)tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${n.breakAxis}`);else return[s,c]}let p=e.slice(0);i&&(a=a*2,p=p.map((s,c)=>c>=p.length-2?p[c]%2===0?p[c]:p[c]+1:p[c]),p.length===1&&(p=[2,p[0]])),p.length!==2&&(p=hr(p).newShape);let o=mg(p);return p.length<=1&&o<=a?[1,o]:p.length===2&&p[0]<=a&&p[1]<=a?p:p.length===3&&p[0]*p[1]<=a&&p[2]<=a?[p[0]*p[1],p[2]]:p.length===3&&p[0]<=a&&p[1]*p[2]<=a?[p[0],p[1]*p[2]]:p.length===4&&p[0]*p[1]*p[2]<=a&&p[3]<=a?[p[0]*p[1]*p[2],p[3]]:p.length===4&&p[0]<=a&&p[1]*p[2]*p[3]<=a?[p[0],p[1]*p[2]*p[3]]:i?fp(o/4).map(s=>s*2):fp(o)}}}),Vn,cp=O(()=>{Y(),Te(),ut(),Ni(),pe(),Vn=class extends Ht{constructor(e){super(e)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSamplingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){let e="offsetToCoords";return{offsetToCoords:new k(`
1314
1314
  vec2 ${e}(int offset, int width, int height) {
1315
1315
  int t = offset / width;
1316
1316
  int s = offset - t*width;
@@ -1324,42 +1324,42 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1324
1324
  int offset = int(t) * width + int(s);
1325
1325
  return offset;
1326
1326
  }
1327
- `)}}getOutputSamplingSnippet(){let e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){let n=e.unpackedShape,a=[e.width,e.height],i={},p="getOutputCoords";switch(n.length){case 0:i[p]=this.getOutputScalarCoords();break;case 1:i[p]=this.getOutputPacked1DCoords(n,a);break;case 2:i[p]=this.getOutputPacked2DCoords(n,a);break;case 3:i[p]=this.getOutputPacked3DCoords(n,a);break;default:i[p]=this.getOutputPackedNDCoords(n,a)}let o=`
1327
+ `)}}getOutputSamplingSnippet(){let e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){let n=e.unpackedShape,i=[e.width,e.height],a={},p="getOutputCoords";switch(n.length){case 0:a[p]=this.getOutputScalarCoords();break;case 1:a[p]=this.getOutputPacked1DCoords(n,i);break;case 2:a[p]=this.getOutputPacked2DCoords(n,i);break;case 3:a[p]=this.getOutputPacked3DCoords(n,i);break;default:a[p]=this.getOutputPackedNDCoords(n,i)}let o=`
1328
1328
  void setOutput(vec4 val) {
1329
1329
  ${G(this.context.glContext.version).output} = val;
1330
1330
  }
1331
- `,s="floatTextureSetRGBA";return i[s]=new k(o),i}getUnpackedOutputSamplingSnippet(e){let n=e.unpackedShape,a=[e.width,e.height],i={},p="getOutputCoords";switch(n.length){case 0:i[p]=this.getOutputScalarCoords();break;case 1:i[p]=this.getOutputUnpacked1DCoords(n,a);break;case 2:i[p]=this.getOutputUnpacked2DCoords(n,a);break;case 3:i[p]=this.getOutputUnpacked3DCoords(n,a);break;case 4:i[p]=this.getOutputUnpacked4DCoords(n,a);break;case 5:i[p]=this.getOutputUnpacked5DCoords(n,a);break;case 6:i[p]=this.getOutputUnpacked6DCoords(n,a);break;default:throw new Error(`Unsupported output dimensionality: ${n.length}`)}let o=`
1331
+ `,s="floatTextureSetRGBA";return a[s]=new k(o),a}getUnpackedOutputSamplingSnippet(e){let n=e.unpackedShape,i=[e.width,e.height],a={},p="getOutputCoords";switch(n.length){case 0:a[p]=this.getOutputScalarCoords();break;case 1:a[p]=this.getOutputUnpacked1DCoords(n,i);break;case 2:a[p]=this.getOutputUnpacked2DCoords(n,i);break;case 3:a[p]=this.getOutputUnpacked3DCoords(n,i);break;case 4:a[p]=this.getOutputUnpacked4DCoords(n,i);break;case 5:a[p]=this.getOutputUnpacked5DCoords(n,i);break;case 6:a[p]=this.getOutputUnpacked6DCoords(n,i);break;default:throw new Error(`Unsupported output dimensionality: ${n.length}`)}let o=`
1332
1332
  void setOutput(float val) {
1333
1333
  ${G(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
1334
1334
  }
1335
- `,s="floatTextureSetR";return i[s]=new k(o),i}getOutputScalarCoords(){return new k(`
1335
+ `,s="floatTextureSetR";return a[s]=new k(o),a}getOutputScalarCoords(){return new k(`
1336
1336
  int getOutputCoords() {
1337
1337
  return 0;
1338
1338
  }
1339
- `)}getOutputPacked1DCoords(e,n){let a=n,i="";return a[0]===1?(i=`
1339
+ `)}getOutputPacked1DCoords(e,n){let i=n,a="";return i[0]===1?(a=`
1340
1340
  int getOutputCoords() {
1341
- return 2 * int(TexCoords.y * ${a[1]}.0);
1341
+ return 2 * int(TexCoords.y * ${i[1]}.0);
1342
1342
  }
1343
- `,new k(i)):a[1]===1?(i=`
1343
+ `,new k(a)):i[1]===1?(a=`
1344
1344
  int getOutputCoords() {
1345
- return 2 * int(TexCoords.x * ${a[0]}.0);
1345
+ return 2 * int(TexCoords.x * ${i[0]}.0);
1346
1346
  }
1347
- `,new k(i)):(i=`
1347
+ `,new k(a)):(a=`
1348
1348
  int getOutputCoords() {
1349
1349
  ivec2 resTexRC = ivec2(TexCoords.xy *
1350
- vec2(${a[0]}, ${a[1]}));
1351
- return 2 * (resTexRC.y * ${a[0]} + resTexRC.x);
1350
+ vec2(${i[0]}, ${i[1]}));
1351
+ return 2 * (resTexRC.y * ${i[0]} + resTexRC.x);
1352
1352
  }
1353
- `,new k(i))}getOutputPacked2DCoords(e,n){let a="";if(Me.arraysEqual(e,n))return a=`
1353
+ `,new k(a))}getOutputPacked2DCoords(e,n){let i="";if(Me.arraysEqual(e,n))return i=`
1354
1354
  ivec2 getOutputCoords() {
1355
1355
  return 2 * ivec2(TexCoords.xy * vec2(${n[0]}, ${n[1]}));
1356
1356
  }
1357
- `,new k(a);let i=n,p=Math.ceil(e[1]/2);return a=`
1357
+ `,new k(i);let a=n,p=Math.ceil(e[1]/2);return i=`
1358
1358
  ivec2 getOutputCoords() {
1359
1359
  ivec2 resTexRC = ivec2(TexCoords.xy *
1360
- vec2(${i[0]}, ${i[1]}));
1360
+ vec2(${a[0]}, ${a[1]}));
1361
1361
 
1362
- int index = resTexRC.y * ${i[0]} + resTexRC.x;
1362
+ int index = resTexRC.y * ${a[0]} + resTexRC.x;
1363
1363
 
1364
1364
  // reverse r and c order for packed texture
1365
1365
  int r = imod(index, ${p}) * 2;
@@ -1367,29 +1367,29 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1367
1367
 
1368
1368
  return ivec2(r, c);
1369
1369
  }
1370
- `,new k(a)}getOutputPacked3DCoords(e,n){let a=[n[0],n[1]],i=Math.ceil(e[2]/2),p=i*Math.ceil(e[1]/2),o=`
1370
+ `,new k(i)}getOutputPacked3DCoords(e,n){let i=[n[0],n[1]],a=Math.ceil(e[2]/2),p=a*Math.ceil(e[1]/2),o=`
1371
1371
  ivec3 getOutputCoords() {
1372
1372
  ivec2 resTexRC = ivec2(TexCoords.xy *
1373
- vec2(${a[0]}, ${a[1]}));
1374
- int index = resTexRC.y * ${a[0]} + resTexRC.x;
1373
+ vec2(${i[0]}, ${i[1]}));
1374
+ int index = resTexRC.y * ${i[0]} + resTexRC.x;
1375
1375
 
1376
1376
  int b = index / ${p};
1377
1377
  index -= b * ${p};
1378
1378
 
1379
1379
  // reverse r and c order for packed texture
1380
- int r = imod(index, ${i}) * 2;
1381
- int c = 2 * (index / ${i});
1380
+ int r = imod(index, ${a}) * 2;
1381
+ int c = 2 * (index / ${a});
1382
1382
 
1383
1383
  return ivec3(b, r, c);
1384
1384
  }
1385
- `;return new k(o)}getOutputPackedNDCoords(e,n){let a=[n[0],n[1]],i=Math.ceil(e[e.length-1]/2),p=i*Math.ceil(e[e.length-2]/2),o=p,s="",c="b, r, c";for(let r=2;r<e.length-1;r++)o*=e[e.length-r-1],s=`
1385
+ `;return new k(o)}getOutputPackedNDCoords(e,n){let i=[n[0],n[1]],a=Math.ceil(e[e.length-1]/2),p=a*Math.ceil(e[e.length-2]/2),o=p,s="",c="b, r, c";for(let r=2;r<e.length-1;r++)o*=e[e.length-r-1],s=`
1386
1386
  int b${r} = index / ${o};
1387
1387
  index -= b${r} * ${o};
1388
1388
  `+s,c=`b${r}, `+c;let h=`
1389
1389
  ivec${e.length} getOutputCoords() {
1390
1390
  ivec2 resTexRC = ivec2(TexCoords.xy *
1391
- vec2(${a[0]}, ${a[1]}));
1392
- int index = resTexRC.y * ${a[0]} + resTexRC.x;
1391
+ vec2(${i[0]}, ${i[1]}));
1392
+ int index = resTexRC.y * ${i[0]} + resTexRC.x;
1393
1393
 
1394
1394
  ${s}
1395
1395
 
@@ -1397,18 +1397,18 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1397
1397
  index -= b * ${p};
1398
1398
 
1399
1399
  // reverse r and c order for packed texture
1400
- int r = imod(index, ${i}) * 2;
1401
- int c = 2 * (index / ${i});
1400
+ int r = imod(index, ${a}) * 2;
1401
+ int c = 2 * (index / ${a});
1402
1402
 
1403
1403
  return ivec${e.length}(${c});
1404
1404
  }
1405
- `;return new k(h)}getOutputUnpacked1DCoords(e,n){let a=`
1405
+ `;return new k(h)}getOutputUnpacked1DCoords(e,n){let i=`
1406
1406
  int getOutputCoords() {
1407
1407
  ivec2 resTexRC = ivec2(TexCoords.xy *
1408
1408
  vec2(${n[0]}, ${n[1]}));
1409
1409
  return resTexRC.y * ${n[0]} + resTexRC.x;
1410
1410
  }
1411
- `;return new k(a)}getOutputUnpacked2DCoords(e,n){let a=`
1411
+ `;return new k(i)}getOutputUnpacked2DCoords(e,n){let i=`
1412
1412
  ivec2 getOutputCoords() {
1413
1413
  ivec2 resTexRC = ivec2(TexCoords.xy *
1414
1414
  vec2(${n[0]}, ${n[1]}));
@@ -1417,7 +1417,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1417
1417
  int c = index - r * ${e[1]};
1418
1418
  return ivec2(r, c);
1419
1419
  }
1420
- `;return new k(a)}getOutputUnpacked3DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1420
+ `;return new k(i)}getOutputUnpacked3DCoords(e,n){let i="",a=e.length,p=null;a<2&&(p=[]),p=new Array(a-1),p[a-2]=e[a-1];for(let c=a-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return i=`
1421
1421
  ivec3 getOutputCoords() {
1422
1422
  ivec2 resTexRC = ivec2(TexCoords.xy *
1423
1423
  vec2(${n[0]}, ${n[1]}));
@@ -1425,7 +1425,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1425
1425
  ${s}
1426
1426
  return ivec3(r, c, d);
1427
1427
  }
1428
- `,new k(a)}getOutputUnpacked4DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1428
+ `,new k(i)}getOutputUnpacked4DCoords(e,n){let i="",a=e.length,p=null;a<2&&(p=[]),p=new Array(a-1),p[a-2]=e[a-1];for(let c=a-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return i=`
1429
1429
  ivec4 getOutputCoords() {
1430
1430
  ivec2 resTexRC = ivec2(TexCoords.xy *
1431
1431
  vec2(${n[0]}, ${n[1]}));
@@ -1433,7 +1433,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1433
1433
  ${s}
1434
1434
  return ivec4(r, c, d, d2);
1435
1435
  }
1436
- `,new k(a)}getOutputUnpacked5DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2","d3"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1436
+ `,new k(i)}getOutputUnpacked5DCoords(e,n){let i="",a=e.length,p=null;a<2&&(p=[]),p=new Array(a-1),p[a-2]=e[a-1];for(let c=a-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2","d3"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return i=`
1437
1437
  ivec5 getOutputCoords() {
1438
1438
  ivec2 resTexRC = ivec2(TexCoords.xy *
1439
1439
  vec2(${n[0]}, ${n[1]}));
@@ -1441,7 +1441,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1441
1441
  ${s}
1442
1442
  return ivec5(r, c, d, d2, d3);
1443
1443
  }
1444
- `,new k(a)}getOutputUnpacked6DCoords(e,n){let a="",i=e.length,p=null;i<2&&(p=[]),p=new Array(i-1),p[i-2]=e[i-1];for(let c=i-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2","d3","d4"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return a=`
1444
+ `,new k(i)}getOutputUnpacked6DCoords(e,n){let i="",a=e.length,p=null;a<2&&(p=[]),p=new Array(a-1),p[a-2]=e[a-1];for(let c=a-3;c>=0;--c)p[c]=p[c+1]*e[c+1];let o=["r","c","d","d2","d3","d4"],s=p.map((c,h)=>{let r=`int ${o[h]} = index / ${c}`,u=h===p.length-1?`int ${o[h+1]} = index - ${o[h]} * ${c}`:`index -= ${o[h]} * ${c}`;return`${r}; ${u};`}).join("");return i=`
1445
1445
  ivec6 getOutputCoords() {
1446
1446
  ivec2 resTexRC = ivec2(TexCoords.xy *
1447
1447
  vec2(${n[0]}, ${n[1]}));
@@ -1449,7 +1449,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1449
1449
  ${s}
1450
1450
  return ivec6(r, c, d, d2, d3, d4);
1451
1451
  }
1452
- `,new k(a)}getCommonUtilFuncs(){let e={},n="uvFromFlat";e[n]=new k(`
1452
+ `,new k(i)}getCommonUtilFuncs(){let e={},n="uvFromFlat";e[n]=new k(`
1453
1453
  vec2 uvFromFlat(int texNumR, int texNumC, int index) {
1454
1454
  int texC = index / texNumR;
1455
1455
  int texR = index - texC * texNumR;
@@ -1480,17 +1480,17 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1480
1480
  int texC = index - texR * texNumC;
1481
1481
  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1482
1482
  }
1483
- `),n="sampleTexture";let a=G(this.context.glContext.version);return e[n]=new k(`
1483
+ `),n="sampleTexture";let i=G(this.context.glContext.version);return e[n]=new k(`
1484
1484
  float sampleTexture(sampler2D textureSampler, vec2 uv) {
1485
- return ${a.texture2D}(textureSampler, uv).r;
1486
- }`),e}getInputsSamplingSnippets(){let e={},n=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i],o=An(a);p.isPacked?e[o]=this.getPackedSamplerFromInput(o,a,p):e[o]=this.getUnpackedSamplerFromInput(o,a,p);let s=Yu(a);p.unpackedShape.length<=n.unpackedShape.length&&(p.isPacked?e[s]=this.getPackedSamplerAtOutputCoords(s,p,n,a):e[s]=this.getUnpackedSamplerAtOutputCoords(s,p,n,a))}),e}getPackedSamplerAtOutputCoords(e,n,a,i){let p=n.unpackedShape,o=a.unpackedShape,s=An(i),c=p.length,h=o.length,r=kt.getBroadcastDims(p,o),u=Bt(h),l=h-c,f,g=ne();c===0?f="":h<2&&r.length>=1?f="coords = 0;":f=r.map(L=>`coords.${g[L+l]} = 0;`).join(`
1487
- `);let b="";h<2&&c>0?b="coords":b=p.map((L,V)=>`coords.${g[V+l]}`).join(", ");let v="return outputValue;",S=B.size(p)===1,P=B.size(o)===1;if(c===1&&!S&&!P)v=`
1485
+ return ${i.texture2D}(textureSampler, uv).r;
1486
+ }`),e}getInputsSamplingSnippets(){let e={},n=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((i,a)=>{let p=this.context.inputTextureLayouts[a],o=An(i);p.isPacked?e[o]=this.getPackedSamplerFromInput(o,i,p):e[o]=this.getUnpackedSamplerFromInput(o,i,p);let s=Yu(i);p.unpackedShape.length<=n.unpackedShape.length&&(p.isPacked?e[s]=this.getPackedSamplerAtOutputCoords(s,p,n,i):e[s]=this.getUnpackedSamplerAtOutputCoords(s,p,n,i))}),e}getPackedSamplerAtOutputCoords(e,n,i,a){let p=n.unpackedShape,o=i.unpackedShape,s=An(a),c=p.length,h=o.length,r=kt.getBroadcastDims(p,o),u=Bt(h),l=h-c,f,g=ne();c===0?f="":h<2&&r.length>=1?f="coords = 0;":f=r.map(L=>`coords.${g[L+l]} = 0;`).join(`
1487
+ `);let b="";h<2&&c>0?b="coords":b=p.map((L,M)=>`coords.${g[M+l]}`).join(", ");let v="return outputValue;",S=B.size(p)===1,P=B.size(o)===1;if(c===1&&!S&&!P)v=`
1488
1488
  return vec4(outputValue.xy, outputValue.xy);
1489
1489
  `;else if(S&&!P)h===1?v=`
1490
1490
  return vec4(outputValue.x, outputValue.x, 0., 0.);
1491
1491
  `:v=`
1492
1492
  return vec4(outputValue.x);
1493
- `;else if(r.length){let L=c-2,V=c-1;r.indexOf(L)>-1&&r.indexOf(V)>-1?v="return vec4(outputValue.x);":r.indexOf(L)>-1?v="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":r.indexOf(V)>-1&&(v="return vec4(outputValue.xx, outputValue.zz);")}let _=`
1493
+ `;else if(r.length){let L=c-2,M=c-1;r.indexOf(L)>-1&&r.indexOf(M)>-1?v="return vec4(outputValue.x);":r.indexOf(L)>-1?v="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":r.indexOf(M)>-1&&(v="return vec4(outputValue.xx, outputValue.zz);")}let _=`
1494
1494
  int lastDim = coords.${g[h-1]};
1495
1495
  coords.${g[h-1]} = coords.${g[h-2]};
1496
1496
  coords.${g[h-2]} = lastDim;
@@ -1502,9 +1502,9 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1502
1502
  vec4 outputValue = ${s}(${b});
1503
1503
  ${v}
1504
1504
  }
1505
- `;return new k(A,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,n,a,i){let p=[a.width,a.height],o=[n.width,n.height],s=n.unpackedShape.length,c=a.unpackedShape.length,h=n.unpackedShape,r=a.unpackedShape,u=An(i);if(s===c&&Me.arraysEqual(o,p)){let _=`
1505
+ `;return new k(A,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,n,i,a){let p=[i.width,i.height],o=[n.width,n.height],s=n.unpackedShape.length,c=i.unpackedShape.length,h=n.unpackedShape,r=i.unpackedShape,u=An(a);if(s===c&&Me.arraysEqual(o,p)){let _=`
1506
1506
  float ${e}() {
1507
- return sampleTexture(${i}, TexCoords);
1507
+ return sampleTexture(${a}, TexCoords);
1508
1508
  }
1509
1509
  `;return new k(_,["coordinates.sampleTexture"])}let l=Bt(c),f=kt.getBroadcastDims(h,r),g=c-s,b,v=ne();s===0?b="":c<2&&f.length>=1?b="coords = 0;":b=f.map(_=>`coords.${v[_+g]} = 0;`).join(`
1510
1510
  `);let S="";c<2&&s>0?S="coords":S=n.unpackedShape.map((_,A)=>`coords.${v[A+g]}`).join(", ");let P=`
@@ -1513,67 +1513,67 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1513
1513
  ${b}
1514
1514
  return ${u}(${S});
1515
1515
  }
1516
- `;return new k(P,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,n,a){switch(a.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,n);case 1:return this.getPackedSampler1D(e,n,a);case 2:return this.getPackedSampler2D(e,n,a);case 3:return this.getPackedSampler3D(e,n,a);default:return this.getPackedSamplerND(e,n,a)}}getUnpackedSamplerFromInput(e,n,a){let i=a.unpackedShape;switch(i.length){case 0:return this.getUnpackedSamplerScalar(e,n,a);case 1:return this.getUnpackedSampler1D(e,n,a);case 2:return this.getUnpackedSampler2D(e,n,a);case 3:return this.getUnpackedSampler3D(e,n,a);case 4:return this.getUnpackedSampler4D(e,n,a);case 5:return this.getUnpackedSampler5D(e,n,a);case 6:return this.getUnpackedSampler6D(e,n,a);default:throw new Error(`Unsupported dimension ${i.length}-D`)}}getPackedSamplerScalar(e,n){let a=G(this.context.glContext.version),i=`
1516
+ `;return new k(P,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,n,i){switch(i.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,n);case 1:return this.getPackedSampler1D(e,n,i);case 2:return this.getPackedSampler2D(e,n,i);case 3:return this.getPackedSampler3D(e,n,i);default:return this.getPackedSamplerND(e,n,i)}}getUnpackedSamplerFromInput(e,n,i){let a=i.unpackedShape;switch(a.length){case 0:return this.getUnpackedSamplerScalar(e,n,i);case 1:return this.getUnpackedSampler1D(e,n,i);case 2:return this.getUnpackedSampler2D(e,n,i);case 3:return this.getUnpackedSampler3D(e,n,i);case 4:return this.getUnpackedSampler4D(e,n,i);case 5:return this.getUnpackedSampler5D(e,n,i);case 6:return this.getUnpackedSampler6D(e,n,i);default:throw new Error(`Unsupported dimension ${a.length}-D`)}}getPackedSamplerScalar(e,n){let i=G(this.context.glContext.version),a=`
1517
1517
  vec4 ${e}() {
1518
- return ${a.texture2D}(${n}, halfCR);
1518
+ return ${i.texture2D}(${n}, halfCR);
1519
1519
  }
1520
- `;return new k(i)}getPackedSampler1D(e,n,a){let i=[a.width,a.height],p=[i[1],i[0]],o=G(this.context.glContext.version),s=`vec4 ${e}(int index) {
1520
+ `;return new k(a)}getPackedSampler1D(e,n,i){let a=[i.width,i.height],p=[a[1],a[0]],o=G(this.context.glContext.version),s=`vec4 ${e}(int index) {
1521
1521
  vec2 uv = packedUVfrom1D(
1522
1522
  ${p[0]}, ${p[1]}, index);
1523
1523
  return ${o.texture2D}(${n}, uv);
1524
- }`;return new k(s,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,n,a){let i=a.unpackedShape,p=[a.width,a.height],o=G(this.context.glContext.version),s=p[0],c=p[1];if(p!=null&&Me.arraysEqual(i,p)){let l=`vec4 ${e}(int row, int col) {
1524
+ }`;return new k(s,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,n,i){let a=i.unpackedShape,p=[i.width,i.height],o=G(this.context.glContext.version),s=p[0],c=p[1];if(p!=null&&Me.arraysEqual(a,p)){let l=`vec4 ${e}(int row, int col) {
1525
1525
  vec2 uv = (vec2(col, row) + halfCR) / vec2(${c}.0, ${s}.0);
1526
1526
  return ${o.texture2D}(${n}, uv);
1527
- }`;return new k(l)}let h=p,r=Math.ceil(i[1]/2),u=`vec4 ${e}(int row, int col) {
1527
+ }`;return new k(l)}let h=p,r=Math.ceil(a[1]/2),u=`vec4 ${e}(int row, int col) {
1528
1528
  vec2 uv = packedUVfrom2D(${h[1]}, ${h[0]}, ${r}, row, col);
1529
1529
  return ${o.texture2D}(${n}, uv);
1530
- }`;return new k(u,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,n,a){let i=a.unpackedShape,p=[a.width,a.height],o=[p[0],p[1]],s=G(this.context.glContext.version);if(i[0]===1){let f=i.slice(1),g=[1,2],b=lr(i,f),v=["b","row","col"],S=JSON.parse(JSON.stringify(a));S.unpackedShape=b;let P=this.getPackedSamplerFromInput(e,n,S),_=`${P.routineBody}
1530
+ }`;return new k(u,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,n,i){let a=i.unpackedShape,p=[i.width,i.height],o=[p[0],p[1]],s=G(this.context.glContext.version);if(a[0]===1){let f=a.slice(1),g=[1,2],b=lr(a,f),v=["b","row","col"],S=JSON.parse(JSON.stringify(i));S.unpackedShape=b;let P=this.getPackedSamplerFromInput(e,n,S),_=`${P.routineBody}
1531
1531
  vec4 ${e}(int b, int row, int col) {
1532
1532
  return ${e}(${fr(v,g)});
1533
- } `;return new k(_,P.dependencies)}let c=o[0],h=o[1],r=Math.ceil(i[2]/2),u=r*Math.ceil(i[1]/2),l=`vec4 ${e}(int b, int row, int col) {
1533
+ } `;return new k(_,P.dependencies)}let c=o[0],h=o[1],r=Math.ceil(a[2]/2),u=r*Math.ceil(a[1]/2),l=`vec4 ${e}(int b, int row, int col) {
1534
1534
  vec2 uv = packedUVfrom3D(
1535
1535
  ${h}, ${c}, ${u}, ${r}, b, row, col);
1536
- return ${s.texture2D}(${n}, uv);}`;return new k(l,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,n,a){let i=a.unpackedShape,p=i.length,o=[a.width,a.height],s=G(this.context.glContext.version),c=[o[0],o[1]],h=c[1],r=c[0],u=Math.ceil(i[p-1]/2),l=u*Math.ceil(i[p-2]/2),f="int b, int row, int col",g=`b * ${l} + (row / 2) * ${u} + (col / 2)`;for(let v=2;v<p-1;v++)f=`int b${v}, `+f,l*=i[p-v-1],g=`b${v} * ${l} + `+g;let b=`vec4 ${e}(${f}) {
1536
+ return ${s.texture2D}(${n}, uv);}`;return new k(l,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,n,i){let a=i.unpackedShape,p=a.length,o=[i.width,i.height],s=G(this.context.glContext.version),c=[o[0],o[1]],h=c[1],r=c[0],u=Math.ceil(a[p-1]/2),l=u*Math.ceil(a[p-2]/2),f="int b, int row, int col",g=`b * ${l} + (row / 2) * ${u} + (col / 2)`;for(let v=2;v<p-1;v++)f=`int b${v}, `+f,l*=a[p-v-1],g=`b${v} * ${l} + `+g;let b=`vec4 ${e}(${f}) {
1537
1537
  int index = ${g};
1538
1538
  int texR = index / ${r};
1539
1539
  int texC = index - texR * ${r};
1540
1540
  vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}, ${h});
1541
1541
  return ${s.texture2D}(${n}, uv);
1542
- }`;return new k(b)}getUnpackedSamplerScalar(e,n,a){let[i,p]=[a.width,a.height];if(i===1&&p===1){let s=`
1542
+ }`;return new k(b)}getUnpackedSamplerScalar(e,n,i){let[a,p]=[i.width,i.height];if(a===1&&p===1){let s=`
1543
1543
  float ${e}() {
1544
1544
  return sampleTexture(${n}, halfCR);
1545
1545
  }
1546
1546
  `;return new k(s,["coordinates.sampleTexture"])}let o=`
1547
1547
  float ${e}() {
1548
- int offset_${n} = coordsToOffset(TexCoords, ${i}, ${p});
1549
- vec2 uv = uvFromFlat(${i}, ${p}, offset_${n});
1548
+ int offset_${n} = coordsToOffset(TexCoords, ${a}, ${p});
1549
+ vec2 uv = uvFromFlat(${a}, ${p}, offset_${n});
1550
1550
  return sampleTexture(${n}, uv);
1551
1551
  }
1552
- `;return new k(o,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(e,n,a){let i=a.width,p=a.height;if(p===1&&i===1){let s=`
1552
+ `;return new k(o,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(e,n,i){let a=i.width,p=i.height;if(p===1&&a===1){let s=`
1553
1553
  float ${e}(int index) {
1554
1554
  return sampleTexture(${n}, halfCR);
1555
1555
  }
1556
1556
  `;return new k(s,["coordinates.sampleTexture"])}if(p===1){let s=`
1557
1557
  float ${e}(int index) {
1558
- vec2 uv = vec2((float(index) + 0.5) / ${i}.0, 0.5);
1558
+ vec2 uv = vec2((float(index) + 0.5) / ${a}.0, 0.5);
1559
1559
  return sampleTexture(${n}, uv);
1560
1560
  }
1561
- `;return new k(s,["coordinates.sampleTexture"])}if(i===1){let s=`
1561
+ `;return new k(s,["coordinates.sampleTexture"])}if(a===1){let s=`
1562
1562
  float ${e}(int index) {
1563
1563
  vec2 uv = vec2(0.5, (float(index) + 0.5) / ${p}.0);
1564
1564
  return sampleTexture(${n}, uv);
1565
1565
  }
1566
1566
  `;return new k(s,["coordinates.sampleTexture"])}let o=`
1567
1567
  float ${e}(int index) {
1568
- vec2 uv = uvFromFlat(${i}, ${p}, index);
1568
+ vec2 uv = uvFromFlat(${a}, ${p}, index);
1569
1569
  return sampleTexture(${n}, uv);
1570
1570
  }
1571
- `;return new k(o,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(e,n,a){let i=a.unpackedShape,p=[a.height,a.width];if(p!=null&&Me.arraysEqual(i,p)){let l=p[1],f=p[0],g=`
1571
+ `;return new k(o,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(e,n,i){let a=i.unpackedShape,p=[i.height,i.width];if(p!=null&&Me.arraysEqual(a,p)){let l=p[1],f=p[0],g=`
1572
1572
  float ${e}(int row, int col) {
1573
1573
  vec2 uv = (vec2(row, col) + halfCR) / vec2(${l}.0, ${f}.0);
1574
1574
  return sampleTexture(${n}, uv);
1575
1575
  }
1576
- `;return new k(g,["coordinates.sampleTexture"])}let{newShape:o,keptDims:s}=hr(i),c=o;if(c.length<i.length){let l=lr(i,c),f=JSON.parse(JSON.stringify(a));f.unpackedShape=l;let g=["col","row"],b=`
1576
+ `;return new k(g,["coordinates.sampleTexture"])}let{newShape:o,keptDims:s}=hr(a),c=o;if(c.length<a.length){let l=lr(a,c),f=JSON.parse(JSON.stringify(i));f.unpackedShape=l;let g=["col","row"],b=`
1577
1577
  ${this.getUnpackedSamplerFromInput(e,n,f).routineBody}
1578
1578
  float ${e}(int row, int col) {
1579
1579
  return ${e}(${fr(g,s)});
@@ -1581,61 +1581,61 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1581
1581
  `;return new k(b,["coordinates.sampleTexture"])}let h=p[1],r=p[0];if(r===1){let l=`
1582
1582
  float ${e}(int row, int col) {
1583
1583
  int offset_${n} = coordsToOffset(TexCoords, ${h}, ${r});
1584
- float index = dot(vec3(row, col, offset_${n}), vec3(${i[1]}, 1, 1));
1584
+ float index = dot(vec3(row, col, offset_${n}), vec3(${a[1]}, 1, 1));
1585
1585
  vec2 uv = vec2(0.5, (index + 0.5) / ${h}.0);
1586
1586
  return sampleTexture(${n}, uv);
1587
1587
  }
1588
1588
  `;return new k(l,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(h===1){let l=`
1589
1589
  float ${e}(int row, int col) {
1590
1590
  int offset_${n} = coordsToOffset(TexCoords, ${h}, ${r});
1591
- float index = dot(vec3(row, col, offset_${n}), vec3(${i[1]}, 1, 1));
1591
+ float index = dot(vec3(row, col, offset_${n}), vec3(${a[1]}, 1, 1));
1592
1592
  vec2 uv = vec2((index + 0.5) / ${r}.0, 0.5);
1593
1593
  return sampleTexture(${n}, uv);
1594
1594
  }
1595
1595
  `;return new k(l,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let u=`
1596
1596
  float ${e}(int row, int col) {
1597
- int index = col * ${i[1]} + row;
1597
+ int index = col * ${a[1]} + row;
1598
1598
  vec2 uv = uvFromFlat(${h}, ${r}, index);
1599
1599
  return sampleTexture(${n}, uv);
1600
1600
  }
1601
- `;return new k(u,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(e,n,a){let i=a.unpackedShape,p=i[1]*i[2],o=i[2],{newShape:s,keptDims:c}=hr(i),h=s;if(h.length<i.length){let f=lr(i,h),g=["batch","col","row"],b=JSON.parse(JSON.stringify(a));b.unpackedShape=f;let v=this.getUnpackedSamplerFromInput(e,n,b),S=c.reverse(),P=`
1601
+ `;return new k(u,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(e,n,i){let a=i.unpackedShape,p=a[1]*a[2],o=a[2],{newShape:s,keptDims:c}=hr(a),h=s;if(h.length<a.length){let f=lr(a,h),g=["batch","col","row"],b=JSON.parse(JSON.stringify(i));b.unpackedShape=f;let v=this.getUnpackedSamplerFromInput(e,n,b),S=c.reverse(),P=`
1602
1602
  ${v.routineBody}
1603
1603
  float ${e}(int batch, int row, int col) {
1604
1604
  return ${e}(${fr(g,S)});
1605
1605
  }
1606
- `;return new k(P,v.dependencies)}let r=a.width,u=a.height,l=`
1606
+ `;return new k(P,v.dependencies)}let r=i.width,u=i.height,l=`
1607
1607
  float ${e}(int depth, int row, int col) {
1608
1608
  // Explicitly use integer operations as dot() only works on floats.
1609
1609
  int index = depth * ${p} + col * ${o} + row;
1610
1610
  vec2 uv = uvFromFlat(${r}, ${u}, index);
1611
1611
  return sampleTexture(${n}, uv);
1612
1612
  }
1613
- `;return new k(l,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(e,n,a){let i=a.unpackedShape,p=i[3],o=i[2]*p,s=i[1]*o,c=a.width,h=a.height,r=`
1613
+ `;return new k(l,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(e,n,i){let a=i.unpackedShape,p=a[3],o=a[2]*p,s=a[1]*o,c=i.width,h=i.height,r=`
1614
1614
  float ${e}(int row, int col, int depth, int depth2) {
1615
1615
  int index = row * ${s} + col * ${o} +
1616
1616
  depth2 * ${p} + depth;
1617
1617
  vec2 uv = uvFromFlat(${c}, ${h}, index);
1618
1618
  return sampleTexture(${n}, uv);
1619
1619
  }
1620
- `;return new k(r,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(e,n,a){let i=a.unpackedShape,p=i[4],o=i[3]*p,s=i[2]*o,c=i[1]*s,{newShape:h,keptDims:r}=hr(i);if(h.length<i.length){let g=lr(i,h),b=["row","col","depth","depth2","depth3"],v=JSON.parse(JSON.stringify(a));v.unpackedShape=g;let S=`
1620
+ `;return new k(r,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(e,n,i){let a=i.unpackedShape,p=a[4],o=a[3]*p,s=a[2]*o,c=a[1]*s,{newShape:h,keptDims:r}=hr(a);if(h.length<a.length){let g=lr(a,h),b=["row","col","depth","depth2","depth3"],v=JSON.parse(JSON.stringify(i));v.unpackedShape=g;let S=`
1621
1621
  ${this.getUnpackedSamplerFromInput(e,n,v).routineBody}
1622
1622
  float ${e}(int row, int col, int depth, int depth2, int depth3) {
1623
1623
  return ${e}(${fr(b,r)});
1624
1624
  }
1625
- `;return new k(S,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let u=a.width,l=a.height,f=`
1625
+ `;return new k(S,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let u=i.width,l=i.height,f=`
1626
1626
  float ${e}(int row, int col, int depth, int depth2, int depth3) {
1627
1627
  int index = row * ${c} + col * ${s} + depth * ${o} +
1628
1628
  depth3 * ${p} + depth2;
1629
1629
  vec2 uv = uvFromFlat(${u}, ${l}, index);
1630
1630
  return sampleTexture(${n}, uv);
1631
1631
  }
1632
- `;return new k(f,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(e,n,a){let i=a.unpackedShape,p=i[5],o=i[4]*p,s=i[3]*o,c=i[2]*s,h=i[1]*c,{newShape:r,keptDims:u}=hr(i);if(r.length<i.length){let b=lr(i,r),v=["row","col","depth","depth2","depth3","depth4"],S=JSON.parse(JSON.stringify(a));S.unpackedShape=b;let P=`
1632
+ `;return new k(f,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(e,n,i){let a=i.unpackedShape,p=a[5],o=a[4]*p,s=a[3]*o,c=a[2]*s,h=a[1]*c,{newShape:r,keptDims:u}=hr(a);if(r.length<a.length){let b=lr(a,r),v=["row","col","depth","depth2","depth3","depth4"],S=JSON.parse(JSON.stringify(i));S.unpackedShape=b;let P=`
1633
1633
  ${this.getUnpackedSamplerFromInput(e,n,S).routineBody}
1634
1634
  float ${e}(int row, int col, int depth,
1635
1635
  int depth2, int depth3, int depth4) {
1636
1636
  return ${e}(${fr(v,u)});
1637
1637
  }
1638
- `;return new k(P,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let l=a.width,f=a.height,g=`
1638
+ `;return new k(P,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let l=i.width,f=i.height,g=`
1639
1639
  float ${e}(int row, int col, int depth,
1640
1640
  int depth2, int depth3, int depth4) {
1641
1641
  int index = row * ${h} + col * ${c} + depth * ${s} +
@@ -1643,28 +1643,28 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1643
1643
  vec2 uv = uvFromFlat(${l}, ${f}, index);
1644
1644
  return sampleTexture(${n}, uv);
1645
1645
  }
1646
- `;return new k(g,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let e=this.context.outputTextureLayout,n=e.shape.length,a=e.strides,i=e.width,p=e.height,o=[];for(let c=0;c<n-1;++c)o.push(`
1647
- c[${c}] = offset / ${a[c]};`),o.push(`
1648
- offset -= c[${c}] * ${a[c]};`);o.push(`
1646
+ `;return new k(g,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){let e=this.context.outputTextureLayout,n=e.shape.length,i=e.strides,a=e.width,p=e.height,o=[];for(let c=0;c<n-1;++c)o.push(`
1647
+ c[${c}] = offset / ${i[c]};`),o.push(`
1648
+ offset -= c[${c}] * ${i[c]};`);o.push(`
1649
1649
  c[${n-1}] = offset;`);let s=`
1650
1650
  void toVec(vec2 texCoords, out int c[${n}]) {
1651
- int offset = coordsToOffset(texCoords, ${i}, ${p});
1651
+ int offset = coordsToOffset(texCoords, ${a}, ${p});
1652
1652
  ${o.join("")}
1653
1653
  }
1654
1654
  void toVec(int offset, out int c[${n}]) {
1655
1655
  ${o.join("")}
1656
1656
  }
1657
- `;return{toVec:new k(s,["coordinates.coordsToOffset"])}}valueFrom(){let e={};return this.context.programInfo.inputNames.forEach((n,a)=>{let i=this.context.inputTextureLayouts[a],p=(i.unpackedShape.length>0?i.unpackedShape:i.shape).length,o=`_${n}`;e[o]=new k(this.getValueFromSingle(n,p,i.width,i.height,!1),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),o=o+"_T",e[o]=new k(this.getValueFromSingle(n,p,i.width,i.height,!0),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),e}getValueFromSingle(e,n,a,i,p){let o=`_${e}`;p&&(o=o+"_T");let s=G(this.context.glContext.version);return`
1657
+ `;return{toVec:new k(s,["coordinates.coordsToOffset"])}}valueFrom(){let e={};return this.context.programInfo.inputNames.forEach((n,i)=>{let a=this.context.inputTextureLayouts[i],p=(a.unpackedShape.length>0?a.unpackedShape:a.shape).length,o=`_${n}`;e[o]=new k(this.getValueFromSingle(n,p,a.width,a.height,!1),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),o=o+"_T",e[o]=new k(this.getValueFromSingle(n,p,a.width,a.height,!0),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),e}getValueFromSingle(e,n,i,a,p){let o=`_${e}`;p&&(o=o+"_T");let s=G(this.context.glContext.version);return`
1658
1658
  float ${o}(int m[${n}]) {
1659
1659
  int offset = indicesToOffset${o}(m);
1660
- vec2 coords = offsetToCoords(offset, ${a}, ${i});
1660
+ vec2 coords = offsetToCoords(offset, ${i}, ${a});
1661
1661
  float value = getColorAsFloat(${s.texture2D}(${e}, coords));
1662
1662
  return value;
1663
1663
  }
1664
- `}getPackedValueFrom(e,n,a,i,p){let o=`_${e}_Pack`;p&&(o=o+"_T");let s=G(this.context.glContext.version);return`
1664
+ `}getPackedValueFrom(e,n,i,a,p){let o=`_${e}_Pack`;p&&(o=o+"_T");let s=G(this.context.glContext.version);return`
1665
1665
  vec4 ${o}(int m[${n}]) {
1666
1666
  int offset = indicesToOffset_${e}(m);
1667
- vec2 coords = offsetToCoords(offset, ${a}, ${i});
1667
+ vec2 coords = offsetToCoords(offset, ${i}, ${a});
1668
1668
  return ${s.texture2D}(${e}, coords);
1669
1669
  }
1670
1670
  `}}}),zn,pp=O(()=>{Te(),zn=class nn extends Ht{constructor(n){super(n)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new k(`highp vec4 encode(highp float f) {
@@ -1699,7 +1699,7 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1699
1699
  highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
1700
1700
  return Result;
1701
1701
  }
1702
- `)}}static isLittleEndian(){let n=new ArrayBuffer(4),a=new Uint32Array(n),i=new Uint8Array(n);if(a[0]=3735928559,i[0]===239)return!0;if(i[0]===222)return!1;throw new Error("unknown endianness")}}}),Wn,dp=O(()=>{Te(),ut(),Wn=class extends Ht{constructor(e){super(e)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let e=G(this.context.glContext.version);return{setFragColor:new k(`
1702
+ `)}}static isLittleEndian(){let n=new ArrayBuffer(4),i=new Uint32Array(n),a=new Uint8Array(n);if(i[0]=3735928559,a[0]===239)return!0;if(a[0]===222)return!1;throw new Error("unknown endianness")}}}),Wn,dp=O(()=>{Te(),ut(),Wn=class extends Ht{constructor(e){super(e)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let e=G(this.context.glContext.version);return{setFragColor:new k(`
1703
1703
  void setFragColor(float value) {
1704
1704
  ${e.output} = encode(value);
1705
1705
  }
@@ -1707,13 +1707,13 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1707
1707
  float getColorAsFloat(vec4 color) {
1708
1708
  return decode(color);
1709
1709
  }
1710
- `,["encoding.decode"])}}}}),Hn,hp=O(()=>{Te(),Hn=class Ie extends Ht{constructor(n){super(n)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let n=this.context.outputTextureLayout.shape.length,a={};return this.context.programInfo.inputNames.forEach((i,p)=>{let o=this.context.inputTextureLayouts[p].unpackedShape;if(o.length<=n){let s=o.length,c=n-s,h=`bcastIndices_${i}`,r="";for(let l=0;l<s;++l)r+=`
1710
+ `,["encoding.decode"])}}}}),Hn,hp=O(()=>{Te(),Hn=class Ie extends Ht{constructor(n){super(n)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let n=this.context.outputTextureLayout.shape.length,i={};return this.context.programInfo.inputNames.forEach((a,p)=>{let o=this.context.inputTextureLayouts[p].unpackedShape;if(o.length<=n){let s=o.length,c=n-s,h=`bcastIndices_${a}`,r="";for(let l=0;l<s;++l)r+=`
1711
1711
  realIndices[${l}] = int( mod(float(bcastedIndices[${c+l}]), ${o[l]}.0) );
1712
1712
  `;let u=`
1713
1713
  void ${h} (int bcastedIndices[${n}], out int realIndices[${s}]) {
1714
1714
  ${r}
1715
1715
  }
1716
- `;a[h]=new k(u)}}),a}bcastMatmulIndex(){let n=this.context.outputTextureLayout.shape.length,a={};return this.context.programInfo.inputNames.forEach((i,p)=>{let o=this.context.inputTextureLayouts[p].shape;if(!(o.length<2||o.length>n)){let s=o.length,c=n-s,h=`bcastMatmulIndices_${i}`,r="";for(let l=0;l<s-2;++l)r+=`
1716
+ `;i[h]=new k(u)}}),i}bcastMatmulIndex(){let n=this.context.outputTextureLayout.shape.length,i={};return this.context.programInfo.inputNames.forEach((a,p)=>{let o=this.context.inputTextureLayouts[p].shape;if(!(o.length<2||o.length>n)){let s=o.length,c=n-s,h=`bcastMatmulIndices_${a}`,r="";for(let l=0;l<s-2;++l)r+=`
1717
1717
  realIndices[${l}] = int( mod(float(bcastedIndices[${c+l}]), ${o[l]}.0) );
1718
1718
  `;let u=`
1719
1719
  void ${h}(int bcastedIndices[${n}], out int realIndices[${s}]) {
@@ -1721,22 +1721,22 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1721
1721
  realIndices[${s-1}] = bcastedIndices[${n-1}];
1722
1722
  realIndices[${s-2}] = bcastedIndices[${n-2}];
1723
1723
  }
1724
- `;a[h]=new k(u)}}),a}indicesToOffset(){let n={};return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i].shape,o=this.context.inputTextureLayouts[i].strides,s=p.length,c=`indicesToOffset_${a}`;n[c]=new k(Ie.indexToOffsetSingle(c,s,o)),c=`indicesToOffset_${a}_T`,n[c]=new k(Ie.indexToOffsetSingle(c,s,o.slice().reverse()))}),n}static indexToOffsetSingle(n,a,i){let p="";for(let o=a-1;o>=0;--o)p+=`
1725
- offset += indices[${o}] * ${i[o]};
1724
+ `;i[h]=new k(u)}}),i}indicesToOffset(){let n={};return this.context.programInfo.inputNames.forEach((i,a)=>{let p=this.context.inputTextureLayouts[a].shape,o=this.context.inputTextureLayouts[a].strides,s=p.length,c=`indicesToOffset_${i}`;n[c]=new k(Ie.indexToOffsetSingle(c,s,o)),c=`indicesToOffset_${i}_T`,n[c]=new k(Ie.indexToOffsetSingle(c,s,o.slice().reverse()))}),n}static indexToOffsetSingle(n,i,a){let p="";for(let o=i-1;o>=0;--o)p+=`
1725
+ offset += indices[${o}] * ${a[o]};
1726
1726
  `;return`
1727
- int ${n}(int indices[${a}]) {
1727
+ int ${n}(int indices[${i}]) {
1728
1728
  int offset = 0;
1729
1729
  ${p}
1730
1730
  return offset;
1731
1731
  }
1732
- `}offsetToIndices(){let n={};return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i].shape,o=this.context.inputTextureLayouts[i].strides,s=p.length,c=`offsetToIndices_${a}`;n[c]=new k(Ie.offsetToIndicesSingle(c,s,o)),c=`offsetToIndices_${a}_T`,n[c]=new k(Ie.offsetToIndicesSingle(c,s,o.slice().reverse()))}),n}static offsetToIndicesSingle(n,a,i){let p=[];for(let o=0;o<a-1;++o)p.push(`
1733
- indices[${o}] = offset / ${i[o]};`),p.push(`
1734
- offset -= indices[${o}] * ${i[o]};`);return p.push(`
1735
- indices[${a-1}] = offset;`),`
1736
- void ${n}(int offset, out int indices[${a}]) {
1732
+ `}offsetToIndices(){let n={};return this.context.programInfo.inputNames.forEach((i,a)=>{let p=this.context.inputTextureLayouts[a].shape,o=this.context.inputTextureLayouts[a].strides,s=p.length,c=`offsetToIndices_${i}`;n[c]=new k(Ie.offsetToIndicesSingle(c,s,o)),c=`offsetToIndices_${i}_T`,n[c]=new k(Ie.offsetToIndicesSingle(c,s,o.slice().reverse()))}),n}static offsetToIndicesSingle(n,i,a){let p=[];for(let o=0;o<i-1;++o)p.push(`
1733
+ indices[${o}] = offset / ${a[o]};`),p.push(`
1734
+ offset -= indices[${o}] * ${a[o]};`);return p.push(`
1735
+ indices[${i-1}] = offset;`),`
1736
+ void ${n}(int offset, out int indices[${i}]) {
1737
1737
  ${p.join("")}
1738
1738
  }
1739
- `}incrementIndices(){let n={};return this.context.programInfo.inputNames.forEach((a,i)=>{let p=this.context.inputTextureLayouts[i].shape,o=p.length,s=`incrementIndices_${a}`,c="";for(let r=0;r<o;++r)c+=`
1739
+ `}incrementIndices(){let n={};return this.context.programInfo.inputNames.forEach((i,a)=>{let p=this.context.inputTextureLayouts[a].shape,o=p.length,s=`incrementIndices_${i}`,c="";for(let r=0;r<o;++r)c+=`
1740
1740
  shape[${r}] = ${p[r]};`;let h=`
1741
1741
  void ${s}(int axis, out int indices[${o}]) {
1742
1742
  int shape[${o}];
@@ -1750,63 +1750,63 @@ value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(e,n,a)=>Xe(
1750
1750
  indices[i] = 0;
1751
1751
  }
1752
1752
  }
1753
- `;n[s]=new k(h)}),n}}}),qn,mp=O(()=>{Te(),qn=class extends Ht{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let e=this.context.outputTextureLayout.shape.length,n={add:"+=",sub:"-=",mul:"*=",div:"/="},a={};for(let i in n){let p=`${i}Vec`,o="";for(let c=0;c<e;++c)o+=`
1754
- dest[${c}] ${n[i]} src[${c}];
1753
+ `;n[s]=new k(h)}),n}}}),qn,mp=O(()=>{Te(),qn=class extends Ht{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let e=this.context.outputTextureLayout.shape.length,n={add:"+=",sub:"-=",mul:"*=",div:"/="},i={};for(let a in n){let p=`${a}Vec`,o="";for(let c=0;c<e;++c)o+=`
1754
+ dest[${c}] ${n[a]} src[${c}];
1755
1755
  `;let s=`
1756
1756
  void ${p}(int src[${e}], out int dest[${e}]) {
1757
1757
  ${o}
1758
1758
  }
1759
- `;a[p]=new k(s)}return a}copyVec(){let e=this.context.outputTextureLayout.shape.length,n="";for(let i=0;i<e;++i)n+=`
1760
- dest[${i}] = src[${i}];
1761
- `;let a=`
1759
+ `;i[p]=new k(s)}return i}copyVec(){let e=this.context.outputTextureLayout.shape.length,n="";for(let a=0;a<e;++a)n+=`
1760
+ dest[${a}] = src[${a}];
1761
+ `;let i=`
1762
1762
  void copyVec(int src[${e}], out int dest[${e}]) {
1763
1763
  ${n}
1764
1764
  }
1765
- `;return{copyVec:new k(a)}}setVecItem(){let e=this.context.outputTextureLayout.shape.length,n=`
1765
+ `;return{copyVec:new k(i)}}setVecItem(){let e=this.context.outputTextureLayout.shape.length,n=`
1766
1766
  if(index < 0)
1767
1767
  index =${e} + index;
1768
1768
  if (index == 0)
1769
1769
  m[0] = value;
1770
- `;for(let i=1;i<e-1;++i)n+=`
1771
- else if (index == ${i})
1772
- m[${i}] = value;
1770
+ `;for(let a=1;a<e-1;++a)n+=`
1771
+ else if (index == ${a})
1772
+ m[${a}] = value;
1773
1773
  `;n+=`
1774
1774
  else
1775
1775
  m[${e-1}] = value;
1776
- `;let a=`
1776
+ `;let i=`
1777
1777
  void setVecItem(out int m[${e}], int index, int value) {
1778
1778
  ${n}
1779
1779
  }
1780
- `;return{setVecItem:new k(a)}}getVecItem(){let e=this.context.outputTextureLayout.shape.length,n=`
1780
+ `;return{setVecItem:new k(i)}}getVecItem(){let e=this.context.outputTextureLayout.shape.length,n=`
1781
1781
  if(index < 0)
1782
1782
  index = ${e} + index;
1783
1783
  if (index == 0)
1784
1784
  return m[0];
1785
- `;for(let i=1;i<e-1;++i)n+=`
1786
- else if (index == ${i})
1787
- return m[${i}];
1785
+ `;for(let a=1;a<e-1;++a)n+=`
1786
+ else if (index == ${a})
1787
+ return m[${a}];
1788
1788
  `;n+=`
1789
1789
  else
1790
1790
  return m[${e-1}];
1791
- `;let a=`
1791
+ `;let i=`
1792
1792
  int getVecItem(int m[${e}], int index) {
1793
1793
  ${n}
1794
1794
  }
1795
- `;return{getVecItem:new k(a)}}}}),Ri,bp=O(()=>{cp(),pp(),dp(),hp(),mp(),Ri={encoding:zn,fragcolor:Wn,vec:qn,shapeUtils:Hn,coordinates:Vn}}),jn,gp=O(()=>{Te(),lp(),bp(),ut(),jn=class{constructor(e,n,a,i){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Ln(e,n,a,i),Object.keys(Ri).forEach(o=>{let s=new Ri[o](this.context);this.libs[o]=s});let p=this.glslLibRoutineDependencyGraph;for(let o in this.libs){let s=this.libs[o].getFunctions();for(let c in s){let h=o+"."+c,r;p[h]?(r=p[h],r.routineBody=s[c].routineBody):(r=new Nr(h,s[c].routineBody),p[h]=r);let u=s[c].dependencies;if(u)for(let l=0;l<u.length;++l)if(p[u[l]])r.addDependency(p[u[l]]);else{let f=new Nr(u[l]);p[u[l]]=f,r.addDependency(f)}}}}preprocess(){let e=this.context.programInfo,n=e.shaderSource;return this.context.programInfo.hasMain||(n=`${n}
1795
+ `;return{getVecItem:new k(i)}}}}),Ri,bp=O(()=>{cp(),pp(),dp(),hp(),mp(),Ri={encoding:zn,fragcolor:Wn,vec:qn,shapeUtils:Hn,coordinates:Vn}}),jn,gp=O(()=>{Te(),lp(),bp(),ut(),jn=class{constructor(e,n,i,a){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Ln(e,n,i,a),Object.keys(Ri).forEach(o=>{let s=new Ri[o](this.context);this.libs[o]=s});let p=this.glslLibRoutineDependencyGraph;for(let o in this.libs){let s=this.libs[o].getFunctions();for(let c in s){let h=o+"."+c,r;p[h]?(r=p[h],r.routineBody=s[c].routineBody):(r=new Nr(h,s[c].routineBody),p[h]=r);let u=s[c].dependencies;if(u)for(let l=0;l<u.length;++l)if(p[u[l]])r.addDependency(p[u[l]]);else{let f=new Nr(u[l]);p[u[l]]=f,r.addDependency(f)}}}}preprocess(){let e=this.context.programInfo,n=e.shaderSource;return this.context.programInfo.hasMain||(n=`${n}
1796
1796
  ${Ju(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),n=up(n),`${Ku(this.context.glContext.version)}
1797
1797
  ${this.getUniforms(e.inputNames,e.variables)}
1798
1798
  ${this.getImports(n)}
1799
- ${n}`}getImports(e){let n=this.selectGlslLibRoutinesToBeIncluded(e);if(n.length===0)return"";let a="";for(let i=0;i<n.length;++i)if(n[i].routineBody)a+=n[i].routineBody+`
1800
- `;else throw new Error(`Missing body for the Glsl Library routine: ${n[i].name}`);return a}selectGlslLibRoutinesToBeIncluded(e){let n=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(a=>{let i=a.split(".")[1];e.indexOf(i)!==-1&&n.push(this.glslLibRoutineDependencyGraph[a])}),$n.returnOrderedNodes(n)}getUniforms(e,n){let a=[];if(e)for(let i of e)a.push(`uniform sampler2D ${i};`);if(n)for(let i of n)a.push(`uniform ${i.type} ${i.name}${i.arrayLength?`[${i.arrayLength}]`:""};`);return a.join(`
1801
- `)}}}),Xn,yp=O(()=>{Yt(),Ut(),gp(),ut(),Xn=class{constructor(e,n,a){this.profiler=e,this.glContext=n,this.textureLayoutStrategy=a,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,n){this.repo.set(e,n)}run(e,n,a){this.profiler.event("op",`ProgramManager.run ${e.programInfo.name??"unknown kernel"}`,()=>{let i=this.glContext.gl,p=e.program;i.useProgram(p);try{this.bindOutput(a),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,e.programInfo.variables??[],n)}catch(o){throw tt.error("ProgramManager",e.programInfo.shaderSource),o}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,n,a){return this.profiler.event("backend","ProgramManager.build",()=>{let i=new jn(this.glContext,e,n,a),p=i.preprocess(),o=this.compile(p);return{programInfo:e,program:o,uniformLocations:this.getUniformLocations(o,i.context.programInfo.inputNames,i.context.programInfo.variables),attribLocations:this.getAttribLocations(o)}})}compile(e){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let i=Xu(this.glContext.version);this.vertexShader=this.glContext.compileShader(i,this.glContext.gl.VERTEX_SHADER)}z.debug&&tt.verbose("ProrgramManager",`FragShader:
1799
+ ${n}`}getImports(e){let n=this.selectGlslLibRoutinesToBeIncluded(e);if(n.length===0)return"";let i="";for(let a=0;a<n.length;++a)if(n[a].routineBody)i+=n[a].routineBody+`
1800
+ `;else throw new Error(`Missing body for the Glsl Library routine: ${n[a].name}`);return i}selectGlslLibRoutinesToBeIncluded(e){let n=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(i=>{let a=i.split(".")[1];e.indexOf(a)!==-1&&n.push(this.glslLibRoutineDependencyGraph[i])}),$n.returnOrderedNodes(n)}getUniforms(e,n){let i=[];if(e)for(let a of e)i.push(`uniform sampler2D ${a};`);if(n)for(let a of n)i.push(`uniform ${a.type} ${a.name}${a.arrayLength?`[${a.arrayLength}]`:""};`);return i.join(`
1801
+ `)}}}),Xn,yp=O(()=>{Yt(),Ut(),gp(),ut(),Xn=class{constructor(e,n,i){this.profiler=e,this.glContext=n,this.textureLayoutStrategy=i,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,n){this.repo.set(e,n)}run(e,n,i){this.profiler.event("op",`ProgramManager.run ${e.programInfo.name??"unknown kernel"}`,()=>{let a=this.glContext.gl,p=e.program;a.useProgram(p);try{this.bindOutput(i),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,e.programInfo.variables??[],n)}catch(o){throw tt.error("ProgramManager",e.programInfo.shaderSource),o}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,n,i){return this.profiler.event("backend","ProgramManager.build",()=>{let a=new jn(this.glContext,e,n,i),p=a.preprocess(),o=this.compile(p);return{programInfo:e,program:o,uniformLocations:this.getUniformLocations(o,a.context.programInfo.inputNames,a.context.programInfo.variables),attribLocations:this.getAttribLocations(o)}})}compile(e){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let a=Xu(this.glContext.version);this.vertexShader=this.glContext.compileShader(a,this.glContext.gl.VERTEX_SHADER)}z.debug&&tt.verbose("ProrgramManager",`FragShader:
1802
1802
  ${e}
1803
- `);let n=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),a=this.glContext.createProgram(this.vertexShader,n);return this.glContext.deleteShader(n),a}bindOutput(e){let n=e.width,a=e.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${n}/${a}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,n,a)}bindAttributes(e){let n=e.position,a=e.textureCoord;this.glContext.setVertexAttributes(n,a),this.attributesBound=!0}bindUniforms(e,n,a){var o;let i=this.glContext.gl,p=0;for(let{name:s,type:c,location:h,arrayLength:r}of e){let u=(o=n.find(l=>l.name===s))==null?void 0:o.data;if(c!=="sampler2D"&&!u)throw new Error(`variable '${s}' does not have data defined in program info`);switch(c){case"sampler2D":this.bindTexture(a[p],h,p),p++;break;case"float":r?i.uniform1fv(h,u):i.uniform1f(h,u);break;case"int":r?i.uniform1iv(h,u):i.uniform1i(h,u);break;default:throw new Error(`Uniform not implemented: ${c}`)}}}bindTexture(e,n,a){this.glContext.bindTextureToUniform(e.texture,a,n)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,n,a){let i=[];if(n)for(let p of n)i.push({name:p,type:"sampler2D",location:this.getUniformLocation(e,p)});if(a)for(let p of a)i.push({...p,location:this.getUniformLocation(e,p.name)});return i}getUniformLocation(e,n){let a=this.glContext.gl.getUniformLocation(e,n);if(a===null)throw new Error(`Uniform ${n} not found.`);return a}getAttribLocation(e,n){return this.glContext.gl.getAttribLocation(e,n)}}}),Kn,xp=O(()=>{Ut(),Fr(),Kn=class{constructor(e,n,a,i){this.glContext=e,this.layoutStrategy=n,this.profiler=a,this.config=i,this.pendingRead=new Map,i.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,n,a,i){let p=this.toEncoderType(e),o=this.glContext.getEncoder(p,n.channels||1,i);if(n.isPacked&&i===1)throw new Error("not implemented");let s=n.width,c=n.height,h,r;if(this.config.reuseTextures){h=`${s}x${c}_${o.format}_${o.internalFormat}_${o.textureType}`,r=this.inUseTextures.get(h),r||(r=[],this.inUseTextures.set(h,r));let l=this.idleTextures.get(h);if(l&&l.length>0){let f=l.pop();return r.push(f),i===1&&this.glContext.updateTexture(f,s,c,o,this.toTextureData(e,a)),f}}tt.verbose("TextureManager",`Creating new texture of size ${n.width}x${n.height}`);let u=this.glContext.allocateTexture(s,c,o,this.toTextureData(e,a));return this.config.reuseTextures&&(r.push(u),this.textureLookup.set(u,h)),u}readTexture(e,n,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let i=e.shape.reduce((o,s)=>o*s)*a,p=this.glContext.readTexture(e.texture,e.width,e.height,i,this.toEncoderType(n),a);return this.toTensorData(n,p)})}async readTextureAsync(e,n,a){let i=e.tensor.dataId;if(a||(a=1),this.pendingRead.has(i)){let p=this.pendingRead.get(i);return new Promise(o=>p==null?void 0:p.push(o))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(i,[]);let p=e.shape.reduce((h,r)=>h*r)*a;await this.glContext.createAndWaitForFence();let o=this.glContext.readTexture(e.texture,e.width,e.height,p,this.toEncoderType(n),a),s=this.toTensorData(n,o),c=this.pendingRead.get(i);return this.pendingRead.delete(i),c==null||c.forEach(h=>h(s)),s})}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let n=e.shape.reduce((i,p)=>i*p),a=this.glContext.readTexture(e.texture,e.width,e.height,n*4,"byte",4);return new Float32Array(a.buffer,a.byteOffset,n)})}releaseTexture(e,n){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(e.texture),a)){n&&this.textureLookup.delete(a);let i=this.inUseTextures.get(a);if(i){let p=i.indexOf(e.texture);if(p!==-1){i.splice(p,1);let o=this.idleTextures.get(a);o||(o=[],this.idleTextures.set(a,o)),o.push(e.texture)}}}(!a||n)&&(tt.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,n){switch(e){case"int16":return n instanceof Int16Array?n:Int16Array.from(n);case"int32":return n instanceof Int32Array?n:Int32Array.from(n);case"int8":return n instanceof Int8Array?n:Int8Array.from(n);case"uint16":return n instanceof Uint16Array?n:Uint16Array.from(n);case"uint32":return n instanceof Uint32Array?n:Uint32Array.from(n);case"uint8":case"bool":return n instanceof Uint8Array?n:Uint8Array.from(n);case"float32":return n instanceof Float32Array?n:Float32Array.from(n);case"float64":return n instanceof Float64Array?n:Float64Array.from(n);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,n){if(n)return n instanceof Float32Array?n:new Float32Array(n)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}}),Jn,Tp=O(()=>{Ut(),Bs(),cl(),ap(),yp(),Ni(),xp(),Jn=class{constructor(e,n){this.backend=e,this.context=n,this.layoutStrategy=new Un(e.glContext.maxTextureSize),this.programManager=new Xn(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new Kn(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 Dn(this)}onGraphInitialized(e){let n=e.getValues().filter(a=>a.from===-1&&a.tensor).map(a=>a.tensor.dataId);this.initializers=new Set(n)}isInitializer(e){return this.initializers?this.initializers.has(e):!1}addInitializer(e){this.initializers.add(e)}getTextureData(e,n){return n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,a=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),a?this.packedTextureDataCache.set(e,n):this.unpackedTextureDataCache.set(e,n)}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,n,a){let i=ks(e,n,ip);return{impl:i.opImpl,context:i.opInit?i.opInit(e,a):e}}}});function bg(e){let n=0;for(;n<e.length&&e[n]();++n);return n-1}var Mr,wp=O(()=>{Yt(),Fr(),Fr(),pe(),Mr=class{constructor(e,n){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=e,this.version=n,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,n,a,i){let p=this.gl,o=p.createTexture();p.bindTexture(p.TEXTURE_2D,o),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);let s=i?a.encode(i,e*n):null;return p.texImage2D(p.TEXTURE_2D,0,a.internalFormat,e,n,0,a.format,a.textureType,s),this.checkError(),o}updateTexture(e,n,a,i,p){let o=this.gl;o.bindTexture(o.TEXTURE_2D,e);let s=i.encode(p,n*a);o.texSubImage2D(o.TEXTURE_2D,0,0,0,n,a,i.format,i.textureType,s),this.checkError()}attachFramebuffer(e,n,a){let i=this.gl;i.bindTexture(i.TEXTURE_2D,e),i.bindFramebuffer(i.FRAMEBUFFER,this.framebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),this.checkError(),i.viewport(0,0,n,a),i.scissor(0,0,n,a)}readTexture(e,n,a,i,p,o){let s=this.gl;o||(o=1),this.frameBufferBound||this.attachFramebuffer(e,n,a);let c=this.getEncoder(p,o),h=c.allocate(n*a);return s.bindTexture(s.TEXTURE_2D,e),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.readPixels(0,0,n,a,s.RGBA,c.textureType,h),this.checkError(),c.decode(h,i)}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,n){let a=this.gl;a.vertexAttribPointer(e,3,a.FLOAT,!1,20,0),a.enableVertexAttribArray(e),n!==-1&&(a.vertexAttribPointer(n,2,a.FLOAT,!1,20,12),a.enableVertexAttribArray(n)),this.checkError()}createProgram(e,n){let a=this.gl,i=a.createProgram();return a.attachShader(i,e),a.attachShader(i,n),a.linkProgram(i),i}compileShader(e,n){let a=this.gl,i=a.createShader(n);if(!i)throw new Error(`createShader() returned null with type ${n}`);if(a.shaderSource(i,e),a.compileShader(i),a.getShaderParameter(i,a.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${a.getShaderInfoLog(i)}
1803
+ `);let n=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),i=this.glContext.createProgram(this.vertexShader,n);return this.glContext.deleteShader(n),i}bindOutput(e){let n=e.width,i=e.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${n}/${i}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,n,i)}bindAttributes(e){let n=e.position,i=e.textureCoord;this.glContext.setVertexAttributes(n,i),this.attributesBound=!0}bindUniforms(e,n,i){var o;let a=this.glContext.gl,p=0;for(let{name:s,type:c,location:h,arrayLength:r}of e){let u=(o=n.find(l=>l.name===s))==null?void 0:o.data;if(c!=="sampler2D"&&!u)throw new Error(`variable '${s}' does not have data defined in program info`);switch(c){case"sampler2D":this.bindTexture(i[p],h,p),p++;break;case"float":r?a.uniform1fv(h,u):a.uniform1f(h,u);break;case"int":r?a.uniform1iv(h,u):a.uniform1i(h,u);break;default:throw new Error(`Uniform not implemented: ${c}`)}}}bindTexture(e,n,i){this.glContext.bindTextureToUniform(e.texture,i,n)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,n,i){let a=[];if(n)for(let p of n)a.push({name:p,type:"sampler2D",location:this.getUniformLocation(e,p)});if(i)for(let p of i)a.push({...p,location:this.getUniformLocation(e,p.name)});return a}getUniformLocation(e,n){let i=this.glContext.gl.getUniformLocation(e,n);if(i===null)throw new Error(`Uniform ${n} not found.`);return i}getAttribLocation(e,n){return this.glContext.gl.getAttribLocation(e,n)}}}),Kn,xp=O(()=>{Ut(),Fr(),Kn=class{constructor(e,n,i,a){this.glContext=e,this.layoutStrategy=n,this.profiler=i,this.config=a,this.pendingRead=new Map,a.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,n,i,a){let p=this.toEncoderType(e),o=this.glContext.getEncoder(p,n.channels||1,a);if(n.isPacked&&a===1)throw new Error("not implemented");let s=n.width,c=n.height,h,r;if(this.config.reuseTextures){h=`${s}x${c}_${o.format}_${o.internalFormat}_${o.textureType}`,r=this.inUseTextures.get(h),r||(r=[],this.inUseTextures.set(h,r));let l=this.idleTextures.get(h);if(l&&l.length>0){let f=l.pop();return r.push(f),a===1&&this.glContext.updateTexture(f,s,c,o,this.toTextureData(e,i)),f}}tt.verbose("TextureManager",`Creating new texture of size ${n.width}x${n.height}`);let u=this.glContext.allocateTexture(s,c,o,this.toTextureData(e,i));return this.config.reuseTextures&&(r.push(u),this.textureLookup.set(u,h)),u}readTexture(e,n,i){return i||(i=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let a=e.shape.reduce((o,s)=>o*s)*i,p=this.glContext.readTexture(e.texture,e.width,e.height,a,this.toEncoderType(n),i);return this.toTensorData(n,p)})}async readTextureAsync(e,n,i){let a=e.tensor.dataId;if(i||(i=1),this.pendingRead.has(a)){let p=this.pendingRead.get(a);return new Promise(o=>p==null?void 0:p.push(o))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(a,[]);let p=e.shape.reduce((h,r)=>h*r)*i;await this.glContext.createAndWaitForFence();let o=this.glContext.readTexture(e.texture,e.width,e.height,p,this.toEncoderType(n),i),s=this.toTensorData(n,o),c=this.pendingRead.get(a);return this.pendingRead.delete(a),c==null||c.forEach(h=>h(s)),s})}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let n=e.shape.reduce((a,p)=>a*p),i=this.glContext.readTexture(e.texture,e.width,e.height,n*4,"byte",4);return new Float32Array(i.buffer,i.byteOffset,n)})}releaseTexture(e,n){let i;if(this.config.reuseTextures&&(i=this.textureLookup.get(e.texture),i)){n&&this.textureLookup.delete(i);let a=this.inUseTextures.get(i);if(a){let p=a.indexOf(e.texture);if(p!==-1){a.splice(p,1);let o=this.idleTextures.get(i);o||(o=[],this.idleTextures.set(i,o)),o.push(e.texture)}}}(!i||n)&&(tt.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,n){switch(e){case"int16":return n instanceof Int16Array?n:Int16Array.from(n);case"int32":return n instanceof Int32Array?n:Int32Array.from(n);case"int8":return n instanceof Int8Array?n:Int8Array.from(n);case"uint16":return n instanceof Uint16Array?n:Uint16Array.from(n);case"uint32":return n instanceof Uint32Array?n:Uint32Array.from(n);case"uint8":case"bool":return n instanceof Uint8Array?n:Uint8Array.from(n);case"float32":return n instanceof Float32Array?n:Float32Array.from(n);case"float64":return n instanceof Float64Array?n:Float64Array.from(n);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,n){if(n)return n instanceof Float32Array?n:new Float32Array(n)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}}),Jn,Tp=O(()=>{Ut(),Bs(),cl(),ap(),yp(),Ni(),xp(),Jn=class{constructor(e,n){this.backend=e,this.context=n,this.layoutStrategy=new Un(e.glContext.maxTextureSize),this.programManager=new Xn(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new Kn(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 Dn(this)}onGraphInitialized(e){let n=e.getValues().filter(i=>i.from===-1&&i.tensor).map(i=>i.tensor.dataId);this.initializers=new Set(n)}isInitializer(e){return this.initializers?this.initializers.has(e):!1}addInitializer(e){this.initializers.add(e)}getTextureData(e,n){return n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,i=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),i?this.packedTextureDataCache.set(e,n):this.unpackedTextureDataCache.set(e,n)}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,n,i){let a=ks(e,n,ip);return{impl:a.opImpl,context:a.opInit?a.opInit(e,i):e}}}});function bg(e){let n=0;for(;n<e.length&&e[n]();++n);return n-1}var Mr,wp=O(()=>{Yt(),Fr(),Fr(),pe(),Mr=class{constructor(e,n){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=e,this.version=n,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,n,i,a){let p=this.gl,o=p.createTexture();p.bindTexture(p.TEXTURE_2D,o),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);let s=a?i.encode(a,e*n):null;return p.texImage2D(p.TEXTURE_2D,0,i.internalFormat,e,n,0,i.format,i.textureType,s),this.checkError(),o}updateTexture(e,n,i,a,p){let o=this.gl;o.bindTexture(o.TEXTURE_2D,e);let s=a.encode(p,n*i);o.texSubImage2D(o.TEXTURE_2D,0,0,0,n,i,a.format,a.textureType,s),this.checkError()}attachFramebuffer(e,n,i){let a=this.gl;a.bindTexture(a.TEXTURE_2D,e),a.bindFramebuffer(a.FRAMEBUFFER,this.framebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e,0),this.checkError(),a.viewport(0,0,n,i),a.scissor(0,0,n,i)}readTexture(e,n,i,a,p,o){let s=this.gl;o||(o=1),this.frameBufferBound||this.attachFramebuffer(e,n,i);let c=this.getEncoder(p,o),h=c.allocate(n*i);return s.bindTexture(s.TEXTURE_2D,e),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.readPixels(0,0,n,i,s.RGBA,c.textureType,h),this.checkError(),c.decode(h,a)}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,n){let i=this.gl;i.vertexAttribPointer(e,3,i.FLOAT,!1,20,0),i.enableVertexAttribArray(e),n!==-1&&(i.vertexAttribPointer(n,2,i.FLOAT,!1,20,12),i.enableVertexAttribArray(n)),this.checkError()}createProgram(e,n){let i=this.gl,a=i.createProgram();return i.attachShader(a,e),i.attachShader(a,n),i.linkProgram(a),a}compileShader(e,n){let i=this.gl,a=i.createShader(n);if(!a)throw new Error(`createShader() returned null with type ${n}`);if(i.shaderSource(a,e),i.compileShader(a),i.getShaderParameter(a,i.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${i.getShaderInfoLog(a)}
1804
1804
  Shader source:
1805
- ${e}`);return i}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,n,a){let i=this.gl;i.activeTexture(i.TEXTURE0+n),this.checkError(),i.bindTexture(i.TEXTURE_2D,e),this.checkError(),i.uniform1i(a,n),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(z.debug){let e=this.gl,n=e.getError(),a="";switch(n){case e.NO_ERROR:return;case e.INVALID_ENUM:a="INVALID_ENUM";break;case e.INVALID_VALUE:a="INVALID_VALUE";break;case e.INVALID_OPERATION:a="INVALID_OPERATION";break;case e.INVALID_FRAMEBUFFER_OPERATION:a="INVALID_FRAMEBUFFER_OPERATION";break;case e.OUT_OF_MEMORY:a="OUT_OF_MEMORY";break;case e.CONTEXT_LOST_WEBGL:a="CONTEXT_LOST_WEBGL";break;default:a=`Unknown WebGL Error: ${n.toString(16)}`}throw new Error(a)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,n,a=0){if(this.version===2)return new Pn(this.gl,n);switch(e){case"float":return a===1||this.isRenderFloat32Supported?new Br(this.gl,n):new Br(this.gl,n,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new En(this.gl,n);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){let e=this.gl;for(let n=0;n<this.maxTextureImageUnits;++n)e.activeTexture(e.TEXTURE0+n),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,n=e.createBuffer();if(!n)throw new Error("createBuffer() returned null");let a=this.createDefaultGeometry();return e.bindBuffer(e.ARRAY_BUFFER,n),e.bufferData(e.ARRAY_BUFFER,a,e.STATIC_DRAW),this.checkError(),n}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,n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let a=this.version===2?e.RGBA32F:e.RGBA;e.texImage2D(e.TEXTURE_2D,0,a,1,1,0,e.RGBA,e.FLOAT,null);let i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);let p=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(i),p}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,n,a,i,p,o;try{n=e.createTexture(),a=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,n);let s=this.version===2?e.RGBA32F:e.RGBA;return e.texImage2D(e.TEXTURE_2D,0,s,1,1,0,e.RGBA,e.FLOAT,null),e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.enable(e.BLEND),i=e.createShader(e.VERTEX_SHADER),!i||(e.shaderSource(i,"void main(){}"),e.compileShader(i),p=e.createShader(e.FRAGMENT_SHADER),!p)||(e.shaderSource(p,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),e.compileShader(p),o=e.createProgram(),!o)?!1:(e.attachShader(o,i),e.attachShader(o,p),e.linkProgram(o),e.useProgram(o),e.drawArrays(e.POINTS,0,1),e.getError()===e.NO_ERROR)}finally{e.disable(e.BLEND),o&&e.deleteProgram(o),i&&e.deleteShader(i),p&&e.deleteShader(p),a&&(e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(a)),n&&(e.bindTexture(e.TEXTURE_2D,null),e.deleteTexture(n))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,n=this.disjointTimerQueryWebgl2Extension,a=e.createQuery();return e.beginQuery(n.TIME_ELAPSED_EXT,a),a}else throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,n=this.disjointTimerQueryWebgl2Extension;e.endQuery(n.TIME_ELAPSED_EXT);return}else throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(e){let n=!1,a=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let i=this.gl,p=this.disjointTimerQueryWebgl2Extension;n=i.getQueryParameter(e,i.QUERY_RESULT_AVAILABLE),a=i.getParameter(p.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return n&&!a}getTimerResult(e){let n=0;if(this.version===2){let a=this.gl;n=a.getQueryParameter(e,a.QUERY_RESULT),a.deleteQuery(e)}else throw new Error("WebGL1 profiling currently not supported");return n/1e6}async waitForQueryAndGetTime(e){return await li(()=>this.isTimerResultAvailable(e)),this.getTimerResult(e)}async createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let n,a=e,i=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),i===null?n=()=>!0:n=()=>{let p=a.clientWaitSync(i,0,0);return p===a.ALREADY_SIGNALED||p===a.CONDITION_SATISFIED},{query:i,isFencePassed:n}}async pollFence(e){return new Promise(n=>{this.addItemToPoll(()=>e.isFencePassed(),()=>n())})}pollItems(){let e=bg(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=e;++n){let{resolveFn:a}=this.itemsToPoll[n];a()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,n){this.itemsToPoll.push({isDoneFn:e,resolveFn:n}),!(this.itemsToPoll.length>1)&&await li(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Gi(e){let n;if((!e||e==="webgl2")&&"webgl2"in mr?n=mr.webgl2:(!e||e==="webgl")&&"webgl"in mr&&(n=mr.webgl),!n)try{let i=yg();n=vp(i,e)}catch{let i=gg();n=vp(i,e)}e=e||n.version===1?"webgl":"webgl2";let a=n.gl;return mr[e]=n,a.isContextLost()?(delete mr[e],Gi(e)):(a.disable(a.DEPTH_TEST),a.disable(a.STENCIL_TEST),a.disable(a.BLEND),a.disable(a.DITHER),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SAMPLE_COVERAGE),a.enable(a.SCISSOR_TEST),a.enable(a.CULL_FACE),a.cullFace(a.BACK),n)}function vp(e,n){let a={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},i,p=a;if((!n||n==="webgl2")&&(i=e.getContext("webgl2",p),i))try{return new Mr(i,2)}catch(o){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${o}`)}if((!n||n==="webgl")&&(i=e.getContext("webgl",p)||e.getContext("experimental-webgl",p),i))try{return new Mr(i,1)}catch(o){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${o}`)}throw new Error("WebGL is not supported")}function gg(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let e=document.createElement("canvas");return e.width=1,e.height=1,e}function yg(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var mr,Ip=O(()=>{Ut(),wp(),mr={}}),Yn,_p=O(()=>{Yt(),Ut(),Tp(),Ip(),Yn=class{get contextId(){return z.webgl.contextId}set contextId(e){z.webgl.contextId=e}get matmulMaxBatchSize(){return z.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){z.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return z.webgl.textureCacheMode}set textureCacheMode(e){z.webgl.textureCacheMode=e}get pack(){return z.webgl.pack}set pack(e){z.webgl.pack=e}get async(){return z.webgl.async}set async(e){z.webgl.async=e}initialize(){try{return this.glContext=Gi(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),tt.setWithEnv(z),z.webgl.context||Object.defineProperty(z.webgl,"context",{value:this.glContext.gl}),tt.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return tt.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new Jn(this,e)}dispose(){this.glContext.dispose()}}});async function Mi(e){if(e){let n=typeof e=="string"?[e]:e;for(let a of n){let i=Op.get(a);if(i)return i;let p=await Tg(a);if(p)return p}}else return Mi(["webgl"]);throw new Error("no available backend to use")}async function Tg(e){let n=xg;if(typeof n[e]<"u"&&wg(n[e])){let a=n[e],i=a.initialize();if(typeof i=="object"&&"then"in i&&(i=await i),i)return Op.set(e,a),a}}function wg(e){let n=e;return"initialize"in n&&typeof n.initialize=="function"&&"createSessionHandler"in n&&typeof n.createSessionHandler=="function"&&"dispose"in n&&typeof n.dispose=="function"}var Op,xg,Sp=O(()=>{_p(),Op=new Map,xg={webgl:new Yn}}),Ui,Zn,Ap=O(()=>{Ut(),Ui=class{constructor(e,n){this.op=e,this.node=n}},Zn=class{constructor(e,n,a){this.graph=e,this.profiler=a,this.initialize(n)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",()=>{let n=this.graph.getNodes();if(n.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map((a,i)=>new Ui(a,n[i])),this.reset(),this._starter=[],this._ops.forEach((a,i)=>{let p=!0;for(let o of a.node.inputs)if(!this._values[o]&&this.graph.getInputIndices().indexOf(o)===-1){p=!1;break}p&&this._starter.push(i)})})}reset(){this._values=this.graph.getValues().map(e=>e.tensor)}async execute(e,n){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let a=e.createInferenceHandler(),i=this.graph.getInputIndices();if(n.length!==i.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${n.length} expected: ${i.length}`);n.forEach((r,u)=>{let l=i[u];this._values[l]=r});let p=this._starter.slice(0),o=this.graph.getValues(),s=this.graph.getNodes(),c=0;for(;c<p.length;){let r=p[c++],u=this._ops[r],l=u.node.inputs.map(v=>this._values[v]);if(l.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${u.node}`);let f=l;tt.verbose("ExecPlan",`Running op:${u.node.name} (${f.map((v,S)=>`'${u.node.inputs[S]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);let g=await this.profiler.event("node",u.node.name,async()=>u.op.impl(a,f,u.op.context));if(g.length!==u.node.outputs.length)throw new Error("the size of output does not match model definition.");g.forEach((v,S)=>{let P=u.node.outputs[S];if(this._values[P])throw new Error(`output [${P}] already has value: op:${u.node.name}`);this._values[P]=v});let b=new Set;g.forEach((v,S)=>{let P=u.node.outputs[S];for(let _ of o[P].to){let A=s[_],L=!0;for(let V of A.inputs)if(!this._values[V]){L=!1;break}L&&b.add(_)}}),p.push(...b)}let h=[];for(let r=0;r<this.graph.getOutputIndices().length;r++){let u=this.graph.getOutputIndices()[r],l=this._values[u];if(l===void 0)throw new Error(`required output [${u}] does not have value`);u===0?await l.getData():l.data,h.push(l)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),a.dispose(),h})}}}),q,Xt,Ur,Pp=O(()=>{Pr(),q=rr(sr()),We(),Y(),Xt=F.experimental.fbs,Ur=class Ae{constructor(n){if(this._attributes=new Map,n!=null){for(let a of n)a instanceof q.onnx.AttributeProto?this._attributes.set(a.name,[Ae.getValue(a),Ae.getType(a)]):a instanceof Xt.Attribute&&this._attributes.set(a.name(),[Ae.getValue(a),Ae.getType(a)]);if(this._attributes.size<n.length)throw new Error("duplicated attribute names")}}set(n,a,i){this._attributes.set(n,[i,a])}delete(n){this._attributes.delete(n)}getFloat(n,a){return this.get(n,"float",a)}getInt(n,a){return this.get(n,"int",a)}getString(n,a){return this.get(n,"string",a)}getTensor(n,a){return this.get(n,"tensor",a)}getFloats(n,a){return this.get(n,"floats",a)}getInts(n,a){return this.get(n,"ints",a)}getStrings(n,a){return this.get(n,"strings",a)}getTensors(n,a){return this.get(n,"tensors",a)}get(n,a,i){let p=this._attributes.get(n);if(p===void 0){if(i!==void 0)return i;throw new Error(`required attribute not found: ${n}`)}if(p[1]!==a)throw new Error(`type mismatch: expected ${a} but got ${p[1]}`);return p[0]}static getType(n){let a=n instanceof q.onnx.AttributeProto?n.type:n.type();switch(a){case q.onnx.AttributeProto.AttributeType.FLOAT:return"float";case q.onnx.AttributeProto.AttributeType.INT:return"int";case q.onnx.AttributeProto.AttributeType.STRING:return"string";case q.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case q.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case q.onnx.AttributeProto.AttributeType.INTS:return"ints";case q.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case q.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${q.onnx.AttributeProto.AttributeType[a]}`)}}static getValue(n){let a=n instanceof q.onnx.AttributeProto?n.type:n.type();if(a===q.onnx.AttributeProto.AttributeType.GRAPH||a===q.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let i=this.getValueNoCheck(n);if(a===q.onnx.AttributeProto.AttributeType.INT&&Rt.isLong(i))return Rt.longToNumber(i);if(a===q.onnx.AttributeProto.AttributeType.INTS){let p=i,o=new Array(p.length);for(let s=0;s<p.length;s++){let c=p[s];o[s]=Rt.longToNumber(c)}return o}if(a===q.onnx.AttributeProto.AttributeType.TENSOR)return n instanceof q.onnx.AttributeProto?bt.fromProto(i):bt.fromOrtTensor(i);if(a===q.onnx.AttributeProto.AttributeType.TENSORS){if(n instanceof q.onnx.AttributeProto)return i.map(p=>bt.fromProto(p));if(n instanceof Xt.Attribute)return i.map(p=>bt.fromOrtTensor(p))}return a===q.onnx.AttributeProto.AttributeType.STRING&&n instanceof q.onnx.AttributeProto?kr(i):a===q.onnx.AttributeProto.AttributeType.STRINGS&&n instanceof q.onnx.AttributeProto?i.map(kr):i}static getValueNoCheck(n){return n instanceof q.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(n):this.getValueNoCheckFromOrtFormat(n)}static getValueNoCheckFromOnnxFormat(n){switch(n.type){case q.onnx.AttributeProto.AttributeType.FLOAT:return n.f;case q.onnx.AttributeProto.AttributeType.INT:return n.i;case q.onnx.AttributeProto.AttributeType.STRING:return n.s;case q.onnx.AttributeProto.AttributeType.TENSOR:return n.t;case q.onnx.AttributeProto.AttributeType.GRAPH:return n.g;case q.onnx.AttributeProto.AttributeType.FLOATS:return n.floats;case q.onnx.AttributeProto.AttributeType.INTS:return n.ints;case q.onnx.AttributeProto.AttributeType.STRINGS:return n.strings;case q.onnx.AttributeProto.AttributeType.TENSORS:return n.tensors;case q.onnx.AttributeProto.AttributeType.GRAPHS:return n.graphs;default:throw new Error(`unsupported attribute type: ${q.onnx.AttributeProto.AttributeType[n.type]}`)}}static getValueNoCheckFromOrtFormat(n){switch(n.type()){case Xt.AttributeType.FLOAT:return n.f();case Xt.AttributeType.INT:return n.i();case Xt.AttributeType.STRING:return n.s();case Xt.AttributeType.TENSOR:return n.t();case Xt.AttributeType.GRAPH:return n.g();case Xt.AttributeType.FLOATS:return n.floatsArray();case Xt.AttributeType.INTS:{let a=[];for(let i=0;i<n.intsLength();i++)a.push(n.ints(i));return a}case Xt.AttributeType.STRINGS:{let a=[];for(let i=0;i<n.stringsLength();i++)a.push(n.strings(i));return a}case Xt.AttributeType.TENSORS:{let a=[];for(let i=0;i<n.tensorsLength();i++)a.push(n.tensors(i));return a}default:throw new Error(`unsupported attribute type: ${Xt.AttributeType[n.type()]}`)}}}}),zi,Qn,Wi,me,to,Vi,Ep=O(()=>{Pp(),Pr(),zi=rr(sr()),We(),Y(),Qn=F.experimental.fbs,Wi={from:(e,n)=>new Vi(e,n)},me=class{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=At.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}},to=class{constructor(e,n){e instanceof zi.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new Ur(e.attribute)):e instanceof Qn.Node&&(this.name=n??e.name(),this.opType=e.opType(),this.attributes=new Ur(At.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Vi=class{constructor(e,n){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(n),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(e){if(e instanceof zi.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else if(e instanceof Qn.Graph)this.buildGraphFromOrtFormat(e);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(e){let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let a=new Map;if(!e.input)throw new Error("missing information in graph: input");let i=[];for(let p of e.input){if(n.has(p.name))throw new Error(`duplicated input name: ${p.name}`);let o=this._allData.push(new me(p))-1;n.set(p.name,o),i.push(p.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(let p of e.initializer){let o=n.get(p.name);if(o===void 0){let s=new me;s.type={shape:{dims:At.tensorDimsFromProto(p.dims)},tensorType:At.tensorDataTypeFromProto(p.dataType)},o=this._allData.push(s)-1,n.set(p.name,o)}this._allData[o]._from=-1,this._allData[o].tensor=bt.fromProto(p)}for(let p=0;p<this._allData.length;p++)this._allData[p].tensor||(this._allInputIndices.push(p),this._allInputNames.push(i[p]));if(!e.output)throw new Error("missing information in graph: output");for(let p of e.output){if(n.has(p.name))throw new Error(`duplicated output name: ${p.name}`);let o=this._allData.push(new me(p))-1;n.set(p.name,o),this._allOutputIndices.push(o),this._allOutputNames.push(p.name)}if(!e.node)throw new Error("missing information in graph: node");for(let p of e.node){if(!p.name)for(let s=0;;s++){let c=`unnamed_${p.opType}_${s}`;if(!a.has(c)){p.name=c;break}}if(a.has(p.name))throw new Error(`duplicated node name: ${p.name}`);let o=this._nodes.push(new to(p))-1;a.set(p.name,o)}for(let p=0;p<this._nodes.length;p++){let o=this._nodes[p],s=e.node[p];if(!s.output)throw new Error(`missing output for node: ${s.name}`);for(let c of s.output){let h=n.get(c);if(typeof h>"u"&&(h=this._allData.push(new me)-1,n.set(c,h)),o.outputs.push(h),this._allData[h]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${h}`);if(this._allData[h]._from=p,s.opType==="Constant"){if(!s.attribute||s.attribute.length!==1||!s.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!s.output||s.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");o.outputs.pop(),o.executeNode=!1,this._allData[h]._from=-1,this._allData[h].tensor=bt.fromProto(s.attribute[0].t)}}}for(let p=0;p<this._nodes.length;p++){let o=this._nodes[p],s=e.node[p];if(!s.input)throw new Error(`missing input for node: ${s.name}`);for(let c of s.input){let h=n.get(c);if(typeof h>"u"){if(c===""&&(s.input.length===3||s.input.length===4)&&s.opType==="Resize")continue;throw new Error(`unrecognized input '${c}' for node: ${s.name}`)}o.inputs.push(h),this._allData[h]._to.push(p)}}return!0}buildGraphFromOrtFormat(e){var p,o,s;let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let a=new Map,i=[];for(let c=0;c<e.inputsLength();c++){let h=e.inputs(c);if(n.has(h))throw new Error(`duplicated input name: ${h}`);for(let r=0;r<e.nodeArgsLength();r++)if(((p=e.nodeArgs(r))==null?void 0:p.name())===h){let u=new me;if(((s=(o=e.nodeArgs(r))==null?void 0:o.type())==null?void 0:s.valueType())!==Qn.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let l=e.nodeArgs(r).type().value(new Qn.TensorTypeAndShape),f=At.tensorDataTypeFromProto(l.elemType()),g=l.shape(),b=[];for(let S=0;S<g.dimLength();S++)b.push(Rt.longToNumber(g.dim(S).value().dimValue()));u.type={shape:{dims:b},tensorType:f};let v=this._allData.push(u)-1;n.set(h,v),i.push(h)}}for(let c=0;c<e.initializersLength();c++){let h=e.initializers(c),r=n.get(h.name());if(r===void 0){let u=new me,l=At.tensorDimsFromORTFormat(h),f=At.tensorDataTypeFromProto(h.dataType());u.type={shape:{dims:l},tensorType:f},r=this._allData.push(u)-1,n.set(h.name(),r)}this._allData[r]._from=-1,this._allData[r].tensor=bt.fromOrtTensor(h)}for(let c=0;c<this._allData.length;c++)this._allData[c].tensor||(this._allInputIndices.push(c),this._allInputNames.push(i[c]));for(let c=0;c<e.outputsLength();c++){let h=e.outputs(c);if(n.has(h))throw new Error(`duplicated output name: ${h}`);let r=this._allData.push(new me)-1;n.set(h,r),this._allOutputIndices.push(r),this._allOutputNames.push(h)}if(!e.nodes)throw new Error("missing information in graph: node");for(let c=0;c<e.nodesLength();c++){let h=e.nodes(c),r=h.name();if(!r)for(let l=0;r=`unnamed_${h.opType()}_${l}`,!!a.has(r);l++);if(a.has(r))throw new Error(`duplicated node name: ${r}`);let u=this._nodes.push(new to(h,r))-1;a.set(r,u)}for(let c=0;c<this._nodes.length;c++){let h=this._nodes[c],r=e.nodes(c);if(r==null)throw new Error(`No node exists at index ${c}`);if((r==null?void 0:r.outputsLength())===0)throw new Error(`missing output for node: ${r.name}`);for(let u=0;u<(r==null?void 0:r.outputsLength());u++){let l=r==null?void 0:r.outputs(u),f=n.get(l);if(typeof f>"u"&&(f=this._allData.push(new me)-1,n.set(l,f)),h.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=c,r.opType()==="Constant"){if(r.attributesLength()!==1||!r.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(r.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");h.outputs.pop(),h.executeNode=!1,this._allData[f]._from=-1,this._allData[f].tensor=bt.fromOrtTensor(r.attributes(0).t())}}}for(let c=0;c<this._nodes.length;c++){let h=this._nodes[c],r=e.nodes(c);if(r.inputsLength()===0)throw new Error(`missing input for node: ${r.name}`);for(let u=0;u<r.inputsLength();u++){let l=r.inputs(u),f=n.get(l);if(typeof f>"u")throw new Error(`unrecognized input '${l}' for node: ${r.name()}`);h.inputs.push(f),this._allData[f]._to.push(c)}}}checkIsAcyclic(){let e=new Set;this._allInputIndices.forEach(i=>{this._allData[i]._to.forEach(p=>{e.add(p)})});let n=Array.from(e),a=new Array(this._nodes.length).fill("white");for(;n.length>0;){let i=n.pop();a[i]==="gray"?a[i]="black":(n.push(i),a[i]="gray",this._nodes[i].outputs.forEach(p=>{let o=this._allData[p];if(typeof o.tensor<"u")throw new Error("node outputs should not be initialized");if(o._from!==i)throw new Error("from property of the Value object doesn't match index of Node being processed");o._to.forEach(s=>{if(a[s]==="gray")throw new Error("model graph is cyclic");a[s]==="white"&&n.push(s)})}))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0,n=new Array(this._nodes.length,0),a=0;for(let i=0;i<this._nodes.length;i++)n[i]=a,this._nodes[i].executeNode?(a!==i&&(this._nodes[a]=this._nodes[i]),a++):this._nodes[i].outputs.forEach(p=>{this._allData[p]._from=-2});this._nodes.splice(a,this._nodes.length-a);for(let i=0;i<this._allData.length;i++){let p=this._allData[i];p._from!==void 0&&p._from!==-1&&p._from!==-2&&(p._from=n[p._from]);for(let o=0;o<p._to.length;o++)if(p._to[o]>=0)p._to[o]=n[p._to[o]];else throw new Error("Trying to update a removed node")}e=0;for(let i=0;i<this._allData.length;i++){if(this._allData[i].from===-2&&this._allOutputIndices.indexOf(i+e)===-1){e++,this._allData.splice(i,1),i--;continue}if(e>0){let p=-1;this._allData[i].from!==void 0&&this._allData[i].from!==-1?(p=this._nodes[this._allData[i].from].outputs.indexOf(i+e),p!==-1&&(this._nodes[this._allData[i].from].outputs[p]=i)):(p=this._allInputIndices.indexOf(i+e),p!==-1&&(this._allInputIndices[p]=i)),this._allData[i].to.forEach(o=>{p=this._nodes[o].inputs.indexOf(i+e),p!==-1&&(this._nodes[o].inputs[p]=i)}),this._allData[i].to.length===0&&(p=this._allOutputIndices.indexOf(i+e),p!==-1&&(this._allOutputIndices[p]=i))}}}deleteNode(e){let n=this._nodes[e];if(n.outputs.length>1){for(let s=1;s<n.outputs.length;s++)if(this._allData[n.outputs[s]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}n.executeNode=!1;let a=n.inputs[0],i=n.outputs[0],p=this._allData[i].to;for(let s=0;s<n.inputs.length;s++){let c=this._allData[n.inputs[s]].to.indexOf(e);if(c===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[n.inputs[s]].to.splice(c,1)}this._allData[i]._to=[];let o=this._allOutputIndices.indexOf(i);if(o!==-1&&(this._allOutputIndices[o]=a),p&&p.length>0)for(let s of p){let c=this._nodes[s].inputs.indexOf(i);if(c===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[s].inputs[c]=a,this._allData[a].to.push(s)}}removeAllDropoutNodes(){let e=0;for(let n of this._nodes){if(n.opType==="Dropout"){if(n.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(n.outputs.length!==1&&n.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(n.outputs.length===2&&this._allData[n.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 n of this._nodes)n.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 n=this._allData[e.outputs[0]]._to;if(n.length===1&&this.isActivation(this._nodes[n[0]])){let a=this._nodes[n[0]];if(a.opType==="Clip")if(a.inputs.length===1)try{e.attributes.set("activation_params","floats",[a.attributes.getFloat("min"),a.attributes.getFloat("max")])}catch{e.attributes.set("activation_params","floats",[Ve,ze])}else if(a.inputs.length>=3&&this._allData[a.inputs[1]].tensor!==void 0&&this._allData[a.inputs[2]].tensor!==void 0)e.attributes.set("activation_params","floats",[this._allData[a.inputs[1]].tensor.floatData[0],this._allData[a.inputs[2]].tensor.floatData[0]]);else continue;e.attributes.set("activation","string",a.opType),this.deleteNode(n[0])}}}}}),Dp,vg,eo,Lp=O(()=>{wn(),Ep(),Pr(),Dp=rr(sr()),Y(),vg=F.experimental.fbs,eo=class{constructor(){}load(e,n,a){let i;if(!a)try{this.loadFromOnnxFormat(e,n);return}catch(p){if(a!==void 0)throw p;i=p}try{this.loadFromOrtFormat(e,n)}catch(p){throw a!==void 0?p:new Error(`Failed to load model as ONNX format: ${i}
1806
- as ORT format: ${p}`)}}loadFromOnnxFormat(e,n){let a=Dp.onnx.ModelProto.decode(e);if(Rt.longToNumber(a.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=a.opsetImport.map(i=>({domain:i.domain,version:Rt.longToNumber(i.version)})),this._graph=Wi.from(a.graph,n)}loadFromOrtFormat(e,n){let a=new w.ByteBuffer(e),i=vg.InferenceSession.getRootAsInferenceSession(a).model();if(Rt.longToNumber(i.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let p=0;p<i.opsetImportLength();p++){let o=i.opsetImport(p);this._opsets.push({domain:o==null?void 0:o.domain(),version:Rt.longToNumber(o.version())})}this._graph=Wi.from(i.graph(),n)}get graph(){return this._graph}get opsets(){return this._opsets}}}),ro,$p=O(()=>{Sp(),Ap(),Ut(),Lp(),ro=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=xn.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,n,a){await this.profiler.event("session","Session.loadModel",async()=>{let i=await Mi(this.backendHint);if(this.sessionHandler=i.createSessionHandler(this.context),this._model=new eo,typeof e=="string"){let p=e.endsWith(".ort");{let o=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(o),p)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{let p=new Uint8Array(e,n||0,a||e.byteLength);this.initialize(p)}})}initialize(e,n){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let a=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,a,n),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new Zn(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 n=this.normalizeAndValidateInputs(e),a=await this._executionPlan.execute(this.sessionHandler,n);return this.createOutput(a)})}normalizeAndValidateInputs(e){let n=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==n.length)throw new Error(`incorrect input array length: expected ${n.length} but got ${e.length}`)}else{if(e.size!==n.length)throw new Error(`incorrect input map size: expected ${n.length} but got ${e.size}`);let a=new Array(e.size),i=0;for(let p=0;p<n.length;++p){let o=e.get(n[p]);if(!o)throw new Error(`missing input tensor for: '${name}'`);a[i++]=o}e=a}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){let a=this._model.graph.getInputIndices(),i=this._model.graph.getValues(),p=new Array(a.length);for(let o=0;o<a.length;++o){let s=i[a[o]];p[o]=s.type.shape.dims,this.context.graphInputTypes.push(s.type.tensorType),this.context.graphInputDims.push(e[o].dims)}this.validateInputTensorDims(p,e,!0)}else this.validateInputTensorDims(this.context.graphInputDims,e,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,e),e}validateInputTensorTypes(e,n){for(let a=0;a<n.length;a++){let i=e[a],p=n[a].type;if(i!==p)throw new Error(`input tensor[${a}] check failed: expected type '${i}' but got ${p}`)}}validateInputTensorDims(e,n,a){for(let i=0;i<n.length;i++){let p=e[i],o=n[i].dims;if(!this.compareTensorDims(p,o,a))throw new Error(`input tensor[${i}] check failed: expected shape '[${p.join(",")}]' but got [${o.join(",")}]`)}}compareTensorDims(e,n,a){if(e.length!==n.length)return!1;for(let i=0;i<e.length;++i)if(e[i]!==n[i]&&(!a||e[i]!==0))return!1;return!0}createOutput(e){let n=this._model.graph.getOutputNames();if(e.length!==n.length)throw new Error("expected number of outputs do not match number of generated outputs");let a=new Map;for(let i=0;i<n.length;++i)a.set(n[i],e[i]);return a}initializeOps(e){let n=e.getNodes();this._ops=new Array(n.length);for(let a=0;a<n.length;a++)this._ops[a]=this.sessionHandler.resolve(n[a],this._model.opsets,e)}}}),no,kp=O(()=>{Yt(),We(),no=class{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,n,a){let i=new Map;for(let s in e)if(Object.hasOwnProperty.call(e,s)){let c=e[s];i.set(s,new bt(c.dims,c.type,void 0,void 0,c.data))}let p=await this.session.run(i),o={};return p.forEach((s,c)=>{o[c]=new yt(s.type,s.data,s.dims)}),o}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),Bp={};Or(Bp,{onnxjsBackend:()=>Ig});var Hi,Ig,Fp=O(()=>{$p(),kp(),Hi=class{async init(){}async createInferenceSessionHandler(e,n){let a=new ro(n);return typeof e=="string"?await a.loadModel(e):await a.loadModel(e),new no(a)}},Ig=new Hi}),oo=O(()=>{}),Rp={};Or(Rp,{default:()=>_g});var Cp,Np,_g,Gp=O(()=>{var e;qi(),Ke(),Vr(),Cp="ort-wasm-proxy-worker",Np=((e=globalThis.self)==null?void 0:e.name)===Cp,Np&&(self.onmessage=n=>{let{type:a,in:i}=n.data;try{switch(a){case"init-wasm":io(i.wasm).then(()=>{ao(i).then(()=>{postMessage({type:a})},p=>{postMessage({type:a,err:p})})},p=>{postMessage({type:a,err:p})});break;case"init-ep":{let{epName:p,env:o}=i;so(o,p).then(()=>{postMessage({type:a})},s=>{postMessage({type:a,err:s})});break}case"copy-from":{let{buffer:p}=i,o=zr(p);postMessage({type:a,out:o});break}case"create":{let{model:p,options:o}=i;uo(p,o).then(s=>{postMessage({type:a,out:s})},s=>{postMessage({type:a,err:s})});break}case"release":lo(i),postMessage({type:a});break;case"run":{let{sessionId:p,inputIndices:o,inputs:s,outputIndices:c,options:h}=i;fo(p,o,s,c,new Array(c.length).fill(null),h).then(r=>{r.some(u=>u[3]!=="cpu")?postMessage({type:a,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:a,out:r},po([...s,...r]))},r=>{postMessage({type:a,err:r})});break}case"end-profiling":co(i),postMessage({type:a});break;default:}}catch(p){postMessage({type:a,err:p})}}),_g=Np?null:n=>new Worker(n??br,{type:"module",name:Cp})}),Up={};Or(Up,{default:()=>Og});var ji,Mp,Og,Vp=O(()=>{var e;Mp=(ji=_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href,async function(n={}){function a(){return gt.buffer!=wt.buffer&&at(),wt}function i(){return gt.buffer!=wt.buffer&&at(),X}function p(){return gt.buffer!=wt.buffer&&at(),Wt}function o(){return gt.buffer!=wt.buffer&&at(),Le}function s(){return gt.buffer!=wt.buffer&&at(),se}var c,h,r=Object.assign({},n),u=new Promise((m,y)=>{c=m,h=y}),l=typeof window=="object",f=typeof importScripts=="function",g=f&&self.name=="em-pthread";r.mountExternalData=(m,y)=>{m.startsWith("./")&&(m=m.substring(2)),(r.Ua||(r.Ua=new Map)).set(m,y)},r.unmountExternalData=()=>{delete r.Ua};var b,v,S=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,P=Object.assign({},r),_="./this.program",A=(m,y)=>{throw y},L="";(l||f)&&(f?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),ji&&(L=ji),L=L.startsWith("blob:")?"":L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1),f&&(v=m=>{var y=new XMLHttpRequest;return y.open("GET",m,!1),y.responseType="arraybuffer",y.send(null),new Uint8Array(y.response)}),b=(m,y,x)=>{var E=new XMLHttpRequest;E.open("GET",m,!0),E.responseType="arraybuffer",E.onload=()=>{E.status==200||E.status==0&&E.response?y(E.response):x()},E.onerror=x,E.send(null)});var V,ft=console.log.bind(console),lt=console.error.bind(console),Nt=ft,Q=lt;if(Object.assign(r,P),P=null,g){let m=function(y){try{var x=y.data,E=x.cmd;if(E==="load"){let I=[];self.onmessage=N=>I.push(N),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let N of I)m(N);self.onmessage=m};for(let N of x.handlers)r[N]&&!r[N].proxy||(r[N]=(...R)=>{postMessage({Za:"callHandler",kb:N,args:R})},N=="print"&&(Nt=r[N]),N=="printErr"&&(Q=r[N]));gt=x.wasmMemory,at(),Pt(x.wasmModule)}else if(E==="run"){Zr(x.pthread_ptr,0,0,1,0,0),Dr(x.pthread_ptr),Pa(),Oo(),$e||($e=!0);try{Aa(x.start_routine,x.arg)}catch(I){if(I!="unwind")throw I}}else E==="cancel"?ue()&&ar(-1):x.target!=="setimmediate"&&(E==="checkMailbox"?$e&&Qe():E&&(Q(`worker: received unknown command ${E}`),Q(x)))}catch(I){throw ma(),I}};var Pt,$e=!1;Q=function(...y){y=y.join(" "),console.error(y)},self.alert=function(...y){postMessage({Za:"alert",text:y.join(" "),nb:ue()})},r.instantiateWasm=(y,x)=>new Promise(E=>{Pt=I=>{I=new WebAssembly.Instance(I,on()),x(I),E()}}),self.onunhandledrejection=y=>{throw y.reason||y},self.onmessage=m}r.wasmBinary&&(V=r.wasmBinary);var gt,De,Ft,wt,X,Wt,Le,_t,se,it=!1;function at(){var m=gt.buffer;r.HEAP8=wt=new Int8Array(m),r.HEAP16=new Int16Array(m),r.HEAPU8=X=new Uint8Array(m),r.HEAPU16=new Uint16Array(m),r.HEAP32=Wt=new Int32Array(m),r.HEAPU32=Le=new Uint32Array(m),r.HEAPF32=new Float32Array(m),r.HEAPF64=se=new Float64Array(m),r.HEAP64=_t=new BigInt64Array(m),r.HEAPU64=new BigUint64Array(m)}if(!g){if(!((gt=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof S))throw Q("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),Error("bad memory");at()}var re=[],Jt=[],Re=[],oe=0,Ot=null;function $t(){if(--oe==0&&Ot){var m=Ot;Ot=null,m()}}function Lt(m){throw Q(m="Aborted("+m+")"),it=!0,Ft=1,m=new WebAssembly.RuntimeError(m+". Build with -sASSERTIONS for more info."),h(m),m}var nt,st=m=>m.startsWith("data:application/octet-stream;base64,"),Mt=m=>m.startsWith("file://");function ce(m){if(m==nt&&V)return new Uint8Array(V);if(v)return v(m);throw"both async and sync fetching of the wasm failed"}function Ge(m,y,x){return function(E){if(!V&&(l||f)){if(typeof fetch=="function"&&!Mt(E))return fetch(E,{credentials:"same-origin"}).then(I=>{if(!I.ok)throw`failed to load wasm binary file at '${E}'`;return I.arrayBuffer()}).catch(()=>ce(E));if(b)return new Promise((I,N)=>{b(E,R=>I(new Uint8Array(R)),N)})}return Promise.resolve().then(()=>ce(E))}(m).then(E=>WebAssembly.instantiate(E,y)).then(x,E=>{Q(`failed to asynchronously prepare wasm: ${E}`),Lt(E)})}function on(){return{a:{j:Ia,b:Da,E:Ao,g:ko,V:Fo,A:Bo,C:zo,W:Xo,T:Ko,L:Yo,S:Jo,o:Zo,B:Qo,y:ti,U:ri,z:ni,_:ka,Z:Na,P:Fa,w:Ca,F:La,k:ja,O:Dr,Y:Ra,I:Ba,J:Va,K:Ma,G:ra,H:na,v:za,q:Ua,l:Ga,p:Ha,e:qa,X:Wa,x:Xa,d:oa,f:Ka,i:Ya,u:Ja,t:Za,s:qs,Q:sa,R:la,D:Ir,h:ua,n:pa,M:da,m:ca,a:gt,r:Er,N:ga,c:Js}}}var vn={837620:(m,y,x,E,I)=>{if(r===void 0||!r.Ua)return 1;if((m=ge(m>>>0)).startsWith("./")&&(m=m.substring(2)),!(m=r.Ua.get(m)))return 2;if(E>>>=0,(y>>>=0)+(x>>>=0)>m.byteLength)return 3;try{let N=m.subarray(y,y+x);switch(I){case 0:i().set(N,E>>>0);break;case 1:r.mb(E,N);break;default:return 4}return 0}catch{return 4}},838303:()=>typeof wasmOffsetConverter<"u"};function Ia(){return typeof wasmOffsetConverter<"u"}function vr(m){this.name="ExitStatus",this.message=`Program terminated with exit(${m})`,this.status=m}var _r=m=>{m.terminate(),m.onmessage=()=>{}},_n=m=>{te.length==0&&(Eo(),So(te[0]));var y=te.pop();if(!y)return 6;ie.push(y),Dt[m.Ra]=y,y.Ra=m.Ra;var x={cmd:"run",start_routine:m.cb,arg:m.ab,pthread_ptr:m.Ra};return y.postMessage(x,m.ib),0},fe=0,Z=(m,y,...x)=>{for(var E=2*x.length,I=en(),N=tn(8*E),R=N>>>3,K=0;K<x.length;K++){var pt=x[K];typeof pt=="bigint"?(_t[R+2*K]=1n,_t[R+2*K+1]=pt):(_t[R+2*K]=0n,s()[R+2*K+1>>>0]=pt)}return m=ba(m,0,E,N,y),gr(I),m};function Er(m){if(g)return Z(0,1,m);if(Ft=m,!(0<fe)){for(var y of ie)_r(y);for(y of te)_r(y);te=[],ie=[],Dt=[],it=!0}A(m,new vr(m))}function On(m){if(g)return Z(1,0,m);Ir(m)}var Ir=m=>{if(Ft=m,g)throw On(m),"unwind";Er(m)},te=[],ie=[],In=[],Dt={},_o=m=>{var y=m.Ra;delete Dt[y],te.push(m),ie.splice(ie.indexOf(m),1),m.Ra=0,Qr(y)};function Oo(){In.forEach(m=>m())}var So=m=>new Promise(y=>{m.onmessage=I=>{var N=(I=I.data).cmd;if(I.targetThread&&I.targetThread!=ue()){var R=Dt[I.targetThread];R?R.postMessage(I,I.transferList):Q(`Internal error! Worker sent a message "${N}" to target pthread ${I.targetThread}, but that thread no longer exists!`)}else N==="checkMailbox"?Qe():N==="spawnThread"?_n(I):N==="cleanupThread"?_o(Dt[I.thread]):N==="killThread"?(I=I.thread,N=Dt[I],delete Dt[I],_r(N),Qr(I),ie.splice(ie.indexOf(N),1),N.Ra=0):N==="cancelThread"?Dt[I.thread].postMessage({cmd:"cancel"}):N==="loaded"?(m.loaded=!0,y(m)):N==="alert"?alert(`Thread ${I.threadId}: ${I.text}`):I.target==="setimmediate"?m.postMessage(I):N==="callHandler"?r[I.handler](...I.args):N&&Q(`worker sent an unknown command ${N}`)},m.onerror=I=>{throw Q(`worker sent an error! ${I.filename}:${I.lineno}: ${I.message}`),I};var x,E=[];for(x of[])r.hasOwnProperty(x)&&E.push(x);m.postMessage({cmd:"load",handlers:E,wasmMemory:gt,wasmModule:De})});function Eo(){var m=new Worker(new URL(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href),{type:"module",workerData:"em-pthread",name:"em-pthread"});te.push(m)}var Io,Ye=m=>{for(;0<m.length;)m.shift()(r)},Pa=()=>{var m=ue(),y=o()[m+52>>>2>>>0];m=o()[m+56>>>2>>>0],wa(y,y-m),gr(y)},Ze=[],Aa=(m,y)=>{fe=0;var x=Ze[m];x||(m>=Ze.length&&(Ze.length=m+1),Ze[m]=x=Io.get(m)),m=x(y),0<fe?Ft=m:ar(m)};class $a{constructor(y){this.Xa=y-24}}function Da(m,y,x){var E=new $a(m>>>=0);throw y>>>=0,x>>>=0,o()[E.Xa+16>>>2>>>0]=0,o()[E.Xa+4>>>2>>>0]=y,o()[E.Xa+8>>>2>>>0]=x,m}function Po(m,y,x,E){return g?Z(2,1,m,y,x,E):Ao(m,y,x,E)}function Ao(m,y,x,E){if(m>>>=0,y>>>=0,x>>>=0,E>>>=0,S===void 0)return Q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var I=[];return g&&I.length===0?Po(m,y,x,E):(m={cb:x,Ra:m,ab:E,ib:I},g?(m.Za="spawnThread",postMessage(m,I),0):_n(m))}var $o=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Do=(m,y,x)=>{var E=(y>>>=0)+x;for(x=y;m[x]&&!(x>=E);)++x;if(16<x-y&&m.buffer&&$o)return $o.decode(m.buffer instanceof S?m.slice(y,x):m.subarray(y,x));for(E="";y<x;){var I=m[y++];if(128&I){var N=63&m[y++];if((224&I)==192)E+=String.fromCharCode((31&I)<<6|N);else{var R=63&m[y++];65536>(I=(240&I)==224?(15&I)<<12|N<<6|R:(7&I)<<18|N<<12|R<<6|63&m[y++])?E+=String.fromCharCode(I):(I-=65536,E+=String.fromCharCode(55296|I>>10,56320|1023&I))}}else E+=String.fromCharCode(I)}return E},ge=(m,y)=>(m>>>=0)?Do(i(),m,y):"";function ko(m,y,x){return g?Z(3,1,m,y,x):0}function Fo(m,y){if(g)return Z(4,1,m,y)}var Lo=m=>{for(var y=0,x=0;x<m.length;++x){var E=m.charCodeAt(x);127>=E?y++:2047>=E?y+=2:55296<=E&&57343>=E?(y+=4,++x):y+=3}return y},jo=(m,y,x,E)=>{if(!(0<E))return 0;var I=x>>>=0;E=x+E-1;for(var N=0;N<m.length;++N){var R=m.charCodeAt(N);if(55296<=R&&57343>=R&&(R=65536+((1023&R)<<10)|1023&m.charCodeAt(++N)),127>=R){if(x>=E)break;y[x++>>>0]=R}else{if(2047>=R){if(x+1>=E)break;y[x++>>>0]=192|R>>6}else{if(65535>=R){if(x+2>=E)break;y[x++>>>0]=224|R>>12}else{if(x+3>=E)break;y[x++>>>0]=240|R>>18,y[x++>>>0]=128|R>>12&63}y[x++>>>0]=128|R>>6&63}y[x++>>>0]=128|63&R}}return y[x>>>0]=0,x-I},be=(m,y,x)=>jo(m,i(),y,x);function Bo(m,y){if(g)return Z(5,1,m,y)}function zo(m,y,x){if(g)return Z(6,1,m,y,x)}function Xo(m,y,x){return g?Z(7,1,m,y,x):0}function Ko(m,y){if(g)return Z(8,1,m,y)}function Yo(m,y,x){if(g)return Z(9,1,m,y,x)}function Jo(m,y,x,E){if(g)return Z(10,1,m,y,x,E)}function Zo(m,y,x,E){if(g)return Z(11,1,m,y,x,E)}function Qo(m,y,x,E){if(g)return Z(12,1,m,y,x,E)}function ti(m){if(g)return Z(13,1,m)}function ri(m,y){if(g)return Z(14,1,m,y)}function ni(m,y,x){if(g)return Z(15,1,m,y,x)}var ka=()=>{Lt("")},Na=()=>1;function Fa(m){Zr(m>>>0,!f,1,!l,131072,!1),Oo()}function Dr(m){m>>>=0,typeof Atomics.jb=="function"&&(Atomics.jb(p(),m>>>2,m).value.then(Qe),m+=128,Atomics.store(p(),m>>>2,1))}var Qe=()=>{var m=ue();if(m&&(Dr(m),m=ya,!it))try{if(m(),!(0<fe))try{g?ar(Ft):Ir(Ft)}catch(y){y instanceof vr||y=="unwind"||A(1,y)}}catch(y){y instanceof vr||y=="unwind"||A(1,y)}};function Ca(m,y){(m>>>=0)==y>>>0?setTimeout(Qe):g?postMessage({targetThread:m,cmd:"checkMailbox"}):(m=Dt[m])&&m.postMessage({cmd:"checkMailbox"})}var Lr=[];function La(m,y,x,E,I){for(y>>>=0,E/=2,Lr.length=E,x=I>>>0>>>3,I=0;I<E;I++)Lr[I]=_t[x+2*I]?_t[x+2*I+1]:s()[x+2*I+1>>>0];return(y?vn[y]:Zs[m])(...Lr)}function ja(m){m>>>=0,g?postMessage({cmd:"cleanupThread",thread:m}):_o(Dt[m])}function Ra(m){}function Ba(m,y){m=-9007199254740992>m||9007199254740992<m?NaN:Number(m),y>>>=0,m=new Date(1e3*m),p()[y>>>2>>>0]=m.getUTCSeconds(),p()[y+4>>>2>>>0]=m.getUTCMinutes(),p()[y+8>>>2>>>0]=m.getUTCHours(),p()[y+12>>>2>>>0]=m.getUTCDate(),p()[y+16>>>2>>>0]=m.getUTCMonth(),p()[y+20>>>2>>>0]=m.getUTCFullYear()-1900,p()[y+24>>>2>>>0]=m.getUTCDay(),m=(m.getTime()-Date.UTC(m.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,p()[y+28>>>2>>>0]=m}var le=m=>m%4==0&&(m%100!=0||m%400==0),ii=[0,31,60,91,121,152,182,213,244,274,305,335],ea=[0,31,59,90,120,151,181,212,243,273,304,334];function Va(m,y){m=-9007199254740992>m||9007199254740992<m?NaN:Number(m),y>>>=0,m=new Date(1e3*m),p()[y>>>2>>>0]=m.getSeconds(),p()[y+4>>>2>>>0]=m.getMinutes(),p()[y+8>>>2>>>0]=m.getHours(),p()[y+12>>>2>>>0]=m.getDate(),p()[y+16>>>2>>>0]=m.getMonth(),p()[y+20>>>2>>>0]=m.getFullYear()-1900,p()[y+24>>>2>>>0]=m.getDay();var x=(le(m.getFullYear())?ii:ea)[m.getMonth()]+m.getDate()-1|0;p()[y+28>>>2>>>0]=x,p()[y+36>>>2>>>0]=-60*m.getTimezoneOffset(),x=new Date(m.getFullYear(),6,1).getTimezoneOffset();var E=new Date(m.getFullYear(),0,1).getTimezoneOffset();m=0|(x!=E&&m.getTimezoneOffset()==Math.min(E,x)),p()[y+32>>>2>>>0]=m}function Ma(m){m>>>=0;var y=new Date(p()[m+20>>>2>>>0]+1900,p()[m+16>>>2>>>0],p()[m+12>>>2>>>0],p()[m+8>>>2>>>0],p()[m+4>>>2>>>0],p()[m>>>2>>>0],0),x=p()[m+32>>>2>>>0],E=y.getTimezoneOffset(),I=new Date(y.getFullYear(),6,1).getTimezoneOffset(),N=new Date(y.getFullYear(),0,1).getTimezoneOffset(),R=Math.min(N,I);return 0>x?p()[m+32>>>2>>>0]=+(I!=N&&R==E):0<x!=(R==E)&&(I=Math.max(N,I),y.setTime(y.getTime()+6e4*((0<x?R:I)-E))),p()[m+24>>>2>>>0]=y.getDay(),x=(le(y.getFullYear())?ii:ea)[y.getMonth()]+y.getDate()-1|0,p()[m+28>>>2>>>0]=x,p()[m>>>2>>>0]=y.getSeconds(),p()[m+4>>>2>>>0]=y.getMinutes(),p()[m+8>>>2>>>0]=y.getHours(),p()[m+12>>>2>>>0]=y.getDate(),p()[m+16>>>2>>>0]=y.getMonth(),p()[m+20>>>2>>>0]=y.getYear(),m=y.getTime(),BigInt(isNaN(m)?-1:m/1e3)}function ra(m,y,x,E,I,N,R){return g?Z(16,1,m,y,x,E,I,N,R):-52}function na(m,y,x,E,I,N){if(g)return Z(17,1,m,y,x,E,I,N)}function za(m,y,x,E){m>>>=0,y>>>=0,x>>>=0,E>>>=0;var I=new Date().getFullYear(),N=new Date(I,0,1),R=new Date(I,6,1);I=N.getTimezoneOffset();var K=R.getTimezoneOffset(),pt=Math.max(I,K);o()[m>>>2>>>0]=60*pt,p()[y>>>2>>>0]=+(I!=K),N=(m=ct=>ct.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(N),R=m(R),K<I?(be(N,x,17),be(R,E,17)):(be(N,E,17),be(R,x,17))}var Kr=[];function Ua(m,y,x){m>>>=0,y>>>=0,x>>>=0,Kr.length=0;for(var E;E=i()[y++>>>0];){var I=E!=105;x+=(I&=E!=112)&&x%8?4:0,Kr.push(E==112?o()[x>>>2>>>0]:E==106?_t[x>>>3]:E==105?p()[x>>>2>>>0]:s()[x>>>3>>>0]),x+=I?8:4}return vn[m](...Kr)}var Ga=()=>{},Ha=()=>Date.now();function qa(m,y){return Q(ge(m>>>0,y>>>0))}var oa,Wa=()=>{throw fe+=1,"unwind"};function Xa(){return 4294901760}oa=()=>performance.timeOrigin+performance.now();var Ka=()=>navigator.hardwareConcurrency;function Ya(){return Lt("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function Ja(m){m>>>=0;var y=i().length;if(m<=y||4294901760<m)return!1;for(var x=1;4>=x;x*=2){var E=y*(1+.2/x);E=Math.min(E,m+100663296);var I=Math;E=Math.max(m,E);t:{I=(I.min.call(I,4294901760,E+(65536-E%65536)%65536)-gt.buffer.byteLength+65535)/65536;try{gt.grow(I),at();var N=1;break t}catch{}N=void 0}if(N)return!0}return!1}var tr=()=>(Lt("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),we={},ia=m=>{m.forEach(y=>{tr()})};function Za(){var m=Error().stack.toString().split(`
1805
+ ${e}`);return a}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,n,i){let a=this.gl;a.activeTexture(a.TEXTURE0+n),this.checkError(),a.bindTexture(a.TEXTURE_2D,e),this.checkError(),a.uniform1i(i,n),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(z.debug){let e=this.gl,n=e.getError(),i="";switch(n){case e.NO_ERROR:return;case e.INVALID_ENUM:i="INVALID_ENUM";break;case e.INVALID_VALUE:i="INVALID_VALUE";break;case e.INVALID_OPERATION:i="INVALID_OPERATION";break;case e.INVALID_FRAMEBUFFER_OPERATION:i="INVALID_FRAMEBUFFER_OPERATION";break;case e.OUT_OF_MEMORY:i="OUT_OF_MEMORY";break;case e.CONTEXT_LOST_WEBGL:i="CONTEXT_LOST_WEBGL";break;default:i=`Unknown WebGL Error: ${n.toString(16)}`}throw new Error(i)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,n,i=0){if(this.version===2)return new Pn(this.gl,n);switch(e){case"float":return i===1||this.isRenderFloat32Supported?new Br(this.gl,n):new Br(this.gl,n,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new En(this.gl,n);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){let e=this.gl;for(let n=0;n<this.maxTextureImageUnits;++n)e.activeTexture(e.TEXTURE0+n),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,n=e.createBuffer();if(!n)throw new Error("createBuffer() returned null");let i=this.createDefaultGeometry();return e.bindBuffer(e.ARRAY_BUFFER,n),e.bufferData(e.ARRAY_BUFFER,i,e.STATIC_DRAW),this.checkError(),n}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,n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let i=this.version===2?e.RGBA32F:e.RGBA;e.texImage2D(e.TEXTURE_2D,0,i,1,1,0,e.RGBA,e.FLOAT,null);let a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);let p=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(a),p}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,n,i,a,p,o;try{n=e.createTexture(),i=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,n);let s=this.version===2?e.RGBA32F:e.RGBA;return e.texImage2D(e.TEXTURE_2D,0,s,1,1,0,e.RGBA,e.FLOAT,null),e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.enable(e.BLEND),a=e.createShader(e.VERTEX_SHADER),!a||(e.shaderSource(a,"void main(){}"),e.compileShader(a),p=e.createShader(e.FRAGMENT_SHADER),!p)||(e.shaderSource(p,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),e.compileShader(p),o=e.createProgram(),!o)?!1:(e.attachShader(o,a),e.attachShader(o,p),e.linkProgram(o),e.useProgram(o),e.drawArrays(e.POINTS,0,1),e.getError()===e.NO_ERROR)}finally{e.disable(e.BLEND),o&&e.deleteProgram(o),a&&e.deleteShader(a),p&&e.deleteShader(p),i&&(e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(i)),n&&(e.bindTexture(e.TEXTURE_2D,null),e.deleteTexture(n))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,n=this.disjointTimerQueryWebgl2Extension,i=e.createQuery();return e.beginQuery(n.TIME_ELAPSED_EXT,i),i}else throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let e=this.gl,n=this.disjointTimerQueryWebgl2Extension;e.endQuery(n.TIME_ELAPSED_EXT);return}else throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(e){let n=!1,i=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){let a=this.gl,p=this.disjointTimerQueryWebgl2Extension;n=a.getQueryParameter(e,a.QUERY_RESULT_AVAILABLE),i=a.getParameter(p.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return n&&!i}getTimerResult(e){let n=0;if(this.version===2){let i=this.gl;n=i.getQueryParameter(e,i.QUERY_RESULT),i.deleteQuery(e)}else throw new Error("WebGL1 profiling currently not supported");return n/1e6}async waitForQueryAndGetTime(e){return await li(()=>this.isTimerResultAvailable(e)),this.getTimerResult(e)}async createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let n,i=e,a=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),a===null?n=()=>!0:n=()=>{let p=i.clientWaitSync(a,0,0);return p===i.ALREADY_SIGNALED||p===i.CONDITION_SATISFIED},{query:a,isFencePassed:n}}async pollFence(e){return new Promise(n=>{this.addItemToPoll(()=>e.isFencePassed(),()=>n())})}pollItems(){let e=bg(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=e;++n){let{resolveFn:i}=this.itemsToPoll[n];i()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,n){this.itemsToPoll.push({isDoneFn:e,resolveFn:n}),!(this.itemsToPoll.length>1)&&await li(()=>(this.pollItems(),this.itemsToPoll.length===0))}}});function Gi(e){let n;if((!e||e==="webgl2")&&"webgl2"in mr?n=mr.webgl2:(!e||e==="webgl")&&"webgl"in mr&&(n=mr.webgl),!n)try{let a=yg();n=vp(a,e)}catch{let a=gg();n=vp(a,e)}e=e||n.version===1?"webgl":"webgl2";let i=n.gl;return mr[e]=n,i.isContextLost()?(delete mr[e],Gi(e)):(i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),i.disable(i.BLEND),i.disable(i.DITHER),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SAMPLE_COVERAGE),i.enable(i.SCISSOR_TEST),i.enable(i.CULL_FACE),i.cullFace(i.BACK),n)}function vp(e,n){let i={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1},a,p=i;if((!n||n==="webgl2")&&(a=e.getContext("webgl2",p),a))try{return new Mr(a,2)}catch(o){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${o}`)}if((!n||n==="webgl")&&(a=e.getContext("webgl",p)||e.getContext("experimental-webgl",p),a))try{return new Mr(a,1)}catch(o){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${o}`)}throw new Error("WebGL is not supported")}function gg(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let e=document.createElement("canvas");return e.width=1,e.height=1,e}function yg(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var mr,Ip=O(()=>{Ut(),wp(),mr={}}),Yn,_p=O(()=>{Yt(),Ut(),Tp(),Ip(),Yn=class{get contextId(){return z.webgl.contextId}set contextId(e){z.webgl.contextId=e}get matmulMaxBatchSize(){return z.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){z.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return z.webgl.textureCacheMode}set textureCacheMode(e){z.webgl.textureCacheMode=e}get pack(){return z.webgl.pack}set pack(e){z.webgl.pack=e}get async(){return z.webgl.async}set async(e){z.webgl.async=e}initialize(){try{return this.glContext=Gi(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),tt.setWithEnv(z),z.webgl.context||Object.defineProperty(z.webgl,"context",{value:this.glContext.gl}),tt.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return tt.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new Jn(this,e)}dispose(){this.glContext.dispose()}}});async function Mi(e){if(e){let n=typeof e=="string"?[e]:e;for(let i of n){let a=Op.get(i);if(a)return a;let p=await Tg(i);if(p)return p}}else return Mi(["webgl"]);throw new Error("no available backend to use")}async function Tg(e){let n=xg;if(typeof n[e]<"u"&&wg(n[e])){let i=n[e],a=i.initialize();if(typeof a=="object"&&"then"in a&&(a=await a),a)return Op.set(e,i),i}}function wg(e){let n=e;return"initialize"in n&&typeof n.initialize=="function"&&"createSessionHandler"in n&&typeof n.createSessionHandler=="function"&&"dispose"in n&&typeof n.dispose=="function"}var Op,xg,Sp=O(()=>{_p(),Op=new Map,xg={webgl:new Yn}}),Ui,Zn,Ap=O(()=>{Ut(),Ui=class{constructor(e,n){this.op=e,this.node=n}},Zn=class{constructor(e,n,i){this.graph=e,this.profiler=i,this.initialize(n)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",()=>{let n=this.graph.getNodes();if(n.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map((i,a)=>new Ui(i,n[a])),this.reset(),this._starter=[],this._ops.forEach((i,a)=>{let p=!0;for(let o of i.node.inputs)if(!this._values[o]&&this.graph.getInputIndices().indexOf(o)===-1){p=!1;break}p&&this._starter.push(a)})})}reset(){this._values=this.graph.getValues().map(e=>e.tensor)}async execute(e,n){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let i=e.createInferenceHandler(),a=this.graph.getInputIndices();if(n.length!==a.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${n.length} expected: ${a.length}`);n.forEach((r,u)=>{let l=a[u];this._values[l]=r});let p=this._starter.slice(0),o=this.graph.getValues(),s=this.graph.getNodes(),c=0;for(;c<p.length;){let r=p[c++],u=this._ops[r],l=u.node.inputs.map(v=>this._values[v]);if(l.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${u.node}`);let f=l;tt.verbose("ExecPlan",`Running op:${u.node.name} (${f.map((v,S)=>`'${u.node.inputs[S]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);let g=await this.profiler.event("node",u.node.name,async()=>u.op.impl(i,f,u.op.context));if(g.length!==u.node.outputs.length)throw new Error("the size of output does not match model definition.");g.forEach((v,S)=>{let P=u.node.outputs[S];if(this._values[P])throw new Error(`output [${P}] already has value: op:${u.node.name}`);this._values[P]=v});let b=new Set;g.forEach((v,S)=>{let P=u.node.outputs[S];for(let _ of o[P].to){let A=s[_],L=!0;for(let M of A.inputs)if(!this._values[M]){L=!1;break}L&&b.add(_)}}),p.push(...b)}let h=[];for(let r=0;r<this.graph.getOutputIndices().length;r++){let u=this.graph.getOutputIndices()[r],l=this._values[u];if(l===void 0)throw new Error(`required output [${u}] does not have value`);u===0?await l.getData():l.data,h.push(l)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),i.dispose(),h})}}}),q,Xt,Ur,Pp=O(()=>{Pr(),q=rr(sr()),We(),Y(),Xt=F.experimental.fbs,Ur=class Ae{constructor(n){if(this._attributes=new Map,n!=null){for(let i of n)i instanceof q.onnx.AttributeProto?this._attributes.set(i.name,[Ae.getValue(i),Ae.getType(i)]):i instanceof Xt.Attribute&&this._attributes.set(i.name(),[Ae.getValue(i),Ae.getType(i)]);if(this._attributes.size<n.length)throw new Error("duplicated attribute names")}}set(n,i,a){this._attributes.set(n,[a,i])}delete(n){this._attributes.delete(n)}getFloat(n,i){return this.get(n,"float",i)}getInt(n,i){return this.get(n,"int",i)}getString(n,i){return this.get(n,"string",i)}getTensor(n,i){return this.get(n,"tensor",i)}getFloats(n,i){return this.get(n,"floats",i)}getInts(n,i){return this.get(n,"ints",i)}getStrings(n,i){return this.get(n,"strings",i)}getTensors(n,i){return this.get(n,"tensors",i)}get(n,i,a){let p=this._attributes.get(n);if(p===void 0){if(a!==void 0)return a;throw new Error(`required attribute not found: ${n}`)}if(p[1]!==i)throw new Error(`type mismatch: expected ${i} but got ${p[1]}`);return p[0]}static getType(n){let i=n instanceof q.onnx.AttributeProto?n.type:n.type();switch(i){case q.onnx.AttributeProto.AttributeType.FLOAT:return"float";case q.onnx.AttributeProto.AttributeType.INT:return"int";case q.onnx.AttributeProto.AttributeType.STRING:return"string";case q.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case q.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case q.onnx.AttributeProto.AttributeType.INTS:return"ints";case q.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case q.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${q.onnx.AttributeProto.AttributeType[i]}`)}}static getValue(n){let i=n instanceof q.onnx.AttributeProto?n.type:n.type();if(i===q.onnx.AttributeProto.AttributeType.GRAPH||i===q.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");let a=this.getValueNoCheck(n);if(i===q.onnx.AttributeProto.AttributeType.INT&&Rt.isLong(a))return Rt.longToNumber(a);if(i===q.onnx.AttributeProto.AttributeType.INTS){let p=a,o=new Array(p.length);for(let s=0;s<p.length;s++){let c=p[s];o[s]=Rt.longToNumber(c)}return o}if(i===q.onnx.AttributeProto.AttributeType.TENSOR)return n instanceof q.onnx.AttributeProto?bt.fromProto(a):bt.fromOrtTensor(a);if(i===q.onnx.AttributeProto.AttributeType.TENSORS){if(n instanceof q.onnx.AttributeProto)return a.map(p=>bt.fromProto(p));if(n instanceof Xt.Attribute)return a.map(p=>bt.fromOrtTensor(p))}return i===q.onnx.AttributeProto.AttributeType.STRING&&n instanceof q.onnx.AttributeProto?kr(a):i===q.onnx.AttributeProto.AttributeType.STRINGS&&n instanceof q.onnx.AttributeProto?a.map(kr):a}static getValueNoCheck(n){return n instanceof q.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(n):this.getValueNoCheckFromOrtFormat(n)}static getValueNoCheckFromOnnxFormat(n){switch(n.type){case q.onnx.AttributeProto.AttributeType.FLOAT:return n.f;case q.onnx.AttributeProto.AttributeType.INT:return n.i;case q.onnx.AttributeProto.AttributeType.STRING:return n.s;case q.onnx.AttributeProto.AttributeType.TENSOR:return n.t;case q.onnx.AttributeProto.AttributeType.GRAPH:return n.g;case q.onnx.AttributeProto.AttributeType.FLOATS:return n.floats;case q.onnx.AttributeProto.AttributeType.INTS:return n.ints;case q.onnx.AttributeProto.AttributeType.STRINGS:return n.strings;case q.onnx.AttributeProto.AttributeType.TENSORS:return n.tensors;case q.onnx.AttributeProto.AttributeType.GRAPHS:return n.graphs;default:throw new Error(`unsupported attribute type: ${q.onnx.AttributeProto.AttributeType[n.type]}`)}}static getValueNoCheckFromOrtFormat(n){switch(n.type()){case Xt.AttributeType.FLOAT:return n.f();case Xt.AttributeType.INT:return n.i();case Xt.AttributeType.STRING:return n.s();case Xt.AttributeType.TENSOR:return n.t();case Xt.AttributeType.GRAPH:return n.g();case Xt.AttributeType.FLOATS:return n.floatsArray();case Xt.AttributeType.INTS:{let i=[];for(let a=0;a<n.intsLength();a++)i.push(n.ints(a));return i}case Xt.AttributeType.STRINGS:{let i=[];for(let a=0;a<n.stringsLength();a++)i.push(n.strings(a));return i}case Xt.AttributeType.TENSORS:{let i=[];for(let a=0;a<n.tensorsLength();a++)i.push(n.tensors(a));return i}default:throw new Error(`unsupported attribute type: ${Xt.AttributeType[n.type()]}`)}}}}),zi,Qn,Wi,me,to,Vi,Ep=O(()=>{Pp(),Pr(),zi=rr(sr()),We(),Y(),Qn=F.experimental.fbs,Wi={from:(e,n)=>new Vi(e,n)},me=class{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=At.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}},to=class{constructor(e,n){e instanceof zi.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new Ur(e.attribute)):e instanceof Qn.Node&&(this.name=n??e.name(),this.opType=e.opType(),this.attributes=new Ur(At.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Vi=class{constructor(e,n){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(n),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(e){if(e instanceof zi.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else if(e instanceof Qn.Graph)this.buildGraphFromOrtFormat(e);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(e){let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let i=new Map;if(!e.input)throw new Error("missing information in graph: input");let a=[];for(let p of e.input){if(n.has(p.name))throw new Error(`duplicated input name: ${p.name}`);let o=this._allData.push(new me(p))-1;n.set(p.name,o),a.push(p.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(let p of e.initializer){let o=n.get(p.name);if(o===void 0){let s=new me;s.type={shape:{dims:At.tensorDimsFromProto(p.dims)},tensorType:At.tensorDataTypeFromProto(p.dataType)},o=this._allData.push(s)-1,n.set(p.name,o)}this._allData[o]._from=-1,this._allData[o].tensor=bt.fromProto(p)}for(let p=0;p<this._allData.length;p++)this._allData[p].tensor||(this._allInputIndices.push(p),this._allInputNames.push(a[p]));if(!e.output)throw new Error("missing information in graph: output");for(let p of e.output){if(n.has(p.name))throw new Error(`duplicated output name: ${p.name}`);let o=this._allData.push(new me(p))-1;n.set(p.name,o),this._allOutputIndices.push(o),this._allOutputNames.push(p.name)}if(!e.node)throw new Error("missing information in graph: node");for(let p of e.node){if(!p.name)for(let s=0;;s++){let c=`unnamed_${p.opType}_${s}`;if(!i.has(c)){p.name=c;break}}if(i.has(p.name))throw new Error(`duplicated node name: ${p.name}`);let o=this._nodes.push(new to(p))-1;i.set(p.name,o)}for(let p=0;p<this._nodes.length;p++){let o=this._nodes[p],s=e.node[p];if(!s.output)throw new Error(`missing output for node: ${s.name}`);for(let c of s.output){let h=n.get(c);if(typeof h>"u"&&(h=this._allData.push(new me)-1,n.set(c,h)),o.outputs.push(h),this._allData[h]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${h}`);if(this._allData[h]._from=p,s.opType==="Constant"){if(!s.attribute||s.attribute.length!==1||!s.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!s.output||s.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");o.outputs.pop(),o.executeNode=!1,this._allData[h]._from=-1,this._allData[h].tensor=bt.fromProto(s.attribute[0].t)}}}for(let p=0;p<this._nodes.length;p++){let o=this._nodes[p],s=e.node[p];if(!s.input)throw new Error(`missing input for node: ${s.name}`);for(let c of s.input){let h=n.get(c);if(typeof h>"u"){if(c===""&&(s.input.length===3||s.input.length===4)&&s.opType==="Resize")continue;throw new Error(`unrecognized input '${c}' for node: ${s.name}`)}o.inputs.push(h),this._allData[h]._to.push(p)}}return!0}buildGraphFromOrtFormat(e){var p,o,s;let n=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let i=new Map,a=[];for(let c=0;c<e.inputsLength();c++){let h=e.inputs(c);if(n.has(h))throw new Error(`duplicated input name: ${h}`);for(let r=0;r<e.nodeArgsLength();r++)if(((p=e.nodeArgs(r))==null?void 0:p.name())===h){let u=new me;if(((s=(o=e.nodeArgs(r))==null?void 0:o.type())==null?void 0:s.valueType())!==Qn.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let l=e.nodeArgs(r).type().value(new Qn.TensorTypeAndShape),f=At.tensorDataTypeFromProto(l.elemType()),g=l.shape(),b=[];for(let S=0;S<g.dimLength();S++)b.push(Rt.longToNumber(g.dim(S).value().dimValue()));u.type={shape:{dims:b},tensorType:f};let v=this._allData.push(u)-1;n.set(h,v),a.push(h)}}for(let c=0;c<e.initializersLength();c++){let h=e.initializers(c),r=n.get(h.name());if(r===void 0){let u=new me,l=At.tensorDimsFromORTFormat(h),f=At.tensorDataTypeFromProto(h.dataType());u.type={shape:{dims:l},tensorType:f},r=this._allData.push(u)-1,n.set(h.name(),r)}this._allData[r]._from=-1,this._allData[r].tensor=bt.fromOrtTensor(h)}for(let c=0;c<this._allData.length;c++)this._allData[c].tensor||(this._allInputIndices.push(c),this._allInputNames.push(a[c]));for(let c=0;c<e.outputsLength();c++){let h=e.outputs(c);if(n.has(h))throw new Error(`duplicated output name: ${h}`);let r=this._allData.push(new me)-1;n.set(h,r),this._allOutputIndices.push(r),this._allOutputNames.push(h)}if(!e.nodes)throw new Error("missing information in graph: node");for(let c=0;c<e.nodesLength();c++){let h=e.nodes(c),r=h.name();if(!r)for(let l=0;r=`unnamed_${h.opType()}_${l}`,!!i.has(r);l++);if(i.has(r))throw new Error(`duplicated node name: ${r}`);let u=this._nodes.push(new to(h,r))-1;i.set(r,u)}for(let c=0;c<this._nodes.length;c++){let h=this._nodes[c],r=e.nodes(c);if(r==null)throw new Error(`No node exists at index ${c}`);if((r==null?void 0:r.outputsLength())===0)throw new Error(`missing output for node: ${r.name}`);for(let u=0;u<(r==null?void 0:r.outputsLength());u++){let l=r==null?void 0:r.outputs(u),f=n.get(l);if(typeof f>"u"&&(f=this._allData.push(new me)-1,n.set(l,f)),h.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=c,r.opType()==="Constant"){if(r.attributesLength()!==1||!r.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(r.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");h.outputs.pop(),h.executeNode=!1,this._allData[f]._from=-1,this._allData[f].tensor=bt.fromOrtTensor(r.attributes(0).t())}}}for(let c=0;c<this._nodes.length;c++){let h=this._nodes[c],r=e.nodes(c);if(r.inputsLength()===0)throw new Error(`missing input for node: ${r.name}`);for(let u=0;u<r.inputsLength();u++){let l=r.inputs(u),f=n.get(l);if(typeof f>"u")throw new Error(`unrecognized input '${l}' for node: ${r.name()}`);h.inputs.push(f),this._allData[f]._to.push(c)}}}checkIsAcyclic(){let e=new Set;this._allInputIndices.forEach(a=>{this._allData[a]._to.forEach(p=>{e.add(p)})});let n=Array.from(e),i=new Array(this._nodes.length).fill("white");for(;n.length>0;){let a=n.pop();i[a]==="gray"?i[a]="black":(n.push(a),i[a]="gray",this._nodes[a].outputs.forEach(p=>{let o=this._allData[p];if(typeof o.tensor<"u")throw new Error("node outputs should not be initialized");if(o._from!==a)throw new Error("from property of the Value object doesn't match index of Node being processed");o._to.forEach(s=>{if(i[s]==="gray")throw new Error("model graph is cyclic");i[s]==="white"&&n.push(s)})}))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0,n=new Array(this._nodes.length,0),i=0;for(let a=0;a<this._nodes.length;a++)n[a]=i,this._nodes[a].executeNode?(i!==a&&(this._nodes[i]=this._nodes[a]),i++):this._nodes[a].outputs.forEach(p=>{this._allData[p]._from=-2});this._nodes.splice(i,this._nodes.length-i);for(let a=0;a<this._allData.length;a++){let p=this._allData[a];p._from!==void 0&&p._from!==-1&&p._from!==-2&&(p._from=n[p._from]);for(let o=0;o<p._to.length;o++)if(p._to[o]>=0)p._to[o]=n[p._to[o]];else throw new Error("Trying to update a removed node")}e=0;for(let a=0;a<this._allData.length;a++){if(this._allData[a].from===-2&&this._allOutputIndices.indexOf(a+e)===-1){e++,this._allData.splice(a,1),a--;continue}if(e>0){let p=-1;this._allData[a].from!==void 0&&this._allData[a].from!==-1?(p=this._nodes[this._allData[a].from].outputs.indexOf(a+e),p!==-1&&(this._nodes[this._allData[a].from].outputs[p]=a)):(p=this._allInputIndices.indexOf(a+e),p!==-1&&(this._allInputIndices[p]=a)),this._allData[a].to.forEach(o=>{p=this._nodes[o].inputs.indexOf(a+e),p!==-1&&(this._nodes[o].inputs[p]=a)}),this._allData[a].to.length===0&&(p=this._allOutputIndices.indexOf(a+e),p!==-1&&(this._allOutputIndices[p]=a))}}}deleteNode(e){let n=this._nodes[e];if(n.outputs.length>1){for(let s=1;s<n.outputs.length;s++)if(this._allData[n.outputs[s]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}n.executeNode=!1;let i=n.inputs[0],a=n.outputs[0],p=this._allData[a].to;for(let s=0;s<n.inputs.length;s++){let c=this._allData[n.inputs[s]].to.indexOf(e);if(c===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[n.inputs[s]].to.splice(c,1)}this._allData[a]._to=[];let o=this._allOutputIndices.indexOf(a);if(o!==-1&&(this._allOutputIndices[o]=i),p&&p.length>0)for(let s of p){let c=this._nodes[s].inputs.indexOf(a);if(c===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[s].inputs[c]=i,this._allData[i].to.push(s)}}removeAllDropoutNodes(){let e=0;for(let n of this._nodes){if(n.opType==="Dropout"){if(n.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(n.outputs.length!==1&&n.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(n.outputs.length===2&&this._allData[n.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 n of this._nodes)n.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 n=this._allData[e.outputs[0]]._to;if(n.length===1&&this.isActivation(this._nodes[n[0]])){let i=this._nodes[n[0]];if(i.opType==="Clip")if(i.inputs.length===1)try{e.attributes.set("activation_params","floats",[i.attributes.getFloat("min"),i.attributes.getFloat("max")])}catch{e.attributes.set("activation_params","floats",[Ve,ze])}else if(i.inputs.length>=3&&this._allData[i.inputs[1]].tensor!==void 0&&this._allData[i.inputs[2]].tensor!==void 0)e.attributes.set("activation_params","floats",[this._allData[i.inputs[1]].tensor.floatData[0],this._allData[i.inputs[2]].tensor.floatData[0]]);else continue;e.attributes.set("activation","string",i.opType),this.deleteNode(n[0])}}}}}),Dp,vg,eo,Lp=O(()=>{wn(),Ep(),Pr(),Dp=rr(sr()),Y(),vg=F.experimental.fbs,eo=class{constructor(){}load(e,n,i){let a;if(!i)try{this.loadFromOnnxFormat(e,n);return}catch(p){if(i!==void 0)throw p;a=p}try{this.loadFromOrtFormat(e,n)}catch(p){throw i!==void 0?p:new Error(`Failed to load model as ONNX format: ${a}
1806
+ as ORT format: ${p}`)}}loadFromOnnxFormat(e,n){let i=Dp.onnx.ModelProto.decode(e);if(Rt.longToNumber(i.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=i.opsetImport.map(a=>({domain:a.domain,version:Rt.longToNumber(a.version)})),this._graph=Wi.from(i.graph,n)}loadFromOrtFormat(e,n){let i=new w.ByteBuffer(e),a=vg.InferenceSession.getRootAsInferenceSession(i).model();if(Rt.longToNumber(a.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let p=0;p<a.opsetImportLength();p++){let o=a.opsetImport(p);this._opsets.push({domain:o==null?void 0:o.domain(),version:Rt.longToNumber(o.version())})}this._graph=Wi.from(a.graph(),n)}get graph(){return this._graph}get opsets(){return this._opsets}}}),ro,$p=O(()=>{Sp(),Ap(),Ut(),Lp(),ro=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=xn.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,n,i){await this.profiler.event("session","Session.loadModel",async()=>{let a=await Mi(this.backendHint);if(this.sessionHandler=a.createSessionHandler(this.context),this._model=new eo,typeof e=="string"){let p=e.endsWith(".ort");{let o=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(o),p)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{let p=new Uint8Array(e,n||0,i||e.byteLength);this.initialize(p)}})}initialize(e,n){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{let i=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,i,n),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new Zn(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 n=this.normalizeAndValidateInputs(e),i=await this._executionPlan.execute(this.sessionHandler,n);return this.createOutput(i)})}normalizeAndValidateInputs(e){let n=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==n.length)throw new Error(`incorrect input array length: expected ${n.length} but got ${e.length}`)}else{if(e.size!==n.length)throw new Error(`incorrect input map size: expected ${n.length} but got ${e.size}`);let i=new Array(e.size),a=0;for(let p=0;p<n.length;++p){let o=e.get(n[p]);if(!o)throw new Error(`missing input tensor for: '${name}'`);i[a++]=o}e=i}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){let i=this._model.graph.getInputIndices(),a=this._model.graph.getValues(),p=new Array(i.length);for(let o=0;o<i.length;++o){let s=a[i[o]];p[o]=s.type.shape.dims,this.context.graphInputTypes.push(s.type.tensorType),this.context.graphInputDims.push(e[o].dims)}this.validateInputTensorDims(p,e,!0)}else this.validateInputTensorDims(this.context.graphInputDims,e,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,e),e}validateInputTensorTypes(e,n){for(let i=0;i<n.length;i++){let a=e[i],p=n[i].type;if(a!==p)throw new Error(`input tensor[${i}] check failed: expected type '${a}' but got ${p}`)}}validateInputTensorDims(e,n,i){for(let a=0;a<n.length;a++){let p=e[a],o=n[a].dims;if(!this.compareTensorDims(p,o,i))throw new Error(`input tensor[${a}] check failed: expected shape '[${p.join(",")}]' but got [${o.join(",")}]`)}}compareTensorDims(e,n,i){if(e.length!==n.length)return!1;for(let a=0;a<e.length;++a)if(e[a]!==n[a]&&(!i||e[a]!==0))return!1;return!0}createOutput(e){let n=this._model.graph.getOutputNames();if(e.length!==n.length)throw new Error("expected number of outputs do not match number of generated outputs");let i=new Map;for(let a=0;a<n.length;++a)i.set(n[a],e[a]);return i}initializeOps(e){let n=e.getNodes();this._ops=new Array(n.length);for(let i=0;i<n.length;i++)this._ops[i]=this.sessionHandler.resolve(n[i],this._model.opsets,e)}}}),no,kp=O(()=>{Yt(),We(),no=class{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,n,i){let a=new Map;for(let s in e)if(Object.hasOwnProperty.call(e,s)){let c=e[s];a.set(s,new bt(c.dims,c.type,void 0,void 0,c.data))}let p=await this.session.run(a),o={};return p.forEach((s,c)=>{o[c]=new yt(s.type,s.data,s.dims)}),o}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),Bp={};Or(Bp,{onnxjsBackend:()=>Ig});var Hi,Ig,Fp=O(()=>{$p(),kp(),Hi=class{async init(){}async createInferenceSessionHandler(e,n){let i=new ro(n);return typeof e=="string"?await i.loadModel(e):await i.loadModel(e),new no(i)}},Ig=new Hi}),oo=O(()=>{}),Rp={};Or(Rp,{default:()=>_g});var Cp,Np,_g,Gp=O(()=>{var e;qi(),Ke(),Vr(),Cp="ort-wasm-proxy-worker",Np=((e=globalThis.self)==null?void 0:e.name)===Cp,Np&&(self.onmessage=n=>{let{type:i,in:a}=n.data;try{switch(i){case"init-wasm":io(a.wasm).then(()=>{ao(a).then(()=>{postMessage({type:i})},p=>{postMessage({type:i,err:p})})},p=>{postMessage({type:i,err:p})});break;case"init-ep":{let{epName:p,env:o}=a;so(o,p).then(()=>{postMessage({type:i})},s=>{postMessage({type:i,err:s})});break}case"copy-from":{let{buffer:p}=a,o=zr(p);postMessage({type:i,out:o});break}case"create":{let{model:p,options:o}=a;uo(p,o).then(s=>{postMessage({type:i,out:s})},s=>{postMessage({type:i,err:s})});break}case"release":lo(a),postMessage({type:i});break;case"run":{let{sessionId:p,inputIndices:o,inputs:s,outputIndices:c,options:h}=a;fo(p,o,s,c,new Array(c.length).fill(null),h).then(r=>{r.some(u=>u[3]!=="cpu")?postMessage({type:i,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:i,out:r},po([...s,...r]))},r=>{postMessage({type:i,err:r})});break}case"end-profiling":co(a),postMessage({type:i});break;default:}}catch(p){postMessage({type:i,err:p})}}),_g=Np?null:n=>new Worker(n??br,{type:"module",name:Cp})}),Up={};Or(Up,{default:()=>Og});var ji,Mp,Og,Vp=O(()=>{var e;Mp=(ji=_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href,async function(n={}){function i(){return gt.buffer!=wt.buffer&&at(),wt}function a(){return gt.buffer!=wt.buffer&&at(),X}function p(){return gt.buffer!=wt.buffer&&at(),Wt}function o(){return gt.buffer!=wt.buffer&&at(),Le}function s(){return gt.buffer!=wt.buffer&&at(),se}var c,h,r=Object.assign({},n),u=new Promise((m,y)=>{c=m,h=y}),l=typeof window=="object",f=typeof importScripts=="function",g=f&&self.name=="em-pthread";r.mountExternalData=(m,y)=>{m.startsWith("./")&&(m=m.substring(2)),(r.Ua||(r.Ua=new Map)).set(m,y)},r.unmountExternalData=()=>{delete r.Ua};var b,v,S=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,P=Object.assign({},r),_="./this.program",A=(m,y)=>{throw y},L="";(l||f)&&(f?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),ji&&(L=ji),L=L.startsWith("blob:")?"":L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1),f&&(v=m=>{var y=new XMLHttpRequest;return y.open("GET",m,!1),y.responseType="arraybuffer",y.send(null),new Uint8Array(y.response)}),b=(m,y,x)=>{var E=new XMLHttpRequest;E.open("GET",m,!0),E.responseType="arraybuffer",E.onload=()=>{E.status==200||E.status==0&&E.response?y(E.response):x()},E.onerror=x,E.send(null)});var M,ft=console.log.bind(console),lt=console.error.bind(console),Nt=ft,Q=lt;if(Object.assign(r,P),P=null,g){let m=function(y){try{var x=y.data,E=x.cmd;if(E==="load"){let I=[];self.onmessage=N=>I.push(N),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let N of I)m(N);self.onmessage=m};for(let N of x.handlers)r[N]&&!r[N].proxy||(r[N]=(...R)=>{postMessage({Za:"callHandler",kb:N,args:R})},N=="print"&&(Nt=r[N]),N=="printErr"&&(Q=r[N]));gt=x.wasmMemory,at(),Pt(x.wasmModule)}else if(E==="run"){Zr(x.pthread_ptr,0,0,1,0,0),Dr(x.pthread_ptr),Pa(),Oo(),$e||($e=!0);try{Aa(x.start_routine,x.arg)}catch(I){if(I!="unwind")throw I}}else E==="cancel"?ue()&&ar(-1):x.target!=="setimmediate"&&(E==="checkMailbox"?$e&&Qe():E&&(Q(`worker: received unknown command ${E}`),Q(x)))}catch(I){throw ma(),I}};var Pt,$e=!1;Q=function(...y){y=y.join(" "),console.error(y)},self.alert=function(...y){postMessage({Za:"alert",text:y.join(" "),nb:ue()})},r.instantiateWasm=(y,x)=>new Promise(E=>{Pt=I=>{I=new WebAssembly.Instance(I,on()),x(I),E()}}),self.onunhandledrejection=y=>{throw y.reason||y},self.onmessage=m}r.wasmBinary&&(M=r.wasmBinary);var gt,De,Ft,wt,X,Wt,Le,_t,se,it=!1;function at(){var m=gt.buffer;r.HEAP8=wt=new Int8Array(m),r.HEAP16=new Int16Array(m),r.HEAPU8=X=new Uint8Array(m),r.HEAPU16=new Uint16Array(m),r.HEAP32=Wt=new Int32Array(m),r.HEAPU32=Le=new Uint32Array(m),r.HEAPF32=new Float32Array(m),r.HEAPF64=se=new Float64Array(m),r.HEAP64=_t=new BigInt64Array(m),r.HEAPU64=new BigUint64Array(m)}if(!g){if(!((gt=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof S))throw Q("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),Error("bad memory");at()}var re=[],Jt=[],Re=[],oe=0,Ot=null;function $t(){if(--oe==0&&Ot){var m=Ot;Ot=null,m()}}function Lt(m){throw Q(m="Aborted("+m+")"),it=!0,Ft=1,m=new WebAssembly.RuntimeError(m+". Build with -sASSERTIONS for more info."),h(m),m}var nt,st=m=>m.startsWith("data:application/octet-stream;base64,"),Mt=m=>m.startsWith("file://");function ce(m){if(m==nt&&M)return new Uint8Array(M);if(v)return v(m);throw"both async and sync fetching of the wasm failed"}function Ge(m,y,x){return function(E){if(!M&&(l||f)){if(typeof fetch=="function"&&!Mt(E))return fetch(E,{credentials:"same-origin"}).then(I=>{if(!I.ok)throw`failed to load wasm binary file at '${E}'`;return I.arrayBuffer()}).catch(()=>ce(E));if(b)return new Promise((I,N)=>{b(E,R=>I(new Uint8Array(R)),N)})}return Promise.resolve().then(()=>ce(E))}(m).then(E=>WebAssembly.instantiate(E,y)).then(x,E=>{Q(`failed to asynchronously prepare wasm: ${E}`),Lt(E)})}function on(){return{a:{j:Ia,b:Da,E:Ao,g:ko,V:Fo,A:Bo,C:zo,W:Xo,T:Ko,L:Yo,S:Jo,o:Zo,B:Qo,y:ti,U:ri,z:ni,_:ka,Z:Na,P:Fa,w:Ca,F:La,k:Ra,O:Dr,Y:ja,I:Ba,J:Ma,K:Va,G:ra,H:na,v:za,q:Ua,l:Ga,p:Ha,e:qa,X:Wa,x:Xa,d:oa,f:Ka,i:Ya,u:Ja,t:Za,s:qs,Q:sa,R:la,D:Ir,h:ua,n:pa,M:da,m:ca,a:gt,r:Er,N:ga,c:Js}}}var vn={837620:(m,y,x,E,I)=>{if(r===void 0||!r.Ua)return 1;if((m=ge(m>>>0)).startsWith("./")&&(m=m.substring(2)),!(m=r.Ua.get(m)))return 2;if(E>>>=0,(y>>>=0)+(x>>>=0)>m.byteLength)return 3;try{let N=m.subarray(y,y+x);switch(I){case 0:a().set(N,E>>>0);break;case 1:r.mb(E,N);break;default:return 4}return 0}catch{return 4}},838303:()=>typeof wasmOffsetConverter<"u"};function Ia(){return typeof wasmOffsetConverter<"u"}function vr(m){this.name="ExitStatus",this.message=`Program terminated with exit(${m})`,this.status=m}var _r=m=>{m.terminate(),m.onmessage=()=>{}},_n=m=>{te.length==0&&(Eo(),So(te[0]));var y=te.pop();if(!y)return 6;ie.push(y),Dt[m.Ra]=y,y.Ra=m.Ra;var x={cmd:"run",start_routine:m.cb,arg:m.ab,pthread_ptr:m.Ra};return y.postMessage(x,m.ib),0},fe=0,Z=(m,y,...x)=>{for(var E=2*x.length,I=en(),N=tn(8*E),R=N>>>3,K=0;K<x.length;K++){var pt=x[K];typeof pt=="bigint"?(_t[R+2*K]=1n,_t[R+2*K+1]=pt):(_t[R+2*K]=0n,s()[R+2*K+1>>>0]=pt)}return m=ba(m,0,E,N,y),gr(I),m};function Er(m){if(g)return Z(0,1,m);if(Ft=m,!(0<fe)){for(var y of ie)_r(y);for(y of te)_r(y);te=[],ie=[],Dt=[],it=!0}A(m,new vr(m))}function On(m){if(g)return Z(1,0,m);Ir(m)}var Ir=m=>{if(Ft=m,g)throw On(m),"unwind";Er(m)},te=[],ie=[],In=[],Dt={},_o=m=>{var y=m.Ra;delete Dt[y],te.push(m),ie.splice(ie.indexOf(m),1),m.Ra=0,Qr(y)};function Oo(){In.forEach(m=>m())}var So=m=>new Promise(y=>{m.onmessage=I=>{var N=(I=I.data).cmd;if(I.targetThread&&I.targetThread!=ue()){var R=Dt[I.targetThread];R?R.postMessage(I,I.transferList):Q(`Internal error! Worker sent a message "${N}" to target pthread ${I.targetThread}, but that thread no longer exists!`)}else N==="checkMailbox"?Qe():N==="spawnThread"?_n(I):N==="cleanupThread"?_o(Dt[I.thread]):N==="killThread"?(I=I.thread,N=Dt[I],delete Dt[I],_r(N),Qr(I),ie.splice(ie.indexOf(N),1),N.Ra=0):N==="cancelThread"?Dt[I.thread].postMessage({cmd:"cancel"}):N==="loaded"?(m.loaded=!0,y(m)):N==="alert"?alert(`Thread ${I.threadId}: ${I.text}`):I.target==="setimmediate"?m.postMessage(I):N==="callHandler"?r[I.handler](...I.args):N&&Q(`worker sent an unknown command ${N}`)},m.onerror=I=>{throw Q(`worker sent an error! ${I.filename}:${I.lineno}: ${I.message}`),I};var x,E=[];for(x of[])r.hasOwnProperty(x)&&E.push(x);m.postMessage({cmd:"load",handlers:E,wasmMemory:gt,wasmModule:De})});function Eo(){var m=new Worker(new URL(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href),{type:"module",workerData:"em-pthread",name:"em-pthread"});te.push(m)}var Io,Ye=m=>{for(;0<m.length;)m.shift()(r)},Pa=()=>{var m=ue(),y=o()[m+52>>>2>>>0];m=o()[m+56>>>2>>>0],wa(y,y-m),gr(y)},Ze=[],Aa=(m,y)=>{fe=0;var x=Ze[m];x||(m>=Ze.length&&(Ze.length=m+1),Ze[m]=x=Io.get(m)),m=x(y),0<fe?Ft=m:ar(m)};class $a{constructor(y){this.Xa=y-24}}function Da(m,y,x){var E=new $a(m>>>=0);throw y>>>=0,x>>>=0,o()[E.Xa+16>>>2>>>0]=0,o()[E.Xa+4>>>2>>>0]=y,o()[E.Xa+8>>>2>>>0]=x,m}function Po(m,y,x,E){return g?Z(2,1,m,y,x,E):Ao(m,y,x,E)}function Ao(m,y,x,E){if(m>>>=0,y>>>=0,x>>>=0,E>>>=0,S===void 0)return Q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var I=[];return g&&I.length===0?Po(m,y,x,E):(m={cb:x,Ra:m,ab:E,ib:I},g?(m.Za="spawnThread",postMessage(m,I),0):_n(m))}var $o=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Do=(m,y,x)=>{var E=(y>>>=0)+x;for(x=y;m[x]&&!(x>=E);)++x;if(16<x-y&&m.buffer&&$o)return $o.decode(m.buffer instanceof S?m.slice(y,x):m.subarray(y,x));for(E="";y<x;){var I=m[y++];if(128&I){var N=63&m[y++];if((224&I)==192)E+=String.fromCharCode((31&I)<<6|N);else{var R=63&m[y++];65536>(I=(240&I)==224?(15&I)<<12|N<<6|R:(7&I)<<18|N<<12|R<<6|63&m[y++])?E+=String.fromCharCode(I):(I-=65536,E+=String.fromCharCode(55296|I>>10,56320|1023&I))}}else E+=String.fromCharCode(I)}return E},ge=(m,y)=>(m>>>=0)?Do(a(),m,y):"";function ko(m,y,x){return g?Z(3,1,m,y,x):0}function Fo(m,y){if(g)return Z(4,1,m,y)}var Lo=m=>{for(var y=0,x=0;x<m.length;++x){var E=m.charCodeAt(x);127>=E?y++:2047>=E?y+=2:55296<=E&&57343>=E?(y+=4,++x):y+=3}return y},jo=(m,y,x,E)=>{if(!(0<E))return 0;var I=x>>>=0;E=x+E-1;for(var N=0;N<m.length;++N){var R=m.charCodeAt(N);if(55296<=R&&57343>=R&&(R=65536+((1023&R)<<10)|1023&m.charCodeAt(++N)),127>=R){if(x>=E)break;y[x++>>>0]=R}else{if(2047>=R){if(x+1>=E)break;y[x++>>>0]=192|R>>6}else{if(65535>=R){if(x+2>=E)break;y[x++>>>0]=224|R>>12}else{if(x+3>=E)break;y[x++>>>0]=240|R>>18,y[x++>>>0]=128|R>>12&63}y[x++>>>0]=128|R>>6&63}y[x++>>>0]=128|63&R}}return y[x>>>0]=0,x-I},be=(m,y,x)=>jo(m,a(),y,x);function Bo(m,y){if(g)return Z(5,1,m,y)}function zo(m,y,x){if(g)return Z(6,1,m,y,x)}function Xo(m,y,x){return g?Z(7,1,m,y,x):0}function Ko(m,y){if(g)return Z(8,1,m,y)}function Yo(m,y,x){if(g)return Z(9,1,m,y,x)}function Jo(m,y,x,E){if(g)return Z(10,1,m,y,x,E)}function Zo(m,y,x,E){if(g)return Z(11,1,m,y,x,E)}function Qo(m,y,x,E){if(g)return Z(12,1,m,y,x,E)}function ti(m){if(g)return Z(13,1,m)}function ri(m,y){if(g)return Z(14,1,m,y)}function ni(m,y,x){if(g)return Z(15,1,m,y,x)}var ka=()=>{Lt("")},Na=()=>1;function Fa(m){Zr(m>>>0,!f,1,!l,131072,!1),Oo()}function Dr(m){m>>>=0,typeof Atomics.jb=="function"&&(Atomics.jb(p(),m>>>2,m).value.then(Qe),m+=128,Atomics.store(p(),m>>>2,1))}var Qe=()=>{var m=ue();if(m&&(Dr(m),m=ya,!it))try{if(m(),!(0<fe))try{g?ar(Ft):Ir(Ft)}catch(y){y instanceof vr||y=="unwind"||A(1,y)}}catch(y){y instanceof vr||y=="unwind"||A(1,y)}};function Ca(m,y){(m>>>=0)==y>>>0?setTimeout(Qe):g?postMessage({targetThread:m,cmd:"checkMailbox"}):(m=Dt[m])&&m.postMessage({cmd:"checkMailbox"})}var Lr=[];function La(m,y,x,E,I){for(y>>>=0,E/=2,Lr.length=E,x=I>>>0>>>3,I=0;I<E;I++)Lr[I]=_t[x+2*I]?_t[x+2*I+1]:s()[x+2*I+1>>>0];return(y?vn[y]:Zs[m])(...Lr)}function Ra(m){m>>>=0,g?postMessage({cmd:"cleanupThread",thread:m}):_o(Dt[m])}function ja(m){}function Ba(m,y){m=-9007199254740992>m||9007199254740992<m?NaN:Number(m),y>>>=0,m=new Date(1e3*m),p()[y>>>2>>>0]=m.getUTCSeconds(),p()[y+4>>>2>>>0]=m.getUTCMinutes(),p()[y+8>>>2>>>0]=m.getUTCHours(),p()[y+12>>>2>>>0]=m.getUTCDate(),p()[y+16>>>2>>>0]=m.getUTCMonth(),p()[y+20>>>2>>>0]=m.getUTCFullYear()-1900,p()[y+24>>>2>>>0]=m.getUTCDay(),m=(m.getTime()-Date.UTC(m.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,p()[y+28>>>2>>>0]=m}var le=m=>m%4==0&&(m%100!=0||m%400==0),ii=[0,31,60,91,121,152,182,213,244,274,305,335],ea=[0,31,59,90,120,151,181,212,243,273,304,334];function Ma(m,y){m=-9007199254740992>m||9007199254740992<m?NaN:Number(m),y>>>=0,m=new Date(1e3*m),p()[y>>>2>>>0]=m.getSeconds(),p()[y+4>>>2>>>0]=m.getMinutes(),p()[y+8>>>2>>>0]=m.getHours(),p()[y+12>>>2>>>0]=m.getDate(),p()[y+16>>>2>>>0]=m.getMonth(),p()[y+20>>>2>>>0]=m.getFullYear()-1900,p()[y+24>>>2>>>0]=m.getDay();var x=(le(m.getFullYear())?ii:ea)[m.getMonth()]+m.getDate()-1|0;p()[y+28>>>2>>>0]=x,p()[y+36>>>2>>>0]=-60*m.getTimezoneOffset(),x=new Date(m.getFullYear(),6,1).getTimezoneOffset();var E=new Date(m.getFullYear(),0,1).getTimezoneOffset();m=0|(x!=E&&m.getTimezoneOffset()==Math.min(E,x)),p()[y+32>>>2>>>0]=m}function Va(m){m>>>=0;var y=new Date(p()[m+20>>>2>>>0]+1900,p()[m+16>>>2>>>0],p()[m+12>>>2>>>0],p()[m+8>>>2>>>0],p()[m+4>>>2>>>0],p()[m>>>2>>>0],0),x=p()[m+32>>>2>>>0],E=y.getTimezoneOffset(),I=new Date(y.getFullYear(),6,1).getTimezoneOffset(),N=new Date(y.getFullYear(),0,1).getTimezoneOffset(),R=Math.min(N,I);return 0>x?p()[m+32>>>2>>>0]=+(I!=N&&R==E):0<x!=(R==E)&&(I=Math.max(N,I),y.setTime(y.getTime()+6e4*((0<x?R:I)-E))),p()[m+24>>>2>>>0]=y.getDay(),x=(le(y.getFullYear())?ii:ea)[y.getMonth()]+y.getDate()-1|0,p()[m+28>>>2>>>0]=x,p()[m>>>2>>>0]=y.getSeconds(),p()[m+4>>>2>>>0]=y.getMinutes(),p()[m+8>>>2>>>0]=y.getHours(),p()[m+12>>>2>>>0]=y.getDate(),p()[m+16>>>2>>>0]=y.getMonth(),p()[m+20>>>2>>>0]=y.getYear(),m=y.getTime(),BigInt(isNaN(m)?-1:m/1e3)}function ra(m,y,x,E,I,N,R){return g?Z(16,1,m,y,x,E,I,N,R):-52}function na(m,y,x,E,I,N){if(g)return Z(17,1,m,y,x,E,I,N)}function za(m,y,x,E){m>>>=0,y>>>=0,x>>>=0,E>>>=0;var I=new Date().getFullYear(),N=new Date(I,0,1),R=new Date(I,6,1);I=N.getTimezoneOffset();var K=R.getTimezoneOffset(),pt=Math.max(I,K);o()[m>>>2>>>0]=60*pt,p()[y>>>2>>>0]=+(I!=K),N=(m=ct=>ct.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(N),R=m(R),K<I?(be(N,x,17),be(R,E,17)):(be(N,E,17),be(R,x,17))}var Kr=[];function Ua(m,y,x){m>>>=0,y>>>=0,x>>>=0,Kr.length=0;for(var E;E=a()[y++>>>0];){var I=E!=105;x+=(I&=E!=112)&&x%8?4:0,Kr.push(E==112?o()[x>>>2>>>0]:E==106?_t[x>>>3]:E==105?p()[x>>>2>>>0]:s()[x>>>3>>>0]),x+=I?8:4}return vn[m](...Kr)}var Ga=()=>{},Ha=()=>Date.now();function qa(m,y){return Q(ge(m>>>0,y>>>0))}var oa,Wa=()=>{throw fe+=1,"unwind"};function Xa(){return 4294901760}oa=()=>performance.timeOrigin+performance.now();var Ka=()=>navigator.hardwareConcurrency;function Ya(){return Lt("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function Ja(m){m>>>=0;var y=a().length;if(m<=y||4294901760<m)return!1;for(var x=1;4>=x;x*=2){var E=y*(1+.2/x);E=Math.min(E,m+100663296);var I=Math;E=Math.max(m,E);t:{I=(I.min.call(I,4294901760,E+(65536-E%65536)%65536)-gt.buffer.byteLength+65535)/65536;try{gt.grow(I),at();var N=1;break t}catch{}N=void 0}if(N)return!0}return!1}var tr=()=>(Lt("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),we={},ia=m=>{m.forEach(y=>{tr()})};function Za(){var m=Error().stack.toString().split(`
1807
1807
  `);return m[0]=="Error"&&m.shift(),ia(m),we.$a=tr(),we.bb=m,we.$a}function qs(m,y,x){if(m>>>=0,y>>>=0,we.$a==m)var E=we.bb;else(E=Error().stack.toString().split(`
1808
- `))[0]=="Error"&&E.shift(),ia(E);for(var I=3;E[I]&&tr()!=m;)++I;for(m=0;m<x&&E[m+I];++m)p()[y+4*m>>>2>>>0]=tr();return m}var Yr,Jr={},aa=()=>{if(!Yr){var m,y={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_};for(m in Jr)Jr[m]===void 0?delete y[m]:y[m]=Jr[m];var x=[];for(m in y)x.push(`${m}=${y[m]}`);Yr=x}return Yr};function sa(m,y){if(g)return Z(18,1,m,y);m>>>=0,y>>>=0;var x=0;return aa().forEach((E,I)=>{var N=y+x;for(I=o()[m+4*I>>>2>>>0]=N,N=0;N<E.length;++N)a()[I++>>>0]=E.charCodeAt(N);a()[I>>>0]=0,x+=E.length+1}),0}function la(m,y){if(g)return Z(19,1,m,y);m>>>=0,y>>>=0;var x=aa();o()[m>>>2>>>0]=x.length;var E=0;return x.forEach(I=>E+=I.length+1),o()[y>>>2>>>0]=E,0}function ua(m){return g?Z(20,1,m):52}function pa(m,y,x,E){return g?Z(21,1,m,y,x,E):52}function da(m,y,x,E){return g?Z(22,1,m,y,x,E):70}var Xs=[null,[],[]];function ca(m,y,x,E){if(g)return Z(23,1,m,y,x,E);y>>>=0,x>>>=0,E>>>=0;for(var I=0,N=0;N<x;N++){var R=o()[y>>>2>>>0],K=o()[y+4>>>2>>>0];y+=8;for(var pt=0;pt<K;pt++){var ct=i()[R+pt>>>0],vt=Xs[m];ct===0||ct===10?((m===1?Nt:Q)(Do(vt,0)),vt.length=0):vt.push(ct)}I+=K}return o()[E>>>2>>>0]=I,0}var ha=[31,29,31,30,31,30,31,31,30,31,30,31],fa=[31,28,31,30,31,30,31,31,30,31,30,31],Ks=(m,y)=>{a().set(m,y>>>0)};function ga(m,y,x,E){function I($,U,et){for($=typeof $=="number"?$.toString():$||"";$.length<U;)$=et[0]+$;return $}function N($,U){return I($,U,"0")}function R($,U){function et(_a){return 0>_a?-1:0<_a?1:0}var ae;return(ae=et($.getFullYear()-U.getFullYear()))===0&&(ae=et($.getMonth()-U.getMonth()))===0&&(ae=et($.getDate()-U.getDate())),ae}function K($){switch($.getDay()){case 0:return new Date($.getFullYear()-1,11,29);case 1:return $;case 2:return new Date($.getFullYear(),0,3);case 3:return new Date($.getFullYear(),0,2);case 4:return new Date($.getFullYear(),0,1);case 5:return new Date($.getFullYear()-1,11,31);case 6:return new Date($.getFullYear()-1,11,30)}}function pt($){var U=$.Sa;for($=new Date(new Date($.Ta+1900,0,1).getTime());0<U;){var et=$.getMonth(),ae=(le($.getFullYear())?ha:fa)[et];if(!(U>ae-$.getDate())){$.setDate($.getDate()+U);break}U-=ae-$.getDate()+1,$.setDate(1),11>et?$.setMonth(et+1):($.setMonth(0),$.setFullYear($.getFullYear()+1))}return et=new Date($.getFullYear()+1,0,4),U=K(new Date($.getFullYear(),0,4)),et=K(et),0>=R(U,$)?0>=R(et,$)?$.getFullYear()+1:$.getFullYear():$.getFullYear()-1}m>>>=0,y>>>=0,x>>>=0,E>>>=0;var ct=o()[E+40>>>2>>>0];for(var vt in E={gb:p()[E>>>2>>>0],fb:p()[E+4>>>2>>>0],Va:p()[E+8>>>2>>>0],Ya:p()[E+12>>>2>>>0],Wa:p()[E+16>>>2>>>0],Ta:p()[E+20>>>2>>>0],Qa:p()[E+24>>>2>>>0],Sa:p()[E+28>>>2>>>0],ob:p()[E+32>>>2>>>0],eb:p()[E+36>>>2>>>0],hb:ct?ge(ct):""},x=ge(x),ct={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})x=x.replace(new RegExp(vt,"g"),ct[vt]);var xa="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ta="January February March April May June July August September October November December".split(" ");for(vt in ct={"%a":$=>xa[$.Qa].substring(0,3),"%A":$=>xa[$.Qa],"%b":$=>Ta[$.Wa].substring(0,3),"%B":$=>Ta[$.Wa],"%C":$=>N(($.Ta+1900)/100|0,2),"%d":$=>N($.Ya,2),"%e":$=>I($.Ya,2," "),"%g":$=>pt($).toString().substring(2),"%G":pt,"%H":$=>N($.Va,2),"%I":$=>(($=$.Va)==0?$=12:12<$&&($-=12),N($,2)),"%j":$=>{for(var U=0,et=0;et<=$.Wa-1;U+=(le($.Ta+1900)?ha:fa)[et++]);return N($.Ya+U,3)},"%m":$=>N($.Wa+1,2),"%M":$=>N($.fb,2),"%n":()=>`
1809
- `,"%p":$=>0<=$.Va&&12>$.Va?"AM":"PM","%S":$=>N($.gb,2),"%t":()=>" ","%u":$=>$.Qa||7,"%U":$=>N(Math.floor(($.Sa+7-$.Qa)/7),2),"%V":$=>{var U=Math.floor(($.Sa+7-($.Qa+6)%7)/7);if(2>=($.Qa+371-$.Sa-2)%7&&U++,U)U==53&&((et=($.Qa+371-$.Sa)%7)==4||et==3&&le($.Ta)||(U=1));else{U=52;var et=($.Qa+7-$.Sa-1)%7;(et==4||et==5&&le($.Ta%400-1))&&U++}return N(U,2)},"%w":$=>$.Qa,"%W":$=>N(Math.floor(($.Sa+7-($.Qa+6)%7)/7),2),"%y":$=>($.Ta+1900).toString().substring(2),"%Y":$=>$.Ta+1900,"%z":$=>{var U=0<=($=$.eb);return $=Math.abs($)/60,(U?"+":"-")+("0000"+($/60*100+$%60)).slice(-4)},"%Z":$=>$.hb,"%%":()=>"%"},x=x.replace(/%%/g,"\0\0"),ct)x.includes(vt)&&(x=x.replace(new RegExp(vt,"g"),ct[vt](E)));return vt=function($){var U=Array(Lo($)+1);return jo($,U,0,U.length),U}(x=x.replace(/\0\0/g,"%")),vt.length>y?0:(Ks(vt,m),vt.length-1)}function Js(m,y,x,E){return ga(m>>>0,y>>>0,x>>>0,E>>>0)}g||function(){for(var m=r.numThreads-1;m--;)Eo();re.unshift(()=>{oe++,function(y){g?y():Promise.all(te.map(So)).then(y)}(()=>$t())})}();var Zs=[Er,On,Po,ko,Fo,Bo,zo,Xo,Ko,Yo,Jo,Zo,Qo,ti,ri,ni,ra,na,sa,la,ua,pa,da,ca],M=function(){function m(x,E){return M=x.exports,M=function(){var I=M,N=K=>()=>K()>>>0,R=K=>pt=>K(pt)>>>0;return(I=Object.assign({},I)).Ba=N(I.Ba),I.Ca=R(I.Ca),I.emscripten_main_runtime_thread_id=N(I.emscripten_main_runtime_thread_id),I.Oa=R(I.Oa),I.Pa=N(I.Pa),I}(),In.push(M.Ea),Io=M.Fa,Jt.unshift(M.$),De=E,$t(),M}var y=on();if(oe++,r.instantiateWasm)try{return r.instantiateWasm(y,m)}catch(x){Q(`Module.instantiateWasm callback failed with error: ${x}`),h(x)}return nt||(nt=r.locateFile?st("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":r.locateFile?r.locateFile("ort-wasm-simd-threaded.wasm",L):L+"ort-wasm-simd-threaded.wasm":""),function(x,E){var I=nt;return V||typeof WebAssembly.instantiateStreaming!="function"||st(I)||Mt(I)||typeof fetch!="function"?Ge(I,x,E):fetch(I,{credentials:"same-origin"}).then(N=>WebAssembly.instantiateStreaming(N,x).then(E,function(R){return Q(`wasm streaming compile failed: ${R}`),Q("falling back to ArrayBuffer instantiation"),Ge(I,x,E)}))}(y,function(x){m(x.instance,x.module)}).catch(h),{}}();r._OrtInit=(m,y)=>(r._OrtInit=M.aa)(m,y),r._OrtGetLastError=(m,y)=>(r._OrtGetLastError=M.ba)(m,y),r._OrtCreateSessionOptions=(m,y,x,E,I,N,R,K,pt,ct)=>(r._OrtCreateSessionOptions=M.ca)(m,y,x,E,I,N,R,K,pt,ct),r._OrtAppendExecutionProvider=(m,y)=>(r._OrtAppendExecutionProvider=M.da)(m,y),r._OrtAddFreeDimensionOverride=(m,y,x)=>(r._OrtAddFreeDimensionOverride=M.ea)(m,y,x),r._OrtAddSessionConfigEntry=(m,y,x)=>(r._OrtAddSessionConfigEntry=M.fa)(m,y,x),r._OrtReleaseSessionOptions=m=>(r._OrtReleaseSessionOptions=M.ga)(m),r._OrtCreateSession=(m,y,x)=>(r._OrtCreateSession=M.ha)(m,y,x),r._OrtReleaseSession=m=>(r._OrtReleaseSession=M.ia)(m),r._OrtGetInputOutputCount=(m,y,x)=>(r._OrtGetInputOutputCount=M.ja)(m,y,x),r._OrtGetInputName=(m,y)=>(r._OrtGetInputName=M.ka)(m,y),r._OrtGetOutputName=(m,y)=>(r._OrtGetOutputName=M.la)(m,y),r._OrtFree=m=>(r._OrtFree=M.ma)(m),r._OrtCreateTensor=(m,y,x,E,I,N)=>(r._OrtCreateTensor=M.na)(m,y,x,E,I,N),r._OrtGetTensorData=(m,y,x,E,I)=>(r._OrtGetTensorData=M.oa)(m,y,x,E,I),r._OrtReleaseTensor=m=>(r._OrtReleaseTensor=M.pa)(m),r._OrtCreateRunOptions=(m,y,x,E)=>(r._OrtCreateRunOptions=M.qa)(m,y,x,E),r._OrtAddRunConfigEntry=(m,y,x)=>(r._OrtAddRunConfigEntry=M.ra)(m,y,x),r._OrtReleaseRunOptions=m=>(r._OrtReleaseRunOptions=M.sa)(m),r._OrtCreateBinding=m=>(r._OrtCreateBinding=M.ta)(m),r._OrtBindInput=(m,y,x)=>(r._OrtBindInput=M.ua)(m,y,x),r._OrtBindOutput=(m,y,x,E)=>(r._OrtBindOutput=M.va)(m,y,x,E),r._OrtClearBoundOutputs=m=>(r._OrtClearBoundOutputs=M.wa)(m),r._OrtReleaseBinding=m=>(r._OrtReleaseBinding=M.xa)(m),r._OrtRunWithBinding=(m,y,x,E,I)=>(r._OrtRunWithBinding=M.ya)(m,y,x,E,I),r._OrtRun=(m,y,x,E,I,N,R,K)=>(r._OrtRun=M.za)(m,y,x,E,I,N,R,K),r._OrtEndProfiling=m=>(r._OrtEndProfiling=M.Aa)(m);var ue=()=>(ue=M.Ba)();r._malloc=m=>(r._malloc=M.Ca)(m),r._free=m=>(r._free=M.Da)(m);var er,Zr=(m,y,x,E,I,N)=>(Zr=M.Ga)(m,y,x,E,I,N),ma=()=>(ma=M.Ha)(),ba=(m,y,x,E,I)=>(ba=M.Ia)(m,y,x,E,I),Qr=m=>(Qr=M.Ja)(m),ar=m=>(ar=M.Ka)(m),ya=()=>(ya=M.La)(),wa=(m,y)=>(wa=M.Ma)(m,y),gr=m=>(gr=M.Na)(m),tn=m=>(tn=M.Oa)(m),en=()=>(en=M.Pa)();function va(){0<oe||(g?(c(r),g||Ye(Jt),startWorker(r)):(Ye(re),0<oe||er||(er=!0,r.calledRun=!0,it||(g||Ye(Jt),c(r),g||Ye(Re)))))}return r.___start_em_js=838360,r.___stop_em_js=838421,r.stackSave=()=>en(),r.stackRestore=m=>gr(m),r.stackAlloc=m=>tn(m),r.UTF8ToString=ge,r.stringToUTF8=be,r.lengthBytesUTF8=Lo,Ot=function m(){er||va(),er||(Ot=m)},va(),u}),Og=Mp,((e=globalThis.self)==null?void 0:e.name)==="em-pthread"&&Mp()}),br,Sg,Ag,Pg,zp,Wp,Eg,Hp,Vr=O(()=>{var e,n;oo(),br=(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href)??(typeof document<"u"?(e=document.currentScript)==null?void 0:e.src:typeof self<"u"?(n=self.location)==null?void 0:n.href:void 0),Sg=typeof location>"u"?void 0:location.origin,Ag=(a,i)=>{try{let p=i??br;return(p?new URL(a,p):new URL(a)).origin===Sg}catch{return!1}},Pg=async a=>{let i=await(await fetch(a,{credentials:"same-origin"})).blob();return URL.createObjectURL(i)},zp=(Gp(),sn(Rp)).default,Wp=async()=>{if(!br)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Ag(br))return[void 0,zp()];let a=await Pg(br);return[a,zp(a)]},Eg=(Vp(),sn(Up)).default,Hp=async(a,i,p)=>[void 0,Eg]}),Xi,Ki,ho,qp,Dg,Lg,io,xt,Ke=O(()=>{Vr(),Ki=!1,ho=!1,qp=!1,Dg=()=>{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}},Lg=()=>{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}},io=async e=>{if(Ki)return Promise.resolve();if(ho)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(qp)throw new Error("previous call to 'initializeWebAssembly()' failed.");ho=!0;let n=e.initTimeout,a=e.numThreads;if(!Lg())throw new Error("WebAssembly SIMD is not supported in the current environment.");let i=Dg();a>1&&!i&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+a+", 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."),e.numThreads=a=1);let p=e.wasmPaths,o=typeof p=="string"?p:void 0,s=p==null?void 0:p.mjs,c=(s==null?void 0:s.href)??s,h=p==null?void 0:p.wasm,r=(h==null?void 0:h.href)??h,u=e.wasmBinary,[l,f]=await Hp(c,o,a>1),g=!1,b=[];if(n>0&&b.push(new Promise(v=>{setTimeout(()=>{g=!0,v()},n)})),b.push(new Promise((v,S)=>{let P={numThreads:a};u?P.wasmBinary=u:(r||o)&&(P.locateFile=(_,A)=>r??(o??A)+_),f(P).then(_=>{ho=!1,Ki=!0,Xi=_,v(),l&&URL.revokeObjectURL(l)},_=>{ho=!1,qp=!0,S(_)})})),await Promise.race(b),g)throw new Error(`WebAssembly backend initializing failed due to timeout: ${n}ms`)},xt=()=>{if(Ki&&Xi)return Xi;throw new Error("WebAssembly is not initialized yet.")}}),Tt,Wr,ht,mo=O(()=>{Ke(),Tt=(e,n)=>{let a=xt(),i=a.lengthBytesUTF8(e)+1,p=a._malloc(i);return a.stringToUTF8(e,p,i),n.push(p),p},Wr=(e,n,a,i)=>{if(typeof e=="object"&&e!==null){if(a.has(e))throw new Error("Circular reference in options");a.add(e)}Object.entries(e).forEach(([p,o])=>{let s=n?n+p:p;if(typeof o=="object")Wr(o,s+".",a,i);else if(typeof o=="string"||typeof o=="number")i(s,o.toString());else if(typeof o=="boolean")i(s,o?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof o}`)})},ht=e=>{let n=xt(),a=n.stackSave();try{let i=n.stackAlloc(8);n._OrtGetLastError(i,i+4);let p=n.HEAP32[i/4],o=n.HEAPU32[i/4+1],s=o?n.UTF8ToString(o):"";throw new Error(`${e} ERROR_CODE: ${p}, ERROR_MESSAGE: ${s}`)}finally{n.stackRestore(a)}}}),jp,Xp=O(()=>{Ke(),mo(),jp=e=>{let n=xt(),a=0,i=[],p=e||{};try{if((e==null?void 0:e.logSeverityLevel)===void 0)p.logSeverityLevel=2;else if(typeof e.logSeverityLevel!="number"||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if((e==null?void 0:e.logVerbosityLevel)===void 0)p.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!="number"||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);(e==null?void 0:e.terminate)===void 0&&(p.terminate=!1);let o=0;return(e==null?void 0:e.tag)!==void 0&&(o=Tt(e.tag,i)),a=n._OrtCreateRunOptions(p.logSeverityLevel,p.logVerbosityLevel,!!p.terminate,o),a===0&&ht("Can't create run options."),(e==null?void 0:e.extra)!==void 0&&Wr(e.extra,"",new WeakSet,(s,c)=>{let h=Tt(s,i),r=Tt(c,i);n._OrtAddRunConfigEntry(a,h,r)!==0&&ht(`Can't set a run config entry: ${s} - ${c}.`)}),[a,i]}catch(o){throw a!==0&&n._OrtReleaseRunOptions(a),i.forEach(s=>n._free(s)),o}}}),$g,kg,Bg,Fg,Kp,Jp=O(()=>{Ke(),mo(),$g=e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}},kg=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},Bg=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let n=e.extra.session;n.use_ort_model_bytes_directly||(n.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some(a=>(typeof a=="string"?a:a.name)==="webgpu")&&(e.enableMemPattern=!1)},Fg=(e,n,a)=>{for(let i of n){let p=typeof i=="string"?i:i.name;switch(p){case"webnn":if(p="WEBNN",typeof i!="string"){let s=i==null?void 0:i.deviceType;if(s){let c=Tt("deviceType",a),h=Tt(s,a);xt()._OrtAddSessionConfigEntry(e,c,h)!==0&&ht(`Can't set a session config entry: 'deviceType' - ${s}.`)}}break;case"webgpu":if(p="JS",typeof i!="string"){let s=i;if(s!=null&&s.preferredLayout){if(s.preferredLayout!=="NCHW"&&s.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${s.preferredLayout}`);let c=Tt("preferredLayout",a),h=Tt(s.preferredLayout,a);xt()._OrtAddSessionConfigEntry(e,c,h)!==0&&ht(`Can't set a session config entry: 'preferredLayout' - ${s.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${p}`)}let o=Tt(p,a);xt()._OrtAppendExecutionProvider(e,o)!==0&&ht(`Can't append execution provider: ${p}.`)}},Kp=e=>{let n=xt(),a=0,i=[],p=e||{};Bg(p);try{let o=$g(p.graphOptimizationLevel??"all"),s=kg(p.executionMode??"sequential"),c=typeof p.logId=="string"?Tt(p.logId,i):0,h=p.logSeverityLevel??2;if(!Number.isInteger(h)||h<0||h>4)throw new Error(`log serverity level is not valid: ${h}`);let r=p.logVerbosityLevel??0;if(!Number.isInteger(r)||r<0||r>4)throw new Error(`log verbosity level is not valid: ${r}`);let u=typeof p.optimizedModelFilePath=="string"?Tt(p.optimizedModelFilePath,i):0;if(a=n._OrtCreateSessionOptions(o,!!p.enableCpuMemArena,!!p.enableMemPattern,s,!!p.enableProfiling,0,c,h,r,u),a===0&&ht("Can't create session options."),p.executionProviders&&Fg(a,p.executionProviders,i),p.enableGraphCapture!==void 0){if(typeof p.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${p.enableGraphCapture}`);let l=Tt("enableGraphCapture",i),f=Tt(p.enableGraphCapture.toString(),i);n._OrtAddSessionConfigEntry(a,l,f)!==0&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${p.enableGraphCapture}.`)}if(p.freeDimensionOverrides)for(let[l,f]of Object.entries(p.freeDimensionOverrides)){if(typeof l!="string")throw new Error(`free dimension override name must be a string: ${l}`);if(typeof f!="number"||!Number.isInteger(f)||f<0)throw new Error(`free dimension override value must be a non-negative integer: ${f}`);let g=Tt(l,i);n._OrtAddFreeDimensionOverride(a,g,f)!==0&&ht(`Can't set a free dimension override: ${l} - ${f}.`)}return p.extra!==void 0&&Wr(p.extra,"",new WeakSet,(l,f)=>{let g=Tt(l,i),b=Tt(f,i);n._OrtAddSessionConfigEntry(a,g,b)!==0&&ht(`Can't set a session config entry: ${l} - ${f}.`)}),[a,i]}catch(o){throw a!==0&&n._OrtReleaseSessionOptions(a),i.forEach(s=>n._free(s)),o}}}),Hr,Yp,qr,Zp,Qp,bo,go,td,Ji=O(()=>{Hr=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${e}`)}},Yp=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${e}`)}},qr=(e,n)=>{let a=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],i=typeof n=="number"?n:n.reduce((p,o)=>p*o,1);return a>0?Math.ceil(i*a):void 0},Zp=e=>{switch(e){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: ${e}`)}},Qp=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}},bo=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",go=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint64"||e==="int8"||e==="uint8"||e==="bool",td=e=>{switch(e){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${e}`)}}}),jr,Yi=O(()=>{oo(),jr=async e=>{if(typeof e=="string"){let n=await fetch(e);if(!n.ok)throw new Error(`failed to load external data file: ${e}`);let a=n.headers.get("Content-Length"),i=a?parseInt(a,10):0;if(i<1073741824)return new Uint8Array(await n.arrayBuffer());{if(!n.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let p=n.body.getReader(),o;try{o=new ArrayBuffer(i)}catch(c){if(c instanceof RangeError){let h=Math.ceil(i/65536);o=new WebAssembly.Memory({initial:h,maximum:h}).buffer}else throw c}let s=0;for(;;){let{done:c,value:h}=await p.read();if(c)break;let r=h.byteLength;new Uint8Array(o,s,r).set(h),s+=r}return new Uint8Array(o,0,i)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Cg,ao,so,yr,Ng,zr,uo,lo,ed,fo,co,po,qi=O(()=>{Xp(),Jp(),Ji(),Ke(),mo(),Yi(),Cg=(e,n)=>{xt()._OrtInit(e,n)!==0&&ht("Can't initialize onnxruntime.")},ao=async e=>{Cg(e.wasm.numThreads,Qp(e.logLevel))},so=async(e,n)=>{},yr=new Map,Ng=e=>{let n=xt(),a=n.stackSave();try{let i=n.stackAlloc(8);return n._OrtGetInputOutputCount(e,i,i+4)!==0&&ht("Can't get session input/output count."),[n.HEAP32[i/4],n.HEAP32[i/4+1]]}finally{n.stackRestore(a)}},zr=e=>{let n=xt(),a=n._malloc(e.byteLength);if(a===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return n.HEAPU8.set(e,a),[a,e.byteLength]},uo=async(e,n)=>{var u;let a,i,p=xt();Array.isArray(e)?[a,i]=e:e.buffer===p.HEAPU8.buffer?[a,i]=[e.byteOffset,e.byteLength]:[a,i]=zr(e);let o=0,s=0,c=[],h=[],r=[];try{if([s,c]=Kp(n),(n==null?void 0:n.externalData)&&p.mountExternalData){let _=[];for(let A of n.externalData){let L=typeof A=="string"?A:A.path;_.push(jr(typeof A=="string"?A:A.data).then(V=>{p.mountExternalData(L,V)}))}await Promise.all(_)}for(let _ of(n==null?void 0:n.executionProviders)??[])if((typeof _=="string"?_:_.name)==="webnn"){if(p.shouldTransferToMLTensor=!1,p.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof _!="string"){let A=_,L=A==null?void 0:A.context,V=A==null?void 0:A.gpuDevice,ft=A==null?void 0:A.deviceType,lt=A==null?void 0:A.numThreads,Nt=A==null?void 0:A.powerPreference;L?p.currentContext=L:V?p.currentContext=await navigator.ml.createContext(V):p.currentContext=await navigator.ml.createContext({deviceType:ft,numThreads:lt,powerPreference:Nt})}else p.currentContext=await navigator.ml.createContext();break}o=await p._OrtCreateSession(a,i,s),o===0&&ht("Can't create a session."),p.currentContext&&(p.jsepRegisterMLContext(o,p.currentContext),p.currentContext=void 0,p.shouldTransferToMLTensor=!0);let[l,f]=Ng(o),g=!!(n!=null&&n.enableGraphCapture),b=[],v=[],S=[];for(let _=0;_<l;_++){let A=p._OrtGetInputName(o,_);A===0&&ht("Can't get an input name."),h.push(A),b.push(p.UTF8ToString(A))}for(let _=0;_<f;_++){let A=p._OrtGetOutputName(o,_);A===0&&ht("Can't get an output name."),r.push(A);let L=p.UTF8ToString(A);v.push(L)}return yr.set(o,[o,h,r,null,g,!1]),[o,b,v]}catch(l){throw h.forEach(f=>p._OrtFree(f)),r.forEach(f=>p._OrtFree(f)),o!==0&&p._OrtReleaseSession(o),l}finally{p._free(a),s!==0&&p._OrtReleaseSessionOptions(s),c.forEach(l=>p._free(l)),(u=p.unmountExternalData)==null||u.call(p)}},lo=e=>{var h;let n=xt(),a=yr.get(e);if(!a)throw new Error(`cannot release session. invalid session id: ${e}`);let[i,p,o,s,c]=a;s&&(c&&n._OrtClearBoundOutputs(s.handle),n._OrtReleaseBinding(s.handle)),(h=n.jsepOnReleaseSession)==null||h.call(n,e),p.forEach(r=>n._OrtFree(r)),o.forEach(r=>n._OrtFree(r)),n._OrtReleaseSession(i),yr.delete(e)},ed=(e,n,a,i,p,o=!1)=>{if(!e){n.push(0);return}let s=xt(),c=e[0],h=e[1],r=e[3],u,l;if(c==="string"&&(r==="gpu-buffer"||r==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(o&&r!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${p} when enableGraphCapture is true.`);if(r==="gpu-buffer"){let b=e[2].gpuBuffer;l=qr(Hr(c),h);let v=s.jsepRegisterBuffer;if(!v)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');u=v(i,p,b,l)}else if(r==="ml-tensor"){let b=e[2].mlTensor;l=qr(Hr(c),h);let v=s.jsepRegisterMLTensor;if(!v)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');u=v(b,Hr(c),h)}else{let b=e[2];if(Array.isArray(b)){l=4*b.length,u=s._malloc(l),a.push(u);let v=u/4;for(let S=0;S<b.length;S++){if(typeof b[S]!="string")throw new TypeError(`tensor data at index ${S} is not a string`);s.HEAPU32[v++]=Tt(b[S],a)}}else l=b.byteLength,u=s._malloc(l),a.push(u),s.HEAPU8.set(new Uint8Array(b.buffer,b.byteOffset,l),u)}let f=s.stackSave(),g=s.stackAlloc(4*h.length);try{let b=g/4;h.forEach(S=>s.HEAP32[b++]=S);let v=s._OrtCreateTensor(Hr(c),u,l,g,h.length,td(r));v===0&&ht(`Can't create tensor for input/output. session=${i}, index=${p}.`),n.push(v)}finally{s.stackRestore(f)}},fo=async(e,n,a,i,p,o)=>{var Q;let s=xt(),c=yr.get(e);if(!c)throw new Error(`cannot run inference. invalid session id: ${e}`);let h=c[0],r=c[1],u=c[2],l=c[3],f=c[4];c[5];let g=n.length,b=i.length,v=0,S=[],P=[],_=[],A=[],L=s.stackSave(),V=s.stackAlloc(g*4),ft=s.stackAlloc(g*4),lt=s.stackAlloc(b*4),Nt=s.stackAlloc(b*4);try{(Q=s.jsepOnRunStart)==null||Q.call(s,h),[v,S]=jp(o);for(let X=0;X<g;X++)ed(a[X],P,A,e,n[X],f);for(let X=0;X<b;X++)ed(p[X],_,A,e,g+i[X],f);let Pt=V/4,$e=ft/4,gt=lt/4,De=Nt/4;for(let X=0;X<g;X++)s.HEAPU32[Pt++]=P[X],s.HEAPU32[$e++]=r[n[X]];for(let X=0;X<b;X++)s.HEAPU32[gt++]=_[X],s.HEAPU32[De++]=u[i[X]];let Ft;Ft=await s._OrtRun(h,ft,V,g,Nt,b,lt,v),Ft!==0&&ht("failed to call OrtRun().");let wt=[];for(let X=0;X<b;X++){let Wt=s.HEAPU32[lt/4+X];if(Wt===_[X]){wt.push(p[X]);continue}let Le=s.stackSave(),_t=s.stackAlloc(4*4),se=!1,it,at=0;try{s._OrtGetTensorData(Wt,_t,_t+4,_t+8,_t+12)!==0&&ht(`Can't access output tensor data on index ${X}.`);let re=_t/4,Jt=s.HEAPU32[re++];at=s.HEAPU32[re++];let Re=s.HEAPU32[re++],oe=s.HEAPU32[re++],Ot=[];for(let nt=0;nt<oe;nt++)Ot.push(s.HEAPU32[Re/4+nt]);s._OrtFree(Re);let $t=Ot.reduce((nt,st)=>nt*st,1);it=Yp(Jt);let Lt=l==null?void 0:l.outputPreferredLocations[i[X]];if(it==="string"){if(Lt==="gpu-buffer"||Lt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let nt=[],st=at/4;for(let Mt=0;Mt<$t;Mt++){let ce=s.HEAPU32[st++],Ge=Mt===$t-1?void 0:s.HEAPU32[st]-ce;nt.push(s.UTF8ToString(ce,Ge))}wt.push([it,Ot,nt,"cpu"])}else if(Lt==="gpu-buffer"&&$t>0){let nt=s.jsepGetBuffer;if(!nt)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let st=nt(at),Mt=qr(Jt,$t);if(Mt===void 0||!bo(it))throw new Error(`Unsupported data type: ${it}`);se=!0,wt.push([it,Ot,{gpuBuffer:st,download:s.jsepCreateDownloader(st,Mt,it),dispose:()=>{s._OrtReleaseTensor(Wt)}},"gpu-buffer"])}else if(Lt==="ml-tensor"&&$t>0){let nt=s.jsepEnsureTensor;if(!nt)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(qr(Jt,$t)===void 0||!go(it))throw new Error(`Unsupported data type: ${it}`);let st=await nt(at,Jt,Ot,!1);se=!0,wt.push([it,Ot,{mlTensor:st,download:s.jsepCreateMLTensorDownloader(at,it),dispose:()=>{s.jsepReleaseTensorId(at),s._OrtReleaseTensor(Wt)}},"ml-tensor"])}else{let nt=Zp(it),st=new nt($t);new Uint8Array(st.buffer,st.byteOffset,st.byteLength).set(s.HEAPU8.subarray(at,at+st.byteLength)),wt.push([it,Ot,st,"cpu"])}}finally{s.stackRestore(Le),it==="string"&&at&&s._free(at),se||s._OrtReleaseTensor(Wt)}}return l&&!f&&(s._OrtClearBoundOutputs(l.handle),yr.set(e,[h,r,u,l,f,!1])),wt}finally{s.stackRestore(L),P.forEach(Pt=>s._OrtReleaseTensor(Pt)),_.forEach(Pt=>s._OrtReleaseTensor(Pt)),A.forEach(Pt=>s._free(Pt)),v!==0&&s._OrtReleaseRunOptions(v),S.forEach(Pt=>s._free(Pt))}},co=e=>{let n=xt(),a=yr.get(e);if(!a)throw new Error("invalid session id");let i=a[0],p=n._OrtEndProfiling(i);p===0&&ht("Can't get an profile file name."),n._OrtFree(p)},po=e=>{let n=[];for(let a of e){let i=a[2];!Array.isArray(i)&&"buffer"in i&&n.push(i.buffer)}return n}}),Je,Kt,Xr,xo,To,yo,Zi,Qi,xr,Tr,Gg,rd,nd,od,id,ad,sd,ud,ta=O(()=>{Yt(),qi(),Ke(),Vr(),Je=()=>!!z.wasm.proxy&&typeof document<"u",Xr=!1,xo=!1,To=!1,Qi=new Map,xr=(e,n)=>{let a=Qi.get(e);a?a.push(n):Qi.set(e,[n])},Tr=()=>{if(Xr||!xo||To||!Kt)throw new Error("worker not ready")},Gg=e=>{switch(e.data.type){case"init-wasm":Xr=!1,e.data.err?(To=!0,Zi[1](e.data.err)):(xo=!0,Zi[0]()),yo&&(URL.revokeObjectURL(yo),yo=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let n=Qi.get(e.data.type);e.data.err?n.shift()[1](e.data.err):n.shift()[0](e.data.out);break}}},rd=async()=>{if(!xo){if(Xr)throw new Error("multiple calls to 'initWasm()' detected.");if(To)throw new Error("previous call to 'initWasm()' failed.");if(Xr=!0,Je())return new Promise((e,n)=>{Kt==null||Kt.terminate(),Wp().then(([a,i])=>{try{Kt=i,Kt.onerror=o=>n(o),Kt.onmessage=Gg,Zi=[e,n];let p={type:"init-wasm",in:z};Kt.postMessage(p),yo=a}catch(p){n(p)}},n)});try{await io(z.wasm),await ao(z),xo=!0}catch(e){throw To=!0,e}finally{Xr=!1}}},nd=async e=>{if(Je())return Tr(),new Promise((n,a)=>{xr("init-ep",[n,a]);let i={type:"init-ep",in:{epName:e,env:z}};Kt.postMessage(i)});await so(z,e)},od=async e=>Je()?(Tr(),new Promise((n,a)=>{xr("copy-from",[n,a]);let i={type:"copy-from",in:{buffer:e}};Kt.postMessage(i,[e.buffer])})):zr(e),id=async(e,n)=>{if(Je()){if(n!=null&&n.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Tr(),new Promise((a,i)=>{xr("create",[a,i]);let p={type:"create",in:{model:e,options:{...n}}},o=[];e instanceof Uint8Array&&o.push(e.buffer),Kt.postMessage(p,o)})}else return uo(e,n)},ad=async e=>{if(Je())return Tr(),new Promise((n,a)=>{xr("release",[n,a]);let i={type:"release",in:e};Kt.postMessage(i)});lo(e)},sd=async(e,n,a,i,p,o)=>{if(Je()){if(a.some(s=>s[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(p.some(s=>s))throw new Error("pre-allocated output tensor is not supported for proxy.");return Tr(),new Promise((s,c)=>{xr("run",[s,c]);let h=a,r={type:"run",in:{sessionId:e,inputIndices:n,inputs:h,outputIndices:i,options:o}};Kt.postMessage(r,po(h))})}else return fo(e,n,a,i,p,o)},ud=async e=>{if(Je())return Tr(),new Promise((n,a)=>{xr("end-profiling",[n,a]);let i={type:"end-profiling",in:e};Kt.postMessage(i)});co(e)}}),ld,Mg,wo,fd=O(()=>{Yt(),ta(),Ji(),oo(),Yi(),ld=(e,n)=>{switch(e.location){case"cpu":return[e.type,e.dims,e.data,"cpu"];case"gpu-buffer":return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[e.type,e.dims,{mlTensor:e.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${e.location} for ${n()}`)}},Mg=e=>{switch(e[3]){case"cpu":return new yt(e[0],e[2],e[1]);case"gpu-buffer":{let n=e[0];if(!bo(n))throw new Error(`not supported data type: ${n} for deserializing GPU tensor`);let{gpuBuffer:a,download:i,dispose:p}=e[2];return yt.fromGpuBuffer(a,{dataType:n,dims:e[1],download:i,dispose:p})}case"ml-tensor":{let n=e[0];if(!go(n))throw new Error(`not supported data type: ${n} for deserializing MLTensor tensor`);let{mlTensor:a,download:i,dispose:p}=e[2];return yt.fromMLTensor(a,{dataType:n,dims:e[1],download:i,dispose:p})}default:throw new Error(`invalid data location: ${e[3]}`)}},wo=class{async fetchModelAndCopyToWasmMemory(e){return od(await jr(e))}async loadModel(e,n){Fe();let a;typeof e=="string"?a=await this.fetchModelAndCopyToWasmMemory(e):a=e,[this.sessionId,this.inputNames,this.outputNames]=await id(a,n),Ce()}async dispose(){return ad(this.sessionId)}async run(e,n,a){Fe();let i=[],p=[];Object.entries(e).forEach(l=>{let f=l[0],g=l[1],b=this.inputNames.indexOf(f);if(b===-1)throw new Error(`invalid input '${f}'`);i.push(g),p.push(b)});let o=[],s=[];Object.entries(n).forEach(l=>{let f=l[0],g=l[1],b=this.outputNames.indexOf(f);if(b===-1)throw new Error(`invalid output '${f}'`);o.push(g),s.push(b)});let c=i.map((l,f)=>ld(l,()=>`input "${this.inputNames[p[f]]}"`)),h=o.map((l,f)=>l?ld(l,()=>`output "${this.outputNames[s[f]]}"`):null),r=await sd(this.sessionId,p,c,s,h,a),u={};for(let l=0;l<r.length;l++)u[this.outputNames[s[l]]]=o[l]??Mg(r[l]);return Ce(),u}startProfiling(){}endProfiling(){ud(this.sessionId)}}}),pd={};Or(pd,{OnnxruntimeWebAssemblyBackend:()=>vo,initializeFlags:()=>cd,wasmBackend:()=>Ug});var cd,vo,Ug,dd=O(()=>{Yt(),ta(),fd(),Vr(),cd=()=>{if((typeof z.wasm.initTimeout!="number"||z.wasm.initTimeout<0)&&(z.wasm.initTimeout=0),z.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 z.wasm.proxy!="boolean"&&(z.wasm.proxy=!1),typeof z.wasm.trace!="boolean"&&(z.wasm.trace=!1),typeof z.wasm.numThreads!="number"||!Number.isInteger(z.wasm.numThreads)||z.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)z.wasm.numThreads=1;else{let e=typeof navigator>"u"?Co("node:os").cpus().length:navigator.hardwareConcurrency;z.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},vo=class{async init(e){cd(),await rd(),await nd(e)}async createInferenceSessionHandler(e,n){let a=new wo;return await a.loadModel(e,n),Promise.resolve(a)}},Ug=new vo});Yt(),Yt(),Yt();var Ds="1.20.1";{let e=(Fp(),sn(Bp)).onnxjsBackend;nr("webgl",e,-10)}{let e=(dd(),sn(pd)).wasmBackend;nr("cpu",e,10),nr("wasm",e,10)}Object.defineProperty(z.versions,"web",{value:Ds,enumerable:!0});/*! Bundled license information:
1808
+ `))[0]=="Error"&&E.shift(),ia(E);for(var I=3;E[I]&&tr()!=m;)++I;for(m=0;m<x&&E[m+I];++m)p()[y+4*m>>>2>>>0]=tr();return m}var Yr,Jr={},aa=()=>{if(!Yr){var m,y={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_};for(m in Jr)Jr[m]===void 0?delete y[m]:y[m]=Jr[m];var x=[];for(m in y)x.push(`${m}=${y[m]}`);Yr=x}return Yr};function sa(m,y){if(g)return Z(18,1,m,y);m>>>=0,y>>>=0;var x=0;return aa().forEach((E,I)=>{var N=y+x;for(I=o()[m+4*I>>>2>>>0]=N,N=0;N<E.length;++N)i()[I++>>>0]=E.charCodeAt(N);i()[I>>>0]=0,x+=E.length+1}),0}function la(m,y){if(g)return Z(19,1,m,y);m>>>=0,y>>>=0;var x=aa();o()[m>>>2>>>0]=x.length;var E=0;return x.forEach(I=>E+=I.length+1),o()[y>>>2>>>0]=E,0}function ua(m){return g?Z(20,1,m):52}function pa(m,y,x,E){return g?Z(21,1,m,y,x,E):52}function da(m,y,x,E){return g?Z(22,1,m,y,x,E):70}var Xs=[null,[],[]];function ca(m,y,x,E){if(g)return Z(23,1,m,y,x,E);y>>>=0,x>>>=0,E>>>=0;for(var I=0,N=0;N<x;N++){var R=o()[y>>>2>>>0],K=o()[y+4>>>2>>>0];y+=8;for(var pt=0;pt<K;pt++){var ct=a()[R+pt>>>0],vt=Xs[m];ct===0||ct===10?((m===1?Nt:Q)(Do(vt,0)),vt.length=0):vt.push(ct)}I+=K}return o()[E>>>2>>>0]=I,0}var ha=[31,29,31,30,31,30,31,31,30,31,30,31],fa=[31,28,31,30,31,30,31,31,30,31,30,31],Ks=(m,y)=>{i().set(m,y>>>0)};function ga(m,y,x,E){function I($,U,et){for($=typeof $=="number"?$.toString():$||"";$.length<U;)$=et[0]+$;return $}function N($,U){return I($,U,"0")}function R($,U){function et(_a){return 0>_a?-1:0<_a?1:0}var ae;return(ae=et($.getFullYear()-U.getFullYear()))===0&&(ae=et($.getMonth()-U.getMonth()))===0&&(ae=et($.getDate()-U.getDate())),ae}function K($){switch($.getDay()){case 0:return new Date($.getFullYear()-1,11,29);case 1:return $;case 2:return new Date($.getFullYear(),0,3);case 3:return new Date($.getFullYear(),0,2);case 4:return new Date($.getFullYear(),0,1);case 5:return new Date($.getFullYear()-1,11,31);case 6:return new Date($.getFullYear()-1,11,30)}}function pt($){var U=$.Sa;for($=new Date(new Date($.Ta+1900,0,1).getTime());0<U;){var et=$.getMonth(),ae=(le($.getFullYear())?ha:fa)[et];if(!(U>ae-$.getDate())){$.setDate($.getDate()+U);break}U-=ae-$.getDate()+1,$.setDate(1),11>et?$.setMonth(et+1):($.setMonth(0),$.setFullYear($.getFullYear()+1))}return et=new Date($.getFullYear()+1,0,4),U=K(new Date($.getFullYear(),0,4)),et=K(et),0>=R(U,$)?0>=R(et,$)?$.getFullYear()+1:$.getFullYear():$.getFullYear()-1}m>>>=0,y>>>=0,x>>>=0,E>>>=0;var ct=o()[E+40>>>2>>>0];for(var vt in E={gb:p()[E>>>2>>>0],fb:p()[E+4>>>2>>>0],Va:p()[E+8>>>2>>>0],Ya:p()[E+12>>>2>>>0],Wa:p()[E+16>>>2>>>0],Ta:p()[E+20>>>2>>>0],Qa:p()[E+24>>>2>>>0],Sa:p()[E+28>>>2>>>0],ob:p()[E+32>>>2>>>0],eb:p()[E+36>>>2>>>0],hb:ct?ge(ct):""},x=ge(x),ct={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})x=x.replace(new RegExp(vt,"g"),ct[vt]);var xa="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ta="January February March April May June July August September October November December".split(" ");for(vt in ct={"%a":$=>xa[$.Qa].substring(0,3),"%A":$=>xa[$.Qa],"%b":$=>Ta[$.Wa].substring(0,3),"%B":$=>Ta[$.Wa],"%C":$=>N(($.Ta+1900)/100|0,2),"%d":$=>N($.Ya,2),"%e":$=>I($.Ya,2," "),"%g":$=>pt($).toString().substring(2),"%G":pt,"%H":$=>N($.Va,2),"%I":$=>(($=$.Va)==0?$=12:12<$&&($-=12),N($,2)),"%j":$=>{for(var U=0,et=0;et<=$.Wa-1;U+=(le($.Ta+1900)?ha:fa)[et++]);return N($.Ya+U,3)},"%m":$=>N($.Wa+1,2),"%M":$=>N($.fb,2),"%n":()=>`
1809
+ `,"%p":$=>0<=$.Va&&12>$.Va?"AM":"PM","%S":$=>N($.gb,2),"%t":()=>" ","%u":$=>$.Qa||7,"%U":$=>N(Math.floor(($.Sa+7-$.Qa)/7),2),"%V":$=>{var U=Math.floor(($.Sa+7-($.Qa+6)%7)/7);if(2>=($.Qa+371-$.Sa-2)%7&&U++,U)U==53&&((et=($.Qa+371-$.Sa)%7)==4||et==3&&le($.Ta)||(U=1));else{U=52;var et=($.Qa+7-$.Sa-1)%7;(et==4||et==5&&le($.Ta%400-1))&&U++}return N(U,2)},"%w":$=>$.Qa,"%W":$=>N(Math.floor(($.Sa+7-($.Qa+6)%7)/7),2),"%y":$=>($.Ta+1900).toString().substring(2),"%Y":$=>$.Ta+1900,"%z":$=>{var U=0<=($=$.eb);return $=Math.abs($)/60,(U?"+":"-")+("0000"+($/60*100+$%60)).slice(-4)},"%Z":$=>$.hb,"%%":()=>"%"},x=x.replace(/%%/g,"\0\0"),ct)x.includes(vt)&&(x=x.replace(new RegExp(vt,"g"),ct[vt](E)));return vt=function($){var U=Array(Lo($)+1);return jo($,U,0,U.length),U}(x=x.replace(/\0\0/g,"%")),vt.length>y?0:(Ks(vt,m),vt.length-1)}function Js(m,y,x,E){return ga(m>>>0,y>>>0,x>>>0,E>>>0)}g||function(){for(var m=r.numThreads-1;m--;)Eo();re.unshift(()=>{oe++,function(y){g?y():Promise.all(te.map(So)).then(y)}(()=>$t())})}();var Zs=[Er,On,Po,ko,Fo,Bo,zo,Xo,Ko,Yo,Jo,Zo,Qo,ti,ri,ni,ra,na,sa,la,ua,pa,da,ca],V=function(){function m(x,E){return V=x.exports,V=function(){var I=V,N=K=>()=>K()>>>0,R=K=>pt=>K(pt)>>>0;return(I=Object.assign({},I)).Ba=N(I.Ba),I.Ca=R(I.Ca),I.emscripten_main_runtime_thread_id=N(I.emscripten_main_runtime_thread_id),I.Oa=R(I.Oa),I.Pa=N(I.Pa),I}(),In.push(V.Ea),Io=V.Fa,Jt.unshift(V.$),De=E,$t(),V}var y=on();if(oe++,r.instantiateWasm)try{return r.instantiateWasm(y,m)}catch(x){Q(`Module.instantiateWasm callback failed with error: ${x}`),h(x)}return nt||(nt=r.locateFile?st("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":r.locateFile?r.locateFile("ort-wasm-simd-threaded.wasm",L):L+"ort-wasm-simd-threaded.wasm":""),function(x,E){var I=nt;return M||typeof WebAssembly.instantiateStreaming!="function"||st(I)||Mt(I)||typeof fetch!="function"?Ge(I,x,E):fetch(I,{credentials:"same-origin"}).then(N=>WebAssembly.instantiateStreaming(N,x).then(E,function(R){return Q(`wasm streaming compile failed: ${R}`),Q("falling back to ArrayBuffer instantiation"),Ge(I,x,E)}))}(y,function(x){m(x.instance,x.module)}).catch(h),{}}();r._OrtInit=(m,y)=>(r._OrtInit=V.aa)(m,y),r._OrtGetLastError=(m,y)=>(r._OrtGetLastError=V.ba)(m,y),r._OrtCreateSessionOptions=(m,y,x,E,I,N,R,K,pt,ct)=>(r._OrtCreateSessionOptions=V.ca)(m,y,x,E,I,N,R,K,pt,ct),r._OrtAppendExecutionProvider=(m,y)=>(r._OrtAppendExecutionProvider=V.da)(m,y),r._OrtAddFreeDimensionOverride=(m,y,x)=>(r._OrtAddFreeDimensionOverride=V.ea)(m,y,x),r._OrtAddSessionConfigEntry=(m,y,x)=>(r._OrtAddSessionConfigEntry=V.fa)(m,y,x),r._OrtReleaseSessionOptions=m=>(r._OrtReleaseSessionOptions=V.ga)(m),r._OrtCreateSession=(m,y,x)=>(r._OrtCreateSession=V.ha)(m,y,x),r._OrtReleaseSession=m=>(r._OrtReleaseSession=V.ia)(m),r._OrtGetInputOutputCount=(m,y,x)=>(r._OrtGetInputOutputCount=V.ja)(m,y,x),r._OrtGetInputName=(m,y)=>(r._OrtGetInputName=V.ka)(m,y),r._OrtGetOutputName=(m,y)=>(r._OrtGetOutputName=V.la)(m,y),r._OrtFree=m=>(r._OrtFree=V.ma)(m),r._OrtCreateTensor=(m,y,x,E,I,N)=>(r._OrtCreateTensor=V.na)(m,y,x,E,I,N),r._OrtGetTensorData=(m,y,x,E,I)=>(r._OrtGetTensorData=V.oa)(m,y,x,E,I),r._OrtReleaseTensor=m=>(r._OrtReleaseTensor=V.pa)(m),r._OrtCreateRunOptions=(m,y,x,E)=>(r._OrtCreateRunOptions=V.qa)(m,y,x,E),r._OrtAddRunConfigEntry=(m,y,x)=>(r._OrtAddRunConfigEntry=V.ra)(m,y,x),r._OrtReleaseRunOptions=m=>(r._OrtReleaseRunOptions=V.sa)(m),r._OrtCreateBinding=m=>(r._OrtCreateBinding=V.ta)(m),r._OrtBindInput=(m,y,x)=>(r._OrtBindInput=V.ua)(m,y,x),r._OrtBindOutput=(m,y,x,E)=>(r._OrtBindOutput=V.va)(m,y,x,E),r._OrtClearBoundOutputs=m=>(r._OrtClearBoundOutputs=V.wa)(m),r._OrtReleaseBinding=m=>(r._OrtReleaseBinding=V.xa)(m),r._OrtRunWithBinding=(m,y,x,E,I)=>(r._OrtRunWithBinding=V.ya)(m,y,x,E,I),r._OrtRun=(m,y,x,E,I,N,R,K)=>(r._OrtRun=V.za)(m,y,x,E,I,N,R,K),r._OrtEndProfiling=m=>(r._OrtEndProfiling=V.Aa)(m);var ue=()=>(ue=V.Ba)();r._malloc=m=>(r._malloc=V.Ca)(m),r._free=m=>(r._free=V.Da)(m);var er,Zr=(m,y,x,E,I,N)=>(Zr=V.Ga)(m,y,x,E,I,N),ma=()=>(ma=V.Ha)(),ba=(m,y,x,E,I)=>(ba=V.Ia)(m,y,x,E,I),Qr=m=>(Qr=V.Ja)(m),ar=m=>(ar=V.Ka)(m),ya=()=>(ya=V.La)(),wa=(m,y)=>(wa=V.Ma)(m,y),gr=m=>(gr=V.Na)(m),tn=m=>(tn=V.Oa)(m),en=()=>(en=V.Pa)();function va(){0<oe||(g?(c(r),g||Ye(Jt),startWorker(r)):(Ye(re),0<oe||er||(er=!0,r.calledRun=!0,it||(g||Ye(Jt),c(r),g||Ye(Re)))))}return r.___start_em_js=838360,r.___stop_em_js=838421,r.stackSave=()=>en(),r.stackRestore=m=>gr(m),r.stackAlloc=m=>tn(m),r.UTF8ToString=ge,r.stringToUTF8=be,r.lengthBytesUTF8=Lo,Ot=function m(){er||va(),er||(Ot=m)},va(),u}),Og=Mp,((e=globalThis.self)==null?void 0:e.name)==="em-pthread"&&Mp()}),br,Sg,Ag,Pg,zp,Wp,Eg,Hp,Vr=O(()=>{var e,n;oo(),br=(_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("segmentation.js",document.baseURI).href)??(typeof document<"u"?(e=document.currentScript)==null?void 0:e.src:typeof self<"u"?(n=self.location)==null?void 0:n.href:void 0),Sg=typeof location>"u"?void 0:location.origin,Ag=(i,a)=>{try{let p=a??br;return(p?new URL(i,p):new URL(i)).origin===Sg}catch{return!1}},Pg=async i=>{let a=await(await fetch(i,{credentials:"same-origin"})).blob();return URL.createObjectURL(a)},zp=(Gp(),sn(Rp)).default,Wp=async()=>{if(!br)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Ag(br))return[void 0,zp()];let i=await Pg(br);return[i,zp(i)]},Eg=(Vp(),sn(Up)).default,Hp=async(i,a,p)=>[void 0,Eg]}),Xi,Ki,ho,qp,Dg,Lg,io,xt,Ke=O(()=>{Vr(),Ki=!1,ho=!1,qp=!1,Dg=()=>{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}},Lg=()=>{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}},io=async e=>{if(Ki)return Promise.resolve();if(ho)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(qp)throw new Error("previous call to 'initializeWebAssembly()' failed.");ho=!0;let n=e.initTimeout,i=e.numThreads;if(!Lg())throw new Error("WebAssembly SIMD is not supported in the current environment.");let a=Dg();i>1&&!a&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+i+", 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."),e.numThreads=i=1);let p=e.wasmPaths,o=typeof p=="string"?p:void 0,s=p==null?void 0:p.mjs,c=(s==null?void 0:s.href)??s,h=p==null?void 0:p.wasm,r=(h==null?void 0:h.href)??h,u=e.wasmBinary,[l,f]=await Hp(c,o,i>1),g=!1,b=[];if(n>0&&b.push(new Promise(v=>{setTimeout(()=>{g=!0,v()},n)})),b.push(new Promise((v,S)=>{let P={numThreads:i};u?P.wasmBinary=u:(r||o)&&(P.locateFile=(_,A)=>r??(o??A)+_),f(P).then(_=>{ho=!1,Ki=!0,Xi=_,v(),l&&URL.revokeObjectURL(l)},_=>{ho=!1,qp=!0,S(_)})})),await Promise.race(b),g)throw new Error(`WebAssembly backend initializing failed due to timeout: ${n}ms`)},xt=()=>{if(Ki&&Xi)return Xi;throw new Error("WebAssembly is not initialized yet.")}}),Tt,Wr,ht,mo=O(()=>{Ke(),Tt=(e,n)=>{let i=xt(),a=i.lengthBytesUTF8(e)+1,p=i._malloc(a);return i.stringToUTF8(e,p,a),n.push(p),p},Wr=(e,n,i,a)=>{if(typeof e=="object"&&e!==null){if(i.has(e))throw new Error("Circular reference in options");i.add(e)}Object.entries(e).forEach(([p,o])=>{let s=n?n+p:p;if(typeof o=="object")Wr(o,s+".",i,a);else if(typeof o=="string"||typeof o=="number")a(s,o.toString());else if(typeof o=="boolean")a(s,o?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof o}`)})},ht=e=>{let n=xt(),i=n.stackSave();try{let a=n.stackAlloc(8);n._OrtGetLastError(a,a+4);let p=n.HEAP32[a/4],o=n.HEAPU32[a/4+1],s=o?n.UTF8ToString(o):"";throw new Error(`${e} ERROR_CODE: ${p}, ERROR_MESSAGE: ${s}`)}finally{n.stackRestore(i)}}}),jp,Xp=O(()=>{Ke(),mo(),jp=e=>{let n=xt(),i=0,a=[],p=e||{};try{if((e==null?void 0:e.logSeverityLevel)===void 0)p.logSeverityLevel=2;else if(typeof e.logSeverityLevel!="number"||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if((e==null?void 0:e.logVerbosityLevel)===void 0)p.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!="number"||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);(e==null?void 0:e.terminate)===void 0&&(p.terminate=!1);let o=0;return(e==null?void 0:e.tag)!==void 0&&(o=Tt(e.tag,a)),i=n._OrtCreateRunOptions(p.logSeverityLevel,p.logVerbosityLevel,!!p.terminate,o),i===0&&ht("Can't create run options."),(e==null?void 0:e.extra)!==void 0&&Wr(e.extra,"",new WeakSet,(s,c)=>{let h=Tt(s,a),r=Tt(c,a);n._OrtAddRunConfigEntry(i,h,r)!==0&&ht(`Can't set a run config entry: ${s} - ${c}.`)}),[i,a]}catch(o){throw i!==0&&n._OrtReleaseRunOptions(i),a.forEach(s=>n._free(s)),o}}}),$g,kg,Bg,Fg,Kp,Jp=O(()=>{Ke(),mo(),$g=e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}},kg=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},Bg=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let n=e.extra.session;n.use_ort_model_bytes_directly||(n.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some(i=>(typeof i=="string"?i:i.name)==="webgpu")&&(e.enableMemPattern=!1)},Fg=(e,n,i)=>{for(let a of n){let p=typeof a=="string"?a:a.name;switch(p){case"webnn":if(p="WEBNN",typeof a!="string"){let s=a==null?void 0:a.deviceType;if(s){let c=Tt("deviceType",i),h=Tt(s,i);xt()._OrtAddSessionConfigEntry(e,c,h)!==0&&ht(`Can't set a session config entry: 'deviceType' - ${s}.`)}}break;case"webgpu":if(p="JS",typeof a!="string"){let s=a;if(s!=null&&s.preferredLayout){if(s.preferredLayout!=="NCHW"&&s.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${s.preferredLayout}`);let c=Tt("preferredLayout",i),h=Tt(s.preferredLayout,i);xt()._OrtAddSessionConfigEntry(e,c,h)!==0&&ht(`Can't set a session config entry: 'preferredLayout' - ${s.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${p}`)}let o=Tt(p,i);xt()._OrtAppendExecutionProvider(e,o)!==0&&ht(`Can't append execution provider: ${p}.`)}},Kp=e=>{let n=xt(),i=0,a=[],p=e||{};Bg(p);try{let o=$g(p.graphOptimizationLevel??"all"),s=kg(p.executionMode??"sequential"),c=typeof p.logId=="string"?Tt(p.logId,a):0,h=p.logSeverityLevel??2;if(!Number.isInteger(h)||h<0||h>4)throw new Error(`log serverity level is not valid: ${h}`);let r=p.logVerbosityLevel??0;if(!Number.isInteger(r)||r<0||r>4)throw new Error(`log verbosity level is not valid: ${r}`);let u=typeof p.optimizedModelFilePath=="string"?Tt(p.optimizedModelFilePath,a):0;if(i=n._OrtCreateSessionOptions(o,!!p.enableCpuMemArena,!!p.enableMemPattern,s,!!p.enableProfiling,0,c,h,r,u),i===0&&ht("Can't create session options."),p.executionProviders&&Fg(i,p.executionProviders,a),p.enableGraphCapture!==void 0){if(typeof p.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${p.enableGraphCapture}`);let l=Tt("enableGraphCapture",a),f=Tt(p.enableGraphCapture.toString(),a);n._OrtAddSessionConfigEntry(i,l,f)!==0&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${p.enableGraphCapture}.`)}if(p.freeDimensionOverrides)for(let[l,f]of Object.entries(p.freeDimensionOverrides)){if(typeof l!="string")throw new Error(`free dimension override name must be a string: ${l}`);if(typeof f!="number"||!Number.isInteger(f)||f<0)throw new Error(`free dimension override value must be a non-negative integer: ${f}`);let g=Tt(l,a);n._OrtAddFreeDimensionOverride(i,g,f)!==0&&ht(`Can't set a free dimension override: ${l} - ${f}.`)}return p.extra!==void 0&&Wr(p.extra,"",new WeakSet,(l,f)=>{let g=Tt(l,a),b=Tt(f,a);n._OrtAddSessionConfigEntry(i,g,b)!==0&&ht(`Can't set a session config entry: ${l} - ${f}.`)}),[i,a]}catch(o){throw i!==0&&n._OrtReleaseSessionOptions(i),a.forEach(s=>n._free(s)),o}}}),Hr,Yp,qr,Zp,Qp,bo,go,td,Ji=O(()=>{Hr=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${e}`)}},Yp=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${e}`)}},qr=(e,n)=>{let i=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],a=typeof n=="number"?n:n.reduce((p,o)=>p*o,1);return i>0?Math.ceil(a*i):void 0},Zp=e=>{switch(e){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: ${e}`)}},Qp=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}},bo=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",go=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint64"||e==="int8"||e==="uint8"||e==="bool",td=e=>{switch(e){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${e}`)}}}),jr,Yi=O(()=>{oo(),jr=async e=>{if(typeof e=="string"){let n=await fetch(e);if(!n.ok)throw new Error(`failed to load external data file: ${e}`);let i=n.headers.get("Content-Length"),a=i?parseInt(i,10):0;if(a<1073741824)return new Uint8Array(await n.arrayBuffer());{if(!n.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let p=n.body.getReader(),o;try{o=new ArrayBuffer(a)}catch(c){if(c instanceof RangeError){let h=Math.ceil(a/65536);o=new WebAssembly.Memory({initial:h,maximum:h}).buffer}else throw c}let s=0;for(;;){let{done:c,value:h}=await p.read();if(c)break;let r=h.byteLength;new Uint8Array(o,s,r).set(h),s+=r}return new Uint8Array(o,0,a)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Cg,ao,so,yr,Ng,zr,uo,lo,ed,fo,co,po,qi=O(()=>{Xp(),Jp(),Ji(),Ke(),mo(),Yi(),Cg=(e,n)=>{xt()._OrtInit(e,n)!==0&&ht("Can't initialize onnxruntime.")},ao=async e=>{Cg(e.wasm.numThreads,Qp(e.logLevel))},so=async(e,n)=>{},yr=new Map,Ng=e=>{let n=xt(),i=n.stackSave();try{let a=n.stackAlloc(8);return n._OrtGetInputOutputCount(e,a,a+4)!==0&&ht("Can't get session input/output count."),[n.HEAP32[a/4],n.HEAP32[a/4+1]]}finally{n.stackRestore(i)}},zr=e=>{let n=xt(),i=n._malloc(e.byteLength);if(i===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return n.HEAPU8.set(e,i),[i,e.byteLength]},uo=async(e,n)=>{var u;let i,a,p=xt();Array.isArray(e)?[i,a]=e:e.buffer===p.HEAPU8.buffer?[i,a]=[e.byteOffset,e.byteLength]:[i,a]=zr(e);let o=0,s=0,c=[],h=[],r=[];try{if([s,c]=Kp(n),(n==null?void 0:n.externalData)&&p.mountExternalData){let _=[];for(let A of n.externalData){let L=typeof A=="string"?A:A.path;_.push(jr(typeof A=="string"?A:A.data).then(M=>{p.mountExternalData(L,M)}))}await Promise.all(_)}for(let _ of(n==null?void 0:n.executionProviders)??[])if((typeof _=="string"?_:_.name)==="webnn"){if(p.shouldTransferToMLTensor=!1,p.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof _!="string"){let A=_,L=A==null?void 0:A.context,M=A==null?void 0:A.gpuDevice,ft=A==null?void 0:A.deviceType,lt=A==null?void 0:A.numThreads,Nt=A==null?void 0:A.powerPreference;L?p.currentContext=L:M?p.currentContext=await navigator.ml.createContext(M):p.currentContext=await navigator.ml.createContext({deviceType:ft,numThreads:lt,powerPreference:Nt})}else p.currentContext=await navigator.ml.createContext();break}o=await p._OrtCreateSession(i,a,s),o===0&&ht("Can't create a session."),p.currentContext&&(p.jsepRegisterMLContext(o,p.currentContext),p.currentContext=void 0,p.shouldTransferToMLTensor=!0);let[l,f]=Ng(o),g=!!(n!=null&&n.enableGraphCapture),b=[],v=[],S=[];for(let _=0;_<l;_++){let A=p._OrtGetInputName(o,_);A===0&&ht("Can't get an input name."),h.push(A),b.push(p.UTF8ToString(A))}for(let _=0;_<f;_++){let A=p._OrtGetOutputName(o,_);A===0&&ht("Can't get an output name."),r.push(A);let L=p.UTF8ToString(A);v.push(L)}return yr.set(o,[o,h,r,null,g,!1]),[o,b,v]}catch(l){throw h.forEach(f=>p._OrtFree(f)),r.forEach(f=>p._OrtFree(f)),o!==0&&p._OrtReleaseSession(o),l}finally{p._free(i),s!==0&&p._OrtReleaseSessionOptions(s),c.forEach(l=>p._free(l)),(u=p.unmountExternalData)==null||u.call(p)}},lo=e=>{var h;let n=xt(),i=yr.get(e);if(!i)throw new Error(`cannot release session. invalid session id: ${e}`);let[a,p,o,s,c]=i;s&&(c&&n._OrtClearBoundOutputs(s.handle),n._OrtReleaseBinding(s.handle)),(h=n.jsepOnReleaseSession)==null||h.call(n,e),p.forEach(r=>n._OrtFree(r)),o.forEach(r=>n._OrtFree(r)),n._OrtReleaseSession(a),yr.delete(e)},ed=(e,n,i,a,p,o=!1)=>{if(!e){n.push(0);return}let s=xt(),c=e[0],h=e[1],r=e[3],u,l;if(c==="string"&&(r==="gpu-buffer"||r==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(o&&r!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${p} when enableGraphCapture is true.`);if(r==="gpu-buffer"){let b=e[2].gpuBuffer;l=qr(Hr(c),h);let v=s.jsepRegisterBuffer;if(!v)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');u=v(a,p,b,l)}else if(r==="ml-tensor"){let b=e[2].mlTensor;l=qr(Hr(c),h);let v=s.jsepRegisterMLTensor;if(!v)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');u=v(b,Hr(c),h)}else{let b=e[2];if(Array.isArray(b)){l=4*b.length,u=s._malloc(l),i.push(u);let v=u/4;for(let S=0;S<b.length;S++){if(typeof b[S]!="string")throw new TypeError(`tensor data at index ${S} is not a string`);s.HEAPU32[v++]=Tt(b[S],i)}}else l=b.byteLength,u=s._malloc(l),i.push(u),s.HEAPU8.set(new Uint8Array(b.buffer,b.byteOffset,l),u)}let f=s.stackSave(),g=s.stackAlloc(4*h.length);try{let b=g/4;h.forEach(S=>s.HEAP32[b++]=S);let v=s._OrtCreateTensor(Hr(c),u,l,g,h.length,td(r));v===0&&ht(`Can't create tensor for input/output. session=${a}, index=${p}.`),n.push(v)}finally{s.stackRestore(f)}},fo=async(e,n,i,a,p,o)=>{var Q;let s=xt(),c=yr.get(e);if(!c)throw new Error(`cannot run inference. invalid session id: ${e}`);let h=c[0],r=c[1],u=c[2],l=c[3],f=c[4];c[5];let g=n.length,b=a.length,v=0,S=[],P=[],_=[],A=[],L=s.stackSave(),M=s.stackAlloc(g*4),ft=s.stackAlloc(g*4),lt=s.stackAlloc(b*4),Nt=s.stackAlloc(b*4);try{(Q=s.jsepOnRunStart)==null||Q.call(s,h),[v,S]=jp(o);for(let X=0;X<g;X++)ed(i[X],P,A,e,n[X],f);for(let X=0;X<b;X++)ed(p[X],_,A,e,g+a[X],f);let Pt=M/4,$e=ft/4,gt=lt/4,De=Nt/4;for(let X=0;X<g;X++)s.HEAPU32[Pt++]=P[X],s.HEAPU32[$e++]=r[n[X]];for(let X=0;X<b;X++)s.HEAPU32[gt++]=_[X],s.HEAPU32[De++]=u[a[X]];let Ft;Ft=await s._OrtRun(h,ft,M,g,Nt,b,lt,v),Ft!==0&&ht("failed to call OrtRun().");let wt=[];for(let X=0;X<b;X++){let Wt=s.HEAPU32[lt/4+X];if(Wt===_[X]){wt.push(p[X]);continue}let Le=s.stackSave(),_t=s.stackAlloc(4*4),se=!1,it,at=0;try{s._OrtGetTensorData(Wt,_t,_t+4,_t+8,_t+12)!==0&&ht(`Can't access output tensor data on index ${X}.`);let re=_t/4,Jt=s.HEAPU32[re++];at=s.HEAPU32[re++];let Re=s.HEAPU32[re++],oe=s.HEAPU32[re++],Ot=[];for(let nt=0;nt<oe;nt++)Ot.push(s.HEAPU32[Re/4+nt]);s._OrtFree(Re);let $t=Ot.reduce((nt,st)=>nt*st,1);it=Yp(Jt);let Lt=l==null?void 0:l.outputPreferredLocations[a[X]];if(it==="string"){if(Lt==="gpu-buffer"||Lt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let nt=[],st=at/4;for(let Mt=0;Mt<$t;Mt++){let ce=s.HEAPU32[st++],Ge=Mt===$t-1?void 0:s.HEAPU32[st]-ce;nt.push(s.UTF8ToString(ce,Ge))}wt.push([it,Ot,nt,"cpu"])}else if(Lt==="gpu-buffer"&&$t>0){let nt=s.jsepGetBuffer;if(!nt)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let st=nt(at),Mt=qr(Jt,$t);if(Mt===void 0||!bo(it))throw new Error(`Unsupported data type: ${it}`);se=!0,wt.push([it,Ot,{gpuBuffer:st,download:s.jsepCreateDownloader(st,Mt,it),dispose:()=>{s._OrtReleaseTensor(Wt)}},"gpu-buffer"])}else if(Lt==="ml-tensor"&&$t>0){let nt=s.jsepEnsureTensor;if(!nt)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(qr(Jt,$t)===void 0||!go(it))throw new Error(`Unsupported data type: ${it}`);let st=await nt(at,Jt,Ot,!1);se=!0,wt.push([it,Ot,{mlTensor:st,download:s.jsepCreateMLTensorDownloader(at,it),dispose:()=>{s.jsepReleaseTensorId(at),s._OrtReleaseTensor(Wt)}},"ml-tensor"])}else{let nt=Zp(it),st=new nt($t);new Uint8Array(st.buffer,st.byteOffset,st.byteLength).set(s.HEAPU8.subarray(at,at+st.byteLength)),wt.push([it,Ot,st,"cpu"])}}finally{s.stackRestore(Le),it==="string"&&at&&s._free(at),se||s._OrtReleaseTensor(Wt)}}return l&&!f&&(s._OrtClearBoundOutputs(l.handle),yr.set(e,[h,r,u,l,f,!1])),wt}finally{s.stackRestore(L),P.forEach(Pt=>s._OrtReleaseTensor(Pt)),_.forEach(Pt=>s._OrtReleaseTensor(Pt)),A.forEach(Pt=>s._free(Pt)),v!==0&&s._OrtReleaseRunOptions(v),S.forEach(Pt=>s._free(Pt))}},co=e=>{let n=xt(),i=yr.get(e);if(!i)throw new Error("invalid session id");let a=i[0],p=n._OrtEndProfiling(a);p===0&&ht("Can't get an profile file name."),n._OrtFree(p)},po=e=>{let n=[];for(let i of e){let a=i[2];!Array.isArray(a)&&"buffer"in a&&n.push(a.buffer)}return n}}),Je,Kt,Xr,xo,To,yo,Zi,Qi,xr,Tr,Gg,rd,nd,od,id,ad,sd,ud,ta=O(()=>{Yt(),qi(),Ke(),Vr(),Je=()=>!!z.wasm.proxy&&typeof document<"u",Xr=!1,xo=!1,To=!1,Qi=new Map,xr=(e,n)=>{let i=Qi.get(e);i?i.push(n):Qi.set(e,[n])},Tr=()=>{if(Xr||!xo||To||!Kt)throw new Error("worker not ready")},Gg=e=>{switch(e.data.type){case"init-wasm":Xr=!1,e.data.err?(To=!0,Zi[1](e.data.err)):(xo=!0,Zi[0]()),yo&&(URL.revokeObjectURL(yo),yo=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let n=Qi.get(e.data.type);e.data.err?n.shift()[1](e.data.err):n.shift()[0](e.data.out);break}}},rd=async()=>{if(!xo){if(Xr)throw new Error("multiple calls to 'initWasm()' detected.");if(To)throw new Error("previous call to 'initWasm()' failed.");if(Xr=!0,Je())return new Promise((e,n)=>{Kt==null||Kt.terminate(),Wp().then(([i,a])=>{try{Kt=a,Kt.onerror=o=>n(o),Kt.onmessage=Gg,Zi=[e,n];let p={type:"init-wasm",in:z};Kt.postMessage(p),yo=i}catch(p){n(p)}},n)});try{await io(z.wasm),await ao(z),xo=!0}catch(e){throw To=!0,e}finally{Xr=!1}}},nd=async e=>{if(Je())return Tr(),new Promise((n,i)=>{xr("init-ep",[n,i]);let a={type:"init-ep",in:{epName:e,env:z}};Kt.postMessage(a)});await so(z,e)},od=async e=>Je()?(Tr(),new Promise((n,i)=>{xr("copy-from",[n,i]);let a={type:"copy-from",in:{buffer:e}};Kt.postMessage(a,[e.buffer])})):zr(e),id=async(e,n)=>{if(Je()){if(n!=null&&n.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Tr(),new Promise((i,a)=>{xr("create",[i,a]);let p={type:"create",in:{model:e,options:{...n}}},o=[];e instanceof Uint8Array&&o.push(e.buffer),Kt.postMessage(p,o)})}else return uo(e,n)},ad=async e=>{if(Je())return Tr(),new Promise((n,i)=>{xr("release",[n,i]);let a={type:"release",in:e};Kt.postMessage(a)});lo(e)},sd=async(e,n,i,a,p,o)=>{if(Je()){if(i.some(s=>s[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(p.some(s=>s))throw new Error("pre-allocated output tensor is not supported for proxy.");return Tr(),new Promise((s,c)=>{xr("run",[s,c]);let h=i,r={type:"run",in:{sessionId:e,inputIndices:n,inputs:h,outputIndices:a,options:o}};Kt.postMessage(r,po(h))})}else return fo(e,n,i,a,p,o)},ud=async e=>{if(Je())return Tr(),new Promise((n,i)=>{xr("end-profiling",[n,i]);let a={type:"end-profiling",in:e};Kt.postMessage(a)});co(e)}}),ld,Mg,wo,fd=O(()=>{Yt(),ta(),Ji(),oo(),Yi(),ld=(e,n)=>{switch(e.location){case"cpu":return[e.type,e.dims,e.data,"cpu"];case"gpu-buffer":return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[e.type,e.dims,{mlTensor:e.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${e.location} for ${n()}`)}},Mg=e=>{switch(e[3]){case"cpu":return new yt(e[0],e[2],e[1]);case"gpu-buffer":{let n=e[0];if(!bo(n))throw new Error(`not supported data type: ${n} for deserializing GPU tensor`);let{gpuBuffer:i,download:a,dispose:p}=e[2];return yt.fromGpuBuffer(i,{dataType:n,dims:e[1],download:a,dispose:p})}case"ml-tensor":{let n=e[0];if(!go(n))throw new Error(`not supported data type: ${n} for deserializing MLTensor tensor`);let{mlTensor:i,download:a,dispose:p}=e[2];return yt.fromMLTensor(i,{dataType:n,dims:e[1],download:a,dispose:p})}default:throw new Error(`invalid data location: ${e[3]}`)}},wo=class{async fetchModelAndCopyToWasmMemory(e){return od(await jr(e))}async loadModel(e,n){Fe();let i;typeof e=="string"?i=await this.fetchModelAndCopyToWasmMemory(e):i=e,[this.sessionId,this.inputNames,this.outputNames]=await id(i,n),Ce()}async dispose(){return ad(this.sessionId)}async run(e,n,i){Fe();let a=[],p=[];Object.entries(e).forEach(l=>{let f=l[0],g=l[1],b=this.inputNames.indexOf(f);if(b===-1)throw new Error(`invalid input '${f}'`);a.push(g),p.push(b)});let o=[],s=[];Object.entries(n).forEach(l=>{let f=l[0],g=l[1],b=this.outputNames.indexOf(f);if(b===-1)throw new Error(`invalid output '${f}'`);o.push(g),s.push(b)});let c=a.map((l,f)=>ld(l,()=>`input "${this.inputNames[p[f]]}"`)),h=o.map((l,f)=>l?ld(l,()=>`output "${this.outputNames[s[f]]}"`):null),r=await sd(this.sessionId,p,c,s,h,i),u={};for(let l=0;l<r.length;l++)u[this.outputNames[s[l]]]=o[l]??Mg(r[l]);return Ce(),u}startProfiling(){}endProfiling(){ud(this.sessionId)}}}),pd={};Or(pd,{OnnxruntimeWebAssemblyBackend:()=>vo,initializeFlags:()=>cd,wasmBackend:()=>Ug});var cd,vo,Ug,dd=O(()=>{Yt(),ta(),fd(),Vr(),cd=()=>{if((typeof z.wasm.initTimeout!="number"||z.wasm.initTimeout<0)&&(z.wasm.initTimeout=0),z.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 z.wasm.proxy!="boolean"&&(z.wasm.proxy=!1),typeof z.wasm.trace!="boolean"&&(z.wasm.trace=!1),typeof z.wasm.numThreads!="number"||!Number.isInteger(z.wasm.numThreads)||z.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)z.wasm.numThreads=1;else{let e=typeof navigator>"u"?Co("node:os").cpus().length:navigator.hardwareConcurrency;z.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},vo=class{async init(e){cd(),await rd(),await nd(e)}async createInferenceSessionHandler(e,n){let i=new wo;return await i.loadModel(e,n),Promise.resolve(i)}},Ug=new vo});Yt(),Yt(),Yt();var Ds="1.20.1";{let e=(Fp(),sn(Bp)).onnxjsBackend;nr("webgl",e,-10)}{let e=(dd(),sn(pd)).wasmBackend;nr("cpu",e,10),nr("wasm",e,10)}Object.defineProperty(z.versions,"web",{value:Ds,enumerable:!0});/*! Bundled license information:
1810
1810
 
1811
1811
  long/index.js:
1812
1812
  (**
@@ -1828,5 +1828,5 @@ as ORT format: ${p}`)}}loadFromOnnxFormat(e,n){let a=Dp.onnx.ModelProto.decode(e
1828
1828
  *
1829
1829
  * SPDX-License-Identifier: Apache-2.0
1830
1830
  *)
1831
- */function C(e){if(e.startsWith("blob:"))return!0;try{return new URL(e),!0}catch{return!1}}const T=(e,n)=>!n||e.startsWith("http")?new URL(e).href:e?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n;class t{constructor(){this.resolvedUriCache=new Map}async resolveUri(n,a){if(!a)throw new Error("Asset URI is undefined.");if(this.resolvedUriCache.has(a))return this.resolvedUriCache.get(a);let i;if(C(a)?i=a:a.match(/\.[a-z0-9]+$/i)?typeof n.assetUrlResolver=="function"&&(i=await n.assetUrlResolver(a,n)):i=T(a,n.baseUrl),!i)throw new Error(`Failed to resolve asset URI: ${a}`);return this.resolvedUriCache.set(a,i),i}}const d=new t;async function loadAndCacheFile(e){const n=await caches.open("ladon-cache"),a=await n.match(e);if(a)return a.arrayBuffer();const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch file: ${e}`);const p=i.headers.get("Content-Type")||"binary/octet-stream";if(!p.includes("application/wasm")&&!p.includes("binary/octet-stream"))throw new Error(`Unexpected MIME type: ${p} for ${e}`);const o=await i.arrayBuffer(),s=new Response(o,{headers:{"Content-Type":p,"Content-Length":o.byteLength.toString()}});return await n.put(e,s),o}const ONNX_WASM_FILENAME="ort-wasm-simd-threaded.wasm";class ModelManager{constructor(){this.modelSessions={}}async loadModel(n){const{mask:a,executionProviders:i}=n;z.wasm.numThreads=1;const p=await d.resolveUri(n,n.wasmUri);if(p)try{z.wasm.wasmBinary=await loadAndCacheFile(p+ONNX_WASM_FILENAME)}catch(c){console.warn("Failed to load or cache WASM file. Using WASM paths.",c),z.wasm.wasmPaths=p}const o=await d.resolveUri(n,a.modelUri);let s=this.modelSessions[o];if(!s){const h={executionProviders:i!=null&&i.length?i:["wasm"]};try{const r=await loadAndCacheFile(o);s=await Yd.create(r,h)}catch(r){console.warn("Failed to load or cache model file. Using model URL.",r),s=await Yd.create(o,h)}}return this.modelSessions[o]=s,await this.warmupModel(s,a.inputSize,a.modelRank),s}async warmupModel(n,a={width:1280,height:720},i=3,p="float32"){const o=a.height*a.width,s=new Float32Array(i*o).fill(0),c=new yt(p,s,[1,i,a.height,a.width]),h={[n.inputNames[0]]:c};if(i===3){const r=new Float32Array(o).fill(0),u=new yt(p,r,[1,1,a.height,a.width]);h[n.inputNames[1]]=u}await n.run(h)}getModelSession(n){return this.modelSessions[n]}}const modelManager=new ModelManager;class LadonGenerator{constructor(n){this.config=n,this.lastMaskGenerationTime=0;const{height:a,width:i}=this.config.mask.outputSize;this.lastMask=new yt("float32",new Float32Array(a*i),[1,1,a,i]),this.lastResult={data:this.lastMask.data,facesAndLandmarks:{data:new Float32Array(0),dims:[]},gesture:new Float32Array(0),motion:0,timestamp:0,warm:!1}}preprocess(n,a){const{modelRank:i,inputSize:p,outputSize:o}=this.config.mask,{height:s,width:c}=p,h=s*c;this.output??(this.output=new Float32Array(h*i));const r=n.length/4;for(let f=0;f<3;f++)for(let g=0;g<r;g++)this.output[g+f*h]=n[g*4+(2-f)];const u=o.width/c,l=o.height/s;for(let f=0;f<c;f++){const g=Math.floor(f*u);for(let b=0;b<s;b++){const v=Math.floor(b*l),S=g+v*o.width,P=f+b*c+3*h,_=Math.min(Math.max(a[S],0),255);this.output[P]=_}}return this.output}getTimeSinceLastGeneration(){return Date.now()-this.lastMaskGenerationTime}async getLadonOutput(n,a){var o,s,c,h;if(!this.maskModel)throw new Error("[ladon-ts] - mask model not loaded.");if(this.getTimeSinceLastGeneration()<this.config.mask.generationIntervalMs)return{data:this.lastMask.data,facesAndLandmarks:this.lastResult.facesAndLandmarks,gesture:this.lastResult.gesture,motion:this.lastResult.motion,timestamp:this.lastResult.timestamp,warm:!1};this.lastMaskGenerationTime=Date.now();const i=new yt("float32",this.preprocess(n,this.lastMask.data),[1,this.config.mask.modelRank,this.config.mask.inputSize.height,this.config.mask.inputSize.width]),p=await this.maskModel.run({input:i});return this.lastMask=p.segmentation,this.lastResult={data:this.lastMask.data??new Float32Array(0),facesAndLandmarks:{data:((o=p.faces_and_landmarks)==null?void 0:o.data)??new Float32Array(0),dims:((s=p.faces_and_landmarks)==null?void 0:s.dims)??[]},gesture:((c=p.gesture)==null?void 0:c.data)??new Float32Array(0),motion:((h=p.motion)==null?void 0:h.data[0])??0,timestamp:a,warm:!0},this.lastResult}async load(){const n=await d.resolveUri(this.config,this.config.mask.modelUri);if(this.maskModel=modelManager.getModelSession(n),this.maskModel??(this.maskModel=await modelManager.loadModel(this.config)),!this.maskModel)throw new Error("Failed to load the ONNX model.")}isLoaded(){return!!this.maskModel}async postRender(n){}destroy(){}}let preloadPromise=null,generator,busy=!1;self.addEventListener("message",async e=>{const{type:n,config:a,image:i,timestamp:p}=e.data;try{switch(n){case"preload":a&&(preloadPromise=handlePreload(a),await preloadPromise);break;case"init":a&&(preloadPromise&&await preloadPromise,await handleInit(a));break;case"generate":i&&await handleGenerate(i,p);break;default:console.warn(`[ladon-ts] - worker generator - unknown message: ${JSON.stringify(e.data)}`)}}catch(o){console.error(`[ladon-ts] - worker generator - error handling message: ${o}`),postMessage({status:"error",error:o.message})}});async function handlePreload(e){await modelManager.loadModel(e),postMessage({status:"preloaded"})}async function handleInit(e){generator=new LadonGenerator(e),await generator.load(),postMessage({status:"initialized"})}async function handleGenerate(e,n){if(busy)return;if(!generator||!generator.isLoaded()){console.warn("[ladon-ts] - Generator is not initialized");return}if(busy=!0,!e){console.warn("[ladon-ts] - No valid input provided for generation"),busy=!1;return}const a=await generator.getLadonOutput(e,n);a.warm&&postMessage({facesAndLandmarks:a.facesAndLandmarks,gesture:a.gesture,mask:a.data,motion:a.motion,timestamp:a.timestamp,status:"generated"}),setTimeout(()=>{busy=!1},0)}})();
1831
+ */function C(e){if(e.startsWith("blob:"))return!0;try{return new URL(e),!0}catch{return!1}}const T=(e,n)=>!n||e.startsWith("http")?new URL(e).href:e?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n;class t{constructor(){this.resolvedUriCache=new Map}async resolveUri(n,i){if(!i)throw new Error("Asset URI is undefined.");if(this.resolvedUriCache.has(i))return this.resolvedUriCache.get(i);let a;if(C(i)?a=i:i.match(/\.[a-z0-9]+$/i)?typeof n.assetUrlResolver=="function"&&(a=await n.assetUrlResolver(i,n)):a=T(i,n.baseUrl),!a)throw new Error(`Failed to resolve asset URI: ${i}`);return this.resolvedUriCache.set(i,a),a}}const d=new t;async function loadAndCacheFile(e){const n=await caches.open("ladon-cache"),i=await n.match(e);if(i)return i.arrayBuffer();const a=await fetch(e);if(!a.ok)throw new Error(`Failed to fetch file: ${e}`);const p=a.headers.get("Content-Type")||"binary/octet-stream";if(!p.includes("application/wasm")&&!p.includes("binary/octet-stream"))throw new Error(`Unexpected MIME type: ${p} for ${e}`);const o=await a.arrayBuffer(),s=new Response(o,{headers:{"Content-Type":p,"Content-Length":o.byteLength.toString()}});return await n.put(e,s),o}const ONNX_WASM_FILENAME="ort-wasm-simd-threaded.wasm";class ModelManager{constructor(){this.modelSessions={}}async loadModel(n){const{mask:i,executionProviders:a}=n;z.wasm.numThreads=1;const p=await d.resolveUri(n,n.wasmUri);if(p)try{z.wasm.wasmBinary=await loadAndCacheFile(p+ONNX_WASM_FILENAME)}catch(c){console.warn("Failed to load or cache WASM file. Using WASM paths.",c),z.wasm.wasmPaths=p}const o=await d.resolveUri(n,i.modelUri);let s=this.modelSessions[o];if(!s){const h={executionProviders:a!=null&&a.length?a:["wasm"]};try{const r=await loadAndCacheFile(o);s=await Yd.create(r,h)}catch(r){console.warn("Failed to load or cache model file. Using model URL.",r),s=await Yd.create(o,h)}}return this.modelSessions[o]=s,await this.warmupModel(s,i.inputSize,i.modelRank),s}async warmupModel(n,i={width:1280,height:720},a=3,p="float32"){const o=i.height*i.width,s=new Float32Array(a*o).fill(0),c=new yt(p,s,[1,a,i.height,i.width]),h={[n.inputNames[0]]:c};if(a===3){const r=new Float32Array(o).fill(0),u=new yt(p,r,[1,1,i.height,i.width]);h[n.inputNames[1]]=u}await n.run(h)}getModelSession(n){return this.modelSessions[n]}async destroyModel(n){const i=this.modelSessions[n];i&&(await i.release(),delete this.modelSessions[n])}}const modelManager=new ModelManager;class LadonGenerator{constructor(n){this.config=n,this.lastMaskGenerationTime=0;const{height:i,width:a}=this.config.mask.outputSize;this.lastMask=new yt("float32",new Float32Array(i*a),[1,1,i,a]),this.lastResult={data:this.lastMask.data,facesAndLandmarks:{data:new Float32Array(0),dims:[]},gesture:new Float32Array(0),motion:0,timestamp:0,warm:!1}}isLoaded(){return!!this.maskModel}preprocess(n,i){const{modelRank:a,inputSize:p,outputSize:o}=this.config.mask,{height:s,width:c}=p,h=s*c;this.output??(this.output=new Float32Array(h*a));const r=n.length/4;for(let f=0;f<3;f++)for(let g=0;g<r;g++)this.output[g+f*h]=n[g*4+(2-f)];const u=o.width/c,l=o.height/s;for(let f=0;f<c;f++){const g=Math.floor(f*u);for(let b=0;b<s;b++){const v=Math.floor(b*l),S=g+v*o.width,P=f+b*c+3*h,_=Math.min(Math.max(i[S],0),255);this.output[P]=_}}return this.output}getTimeSinceLastGeneration(){return Date.now()-this.lastMaskGenerationTime}async getLadonOutput(n,i){var o,s,c,h;if(!this.maskModel)throw new Error("[ladon-ts] Mask model not loaded.");if(this.getTimeSinceLastGeneration()<this.config.mask.generationIntervalMs)return{data:this.lastMask.data,facesAndLandmarks:this.lastResult.facesAndLandmarks,gesture:this.lastResult.gesture,motion:this.lastResult.motion,timestamp:this.lastResult.timestamp,warm:!1};this.lastMaskGenerationTime=Date.now();const a=new yt("float32",this.preprocess(n,this.lastMask.data),[1,this.config.mask.modelRank,this.config.mask.inputSize.height,this.config.mask.inputSize.width]),p=await this.maskModel.run({input:a});return this.lastMask=p.segmentation,this.lastResult={data:this.lastMask.data??new Float32Array(0),facesAndLandmarks:{data:((o=p.faces_and_landmarks)==null?void 0:o.data)??new Float32Array(0),dims:((s=p.faces_and_landmarks)==null?void 0:s.dims)??[]},gesture:((c=p.gesture)==null?void 0:c.data)??new Float32Array(0),motion:((h=p.motion)==null?void 0:h.data[0])??0,timestamp:i,warm:!0},this.lastResult}async load(){if(this.modelUrl=await d.resolveUri(this.config,this.config.mask.modelUri),this.maskModel=modelManager.getModelSession(this.modelUrl),this.maskModel??(this.maskModel=await modelManager.loadModel(this.config)),!this.maskModel)throw new Error("Failed to load the ONNX model.")}async postRender(){}async destroy(){if(!this.modelUrl)throw new Error("[ladon-ts] Generator teardown failed. Model URL is not defined.");await modelManager.destroyModel(this.modelUrl),this.modelUrl=void 0,this.maskModel=void 0,this.output=void 0}}let preloadPromise=null,generator,busy=!1;self.addEventListener("message",async e=>{const{type:n,config:i,image:a,timestamp:p}=e.data;try{switch(n){case"preload":i&&(preloadPromise=handlePreload(i),await preloadPromise);break;case"init":i&&(preloadPromise&&await preloadPromise,await handleInit(i));break;case"generate":a&&await handleGenerate(a,p);break;case"destroy":await handleDestroy();break;default:console.warn(`[ladon-ts] Worker generator recieved unknown message: ${JSON.stringify(e.data)}`)}}catch(o){console.error(`[ladon-ts] Worker generator error handling message: ${o}`),postMessage({status:"error",error:o.message})}});async function handlePreload(e){await modelManager.loadModel(e),postMessage({status:"preloaded"})}async function handleInit(e){generator=new LadonGenerator(e),await generator.load(),postMessage({status:"initialized"})}async function handleGenerate(e,n){if(busy)return;if(!generator||!generator.isLoaded()){console.warn("[ladon-ts] Generator is not initialized");return}if(busy=!0,!e){console.warn("[ladon-ts] No valid input provided for generation"),busy=!1;return}const i=await generator.getLadonOutput(e,n);i.warm&&postMessage({facesAndLandmarks:i.facesAndLandmarks,gesture:i.gesture,mask:i.data,motion:i.motion,timestamp:i.timestamp,status:"generated"}),setTimeout(()=>{busy=!1},0)}async function handleDestroy(){generator?await generator.destroy():console.warn("[ladon-ts] No generator to destroy"),postMessage({status:"destroyed"})}})();
1832
1832
  //# sourceMappingURL=segmentation.js.map