PageSourceSearch

https://reflect.app/_next/static/chunks/471273d8.06e0ffb58cbf7026.js

js reflect.app collected 2026-09-24 08:53:02 UTC 462,987 bytes, 1,800 lines download raw bytes

1!function(){try{var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=(new t.Error).stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a33c4d4e-090e-44b4-a1bb-d1e315dd0cac",t._sentryDebugIdIdentifier="sentry-dbid-a33c4d4e-090e-44b4-a1bb-d1e315dd0cac")}catch(t){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2853],{69167:function(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__){let i;__webpack_require__.d(__webpack_exports__,{Bc:function(){return Yd},env:function(){return z},es:function(){return yt}});var un,ke,nr,Jd,ln,es,ns,Gt,z,is,as,Ro,us,ls,fs,cs,ps,Be,Sr,hs,ms,gs,ys,St,yt,Ts,ws,Fe,Ce,dn,Yd,Zd,hn,Qd,Hd=Object.create,an=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,jd=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty,Co=(i=function(t){if("u">typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')},"u">typeof require?require:"u">typeof Proxy?new Proxy(i,{get:(t,e)=>("u">typeof require?require:t)[e]}):i),O=(t,e)=>()=>(t&&(e=t(t=0)),e),mt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Or=(t,e)=>{for(var r in e)an(t,r,{get:e[r],enumerable:!0})},Qa=(t,e,r,n)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let o of jd(e))Kd.call(t,o)||o===r||an(t,o,{get:()=>e[o],enumerable:!(n=qd(e,o))||n.enumerable});return t},rr=(t,e,r)=>(r=null!=t?Hd(Xd(t)):{},Qa(!e&&t&&t.__esModule?r:an(r,"default",{value:t,enumerable:!0}),t)),sn=t=>Qa(an({},"__esModule",{value:!0}),t),fn=O(()=>{"use strict";un=new Map,ke=[],nr=(t,e,r)=>{if(e&&"function"==typeof e.init&&"function"==typeof e.createInferenceSessionHandler){let n=un.get(t);if(void 0===n)un.set(t,{backend:e,priority:r});else{if(n.priority>r)return;if(n.priority===r&&n.backend!==e)throw Error(`cannot register backend "${t}" using priority ${r}`)}if(r>=0){let e=ke.indexOf(t);-1!==e&&ke.splice(e,1);for(let e=0;e<ke.length;e++)if(un.get(ke[e]).priority<=r){ke.splice(e,0,t);return}ke.push(t)}return}throw TypeError("not a valid backend")},Jd=async t=>{let e=un.get(t);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let r=!!e.initPromise;try{return r||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(t){return r||(e.error=`${t}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},ln=async t=>{let e=t.executionProviders||[],r=e.map(t=>"string"==typeof t?t:t.name),n=0===r.length?ke:r,o,s=[],a=new Set;for(let t of n){let e=await Jd(t);"string"==typeof e?s.push({name:t,err:e}):(o||(o=e),o===e&&a.add(t))}if(!o)throw Error(`no available backend found. ERR: ${s.map(t=>`[${t.name}] ${t.err}`).join(", ")}`);for(let{name:t,err:e}of s)r.includes(t)&&console.warn(`removing requested execution provider "${t}" from session options because it is not available: ${e}`);let u=e.filter(t=>a.has("string"==typeof t?t:t.name));return[o,new Proxy(t,{get:(t,e)=>"executionProviders"===e?u:Reflect.get(t,e)})]}}),ts=O(()=>{"use strict";fn()}),rs=O(()=>{"use strict";es="1.20.1"}),No=O(()=>{"use strict";rs(),ns="warning",Object.defineProperty(Gt={wasm:{},webgl:{},webgpu:{},versions:{common:es},set logLevel(i){if(void 0!==i){if("string"!=typeof i||-1===["verbose","info","warning","error","fatal"].indexOf(i))throw Error(`Unsupported logging level: ${i}`);ns=i}},get logLevel(){return ns}},"logLevel",{enumerable:!0})}),os=O(()=>{"use strict";No(),z=Gt}),ss=O(()=>{"use strict";is=(t,e)=>{let r="u">typeof document?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=t.dims[3],r.height=t.dims[2];let n=r.getContext("2d");if(null!=n){let o,s;e?.tensorLayout!==void 0&&"NHWC"===e.tensorLayout?(o=t.dims[2],s=t.dims[3]):(o=t.dims[3],s=t.dims[2]);let a=e?.format!==void 0?e.format:"RGB",u=e?.norm,l,p;void 0===u||void 0===u.mean?l=[255,255,255,255]:"number"==typeof u.mean?l=[u.mean,u.mean,u.mean,u.mean]:(l=[u.mean[0],u.mean[1],u.mean[2],0],void 0!==u.mean[3]&&(l[3]=u.mean[3])),void 0===u||void 0===u.bias?p=[0,0,0,0]:"number"==typeof u.bias?p=[u.bias,u.bias,u.bias,u.bias]:(p=[u.bias[0],u.bias[1],u.bias[2],0],void 0!==u.bias[3]&&(p[3]=u.bias[3]));let c=s*o,d=0,h=c,f=2*c,g=-1;"RGBA"===a?(d=0,h=c,f=2*c,g=3*c):"RGB"===a?(d=0,h=c,f=2*c):"RBG"===a&&(d=0,f=c,h=2*c);for(let e=0;e<s;e++)for(let r=0;r<o;r++){let o=(t.data[d++]-p[0])*l[0],s=(t.data[h++]-p[1])*l[1],a=(t.data[f++]-p[2])*l[2],u=-1===g?255:(t.data[g++]-p[3])*l[3];n.fillStyle="rgba("+o+","+s+","+a+","+u+")",n.fillRect(r,e,1,1)}if("toDataURL"in r)return r.toDataURL();throw Error("toDataURL is not supported")}throw Error("Can not access image data")},as=(t,e)=>{let r="u">typeof document?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),n;if(null!=r){let o,s,a;e?.tensorLayout!==void 0&&"NHWC"===e.tensorLayout?(o=t.dims[2],s=t.dims[1],a=t.dims[3]):(o=t.dims[3],s=t.dims[2],a=t.dims[1]);let u=void 0!==e&&void 0!==e.format?e.format:"RGB",l=e?.norm,p,c;void 0===l||void 0===l.mean?p=[255,255,255,255]:"number"==typeof l.mean?p=[l.mean,l.mean,l.mean,l.mean]:(p=[l.mean[0],l.mean[1],l.mean[2],255],void 0!==l.mean[3]&&(p[3]=l.mean[3])),void 0===l||void 0===l.bias?c=[0,0,0,0]:"number"==typeof l.bias?c=[l.bias,l.bias,l.bias,l.bias]:(c=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(c[3]=l.bias[3]));let d=s*o;if(void 0!==e&&(void 0!==e.format&&4===a&&"RGBA"!==e.format||3===a&&"RGB"!==e.format&&"BGR"!==e.format))throw Error("Tensor format doesn't match input tensor dims");let h=4,f=0,g=1,m=2,b=3,y=0,x=d,v=2*d,T=-1;"RGBA"===u?(y=0,x=d,v=2*d,T=3*d):"RGB"===u?(y=0,x=d,v=2*d):"RBG"===u&&(y=0,v=d,x=2*d),n=r.createImageData(o,s);for(let e=0;e<s*o;f+=h,g+=h,m+=h,b+=h,e++)n.data[f]=(t.data[y++]-c[0])*p[0],n.data[g]=(t.data[x++]-c[1])*p[1],n.data[m]=(t.data[v
1++]-c[2])*p[2],n.data[b]=-1===T?255:(t.data[T++]-c[3])*p[3]}else throw Error("Can not access image data");return n}}),ds=O(()=>{"use strict";cn(),Ro=(t,e)=>{if(void 0===t)throw Error("Image buffer must be defined");if(void 0===e.height||void 0===e.width)throw Error("Image height and width must be defined");if("NHWC"===e.tensorLayout)throw Error("NHWC Tensor layout is not supported yet");let{height:r,width:n}=e,o=e.norm??{mean:255,bias:0},s,a;s="number"==typeof o.mean?[o.mean,o.mean,o.mean,o.mean]:[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],a="number"==typeof o.bias?[o.bias,o.bias,o.bias,o.bias]:[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let u=void 0!==e.format?e.format:"RGBA",l=void 0!==e.tensorFormat&&void 0!==e.tensorFormat?e.tensorFormat:"RGB",p=r*n,c=new Float32Array("RGBA"===l?4*p:3*p),d=4,h=0,f=1,g=2,m=3,b=0,y=p,x=2*p,v=-1;"RGB"===u&&(d=3,h=0,f=1,g=2,m=-1),"RGBA"===l?v=3*p:"RBG"===l?(b=0,x=p,y=2*p):"BGR"===l&&(x=0,y=p,b=2*p);for(let e=0;e<p;e++,h+=d,g+=d,f+=d,m+=d)c[b++]=(t[h]+a[0])/s[0],c[y++]=(t[f]+a[1])/s[1],c[x++]=(t[g]+a[2])/s[2],-1!==v&&-1!==m&&(c[v++]=(t[m]+a[3])/s[3]);return"RGBA"===l?new St("float32",c,[1,4,r,n]):new St("float32",c,[1,3,r,n])},us=async(t,e)=>{let r="u">typeof HTMLImageElement&&t instanceof HTMLImageElement,n="u">typeof ImageData&&t instanceof ImageData,o="u">typeof ImageBitmap&&t instanceof ImageBitmap,s="string"==typeof t,a,u=e??{},l=()=>{if("u">typeof document)return document.createElement("canvas");if("u">typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw Error("Canvas is not supported")},p=t=>"u">typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas?t.getContext("2d"):null;if(r){let r=l();r.width=t.width,r.height=t.height;let n=p(r);if(null!=n){let r=t.height,o=t.width;if(void 0!==e&&void 0!==e.resizedHeight&&void 0!==e.resizedWidth&&(r=e.resizedHeight,o=e.resizedWidth),void 0!==e){if(u=e,void 0!==e.tensorFormat)throw Error("Image input config format must be RGBA for HTMLImageElement");u.tensorFormat="RGBA",u.height=r,u.width=o}else u.tensorFormat="RGBA",u.height=r,u.width=o;n.drawImage(t,0,0),a=n.getImageData(0,0,o,r).data}else throw Error("Can not access image data")}else if(n){let r,n;if(void 0!==e&&void 0!==e.resizedWidth&&void 0!==e.resizedHeight?(r=e.resizedHeight,n=e.resizedWidth):(r=t.height,n=t.width),void 0!==e&&(u=e),u.format="RGBA",u.height=r,u.width=n,void 0!==e){let e=l();e.width=n,e.height=r;let o=p(e);if(null!=o)o.putImageData(t,0,0),a=o.getImageData(0,0,n,r).data;else throw Error("Can not access image data")}else a=t.data}else if(o){if(void 0===e)throw Error("Please provide image config with format for Imagebitmap");let r=l();r.width=t.width,r.height=t.height;let n=p(r);if(null!=n){let e=t.height,r=t.width;return n.drawImage(t,0,0,r,e),a=n.getImageData(0,0,r,e).data,u.height=e,u.width=r,Ro(a,u)}throw Error("Can not access image data")}else{if(s)return new Promise((e,r)=>{let n=l(),o=p(n);if(!t||!o)return r();let s=new Image;s.crossOrigin="Anonymous",s.src=t,s.onload=()=>{n.width=s.width,n.height=s.height,o.drawImage(s,0,0,n.width,n.height);let t=o.getImageData(0,0,n.width,n.height);u.height=n.height,u.width=n.width,e(Ro(t.data,u))}});throw Error("Input data provided is not supported - aborted tensor creation")}if(void 0!==a)return Ro(a,u);throw Error("Input data provided is not supported - aborted tensor creation")},ls=(t,e)=>{let{width:r,height:n,download:o,dispose:s}=e;return new St({location:"texture",type:"float32",texture:t,dims:[1,n,r,4],download:o,dispose:s})},fs=(t,e)=>{let{dataType:r,dims:n,download:o,dispose:s}=e;return new St({location:"gpu-buffer",type:r??"float32",gpuBuffer:t,dims:n,download:o,dispose:s})},cs=(t,e)=>{let{dataType:r,dims:n,download:o,dispose:s}=e;return new St({location:"ml-tensor",type:r??"float32",mlTensor:t,dims:n,download:o,dispose:s})},ps=(t,e,r)=>new St({location:"cpu-pinned",type:t,data:e,dims:r??[e.length]})}),bs=O(()=>{"use strict";Be=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array
1],["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 t="u">typeof BigInt64Array&&BigInt64Array.from,e="u">typeof BigUint64Array&&BigUint64Array.from,r="u">typeof Float16Array&&Float16Array.from;t&&(Be.set("int64",BigInt64Array),Sr.set(BigInt64Array,"int64")),e&&(Be.set("uint64",BigUint64Array),Sr.set(BigUint64Array,"uint64")),r?(Be.set("float16",Float16Array),Sr.set(Float16Array,"float16")):Be.set("float16",Uint16Array)}}}),xs=O(()=>{"use strict";cn(),gs=t=>{let e=1;for(let r=0;r<t.length;r++){let n=t[r];if("number"!=typeof n||!Number.isSafeInteger(n))throw TypeError(`dims[${r}] must be an integer, got: ${n}`);if(n<0)throw RangeError(`dims[${r}] must be a non-negative integer, got: ${n}`);e*=n}return e},ys=(t,e)=>{switch(t.location){case"cpu":return new St(t.type,t.data,e);case"cpu-pinned":return new St({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new St({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new St({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});case"ml-tensor":return new St({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:e});default:throw Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),cn=O(()=>{"use strict";ss(),ds(),bs(),xs(),St=class{constructor(t,e,r){let n,o;if(ms(),"object"==typeof t&&"location"in t)switch(this.dataLocation=t.location,n=t.type,o=t.dims,t.location){case"cpu-pinned":{let e=Be.get(n);if(!e)throw TypeError(`unsupported type "${n}" to create tensor from pinned buffer`);if(!(t.data instanceof e))throw TypeError(`buffer should be of type ${e.name}`);this.cpuData=t.data;break}case"texture":if("float32"!==n)throw TypeError(`unsupported type "${n}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break;case"gpu-buffer":if("float32"!==n&&"float16"!==n&&"int32"!==n&&"int64"!==n&&"uint32"!==n&&"uint8"!==n&&"bool"!==n&&"uint4"!==n&&"int4"!==n)throw TypeError(`unsupported type "${n}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break;case"ml-tensor":if("float32"!==n&&"float16"!==n&&"int32"!==n&&"int64"!==n&&"uint32"!==n&&"uint64"!==n&&"int8"!==n&&"uint8"!==n&&"bool"!==n)throw TypeError(`unsupported type "${n}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let s,a;if("string"==typeof t){if(n=t,a=r,"string"===t){if(!Array.isArray(e))throw TypeError("A string tensor's data must be a string array.");s=e}else{let r=Be.get(t);if(void 0===r)throw TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if("float16"===t&&r===Uint16Array||"uint4"===t||"int4"===t)throw TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${r.name} as data.`);s="uint64"===t||"int64"===t?r.from(e,BigInt):r.from(e)}else if(e instanceof r)s=e;else if(e instanceof Uint8ClampedArray){if("uint8"===t)s=Uint8Array.from(e);else throw TypeError("A Uint8ClampedArray tensor's data must be type of uint8")}else throw TypeError(`A ${n} tensor's data must be type of ${r}`)}}else if(a=e,Array.isArray(t)){if(0===t.length)throw TypeError("Tensor type cannot be inferred from an empty array.");let e=typeof t[0];if("string"===e)n="string",s=t;else if("boolean"===e)n="bool",s=Uint8Array.from(t);else throw TypeError(`Invalid element type of data array: ${e}.`)}else if(t instanceof Uint8ClampedArray)n="uint8",s=Uint8Array.from(t);else{let e=Sr.get(t.constructor);if(void 0===e)throw TypeError(`Unsupported type for tensor data: ${t.constructor}.`);n=e,s=t}if(void 0===a)a=[s.length];else if(!Array.isArray(a))throw TypeError("A tensor's dims must be a number array");o=a,this.cpuData=s,this.dataLocation="cpu"}let s=gs(o);if(this.cpuData&&s!==this.cpuData.length&&!(("uint4"===n||"int4"===n)&&Math.ceil(s/2)===this.cpuData.length))throw Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=n,this.dims=o,this.size=s}static async fromImage(t,e){return us(t,e)}static fromTexture(t,e){return ls(t,e)}static fromGpuBuffer(t,e){return fs(t,e)}static fromMLTensor(t,e){return cs(t,e)}static fromPinnedBuffer(t,e,r){return ps(t,e,r)}toDataURL(t){return is(this,t)}toImageData(t){return as(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw 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 Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){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 Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw 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("none"===this.dataLocation)throw Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw Error("Cannot reshape a tensor that owns GPU resource.");return ys(this,t)}}}
1),pn=O(()=>{"use strict";cn(),yt=St}),Go=O(()=>{"use strict";No(),Ts=(t,e)=>{(typeof Gt.trace>"u"?Gt.wasm.trace:Gt.trace)&&console.timeStamp(`${t}::ORT::${e}`)},ws=(t,e)=>{let r=Error().stack?.split(/\r\n|\r|\n/g)||[],n=!1;for(let o=0;o<r.length;o++){if(n&&!r[o].includes("TRACE_FUNC")){let n=`FUNC_${t}::${r[o].trim().split(" ")[1]}`;e&&(n+=`::${e}`),Ts("CPU",n);return}r[o].includes("TRACE_FUNC")&&(n=!0)}},Fe=t=>{(typeof Gt.trace>"u"?Gt.wasm.trace:Gt.trace)&&ws("BEGIN",t)},Ce=t=>{(typeof Gt.trace>"u"?Gt.wasm.trace:Gt.trace)&&ws("END",t)}}),vs=O(()=>{"use strict";fn(),pn(),Go(),dn=class t{constructor(t){this.handler=t}async run(t,e,r){Fe();let n={},o={};if("object"!=typeof t||null===t||t instanceof yt||Array.isArray(t))throw TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if("object"==typeof e){if(null===e)throw TypeError("Unexpected argument[1]: cannot be null.");if(e instanceof yt)throw TypeError("'fetches' cannot be a Tensor");if(Array.isArray(e)){if(0===e.length)throw TypeError("'fetches' cannot be an empty array.");for(let t of(s=!1,e)){if("string"!=typeof t)throw TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(t))throw RangeError(`'fetches' contains invalid output name: ${t}.`);n[t]=null}if("object"==typeof r&&null!==r)o=r;else if("u">typeof r)throw TypeError("'options' must be an object.")}else{let t=!1,a=Object.getOwnPropertyNames(e);for(let r of this.outputNames)if(-1!==a.indexOf(r)){let o=e[r];(null===o||o instanceof yt)&&(t=!0,s=!1,n[r]=o)}if(t){if("object"==typeof r&&null!==r)o=r;else if("u">typeof r)throw TypeError("'options' must be an object.")}else o=e}}else if("u">typeof e)throw TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of this.inputNames)if(typeof t[e]>"u")throw Error(`input '${e}' is missing in 'feeds'.`);if(s)for(let t of this.outputNames)n[t]=null;let a=await this.handler.run(t,n,o),u={};for(let t in a)if(Object.hasOwnProperty.call(a,t)){let e=a[t];e instanceof yt?u[t]=e:u[t]=new yt(e.type,e.data,e.dims)}return Ce(),u}async release(){return this.handler.dispose()}static async create(e,r,n,o){Fe();let s,a={};if("string"==typeof e){if(s=e,"object"==typeof r&&null!==r)a=r;else if("u">typeof r)throw TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(s=e,"object"==typeof r&&null!==r)a=r;else if("u">typeof r)throw TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer){let t=e,u=0,l=e.byteLength;if("object"==typeof r&&null!==r)a=r;else if("number"==typeof r){if(!Number.isSafeInteger(u=r))throw RangeError("'byteOffset' must be an integer.");if(u<0||u>=t.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(l=e.byteLength-u,"number"==typeof n){if(!Number.isSafeInteger(l=n))throw RangeError("'byteLength' must be an integer.");if(l<=0||u+l>t.byteLength)throw RangeError(`'byteLength' is out of range (0, ${t.byteLength-u}].`);if("object"==typeof o&&null!==o)a=o;else if("u">typeof o)throw TypeError("'options' must be an object.")}else if("u">typeof n)throw TypeError("'byteLength' must be a number.")}else if("u">typeof r)throw TypeError("'options' must be an object.");s=new Uint8Array(t,u,l)}else throw TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[u,l]=await ln(a),p=await u.createInferenceSessionHandler(s,l);return Ce(),new t(p)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Is=O(()=>{"use strict";vs(),Yd=dn}),_s=O(()=>{}),Os=O(()=>{}),Ss=O(()=>{}),As=O(()=>{}),Ps=O(()=>{"use strict";fn(),pn(),Zd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",hn=class t{constructor(t,e,r){this.handler=t,this.hasOptimizerModel=e,this.hasEvalModel=r}get trainingInputNames(){return this.handler.inputNames}
1get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw Error("This training session has no evalModel loaded.")}static async create(e,r){let n=e.evalModel||"",o=e.optimizerModel||"",s=r||{},[a,u]=await ln(s);if(a.createTrainingSessionHandler)return new t(await a.createTrainingSessionHandler(e.checkpointState,e.trainModel,n,o,u),!!e.optimizerModel,!!e.evalModel);throw Error(Zd)}typeNarrowingForRunStep(t,e,r,n,o){let s={},a={};if("object"!=typeof r||null===r||r instanceof yt||Array.isArray(r))throw TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let u=!0;if("object"==typeof n){if(null===n)throw TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof yt)throw TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(0===n.length)throw TypeError("'fetches' cannot be an empty array.");for(let t of(u=!1,n)){if("string"!=typeof t)throw TypeError("'fetches' must be a string array or an object.");if(-1===e.indexOf(t))throw RangeError(`'fetches' contains invalid output name: ${t}.`);s[t]=null}if("object"==typeof o&&null!==o)a=o;else if("u">typeof o)throw TypeError("'options' must be an object.")}else{let t=!1,r=Object.getOwnPropertyNames(n);for(let o of e)if(-1!==r.indexOf(o)){let e=n[o];(null===e||e instanceof yt)&&(t=!0,u=!1,s[o]=e)}if(t){if("object"==typeof o&&null!==o)a=o;else if("u">typeof o)throw TypeError("'options' must be an object.")}else a=n}}else if("u">typeof n)throw TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let e of t)if(typeof r[e]>"u")throw Error(`input '${e}' is missing in 'feeds'.`);if(u)for(let t of e)s[t]=null;return[s,a]}convertHandlerReturnTypeToMapOfTensors(t){let e={};for(let r in t)if(Object.hasOwnProperty.call(t,r)){let n=t[r];n instanceof yt?e[r]=n:e[r]=new yt(n.type,n.data,n.dims)}return e}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,e,r){let[n,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,e,r),s=await this.handler.runTrainStep(t,n,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(t){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(t||{});else throw Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(t,e,r){if(this.hasEvalModel){let[n,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,e,r),s=await this.handler.runEvalStep(t,n,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}throw Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,e=!0){let r=await this.getParametersSize(e);if(t.length!==4*r)throw Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(t,e)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}}),Es=O(()=>{"use strict";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(()=>{"use strict";ts(),os(),Is(),pn(),_s(),Os(),Go(),Ss(),As(),Es()});function _e(t,e,r,n){if(void 0===e)return eh(t);if(void 0===r)mn(t,e,1);else if("number"==typeof r&&void 0===n)mn(t,e,r);else if("string"==typeof r&&void 0===n)mn(t,r,1,e);else if("string"==typeof r&&"number"==typeof n)mn(t,r,n,e);else throw TypeError("input is valid")}function eh(t){return{verbose:_e.verbose.bind(null,t),info:_e.info.bind(null,t),warning:_e.warning.bind(null,t),error:_e.error.bind(null,t),fatal:_e.fatal.bind(null,t)}}function mn(t,e,r,n){let o=Ar[n||""]||Ar[""];Ls[t]<Ls[o.minimalSeverity]||(o.logDateTime&&(e=`${new Date().toISOString()}|${e}`),o.logSourceLocation,th[o.provider].log(t,e,n))}var Uo,Vo,Ls,th,$s,Ar,tt,gn,yn,xn,bn,Ut=O(()=>{"use strict";Uo=class{log(t,e,r){}},Vo=class{log(t,e,r){console.log(`${this.color(t)} ${r?"\x1b[35m"+r+"\x1b[0m ":""}${e}`)}color(t){switch(t){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 Error(`unsupported severity: ${t}`)}}},Ls={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},th={none:new Uo,console:new Vo},Ar={"":$s={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(t=>{function e(e,r){t("verbose",e,r)}function r(e,r){t("info",e,r)}function n(e,r){t("warning",e,r)}function o(e,r){t("error",e,r)}function s(e,r){t("fatal",e,r)}function a(t){Ar={},u("",t||{})}function u(t,e){if("*"===t)a(e);else{let r=Ar[t]||$s;Ar[t]={provider:e.provider||r.provider,minimalSeverity:e.minimalSeverity||r.minimalSeverity,logDateTime:void 0===e.logDateTime?r.logDateTime:e.logDateTime,logSourceLocation:void 0===e.logSourceLocation?r.logSourceLocation:e.logSourceLocation}}}function l(t){let e={};t.logLevel&&(e.minimalSeverity=t.logLevel),u("",e)}t.verbose=e,t.info=r,t.warning=n,t.error=o,t.fatal=s,t.reset=a,t.set=u,t.setWithEnv=l})(_e||={}),tt=_e,gn=class{constructor(t,e,r,n,o,s){this.category=t,this.name=e,this.startTime=r,this.endCallback=n,this.timer=o,this.ctx=s}async end(){return this.endCallback(this)}async checkTimer(){if(void 0===this.ctx||void 0===this.timer)throw Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},yn=class{constructor(t,e,r,n){this.category=t,this.name=e,this.startTime=r,this.endTime=n}},xn=class{constructor(t,e,r){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=void 0===t?1e4:t,this._flushBatchSize=void 0===e?10:e,this._flushIntervalInMilliseconds=void 0===r?5e3:r}static create(t){return void 0===t?new this:new this(t.maxNumberEvents,t.flushBatchSize,t.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=bn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,e,r,n){let o=this._started?this.begin(t,e,n):void 0,s=!1,a=r();if(a&&"function"==typeof a.then)return s=!0,new Promise((t,e)=>{a.then(async e=>{o&&await o.end(),t(e)},async t=>{o&&await o.end(),e(t)})});
1if(!s&&o){let t=o.end();if(t&&"function"==typeof t.then)return new Promise((e,r)=>{t.then(()=>{e(a)},t=>{r(t)})})}return a}begin(t,e,r){if(!this._started)throw Error("profiler is not started yet");if(void 0!==r)return new gn(t,e,0,async t=>this.end(t),r.beginTimer(),r);{let r=bn();return this.flush(r),new gn(t,e,r,t=>this.endSync(t))}}async end(t){let e=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(t.category,t.name,t.startTime,e)),this.flush(e))}endSync(t){let e=bn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new yn(t.category,t.name,t.startTime,e)),this.flush(e))}logOneEvent(t){tt.verbose(`Profiler.${t.category}`,`${(t.endTime-t.startTime).toFixed(2)}ms on event '${t.name}' at ${t.endTime.toFixed(2)}`)}flush(t){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||t-this._flushTime>=this._flushIntervalInMilliseconds){for(let t=this._flushPointer;this._flushPointer<t+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=bn()}}get started(){return this._started}},bn="u">typeof performance&&performance.now?()=>performance.now():Date.now});function ks(t,e,r){for(let n of r){let r=n[0],o=n[1],s=n[2],a=n[3],u=n[4];if(t.opType===r){for(let t of e)if((t.domain===o||"ai.onnx"===t.domain&&""===o)&&rh(t.version,s))return{opImpl:a,opInit:u}}}throw TypeError(`cannot resolve operator '${t.opType}' with opsets: ${e.map(t=>`${t.domain||"ai.onnx"} v${t.version}`).join(", ")}`)}function rh(t,e){if(e.endsWith("+")){let r=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(r)&&r<=t}if(2!==e.split("-").length)return Number.parseInt(e,10)===t;{let r=e.split("-"),n=Number.parseInt(r[0],10),o=Number.parseInt(r[1],10);return!isNaN(n)&&!isNaN(o)&&n<=t&&t<=o}}var Bs=O(()=>{}),Fs=mt(t=>{"use strict";t.__esModule=!0;var e=function(){function t(e){if(!e)throw TypeError("Invalid argument; `value` has no value.");this.value=t.EMPTY,e&&t.isGuid(e)&&(this.value=e)}return t.isGuid=function(e){var r=e.toString();return e&&(e instanceof t||t.validator.test(r))},t.create=function(){return new t([t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-"))},t.createEmpty=function(){return new t("emptyguid")},t.parse=function(e){return new t(e)},t.raw=function(){return[t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-")},t.gen=function(t){for(var e="",r=0;r<t;r++)e+=((1+Math.random())*65536|0).toString(16).substring(1);return e},t.prototype.equals=function(e){return t.isGuid(e)&&this.value===e.toString()},t.prototype.isEmpty=function(){return this.value===t.EMPTY},t.prototype.toString=function(){return this.value},t.prototype.toJSON=function(){return{value:this.value}},t.validator=RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),t.EMPTY="00000000-0000-0000-0000-000000000000",t}();t.Guid=e});function rt(t,e,r){this.low=0|t,this.high=0|e,this.unsigned=!!r}function Et(t){return(t&&t.__isLong__)===!0}function Cs(t){var e=Math.clz32(t&-t);return t?31-e:e}function Ne(t,e){var r,n,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(n=Rs[t])?n:(r=J(t,0,!0),o&&(Rs[t]=r),r)):(t|=0,(o=-128<=t&&t<128)&&(n=Ns[t])?n:(r=J(t,t<0?-1:0,!1),o&&(Ns[t]=r),r))}function zt(t,e){if(isNaN(t))return e?ye:Zt;if(e){if(t<0)return ye;if(t>=Vs)return Hs}else{if(t<=-Ms)return Ct;if(t+1>=Ms)return Ws}return t<0?zt(-t,e).neg():J(t%ir|0,t/ir|0,e)}function J(t,e,r){return new rt(t,e,r)}function Ho(t,e,r){if(0===t.length)throw Error("empty string");if("number"==typeof e?(r=e,e=!1):e=!!e,"NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e?ye:Zt;if((r=r||10)<2||36<r)throw RangeError("radix");if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return Ho(t.substring(1),e,r).neg();for(var n,o=zt(Tn(r,8)),s=Zt,a=0;a<t.length;a+=8){var u=Math.min(8,t.length-a),l=parseInt(t.substring(a,a+u),r);if(u<8){var p=zt(Tn(r,u));s=s.mul(p).add(zt(l))}else s=(s=s.mul(o)).add(zt(l))}return s.unsigned=e,s}function Qt(t,e){return"number"==typeof t?zt(t,e):"string"==typeof t?Ho(t,e):J(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}var Vt,Ns,Rs,Tn,Gs,oh,ir,Vs,Ms,Us,Zt,ye,or,zs,Wo,Ws,Hs,Ct,D,xe,w,F,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,oh=16777216,Ms=(Vs=(ir=(Gs=65536)*Gs)*ir)/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).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(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(!this.eq(Ct))return"-"+this.neg().toString(t);var e=zt(t),r=this.div(e),n=r.mul(e).sub(this);return r.toString(t)+n.toInt().toString(t)}for(var o=zt(Tn(t,6),this.unsigned),s=this,a="";;){var u=s.div(o),l=(s.sub(u.mul(o)).toInt()>>>0).toString(t);if((s=u).isZero())return l+a;for(;l.length<6;)l="0"+l;a=""+l+a}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0}
1,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 t=0!=this.high?this.high:this.low,e=31;e>0&&!(t&1<<e);e--);return 0!=this.high?e+33:e+1},D.isZero=function(){return 0===this.high&&0===this.low},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(1&this.low)==1},D.isEven=function(){return(1&this.low)==0},D.equals=function(t){return Et(t)||(t=Qt(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},D.eq=D.equals,D.notEquals=function(t){return!this.eq(t)},D.neq=D.notEquals,D.ne=D.notEquals,D.lessThan=function(t){return 0>this.comp(t)},D.lt=D.lessThan,D.lessThanOrEqual=function(t){return 0>=this.comp(t)},D.lte=D.lessThanOrEqual,D.le=D.lessThanOrEqual,D.greaterThan=function(t){return this.comp(t)>0},D.gt=D.greaterThan,D.greaterThanOrEqual=function(t){return this.comp(t)>=0},D.gte=D.greaterThanOrEqual,D.ge=D.greaterThanOrEqual,D.compare=function(t){if(Et(t)||(t=Qt(t)),this.eq(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},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(t){Et(t)||(t=Qt(t));var e,r,n=this.high>>>16,o=65535&this.high,s=this.low>>>16,a=65535&this.low,u=t.high>>>16,l=65535&t.high,p=t.low>>>16,c=65535&t.low,d=0,h=0;return r=0+((e=0+(a+c))>>>16),e&=65535,r+=s+p,h+=r>>>16,r&=65535,h+=o+l,d+=h>>>16,h&=65535,d+=n+u,J(r<<16|e,(d&=65535)<<16|h,this.unsigned)},D.subtract=function(t){return Et(t)||(t=Qt(t)),this.add(t.neg())},D.sub=D.subtract,D.multiply=function(t){if(this.isZero())return this;if(Et(t)||(t=Qt(t)),Vt)return J(Vt.mul(this.low,this.high,t.low,t.high),Vt.get_high(),this.unsigned);if(t.isZero())return this.unsigned?ye:Zt;if(this.eq(Ct))return t.isOdd()?Ct:Zt;if(t.eq(Ct))return this.isOdd()?Ct:Zt;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Us)&&t.lt(Us))return zt(this.toNumber()*t.toNumber(),this.unsigned);var e,r,n=this.high>>>16,o=65535&this.high,s=this.low>>>16,a=65535&this.low,u=t.high>>>16,l=65535&t.high,p=t.low>>>16,c=65535&t.low,d=0,h=0;return r=0+((e=0+a*c)>>>16),e&=65535,r+=s*c,h+=r>>>16,r&=65535,r+=a*p,h+=r>>>16,r&=65535,h+=o*c,d+=h>>>16,h&=65535,h+=s*p,d+=h>>>16,h&=65535,h+=a*l,d+=h>>>16,h&=65535,d+=n*c+o*p+s*l+a*u,J(r<<16|e,(d&=65535)<<16|h,this.unsigned)},D.mul=D.multiply,D.divide=function(t){if(Et(t)||(t=Qt(t)),t.isZero())throw Error("division by zero");if(Vt){var e,r,n;return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?J((this.unsigned?Vt.div_u:Vt.div_s)(this.low,this.high,t.low,t.high),Vt.get_high(),this.unsigned):this}if(this.isZero())return this.unsigned?ye:Zt;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return ye;if(t.gt(this.shru(1)))return zs;n=ye}else{if(this.eq(Ct))return t.eq(or)||t.eq(Wo)?Ct:t.eq(Ct)?or:(e=this.shr(1).div(t).shl(1)).eq(Zt)?t.isNegative()?or:Wo:(r=this.sub(t.mul(e)),n=e.add(r.div(t)));if(t.eq(Ct))return this.unsigned?ye:Zt;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();n=Zt}for(r=this;r.gte(t);){e=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var o=Math.ceil(Math.log(e)/Math.LN2),s=o<=48?1:Tn(2,o-48),a=zt(e),u=a.mul(t);u.isNegative()||u.gt(r);)e-=s,u=(a=zt(e,this.unsigned)).mul(t);a.isZero()&&(a=or),n=n.add(a),r=r.sub(u)}return n},D.div=D.divide,D.modulo=function(t){return(Et(t)||(t=Qt(t)),Vt)?J((this.unsigned?Vt.rem_u:Vt.rem_s)(this.low,this.high,t.low,t.high),Vt.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},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(t){return Et(t)||(t=Qt(t)),J(this.low&t.low,this.high&t.high,this.unsigned)},D.or=function(t){return Et(t)||(t=Qt(t)),J(this.low|t.low,this.high|t.high,this.unsigned)},D.xor=function(t){return Et(t)||(t=Qt(t)),J(this.low^t.low,this.high^t.high,this.unsigned)},D.shiftLeft=function(t){return Et(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?J(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):J(0,this.low<<t-32,this.unsigned)},D.shl=D.shiftLeft,D.shiftRight=function(t){return Et(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?J(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):J(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},D.shr=D.shiftRight,D.shiftRightUnsigned=function(t){return Et(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?J(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):32===t?J(this.high,0,this.unsigned):J(this.high>>>t-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.rotateLeft=function(t){var e;return Et(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?J(this.high,this.low,this.unsigned):t<32?
vendor: 6,716 bytes, line 1
1(e=32-t,J(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)):(t-=32,e=32-t,J(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned))},D.rotl=D.rotateLeft,D.rotateRight=function(t){var e;return Et(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?J(this.high,this.low,this.unsigned):t<32?(e=32-t,J(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned)):(t-=32,e=32-t,J(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,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(t){return t?this.toBytesLE():this.toBytesBE()},D.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},D.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},rt.fromBytes=function(t,e,r){return r?rt.fromBytesLE(t,e):rt.fromBytesBE(t,e)},rt.fromBytesLE=function(t,e){return new rt(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},rt.fromBytesBE=function(t,e){return new rt(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)},xe=rt}),wn=O(()=>{(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=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],w.Long=function(t,e){this.low=0|t,this.high=0|e},w.Long.create=function(t,e){return 0==t&&0==e?w.Long.ZERO:new w.Long(t,e)},w.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},w.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},w.Long.ZERO=new w.Long(0,0),w.Builder=function(t){if(t)var e=t;else var e=1024;this.bb=w.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},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(t){this.force_defaults=t},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(t,e){t>this.minalign&&(this.minalign=t);for(var r=~(this.bb.capacity()-this.space+e)+1&t-1;this.space<r+t+e;){var n=this.bb.capacity();this.bb=w.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(r)},w.Builder.prototype.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},w.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},w.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},w.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},w.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},w.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},w.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},w.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},w.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},w.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},w.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},w.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},w.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},w.Builder.prototype.addFieldInt8=function(t,e,r){(this.force_defaults||e!=r)&&(this.addInt8(e),this.slot(t))},w.Builder.prototype.addFieldInt16=function(t,e,r){(this.force_defaults||e!=r)&&(this.addInt16(e),this.slot(t))},w.Builder.prototype.addFieldInt32=function(t,e,r){(this.force_defaults||e!=r)&&(this.addInt32(e),this.slot(t))},w.Builder.prototype.addFieldInt64=function(t,e,r){(this.force_defaults||!e.equals(r))&&(this.addInt64(e),this.slot(t))},w.Builder.prototype.addFieldFloat32=function(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat32(e),this.slot(t))},w.Builder.prototype.addFieldFloat64=function(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat64(e),this.slot(t))},w.Builder.prototype.addFieldOffset=function(t,e,r){(this.force_defaults||e!=r)&&(this.addOffset(e),this.slot(t))},w.Builder.prototype.addFieldStruct=function(t,e,r){e!=r&&(this.nested(e),this.slot(t))},w.Builder.prototype.nested=function(t){if(t!=this.offset())throw Error("FlatBuffers: struct must be serialized inline.")},w.Builder.prototype.notNested=function(){if(this.isNested)throw Error("FlatBuffers: object serialization must not be nested.")},w.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},w.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},w.Builder.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var r=e<<1,n=w.ByteBuffer.allocate(r);return n.setPosition(r-e),n.bytes().set(t.bytes(),r-e),n},w.Builder.prototype.addOffset=function(t){this.prep(w.SIZEOF_INT,0),this.writeInt32(this.offset()-t+w.SIZEOF_INT)},w.Builder.prototype.startObject=function(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(var e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()},w.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var r=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);var n=2;this.addInt16(t-this.object_start);var o=(r+n)*w.SIZEOF_SHORT;this.addInt16(o);var s=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){var u=this.bb.capacity()-this.vtables[e];if(o==this.bb.readInt16(u)){for(var l=w.SIZEOF_SHORT;l<o;l+=w.SIZEOF_SHORT)if(this.bb.readInt16(a+l)!=this.bb.readInt16(u+l))continue t;s=this.vtables[e];break}}return s?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,s-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},w.Builder.prototype.finish=function(t,e,r){var n=r?w.SIZE_PREFIX_LENGTH:0;
vendor: 7,085 bytes, line 1
1if(e){var o=e;if(this.prep(this.minalign,w.SIZEOF_INT+w.FILE_IDENTIFIER_LENGTH+n),o.length!=w.FILE_IDENTIFIER_LENGTH)throw Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var s=w.FILE_IDENTIFIER_LENGTH-1;s>=0;s--)this.writeInt8(o.charCodeAt(s))}this.prep(this.minalign,w.SIZEOF_INT+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},w.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},w.Builder.prototype.requiredField=function(t,e){var r=this.bb.capacity()-t,n=r-this.bb.readInt32(r);if(!(0!=this.bb.readInt16(n+e)))throw Error("FlatBuffers: field "+e+" must be set")},w.Builder.prototype.startVector=function(t,e,r){this.notNested(),this.vector_num_elems=e,this.prep(w.SIZEOF_INT,t*e),this.prep(r,t*e)},w.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},w.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else for(var e=[],r=0;r<t.length;){var n,o=t.charCodeAt(r++);(n=o<55296||o>=56320?o:(o<<10)+t.charCodeAt(r++)+-56613888)<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(63&n|128))}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(var r=0,s=this.space,a=this.bb.bytes();r<e.length;r++)a[s++]=e[r];return this.endVector()},w.Builder.prototype.createLong=function(t,e){return w.Long.create(t,e)},w.ByteBuffer=function(t){this.bytes_=t,this.position_=0},w.ByteBuffer.allocate=function(t){return new w.ByteBuffer(new Uint8Array(t))},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(t){this.position_=t},w.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},w.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},w.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},w.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},w.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},w.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},w.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},w.ByteBuffer.prototype.readInt64=function(t){return new w.Long(this.readInt32(t),this.readInt32(t+4))},w.ByteBuffer.prototype.readUint64=function(t){return new w.Long(this.readUint32(t),this.readUint32(t+4))},w.ByteBuffer.prototype.readFloat32=function(t){return w.int32[0]=this.readInt32(t),w.float32[0]},w.ByteBuffer.prototype.readFloat64=function(t){return w.int32[w.isLittleEndian?0:1]=this.readInt32(t),w.int32[w.isLittleEndian?1:0]=this.readInt32(t+4),w.float64[0]},w.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},w.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},w.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},w.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},w.ByteBuffer.prototype.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},w.ByteBuffer.prototype.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},w.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},w.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},w.ByteBuffer.prototype.writeFloat32=function(t,e){w.float32[0]=e,this.writeInt32(t,w.int32[0])},w.ByteBuffer.prototype.writeFloat64=function(t,e){w.float64[0]=e,this.writeInt32(t,w.int32[w.isLittleEndian?0:1]),this.writeInt32(t+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 Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<w.FILE_IDENTIFIER_LENGTH;e++)t+=String.fromCharCode(this.readInt8(this.position_+w.SIZEOF_INT+e));return t},w.ByteBuffer.prototype.__offset=function(t,e){var r=t-this.readInt32(t);return e<this.readInt16(r)?this.readInt16(r+e):0},w.ByteBuffer.prototype.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},w.ByteBuffer.prototype.__string=function(t,e){t+=this.readInt32(t);var r=this.readInt32(t),n="",o=0;if(t+=w.SIZEOF_INT,e===w.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+r);for(;o<r;){var s,a=this.readUint8(t+o++);if(a<192)s=a;else{var u=this.readUint8(t+o++);if(a<224)s=(31&a)<<6|63&u;else{var l=this.readUint8(t+o++);s=a<240?(15&a)<<12|(63&u)<<6|63&l:(7&a)<<18|(63&u)<<12|(63&l)<<6|63&this.readUint8(t+o++)}}s<65536?n+=String.fromCharCode(s):(s-=65536,n+=String.fromCharCode((s>>10)+55296,(1023&s)+56320))}return n},w.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},w.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+w.SIZEOF_INT},w.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},w.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=w.FILE_IDENTIFIER_LENGTH)throw Error("FlatBuffers: file identifier must be length "+w.FILE_IDENTIFIER_LENGTH);for(var e=0;e<w.FILE_IDENTIFIER_LENGTH;e++)if(t.charCodeAt(e)!=this.readInt8(this.position_+w.SIZEOF_INT+e))return!1;return!0},w.ByteBuffer.prototype.createLong=function(t,e){return w.Long.create(t,e)}}),Pr=O(()=>{"use strict";wn(),(t=>{let e;(t=>{let e;(t=>{let e,r;(r=e=t.AttributeType||={})[r.UNDEFINED=0]="UNDEFINED",r[r.FLOAT=1]="FLOAT",r[r.INT=2]="INT",r[r.STRING=3]="STRING",r[r.TENSOR=4]="TENSOR",r[r.GRAPH=5]="GRAPH",r[r.FLOATS=6]="FLOATS",r[r.INTS=7]="INTS",r[r.STRINGS=8]="STRINGS",r[r.TENSORS=9]="TENSORS",r[r.GRAPHS=10]="GRAPHS",r[r.SPARSE_TENSOR=11]="SPARSE_TENSOR",r[r.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{let e,r;(r=e=t.DimensionValueType||={})[r.UNKNOWN=0]="UNKNOWN",r[r.VALUE=1]="VALUE",r[r.PARAM=2]="PARAM"})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{let e,r;(r=e=t.TensorDataType||={})[r.UNDEFINED=0]="UNDEFINED",r[r.FLOAT=1]="FLOAT",r[r.UINT8=2]="UINT8",r[r.INT8=3]="INT8",r[r.UINT16=4]="UINT16",r[r.INT16=5]="INT16",r[r.INT32=6]="INT32",r[r.INT64=7]="INT64",r[r.STRING=8]="STRING",r[r.BOOL=9]="BOOL",r[r.FLOAT16=10]="FLOAT16",r[r.DOUBLE=11]="DOUBLE",r[r.UINT32=12]="UINT32",r[r.UINT64=13]="UINT64",r[r.COMPLEX64=14]="COMPLEX64",r[r.COMPLEX128=15]="COMPLEX128",r[r.BFLOAT16=16]="BFLOAT16",r[r.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",r[r.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",r[r.FLOAT8E5M2=19]="FLOAT8E5M2",r[r.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{let e,r;(r=e=t.NodeType||={}
vendor: 34,004 bytes, line 1
1)[r.Primitive=0]="Primitive",r[r.Fused=1]="Fused"})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{let e,r;(r=e=t.TypeInfoValue||={})[r.NONE=0]="NONE",r[r.tensor_type=1]="tensor_type",r[r.sequence_type=2]="sequence_type",r[r.map_type=3]="map_type"})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsShape(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsShape(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}dim(e,r){let n=this.bb.__offset(this.bb_pos,4);return n?(r||new t.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}dimLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startShape(t){t.startObject(1)}static addDim(t,e){t.addFieldOffset(0,e,0)}static createDimVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startDimVector(t,e){t.startVector(4,e,4)}static endShape(t){return t.endObject()}static createShape(t,e){return r.startShape(t),r.addDim(t,e),r.endShape(t)}}e.Shape=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDimension(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimension(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}value(e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new t.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}denotation(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startDimension(t){t.startObject(2)}static addValue(t,e){t.addFieldOffset(0,e,0)}static addDenotation(t,e){t.addFieldOffset(1,e,0)}static endDimension(t){return t.endObject()}static createDimension(t,e,n){return r.startDimension(t),r.addValue(t,e),r.addDenotation(t,n),r.endDimension(t)}}e.Dimension=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{class e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDimensionValue(t,r){return(r||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimensionValue(t,r){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(r||new e).__init(t.readInt32(t.position())+t.position(),t)}dimType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):0}dimValue(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}dimParam(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}static startDimensionValue(t){t.startObject(3)}static addDimType(t,e){t.addFieldInt8(0,e,0)}static addDimValue(t,e){t.addFieldInt64(1,e,t.createLong(0,0))}static addDimParam(t,e){t.addFieldOffset(2,e,0)}static endDimensionValue(t){return t.endObject()}static createDimensionValue(t,r,n,o){return e.startDimensionValue(t),e.addDimType(t,r),e.addDimValue(t,n),e.addDimParam(t,o),e.endDimensionValue(t)}}t.DimensionValue=e})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTensorTypeAndShape(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensorTypeAndShape(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}elemType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}shape(e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new t.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startTensorTypeAndShape(t){t.startObject(2)}static addElemType(t,e){t.addFieldInt32(0,e,0)}static addShape(t,e){t.addFieldOffset(1,e,0)}static endTensorTypeAndShape(t){return t.endObject()}static createTensorTypeAndShape(t,e,n){return r.startTensorTypeAndShape(t),r.addElemType(t,e),r.addShape(t,n),r.endTensorTypeAndShape(t)}}e.TensorTypeAndShape=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMapType(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMapType(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keyType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}valueType(e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startMapType(t){t.startObject(2)}static addKeyType(t,e){t.addFieldInt32(0,e,0)}static addValueType(t,e){t.addFieldOffset(1,e,0)}static endMapType(t){return t.endObject()}static createMapType(t,e,n){return r.startMapType(t),r.addKeyType(t,e),r.addValueType(t,n),r.endMapType(t)}}e.MapType=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSequenceType(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSequenceType(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}elemType(e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startSequenceType(t){t.startObject(1)}static addElemType(t,e){t.addFieldOffset(0,e,0)}static endSequenceType(t){return t.endObject()}static createSequenceType(t,e){return r.startSequenceType(t),r.addElemType(t,e),r.endSequenceType(t)}}e.SequenceType=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{class e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,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(t,e,r,n){return t.prep(4,12),t.writeInt32(n),t.writeInt32(r),t.writeInt32(e),t.offset()}}t.EdgeEnd=e})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNodeEdge(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodeEdge(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}nodeIndex(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}inputEdges(e,r){let n=this.bb.__offset(this.bb_pos,6);return n?(r||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}inputEdgesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}outputEdges(e,r){let n=this.bb.__offset(this.bb_pos,8);return n?(r||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}outputEdgesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNodeEdge(t){t.startObject(3)}static addNodeIndex(t,e){t.addFieldInt32(0,e,0)}static addInputEdges(t,e){t.addFieldOffset(1,e,0)}static startInputEdgesVector(t,e){t.startVector(12,e,4)}static addOutputEdges(t,e){t.addFieldOffset(2,e,0)}static startOutputEdgesVector(t,e){t.startVector(12,e,4)}static endNodeEdge(t){return t.endObject()}static createNodeEdge(t,e,n,o){return r.startNodeEdge(t),r.addNodeIndex(t,e),r.addInputEdges(t,n),r.addOutputEdges(t,o),r.endNodeEdge(t)}}e.NodeEdge=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNode(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNode(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}domain(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}sinceVersion(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0}index(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint32(this.bb_pos+t):0}opType(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):0}executionProviderType(t){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null}inputs(t,e){let r=this.bb.__offset(this.bb_pos,20);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,e){let r=this.bb.__offset(this.bb_pos,22);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}attributes(e,r){let n=this.bb.__offset(this.bb_pos,24);return n?(r||new t.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}attributesLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCounts(t){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*t):0}inputArgCountsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCountsArray(){let t=this.bb.__offset(this.bb_pos,26);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}implicitInputs(t,e){let r=this.bb.__offset(this.bb_pos,28);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}implicitInputsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNode(t){t.startObject(13)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addDomain(t,e){t.addFieldOffset(2,e,0)}static addSinceVersion(t,e){t.addFieldInt32(3,e,0)}static addIndex(t,e){t.addFieldInt32(4,e,0)}static addOpType(t,e){t.addFieldOffset(5,e,0)}static addType(t,e){t.addFieldInt32(6,e,0)}static addExecutionProviderType(t,e){t.addFieldOffset(7,e,0)}static addInputs(t,e){t.addFieldOffset(8,e,0)}static createInputsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startInputsVector(t,e){t.startVector(4,e,4)}static addOutputs(t,e){t.addFieldOffset(9,e,0)}static createOutputsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startOutputsVector(t,e){t.startVector(4,e,4)}static addAttributes(t,e){t.addFieldOffset(10,e,0)}static createAttributesVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startAttributesVector(t,e){t.startVector(4,e,4)}static addInputArgCounts(t,e){t.addFieldOffset(11,e,0)}static createInputArgCountsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addInt32(e[r]);return t.endVector()}static startInputArgCountsVector(t,e){t.startVector(4,e,4)}static addImplicitInputs(t,e){t.addFieldOffset(12,e,0)}static createImplicitInputsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startImplicitInputsVector(t,e){t.startVector(4,e,4)}static endNode(t){return t.endObject()}static createNode(t,e,n,o,s,a,u,l,p,c,d,h,f,g){return r.startNode(t),r.addName(t,e),r.addDocString(t,n),r.addDomain(t,o),r.addSinceVersion(t,s),r.addIndex(t,a),r.addOpType(t,u),r.addType(t,l),r.addExecutionProviderType(t,p),r.addInputs(t,c),r.addOutputs(t,d),r.addAttributes(t,h),r.addInputArgCounts(t,f),r.addImplicitInputs(t,g),r.endNode(t)}}e.Node=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsValueInfo(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsValueInfo(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}type(e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startValueInfo(t){t.startObject(3)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addType(t,e){t.addFieldOffset(2,e,0)}static endValueInfo(t){return t.endObject()}static createValueInfo(t,e,n,o){return r.startValueInfo(t),r.addName(t,e),r.addDocString(t,n),r.addType(t,o),r.endValueInfo(t)}}e.ValueInfo=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{class e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTypeInfo(t,r){return(r||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTypeInfo(t,r){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(r||new e).__init(t.readInt32(t.position())+t.position(),t)}denotation(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}valueType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):0}value(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}static startTypeInfo(t){t.startObject(3)}static addDenotation(t,e){t.addFieldOffset(0,e,0)}static addValueType(t,e){t.addFieldInt8(1,e,0)}static addValue(t,e){t.addFieldOffset(2,e,0)}static endTypeInfo(t){return t.endObject()}static createTypeInfo(t,r,n,o){return e.startTypeInfo(t),e.addDenotation(t,r),e.addValueType(t,n),e.addValue(t,o),e.endTypeInfo(t)}}t.TypeInfo=e})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{class e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsOperatorSetId(t,r){return(r||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOperatorSetId(t,r){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(r||new e).__init(t.readInt32(t.position())+t.position(),t)}domain(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}version(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}static startOperatorSetId(t){t.startObject(2)}static addDomain(t,e){t.addFieldOffset(0,e,0)}static addVersion(t,e){t.addFieldInt64(1,e,t.createLong(0,0))}static endOperatorSetId(t){return t.endObject()}static createOperatorSetId(t,r,n){return e.startOperatorSetId(t),e.addDomain(t,r),e.addVersion(t,n),e.endOperatorSetId(t)}}t.OperatorSetId=e})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{class e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTensor(t,r){return(r||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensor(t,r){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(r||new e).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}dims(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}dataType(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0}rawData(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}rawDataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}rawDataArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}stringData(t,e){let r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}stringDataLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}static startTensor(t){t.startObject(6)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addDims(t,e){t.addFieldOffset(2,e,0)}static createDimsVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static addDataType(t,e){t.addFieldInt32(3,e,0)}static addRawData(t,e){t.addFieldOffset(4,e,0)}static createRawDataVector(t,e){t.startVector(1,e.length,1);for(let r=e.length-1;r>=0;r--)t.addInt8(e[r]);return t.endVector()}static startRawDataVector(t,e){t.startVector(1,e,1)}static addStringData(t,e){t.addFieldOffset(5,e,0)}static createStringDataVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startStringDataVector(t,e){t.startVector(4,e,4)}static endTensor(t){return t.endObject()}static createTensor(t,r,n,o,s,a,u){return e.startTensor(t),e.addName(t,r),e.addDocString(t,n),e.addDims(t,o),e.addDataType(t,s),e.addRawData(t,a),e.addStringData(t,u),e.endTensor(t)}}t.Tensor=e})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSparseTensor(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSparseTensor(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}values(e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}indices(e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}dims(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSparseTensor(t){t.startObject(3)}static addValues(t,e){t.addFieldOffset(0,e,0)}static addIndices(t,e){t.addFieldOffset(1,e,0)}static addDims(t,e){t.addFieldOffset(2,e,0)}static createDimsVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static endSparseTensor(t){return t.endObject()}static createSparseTensor(t,e,n,o){return r.startSparseTensor(t),r.addValues(t,e),r.addIndices(t,n),r.addDims(t,o),r.endSparseTensor(t)}}e.SparseTensor=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsAttribute(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsAttribute(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):0}f(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0}i(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}s(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}t(e){let r=this.bb.__offset(this.bb_pos,16);return r?(e||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}g(e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}floats(t){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0}floatsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}floatsArray(){let t=this.bb.__offset(this.bb_pos,20);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}ints(t){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}intsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}strings(t,e){let r=this.bb.__offset(this.bb_pos,24);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}stringsLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}tensors(e,r){let n=this.bb.__offset(this.bb_pos,26);return n?(r||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}tensorsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}graphs(e,r){let n=this.bb.__offset(this.bb_pos,28);return n?(r||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}graphsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startAttribute(t){t.startObject(13)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addType(t,e){t.addFieldInt32(2,e,0)}static addF(t,e){t.addFieldFloat32(3,e,0)}static addI(t,e){t.addFieldInt64(4,e,t.createLong(0,0))}static addS(t,e){t.addFieldOffset(5,e,0)}static addT(t,e){t.addFieldOffset(6,e,0)}static addG(t,e){t.addFieldOffset(7,e,0)}static addFloats(t,e){t.addFieldOffset(8,e,0)}static createFloatsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addFloat32(e[r]);return t.endVector()}static startFloatsVector(t,e){t.startVector(4,e,4)}static addInts(t,e){t.addFieldOffset(9,e,0)}static createIntsVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startIntsVector(t,e){t.startVector(8,e,8)}static addStrings(t,e){t.addFieldOffset(10,e,0)}static createStringsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startStringsVector(t,e){t.startVector(4,e,4)}static addTensors(t,e){t.addFieldOffset(11,e,0)}static createTensorsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startTensorsVector(t,e){t.startVector(4,e,4)}static addGraphs(t,e){t.addFieldOffset(12,e,0)}static createGraphsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startGraphsVector(t,e){t.startVector(4,e,4)}static endAttribute(t){return t.endObject()}static createAttribute(t,e,n,o,s,a,u,l,p,c,d,h,f,g){return r.startAttribute(t),r.addName(t,e),r.addDocString(t,n),r.addType(t,o),r.addF(t,s),r.addI(t,a),r.addS(t,u),r.addT(t,l),r.addG(t,p),r.addFloats(t,c),r.addInts(t,d),r.addStrings(t,h),r.addTensors(t,f),r.addGraphs(t,g),r.endAttribute(t)}}e.Attribute=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGraph(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGraph(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}initializers(e,r){let n=this.bb.__offset(this.bb_pos,4);return n?(r||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}initializersLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeArgs(e,r){let n=this.bb.__offset(this.bb_pos,6);return n?(r||new t.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}nodeArgsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}nodes(e,r){let n=this.bb.__offset(this.bb_pos,8);return n?(r||new t.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}maxNodeIndex(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readUint32(this.bb_pos+t):0}nodeEdges(e,r){let n=this.bb.__offset(this.bb_pos,12);return n?(r||new t.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}nodeEdgesLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}inputs(t,e){let r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,e){let r=this.bb.__offset(this.bb_pos,16);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*t,e):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}sparseInitializers(e,r){let n=this.bb.__offset(this.bb_pos,18);return n?(r||new t.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}sparseInitializersLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGraph(t){t.startObject(8)}static addInitializers(t,e){t.addFieldOffset(0,e,0)}static createInitializersVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startInitializersVector(t,e){t.startVector(4,e,4)}static addNodeArgs(t,e){t.addFieldOffset(1,e,0)}static createNodeArgsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startNodeArgsVector(t,e){t.startVector(4,e,4)}static addNodes(t,e){t.addFieldOffset(2,e,0)}static createNodesVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startNodesVector(t,e){t.startVector(4,e,4)}static addMaxNodeIndex(t,e){t.addFieldInt32(3,e,0)}static addNodeEdges(t,e){t.addFieldOffset(4,e,0)}static createNodeEdgesVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startNodeEdgesVector(t,e){t.startVector(4,e,4)}static addInputs(t,e){t.addFieldOffset(5,e,0)}static createInputsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startInputsVector(t,e){t.startVector(4,e,4)}static addOutputs(t,e){t.addFieldOffset(6,e,0)}static createOutputsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startOutputsVector(t,e){t.startVector(4,e,4)}static addSparseInitializers(t,e){t.addFieldOffset(7,e,0)}static createSparseInitializersVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startSparseInitializersVector(t,e){t.startVector(4,e,4)}static endGraph(t){return t.endObject()}static createGraph(t,e,n,o,s,a,u,l,p){return r.startGraph(t),r.addInitializers(t,e),r.addNodeArgs(t,n),r.addNodes(t,o),r.addMaxNodeIndex(t,s),r.addNodeEdges(t,a),r.addInputs(t,u),r.addOutputs(t,l),r.addSparseInitializers(t,p),r.endGraph(t)}}e.Graph=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModel(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsModel(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}irVersion(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}opsetImport(e,r){let n=this.bb.__offset(this.bb_pos,6);return n?(r||new t.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}opsetImportLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}producerName(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}producerVersion(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}domain(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}modelVersion(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}docString(t){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,t):null}graph(e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}graphDocString(t){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,t):null}static startModel(t){t.startObject(9)}static addIrVersion(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addOpsetImport(t,e){t.addFieldOffset(1,e,0)}static createOpsetImportVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startOpsetImportVector(t,e){t.startVector(4,e,4)}static addProducerName(t,e){t.addFieldOffset(2,e,0)}static addProducerVersion(t,e){t.addFieldOffset(3,e,0)}static addDomain(t,e){t.addFieldOffset(4,e,0)}static addModelVersion(t,e){t.addFieldInt64(5,e,t.createLong(0,0))}static addDocString(t,e){t.addFieldOffset(6,e,0)}static addGraph(t,e){t.addFieldOffset(7,e,0)}static addGraphDocString(t,e){t.addFieldOffset(8,e,0)}static endModel(t){return t.endObject()}static createModel(t,e,n,o,s,a,u,l,p,c){return r.startModel(t),r.addIrVersion(t,e),r.addOpsetImport(t,n),r.addProducerName(t,o),r.addProducerVersion(t,s),r.addDomain(t,a),r.addModelVersion(t,u),r.addDocString(t,l),r.addGraph(t,p),r.addGraphDocString(t,c),r.endModel(t)}}e.Model=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(t=>{let e;(t=>{class e{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKernelCreateInfos(t,r){return(r||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelCreateInfos(t,r){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(r||new e).__init(t.readInt32(t.position())+t.position(),t)}nodeIndices(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}nodeIndicesLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeIndicesArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}kernelDefHashes(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}kernelDefHashesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startKernelCreateInfos(t){t.startObject(2)}static addNodeIndices(t,e){t.addFieldOffset(0,e,0)}static createNodeIndicesVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addInt32(e[r]);return t.endVector()}static startNodeIndicesVector(t,e){t.startVector(4,e,4)}static addKernelDefHashes(t,e){t.addFieldOffset(1,e,0)}static createKernelDefHashesVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startKernelDefHashesVector(t,e){t.startVector(8,e,8)}static endKernelCreateInfos(t){return t.endObject()}static createKernelCreateInfos(t,r,n){return e.startKernelCreateInfos(t),e.addNodeIndices(t,r),e.addKernelDefHashes(t,n),e.endKernelCreateInfos(t)}}t.KernelCreateInfos=e})(e=t.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>
1{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSubGraphSessionState(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSubGraphSessionState(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}graphId(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}sessionState(e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startSubGraphSessionState(t){t.startObject(2)}static addGraphId(t,e){t.addFieldOffset(0,e,0)}static addSessionState(t,e){t.addFieldOffset(1,e,0)}static endSubGraphSessionState(t){let e=t.endObject();return t.requiredField(e,4),e}static createSubGraphSessionState(t,e,n){return r.startSubGraphSessionState(t),r.addGraphId(t,e),r.addSessionState(t,n),r.endSubGraphSessionState(t)}}e.SubGraphSessionState=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSessionState(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSessionState(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}kernels(e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new t.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}subGraphSessionStates(e,r){let n=this.bb.__offset(this.bb_pos,6);return n?(r||new t.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}subGraphSessionStatesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSessionState(t){t.startObject(2)}static addKernels(t,e){t.addFieldOffset(0,e,0)}static addSubGraphSessionStates(t,e){t.addFieldOffset(1,e,0)}static createSubGraphSessionStatesVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startSubGraphSessionStatesVector(t,e){t.startVector(4,e,4)}static endSessionState(t){return t.endObject()}static createSessionState(t,e,n){return r.startSessionState(t),r.addKernels(t,e),r.addSubGraphSessionStates(t,n),r.endSessionState(t)}}e.SessionState=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={}),(t=>{let e;(e=>{let r;(e=>{class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInferenceSession(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInferenceSession(t,e){return t.setPosition(t.position()+w.SIZE_PREFIX_LENGTH),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static bufferHasIdentifier(t){return t.__has_identifier("ORTM")}ortVersion(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}model(e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new t.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}sessionState(e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startInferenceSession(t){t.startObject(3)}static addOrtVersion(t,e){t.addFieldOffset(0,e,0)}static addModel(t,e){t.addFieldOffset(1,e,0)}static addSessionState(t,e){t.addFieldOffset(2,e,0)}static endInferenceSession(t){return t.endObject()}static finishInferenceSessionBuffer(t,e){t.finish(e,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(t,e){t.finish(e,"ORTM",!0)}static createInferenceSession(t,e,n,o){return r.startInferenceSession(t),r.addOrtVersion(t,e),r.addModel(t,n),r.addSessionState(t,o),r.endInferenceSession(t)}}e.InferenceSession=r})(r=e.fbs||={})})(e=t.experimental||={})})(F||={})}),js=mt((t,e)=>{"use strict";function r(t,e){for(var r=Array(arguments.length-1),n=0,o=2,s=!0;o<arguments.length;)r[n++]=arguments[o++];return new Promise(function(o,a){r[n]=function(t){if(s){if(s=!1,t)a(t);else{for(var e=Array(arguments.length-1),r=0;r<e.length;)e[r++]=arguments[r];o.apply(null,e)}}};try{t.apply(e||null,r)}catch(t){s&&(s=!1,a(t))}})}
vendor: 123,379 bytes, line 1
1e.exports=r}),Ys=mt(t=>{"use strict";var e,r=t;r.length=function(t){var e=t.length;if(!e)return 0;for(var r=0;--e%4>1&&"="===t.charAt(e);)++r;return Math.ceil(3*t.length)/4-r};var n=Array(64),o=Array(123);for(e=0;e<64;)o[n[e]=e<26?e+65:e<52?e+71:e<62?e-4:e-59|43]=e++;r.encode=function(t,e,r){for(var o,s=null,a=[],u=0,l=0;e<r;){var p=t[e++];switch(l){case 0:a[u++]=n[p>>2],o=(3&p)<<4,l=1;break;case 1:a[u++]=n[o|p>>4],o=(15&p)<<2,l=2;break;case 2:a[u++]=n[o|p>>6],a[u++]=n[63&p],l=0}u>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),u=0)}return l&&(a[u++]=n[o],a[u++]=61,1===l&&(a[u++]=61)),s?(u&&s.push(String.fromCharCode.apply(String,a.slice(0,u))),s.join("")):String.fromCharCode.apply(String,a.slice(0,u))};var s="invalid encoding";r.decode=function(t,e,r){for(var n,a=r,u=0,l=0;l<t.length;){var p=t.charCodeAt(l++);if(61===p&&u>1)break;if(void 0===(p=o[p]))throw Error(s);switch(u){case 0:n=p,u=1;break;case 1:e[r++]=n<<2|(48&p)>>4,n=p,u=2;break;case 2:e[r++]=(15&n)<<4|(60&p)>>2,n=p,u=3;break;case 3:e[r++]=(3&n)<<6|p,u=0}}if(1===u)throw Error(s);return r-a},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}),Qs=mt((t,e)=>{"use strict";function r(){this._listeners={}}e.exports=r,r.prototype.on=function(t,e,r){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:r||this}),this},r.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var r=this._listeners[t],n=0;n<r.length;)r[n].fn===e?r.splice(n,1):++n;return this},r.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<e.length;)e[n].fn.apply(e[n++].ctx,r)}return this}}),au=mt((t,e)=>{"use strict";function r(t){return"u">typeof Float32Array?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),n=128===r[3];function o(t,n,o){e[0]=t,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3]}function s(t,n,o){e[0]=t,n[o]=r[3],n[o+1]=r[2],n[o+2]=r[1],n[o+3]=r[0]}function a(t,n){return r[0]=t[n],r[1]=t[n+1],r[2]=t[n+2],r[3]=t[n+3],e[0]}function u(t,n){return r[3]=t[n],r[2]=t[n+1],r[1]=t[n+2],r[0]=t[n+3],e[0]}t.writeFloatLE=n?o:s,t.writeFloatBE=n?s:o,t.readFloatLE=n?a:u,t.readFloatBE=n?u:a}():function(){function e(t,e,r,n){var o=e<0?1:0;if(o&&(e=-e),0===e)t(1/e>0?0:2147483648,r,n);else if(isNaN(e))t(2143289344,r,n);else if(e>34028234663852886e22)t((o<<31|2139095040)>>>0,r,n);else if(e<11754943508222875e-54)t((o<<31|Math.round(e/1401298464324817e-60))>>>0,r,n);else{var s=Math.floor(Math.log(e)/Math.LN2),a=8388607&Math.round(e*Math.pow(2,-s)*8388608);t((o<<31|s+127<<23|a)>>>0,r,n)}}function r(t,e,r){var n=t(e,r),o=(n>>31)*2+1,s=n>>>23&255,a=8388607&n;return 255===s?a?NaN:1/0*o:0===s?1401298464324817e-60*o*a:o*Math.pow(2,s-150)*(a+8388608)}t.writeFloatLE=e.bind(null,n),t.writeFloatBE=e.bind(null,o),t.readFloatLE=r.bind(null,s),t.readFloatBE=r.bind(null,a)}(),"u">typeof Float64Array?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),n=128===r[7];function o(t,n,o){e[0]=t,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3],n[o+4]=r[4],n[o+5]=r[5],n[o+6]=r[6],n[o+7]=r[7]}function s(t,n,o){e[0]=t,n[o]=r[7],n[o+1]=r[6],n[o+2]=r[5],n[o+3]=r[4],n[o+4]=r[3],n[o+5]=r[2],n[o+6]=r[1],n[o+7]=r[0]}function a(t,n){return r[0]=t[n],r[1]=t[n+1],r[2]=t[n+2],r[3]=t[n+3],r[4]=t[n+4],r[5]=t[n+5],r[6]=t[n+6],r[7]=t[n+7],e[0]}function u(t,n){return r[7]=t[n],r[6]=t[n+1],r[5]=t[n+2],r[4]=t[n+3],r[3]=t[n+4],r[2]=t[n+5],r[1]=t[n+6],r[0]=t[n+7],e[0]}t.writeDoubleLE=n?o:s,t.writeDoubleBE=n?s:o,t.readDoubleLE=n?a:u,t.readDoubleBE=n?u:a}():function(){function e(t,e,r,n,o,s){var a,u=n<0?1:0;if(u&&(n=-n),0===n)t(0,o,s+e),t(1/n>0?0:2147483648,o,s+r);else if(isNaN(n))t(0,o,s+e),t(2146959360,o,s+r);else if(n>17976931348623157e292)t(0,o,s+e),t((u<<31|2146435072)>>>0,o,s+r);else if(n<22250738585072014e-324)t((a=n/5e-324)>>>0,o,s+e),t((u<<31|a/4294967296)>>>0,o,s+r);else{var l=Math.floor(Math.log(n)/Math.LN2);1024===l&&(l=1023),t(4503599627370496*(a=n*Math.pow(2,-l))>>>0,o,s+e),t((u<<31|l+1023<<20|1048576*a&1048575)>>>0,o,s+r)}}function r(t,e,r,n,o){var s=t(n,o+e),a=t(n,o+r),u=(a>>31)*2+1,l=a>>>20&2047,p=4294967296*(1048575&a)+s;return 2047===l?p?NaN:1/0*u:0===l?5e-324*u*p:u*Math.pow(2,l-1075)*(p+4503599627370496)}t.writeDoubleLE=e.bind(null,n,0,4),t.writeDoubleBE=e.bind(null,o,4,0),t.readDoubleLE=r.bind(null,s,0,4),t.readDoubleBE=r.bind(null,a,4,0)}(),t}function n(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function o(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function s(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function a(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}e.exports=r(r)}),su=mt((exports,module)=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(i){}return null}module.exports=inquire}),lu=mt(t=>{"use strict";var e=t;e.length=function(t){for(var e=0,r=0,n=0;n<t.length;++n)(r=t.charCodeAt(n))<128?e+=1:r<2048?e+=2:(64512&r)==55296&&(64512&t.charCodeAt(n+1))==56320?(++n,e+=4):e+=3;return e},e.read=function(t,e,r){if(r-e<1)return"";for(var n,o=null,s=[],a=0;e<r;)(n=t[e++])<128?s[a++]=n:n>191&&n<224?s[a++]=(31&n)<<6|63&t[e++]:n>239&&n<365?(n=((7&n)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,s[a++]=55296+(n>>10),s[a++]=56320+(1023&n)):s[a++]=(15&n)<<12|(63&t[e++])<<6|63&t[e++],a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0);return o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))},e.write=function(t,e,r){for(var n,o,s=r,a=0;a<t.length;++a)(n=t.charCodeAt(a))<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:((64512&n)==55296&&(64512&(o=t.charCodeAt(a+1)))==56320?(n=65536+((1023&n)<<10)+(1023&o),++a,e[r++]=n>>18|240,e[r++]=n>>12&63|128):e[r++]=n>>12|224,e[r++]=n>>6&63|128),e[r++]=63&n|128);return r-s}}),cu=mt((t,e)=>{"use strict";function r(t,e,r){var n=r||8192,o=n>>>1,s=null,a=n;return function(r){if(r<1||r>o)return t(r);a+r>n&&(s=t(n),a=0);var u=e.call(s,a,a+=r);return 7&a&&(a=(7|a)+1),u}}e.exports=r}),du=mt((t,e)=>{"use strict";e.exports=n;var r=Se();function n(t,e){this.lo=t>>>0,this.hi=e>>>0}var o=n.zero=new n(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(t){if(0===t)return o;var e=t<0;e&&(t=-t);var r=t>>>0,s=(t-r)/4294967296>>>0;return e&&(s=~s>>>0,r=~r>>>0,++r>4294967295&&(r=0,++s>4294967295&&(s=0))),new n(r,s)},n.from=function(t){if("number"==typeof t)return n.fromNumber(t);if(r.isString(t)){if(!r.Long)return n.fromNumber(parseInt(t,10));t=r.Long.fromString(t)}return t.low||t.high?new n(t.low>>>0,t.high>>>0):o},n.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,r=~this.hi>>>0;return e||(r=r+1>>>0),-(e+4294967296*r)}return this.lo+4294967296*this.hi},n.prototype.toLong=function(t){return r.Long?new r.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var a=String.prototype.charCodeAt;n.fromHash=function(t){return t===s?o:new n((a.call(t,0)|a.call(t,1)<<8|a.call(t,2)<<16|a.call(t,3)<<24)>>>0,(a.call(t,4)|a.call(t,5)<<8|a.call(t,6)<<16|a.call(t,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},n.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},n.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:r<128?9:10}}),Se=mt(t=>{"use strict";var e=t;function r(t,e,r){for(var n=Object.keys(e),o=0;o<n.length;++o)void 0!==t[n[o]]&&r||(t[n[o]]=e[n[o]]);return t}function n(t){function e(t,n){if(!(this instanceof e))return new e(t,n);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack||""}),n&&r(this,n)}return e.prototype=Object.create(Error.prototype,{constructor:{value:e,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),e}e.asPromise=js(),e.base64=Ys(),e.EventEmitter=Qs(),e.float=au(),e.inquire=su(),e.utf8=lu(),e.pool=cu(),e.LongBits=du(),e.isNode=!!("u">typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),e.global=e.isNode&&global||"u">typeof window&&window||"u">typeof self&&self||t,e.emptyArray=Object.freeze?Object.freeze([]):[],e.emptyObject=Object.freeze?Object.freeze({}):{},e.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},e.isString=function(t){return"string"==typeof t||t instanceof String},e.isObject=function(t){return t&&"object"==typeof t},e.isset=e.isSet=function(t,e){var r=t[e];return!!(null!=r&&t.hasOwnProperty(e))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},e.Buffer=function(){try{var t=e.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch{return null}}(),e._Buffer_from=null,e._Buffer_allocUnsafe=null,e.newBuffer=function(t){return"number"==typeof t?e.Buffer?e._Buffer_allocUnsafe(t):new e.Array(t):e.Buffer?e._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)},e.Array="u">typeof Uint8Array?Uint8Array:Array,e.Long=e.global.dcodeIO&&e.global.dcodeIO.Long||e.global.Long||e.inquire("long"),e.key2Re=/^true|false|0|1$/,e.key32Re=/^-?(?:0|[1-9][0-9]*)$/,e.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,e.longToHash=function(t){return t?e.LongBits.from(t).toHash():e.LongBits.zeroHash},e.longFromHash=function(t,r){var n=e.LongBits.fromHash(t);return e.Long?e.Long.fromBits(n.lo,n.hi,r):n.toNumber(!!r)},e.merge=r,e.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},e.newError=n,e.ProtocolError=n("ProtocolError"),e.oneOfGetter=function(t){for(var e={},r=0;r<t.length;++r)e[t[r]]=1;return function(){for(var t=Object.keys(this),r=t.length-1;r>-1;--r)if(1===e[t[r]]&&void 0!==this[t[r]]&&null!==this[t[r]])return t[r]}},e.oneOfSetter=function(t){return function(e){for(var r=0;r<t.length;++r)t[r]!==e&&delete this[t[r]]}},e.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},e._configure=function(){var t=e.Buffer;if(!t){e._Buffer_from=e._Buffer_allocUnsafe=null;return}e._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,r){return new t(e,r)},e._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}}}),ei=mt((t,e)=>{"use strict";e.exports=c;var r,n=Se(),o=n.LongBits,s=n.base64,a=n.utf8;function u(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function l(){}function p(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function c(){this.len=0,this.head=new u(l,0,0),this.tail=this.head,this.states=null}var d=function(){return n.Buffer?function(){return(c.create=function(){return new r})()}:function(){return new c}};function h(t,e,r){e[r]=255&t}function f(t,e,r){for(;t>127;)e[r++]=127&t|128,t>>>=7;e[r]=t}function g(t,e){this.len=t,this.next=void 0,this.val=e}function m(t,e,r){for(;t.hi;)e[r++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=127&t.lo|128,t.lo=t.lo>>>7;e[r++]=t.lo}function b(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}c.create=d(),c.alloc=function(t){return new n.Array(t)},n.Array!==Array&&(c.alloc=n.pool(c.alloc,n.Array.prototype.subarray)),c.prototype._push=function(t,e,r){return this.tail=this.tail.next=new u(t,e,r),this.len+=e,this},g.prototype=Object.create(u.prototype),g.prototype.fn=f,c.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new g((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},c.prototype.int32=function(t){return t<0?this._push(m,10,o.fromNumber(t)):this.uint32(t)},c.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},c.prototype.uint64=function(t){var e=o.from(t);return this._push(m,e.length(),e)},c.prototype.int64=c.prototype.uint64,c.prototype.sint64=function(t){var e=o.from(t).zzEncode();return this._push(m,e.length(),e)},c.prototype.bool=function(t){return this._push(h,1,t?1:0)},c.prototype.fixed32=function(t){return this._push(b,4,t>>>0)},c.prototype.sfixed32=c.prototype.fixed32,c.prototype.fixed64=function(t){var e=o.from(t);return this._push(b,4,e.lo)._push(b,4,e.hi)},c.prototype.sfixed64=c.prototype.fixed64,c.prototype.float=function(t){return this._push(n.float.writeFloatLE,4,t)},c.prototype.double=function(t){return this._push(n.float.writeDoubleLE,8,t)};var y=n.Array.prototype.set?function(t,e,r){e.set(t,r)}:function(t,e,r){for(var n=0;n<t.length;++n)e[r+n]=t[n]};c.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(h,1,0);if(n.isString(t)){var r=c.alloc(e=s.length(t));s.decode(t,r,0),t=r}return this.uint32(e)._push(y,e,t)},c.prototype.string=function(t){var e=a.length(t);return e?this.uint32(e)._push(a.write,e,t):this._push(h,1,0)},c.prototype.fork=function(){return this.states=new p(this),this.head=this.tail=new u(l,0,0),this.len=0,this},c.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new u(l,0,0),this.len=0),this},c.prototype.ldelim=function(){var t=this.head,e=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=t.next,this.tail=e,this.len+=r),this},c.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),r=0;t;)t.fn(t.val,e,r),r+=t.len,t=t.next;return e},c._configure=function(t){r=t,c.create=d(),r._configure()}}),vu=mt((t,e)=>{"use strict";e.exports=o;var r=ei();(o.prototype=Object.create(r.prototype)).constructor=o;var n=Se();function o(){r.call(this)}function s(t,e,r){t.length<40?n.utf8.write(t,e,r):e.utf8Write?e.utf8Write(t,r):e.write(t,r)}o._configure=function(){o.alloc=n._Buffer_allocUnsafe,o.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(t,e,r){e.set(t,r)}:function(t,e,r){if(t.copy)t.copy(e,r,0,t.length);else for(var n=0;n<t.length;)e[r++]=t[n++]}},o.prototype.bytes=function(t){n.isString(t)&&(t=n._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(o.writeBytesBuffer,e,t),this},o.prototype.string=function(t){var e=n.Buffer.byteLength(t);return this.uint32(e),e&&this._push(s,e,t),this},o._configure()}),oi=mt((t,e)=>{"use strict";e.exports=u;var r,n=Se(),o=n.LongBits,s=n.utf8;function a(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function u(t){this.buf=t,this.pos=0,this.len=t.length}var l="u">typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new u(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new u(t);throw Error("illegal buffer")},p=function(){return n.Buffer?function(t){return(u.create=function(t){return n.Buffer.isBuffer(t)?new r(t):l(t)})(t)}:l};function c(){var t=new o(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw a(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw a(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function d(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function h(){if(this.pos+8>this.len)throw a(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}u.create=p(),u.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,u.prototype.uint32=function(){var t=4294967295;return function(){if(t=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(t=(t|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return t}}(),u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var t=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},u.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var t=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},u.prototype.bytes=function(){var t=this.uint32(),e=this.pos,r=this.pos+t;if(r>this.len)throw a(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(e,r);if(e===r){var o=n.Buffer;return o?o.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,e,r)},u.prototype.string=function(){var t=this.bytes();return s.read(t,0,t.length)},u.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw a(this,t);this.pos+=t}else do if(this.pos>=this.len)throw a(this);while(128&this.buf[this.pos++]);return this},u.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},u._configure=function(t){r=t,u.create=p(),r._configure();var e=n.Long?"toLong":"toNumber";n.merge(u.prototype,{int64:function(){return c.call(this)[e](!1)},uint64:function(){return c.call(this)[e](!0)},sint64:function(){return c.call(this).zzDecode()[e](!1)},fixed64:function(){return h.call(this)[e](!0)},sfixed64:function(){return h.call(this)[e](!1)}})}}),Lu=mt((t,e)=>{"use strict";e.exports=o;var r=oi();(o.prototype=Object.create(r.prototype)).constructor=o;var n=Se();function o(t){r.call(this,t)}o._configure=function(){n.Buffer&&(o.prototype._slice=n.Buffer.prototype.slice)},o.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},o._configure()}),ku=mt((t,e)=>{"use strict";e.exports=n;var r=Se();function n(t,e,n){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!e,this.responseDelimited=!!n}(n.prototype=Object.create(r.EventEmitter.prototype)).constructor=n,n.prototype.rpcCall=function t(e,n,o,s,a){if(!s)throw TypeError("request must be specified");var u=this;if(!a)return r.asPromise(t,u,e,n,o,s);if(!u.rpcImpl){setTimeout(function(){a(Error("already ended"))},0);return}try{return u.rpcImpl(e,n[u.requestDelimited?"encodeDelimited":"encode"](s).finish(),function(t,r){if(t)return u.emit("error",t,e),a(t);if(null===r){u.end(!0);return}if(!(r instanceof o))try{r=o[u.responseDelimited?"decodeDelimited":"decode"](r)}catch(t){return u.emit("error",t,e),a(t)}return u.emit("data",r,e),a(null,r)})}catch(t){u.emit("error",t,e),setTimeout(function(){a(t)},0);return}},n.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),Fu=mt(t=>{"use strict";t.Service=ku()}),Nu=mt((t,e)=>{"use strict";e.exports={}}),Mu=mt(t=>{"use strict";var e=t;function r(){e.util._configure(),e.Writer._configure(e.BufferWriter),e.Reader._configure(e.BufferReader)}e.build="minimal",e.Writer=ei(),e.BufferWriter=vu(),e.Reader=oi(),e.BufferReader=Lu(),e.util=Se(),e.rpc=Fu(),e.roots=Nu(),e.configure=r,r()}),Vu=mt((t,e)=>{"use strict";e.exports=Mu()}),sr=mt((t,e)=>{"use strict";var r=Vu(),n=r.Reader,o=r.Writer,s=r.util,a=r.roots.default||(r.roots.default={});a.onnx=function(){var t={};return t.Version=function(){var t={},e=Object.create(t);return e[t[0]="_START_VERSION"]=0,e[t[1]="IR_VERSION_2017_10_10"]=1,e[t[2]="IR_VERSION_2017_10_30"]=2,e[t[3]="IR_VERSION_2017_11_3"]=3,e[t[4]="IR_VERSION_2019_1_22"]=4,e[t[5]="IR_VERSION_2019_3_18"]=5,e[t[6]="IR_VERSION_2019_9_19"]=6,e[t[7]="IR_VERSION_2020_5_8"]=7,e[t[8]="IR_VERSION_2021_7_30"]=8,e[t[9]="IR_VERSION"]=9,e}(),t.AttributeProto=function(){function t(t){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.refAttrName="",t.prototype.docString="",t.prototype.type=0,t.prototype.f=0,t.prototype.i=s.Long?s.Long.fromBits(0,0,!1):0,t.prototype.s=s.newBuffer([]),t.prototype.t=null,t.prototype.g=null,t.prototype.sparseTensor=null,t.prototype.tp=null,t.prototype.floats=s.emptyArray,t.prototype.ints=s.emptyArray,t.prototype.strings=s.emptyArray,t.prototype.tensors=s.emptyArray,t.prototype.graphs=s.emptyArray,t.prototype.sparseTensors=s.emptyArray,t.prototype.typeProtos=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(10).string(t.name),null!=t.f&&Object.hasOwnProperty.call(t,"f")&&e.uint32(21).float(t.f),null!=t.i&&Object.hasOwnProperty.call(t,"i")&&e.uint32(24).int64(t.i),null!=t.s&&Object.hasOwnProperty.call(t,"s")&&e.uint32(34).bytes(t.s),null!=t.t&&Object.hasOwnProperty.call(t,"t")&&a.onnx.TensorProto.encode(t.t,e.uint32(42).fork()).ldelim(),null!=t.g&&Object.hasOwnProperty.call(t,"g")&&a.onnx.GraphProto.encode(t.g,e.uint32(50).fork()).ldelim(),null!=t.floats&&t.floats.length){e.uint32(58).fork();for(var r=0;r<t.floats.length;++r)e.float(t.floats[r]);e.ldelim()}if(null!=t.ints&&t.ints.length){e.uint32(66).fork();for(var r=0;r<t.ints.length;++r)e.int64(t.ints[r]);e.ldelim()}if(null!=t.strings&&t.strings.length)for(var r=0;r<t.strings.length;++r)e.uint32(74).bytes(t.strings[r]);if(null!=t.tensors&&t.tensors.length)for(var r=0;r<t.tensors.length;++r)a.onnx.TensorProto.encode(t.tensors[r],e.uint32(82).fork()).ldelim();if(null!=t.graphs&&t.graphs.length)for(var r=0;r<t.graphs.length;++r)a.onnx.GraphProto.encode(t.graphs[r],e.uint32(90).fork()).ldelim();if(null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(106).string(t.docString),null!=t.tp&&Object.hasOwnProperty.call(t,"tp")&&a.onnx.TypeProto.encode(t.tp,e.uint32(114).fork()).ldelim(),null!=t.typeProtos&&t.typeProtos.length)for(var r=0;r<t.typeProtos.length;++r)a.onnx.TypeProto.encode(t.typeProtos[r],e.uint32(122).fork()).ldelim();if(null!=t.type&&Object.hasOwnProperty.call(t,"type")&&e.uint32(160).int32(t.type),null!=t.refAttrName&&Object.hasOwnProperty.call(t,"refAttrName")&&e.uint32(170).string(t.refAttrName),null!=t.sparseTensor&&Object.hasOwnProperty.call(t,"sparseTensor")&&a.onnx.SparseTensorProto.encode(t.sparseTensor,e.uint32(178).fork()).ldelim(),null!=t.sparseTensors&&t.sparseTensors.length)for(var r=0;r<t.sparseTensors.length;++r)a.onnx.SparseTensorProto.encode(t.sparseTensors[r],e.uint32(186).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.AttributeProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.name=t.string();break;case 21:o.refAttrName=t.string();break;case 13:o.docString=t.string();break;case 20:o.type=t.int32();break;case 2:o.f=t.float();break;case 3:o.i=t.int64();break;case 4:o.s=t.bytes();break;case 5:o.t=a.onnx.TensorProto.decode(t,t.uint32());break;case 6:o.g=a.onnx.GraphProto.decode(t,t.uint32());break;case 22:o.sparseTensor=a.onnx.SparseTensorProto.decode(t,t.uint32());break;case 14:o.tp=a.onnx.TypeProto.decode(t,t.uint32());break;case 7:if(o.floats&&o.floats.length||(o.floats=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.floats.push(t.float());else o.floats.push(t.float());break;case 8:if(o.ints&&o.ints.length||(o.ints=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.ints.push(t.int64());else o.ints.push(t.int64());break;case 9:o.strings&&o.strings.length||(o.strings=[]),o.strings.push(t.bytes());break;case 10:o.tensors&&o.tensors.length||(o.tensors=[]),o.tensors.push(a.onnx.TensorProto.decode(t,t.uint32()));break;case 11:o.graphs&&o.graphs.length||(o.graphs=[]),o.graphs.push(a.onnx.GraphProto.decode(t,t.uint32()));break;case 23:o.sparseTensors&&o.sparseTensors.length||(o.sparseTensors=[]),o.sparseTensors.push(a.onnx.SparseTensorProto.decode(t,t.uint32()));break;case 15:o.typeProtos&&o.typeProtos.length||(o.typeProtos=[]),o.typeProtos.push(a.onnx.TypeProto.decode(t,t.uint32()));break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.name&&t.hasOwnProperty("name")&&!s.isString(t.name))return"name: string expected";if(null!=t.refAttrName&&t.hasOwnProperty("refAttrName")&&!s.isString(t.refAttrName))return"refAttrName: string expected";if(null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString))return"docString: string expected";if(null!=t.type&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 11:case 13:case 6:case 7:case 8:case 9:case 10:case 12:case 14:}if(null!=t.f&&t.hasOwnProperty("f")&&"number"!=typeof t.f)return"f: number expected";if(null!=t.i&&t.hasOwnProperty("i")&&!s.isInteger(t.i)&&!(t.i&&s.isInteger(t.i.low)&&s.isInteger(t.i.high)))return"i: integer|Long expected";if(null!=t.s&&t.hasOwnProperty("s")&&!(t.s&&"number"==typeof t.s.length||s.isString(t.s)))return"s: buffer expected";if(null!=t.t&&t.hasOwnProperty("t")){var e=a.onnx.TensorProto.verify(t.t);if(e)return"t."+e}if(null!=t.g&&t.hasOwnProperty("g")){var e=a.onnx.GraphProto.verify(t.g);if(e)return"g."+e}if(null!=t.sparseTensor&&t.hasOwnProperty("sparseTensor")){var e=a.onnx.SparseTensorProto.verify(t.sparseTensor);if(e)return"sparseTensor."+e}if(null!=t.tp&&t.hasOwnProperty("tp")){var e=a.onnx.TypeProto.verify(t.tp);if(e)return"tp."+e}if(null!=t.floats&&t.hasOwnProperty("floats")){if(!Array.isArray(t.floats))return"floats: array expected";for(var r=0;r<t.floats.length;++r)if("number"!=typeof t.floats[r])return"floats: number[] expected"}if(null!=t.ints&&t.hasOwnProperty("ints")){if(!Array.isArray(t.ints))return"ints: array expected";for(var r=0;r<t.ints.length;++r)if(!s.isInteger(t.ints[r])&&!(t.ints[r]&&s.isInteger(t.ints[r].low)&&s.isInteger(t.ints[r].high)))return"ints: integer|Long[] expected"}if(null!=t.strings&&t.hasOwnProperty("strings")){if(!Array.isArray(t.strings))return"strings: array expected";for(var r=0;r<t.strings.length;++r)if(!(t.strings[r]&&"number"==typeof t.strings[r].length||s.isString(t.strings[r])))return"strings: buffer[] expected"}if(null!=t.tensors&&t.hasOwnProperty("tensors")){if(!Array.isArray(t.tensors))return"tensors: array expected";for(var r=0;r<t.tensors.length;++r){var e=a.onnx.TensorProto.verify(t.tensors[r]);if(e)return"tensors."+e}}if(null!=t.graphs&&t.hasOwnProperty("graphs")){if(!Array.isArray(t.graphs))return"graphs: array expected";for(var r=0;r<t.graphs.length;++r){var e=a.onnx.GraphProto.verify(t.graphs[r]);if(e)return"graphs."+e}}if(null!=t.sparseTensors&&t.hasOwnProperty("sparseTensors")){if(!Array.isArray(t.sparseTensors))return"sparseTensors: array expected";for(var r=0;r<t.sparseTensors.length;++r){var e=a.onnx.SparseTensorProto.verify(t.sparseTensors[r]);if(e)return"sparseTensors."+e}}if(null!=t.typeProtos&&t.hasOwnProperty("typeProtos")){if(!Array.isArray(t.typeProtos))return"typeProtos: array expected";for(var r=0;r<t.typeProtos.length;++r){var e=a.onnx.TypeProto.verify(t.typeProtos[r]);if(e)return"typeProtos."+e}}return null},t.fromObject=function(t){if(t instanceof a.onnx.AttributeProto)return t;var e=new a.onnx.AttributeProto;switch(null!=t.name&&(e.name=String(t.name)),null!=t.refAttrName&&(e.refAttrName=String(t.refAttrName)),null!=t.docString&&(e.docString=String(t.docString)),t.type){default:"number"==typeof t.type&&(e.type=t.type);break;case"UNDEFINED":case 0:e.type=0;break;case"FLOAT":case 1:e.type=1;break;case"INT":case 2:e.type=2;break;case"STRING":case 3:e.type=3;break;case"TENSOR":case 4:e.type=4;break;case"GRAPH":case 5:e.type=5;break;case"SPARSE_TENSOR":case 11:e.type=11;break;case"TYPE_PROTO":case 13:e.type=13;break;case"FLOATS":case 6:e.type=6;break;case"INTS":case 7:e.type=7;break;case"STRINGS":case 8:e.type=8;break;case"TENSORS":case 9:e.type=9;break;case"GRAPHS":case 10:e.type=10;break;case"SPARSE_TENSORS":case 12:e.type=12;break;case"TYPE_PROTOS":case 14:e.type=14}if(null!=t.f&&(e.f=Number(t.f)),null!=t.i&&(s.Long?(e.i=s.Long.fromValue(t.i)).unsigned=!1:"string"==typeof t.i?e.i=parseInt(t.i,10):"number"==typeof t.i?e.i=t.i:"object"==typeof t.i&&(e.i=new s.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber())),null!=t.s&&("string"==typeof t.s?s.base64.decode(t.s,e.s=s.newBuffer(s.base64.length(t.s)),0):t.s.length>=0&&(e.s=t.s)),null!=t.t){if("object"!=typeof t.t)throw TypeError(".onnx.AttributeProto.t: object expected");e.t=a.onnx.TensorProto.fromObject(t.t)}if(null!=t.g){if("object"!=typeof t.g)throw TypeError(".onnx.AttributeProto.g: object expected");e.g=a.onnx.GraphProto.fromObject(t.g)}if(null!=t.sparseTensor){if("object"!=typeof t.sparseTensor)throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");e.sparseTensor=a.onnx.SparseTensorProto.fromObject(t.sparseTensor)}if(null!=t.tp){if("object"!=typeof t.tp)throw TypeError(".onnx.AttributeProto.tp: object expected");e.tp=a.onnx.TypeProto.fromObject(t.tp)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");e.floats=[];for(var r=0;r<t.floats.length;++r)e.floats[r]=Number(t.floats[r])}if(t.ints){if(!Array.isArray(t.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");e.ints=[];for(var r=0;r<t.ints.length;++r)s.Long?(e.ints[r]=s.Long.fromValue(t.ints[r])).unsigned=!1:"string"==typeof t.ints[r]?e.ints[r]=parseInt(t.ints[r],10):"number"==typeof t.ints[r]?e.ints[r]=t.ints[r]:"object"==typeof t.ints[r]&&(e.ints[r]=new s.LongBits(t.ints[r].low>>>0,t.ints[r].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");e.strings=[];for(var r=0;r<t.strings.length;++r)"string"==typeof t.strings[r]?s.base64.decode(t.strings[r],e.strings[r]=s.newBuffer(s.base64.length(t.strings[r])),0):t.strings[r].length>=0&&(e.strings[r]=t.strings[r])}if(t.tensors){if(!Array.isArray(t.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");e.tensors=[];for(var r=0;r<t.tensors.length;++r){if("object"!=typeof t.tensors[r])throw TypeError(".onnx.AttributeProto.tensors: object expected");e.tensors[r]=a.onnx.TensorProto.fromObject(t.tensors[r])}}if(t.graphs){if(!Array.isArray(t.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");e.graphs=[];for(var r=0;r<t.graphs.length;++r){if("object"!=typeof t.graphs[r])throw TypeError(".onnx.AttributeProto.graphs: object expected");e.graphs[r]=a.onnx.GraphProto.fromObject(t.graphs[r])}}if(t.sparseTensors){if(!Array.isArray(t.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");e.sparseTensors=[];for(var r=0;r<t.sparseTensors.length;++r){if("object"!=typeof t.sparseTensors[r])throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");e.sparseTensors[r]=a.onnx.SparseTensorProto.fromObject(t.sparseTensors[r])}}if(t.typeProtos){if(!Array.isArray(t.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");e.typeProtos=[];for(var r=0;r<t.typeProtos.length;++r){if("object"!=typeof t.typeProtos[r])throw TypeError(".onnx.AttributeProto.typeProtos: object expected");e.typeProtos[r]=a.onnx.TypeProto.fromObject(t.typeProtos[r])}}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.floats=[],r.ints=[],r.strings=[],r.tensors=[],r.graphs=[],r.typeProtos=[],r.sparseTensors=[]),e.defaults){if(r.name="",r.f=0,s.Long){var n=new s.Long(0,0,!1);r.i=e.longs===String?n.toString():e.longs===Number?n.toNumber():n}else r.i=e.longs===String?"0":0;e.bytes===String?r.s="":(r.s=[],e.bytes!==Array&&(r.s=s.newBuffer(r.s))),r.t=null,r.g=null,r.docString="",r.tp=null,r.type=e.enums===String?"UNDEFINED":0,r.refAttrName="",r.sparseTensor=null}if(null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),null!=t.f&&t.hasOwnProperty("f")&&(r.f=e.json&&!isFinite(t.f)?String(t.f):t.f),null!=t.i&&t.hasOwnProperty("i")&&("number"==typeof t.i?r.i=e.longs===String?String(t.i):t.i:r.i=e.longs===String?s.Long.prototype.toString.call(t.i):e.longs===Number?new s.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber():t.i),null!=t.s&&t.hasOwnProperty("s")&&(r.s=e.bytes===String?s.base64.encode(t.s,0,t.s.length):e.bytes===Array?Array.prototype.slice.call(t.s):t.s),null!=t.t&&t.hasOwnProperty("t")&&(r.t=a.onnx.TensorProto.toObject(t.t,e)),null!=t.g&&t.hasOwnProperty("g")&&(r.g=a.onnx.GraphProto.toObject(t.g,e)),t.floats&&t.floats.length){r.floats=[];for(var o=0;o<t.floats.length;++o)r.floats[o]=e.json&&!isFinite(t.floats[o])?String(t.floats[o]):t.floats[o]}if(t.ints&&t.ints.length){r.ints=[];for(var o=0;o<t.ints.length;++o)"number"==typeof t.ints[o]?r.ints[o]=e.longs===String?String(t.ints[o]):t.ints[o]:r.ints[o]=e.longs===String?s.Long.prototype.toString.call(t.ints[o]):e.longs===Number?new s.LongBits(t.ints[o].low>>>0,t.ints[o].high>>>0).toNumber():t.ints[o]}if(t.strings&&t.strings.length){r.strings=[];for(var o=0;o<t.strings.length;++o)r.strings[o]=e.bytes===String?s.base64.encode(t.strings[o],0,t.strings[o].length):e.bytes===Array?Array.prototype.slice.call(t.strings[o]):t.strings[o]}if(t.tensors&&t.tensors.length){r.tensors=[];for(var o=0;o<t.tensors.length;++o)r.tensors[o]=a.onnx.TensorProto.toObject(t.tensors[o],e)}if(t.graphs&&t.graphs.length){r.graphs=[];for(var o=0;o<t.graphs.length;++o)r.graphs[o]=a.onnx.GraphProto.toObject(t.graphs[o],e)}if(null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),null!=t.tp&&t.hasOwnProperty("tp")&&(r.tp=a.onnx.TypeProto.toObject(t.tp,e)),t.typeProtos&&t.typeProtos.length){r.typeProtos=[];for(var o=0;o<t.typeProtos.length;++o)r.typeProtos[o]=a.onnx.TypeProto.toObject(t.typeProtos[o],e)}if(null!=t.type&&t.hasOwnProperty("type")&&(r.type=e.enums===String?void 0===a.onnx.AttributeProto.AttributeType[t.type]?t.type:a.onnx.AttributeProto.AttributeType[t.type]:t.type),null!=t.refAttrName&&t.hasOwnProperty("refAttrName")&&(r.refAttrName=t.refAttrName),null!=t.sparseTensor&&t.hasOwnProperty("sparseTensor")&&(r.sparseTensor=a.onnx.SparseTensorProto.toObject(t.sparseTensor,e)),t.sparseTensors&&t.sparseTensors.length){r.sparseTensors=[];for(var o=0;o<t.sparseTensors.length;++o)r.sparseTensors[o]=a.onnx.SparseTensorProto.toObject(t.sparseTensors[o],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.AttributeProto"},t.AttributeType=function(){var t={},e=Object.create(t);return e[t[0]="UNDEFINED"]=0,e[t[1]="FLOAT"]=1,e[t[2]="INT"]=2,e[t[3]="STRING"]=3,e[t[4]="TENSOR"]=4,e[t[5]="GRAPH"]=5,e[t[11]="SPARSE_TENSOR"]=11,e[t[13]="TYPE_PROTO"]=13,e[t[6]="FLOATS"]=6,e[t[7]="INTS"]=7,e[t[8]="STRINGS"]=8,e[t[9]="TENSORS"]=9,e[t[10]="GRAPHS"]=10,e[t[12]="SPARSE_TENSORS"]=12,e[t[14]="TYPE_PROTOS"]=14,e}(),t}(),t.ValueInfoProto=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.type=null,t.prototype.docString="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(10).string(t.name),null!=t.type&&Object.hasOwnProperty.call(t,"type")&&a.onnx.TypeProto.encode(t.type,e.uint32(18).fork()).ldelim(),null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(26).string(t.docString),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.ValueInfoProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.name=t.string();break;case 2:o.type=a.onnx.TypeProto.decode(t,t.uint32());break;case 3:o.docString=t.string();break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.name&&t.hasOwnProperty("name")&&!s.isString(t.name))return"name: string expected";if(null!=t.type&&t.hasOwnProperty("type")){var e=a.onnx.TypeProto.verify(t.type);if(e)return"type."+e}return null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString)?"docString: string expected":null},t.fromObject=function(t){if(t instanceof a.onnx.ValueInfoProto)return t;var e=new a.onnx.ValueInfoProto;if(null!=t.name&&(e.name=String(t.name)),null!=t.type){if("object"!=typeof t.type)throw TypeError(".onnx.ValueInfoProto.type: object expected");e.type=a.onnx.TypeProto.fromObject(t.type)}return null!=t.docString&&(e.docString=String(t.docString)),e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.name="",r.type=null,r.docString=""),null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),null!=t.type&&t.hasOwnProperty("type")&&(r.type=a.onnx.TypeProto.toObject(t.type,e)),null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.ValueInfoProto"},t}(),t.NodeProto=function(){function t(t){if(this.input=[],this.output=[],this.attribute=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.input=s.emptyArray,t.prototype.output=s.emptyArray,t.prototype.name="",t.prototype.opType="",t.prototype.domain="",t.prototype.attribute=s.emptyArray,t.prototype.docString="",t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.input&&t.input.length)for(var r=0;r<t.input.length;++r)e.uint32(10).string(t.input[r]);if(null!=t.output&&t.output.length)for(var r=0;r<t.output.length;++r)e.uint32(18).string(t.output[r]);if(null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(26).string(t.name),null!=t.opType&&Object.hasOwnProperty.call(t,"opType")&&e.uint32(34).string(t.opType),null!=t.attribute&&t.attribute.length)for(var r=0;r<t.attribute.length;++r)a.onnx.AttributeProto.encode(t.attribute[r],e.uint32(42).fork()).ldelim();return null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(50).string(t.docString),null!=t.domain&&Object.hasOwnProperty.call(t,"domain")&&e.uint32(58).string(t.domain),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.NodeProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.input&&o.input.length||(o.input=[]),o.input.push(t.string());break;case 2:o.output&&o.output.length||(o.output=[]),o.output.push(t.string());break;case 3:o.name=t.string();break;case 4:o.opType=t.string();break;case 7:o.domain=t.string();break;case 5:o.attribute&&o.attribute.length||(o.attribute=[]),o.attribute.push(a.onnx.AttributeProto.decode(t,t.uint32()));break;case 6:o.docString=t.string();break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.input&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var e=0;e<t.input.length;++e)if(!s.isString(t.input[e]))return"input: string[] expected"}if(null!=t.output&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var e=0;e<t.output.length;++e)if(!s.isString(t.output[e]))return"output: string[] expected"}if(null!=t.name&&t.hasOwnProperty("name")&&!s.isString(t.name))return"name: string expected";if(null!=t.opType&&t.hasOwnProperty("opType")&&!s.isString(t.opType))return"opType: string expected";if(null!=t.domain&&t.hasOwnProperty("domain")&&!s.isString(t.domain))return"domain: string expected";if(null!=t.attribute&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(var e=0;e<t.attribute.length;++e){var r=a.onnx.AttributeProto.verify(t.attribute[e]);if(r)return"attribute."+r}}return null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString)?"docString: string expected":null},t.fromObject=function(t){if(t instanceof a.onnx.NodeProto)return t;var e=new a.onnx.NodeProto;if(t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.NodeProto.input: array expected");e.input=[];for(var r=0;r<t.input.length;++r)e.input[r]=String(t.input[r])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.NodeProto.output: array expected");e.output=[];for(var r=0;r<t.output.length;++r)e.output[r]=String(t.output[r])}if(null!=t.name&&(e.name=String(t.name)),null!=t.opType&&(e.opType=String(t.opType)),null!=t.domain&&(e.domain=String(t.domain)),t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");e.attribute=[];for(var r=0;r<t.attribute.length;++r){if("object"!=typeof t.attribute[r])throw TypeError(".onnx.NodeProto.attribute: object expected");e.attribute[r]=a.onnx.AttributeProto.fromObject(t.attribute[r])}}return null!=t.docString&&(e.docString=String(t.docString)),e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.input=[],r.output=[],r.attribute=[]),e.defaults&&(r.name="",r.opType="",r.docString="",r.domain=""),t.input&&t.input.length){r.input=[];for(var n=0;n<t.input.length;++n)r.input[n]=t.input[n]}if(t.output&&t.output.length){r.output=[];for(var n=0;n<t.output.length;++n)r.output[n]=t.output[n]}if(null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),null!=t.opType&&t.hasOwnProperty("opType")&&(r.opType=t.opType),t.attribute&&t.attribute.length){r.attribute=[];for(var n=0;n<t.attribute.length;++n)r.attribute[n]=a.onnx.AttributeProto.toObject(t.attribute[n],e)}return null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),null!=t.domain&&t.hasOwnProperty("domain")&&(r.domain=t.domain),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.NodeProto"},t}(),t.TrainingInfoProto=function(){function t(t){if(this.initializationBinding=[],this.updateBinding=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.initialization=null,t.prototype.algorithm=null,t.prototype.initializationBinding=s.emptyArray,t.prototype.updateBinding=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.initialization&&Object.hasOwnProperty.call(t,"initialization")&&a.onnx.GraphProto.encode(t.initialization,e.uint32(10).fork()).ldelim(),null!=t.algorithm&&Object.hasOwnProperty.call(t,"algorithm")&&a.onnx.GraphProto.encode(t.algorithm,e.uint32(18).fork()).ldelim(),null!=t.initializationBinding&&t.initializationBinding.length)for(var r=0;r<t.initializationBinding.length;++r)a.onnx.StringStringEntryProto.encode(t.initializationBinding[r],e.uint32(26).fork()).ldelim();if(null!=t.updateBinding&&t.updateBinding.length)for(var r=0;r<t.updateBinding.length;++r)a.onnx.StringStringEntryProto.encode(t.updateBinding[r],e.uint32(34).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TrainingInfoProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.initialization=a.onnx.GraphProto.decode(t,t.uint32());break;case 2:o.algorithm=a.onnx.GraphProto.decode(t,t.uint32());break;case 3:o.initializationBinding&&o.initializationBinding.length||(o.initializationBinding=[]),o.initializationBinding.push(a.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 4:o.updateBinding&&o.updateBinding.length||(o.updateBinding=[]),o.updateBinding.push(a.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.initialization&&t.hasOwnProperty("initialization")){var e=a.onnx.GraphProto.verify(t.initialization);if(e)return"initialization."+e}if(null!=t.algorithm&&t.hasOwnProperty("algorithm")){var e=a.onnx.GraphProto.verify(t.algorithm);if(e)return"algorithm."+e}if(null!=t.initializationBinding&&t.hasOwnProperty("initializationBinding")){if(!Array.isArray(t.initializationBinding))return"initializationBinding: array expected";for(var r=0;r<t.initializationBinding.length;++r){var e=a.onnx.StringStringEntryProto.verify(t.initializationBinding[r]);if(e)return"initializationBinding."+e}}if(null!=t.updateBinding&&t.hasOwnProperty("updateBinding")){if(!Array.isArray(t.updateBinding))return"updateBinding: array expected";for(var r=0;r<t.updateBinding.length;++r){var e=a.onnx.StringStringEntryProto.verify(t.updateBinding[r]);if(e)return"updateBinding."+e}}return null},t.fromObject=function(t){if(t instanceof a.onnx.TrainingInfoProto)return t;var e=new a.onnx.TrainingInfoProto;if(null!=t.initialization){if("object"!=typeof t.initialization)throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");e.initialization=a.onnx.GraphProto.fromObject(t.initialization)}if(null!=t.algorithm){if("object"!=typeof t.algorithm)throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");e.algorithm=a.onnx.GraphProto.fromObject(t.algorithm)}if(t.initializationBinding){if(!Array.isArray(t.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");e.initializationBinding=[];for(var r=0;r<t.initializationBinding.length;++r){if("object"!=typeof t.initializationBinding[r])throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");e.initializationBinding[r]=a.onnx.StringStringEntryProto.fromObject(t.initializationBinding[r])}}if(t.updateBinding){if(!Array.isArray(t.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");e.updateBinding=[];for(var r=0;r<t.updateBinding.length;++r){if("object"!=typeof t.updateBinding[r])throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");e.updateBinding[r]=a.onnx.StringStringEntryProto.fromObject(t.updateBinding[r])}}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.initializationBinding=[],r.updateBinding=[]),e.defaults&&(r.initialization=null,r.algorithm=null),null!=t.initialization&&t.hasOwnProperty("initialization")&&(r.initialization=a.onnx.GraphProto.toObject(t.initialization,e)),null!=t.algorithm&&t.hasOwnProperty("algorithm")&&(r.algorithm=a.onnx.GraphProto.toObject(t.algorithm,e)),t.initializationBinding&&t.initializationBinding.length){r.initializationBinding=[];for(var n=0;n<t.initializationBinding.length;++n)r.initializationBinding[n]=a.onnx.StringStringEntryProto.toObject(t.initializationBinding[n],e)}if(t.updateBinding&&t.updateBinding.length){r.updateBinding=[];for(var n=0;n<t.updateBinding.length;++n)r.updateBinding[n]=a.onnx.StringStringEntryProto.toObject(t.updateBinding[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TrainingInfoProto"},t}(),t.ModelProto=function(){function t(t){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.irVersion=s.Long?s.Long.fromBits(0,0,!1):0,t.prototype.opsetImport=s.emptyArray,t.prototype.producerName="",t.prototype.producerVersion="",t.prototype.domain="",t.prototype.modelVersion=s.Long?s.Long.fromBits(0,0,!1):0,t.prototype.docString="",t.prototype.graph=null,t.prototype.metadataProps=s.emptyArray,t.prototype.trainingInfo=s.emptyArray,t.prototype.functions=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.irVersion&&Object.hasOwnProperty.call(t,"irVersion")&&e.uint32(8).int64(t.irVersion),null!=t.producerName&&Object.hasOwnProperty.call(t,"producerName")&&e.uint32(18).string(t.producerName),null!=t.producerVersion&&Object.hasOwnProperty.call(t,"producerVersion")&&e.uint32(26).string(t.producerVersion),null!=t.domain&&Object.hasOwnProperty.call(t,"domain")&&e.uint32(34).string(t.domain),null!=t.modelVersion&&Object.hasOwnProperty.call(t,"modelVersion")&&e.uint32(40).int64(t.modelVersion),null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(50).string(t.docString),null!=t.graph&&Object.hasOwnProperty.call(t,"graph")&&a.onnx.GraphProto.encode(t.graph,e.uint32(58).fork()).ldelim(),null!=t.opsetImport&&t.opsetImport.length)for(var r=0;r<t.opsetImport.length;++r)a.onnx.OperatorSetIdProto.encode(t.opsetImport[r],e.uint32(66).fork()).ldelim();if(null!=t.metadataProps&&t.metadataProps.length)for(var r=0;r<t.metadataProps.length;++r)a.onnx.StringStringEntryProto.encode(t.metadataProps[r],e.uint32(114).fork()).ldelim();if(null!=t.trainingInfo&&t.trainingInfo.length)for(var r=0;r<t.trainingInfo.length;++r)a.onnx.TrainingInfoProto.encode(t.trainingInfo[r],e.uint32(162).fork()).ldelim();if(null!=t.functions&&t.functions.length)for(var r=0;r<t.functions.length;++r)a.onnx.FunctionProto.encode(t.functions[r],e.uint32(202).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.ModelProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.irVersion=t.int64();break;case 8:o.opsetImport&&o.opsetImport.length||(o.opsetImport=[]),o.opsetImport.push(a.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 2:o.producerName=t.string();break;case 3:o.producerVersion=t.string();break;case 4:o.domain=t.string();break;case 5:o.modelVersion=t.int64();break;case 6:o.docString=t.string();break;case 7:o.graph=a.onnx.GraphProto.decode(t,t.uint32());break;case 14:o.metadataProps&&o.metadataProps.length||(o.metadataProps=[]),o.metadataProps.push(a.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 20:o.trainingInfo&&o.trainingInfo.length||(o.trainingInfo=[]),o.trainingInfo.push(a.onnx.TrainingInfoProto.decode(t,t.uint32()));break;case 25:o.functions&&o.functions.length||(o.functions=[]),o.functions.push(a.onnx.FunctionProto.decode(t,t.uint32()));break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.irVersion&&t.hasOwnProperty("irVersion")&&!s.isInteger(t.irVersion)&&!(t.irVersion&&s.isInteger(t.irVersion.low)&&s.isInteger(t.irVersion.high)))return"irVersion: integer|Long expected";if(null!=t.opsetImport&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var e=0;e<t.opsetImport.length;++e){var r=a.onnx.OperatorSetIdProto.verify(t.opsetImport[e]);if(r)return"opsetImport."+r}}if(null!=t.producerName&&t.hasOwnProperty("producerName")&&!s.isString(t.producerName))return"producerName: string expected";if(null!=t.producerVersion&&t.hasOwnProperty("producerVersion")&&!s.isString(t.producerVersion))return"producerVersion: string expected";if(null!=t.domain&&t.hasOwnProperty("domain")&&!s.isString(t.domain))return"domain: string expected";if(null!=t.modelVersion&&t.hasOwnProperty("modelVersion")&&!s.isInteger(t.modelVersion)&&!(t.modelVersion&&s.isInteger(t.modelVersion.low)&&s.isInteger(t.modelVersion.high)))return"modelVersion: integer|Long expected";if(null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString))return"docString: string expected";if(null!=t.graph&&t.hasOwnProperty("graph")){var r=a.onnx.GraphProto.verify(t.graph);if(r)return"graph."+r}if(null!=t.metadataProps&&t.hasOwnProperty("metadataProps")){if(!Array.isArray(t.metadataProps))return"metadataProps: array expected";for(var e=0;e<t.metadataProps.length;++e){var r=a.onnx.StringStringEntryProto.verify(t.metadataProps[e]);if(r)return"metadataProps."+r}}if(null!=t.trainingInfo&&t.hasOwnProperty("trainingInfo")){if(!Array.isArray(t.trainingInfo))return"trainingInfo: array expected";for(var e=0;e<t.trainingInfo.length;++e){var r=a.onnx.TrainingInfoProto.verify(t.trainingInfo[e]);if(r)return"trainingInfo."+r}}if(null!=t.functions&&t.hasOwnProperty("functions")){if(!Array.isArray(t.functions))return"functions: array expected";for(var e=0;e<t.functions.length;++e){var r=a.onnx.FunctionProto.verify(t.functions[e]);if(r)return"functions."+r}}return null},t.fromObject=function(t){if(t instanceof a.onnx.ModelProto)return t;var e=new a.onnx.ModelProto;if(null!=t.irVersion&&(s.Long?(e.irVersion=s.Long.fromValue(t.irVersion)).unsigned=!1:"string"==typeof t.irVersion?e.irVersion=parseInt(t.irVersion,10):"number"==typeof t.irVersion?e.irVersion=t.irVersion:"object"==typeof t.irVersion&&(e.irVersion=new s.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber())),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");e.opsetImport=[];for(var r=0;r<t.opsetImport.length;++r){if("object"!=typeof t.opsetImport[r])throw TypeError(".onnx.ModelProto.opsetImport: object expected");e.opsetImport[r]=a.onnx.OperatorSetIdProto.fromObject(t.opsetImport[r])}}if(null!=t.producerName&&(e.producerName=String(t.producerName)),null!=t.producerVersion&&(e.producerVersion=String(t.producerVersion)),null!=t.domain&&(e.domain=String(t.domain)),null!=t.modelVersion&&(s.Long?(e.modelVersion=s.Long.fromValue(t.modelVersion)).unsigned=!1:"string"==typeof t.modelVersion?e.modelVersion=parseInt(t.modelVersion,10):"number"==typeof t.modelVersion?e.modelVersion=t.modelVersion:"object"==typeof t.modelVersion&&(e.modelVersion=new s.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber())),null!=t.docString&&(e.docString=String(t.docString)),null!=t.graph){if("object"!=typeof t.graph)throw TypeError(".onnx.ModelProto.graph: object expected");e.graph=a.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");e.metadataProps=[];for(var r=0;r<t.metadataProps.length;++r){if("object"!=typeof t.metadataProps[r])throw TypeError(".onnx.ModelProto.metadataProps: object expected");e.metadataProps[r]=a.onnx.StringStringEntryProto.fromObject(t.metadataProps[r])}}if(t.trainingInfo){if(!Array.isArray(t.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");e.trainingInfo=[];for(var r=0;r<t.trainingInfo.length;++r){if("object"!=typeof t.trainingInfo[r])throw TypeError(".onnx.ModelProto.trainingInfo: object expected");e.trainingInfo[r]=a.onnx.TrainingInfoProto.fromObject(t.trainingInfo[r])}}if(t.functions){if(!Array.isArray(t.functions))throw TypeError(".onnx.ModelProto.functions: array expected");e.functions=[];for(var r=0;r<t.functions.length;++r){if("object"!=typeof t.functions[r])throw TypeError(".onnx.ModelProto.functions: object expected");e.functions[r]=a.onnx.FunctionProto.fromObject(t.functions[r])}}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.opsetImport=[],r.metadataProps=[],r.trainingInfo=[],r.functions=[]),e.defaults){if(s.Long){var n=new s.Long(0,0,!1);r.irVersion=e.longs===String?n.toString():e.longs===Number?n.toNumber():n}else r.irVersion=e.longs===String?"0":0;if(r.producerName="",r.producerVersion="",r.domain="",s.Long){var n=new s.Long(0,0,!1);r.modelVersion=e.longs===String?n.toString():e.longs===Number?n.toNumber():n}else r.modelVersion=e.longs===String?"0":0;r.docString="",r.graph=null}if(null!=t.irVersion&&t.hasOwnProperty("irVersion")&&("number"==typeof t.irVersion?r.irVersion=e.longs===String?String(t.irVersion):t.irVersion:r.irVersion=e.longs===String?s.Long.prototype.toString.call(t.irVersion):e.longs===Number?new s.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber():t.irVersion),null!=t.producerName&&t.hasOwnProperty("producerName")&&(r.producerName=t.producerName),null!=t.producerVersion&&t.hasOwnProperty("producerVersion")&&(r.producerVersion=t.producerVersion),null!=t.domain&&t.hasOwnProperty("domain")&&(r.domain=t.domain),null!=t.modelVersion&&t.hasOwnProperty("modelVersion")&&("number"==typeof t.modelVersion?r.modelVersion=e.longs===String?String(t.modelVersion):t.modelVersion:r.modelVersion=e.longs===String?s.Long.prototype.toString.call(t.modelVersion):e.longs===Number?new s.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),null!=t.graph&&t.hasOwnProperty("graph")&&(r.graph=a.onnx.GraphProto.toObject(t.graph,e)),t.opsetImport&&t.opsetImport.length){r.opsetImport=[];for(var o=0;o<t.opsetImport.length;++o)r.opsetImport[o]=a.onnx.OperatorSetIdProto.toObject(t.opsetImport[o],e)}if(t.metadataProps&&t.metadataProps.length){r.metadataProps=[];for(var o=0;o<t.metadataProps.length;++o)r.metadataProps[o]=a.onnx.StringStringEntryProto.toObject(t.metadataProps[o],e)}if(t.trainingInfo&&t.trainingInfo.length){r.trainingInfo=[];for(var o=0;o<t.trainingInfo.length;++o)r.trainingInfo[o]=a.onnx.TrainingInfoProto.toObject(t.trainingInfo[o],e)}if(t.functions&&t.functions.length){r.functions=[];for(var o=0;o<t.functions.length;++o)r.functions[o]=a.onnx.FunctionProto.toObject(t.functions[o],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.ModelProto"},t}(),t.StringStringEntryProto=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.key="",t.prototype.value="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.key&&Object.hasOwnProperty.call(t,"key")&&e.uint32(10).string(t.key),null!=t.value&&Object.hasOwnProperty.call(t,"value")&&e.uint32(18).string(t.value),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.StringStringEntryProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.key=t.string();break;case 2:o.value=t.string();break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.key&&t.hasOwnProperty("key")&&!s.isString(t.key)?"key: string expected":null!=t.value&&t.hasOwnProperty("value")&&!s.isString(t.value)?"value: string expected":null},t.fromObject=function(t){if(t instanceof a.onnx.StringStringEntryProto)return t;var e=new a.onnx.StringStringEntryProto;return null!=t.key&&(e.key=String(t.key)),null!=t.value&&(e.value=String(t.value)),e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.key="",r.value=""),null!=t.key&&t.hasOwnProperty("key")&&(r.key=t.key),null!=t.value&&t.hasOwnProperty("value")&&(r.value=t.value),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.StringStringEntryProto"},t}(),t.TensorAnnotation=function(){function t(t){if(this.quantParameterTensorNames=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.tensorName="",t.prototype.quantParameterTensorNames=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.tensorName&&Object.hasOwnProperty.call(t,"tensorName")&&e.uint32(10).string(t.tensorName),null!=t.quantParameterTensorNames&&t.quantParameterTensorNames.length)for(var r=0;r<t.quantParameterTensorNames.length;++r)a.onnx.StringStringEntryProto.encode(t.quantParameterTensorNames[r],e.uint32(18).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TensorAnnotation;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.tensorName=t.string();break;case 2:o.quantParameterTensorNames&&o.quantParameterTensorNames.length||(o.quantParameterTensorNames=[]),o.quantParameterTensorNames.push(a.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.tensorName&&t.hasOwnProperty("tensorName")&&!s.isString(t.tensorName))return"tensorName: string expected";if(null!=t.quantParameterTensorNames&&t.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(t.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var e=0;e<t.quantParameterTensorNames.length;++e){var r=a.onnx.StringStringEntryProto.verify(t.quantParameterTensorNames[e]);if(r)return"quantParameterTensorNames."+r}}return null},t.fromObject=function(t){if(t instanceof a.onnx.TensorAnnotation)return t;var e=new a.onnx.TensorAnnotation;if(null!=t.tensorName&&(e.tensorName=String(t.tensorName)),t.quantParameterTensorNames){if(!Array.isArray(t.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");e.quantParameterTensorNames=[];for(var r=0;r<t.quantParameterTensorNames.length;++r){if("object"!=typeof t.quantParameterTensorNames[r])throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");e.quantParameterTensorNames[r]=a.onnx.StringStringEntryProto.fromObject(t.quantParameterTensorNames[r])}}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.quantParameterTensorNames=[]),e.defaults&&(r.tensorName=""),null!=t.tensorName&&t.hasOwnProperty("tensorName")&&(r.tensorName=t.tensorName),t.quantParameterTensorNames&&t.quantParameterTensorNames.length){r.quantParameterTensorNames=[];for(var n=0;n<t.quantParameterTensorNames.length;++n)r.quantParameterTensorNames[n]=a.onnx.StringStringEntryProto.toObject(t.quantParameterTensorNames[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorAnnotation"},t}(),t.GraphProto=function(){function t(t){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.node=s.emptyArray,t.prototype.name="",t.prototype.initializer=s.emptyArray,t.prototype.sparseInitializer=s.emptyArray,t.prototype.docString="",t.prototype.input=s.emptyArray,t.prototype.output=s.emptyArray,t.prototype.valueInfo=s.emptyArray,t.prototype.quantizationAnnotation=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.node&&t.node.length)for(var r=0;r<t.node.length;++r)a.onnx.NodeProto.encode(t.node[r],e.uint32(10).fork()).ldelim();if(null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(18).string(t.name),null!=t.initializer&&t.initializer.length)for(var r=0;r<t.initializer.length;++r)a.onnx.TensorProto.encode(t.initializer[r],e.uint32(42).fork()).ldelim();if(null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(82).string(t.docString),null!=t.input&&t.input.length)for(var r=0;r<t.input.length;++r)a.onnx.ValueInfoProto.encode(t.input[r],e.uint32(90).fork()).ldelim();if(null!=t.output&&t.output.length)for(var r=0;r<t.output.length;++r)a.onnx.ValueInfoProto.encode(t.output[r],e.uint32(98).fork()).ldelim();if(null!=t.valueInfo&&t.valueInfo.length)for(var r=0;r<t.valueInfo.length;++r)a.onnx.ValueInfoProto.encode(t.valueInfo[r],e.uint32(106).fork()).ldelim();if(null!=t.quantizationAnnotation&&t.quantizationAnnotation.length)for(var r=0;r<t.quantizationAnnotation.length;++r)a.onnx.TensorAnnotation.encode(t.quantizationAnnotation[r],e.uint32(114).fork()).ldelim();if(null!=t.sparseInitializer&&t.sparseInitializer.length)for(var r=0;r<t.sparseInitializer.length;++r)a.onnx.SparseTensorProto.encode(t.sparseInitializer[r],e.uint32(122).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.GraphProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.node&&o.node.length||(o.node=[]),o.node.push(a.onnx.NodeProto.decode(t,t.uint32()));break;case 2:o.name=t.string();break;case 5:o.initializer&&o.initializer.length||(o.initializer=[]),o.initializer.push(a.onnx.TensorProto.decode(t,t.uint32()));break;case 15:o.sparseInitializer&&o.sparseInitializer.length||(o.sparseInitializer=[]),o.sparseInitializer.push(a.onnx.SparseTensorProto.decode(t,t.uint32()));break;case 10:o.docString=t.string();break;case 11:o.input&&o.input.length||(o.input=[]),o.input.push(a.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 12:o.output&&o.output.length||(o.output=[]),o.output.push(a.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 13:o.valueInfo&&o.valueInfo.length||(o.valueInfo=[]),o.valueInfo.push(a.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 14:o.quantizationAnnotation&&o.quantizationAnnotation.length||(o.quantizationAnnotation=[]),o.quantizationAnnotation.push(a.onnx.TensorAnnotation.decode(t,t.uint32()));break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.node&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var e=0;e<t.node.length;++e){var r=a.onnx.NodeProto.verify(t.node[e]);if(r)return"node."+r}}if(null!=t.name&&t.hasOwnProperty("name")&&!s.isString(t.name))return"name: string expected";if(null!=t.initializer&&t.hasOwnProperty("initializer")){if(!Array.isArray(t.initializer))return"initializer: array expected";for(var e=0;e<t.initializer.length;++e){var r=a.onnx.TensorProto.verify(t.initializer[e]);if(r)return"initializer."+r}}if(null!=t.sparseInitializer&&t.hasOwnProperty("sparseInitializer")){if(!Array.isArray(t.sparseInitializer))return"sparseInitializer: array expected";for(var e=0;e<t.sparseInitializer.length;++e){var r=a.onnx.SparseTensorProto.verify(t.sparseInitializer[e]);if(r)return"sparseInitializer."+r}}if(null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString))return"docString: string expected";if(null!=t.input&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var e=0;e<t.input.length;++e){var r=a.onnx.ValueInfoProto.verify(t.input[e]);if(r)return"input."+r}}if(null!=t.output&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var e=0;e<t.output.length;++e){var r=a.onnx.ValueInfoProto.verify(t.output[e]);if(r)return"output."+r}}if(null!=t.valueInfo&&t.hasOwnProperty("valueInfo")){if(!Array.isArray(t.valueInfo))return"valueInfo: array expected";for(var e=0;e<t.valueInfo.length;++e){var r=a.onnx.ValueInfoProto.verify(t.valueInfo[e]);if(r)return"valueInfo."+r}}if(null!=t.quantizationAnnotation&&t.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(t.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var e=0;e<t.quantizationAnnotation.length;++e){var r=a.onnx.TensorAnnotation.verify(t.quantizationAnnotation[e]);if(r)return"quantizationAnnotation."+r}}return null},t.fromObject=function(t){if(t instanceof a.onnx.GraphProto)return t;var e=new a.onnx.GraphProto;if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.GraphProto.node: array expected");e.node=[];for(var r=0;r<t.node.length;++r){if("object"!=typeof t.node[r])throw TypeError(".onnx.GraphProto.node: object expected");e.node[r]=a.onnx.NodeProto.fromObject(t.node[r])}}if(null!=t.name&&(e.name=String(t.name)),t.initializer){if(!Array.isArray(t.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");e.initializer=[];for(var r=0;r<t.initializer.length;++r){if("object"!=typeof t.initializer[r])throw TypeError(".onnx.GraphProto.initializer: object expected");e.initializer[r]=a.onnx.TensorProto.fromObject(t.initializer[r])}}if(t.sparseInitializer){if(!Array.isArray(t.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");e.sparseInitializer=[];for(var r=0;r<t.sparseInitializer.length;++r){if("object"!=typeof t.sparseInitializer[r])throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");e.sparseInitializer[r]=a.onnx.SparseTensorProto.fromObject(t.sparseInitializer[r])}}if(null!=t.docString&&(e.docString=String(t.docString)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.GraphProto.input: array expected");e.input=[];for(var r=0;r<t.input.length;++r){if("object"!=typeof t.input[r])throw TypeError(".onnx.GraphProto.input: object expected");e.input[r]=a.onnx.ValueInfoProto.fromObject(t.input[r])}}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.GraphProto.output: array expected");e.output=[];for(var r=0;r<t.output.length;++r){if("object"!=typeof t.output[r])throw TypeError(".onnx.GraphProto.output: object expected");e.output[r]=a.onnx.ValueInfoProto.fromObject(t.output[r])}}if(t.valueInfo){if(!Array.isArray(t.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");e.valueInfo=[];for(var r=0;r<t.valueInfo.length;++r){if("object"!=typeof t.valueInfo[r])throw TypeError(".onnx.GraphProto.valueInfo: object expected");e.valueInfo[r]=a.onnx.ValueInfoProto.fromObject(t.valueInfo[r])}}if(t.quantizationAnnotation){if(!Array.isArray(t.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");e.quantizationAnnotation=[];for(var r=0;r<t.quantizationAnnotation.length;++r){if("object"!=typeof t.quantizationAnnotation[r])throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");e.quantizationAnnotation[r]=a.onnx.TensorAnnotation.fromObject(t.quantizationAnnotation[r])}}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.node=[],r.initializer=[],r.input=[],r.output=[],r.valueInfo=[],r.quantizationAnnotation=[],r.sparseInitializer=[]),e.defaults&&(r.name="",r.docString=""),t.node&&t.node.length){r.node=[];for(var n=0;n<t.node.length;++n)r.node[n]=a.onnx.NodeProto.toObject(t.node[n],e)}if(null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),t.initializer&&t.initializer.length){r.initializer=[];for(var n=0;n<t.initializer.length;++n)r.initializer[n]=a.onnx.TensorProto.toObject(t.initializer[n],e)}if(null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),t.input&&t.input.length){r.input=[];for(var n=0;n<t.input.length;++n)r.input[n]=a.onnx.ValueInfoProto.toObject(t.input[n],e)}if(t.output&&t.output.length){r.output=[];for(var n=0;n<t.output.length;++n)r.output[n]=a.onnx.ValueInfoProto.toObject(t.output[n],e)}if(t.valueInfo&&t.valueInfo.length){r.valueInfo=[];for(var n=0;n<t.valueInfo.length;++n)r.valueInfo[n]=a.onnx.ValueInfoProto.toObject(t.valueInfo[n],e)}if(t.quantizationAnnotation&&t.quantizationAnnotation.length){r.quantizationAnnotation=[];for(var n=0;n<t.quantizationAnnotation.length;++n)r.quantizationAnnotation[n]=a.onnx.TensorAnnotation.toObject(t.quantizationAnnotation[n],e)}if(t.sparseInitializer&&t.sparseInitializer.length){r.sparseInitializer=[];for(var n=0;n<t.sparseInitializer.length;++n)r.sparseInitializer[n]=a.onnx.SparseTensorProto.toObject(t.sparseInitializer[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.GraphProto"},t}(),t.TensorProto=function(){function t(t){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.dims=s.emptyArray,t.prototype.dataType=0,t.prototype.segment=null,t.prototype.floatData=s.emptyArray,t.prototype.int32Data=s.emptyArray,t.prototype.stringData=s.emptyArray,t.prototype.int64Data=s.emptyArray,t.prototype.name="",t.prototype.docString="",t.prototype.rawData=s.newBuffer([]),t.prototype.externalData=s.emptyArray,t.prototype.dataLocation=0,t.prototype.doubleData=s.emptyArray,t.prototype.uint64Data=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.dims&&t.dims.length){e.uint32(10).fork();for(var r=0;r<t.dims.length;++r)e.int64(t.dims[r]);e.ldelim()}if(null!=t.dataType&&Object.hasOwnProperty.call(t,"dataType")&&e.uint32(16).int32(t.dataType),null!=t.segment&&Object.hasOwnProperty.call(t,"segment")&&a.onnx.TensorProto.Segment.encode(t.segment,e.uint32(26).fork()).ldelim(),null!=t.floatData&&t.floatData.length){e.uint32(34).fork();for(var r=0;r<t.floatData.length;++r)e.float(t.floatData[r]);e.ldelim()}if(null!=t.int32Data&&t.int32Data.length){e.uint32(42).fork();for(var r=0;r<t.int32Data.length;++r)e.int32(t.int32Data[r]);e.ldelim()}if(null!=t.stringData&&t.stringData.length)for(var r=0;r<t.stringData.length;++r)e.uint32(50).bytes(t.stringData[r]);if(null!=t.int64Data&&t.int64Data.length){e.uint32(58).fork();for(var r=0;r<t.int64Data.length;++r)e.int64(t.int64Data[r]);e.ldelim()}if(null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(66).string(t.name),null!=t.rawData&&Object.hasOwnProperty.call(t,"rawData")&&e.uint32(74).bytes(t.rawData),null!=t.doubleData&&t.doubleData.length){e.uint32(82).fork();for(var r=0;r<t.doubleData.length;++r)e.double(t.doubleData[r]);e.ldelim()}if(null!=t.uint64Data&&t.uint64Data.length){e.uint32(90).fork();for(var r=0;r<t.uint64Data.length;++r)e.uint64(t.uint64Data[r]);e.ldelim()}if(null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(98).string(t.docString),null!=t.externalData&&t.externalData.length)for(var r=0;r<t.externalData.length;++r)a.onnx.StringStringEntryProto.encode(t.externalData[r],e.uint32(106).fork()).ldelim();return null!=t.dataLocation&&Object.hasOwnProperty.call(t,"dataLocation")&&e.uint32(112).int32(t.dataLocation),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TensorProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:if(o.dims&&o.dims.length||(o.dims=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.dims.push(t.int64());else o.dims.push(t.int64());break;case 2:o.dataType=t.int32();break;case 3:o.segment=a.onnx.TensorProto.Segment.decode(t,t.uint32());break;case 4:if(o.floatData&&o.floatData.length||(o.floatData=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.floatData.push(t.float());else o.floatData.push(t.float());break;case 5:if(o.int32Data&&o.int32Data.length||(o.int32Data=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.int32Data.push(t.int32());else o.int32Data.push(t.int32());break;case 6:o.stringData&&o.stringData.length||(o.stringData=[]),o.stringData.push(t.bytes());break;case 7:if(o.int64Data&&o.int64Data.length||(o.int64Data=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.int64Data.push(t.int64());else o.int64Data.push(t.int64());break;case 8:o.name=t.string();break;case 12:o.docString=t.string();break;case 9:o.rawData=t.bytes();break;case 13:o.externalData&&o.externalData.length||(o.externalData=[]),o.externalData.push(a.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 14:o.dataLocation=t.int32();break;case 10:if(o.doubleData&&o.doubleData.length||(o.doubleData=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.doubleData.push(t.double());else o.doubleData.push(t.double());break;case 11:if(o.uint64Data&&o.uint64Data.length||(o.uint64Data=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.uint64Data.push(t.uint64());else o.uint64Data.push(t.uint64());break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.dims&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var e=0;e<t.dims.length;++e)if(!s.isInteger(t.dims[e])&&!(t.dims[e]&&s.isInteger(t.dims[e].low)&&s.isInteger(t.dims[e].high)))return"dims: integer|Long[] expected"}if(null!=t.dataType&&t.hasOwnProperty("dataType")&&!s.isInteger(t.dataType))return"dataType: integer expected";if(null!=t.segment&&t.hasOwnProperty("segment")){var r=a.onnx.TensorProto.Segment.verify(t.segment);if(r)return"segment."+r}if(null!=t.floatData&&t.hasOwnProperty("floatData")){if(!Array.isArray(t.floatData))return"floatData: array expected";for(var e=0;e<t.floatData.length;++e)if("number"!=typeof t.floatData[e])return"floatData: number[] expected"}if(null!=t.int32Data&&t.hasOwnProperty("int32Data")){if(!Array.isArray(t.int32Data))return"int32Data: array expected";for(var e=0;e<t.int32Data.length;++e)if(!s.isInteger(t.int32Data[e]))return"int32Data: integer[] expected"}if(null!=t.stringData&&t.hasOwnProperty("stringData")){if(!Array.isArray(t.stringData))return"stringData: array expected";for(var e=0;e<t.stringData.length;++e)if(!(t.stringData[e]&&"number"==typeof t.stringData[e].length||s.isString(t.stringData[e])))return"stringData: buffer[] expected"}if(null!=t.int64Data&&t.hasOwnProperty("int64Data")){if(!Array.isArray(t.int64Data))return"int64Data: array expected";for(var e=0;e<t.int64Data.length;++e)if(!s.isInteger(t.int64Data[e])&&!(t.int64Data[e]&&s.isInteger(t.int64Data[e].low)&&s.isInteger(t.int64Data[e].high)))return"int64Data: integer|Long[] expected"}if(null!=t.name&&t.hasOwnProperty("name")&&!s.isString(t.name))return"name: string expected";if(null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString))return"docString: string expected";if(null!=t.rawData&&t.hasOwnProperty("rawData")&&!(t.rawData&&"number"==typeof t.rawData.length||s.isString(t.rawData)))return"rawData: buffer expected";if(null!=t.externalData&&t.hasOwnProperty("externalData")){if(!Array.isArray(t.externalData))return"externalData: array expected";for(var e=0;e<t.externalData.length;++e){var r=a.onnx.StringStringEntryProto.verify(t.externalData[e]);if(r)return"externalData."+r}}if(null!=t.dataLocation&&t.hasOwnProperty("dataLocation"))switch(t.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:}if(null!=t.doubleData&&t.hasOwnProperty("doubleData")){if(!Array.isArray(t.doubleData))return"doubleData: array expected";for(var e=0;e<t.doubleData.length;++e)if("number"!=typeof t.doubleData[e])return"doubleData: number[] expected"}if(null!=t.uint64Data&&t.hasOwnProperty("uint64Data")){if(!Array.isArray(t.uint64Data))return"uint64Data: array expected";for(var e=0;e<t.uint64Data.length;++e)if(!s.isInteger(t.uint64Data[e])&&!(t.uint64Data[e]&&s.isInteger(t.uint64Data[e].low)&&s.isInteger(t.uint64Data[e].high)))return"uint64Data: integer|Long[] expected"}return null},t.fromObject=function(t){if(t instanceof a.onnx.TensorProto)return t;var e=new a.onnx.TensorProto;if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.TensorProto.dims: array expected");e.dims=[];for(var r=0;r<t.dims.length;++r)s.Long?(e.dims[r]=s.Long.fromValue(t.dims[r])).unsigned=!1:"string"==typeof t.dims[r]?e.dims[r]=parseInt(t.dims[r],10):"number"==typeof t.dims[r]?e.dims[r]=t.dims[r]:"object"==typeof t.dims[r]&&(e.dims[r]=new s.LongBits(t.dims[r].low>>>0,t.dims[r].high>>>0).toNumber())}if(null!=t.dataType&&(e.dataType=0|t.dataType),null!=t.segment){if("object"!=typeof t.segment)throw TypeError(".onnx.TensorProto.segment: object expected");e.segment=a.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");e.floatData=[];for(var r=0;r<t.floatData.length;++r)e.floatData[r]=Number(t.floatData[r])}if(t.int32Data){if(!Array.isArray(t.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");e.int32Data=[];for(var r=0;r<t.int32Data.length;++r)e.int32Data[r]=0|t.int32Data[r]}if(t.stringData){if(!Array.isArray(t.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");e.stringData=[];for(var r=0;r<t.stringData.length;++r)"string"==typeof t.stringData[r]?s.base64.decode(t.stringData[r],e.stringData[r]=s.newBuffer(s.base64.length(t.stringData[r])),0):t.stringData[r].length>=0&&(e.stringData[r]=t.stringData[r])}if(t.int64Data){if(!Array.isArray(t.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");e.int64Data=[];for(var r=0;r<t.int64Data.length;++r)s.Long?(e.int64Data[r]=s.Long.fromValue(t.int64Data[r])).unsigned=!1:"string"==typeof t.int64Data[r]?e.int64Data[r]=parseInt(t.int64Data[r],10):"number"==typeof t.int64Data[r]?e.int64Data[r]=t.int64Data[r]:"object"==typeof t.int64Data[r]&&(e.int64Data[r]=new s.LongBits(t.int64Data[r].low>>>0,t.int64Data[r].high>>>0).toNumber())}if(null!=t.name&&(e.name=String(t.name)),null!=t.docString&&(e.docString=String(t.docString)),null!=t.rawData&&("string"==typeof t.rawData?s.base64.decode(t.rawData,e.rawData=s.newBuffer(s.base64.length(t.rawData)),0):t.rawData.length>=0&&(e.rawData=t.rawData)),t.externalData){if(!Array.isArray(t.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");e.externalData=[];for(var r=0;r<t.externalData.length;++r){if("object"!=typeof t.externalData[r])throw TypeError(".onnx.TensorProto.externalData: object expected");e.externalData[r]=a.onnx.StringStringEntryProto.fromObject(t.externalData[r])}}switch(t.dataLocation){default:"number"==typeof t.dataLocation&&(e.dataLocation=t.dataLocation);break;case"DEFAULT":case 0:e.dataLocation=0;break;case"EXTERNAL":case 1:e.dataLocation=1}if(t.doubleData){if(!Array.isArray(t.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");e.doubleData=[];for(var r=0;r<t.doubleData.length;++r)e.doubleData[r]=Number(t.doubleData[r])}if(t.uint64Data){if(!Array.isArray(t.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");e.uint64Data=[];for(var r=0;r<t.uint64Data.length;++r)s.Long?(e.uint64Data[r]=s.Long.fromValue(t.uint64Data[r])).unsigned=!0:"string"==typeof t.uint64Data[r]?e.uint64Data[r]=parseInt(t.uint64Data[r],10):"number"==typeof t.uint64Data[r]?e.uint64Data[r]=t.uint64Data[r]:"object"==typeof t.uint64Data[r]&&(e.uint64Data[r]=new s.LongBits(t.uint64Data[r].low>>>0,t.uint64Data[r].high>>>0).toNumber(!0))}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.dims=[],r.floatData=[],r.int32Data=[],r.stringData=[],r.int64Data=[],r.doubleData=[],r.uint64Data=[],r.externalData=[]),e.defaults&&(r.dataType=0,r.segment=null,r.name="",e.bytes===String?r.rawData="":(r.rawData=[],e.bytes!==Array&&(r.rawData=s.newBuffer(r.rawData))),r.docString="",r.dataLocation=e.enums===String?"DEFAULT":0),t.dims&&t.dims.length){r.dims=[];for(var n=0;n<t.dims.length;++n)"number"==typeof t.dims[n]?r.dims[n]=e.longs===String?String(t.dims[n]):t.dims[n]:r.dims[n]=e.longs===String?s.Long.prototype.toString.call(t.dims[n]):e.longs===Number?new s.LongBits(t.dims[n].low>>>0,t.dims[n].high>>>0).toNumber():t.dims[n]}if(null!=t.dataType&&t.hasOwnProperty("dataType")&&(r.dataType=t.dataType),null!=t.segment&&t.hasOwnProperty("segment")&&(r.segment=a.onnx.TensorProto.Segment.toObject(t.segment,e)),t.floatData&&t.floatData.length){r.floatData=[];for(var n=0;n<t.floatData.length;++n)r.floatData[n]=e.json&&!isFinite(t.floatData[n])?String(t.floatData[n]):t.floatData[n]}if(t.int32Data&&t.int32Data.length){r.int32Data=[];for(var n=0;n<t.int32Data.length;++n)r.int32Data[n]=t.int32Data[n]}if(t.stringData&&t.stringData.length){r.stringData=[];for(var n=0;n<t.stringData.length;++n)r.stringData[n]=e.bytes===String?s.base64.encode(t.stringData[n],0,t.stringData[n].length):e.bytes===Array?Array.prototype.slice.call(t.stringData[n]):t.stringData[n]}if(t.int64Data&&t.int64Data.length){r.int64Data=[];for(var n=0;n<t.int64Data.length;++n)"number"==typeof t.int64Data[n]?r.int64Data[n]=e.longs===String?String(t.int64Data[n]):t.int64Data[n]:r.int64Data[n]=e.longs===String?s.Long.prototype.toString.call(t.int64Data[n]):e.longs===Number?new s.LongBits(t.int64Data[n].low>>>0,t.int64Data[n].high>>>0).toNumber():t.int64Data[n]}if(null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),null!=t.rawData&&t.hasOwnProperty("rawData")&&(r.rawData=e.bytes===String?s.base64.encode(t.rawData,0,t.rawData.length):e.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length){r.doubleData=[];for(var n=0;n<t.doubleData.length;++n)r.doubleData[n]=e.json&&!isFinite(t.doubleData[n])?String(t.doubleData[n]):t.doubleData[n]}if(t.uint64Data&&t.uint64Data.length){r.uint64Data=[];for(var n=0;n<t.uint64Data.length;++n)"number"==typeof t.uint64Data[n]?r.uint64Data[n]=e.longs===String?String(t.uint64Data[n]):t.uint64Data[n]:r.uint64Data[n]=e.longs===String?s.Long.prototype.toString.call(t.uint64Data[n]):e.longs===Number?new s.LongBits(t.uint64Data[n].low>>>0,t.uint64Data[n].high>>>0).toNumber(!0):t.uint64Data[n]}if(null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),t.externalData&&t.externalData.length){r.externalData=[];for(var n=0;n<t.externalData.length;++n)r.externalData[n]=a.onnx.StringStringEntryProto.toObject(t.externalData[n],e)}return null!=t.dataLocation&&t.hasOwnProperty("dataLocation")&&(r.dataLocation=e.enums===String?void 0===a.onnx.TensorProto.DataLocation[t.dataLocation]?t.dataLocation:a.onnx.TensorProto.DataLocation[t.dataLocation]:t.dataLocation),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorProto"},t.DataType=function(){var t={},e=Object.create(t);return e[t[0]="UNDEFINED"]=0,e[t[1]="FLOAT"]=1,e[t[2]="UINT8"]=2,e[t[3]="INT8"]=3,e[t[4]="UINT16"]=4,e[t[5]="INT16"]=5,e[t[6]="INT32"]=6,e[t[7]="INT64"]=7,e[t[8]="STRING"]=8,e[t[9]="BOOL"]=9,e[t[10]="FLOAT16"]=10,e[t[11]="DOUBLE"]=11,e[t[12]="UINT32"]=12,e[t[13]="UINT64"]=13,e[t[14]="COMPLEX64"]=14,e[t[15]="COMPLEX128"]=15,e[t[16]="BFLOAT16"]=16,e[t[17]="FLOAT8E4M3FN"]=17,e[t[18]="FLOAT8E4M3FNUZ"]=18,e[t[19]="FLOAT8E5M2"]=19,e[t[20]="FLOAT8E5M2FNUZ"]=20,e}(),t.Segment=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.begin=s.Long?s.Long.fromBits(0,0,!1):0,t.prototype.end=s.Long?s.Long.fromBits(0,0,!1):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.begin&&Object.hasOwnProperty.call(t,"begin")&&e.uint32(8).int64(t.begin),null!=t.end&&Object.hasOwnProperty.call(t,"end")&&e.uint32(16).int64(t.end),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TensorProto.Segment;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.begin=t.int64();break;case 2:o.end=t.int64();break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.begin&&t.hasOwnProperty("begin")&&!s.isInteger(t.begin)&&!(t.begin&&s.isInteger(t.begin.low)&&s.isInteger(t.begin.high))?"begin: integer|Long expected":null!=t.end&&t.hasOwnProperty("end")&&!s.isInteger(t.end)&&!(t.end&&s.isInteger(t.end.low)&&s.isInteger(t.end.high))?"end: integer|Long expected":null},t.fromObject=function(t){if(t instanceof a.onnx.TensorProto.Segment)return t;var e=new a.onnx.TensorProto.Segment;return null!=t.begin&&(s.Long?(e.begin=s.Long.fromValue(t.begin)).unsigned=!1:"string"==typeof t.begin?e.begin=parseInt(t.begin,10):"number"==typeof t.begin?e.begin=t.begin:"object"==typeof t.begin&&(e.begin=new s.LongBits(t.begin.low>>>0,t.begin.high>>>0).toNumber())),null!=t.end&&(s.Long?(e.end=s.Long.fromValue(t.end)).unsigned=!1:"string"==typeof t.end?e.end=parseInt(t.end,10):"number"==typeof t.end?e.end=t.end:"object"==typeof t.end&&(e.end=new s.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var r={};if(e.defaults){if(s.Long){var n=new s.Long(0,0,!1);r.begin=e.longs===String?n.toString():e.longs===Number?n.toNumber():n}else r.begin=e.longs===String?"0":0;if(s.Long){var n=new s.Long(0,0,!1);r.end=e.longs===String?n.toString():e.longs===Number?n.toNumber():n}else r.end=e.longs===String?"0":0}return null!=t.begin&&t.hasOwnProperty("begin")&&("number"==typeof t.begin?r.begin=e.longs===String?String(t.begin):t.begin:r.begin=e.longs===String?s.Long.prototype.toString.call(t.begin):e.longs===Number?new s.LongBits(t.begin.low>>>0,t.begin.high>>>0).toNumber():t.begin),null!=t.end&&t.hasOwnProperty("end")&&("number"==typeof t.end?r.end=e.longs===String?String(t.end):t.end:r.end=e.longs===String?s.Long.prototype.toString.call(t.end):e.longs===Number?new s.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber():t.end),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorProto.Segment"},t}(),t.DataLocation=function(){var t={},e=Object.create(t);return e[t[0]="DEFAULT"]=0,e[t[1]="EXTERNAL"]=1,e}(),t}(),t.SparseTensorProto=function(){function t(t){if(this.dims=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.values=null,t.prototype.indices=null,t.prototype.dims=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.values&&Object.hasOwnProperty.call(t,"values")&&a.onnx.TensorProto.encode(t.values,e.uint32(10).fork()).ldelim(),null!=t.indices&&Object.hasOwnProperty.call(t,"indices")&&a.onnx.TensorProto.encode(t.indices,e.uint32(18).fork()).ldelim(),null!=t.dims&&t.dims.length){e.uint32(26).fork();for(var r=0;r<t.dims.length;++r)e.int64(t.dims[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.SparseTensorProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.values=a.onnx.TensorProto.decode(t,t.uint32());break;case 2:o.indices=a.onnx.TensorProto.decode(t,t.uint32());break;case 3:if(o.dims&&o.dims.length||(o.dims=[]),(7&s)==2)for(var u=t.uint32()+t.pos;t.pos<u;)o.dims.push(t.int64());else o.dims.push(t.int64());break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.values&&t.hasOwnProperty("values")){var e=a.onnx.TensorProto.verify(t.values);if(e)return"values."+e}if(null!=t.indices&&t.hasOwnProperty("indices")){var e=a.onnx.TensorProto.verify(t.indices);if(e)return"indices."+e}if(null!=t.dims&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var r=0;r<t.dims.length;++r)if(!s.isInteger(t.dims[r])&&!(t.dims[r]&&s.isInteger(t.dims[r].low)&&s.isInteger(t.dims[r].high)))return"dims: integer|Long[] expected"}return null},t.fromObject=function(t){if(t instanceof a.onnx.SparseTensorProto)return t;var e=new a.onnx.SparseTensorProto;if(null!=t.values){if("object"!=typeof t.values)throw TypeError(".onnx.SparseTensorProto.values: object expected");e.values=a.onnx.TensorProto.fromObject(t.values)}if(null!=t.indices){if("object"!=typeof t.indices)throw TypeError(".onnx.SparseTensorProto.indices: object expected");e.indices=a.onnx.TensorProto.fromObject(t.indices)}if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");e.dims=[];for(var r=0;r<t.dims.length;++r)s.Long?(e.dims[r]=s.Long.fromValue(t.dims[r])).unsigned=!1:"string"==typeof t.dims[r]?e.dims[r]=parseInt(t.dims[r],10):"number"==typeof t.dims[r]?e.dims[r]=t.dims[r]:"object"==typeof t.dims[r]&&(e.dims[r]=new s.LongBits(t.dims[r].low>>>0,t.dims[r].high>>>0).toNumber())}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.dims=[]),e.defaults&&(r.values=null,r.indices=null),null!=t.values&&t.hasOwnProperty("values")&&(r.values=a.onnx.TensorProto.toObject(t.values,e)),null!=t.indices&&t.hasOwnProperty("indices")&&(r.indices=a.onnx.TensorProto.toObject(t.indices,e)),t.dims&&t.dims.length){r.dims=[];for(var n=0;n<t.dims.length;++n)"number"==typeof t.dims[n]?r.dims[n]=e.longs===String?String(t.dims[n]):t.dims[n]:r.dims[n]=e.longs===String?s.Long.prototype.toString.call(t.dims[n]):e.longs===Number?new s.LongBits(t.dims[n].low>>>0,t.dims[n].high>>>0).toNumber():t.dims[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.SparseTensorProto"},t}(),t.TensorShapeProto=function(){function t(t){if(this.dim=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.dim=s.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.dim&&t.dim.length)for(var r=0;r<t.dim.length;++r)a.onnx.TensorShapeProto.Dimension.encode(t.dim[r],e.uint32(10).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TensorShapeProto;t.pos<r;){var s=t.uint32();s>>>3==1?(o.dim&&o.dim.length||(o.dim=[]),o.dim.push(a.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()))):t.skipType(7&s)}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.dim&&t.hasOwnProperty("dim")){if(!Array.isArray(t.dim))return"dim: array expected";for(var e=0;e<t.dim.length;++e){var r=a.onnx.TensorShapeProto.Dimension.verify(t.dim[e]);if(r)return"dim."+r}}return null},t.fromObject=function(t){if(t instanceof a.onnx.TensorShapeProto)return t;var e=new a.onnx.TensorShapeProto;if(t.dim){if(!Array.isArray(t.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");e.dim=[];for(var r=0;r<t.dim.length;++r){if("object"!=typeof t.dim[r])throw TypeError(".onnx.TensorShapeProto.dim: object expected");e.dim[r]=a.onnx.TensorShapeProto.Dimension.fromObject(t.dim[r])}}return e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.dim=[]),t.dim&&t.dim.length){r.dim=[];for(var n=0;n<t.dim.length;++n)r.dim[n]=a.onnx.TensorShapeProto.Dimension.toObject(t.dim[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorShapeProto"},t.Dimension=function(){var t;function e(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return e.prototype.dimValue=null,e.prototype.dimParam=null,e.prototype.denotation="",Object.defineProperty(e.prototype,"value",{get:s.oneOfGetter(t=["dimValue","dimParam"]),set:s.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(t,e){return e||(e=o.create()),null!=t.dimValue&&Object.hasOwnProperty.call(t,"dimValue")&&e.uint32(8).int64(t.dimValue),null!=t.dimParam&&Object.hasOwnProperty.call(t,"dimParam")&&e.uint32(18).string(t.dimParam),null!=t.denotation&&Object.hasOwnProperty.call(t,"denotation")&&e.uint32(26).string(t.denotation),e},e.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},e.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TensorShapeProto.Dimension;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.dimValue=t.int64();break;case 2:o.dimParam=t.string();break;case 3:o.denotation=t.string();break;default:t.skipType(7&s)}}return o},e.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},e.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.dimValue&&t.hasOwnProperty("dimValue")&&(e.value=1,!s.isInteger(t.dimValue)&&!(t.dimValue&&s.isInteger(t.dimValue.low)&&s.isInteger(t.dimValue.high))))return"dimValue: integer|Long expected";if(null!=t.dimParam&&t.hasOwnProperty("dimParam")){if(1===e.value)return"value: multiple values";if(e.value=1,!s.isString(t.dimParam))return"dimParam: string expected"}return null!=t.denotation&&t.hasOwnProperty("denotation")&&!s.isString(t.denotation)?"denotation: string expected":null},e.fromObject=function(t){if(t instanceof a.onnx.TensorShapeProto.Dimension)return t;var e=new a.onnx.TensorShapeProto.Dimension;return null!=t.dimValue&&(s.Long?(e.dimValue=s.Long.fromValue(t.dimValue)).unsigned=!1:"string"==typeof t.dimValue?e.dimValue=parseInt(t.dimValue,10):"number"==typeof t.dimValue?e.dimValue=t.dimValue:"object"==typeof t.dimValue&&(e.dimValue=new s.LongBits(t.dimValue.low>>>0,t.dimValue.high>>>0).toNumber())),null!=t.dimParam&&(e.dimParam=String(t.dimParam)),null!=t.denotation&&(e.denotation=String(t.denotation)),e},e.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.denotation=""),null!=t.dimValue&&t.hasOwnProperty("dimValue")&&("number"==typeof t.dimValue?r.dimValue=e.longs===String?String(t.dimValue):t.dimValue:r.dimValue=e.longs===String?s.Long.prototype.toString.call(t.dimValue):e.longs===Number?new s.LongBits(t.dimValue.low>>>0,t.dimValue.high>>>0).toNumber():t.dimValue,e.oneofs&&(r.value="dimValue")),null!=t.dimParam&&t.hasOwnProperty("dimParam")&&(r.dimParam=t.dimParam,e.oneofs&&(r.value="dimParam")),null!=t.denotation&&t.hasOwnProperty("denotation")&&(r.denotation=t.denotation),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},e.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorShapeProto.Dimension"},e}(),t}(),t.TypeProto=function(){var t;function e(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return e.prototype.tensorType=null,e.prototype.sequenceType=null,e.prototype.mapType=null,e.prototype.optionalType=null,e.prototype.sparseTensorType=null,e.prototype.denotation="",Object.defineProperty(e.prototype,"value",{get:s.oneOfGetter(t=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:s.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(t,e){return e||(e=o.create()),null!=t.tensorType&&Object.hasOwnProperty.call(t,"tensorType")&&a.onnx.TypeProto.Tensor.encode(t.tensorType,e.uint32(10).fork()).ldelim(),null!=t.sequenceType&&Object.hasOwnProperty.call(t,"sequenceType")&&a.onnx.TypeProto.Sequence.encode(t.sequenceType,e.uint32(34).fork()).ldelim(),null!=t.mapType&&Object.hasOwnProperty.call(t,"mapType")&&a.onnx.TypeProto.Map.encode(t.mapType,e.uint32(42).fork()).ldelim(),null!=t.denotation&&Object.hasOwnProperty.call(t,"denotation")&&e.uint32(50).string(t.denotation),null!=t.sparseTensorType&&Object.hasOwnProperty.call(t,"sparseTensorType")&&a.onnx.TypeProto.SparseTensor.encode(t.sparseTensorType,e.uint32(66).fork()).ldelim(),null!=t.optionalType&&Object.hasOwnProperty.call(t,"optionalType")&&a.onnx.TypeProto.Optional.encode(t.optionalType,e.uint32(74).fork()).ldelim(),e},e.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},e.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TypeProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.tensorType=a.onnx.TypeProto.Tensor.decode(t,t.uint32());break;case 4:o.sequenceType=a.onnx.TypeProto.Sequence.decode(t,t.uint32());break;case 5:o.mapType=a.onnx.TypeProto.Map.decode(t,t.uint32());break;case 9:o.optionalType=a.onnx.TypeProto.Optional.decode(t,t.uint32());break;case 8:o.sparseTensorType=a.onnx.TypeProto.SparseTensor.decode(t,t.uint32());break;case 6:o.denotation=t.string();break;default:t.skipType(7&s)}}return o},e.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},e.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.tensorType&&t.hasOwnProperty("tensorType")){e.value=1;var r=a.onnx.TypeProto.Tensor.verify(t.tensorType);if(r)return"tensorType."+r}if(null!=t.sequenceType&&t.hasOwnProperty("sequenceType")){if(1===e.value)return"value: multiple values";e.value=1;var r=a.onnx.TypeProto.Sequence.verify(t.sequenceType);if(r)return"sequenceType."+r}if(null!=t.mapType&&t.hasOwnProperty("mapType")){if(1===e.value)return"value: multiple values";e.value=1;var r=a.onnx.TypeProto.Map.verify(t.mapType);if(r)return"mapType."+r}if(null!=t.optionalType&&t.hasOwnProperty("optionalType")){if(1===e.value)return"value: multiple values";e.value=1;var r=a.onnx.TypeProto.Optional.verify(t.optionalType);if(r)return"optionalType."+r}if(null!=t.sparseTensorType&&t.hasOwnProperty("sparseTensorType")){if(1===e.value)return"value: multiple values";e.value=1;var r=a.onnx.TypeProto.SparseTensor.verify(t.sparseTensorType);if(r)return"sparseTensorType."+r}return null!=t.denotation&&t.hasOwnProperty("denotation")&&!s.isString(t.denotation)?"denotation: string expected":null},e.fromObject=function(t){if(t instanceof a.onnx.TypeProto)return t;var e=new a.onnx.TypeProto;if(null!=t.tensorType){if("object"!=typeof t.tensorType)throw TypeError(".onnx.TypeProto.tensorType: object expected");e.tensorType=a.onnx.TypeProto.Tensor.fromObject(t.tensorType)}if(null!=t.sequenceType){if("object"!=typeof t.sequenceType)throw TypeError(".onnx.TypeProto.sequenceType: object expected");e.sequenceType=a.onnx.TypeProto.Sequence.fromObject(t.sequenceType)}if(null!=t.mapType){if("object"!=typeof t.mapType)throw TypeError(".onnx.TypeProto.mapType: object expected");e.mapType=a.onnx.TypeProto.Map.fromObject(t.mapType)}if(null!=t.optionalType){if("object"!=typeof t.optionalType)throw TypeError(".onnx.TypeProto.optionalType: object expected");e.optionalType=a.onnx.TypeProto.Optional.fromObject(t.optionalType)}if(null!=t.sparseTensorType){if("object"!=typeof t.sparseTensorType)throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");e.sparseTensorType=a.onnx.TypeProto.SparseTensor.fromObject(t.sparseTensorType)}return null!=t.denotation&&(e.denotation=String(t.denotation)),e},e.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.denotation=""),null!=t.tensorType&&t.hasOwnProperty("tensorType")&&(r.tensorType=a.onnx.TypeProto.Tensor.toObject(t.tensorType,e),e.oneofs&&(r.value="tensorType")),null!=t.sequenceType&&t.hasOwnProperty("sequenceType")&&(r.sequenceType=a.onnx.TypeProto.Sequence.toObject(t.sequenceType,e),e.oneofs&&(r.value="sequenceType")),null!=t.mapType&&t.hasOwnProperty("mapType")&&(r.mapType=a.onnx.TypeProto.Map.toObject(t.mapType,e),e.oneofs&&(r.value="mapType")),null!=t.denotation&&t.hasOwnProperty("denotation")&&(r.denotation=t.denotation),null!=t.sparseTensorType&&t.hasOwnProperty("sparseTensorType")&&(r.sparseTensorType=a.onnx.TypeProto.SparseTensor.toObject(t.sparseTensorType,e),e.oneofs&&(r.value="sparseTensorType")),null!=t.optionalType&&t.hasOwnProperty("optionalType")&&(r.optionalType=a.onnx.TypeProto.Optional.toObject(t.optionalType,e),e.oneofs&&(r.value="optionalType")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},e.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto"},e.Tensor=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elemType=0,t.prototype.shape=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&e.uint32(8).int32(t.elemType),null!=t.shape&&Object.hasOwnProperty.call(t,"shape")&&a.onnx.TensorShapeProto.encode(t.shape,e.uint32(18).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TypeProto.Tensor;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.elemType=t.int32();break;case 2:o.shape=a.onnx.TensorShapeProto.decode(t,t.uint32());break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elemType&&t.hasOwnProperty("elemType")&&!s.isInteger(t.elemType))return"elemType: integer expected";if(null!=t.shape&&t.hasOwnProperty("shape")){var e=a.onnx.TensorShapeProto.verify(t.shape);if(e)return"shape."+e}return null},t.fromObject=function(t){if(t instanceof a.onnx.TypeProto.Tensor)return t;var e=new a.onnx.TypeProto.Tensor;if(null!=t.elemType&&(e.elemType=0|t.elemType),null!=t.shape){if("object"!=typeof t.shape)throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");e.shape=a.onnx.TensorShapeProto.fromObject(t.shape)}return e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.elemType=0,r.shape=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(r.elemType=t.elemType),null!=t.shape&&t.hasOwnProperty("shape")&&(r.shape=a.onnx.TensorShapeProto.toObject(t.shape,e)),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Tensor"},t}(),e.Sequence=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elemType=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&a.onnx.TypeProto.encode(t.elemType,e.uint32(10).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TypeProto.Sequence;t.pos<r;){var s=t.uint32();s>>>3==1?o.elemType=a.onnx.TypeProto.decode(t,t.uint32()):t.skipType(7&s)}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elemType&&t.hasOwnProperty("elemType")){var e=a.onnx.TypeProto.verify(t.elemType);if(e)return"elemType."+e}return null},t.fromObject=function(t){if(t instanceof a.onnx.TypeProto.Sequence)return t;var e=new a.onnx.TypeProto.Sequence;if(null!=t.elemType){if("object"!=typeof t.elemType)throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");e.elemType=a.onnx.TypeProto.fromObject(t.elemType)}return e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.elemType=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(r.elemType=a.onnx.TypeProto.toObject(t.elemType,e)),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Sequence"},t}(),e.Map=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.keyType=0,t.prototype.valueType=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.keyType&&Object.hasOwnProperty.call(t,"keyType")&&e.uint32(8).int32(t.keyType),null!=t.valueType&&Object.hasOwnProperty.call(t,"valueType")&&a.onnx.TypeProto.encode(t.valueType,e.uint32(18).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TypeProto.Map;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.keyType=t.int32();break;case 2:o.valueType=a.onnx.TypeProto.decode(t,t.uint32());break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.keyType&&t.hasOwnProperty("keyType")&&!s.isInteger(t.keyType))return"keyType: integer expected";if(null!=t.valueType&&t.hasOwnProperty("valueType")){var e=a.onnx.TypeProto.verify(t.valueType);if(e)return"valueType."+e}return null},t.fromObject=function(t){if(t instanceof a.onnx.TypeProto.Map)return t;var e=new a.onnx.TypeProto.Map;if(null!=t.keyType&&(e.keyType=0|t.keyType),null!=t.valueType){if("object"!=typeof t.valueType)throw TypeError(".onnx.TypeProto.Map.valueType: object expected");e.valueType=a.onnx.TypeProto.fromObject(t.valueType)}return e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.keyType=0,r.valueType=null),null!=t.keyType&&t.hasOwnProperty("keyType")&&(r.keyType=t.keyType),null!=t.valueType&&t.hasOwnProperty("valueType")&&(r.valueType=a.onnx.TypeProto.toObject(t.valueType,e)),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Map"},t}(),e.Optional=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elemType=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&a.onnx.TypeProto.encode(t.elemType,e.uint32(10).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TypeProto.Optional;t.pos<r;){var s=t.uint32();s>>>3==1?o.elemType=a.onnx.TypeProto.decode(t,t.uint32()):t.skipType(7&s)}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elemType&&t.hasOwnProperty("elemType")){var e=a.onnx.TypeProto.verify(t.elemType);if(e)return"elemType."+e}return null},t.fromObject=function(t){if(t instanceof a.onnx.TypeProto.Optional)return t;var e=new a.onnx.TypeProto.Optional;if(null!=t.elemType){if("object"!=typeof t.elemType)throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");e.elemType=a.onnx.TypeProto.fromObject(t.elemType)}return e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.elemType=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(r.elemType=a.onnx.TypeProto.toObject(t.elemType,e)),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Optional"},t}(),e.SparseTensor=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elemType=0,t.prototype.shape=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&e.uint32(8).int32(t.elemType),null!=t.shape&&Object.hasOwnProperty.call(t,"shape")&&a.onnx.TensorShapeProto.encode(t.shape,e.uint32(18).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.TypeProto.SparseTensor;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.elemType=t.int32();break;case 2:o.shape=a.onnx.TensorShapeProto.decode(t,t.uint32());break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elemType&&t.hasOwnProperty("elemType")&&!s.isInteger(t.elemType))return"elemType: integer expected";if(null!=t.shape&&t.hasOwnProperty("shape")){var e=a.onnx.TensorShapeProto.verify(t.shape);if(e)return"shape."+e}return null},t.fromObject=function(t){if(t instanceof a.onnx.TypeProto.SparseTensor)return t;var e=new a.onnx.TypeProto.SparseTensor;if(null!=t.elemType&&(e.elemType=0|t.elemType),null!=t.shape){if("object"!=typeof t.shape)throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");e.shape=a.onnx.TensorShapeProto.fromObject(t.shape)}return e},t.toObject=function(t,e){e||(e={});var r={};return e.defaults&&(r.elemType=0,r.shape=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(r.elemType=t.elemType),null!=t.shape&&t.hasOwnProperty("shape")&&(r.shape=a.onnx.TensorShapeProto.toObject(t.shape,e)),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.SparseTensor"},t}(),e}(),t.OperatorSetIdProto=function(){function t(t){if(t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.domain="",t.prototype.version=s.Long?s.Long.fromBits(0,0,!1):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=o.create()),null!=t.domain&&Object.hasOwnProperty.call(t,"domain")&&e.uint32(10).string(t.domain),null!=t.version&&Object.hasOwnProperty.call(t,"version")&&e.uint32(16).int64(t.version),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.OperatorSetIdProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.domain=t.string();break;case 2:o.version=t.int64();break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.domain&&t.hasOwnProperty("domain")&&!s.isString(t.domain)?"domain: string expected":null!=t.version&&t.hasOwnProperty("version")&&!s.isInteger(t.version)&&!(t.version&&s.isInteger(t.version.low)&&s.isInteger(t.version.high))?"version: integer|Long expected":null},t.fromObject=function(t){if(t instanceof a.onnx.OperatorSetIdProto)return t;var e=new a.onnx.OperatorSetIdProto;return null!=t.domain&&(e.domain=String(t.domain)),null!=t.version&&(s.Long?(e.version=s.Long.fromValue(t.version)).unsigned=!1:"string"==typeof t.version?e.version=parseInt(t.version,10):"number"==typeof t.version?e.version=t.version:"object"==typeof t.version&&(e.version=new s.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var r={};if(e.defaults){if(r.domain="",s.Long){var n=new s.Long(0,0,!1);r.version=e.longs===String?n.toString():e.longs===Number?n.toNumber():n}else r.version=e.longs===String?"0":0}return null!=t.domain&&t.hasOwnProperty("domain")&&(r.domain=t.domain),null!=t.version&&t.hasOwnProperty("version")&&("number"==typeof t.version?r.version=e.longs===String?String(t.version):t.version:r.version=e.longs===String?s.Long.prototype.toString.call(t.version):e.longs===Number?new s.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.OperatorSetIdProto"},t}(),t.OperatorStatus=function(){var t={},e=Object.create(t);return e[t[0]="EXPERIMENTAL"]=0,e[t[1]="STABLE"]=1,e}(),t.FunctionProto=function(){function t(t){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],t)for(var e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.input=s.emptyArray,t.prototype.output=s.emptyArray,t.prototype.attribute=s.emptyArray,t.prototype.attributeProto=s.emptyArray,t.prototype.node=s.emptyArray,t.prototype.docString="",t.prototype.opsetImport=s.emptyArray,t.prototype.domain="",t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=o.create()),null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(10).string(t.name),null!=t.input&&t.input.length)for(var r=0;r<t.input.length;++r)e.uint32(34).string(t.input[r]);if(null!=t.output&&t.output.length)for(var r=0;r<t.output.length;++r)e.uint32(42).string(t.output[r]);if(null!=t.attribute&&t.attribute.length)for(var r=0;r<t.attribute.length;++r)e.uint32(50).string(t.attribute[r]);if(null!=t.node&&t.node.length)for(var r=0;r<t.node.length;++r)a.onnx.NodeProto.encode(t.node[r],e.uint32(58).fork()).ldelim();if(null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(66).string(t.docString),null!=t.opsetImport&&t.opsetImport.length)for(var r=0;r<t.opsetImport.length;++r)a.onnx.OperatorSetIdProto.encode(t.opsetImport[r],e.uint32(74).fork()).ldelim();if(null!=t.domain&&Object.hasOwnProperty.call(t,"domain")&&e.uint32(82).string(t.domain),null!=t.attributeProto&&t.attributeProto.length)for(var r=0;r<t.attributeProto.length;++r)a.onnx.AttributeProto.encode(t.attributeProto[r],e.uint32(90).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var r=void 0===e?t.len:t.pos+e,o=new a.onnx.FunctionProto;t.pos<r;){var s=t.uint32();switch(s>>>3){case 1:o.name=t.string();break;case 4:o.input&&o.input.length||(o.input=[]),o.input.push(t.string());break;case 5:o.output&&o.output.length||(o.output=[]),o.output.push(t.string());break;case 6:o.attribute&&o.attribute.length||(o.attribute=[]),o.attribute.push(t.string());break;case 11:o.attributeProto&&o.attributeProto.length||(o.attributeProto=[]),o.attributeProto.push(a.onnx.AttributeProto.decode(t,t.uint32()));break;case 7:o.node&&o.node.length||(o.node=[]),o.node.push(a.onnx.NodeProto.decode(t,t.uint32()));break;case 8:o.docString=t.string();break;case 9:o.opsetImport&&o.opsetImport.length||(o.opsetImport=[]),o.opsetImport.push(a.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 10:o.domain=t.string();break;default:t.skipType(7&s)}}return o},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.name&&t.hasOwnProperty("name")&&!s.isString(t.name))return"name: string expected";if(null!=t.input&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var e=0;e<t.input.length;++e)if(!s.isString(t.input[e]))return"input: string[] expected"}if(null!=t.output&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var e=0;e<t.output.length;++e)if(!s.isString(t.output[e]))return"output: string[] expected"}if(null!=t.attribute&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(var e=0;e<t.attribute.length;++e)if(!s.isString(t.attribute[e]))return"attribute: string[] expected"}if(null!=t.attributeProto&&t.hasOwnProperty("attributeProto")){if(!Array.isArray(t.attributeProto))return"attributeProto: array expected";for(var e=0;e<t.attributeProto.length;++e){var r=a.onnx.AttributeProto.verify(t.attributeProto[e]);if(r)return"attributeProto."+r}}if(null!=t.node&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var e=0;e<t.node.length;++e){var r=a.onnx.NodeProto.verify(t.node[e]);if(r)return"node."+r}}if(null!=t.docString&&t.hasOwnProperty("docString")&&!s.isString(t.docString))return"docString: string expected";if(null!=t.opsetImport&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var e=0;e<t.opsetImport.length;++e){var r=a.onnx.OperatorSetIdProto.verify(t.opsetImport[e]);if(r)return"opsetImport."+r}}return null!=t.domain&&t.hasOwnProperty("domain")&&!s.isString(t.domain)?"domain: string expected":null},t.fromObject=function(t){if(t instanceof a.onnx.FunctionProto)return t;var e=new a.onnx.FunctionProto;if(null!=t.name&&(e.name=String(t.name)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.FunctionProto.input: array expected");e.input=[];for(var r=0;r<t.input.length;++r)e.input[r]=String(t.input[r])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.FunctionProto.output: array expected");e.output=[];for(var r=0;r<t.output.length;++r)e.output[r]=String(t.output[r])}if(t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");e.attribute=[];for(var r=0;r<t.attribute.length;++r)e.attribute[r]=String(t.attribute[r])}if(t.attributeProto){if(!Array.isArray(t.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");e.attributeProto=[];for(var r=0;r<t.attributeProto.length;++r){if("object"!=typeof t.attributeProto[r])throw TypeError(".onnx.FunctionProto.attributeProto: object expected");e.attributeProto[r]=a.onnx.AttributeProto.fromObject(t.attributeProto[r])}}if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.FunctionProto.node: array expected");e.node=[];for(var r=0;r<t.node.length;++r){if("object"!=typeof t.node[r])throw TypeError(".onnx.FunctionProto.node: object expected");
1e.node[r]=a.onnx.NodeProto.fromObject(t.node[r])}}if(null!=t.docString&&(e.docString=String(t.docString)),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");e.opsetImport=[];for(var r=0;r<t.opsetImport.length;++r){if("object"!=typeof t.opsetImport[r])throw TypeError(".onnx.FunctionProto.opsetImport: object expected");e.opsetImport[r]=a.onnx.OperatorSetIdProto.fromObject(t.opsetImport[r])}}return null!=t.domain&&(e.domain=String(t.domain)),e},t.toObject=function(t,e){e||(e={});var r={};if((e.arrays||e.defaults)&&(r.input=[],r.output=[],r.attribute=[],r.node=[],r.opsetImport=[],r.attributeProto=[]),e.defaults&&(r.name="",r.docString="",r.domain=""),null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),t.input&&t.input.length){r.input=[];for(var n=0;n<t.input.length;++n)r.input[n]=t.input[n]}if(t.output&&t.output.length){r.output=[];for(var n=0;n<t.output.length;++n)r.output[n]=t.output[n]}if(t.attribute&&t.attribute.length){r.attribute=[];for(var n=0;n<t.attribute.length;++n)r.attribute[n]=t.attribute[n]}if(t.node&&t.node.length){r.node=[];for(var n=0;n<t.node.length;++n)r.node[n]=a.onnx.NodeProto.toObject(t.node[n],e)}if(null!=t.docString&&t.hasOwnProperty("docString")&&(r.docString=t.docString),t.opsetImport&&t.opsetImport.length){r.opsetImport=[];for(var n=0;n<t.opsetImport.length;++n)r.opsetImport[n]=a.onnx.OperatorSetIdProto.toObject(t.opsetImport[n],e)}if(null!=t.domain&&t.hasOwnProperty("domain")&&(r.domain=t.domain),t.attributeProto&&t.attributeProto.length){r.attributeProto=[];for(var n=0;n<t.attributeProto.length;++n)r.attributeProto[n]=a.onnx.AttributeProto.toObject(t.attributeProto[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.FunctionProto"},t}(),t}(),e.exports=a});function ur(t,e){if(!t)throw Error("string"==typeof e?e:e())}function kr(t){return new TextDecoder().decode(t)}var ot,Me,ai,kt,Sn,At,Rt,B,$r,Ue,Ve,ze,Y=O(()=>{"use strict";wn(),qo(),ot=rr(sr()),We(),Me=class{static arraysEqual(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}},ai=class{static preprocessInputShapes(t,e){return[1===t.length?[1,t[0]]:t,1===e.length?[e[0],1]:e]}static postprocessOutputShape(t,e,r){1===e&&t.splice(t.length-2,1),1===r&&t.pop()}static calcMatMulShape(t,e){return t[1]!==e[0]?void 0:[t[0],e[1]]}},kt=class t{static calcShape(t,e,r=!1){let n=t.length,o=e.length;if(0===n)return e;if(0===o)return t;let s=Math.max(t.length,e.length),a=Array(s);if(r){if(n<2||o<2)return;let r=ai.calcMatMulShape([t[n-2],t[n-1]],[e[o-2],e[o-1]]);if(void 0===r)return;[a[s-2],a[s-1]]=r}for(let u=r?3:1;u<=s;u++){let r=n-u<0?1:t[n-u],l=o-u<0?1:e[o-u];if(r!==l&&r>1&&l>1)return;a[s-u]=Math.max(r,l)}return a}static index(e,r){let n=Array(r.length);return t.fillIndex(e,r,n),n}static fillIndex(t,e,r){let n=t.length-e.length;for(let o=0;o<e.length;o++)r[o]=t[n+o]%e[o]}static calc(e,r,n,o,s){let a=t.calcShape(e.dims,r.dims);if(a){if(o&&!B.areEqual(a,e.dims))return;let u=B.size(a),l=o?e:new bt(a,s||e.type);if(0===a.length)l.set([],n(e.get([]),r.get([])));else{let o,s=Array(a.length),p=Array(e.dims.length),c=Array(r.dims.length),d=0,h=0,f=!1,g=!1;0===e.dims.length&&(d=e.get([]),f=!0),0===r.dims.length&&(h=r.get([]),g=!0);for(let m=0;m<u;m++){o=m;for(let t=a.length-1;t>=0;t--)s[t]=o%a[t],o=Math.floor(o/a[t]);f||(t.fillIndex(s,e.dims,p),d=e.get(p)),g||(t.fillIndex(s,r.dims,c),h=r.get(c)),l.set(s,n(d,h))}}return l}}static isValidBroadcast(t,e){let r=t.length,n=e.length;if(r>n)return!1;for(let o=1;o<=r;o++)if(1!==t[r-o]&&t[r-o]!==e[n-o])return!1;return!0}static getBroadcastDims(t,e){let r=t.length,n=[];for(let o=0;o<r;o++){let s=r-1-o,a=t[s]||1;(e[e.length-1-o]||1)>1&&1===a&&n.unshift(s)}return n}},Sn=class{static getShapeOfGemmResult(t,e,r,n,o){let s,a,u;if(2!==t.length||2!==r.length)throw Error("shape need to be of size 2");e?(s=t[1],a=t[0]):(s=t[0],a=t[1]);let l=-1;if(n?(u=r[0],l=1):(u=r[1],l=0),r[l]!==a)throw Error("dimension mismatch");if(s<=0||u<=0||a<=0)throw Error("invalid shape specified");if(o&&!kt.isValidBroadcast(o,[s,u]))throw Error("gemm: invalid bias shape for broadcast");return[s,u,a]}},At=class t{static tensorDataTypeFromProto(t){switch(t){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 Error(`unsupported data type: ${ot.onnx.TensorProto.DataType[t]}`)}}static tensorDataTypeStringToEnum(t){switch(t){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 Error(`unsupported data type: ${t}`)}}static tensorDimsFromProto(t){return t.map(t=>xe.isLong(t)?t.toNumber():t)}static tensorValueTypeFromProto(e){return{tensorType:t.tensorDataTypeFromProto(e.elemType),shape:{dims:t.tensorDimsFromProto(e.shape.dim.map(t=>t.dimValue))}}}static tensorDimsFromORTFormat(t){let e=[];for(let r=0;r<t.dimsLength();r++)e.push(Rt.longToNumber(t.dims(r)));return e}static tensorAttributesFromORTFormat(t){let e=[];for(let r=0;r<t.attributesLength();r++)e.push(t.attributes(r));return e}},Rt=class{static longToNumber(t,e){return xe.isLong(t)?t.toNumber():t instanceof w.Long?xe.fromValue({low:t.low,high:t.high,unsigned:e??!1}).toNumber():t}static isLong(t){return xe.isLong(t)||t instanceof w.Long}},B=class t{static size(e){return t.getSizeFromDimensionRange(e,0,e.length)}static sizeFromDimension(e,r){if(r<0||r>e.length)throw Error(`invalid dimension of ${r} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return t.getSizeFromDimensionRange(e,r,e.length)}static sizeToDimension(e,r){if(r<0||r>e.length)throw Error(`invalid dimension of ${r} for sizeToDimension as Tensor has ${e.length} dimensions.`);return t.getSizeFromDimensionRange(e,0,r)}static getSizeFromDimensionRange(t,e,r){let n=1;for(let o=e;o<r;o++){if(t[o]<=0)throw Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");n*=t[o]}return n}static computeStrides(t){let e=t.length;if(0===e)return[];if(1===e)return[1];let r=Array(e);r[e-1]=1,r[e-2]=t[e-1];for(let n=e-3;n>=0;--n)r[n]=r[n+1]*t[n+1];return r}static transpose(t){return t.slice().reverse()}static indicesToOffset(t,e,r){void 0===r&&(r=t.length);let n=0;for(let o=0;o<r;++o)n+=e[o]*t[o];return n}static offsetToIndices(t,e){let r=e.length;if(0===r)return[];if(1===r)return[t*e[0]];let n=Array(e.length);for(let r=0;r<n.length-1;++r)n[r]=Math.floor(t/e[r]),t-=n[r]*e[r];return n[n.length-1]=t,n}static normalizeAxis(t,e){if(t<-e&&t>=e)throw Error("unsupported axis for this operation.");return t<0?t+e:t}static normalizeAxes(t,e){return t.map(t=>this.normalizeAxis(t,e))}static incrementIndex(t,e,r){if(0===e.length||0===t.length)throw Error("Index incrementing unsupported for scalar Tensor");if(void 0===r)r=e.length;else if(r<=0||r>e.length)throw Error("Incorrect axis to increment on");for(let n=r-1;n>=0&&(t[n]++,!(t[n]<e[n]));--n)t[n]=0}static calculateReshapedDims(e,r){if(0===r.length){if(0===e.length||1===t.size(e))return[];throw Error("cannot reshape to a scalar Tensor")}let n=r.length,o=Array(n),s=-1,a=1;for(let t=0;t<n;t++){if(r[t]<-1)throw Error("a dimension in shape hints cannot be less than -1");if(-1===r[t]){if(-1!==s)throw Error("at most one dimension in shape hints can be -1");s=t}else{if(0===r[t]){if(t>=e.length)throw Error("the dimension with value zero exceeds the dimension size of the input tensor");o[t]=e[t]}else o[t]=r[t];a*=o[t]}}let u=t.size(e);if(-1!==s){if(u%a!=0)throw Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${e}] Output shape: [${r}]`);o[s]=u/a}else if(a!==u)throw Error("reshapedDims and originalDims don't have matching sizes");return o}static sortBasedOnPerm(t,e){return e?e.map(e=>t[e]):t.slice().reverse()}static padShape(t,e){let r=t.length;return t.map((t,n)=>t+e[n]+e[n+r])}static areEqual(t,e){return t.length===e.length&&t.every((t,r)=>t===e[r])}static validateDimsAndCalcSize(t){if(t.length>6)throw TypeError("Only rank 0 to 6 is supported for tensor shape.");let e=1;for(let r of t){if(!Number.isInteger(r))throw TypeError(`Invalid shape: ${r} is not an integer`);if(r<0||r>2147483647)throw TypeError(`Invalid shape: length ${r} is not allowed`);e*=r}return e}
1static flattenShape(t,e){e<0&&(e+=t.length);let r=t.reduce((t,e)=>t*e,1),n=t.slice(e).reduce((t,e)=>t*e,1);return[r/n,n]}static squeezeShape(e,r){let n=[];r=t.normalizeAxes(r,e.length);for(let t=0;t<e.length;t++){let o=r.indexOf(t)>=0;if(o&&1!==e[t])throw Error("squeeze an axis of size different than 1");(0===r.length&&e[t]>1||r.length>0&&!o)&&n.push(e[t])}return n}static unsqueezeShape(e,r){let n=Array(e.length+r.length);n.fill(0);for(let e=0;e<r.length;e++){let o=t.normalizeAxis(r[e],n.length);if(o>=n.length)throw Error("'axes' has an out of range axis");if(0!==n[o])throw Error("'axes' has a duplicate axis");n[o]=1}let o=0;for(let t=0;t<n.length;t++)0===n[t]&&(n[t]=e[o++]);if(o!==e.length)throw Error("the unsqueezed dimension could not be established");return n}},$r=class t{static splitShape(e,r,n,o){if(0===n.length){if(!o)throw Error("need to know number of outputs when the 'split' attribute is not specified");t.determineSplit(e[r],o,n)}let s=[],a=[0];for(let t=0;t<n.length;++t){0!==t&&a.push(a[t-1]+n[t-1]);let o=e.slice();o[r]=n[t],s.push(o)}return[s,a]}static determineSplit(t,e,r){if(t%e!=0)throw Error("cannot split tensor to equal sized parts");for(let n=0;n<e;++n)r.push(t/e)}},Ue=class t{static adjustPoolAttributes(t,e,r,n,o,s){if(!t&&r.length!==e.length-2)throw Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(t)for(let t=0;t<e.length-2;t++)t>=r.length?r.push(e[t+2]):r[t]=e[t+2];for(let t=0;t<r.length;t++)if(t<n.length){if(n[t]<0)throw Error("strides should be greater than or equal to 1")}else n.push(1);for(let t=0;t<r.length;t++)if(t<o.length){if(o[t]<0)throw Error("dilations should be greater than or equal to 1")}else o.push(1);for(let t=0;t<2*r.length;t++)if(t<s.length){if(s[t]<0)throw Error("pad should be greater than or equal to 1")}else s.push(0);for(let t=0;t<r.length;t++){if(r[t]<=0)throw Error("kernel shapes need to be greater than 0");if(s[t]>=r[t]||s[t+r.length]>=r[t])throw Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,r,n,o,s,a){if(a){if(s.length!==2*(e.length-2))throw Error("length of pads should be twice the length of data dimensions");if(r.length!==e.length-2)throw Error("length of strides should be the length of data dimensions");if(o.length!==e.length-2)throw Error("length of kernel shapes should be the length of data dimensions");for(let u=0;u<e.length-2;u++)t.adjustPadAndReturnShape(e[u+2],r[u],n[u],o[u],s,u,u+e.length-2,a)}}static computePoolOutputShape(e,r,n,o,s,a,u){if(r.length<=0)throw Error("input shape must be of size greater than 0");let l=[r[0],r[1]];return t.computeShapeHelper(e,r,l,n,o,s,a,u),l}static computeConvOutputShape(e,r,n,o,s,a,u){if(e.length<=0||r.length<=0)throw Error("invalid input tensor dims or invalid filter tensor dims");let l=[e[0],r[0]];return t.computeShapeHelper(!1,e,l,n,o,s,a,u),l}static computeShapeHelper(e,r,n,o,s,a,u,l){if(e)for(let t=0;t<r.length-2;t++)n.push(1);else for(let e=0;e<r.length-2;e++)n.push(t.adjustPadAndReturnShape(r[e+2],o[e],s[e],a[e],u,e,e+r.length-2,l))}static adjustPadAndReturnShape(t,e,r,n,o,s,a,u){let l=r*(n-1)+1;if(!u||"NOTSET"===u)return Math.floor((t+o[s]+o[a]-l)/e+1);switch(u){case"VALID":return o[s]=0,o[a]=0,Math.floor((t-l)/e+1);case"SAME_LOWER":case"SAME_UPPER":if(1!==r)throw Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let r=((t+e-1)/e-1)*e+n-t;return o[s]=Math.floor("SAME_LOWER"===u?(r+1)/2:r/2),o[a]=r-o[s],Math.floor((t+r-n)/e+1)}default:throw Error("Unsupported AutoPad type")}}},Ve=-34028234663852886e22,ze=34028234663852886e22});function hh(t){switch(t){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 Error(`cannot calculate sizeof() on type ${t}`)}}function Wu(t){switch(t){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 Error(`cannot calculate sizeof() on type ${H.onnx.TensorProto.DataType[t]}`)}}function mh(t,e){return new(ju(e))(t)}function ju(t){switch(t){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 Error("unspecified error")}}function ui(t,e){if(e===H.onnx.TensorProto.DataType.INT64||e===si.TensorDataType.INT64){if(t.greaterThanOrEqual(2147483648)||t.lessThan(-2147483648))throw TypeError("int64 is not supported")}else if(e===H.onnx.TensorProto.DataType.UINT32||e===si.TensorDataType.UINT32||e===H.onnx.TensorProto.DataType.UINT64||e===si.TensorDataType.UINT64){if(t.greaterThanOrEqual(4294967296)||t.lessThan(0))throw TypeError("uint64 is not supported")}else throw TypeError(`not a LONG type: ${H.onnx.TensorProto.DataType[e]}`);return t.toNumber()}function Hu(t,e,r){switch(e){case H.onnx.TensorProto.DataType.BOOL:case H.onnx.TensorProto.DataType.UINT8:return t.getUint8(r);case H.onnx.TensorProto.DataType.INT8:return t.getInt8(r);case H.onnx.TensorProto.DataType.UINT16:return t.getUint16(r,!0);case H.onnx.TensorProto.DataType.INT16:return t.getInt16(r,!0);case H.onnx.TensorProto.DataType.FLOAT:return t.getFloat32(r,!0);case H.onnx.TensorProto.DataType.INT32:return t.getInt32(r,!0);case H.onnx.TensorProto.DataType.UINT32:return t.getUint32(r,!0);case H.onnx.TensorProto.DataType.INT64:return ui(xe.fromBits(t.getUint32(r,!0),t.getUint32(r+4,!0),!1),e);case H.onnx.TensorProto.DataType.DOUBLE:return t.getFloat64(r,!0);case H.onnx.TensorProto.DataType.UINT64:return ui(xe.fromBits(t.getUint32(r,!0),t.getUint32(r+4,!0),!0),e);default:throw Error(`cannot read from DataView for type ${H.onnx.TensorProto.DataType[e]}`)}}var qu,H,si,bt,We=O(()=>{"use strict";qu=rr(Fs()),qo(),Pr(),H=rr(sr()),Y(),si=F.experimental.fbs,bt=class t{constructor(t,e,r,n,o,s=qu.Guid.create()){this.dims=t,this.type=e,this.dataProvider=r,this.asyncDataProvider=n,this.cache=o,this.dataId=s,this.size=B.validateDimsAndCalcSize(t);let a=this.size,u=void 0===r&&void 0===n&&void 0===o;if(void 0!==o&&o.length!==a)throw RangeError("Input dims doesn't match data length.");
1if("string"===e){if(void 0!==o&&(!Array.isArray(o)||!o.every(t=>"string"==typeof t)))throw TypeError("cache should be a string array");u&&(this.cache=Array(a))}else{if(void 0!==o){let t=ju(e);if(!(o instanceof t))throw TypeError(`cache should be type ${t.name}`)}if(u){let t=new ArrayBuffer(a*hh(e));this.cache=mh(t,e)}}}get data(){if(void 0===this.cache){let t=this.dataProvider(this.dataId);if(t.length!==this.size)throw Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=t}return this.cache}get stringData(){if("string"!==this.type)throw 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 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 TypeError("data type is not float (float32, float64)")}}get numberData(){if("string"!==this.type)return this.data;throw TypeError("type cannot be non-number (string)")}get(t){return this.data[B.indicesToOffset(t,this.strides)]}set(t,e){this.data[B.indicesToOffset(t,this.strides)]=e}async getData(){return void 0===this.cache&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=B.computeStrides(this.dims)),this._strides}static fromProto(e){if(!e)throw Error("cannot construct Value from an empty tensor");let r=At.tensorDataTypeFromProto(e.dataType),n=new t(At.tensorDimsFromProto(e.dims),r);if("string"===r)e.stringData.forEach((t,e)=>{n.data[e]=kr(t)});else if(e.rawData&&"number"==typeof e.rawData.byteLength&&e.rawData.byteLength>0){let t=n.data,r=new DataView(e.rawData.buffer,e.rawData.byteOffset,e.rawData.byteLength),o=Wu(e.dataType),s=e.rawData.byteLength/o;if(e.rawData.byteLength%o!=0)throw Error("invalid buffer length");if(t.length!==s)throw Error("buffer length mismatch");for(let n=0;n<s;n++){let s=Hu(r,e.dataType,n*o);t[n]=s}}else{let t;switch(e.dataType){case H.onnx.TensorProto.DataType.FLOAT:t=e.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:t=e.int32Data;break;case H.onnx.TensorProto.DataType.INT64:t=e.int64Data;break;case H.onnx.TensorProto.DataType.DOUBLE:t=e.doubleData;break;case H.onnx.TensorProto.DataType.UINT32:case H.onnx.TensorProto.DataType.UINT64:t=e.uint64Data;break;default:throw Error("unspecific error")}if(null==t)throw Error("failed to populate data from a tensorproto value");let r=n.data;if(r.length!==t.length)throw Error("array length mismatch");for(let n=0;n<t.length;n++){let o=t[n];xe.isLong(o)?r[n]=ui(o,e.dataType):r[n]=o}}return n}static fromData(e,r,n){return new t(r,n,void 0,void 0,e)}static fromOrtTensor(e){if(!e)throw Error("cannot construct Value from an empty tensor");let r=At.tensorDimsFromORTFormat(e),n=At.tensorDataTypeFromProto(e.dataType()),o=new t(r,n);if("string"===n)for(let t=0;t<e.stringDataLength();t++)o.data[t]=e.stringData(t);else if(e.rawDataArray()&&"number"==typeof e.rawDataLength()&&e.rawDataLength()>0){let t=o.data,r=new DataView(e.rawDataArray().buffer,e.rawDataArray().byteOffset,e.rawDataLength()),n=Wu(e.dataType()),s=e.rawDataLength()/n;if(e.rawDataLength()%n!=0)throw Error("invalid buffer length");if(t.length!==s)throw Error("buffer length mismatch");for(let o=0;o<s;o++){let s=Hu(r,e.dataType(),o*n);t[o]=s}}return o}}});function G(t){return 1===t?bh:gh}function Xu(t){let e=G(t);return`${e.version}
2      precision highp float;
3      ${e.attribute} vec3 position;
4      ${e.attribute} vec2 textureCoord;
5
6      ${e.varyingVertex} vec2 TexCoords;
7
8      void main()
9      {
10          gl_Position = vec4(position, 1.0);
11          TexCoords = textureCoord;
12      }`}function Ku(t){let e=G(t);return`${e.version}
13    precision highp float;
14    precision highp int;
15    precision highp sampler2D;
16    ${e.varyingFrag} vec2 TexCoords;
17    ${e.outputDeclaration}
18    const vec2 halfCR = vec2(0.5, 0.5);
19
20    // Custom vector types to handle higher dimenalities.
21    struct ivec5
22    {
23      int x;
24      int y;
25      int z;
26      int w;
27      int u;
28    };
29
30    struct ivec6
31    {
32      int x;
33      int y;
34      int z;
35      int w;
36      int u;
37      int v;
38    };
39
40    int imod(int x, int y) {
41      return x - y * (x / y);
42    }
43
44    `}function Ju(t,e){let r=G(t);return`
45  void main() {
46    int indices[${e}];
47    toVec(TexCoords, indices);
48    vec4 result = vec4(process(indices));
49    ${r.output} = result;
50  }
51  `}var bh,gh,ut=O(()=>{"use strict";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(t,e=t=>0,r){return new Promise((n,o)=>{let s=0,a=()=>{if(t()){n();return}let u=e(++s);if(null!=r&&s>=r){o();return}setTimeout(a,u)};a()})}function An(t){return ur("u">typeof t&&0!==t.length,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)}function Yu(t){return ur("u">typeof t&&0!==t.length,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)+"AtOutCoords"}function lr(t,e){return JSON.parse(JSON.stringify(t)),e}function fr(t,e){return e.map(e=>t[e]).join(", ")}function Bt(t){if(t<=1)return"int";if(2===t)return"ivec2";if(3===t)return"ivec3";if(4===t)return"ivec4";if(5===t)return"ivec5";if(6===t)return"ivec6";throw Error(`GPU for rank ${t} is not yet supported`)}function ne(t=6){return["x","y","z","w","u","v"].slice(0,t)}var pe=O(()=>{"use strict";Y()});function yh(t,e){return ne(e).map(e=>`${t}.${e}`)}function cr(t,e){return 1===e?[t]:yh(t,e)}function de(){return`
52    float getChannel(vec4 frag, int dim) {
53      int modCoord = imod(dim, 2);
54      return modCoord == 0 ? frag.r : frag.g;
55    }
56
57    float getChannel(vec4 frag, vec2 innerDims) {
58      vec2 modCoord = mod(innerDims, 2.);
59      return modCoord.x == 0. ?
60        (modCoord.y == 0. ? frag.r : frag.g) :
61        (modCoord.y == 0. ? frag.b : frag.a);
62    }
63  `}var He=O(()=>{"use strict";pe()});function Th(t,e,r){if(0===t)return"false";if(1===t)return`rc > ${e[0]}`;let n="";for(let o=t-2;o<t;o++)n+=`${r[o]} >= ${e[o-t+2]}`,o<t-1&&(n+="||");return n}function wh(t,e){let r=t.length;if(0===r)return"getA(), 0, 0, 0";if(1===r)return`getA(rc),
64            rc + 1 >= ${t[0]} ? 0. : getA(rc + 1),
65            0, 0`;let n="r, c",o="r, cp1",s="rp1, c",a="rp1, cp1",u="";if(r>2)for(let t=0;t<r-2;++t)u+=`${e[t]},`;return`getA(${u}${n}),
66          rEdge ? 0. : getA(${u}${s}),
67          cEdge ? 0. : getA(${u}${o}),
68          rEdge || cEdge ? 0. : getA(${u}${a})`}function vh(t,e,r,n){return 0===t||1===t?"":`
69    int r = ${e[t-2]};
70    int c = ${e[t-1]};
71    int rp1 = ${e[t-2]} + 1;
72    int cp1 = ${e[t-1]} + 1;
73    bool rEdge = rp1 >= ${n};
74    bool cEdge = cp1 >= ${r};
75    `}var Zu,xh,Qu,tl=O(()=>{"use strict";ut(),j(),pe(),He(),Zu={name:"pack",inputNames:["A"],inputTypes:[1]},xh=(t,e)=>{let r=G(t.session.backend.glContext.version),n=e.dims,o=n.length,s=e.dims.length,a=Bt(s),u=cr("rc",s),l=vh(s,u,n[n.length-2],n[n.length-1]),p;p=0===o?[1,1]:1===o?[n[0],1]:[n[s-1],n[s-2]];let c=Th(s,p,u),d=wh(n,u),h=`
76        void main() {
77          ${a} rc = getOutputCoords();
78
79          if(${c}) {
80            ${r.output} = vec4(0);
81          } else {
82            ${l}
83
84            ${r.output} = vec4(${d});
85          }
86        }
87      `;return{...Zu,hasMain:!0,output:{dims:e.dims,type:e.type,textureType:2},shaderSource:h}},Qu=(t,e)=>({...Zu,get:()=>xh(t,e)})});function fi(t){if(0===t.length)return[1,1,1];let e=1;for(let r=0;r<t.length-2;++r)e*=t[r];return[e,t.length>1?t[t.length-2]:1,t[t.length-1]]}function rl(t,e){return 0===t.length||0===e.length||(t.length<2||e.length<2?t[t.length-1]===e[e.length-1]:t[t.length-1]===e[e.length-1]&&t[t.length-2]===e[e.length-2])}function Oh(t){let e=B.computeStrides(t),r=["b","r","c"],n="index";return`
88    ivec3 inputCoordsFromReshapedOutCoords(int index) {
89      ${e.map((t,o)=>{let s=`int ${r[o]} = ${n} / ${t}`,a=o===e.length-1?`int ${r[o+1]} = ${n} - ${r[o]} * ${t}`:`index -= ${r[o]} * ${t}`;return`${s}; ${a};`}).join("")}
90      return ivec3(b, r, c);
91    }
92  `}function Sh(t){let e=B.computeStrides(t);return`
93  int getFlattenedIndex(ivec3 coords) {
94    // reverse y, z order
95    return coords.x * ${e[0]} + coords.z * ${e[1]} + coords.y;
96  }
97`}var Ih,_h,el,ci,nl=O(()=>{"use strict";Y(),ut(),j(),He(),Ih=t=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${t}`}),_h=(t,e,r,n)=>{let o=e.dims,s=n,a="";for(let t=0;t<4;t++){let e="";switch(t){case 0:e="outputCoords = rc;";break;
97case 1:e="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:e="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:e="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw Error()}a+=`
98        ${e}
99        ${t>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
100          int flattenedIndex = getFlattenedIndex(outputCoords);
101
102          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);
103          vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));
104
105          result[${t}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
106
107        ${t>0?"}":""}
108      `}let u=G(t.session.backend.glContext.version),l=`
109      ${Oh(o)}
110      ${Sh(s)}
111      ${de()}
112
113      void main() {
114        ivec3 rc = getOutputCoords();
115
116        vec4 result = vec4(0.0);
117
118        ivec3 outputCoords;
119        int rows = ${s[2]};
120        int cols = ${s[1]};
121
122        ${a}
123        ${u.output} = result;
124      }
125    `;return{...r,output:{dims:s,type:e.type,textureType:2},shaderSource:l,hasMain:!0}},el=(t,e,r)=>{let n=Ih(r);return{...n,get:()=>_h(t,e,n,r)}}}),ol=O(()=>{"use strict";ut(),j(),ci=(t,e)=>{let r=e.shape,n=G(t.session.backend.glContext.version),o=`
126    const float FLOAT_MAX = 1.70141184e38;
127    const float FLOAT_MIN = 1.17549435e-38;
128
129    bool isNaN(float val) {
130      return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;
131    }
132
133    highp vec4 encodeAsUint8(highp float v) {
134      if (isNaN(v)) {
135        return vec4(255, 255, 255, 255);
136      }
137
138      highp float av = abs(v);
139
140      if(av < FLOAT_MIN) {
141        return vec4(0.0, 0.0, 0.0, 0.0);
142      } else if(v > FLOAT_MAX) {
143        return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
144      } else if(v < -FLOAT_MAX) {
145        return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;
146      }
147
148      highp vec4 c = vec4(0,0,0,0);
149
150      highp float e = floor(log2(av));
151      highp float m = exp2(fract(log2(av))) - 1.0;
152
153      c[2] = floor(128.0 * m);
154      m -= c[2] / 128.0;
155      c[1] = floor(32768.0 * m);
156      m -= c[1] / 32768.0;
157      c[0] = floor(8388608.0 * m);
158
159      highp float ebias = e + 127.0;
160      c[3] = floor(ebias / 2.0);
161      ebias -= c[3] * 2.0;
162      c[2] += floor(ebias) * 128.0;
163
164      c[3] += 128.0 * step(0.0, -v);
165
166      return c / 255.0;
167    }
168
169    void main() {
170      float value = ${n.texture2D}(X,TexCoords).r;
171      ${n.output} = encodeAsUint8(value);
172    }`,s={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:r,type:e.tensor.type,textureType:3},shaderSource:o,hasMain:!0};return t.executeProgram(s,[e.tensor])}});function Ph(t,e){if(1===t)return"rc";let r="";for(let n=0;n<t;n++)r+=e[n],n<t-1&&(r+=",");return r}var il,Ah,al,Pn,Br,En,Cr,ul,pi,Dh,Dn,di,W,pl,dl,hl,Lh,$h,Ln,Ht,k,Nr,$n,sl=O(()=>{"use strict";ut(),j(),pe(),He(),il={name:"unpack",inputNames:["A"],inputTypes:[2]},Ah=(t,e)=>{let r=e.dims.length,n=cr("rc",r),o=n.slice(-2),s=Bt(r),a=de(),u=0===e.dims.length?"":Ph(r,n),l=r<=1?"rc":`vec2(${o.join(",")})`,p=G(t.session.backend.glContext.version),c=`
173    ${a}
174    void main() {
175      ${s} rc = getOutputCoords();
176
177       // Sample the texture with the coords to get the rgba channel value.
178       vec4 packedInput = getA(${u});
179
180       ${p.output} = vec4(getChannel(packedInput, ${l}), 0, 0, 0);
181     }
182   `;return{...il,hasMain:!0,output:{dims:e.dims,type:e.type,textureType:0},shaderSource:c}},al=(t,e)=>({...il,get:()=>Ah(t,e)})}),Fr=O(()=>{"use strict";Ut(),Pn=class{constructor(t,e=1){if(1===e)this.internalFormat=t.R32F,this.format=t.RED,this.textureType=t.FLOAT,this.channelSize=e;else if(4===e)this.internalFormat=t.RGBA32F,this.format=t.RGBA,this.textureType=t.FLOAT,this.channelSize=e;else throw Error(`Invalid number of channels: ${e}`)}encode(t,e){let r,n;return t.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),n=new Float32Array(t)),e*this.channelSize>t.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),n=t,r=this.allocate(e*this.channelSize),n.forEach((t,e)=>r[e]=t)):r=n=t,r}allocate(t){return new Float32Array(4*t)}decode(t,e){return 1===this.channelSize?t.filter((t,e)=>e%4==0).subarray(0,e):t.subarray(0,e)}},Br=class{constructor(t,e=1,r){if(1!==e&&4!==e)throw Error(`Invalid number of channels: ${e}`);this.internalFormat=t.RGBA,this.format=t.RGBA,this.channelSize=e,this.textureType=r||t.FLOAT}encode(t,e){let r=t;return 1===this.channelSize&&(tt.verbose("Encoder","Exploding into a larger array"),r=this.allocate(e),t.forEach((t,e)=>r[4*e]=t)),r}allocate(t){return new Float32Array(4*t)}decode(t,e){return 1===this.channelSize?t.filter((t,e)=>e%4==0).subarray(0,e):t.subarray(0,e)}},En=class{constructor(t,e=1){if(this.channelSize=4,1===e)this.internalFormat=t.ALPHA,this.format=t.ALPHA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=e;else if(4===e)this.internalFormat=t.RGBA,this.format=t.RGBA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=e;else throw Error(`Invalid number of channels: ${e}`)}encode(t,e){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}allocate(t){return new Uint8Array(t*this.channelSize)}
182decode(t,e){if(t instanceof Uint8Array)return t.subarray(0,e);throw Error(`Invalid array type: ${t.constructor}`)}}}),ll=O(()=>{"use strict";Y(),j(),Cr=(t,e,r)=>{let n=0===r||1===r?1:4,o=2===r,s=1===r||2===r,a=4===r?e.length-1:void 0,u=4===r?e.map((t,r)=>r===e.length-1?4*t:t):void 0;return pi(t,e,n,u,{isPacked:o,reverseWH:s,breakAxis:a})},ul=(t,e,r)=>{let n=Cr(t,e,r);return[n.width,n.height]},pi=(t,e,r=1,n,o)=>{let s=!!(o&&o.isPacked),[a,u]=t.computeTextureWH(s&&n||e,o),l=e.length,p=e.slice(0);if(0===l&&(p=[1]),1===r)n=e;else if(s){if(4!==r)throw Error("a packed texture must be 4-channel");n=e,l>0&&(p[l-1]=Math.ceil(p[l-1]/2)),l>1&&(p[l-2]=Math.ceil(p[l-2]/2))}else if(!n)throw Error("Unpacked shape is needed when using channels > 1");return{width:a,height:u,channels:r,isPacked:s,shape:p,strides:B.computeStrides(p),unpackedShape:n,reversedWH:o&&o.reverseWH}}}),cl=O(()=>{"use strict";Ut(),We(),Y(),tl(),nl(),ol(),sl(),Fr(),ll(),j(),Dh=(t,e)=>{let r=e.map(t=>`${t.unpackedShape.join(",")};${t.width}x${t.height}`).join("_"),n=t.name;return t.cacheHint&&(n+="["+t.cacheHint+"]"),n+=":"+r},Dn=class{constructor(t){this.session=t,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(t,e){return ul(this.session.layoutStrategy,t,e)}executeProgram(t,e){if(e.length<t.inputNames.length)throw Error(`Input size mustn't be less than ${t.inputNames.length}.`);if(t.inputNames.length!==t.inputTypes.length)throw Error("input names size does not match input types");let r=[];for(let n=0;n<t.inputNames.length;++n)r[n]=this.getOrCreateTextureData(e[n],t.inputTypes[n]);let n=Dh(t,r),o=this.session.programManager.getArtifact(n),s=o?o.programInfo:"function"==typeof t.get?t.get():t,a=Cr(this.session.layoutStrategy,s.output.dims,s.output.textureType),u=this.createTextureData(a,s.output.type);return o||(o=this.session.programManager.build(s,r,u),this.session.programManager.setArtifact(n,o)),this.runProgram(o,r,u),u}run(t,e){return this.executeProgram(t,e).tensor}runProgram(t,e,r){for(let r=0;r<e.length;++r)if(!!e[r].isPacked!=(2===t.programInfo.inputTypes[r]))throw Error(`input[${r}] property packed inconsistent`);if(!!r.isPacked!=(2===t.programInfo.output.textureType))throw Error("output property packed inconsistent");this.session.programManager.run(t,e,r)}getOrCreateTextureData(t,e){let r=this.getTextureData(t.dataId,2===e);if(!r&&(r=this.getTextureData(t.dataId,2!==e)))return 2===e?this.pack(r):this.unpack(r);if(!r){let n=Cr(this.session.layoutStrategy,t.dims,e);if(4===e){let r=t.dims;if(4===r.length){let n=[r[0],Math.ceil(r[1]*r[2]*r[3]/4)],o=Cr(this.session.layoutStrategy,n,e),s=t.numberData;if(r[1]*r[2]*r[3]%4!=0){let e=r[0],n=r[1]*r[2]*r[3],o=4*Math.ceil(1*n/4);s=new Float32Array(e*o);for(let r=0;r<e;++r){let e=r*n,a=r*o+r%1*n;s.set(t.numberData.subarray(e,e+n),a)}}return this.createTextureData(o,t.type,s,t,1)}}if(2===e){let e=pi(this.session.layoutStrategy,t.dims,1,[],{reverseWH:!0}),n=this.createTextureData(e,t.type,t.numberData,t,1);r=this.pack(n)}else r=this.createTextureData(n,t.type,t.numberData,t,1)}return r}createTextureDataFromLayoutBindTensor(t,e,r,n){return this.createTextureData(t,e,r,n,1)}createTextureData(t,e,r,n,o){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(t)}]`);let s=this.session.textureManager.createTextureFromLayout(e,t,r,o);return this.createTextureDataFromTexture(t,e,s,n)}reshapeUnpacked(t,e){let r=this.getOrCreateTextureData(t,0),n={channels:r.channels,height:r.height,width:r.width,shape:0!==e.length?e:[1],strides:B.computeStrides(e),unpackedShape:e};return this.createTextureDataFromTexture(n,t.type,r.texture).tensor}reshapePacked(t,e){let r=this.getOrCreateTextureData(t,2);if(rl(t.dims,e)){let n={channels:r.channels,height:r.height,width:r.width,shape:0!==e.length?e:[1],strides:B.computeStrides(e),unpackedShape:e,isPacked:!0};return this.createTextureDataFromTexture(n,t.type,r.texture).tensor}let n=fi(t.dims),o=fi(e),s=this.reshapePacked(t,n),a=this.run(el(this,s,o),[s]);return this.reshapePacked(a,e)}cast(t,e){let r=this.getOrCreateTextureData(t,0);return this.createTextureDataFromTexture(r,e,r.texture).tensor}createTextureDataFromTexture(t,e,r,n,o){let s={...t,tensor:n||new bt(t.unpackedShape,e,t=>this.readTexture(s),async t=>this.readTextureAsync(s),void 0,o),texture:r};return this.setTextureData(s.tensor.dataId,s,t.isPacked),s}getTextureData(t,e=!1){return this.session.isInitializer(t)?this.session.getTextureData(t,e):e?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,e,r=!1){this.session.isInitializer(t)?this.session.setTextureData(t,e,r):(r?this.packedTextureDataCache:this.unpackedTextureDataCache).set(t,e)}isTextureLayoutCached(t,e=!1){return!!this.getTextureData(t.dataId,e)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(t=>this.session.textureManager.releaseTexture(t)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(t=>this.session.textureManager.releaseTexture(t)),this.unpackedTextureDataCache=new Map}readTexture(t){return t.isPacked?this.readTexture(this.unpack(t)):this.session.backend.glContext.
182isFloat32DownloadSupported?this.session.textureManager.readTexture(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat(ci(this,t))}async readTextureAsync(t){return t.isPacked?this.readTextureAsync(this.unpack(t)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat(ci(this,t))}pack(t){return this.executeProgram(Qu(this,t.tensor),[t.tensor])}unpack(t){return this.executeProgram(al(this,t.tensor),[t.tensor])}}}),It=O(()=>{"use strict";di=class{constructor(t){Object.assign(this,t)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map(t=>`${this[t]}`).join(";")),this.key}},W=t=>new di(t)}),ml=O(()=>{"use strict";It(),ut(),j(),pl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},dl=(t,e,r)=>($h(e),[t.run({...pl,cacheHint:r.cacheKey,get:()=>Lh(t,e,r)},e)]),hl=t=>{let e=t.attributes.getFloat("epsilon",1e-5),r=t.attributes.getFloat("momentum",.9),n=t.attributes.getInt("spatial",1);return W({epsilon:e,momentum:r,spatial:n})},Lh=(t,e,r)=>{let n=G(t.session.backend.glContext.version),o=e[0].dims.length,[s,a]=t.calculateTextureWidthAndHeight(e[1].dims,0),u=`
183  float process(int[${o}] indices) {
184    vec2 position = offsetToCoords(indices[1], ${s}, ${a});
185    float scale = getColorAsFloat(${n.texture2D}(Scale, position));
186    float mean = getColorAsFloat(${n.texture2D}(Mean, position));
187    float variance = getColorAsFloat(${n.texture2D}(Variance, position));
188    float b = getColorAsFloat(${n.texture2D}(B, position));
189
190    return scale * ( (_A(indices) - mean) / sqrt(variance + float(${r.epsilon})) ) + b;
191  }`;return{...pl,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:u}},$h=t=>{if(!t||5!==t.length)throw Error("BatchNormalization requires 5 inputs.");let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4];if(e.dims.length<3||1!==r.dims.length||1!==n.dims.length||1!==o.dims.length||1!==s.dims.length||r.dims[0]!==e.dims[1]||n.dims[0]!==e.dims[1]||o.dims[
1910]!==e.dims[1]||s.dims[0]!==e.dims[1])throw Error("invalid input shape.");if("float32"!==e.type&&"float64"!==e.type||"float32"!==r.type&&"float64"!==r.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==o.type&&"float64"!==o.type||"float32"!==s.type&&"float64"!==s.type)throw Error("invalid input tensor types.")}}),Te=O(()=>{"use strict";Ln=class{constructor(t,e,r,n){this.glContext=t,this.programInfo=e,this.inputTextureLayouts=r,this.outputTextureLayout=n}},Ht=class{constructor(t){this.context=t}},k=class{constructor(t,e){this.routineBody=t,this.dependencies=e}},Nr=class{constructor(t,e,r){this.name=t,r?this.dependencies=r:this.dependencies=[],e&&(this.routineBody=e)}addDependency(t){t&&this.dependencies.push(t)}},$n=class{static returnOrderedNodes(t){if(!t||0===t.length)return[];if(1===t.length)return t;let e=new Set,r=new Set,n=[];return this.createOrderedNodes(t,e,r,n),n}static createOrderedNodes(t,e,r,n){for(let o=0;o<t.length;++o)this.dfsTraverse(t[o],e,r,n)}static dfsTraverse(t,e,r,n){if(!t||r.has(t.name))return;if(e.has(t.name))throw Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");e.add(t.name);let o=t.dependencies;if(o&&o.length>0)for(let t=0;t<o.length;++t)this.dfsTraverse(o[t],e,r,n);n.push(t),r.add(t.name),e.delete(t.name)}}});function Bh(){let t="add_";return{body:`
192  float ${t}(float a, float b) {
193    return a + b;
194  }
195  vec4 ${t}(vec4 v1, vec4 v2) {
196    return v1 + v2;
197  }
198  `,name:t,type:0}}function Fh(){let t="div_";return{body:`
199  float ${t}(float a, float b) {
200    return a / b;
201  }
202  vec4 ${t}(vec4 v1, vec4 v2) {
203    return v1 / v2;
204  }
205  `,name:t,type:0}}function Ch(){let t="mul_";return{body:`
206  float ${t}(float a, float b) {
207    return a * b;
208  }
209  vec4 ${t}(vec4 v1, vec4 v2) {
210    return v1 * v2;
211  }
212  `,name:t,type:0}}function Nh(){let t="sub_";return{body:`
213  float ${t}(float a, float b) {
214    return a - b;
215  }
216  vec4 ${t}(vec4 v1, vec4 v2) {
217    return v1 - v2;
218  }
219  `,name:t,type:0}}function Rh(){let t="equal_";return{body:`
220  float ${t}(float a, float b) {
221    return float(a == b);
222  }
223  vec4 ${t}(vec4 v1, vec4 v2) {
224    return vec4(equal(v1, v2));
225  }
226  `,name:t,type:0}}function Gh(){let t="greater_";return{body:`
227  float ${t}(float a, float b) {
228    return float(a > b);
229  }
230  vec4 ${t}(vec4 v1, vec4 v2) {
231    return vec4( v1.r > v2.r ,
232      v1.g > v2.g,
233      v1.b > v2.b,
234      v1.a > v2.a );
235  }
236  `,name:t,type:0}}function Mh(){let t="less_";return{body:`
237  float ${t}(float a, float b) {
238    return float(a < b);
239  }
240  vec4 ${t}(vec4 v1, vec4 v2) {
241    return vec4( v1.r < v2.r ,
242                v1.g < v2.g,
243                v1.b < v2.b,
244                v1.a < v2.a );
245  }
246  `,name:t,type:0}}function Uh(){let t="and_";return{body:`
247  float ${t}(float a, float b) {
248    return float( bool(a) && bool(b) );
249  }
250  vec4 ${t}(vec4 v1, vec4 v2) {
251    bvec4 b1 = bvec4(v1);
252    bvec4 b2 = bvec4(v2);
253    return vec4( b1.r && b2.r ,
254                b1.g && b2.g,
255                b1.b && b2.b,
256                b1.a && b2.a );
257  }
258  `,name:t,type:0}}function Vh(){let t="or_";return{body:`
259  float ${t}(float a, float b) {
260    return float( bool(a) || bool(b) );
261  }
262  vec4 ${t}(vec4 v1, vec4 v2) {
263    bvec4 b1 = bvec4(v1);
264    bvec4 b2 = bvec4(v2);
265    return vec4( b1.r || b2.r ,
266                b1.g || b2.g,
267                b1.b || b2.b,
268                b1.a || b2.a );
269  }
270  `,name:t,type:0}}function zh(){let t="xor_";return{body:`
271  float ${t}(float a, float b) {
272    return float( bool(a) ^^ bool(b) );
273  }
274  vec4 ${t}(vec4 v1, vec4 v2) {
275    bvec4 b1 = bvec4(v1);
276    bvec4 b2 = bvec4(v2);
277    return vec4( b1.r ^^ b2.r ,
278                b1.g ^^ b2.g,
279                b1.b ^^ b2.b,
280                b1.a ^^ b2.a );
281  }
282  `,name:t,type:0}}function Wh(){return qh("pow")}function Hh(){let t="prelu_";return{body:`
283  float ${t}(float a, float b) {
284    return a < 0.0 ? a * b: a;
285  }
286  vec4 ${t}(vec4 v1, vec4 v2) {
287    return vec4(
288      v1.r < 0.0 ? v1.r * v2.r: v1.r,
289      v1.g < 0.0 ? v1.g * v2.g: v1.g,
290      v1.b < 0.0 ? v1.b * v2.b: v1.b,
291      v1.a < 0.0 ? v1.a * v2.a: v1.a
292      );
293  }
294  `,name:t,type:0}}function qh(t){let e=`${t}_`;return{body:`
295  float ${e}(float a, float b) {
296    return ${t}(a, b);
297  }
298  vec4 ${e}(vec4 v1, vec4 v2) {
299    return ${t}(v1, v2);
300  }
301  `,name:e,type:0}}var qt,jh,bl,gl,yl,xl,Tl,wl,vl,Il,_l,Ol,Sl,Al,El,Dl,Kh,Jh,Yh,$l,kn,Bl,Zh,Qh,tm,Fl,em,rm,nm,Cl,om,Pl=O(()=>{"use strict";Y(),Te(),ut(),j(),qt=(t,e,r,n=e[0].type,o)=>{let s=t.session.pack?2:0;return{name:r.name,inputNames:["A","B"],inputTypes:[s,s],cacheHint:o,get:()=>jh(t,e,r,n)}},jh=(t,e,r,n=e[0].type)=>{let o=t.session.pack?2:0,s=!B.areEqual(e[0].dims,e[1].dims),a=e[0].dims,u=t.session.pack;if(s){let s=kt.calcShape(e[0].dims,e[1].dims,!1);if(!s)throw Error("Can't perform binary op on the given tensors");let l=(a=s).length,p=0!==e[0].dims.length?e[0].dims.length:1,c=0!==e[1].dims.length?e[1].dims.length:1,d=0!==e[0].dims.length?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",h=0!==e[1].dims.length?"bcastIndices_B(indices, bindices);
301":"bindices[0] = 0;",f=G(t.session.backend.glContext.version),g=u?`
302      ${r.body}
303      void main() {
304        vec4 a = getAAtOutCoords();
305        vec4 b = getBAtOutCoords();
306        vec4 result = ${r.name}(a, b);
307        ${f.output} = result;
308      }`:`
309      ${r.body}
310      float process(int indices[${l}]) {
311        int aindices[${p}];
312        int bindices[${c}];
313        ${d}
314        ${h}
315        return ${r.name}(_A(aindices), _B(bindices));
316      }`;return{name:r.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:a,type:n,textureType:o},shaderSource:g,hasMain:u}}let l=G(t.session.backend.glContext.version),p=`
317    ${r.body}
318    void main() {
319      vec4 v1 = ${l.texture2D}(A, TexCoords);
320      vec4 v2 = ${l.texture2D}(B, TexCoords);
321      vec4 result = ${r.name}(v1, v2);
322      ${l.output} = result;
323    }
324    `;return{name:r.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:e[0].dims,type:n,textureType:o},shaderSource:p,hasMain:!0}},bl=(t,e)=>[t.run(qt(t,e,Bh()),e)],gl=(t,e)=>[t.run(qt(t,e,Uh(),"bool"),e)],yl=(t,e)=>[t.run(qt(t,e,Fh()),e)],xl=(t,e)=>[t.run(qt(t,e,Rh(),"bool"),e)],Tl=(t,e)=>[t.run(qt(t,e,Gh(),"bool"),e)],wl=(t,e)=>[t.run(qt(t,e,Mh(),"bool"),e)],vl=(t,e)=>[t.run(qt(t,e,Ch()),e)],Il=(t,e)=>[t.run(qt(t,e,Vh(),"bool"),e)],_l=(t,e)=>[t.run(qt(t,e,Wh()),e)],Ol=(t,e)=>[t.run(qt(t,e,Hh()),e)],Sl=(t,e)=>[t.run(qt(t,e,Nh()),e)],Al=(t,e)=>[t.run(qt(t,e,zh(),"bool"),e)]}),Ll=O(()=>{"use strict";Y(),El=(t,e,r)=>(Kh(e),[t.cast(e[0],r)]),Dl=t=>At.tensorDataTypeFromProto(t.attributes.getInt("to")),Kh=t=>{if(!t||1!==t.length)throw Error("Cast requires 1 input.");if("string"===t[0].type)throw Error("Invalid input type.")}}),kl=O(()=>{"use strict";ut(),j(),pe(),He(),Jh=(t,e)=>({name:"Concat (packed)",inputNames:Array.from({length:t},(t,e)=>`X${e}`),inputTypes:Array(t).fill(2),cacheHint:e}),Yh=(t,e,r,n)=>{let o=r[0].dims.slice();if(n>=o.length||n<-1*o.length)throw Error("axis specified for concat doesn't match input dimensionality");n<0&&(n=o.length+n);let s=o.slice(0);for(let t=1;t<r.length;t++){let e=r[t].dims.slice();for(let t=0;t<o.length;t++)if(t===n)s[n]+=e[t];else if(o[t]!==e[t])throw Error("non concat dimensions must match")}let a=s.length,u=cr("coords",a),l=Bt(a),p=de(),c=r.map(t=>t.dims),d=ne(a),h=Array(c.length-1);h[0]=c[0][n];for(let t=1;t<h.length;t++)h[t]=h[t-1]+c[t][n];let f=d[n],g=d.slice(-2),m=d.join(),b=`if (${f} < ${h[0]}) {
325        return getChannel(
326            getX0(${m}), vec2(${g.join()}));
327        }`;for(let t=1;t<h.length;t++){let e=h[t-1];b+=`
328            if (${f} < ${h[t]}  && ${f} >= ${h[t-1]}) {
329              return getChannel(
330                getX${t}(${kn(d,f,e)}),
331                vec2(${kn(g,f,e)}));
332            }`}let y=h.length,x=h[h.length-1];b+=`
333            return getChannel(
334              getX${y}(${kn(d,f,x)}),
335              vec2(${kn(g,f,x)}));`;let v=G(t.session.backend.glContext.version),T=`
336          ${p}
337          float getValue(${d.map(t=>"int "+t)}) {
338            ${b}
339          }
340
341          void main() {
342            ${l} coords = getOutputCoords();
343            int lastDim = coords.${d[a-1]};
344            coords.${d[a-1]} = coords.${d[a-2]};
345            coords.${d[a-2]} = lastDim;
346
347            vec4 result = vec4(getValue(${u}), 0., 0., 0.);
348
349            ${u[a-1]} = ${u[a-1]} + 1;
350            if (${u[a-1]} < ${s[a-1]}) {
351              result.g = getValue(${u});
352            }
353
354            ${u[a-2]} = ${u[a-2]} + 1;
355            if (${u[a-2]} < ${s[a-2]}) {
356              result.a = getValue(${u});
357            }
358
359            ${u[a-1]} = ${u[a-1]} - 1;
360            if (${u[a-2]} < ${s[a-2]} &&
361                ${u[a-1]} < ${s[a-1]}) {
362              result.b = getValue(${u});
363            }
364            ${v.output} = result;
365          }
366        `;return{...e,output:{dims:s,type:r[0].type,textureType:2},shaderSource:T,hasMain:!0}},$l=(t,e,r)=>{let n=Jh(e.length,r.cacheKey);return{...n,get:()=>Yh(t,n,e,r.axis)}},kn=(t,e,r)=>{let n=t.indexOf(e);return t.map((t,e)=>e===n?`${t} - ${r}`:t).join()}}),Nl=O(()=>{"use strict";It(),j(),kl(),Bl=(t,e,r)=>(om(e),t.session.pack&&e[0].dims.length>1?[t.run($l(t,e,r),e)]:[t.run(tm(t,e,r),e)]),Zh=(t,e)=>({name:"Concat",inputNames:Array.from({length:t},(t,e)=>`X${e}`),inputTypes:Array(t).fill(0),cacheHint:e}),Qh=(t,e,r,n)=>{let o=r[0].dims.slice();if(n>
366=o.length||n<-1*o.length)throw Error("axis specified for concat doesn't match input dimensionality");n<0&&(n=o.length+n);let s=o.slice(0);for(let t=1;t<r.length;t++){let e=r[t].dims.slice();for(let t=0;t<o.length;t++)if(t===n)s[n]+=e[t];else if(o[t]!==e[t])throw Error("non concat dimensions must match")}let a=s.length,u=Array(r.length),l=0;for(let t=0;t<u.length;++t)l+=r[t].dims[n],u[t]=l;let p="";p=r.length<5?Fl(u):em(u);let c=rm(r.length,a),d=nm(u),h=`
367        ${c}
368        ${d}
369        ${p}
370        float process(int indices[${a}]) {
371          int textureIndex = getTextureWhereDataResides (indices[${n}]);
372
373          if(textureIndex != 0) {
374            indices[${n}] = indices[${n}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
375          }
376
377          return fetchDataFromCorrectTexture(textureIndex, indices);
378        }`;return{...e,output:{dims:s,type:r[0].type,textureType:0},shaderSource:h}},tm=(t,e,r)=>{let n=Zh(e.length,r.cacheKey);return{...n,get:()=>Qh(t,n,e,r.axis)}},Fl=t=>`int getTextureWhereDataResides(int index) {
379      ${t.map((t,e)=>`if(index<${t}) {return ${e};}
380`).join("")}
381    }`,em=t=>Fl(t),rm=(t,e)=>{let r=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${e}]) {`];for(let e=0;e<t;++e)0===e?r.push(`	if (textureIndex == ${e}) { return _X${e}(indices); }`):e===t-1?r.push(`	else { return _X${e}(indices); }`):r.push(`	else if (textureIndex == ${e}) { return _X${e}(indices); }`);return r.push("	}"),r.join(`
382`)},nm=t=>{let e=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let r=0;r<t.length;++r)0===r?e.push(`	if (index == ${r}) { return ${t[r]}; }`):r===t.length-1?e.push(`	else { return ${t[r]}; }`):e.push(`	else if (index == ${r}) { return ${t[r]}; }`);return e.push("	}"),e.join(`
383`)},Cl=t=>W({axis:t.attributes.getInt("axis")}),om=t=>{if(!t||t.length<1)throw Error("too few inputs");let e=t[0].type,r=t[0].dims.length;if("string"===e)throw Error("string tensor is not supported yet");for(let n of t){if(n.type!==e)throw Error("input tensors should be one type");if(n.dims.length!==r)throw 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(t){let e="elu";return{body:`
384  const float alpha = float(${t});
385
386  float ${e}_(float a) {
387    return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
388  }
389  vec4 ${e}_(vec4 v) {
390    return vec4(${e}_(v.x), ${e}_(v.y), ${e}_(v.z), ${e}_(v.w));
391  }
392  `,name:e,type:0}}function pm(){return jt("exp")}function dm(){return jt("floor")}function hi(t,e){let r="clip";return{body:`
393  const float min = float(${t});
394  const float max = float(${e});
395
396  float ${r}_(float a) {
397    return clamp(a, min, max);
398  }
399  vec4 ${r}_(vec4 v) {
400    return clamp(v, min, max);
401  }
402  `,name:r,type:0}}function hm(){let t="indentity";return{body:`
403  float ${t}_(float a) {
404    return a;
405  }
406  vec4 ${t}_(vec4 v) {
407    return v;
408  }
409  `,name:t,type:0}}function mm(t){let e="leakyRelu";return{body:`
410  const float alpha = float(${t});
411
412  float ${e}_(float a) {
413    return a < 0.0 ? a * alpha : a;
414  }
415  vec4 ${e}_(vec4 v) {
416    return vec4(${e}_(v.x), ${e}_(v.y), ${e}_(v.z), ${e}_(v.w));
417  }
418  `,name:e,type:0}}function bm(){return jt("log")}function gm(){let t="neg";return{body:`
419  float ${t}_(float a) {
420    return -a;
421  }
422  vec4 ${t}_(vec4 v) {
423    return -v;
424  }
425  `,name:t,type:0}}function ym(){let t="not";return{body:`
426  float ${t}_(float a) {
427    return float( ! bool(a) );
428  }
429  bool ${t}_(bool a) {
430    return !a;
431  }
432  vec4 ${t}_(vec4 v) {
433    return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
434  }
435  bvec4 ${t}_(bvec4 v) {
436    return bvec4(!v.x, !v.y, !v.z, !v.w);
437  }
438  `,name:t,type:0}}function xm(){return jt("sin")}function mi(){let t="relu";return{body:`
439  float ${t}_(float a) {
440    return max( a, 0.0 );
441  }
442  vec4 ${t}_(vec4 v) {
443    return max( v, 0.0 );
444  }
445  `,name:t,type:0}}function bi(){let t="sigmoid";return{body:`
446  float ${t}_(float a) {
447    return 1.0 / (1.0 + exp(-a));
448  }
449  vec4 ${t}_(vec4 v) {
450    return 1.0 / (1.0 + exp(-v));
451  }
452  `,name:t,type:0}}function Tm(){return jt("sqrt")}function wm(){return jt("tan")}function vm(){let t="tanh";return{body:`
453  float ${t}_(float a) {
454    a = clamp(a, -10., 10.);
455    a = exp(2.*a);
456    return (a - 1.) / (a + 1.);
457  }
458  vec4 ${t}_(vec4 v) {
459    v = clamp(v, -10., 10.);
460    v = exp(2.*v);
461    return (v - 1.) / (v + 1.);
462  }
463  `,name:t,type:0}}function jt(t){return{body:`
464  float ${t}_(float a) {
465    return ${t}(a);
466  }
467  vec4 ${t}_(vec4 v) {
468    return ${t}(v);
469  }
470  `,name:t,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(()=>{"use strict";It(),Y(),Te(),ut(),j(),Im=(t,e,r,n)=>{let o=t.session.pack?2:0,s=G(t.session.backend.glContext.version);return{...e,output:{dims:r.dims,type:r.type,textureType:o},shaderSource:`
471     ${n.body}
472     void main() {
473       vec4 v = ${s.texture2D}(A, TexCoords);
474       v = ${n.name}_(v);
475       ${s.output} = v;
476     }
477     `,hasMain:!0}},dt=(t,e,r,n)=>{let o=t.session.pack?2:0,s={name:r.name,inputTypes:[o],inputNames:["A"],cacheHint:n};return{...s,get:()=>Im(t,s,e,r)}},Rl=(t,e)=>[t.run(dt(t,e[0],im()),e)],Gl=(t,e)=>[t.run(dt(t,e[0],am()),e)],Ml=(t,e)=>[t.run(dt(t,e[0],sm()),e)],Ul=(t,e)=>[t.run(dt(t,e[0],um()),e)],gi=(t,e,r)=>[t.run(dt(t,e[0],hi(r.min,r.max),r.cacheKey),e)],Vl=t=>W({min:t.attributes.getFloat("min",Ve),max:t.attributes.getFloat("max",ze)}),zl=(t,e)=>{let r=_m(t,e);return gi(t,[e[0]],r)},_m=(t,e)=>{if(e.length>=3&&(!t.session.isInitializer(e[1].dataId)||!t.session.isInitializer(e[2].dataId)))throw Error("dynamic clip attributes are not allowed");let r=e.length>=3?e[1].numberData[0]:Ve,n=e.length>=3?e[2].numberData[0]:ze;return W({min:r,max:n})},Wl=(t,e)=>[t.run(dt(t,e[0],lm()),e)],Hl=(t,e)=>[t.run(dt(t,e[0],fm()),e)],ql=(t,e,r)=>[t.run(dt(t,e[0],cm(r.alpha),r.cacheKey),e)],jl=t=>W({alpha:t.attributes.getFloat("alpha",1)}),Xl=(t,e)=>[t.run(dt(t,e[0],pm()),e)],Kl=(t,e)=>[t.run(dt(t,e[0],dm()),e)],yi=(t,e)=>[t.run(dt(t,e[0],hm()),e)],Jl=(t,e,r)=>[t.run(dt(t,e[0],mm(r.alpha),r.cacheKey),e)],Yl=t=>W({alpha:t.attributes.getFloat("alpha",.01)}),Zl=(t,e)=>[t.run(dt(t,e[0],bm()),e)],Ql=(t,e)=>[t.run(dt(t,e[0],gm()),e)],tf=(t,e)=>[t.run(dt(t,e[0],ym()),e)],ef=(t,e)=>[t.run(dt(t,e[0],mi()),e)],rf=(t,e)=>[t.run(dt(t,e[0],bi()),e)],nf=(t,e)=>[t.run(dt(t,e[0],xm()),e)],of=(t,e)=>[t.run(dt(t,e[0],Tm()),e)],af=(t,e)=>[t.run(dt(t,e[0],wm()),e)],sf=(t,e)=>[t.run(dt(t,e[0],vm()),e)]});function he(t){let e;switch(t.activation){case"Relu":e=mi();break;case"Sigmoid":e=bi();break;case"Clip":e=hi(t.clipMin,t.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let r=e.name;return{activationFunction:e.body,applyActivation:`value = ${r}_(value);`}}var pr,Sm,Am,uf,Pm,Em,ff,qe=O(()=>{"use strict";Y(),xi(),pr=t=>{let e=t.getString("activation","");if("Clip"===e){let[r,n]=t.getFloats("activation_params",[Ve,ze]);return{activation:e,clipMax:n,clipMin:r,activationCacheKey:`${e}:${r},${n}`}}return{activation:e,activationCacheKey:e}}}),lf=O(()=>{"use strict";Ut(),ut(),j(),Bn(),qe(),Sm=(t,e)=>({name:"GroupedConv",inputNames:t?["X","W","Bias"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:e}),Am=(t,e,r,n)=>{let o=e.length>2?"value += getBias(output_channel);":"",s=e[0].dims.slice(),a=e[1].dims.slice(),u=a[0]/n.group;tt.verbose("GroupedConv",`autpPad:${n.autoPad}, dilations:${n.dilations}, group:${n.group}, kernelShape:${n.kernelShape}, pads:${n.pads}, strides:${n.strides}`);let l=dr(s,a,n.dilations,n.pads,n.strides),p=G(t.session.backend.glContext.version),{activationFunction:c,applyActivation:d}=he(n),h=`
478  const ivec2 strides = ivec2(${n.strides[0]}, ${n.strides[1]});
479  const ivec2 pads = ivec2(${n.pads[0]}, ${n.pads[1]});
480  ${c}
481  void main() {
482    ivec4 coords = getOutputCoords();
483    int batch = coords.x;
484    int output_channel = coords.y;
485    ivec2 xRCCorner = coords.zw * strides - pads;
486    int group_id = output_channel / ${u};
487
488    float value = 0.0;
489    for (int wInChannel = 0; wInChannel < ${a[1]}; wInChannel++) {
490      int input_channel = group_id * ${a[1]} + wInChannel;
491      for (int wHeight = 0; wHeight < ${a[2]}; wHeight++) {
492        int xHeight = xRCCorner.x + wHeight * ${n.dilations[0]};
493
494        if (xHeight < 0 || xHeight >= ${s[2]}) {
495          continue;
496        }
497
498        for (int wWidth = 0; wWidth < ${a[3]}; wWidth++) {
499          int xWidth = xRCCorner.y + wWidth * ${n.dilations[1]};
500          if (xWidth < 0 || xWidth >= ${s[3]}) {
501            continue;
502          }
503
504          float xVal = getX(batch, input_channel, xWidth, xHeight);
505          float wVal = getW(output_channel, wInChannel, wWidth, wHeight);
506          value += xVal*wVal;
507        }
508      }
509    }
510    ${o}
511    ${d}
512    ${p.output} = vec4(value, .0, .0, .0);
513  }
514`;return{...r,output:{dims:l,type:e[0].type,textureType:0},shaderSource:h,hasMain:!0}},uf=(t,e,r)=>{let n=Sm(e.length>
5142,r.cacheKey);return{...n,get:()=>Am(t,e,n,r)}}}),cf=O(()=>{"use strict";ut(),j(),He(),Pm=t=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:t}),Em=(t,e,r,n,o,s)=>{let a=r.dims,u=n.dims,l=2,p=3,c=o.length,d=[u[1]*u[2]*u[3],o[2]*o[3]],h=u[2]*u[3],f=de(),g=G(t.session.backend.glContext.version),m="";for(let t=0;t<=1;t++)for(let e=0;e<=1;e++)m+=`
515            blockIndex = rc.x + ${e};
516            pos = rc.y + ${t};
517
518            if(blockIndex < ${d[1]} && pos < ${d[0]}) {
519              offsetY = int(blockIndex / (${o[c-1]})) * ${s.strides[0]} -
520                ${s.pads[0]};
521              d0 = offsetY + ${s.dilations[0]} * (imod(pos, ${h}) / ${u[2]});
522
523              if(d0 < ${a[l]} && d0 >= 0) {
524                offsetX = imod(blockIndex, ${o[c-1]}) * ${s.strides[1]} -
525                  ${s.pads[1]};
526                d1 = offsetX + ${s.dilations[1]} * imod(imod(pos, ${h}), ${u[2]});
527
528                if(d1 < ${a[p]} && d1 >= 0) {
529
530                  ch = int(float(pos)/ ${h}.);
531                    innerDims = vec2(d0, d1);
532                    result[${2*t+e}] = getChannel(
533                      getA(0, ch, int(innerDims.x),
534                      int(innerDims.y)), innerDims);
535                }
536              }
537            }
538
539          `;let b=`
540      ${f}
541
542      void main() {
543        ivec2 rc = getOutputCoords();
544          vec4 result = vec4(0.0);
545          int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
546          vec2 innerDims;
547          ${m}
548          ${g.output} = result;
549      }
550            `;return{...e,output:{dims:d,type:r.type,textureType:2},shaderSource:b,hasMain:!0}},ff=(t,e,r,n,o)=>{let s=Pm(o.cacheKey);return{...s,get:()=>Em(t,s,e,r,n,o)}}});function Lm(t,e,r){let n=e[0].dims,o=e[1].dims,s=kt.calcShape(n,o,!0);if(!s)throw Error("Can't use matmul on the given tensors");let a=Bt(s.length),u=ne(),{activationFunction:l,applyActivation:p}=he(r),c=e.length>2,d=c?"value += getBiasForMatmul();":"",h=c?`${wi(a,u,e[2].dims,s,!1)}`:"",f=s.length,g=n.length,m=o.length,b=n[n.length-1],y=`
551    ${l}
552    ${h}
553    float process(int indices[${f}]) {
554        int a[${g}];
555        int b[${m}];
556        bcastMatmulIndices_A(indices, a);
557        bcastMatmulIndices_B(indices, b);
558
559        float value;
560        for (int k=0; k<${b}; ++k) {
561            a[${g-1}] = k;
562            b[${m-2}] = k;
563            value += _A(a) * _B(b);
564        }
565        ${d}
566        ${p}
567        return value;
568    }`;return{...t,output:{dims:s,type:e[0].type,textureType:0},shaderSource:y}}function Ti(t,e){let r=Dm(t.length>2,e.activationCacheKey);return{...r,get:()=>Lm(r,t,e)}}function wi(t,e,r,n,o){let s="",a=r.length,u=n.length,l=u-a;s=u<2&&a>0?"coords":r.map((t,r)=>`coords.${e[r+l]}`).join(", ");let p=kt.getBroadcastDims(r,n).map(t=>`coords.${e[t+l]} = 0;`).join(`
569`),c=1===B.size(r),d="vec4(outputValue.xx, outputValue.yy)";return c&&(d="vec4(outputValue.x)"),o?`
570vec4 getBiasForMatmul() {
571  ${t} coords = getOutputCoords();
572  ${p}
573  vec4 outputValue = getBias(${s});
574  return ${d};
575}`:`
576float getBiasForMatmul() {
577  ${t} coords = getOutputCoords();
578  ${p}
579  return getBias(coords.x);
580}`}var pf,df,Dm,$m,Fn=O(()=>{"use strict";Y(),j(),pe(),qe(),vi(),pf=(t,e,r)=>($m(e),t.session.pack?[t.run(Cn(t,e,r),e)]:[t.run(Ti(e,r),e)]),df=t=>pr(t.attributes),Dm=(t,e)=>({name:"MatMul",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[0,0,0]:[0,0],cacheHint:e}),$m=t=>{if(!t||2!==t.length)throw Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw Error("shared dimension does not match.");if("float32"!==t[0].type&&"float64"!==t[0].type||"float32"!==t[1].type&&"float64"!==t[1].type)throw Error("inputs should be float type");if(t[0].type!==t[1].type)throw Error("inputs types should match")}});function Fm(t,e,r,n){let o=[],s=[],a=r[0].dims,u=r[1].dims,l=a.length,p=u.length,c=n.length,d=c-l,h=c-p;(o=a.map((t,r)=>`coords.${e[r+d]}`))[l-1]="i*2",o.join(", "),(s=u.map((t,r)=>`coords.${e[r+h]}`))[p-2]="i*2",s.join(", ");let f=kt.getBroadcastDims(a,n),g=kt.getBroadcastDims(u,n),m=f.map(t=>`coords.${e[t+d]} = 0;`).join(`
581`),b=g.map(t=>`coords.${e[t+h]} = 0;`).join(`
582`),y=`int lastDim = coords.${e[c-1]};
583  coords.${e[c-1]}
583 = coords.${e[c-2]};
584  coords.${e[c-2]} = lastDim;`;return`
585vec4 getAAtOutCoordsMatmul(int i) {
586  ${t} coords = getOutputCoords();
587  ${y}
588  ${m}
589  vec4 outputValue = getA(${o});
590  return outputValue;
591}
592
593vec4 getBAtOutCoordsMatmul(int i) {
594  ${t} coords = getOutputCoords();
595  ${y}
596  ${b}
597  vec4 outputValue = getB(${s});
598  return outputValue;
599}`}function Cm(t,e){let r="";for(let n=0;n<e-2;n++)r+=`rc.${t[n]}, `;return r+`rc.${t[e-2]}, i*2`}function Nm(t,e){let r="";for(let n=0;n<e-2;n++)r+=`rc.${t[n]}, `;return r+`i*2, rc.${t[e-1]}`}var km,Bm,Cn,hf,Rm,Gm,bf,Ii,Mm,Um,gf,dr,Oi,Vm,zm,Wm,Hm,Si,qm,jm,Xm,Km,xf,Jm,Ym,Zm,Qm,tb,eb,Tf,rb,vf,je,If,nb,_f,ob,ib,ab,Of,Sf,sb,Pf,Ef,ub,Pe,Lf,$f,lb,fb,cb,pb,Ai,Bf,Ff,Cf,db,hb,mb,Rf,Gf,bb,gb,yb,xb,Tb,Vf,zf,Uf,wb,vb,Ib,_b,Ob,Sb,vi=O(()=>{"use strict";Y(),ut(),j(),pe(),qe(),Fn(),km=(t,e)=>({name:"MatMul (packed)",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[2,2,2]:[2,2],cacheHint:e}),Bm=(t,e,r,n)=>{let o=r.length>2,s=o?"value += getBiasForMatmul();":"",a=r[0].dims,u=r[1].dims,l=kt.calcShape(a,u,!0),p=!B.areEqual(r[0].dims,r[1].dims);if(!l)throw Error("Can't use matmul on the given tensors");let c=Math.ceil(a[a.length-1]/2),d=a.length,h=u.length,f=G(t.session.backend.glContext.version),g=Bt(l.length),m=l.length,b=ne(),{activationFunction:y,applyActivation:x}=he(n),v=o?`${wi(g,b,r[2].dims,l,!0)}`:"",T=p?`${Fm(g,b,r,l)}`:"",_=p?"getAAtOutCoordsMatmul(i)":`getA(${Cm(b,d)})`,w=p?"getBAtOutCoordsMatmul(i)":`getB(${Nm(b,h)})`,O=p?"":`${g} rc =
600          getOutputCoords(); int lastDim = rc.${b[m-1]}; rc.${b[m-1]} =
601          rc.${b[m-2]}; rc.${b[m-2]} = lastDim;
602      `,S=`
603            ${T}
604            ${v}
605            ${y}
606            void main() {
607              ${O}
608
609              vec4 value = vec4(0);
610              for (int i = 0; i < ${c}; i++) {
611                vec4 a = ${_};
612                vec4 b = ${w};
613
614                value += (a.rrbb * b.rgrg);
615                value += (a.ggaa * b.baba);
616              }
617              ${s}
618              ${x}
619              ${f.output} = value;
620            }`;return{...e,output:{dims:l,type:r[0].type,textureType:2},shaderSource:S,hasMain:!0}},Cn=(t,e,r)=>{let n=km(e.length>2,r.activationCacheKey);return{...n,get:()=>Bm(t,n,e,r)}}}),mf=O(()=>{"use strict";Bn(),cf(),vi(),hf=(t,e,r)=>{let n=e[0].dims,o=e[1].dims,s=dr(n,o,r.dilations,r.pads,r.strides),a=t.run(ff(t,e[0],e[1],s,r),[e[0]]),u=t.reshapePacked(e[1],[o[0],o[1]*o[2]*o[3]]),l=3===e.length?[u,a,e[2]]:[u,a],p=t.run(Cn(t,l,r),l);return t.reshapePacked(p,s)}}),_i=O(()=>{"use strict";j(),Rm=t=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:t}),Gm=(t,e,r,n,o,s)=>{let a=r.dims,u=n.dims,l=o.length,p=Ii(a,u,o,4),c=`
621        const int XC = ${a[1]};
622        const int XH = ${a[2]};
623        const int XW = ${a[3]};
624        const int KH = ${s.kernelShape[0]};
625        const int KW = ${s.kernelShape[1]};
626        const int dilationH = ${s.dilations[0]};
627        const int dilationW = ${s.dilations[1]};
628        const int strideH = ${s.strides[0]};
629        const int strideW = ${s.strides[1]};
630        const int padH = ${s.pads[0]};
631        const int padW = ${s.pads[1]};
632        const int KHKW = KH*KW;
633        const int XCKHKW = XC * KHKW;
634        const int outputChannels = 4;
635        vec4 process(int indices[${l}]) {
636          int b  = indices[0]; // batch size
637          int oh = indices[1] * strideH - padH; //output height
638          int ow = indices[2] * strideW - padW; //output width
639          int p = indices[3] * outputChannels; //patch
640          vec4 value = vec4(0.0);
641          for(int i=0; i < outputChannels; ++i) {
642            if(p < XCKHKW) {
643              int patchC = p / KHKW;
644              int patchH = (p - patchC*KHKW) / KW;
645              int patchW = (p - patchC*KHKW) - patchH * KW;
646              int xh2 = oh + patchH * dilationH;
647              int xw2 = ow + patchW * dilationW;
648              int x[${a.length}];
649              x[0] = b;
650              x[1] = patchC;
651              x[2] = xh2;
652              x[3] = xw2;
653              if(xh2 >= 0 &&
654                  xh2 < XH &&
655                  xw2 >= 0 &&
656                  xw2 < XW) {
657                value[i] = _X(x);
658              }
659            }
660            ++p;
661          }
662          return value;
663        }
664        `;return{...e,output:{dims:p,type:r.type,textureType:4},shaderSource:c}},bf=(t,e,r,n,o)=>{let s=Rm(o.cacheKey);return{...s,get:()=>Gm(t,s,e,r,n,o)}},Ii=(t,e,r,n=4)=>[r[0],r[2],r[3],Math.ceil(t[1]*e[2]*e[3]/n)]}),yf=O(()=>{"use strict";Y(),ut(),j(),qe(),_i(),Mm=(t,e)=>({name:"ConvDotProduct",inputNames:t?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:t?[0,4,0]:[0,4],cacheKey:e.activationCacheKey}),Um=(t,e,r,n,o)=>{let s=r[0].dims,a=r[1].dims,u=[a[0],Math.ceil(s[1]*a[2]*a[3]/4)],l=Ii(s,a,n),[p,c]=t.calculateTextureWidthAndHeight(u,4),d=B.computeStrides(l),[h,f]=t.calculateTextureWidthAndHeight(l,4),g=n.length,m=r.length<3?"0.0":"_B(b)",b=Math.ceil(s[1]*a[2]*a[3]/4),{activationFunction:y,applyActivation:x}=he(o),v=G(t.session.backend.glContext.version),T=`
665${y}
666float process(int indices[${g}]) {
667  int b[1];
668  b[0] = indices[1];
669  int im2col[4];
670  im2col[0] = indices[0];
671  im2col[1] = indices[2];
672  im2col[2] = indices[3];
673  int im2colOffset = im2col[0] * ${d[0]} + im2col[1] * ${d[1]} + im2col[2] * ${d[2]};
674  int kernelOffset = indices[1] * ${u[1]};
675  float value = ${m};
676  for (int i = 0; i < ${b}; ++i) {
677    vec2 im2colCoords = offsetToCoords(im2colOffset, ${h}, ${f});
678    vec2 kernelCoords = offsetToCoords(kernelOffset, ${p}, ${c});
679    value += dot(${v.texture2D}(Im2Col, im2colCoords), ${v.texture2D}(K, kernelCoords));
680    ++im2colOffset;
681    ++kernelOffset;
682  }
683  ${x}
684  return value;
685}`;return{...e,output:{dims:n,type:r[0].type,textureType:0},shaderSource:T}},gf=(t,e,r,n)=>{let o=Mm(e.length>2,n);return{...o,get:()=>Um(t,o,e,r,n)}}}),Bn=O(()=>{"use strict";It(),Y(),lf(),mf(),yf(),qe(),_i(),Fn(),dr=(t,e,r,n,o)=>{let s=t[0],a=t.slice(2),u=a.length,l=e[0],p=e.slice(2).map((t,e)=>t+(t-1)*(r[e]-1));return[s,l].concat(...a.map((t,e)=>t+n[e]+n[e+u]).map((t,e)=>Math.floor((t-p[e]+o[e])/o[e])))},Oi=(t,e,r)=>(qm(e,r),Vm(t,e,r)),Vm=(t,e,r)=>{let n=Hm(r,e),o=t.session.pack,s=1===n.kernelShape[0]&&1===n.kernelShape[1];return n.group>1?[t.run(uf(t,e,n),e)]:s&&o?[zm(t,e,n)]:o&&4===e[0].dims.length&&1===e[0].dims[0]&&!s?[hf(t,e,n)]:[Wm(t,e,n)]},zm=(t,e,r)=>{let n=e[0].dims,o=e[1].dims,s=dr(n,o,r.dilations,r.pads,r.strides),a=t.reshapeUnpacked(e[0],[n[1],n[2]*n[3]]),u=t.reshapeUnpacked(e[1],[o[0],o[1]]),l=e.length>2?[u,a,e[2]]:[u,a],p=t.run(Ti(l,r),l);return t.reshapeUnpacked(p,s)},Wm=(t,e,r)=>{let n=e[0].dims,o=e[1].dims,s=dr(n,o,r.dilations,r.pads,r.strides),a=t.run(bf(t,e[0],e[1],s,r),[e[0]]),u=3===e.length?[a,e[1],e[2]]:[a,e[1]];return t.run(gf(t,e,s,r),u)},Hm=(t,e)=>{let r=t.kernelShape.slice();if(0===t.kernelShape.length)for(let t=2;t<e[1].dims.length;++t)r.push(e[1].dims[t]);let n=t.pads.slice();Ue.adjustPadsBasedOnAutoPad(e[0].dims,t.strides,t.dilations,r,n,t.autoPad);let o=Object.assign({},t);return Object.assign(o,{kernelShape:r,pads:n,cacheKey:t.cacheKey}),o},Si=t=>{let e=t.attributes,r=pr(e),n=e.getString("auto_pad","NOTSET"),o=e.getInts("dilations",[1,1]),s=e.getInt("group",1),a=e.getInts("kernel_shape",[]),u=e.getInts("pads",[0,0,0,0]),l=e.getInts("strides",[1,1]);return W({autoPad:n,dilations:o,group:s,kernelShape:a,pads:u,strides:l,...r})},qm=(t,e)=>{if(!t||2!==t.length&&3!==t.length)throw Error("Conv requires 2 or 3 inputs");if(4!==t[0].dims.length||4!==t[1].dims.length)throw Error("currently only support 2-dimensional conv");if(t[0].dims[1]!==t[1].dims[1]*e.group)throw Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(3===t.length&&(1!==t[2].dims.length||t[1].dims[0]!==t[2].dims[0]))throw Error("invalid bias");let r=t[0].dims.length-2;if(e.dilations.length!==r)throw Error(`dilations should be ${r}D`);if(e.strides.length!==r)throw Error(`strides should be ${r}D`);if(e.pads.length!==2*r)throw Error(`pads should be ${2*r}D`);if(0!==e.kernelShape.length&&e.kernelShape.length!==t[1].dims.length-2)throw Error("invalid kernel shape");if("float32"!==t[0].type||"float32"!==t[1].type)throw Error("Conv input(X,W) should be float tensor");if(3===t.length&&"float32"!==t[2].type)throw Error("Conv input(bias) should be float tensor")}}),wf=O(()=>{"use strict";It(),ut(),j(),qe(),jm=(t,e,r,n,o,s)=>(t-1)*e+r+(n-1)*o+1-s,Xm=(t,e,r,n,o)=>{let s=Math.floor(t/2);"SAME_UPPER"===e?(r[n]=s,r[o]=t-s):"SAME_LOWER"===e&&(r[n]=t-s,r[o]=s)},Km=(t,e,r,n,o,s,a,u)=>{let l=t.length-2,p=0===u.length;for(let c=0;c<l;++c){let d=p?t[c+2]*s[c]:u[c];Xm(jm(t[c+2],s[c],o[c],e[c],r[c],d),n,o,c,c+l),p&&u.push(s[c]*(t[c+2]-1)+a[c]+(e[c]-1)*r[c]+1-o[c]-o[c+l])}},xf=(t,e,r)=>(rb(e,r),Jm(t,e,r)),Jm=(t,e,r)=>{let n=eb(r,e);return[tb(t,e,n)]},Ym=(t,e)=>({name:"ConvTranspose",inputNames:t?["X","W","B"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:e}),Zm=(t,e,r,n)=>{let o=e.length>2?"getB(output_channel)":"0.0",s=e[0].dims,a=e[1].dims,u=a[1],l=a[0]/n.group,p=[e[0].dims[0],e[1].dims[1]*n.group,...n.outputShape],c=G(t.session.backend.glContext.version),{activationFunction:d,applyActivation:h}=he(n),f=`
686  const ivec2 strides = ivec2(${n.strides[0]}, ${n.strides[1]});
687  const ivec2 pads = ivec2(${n.pads[0]}, ${n.pads[1]});
688  ${d}
689  void main() {
690    ivec4 coords = getOutputCoords();
691    int batch = coords.x;
692    int output_channel = coords.y;
693
694    ivec2 loc = coords.zw + pads;
695
696    int group_id = output_channel / ${u};
697    int wOutChannel = output_channel - group_id * ${u};
698
699    float value = ${o};
700    for (int inChannelOffset = 0; inChannelOffset < ${l}; inChannelOffset++) {
701      int input_channel = group_id * ${l} + inChannelOffset;
702      for (int wWOff = 0; wWOff < ${a[2]}; wWOff++) {
703        for (int wHOff = 0; wHOff < ${a[3]}; wHOff++) {
704          ivec2 wOff = ivec2(wWOff * ${n.dilations[0]}, wHOff * ${n.dilations[1]});
705          ivec2 wLoc = loc - wOff;
706          ivec2 wLocIn = wLoc / strides;
707          if (
708            wLocIn * strides == wLoc &&
709            wLocIn.x >= 0 && wLocIn.x < ${s[2]} &&
710            wLocIn.y >= 0 && wLocIn.y < ${s[3]}
711          ) {
712            float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);
713            float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);
714            value += xVal * wVal;
715          }
716        }
717      }
718    }
719    ${h}
720    ${c.output} = vec4(value, .0, .0, .0);
721  }
722`;return{...r,output:{dims:p,type:e[0].type,textureType:0},shaderSource:f,hasMain:!0}},Qm=(t,e,r)=>{let n=Ym(e.length>
7222,r.cacheKey);return{...n,get:()=>Zm(t,e,n,r)}},tb=(t,e,r)=>t.run(Qm(t,e,r),e),eb=(t,e)=>{let r=t.kernelShape.slice();if(0===t.kernelShape.length)for(let t=2;t<e[1].dims.length;++t)r.push(e[1].dims[t]);let n=t.pads.slice(),o=t.outputShape.slice();Km(e[0].dims,r,t.dilations,t.autoPad,n,t.strides,t.outputPadding,o);let s=Object.assign({},t);return Object.assign(s,{kernelShape:r,pads:n,outputShape:o,cacheKey:t.cacheKey}),s},Tf=t=>{let e=t.attributes,r=pr(e),n=e.getString("auto_pad","NOTSET"),o=e.getInts("dilations",[1,1]),s=e.getInt("group",1),a=e.getInts("kernel_shape",[]),u=e.getInts("output_padding",[0,0]),l=e.getInts("output_shape",[]),p=e.getInts("pads",[0,0,0,0]),c=e.getInts("strides",[1,1]);return W({autoPad:n,dilations:o,group:s,kernelShape:a,outputPadding:u,outputShape:l,pads:p,strides:c,...r})},rb=(t,e)=>{if(!t||2!==t.length&&3!==t.length)throw Error("Conv requires 2 or 3 inputs");if(4!==t[0].dims.length||4!==t[1].dims.length)throw Error("currently only support 2-dimensional conv");if(t[0].dims[1]!==t[1].dims[0])throw Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let r=t[1].dims[1]*e.group;if(3===t.length&&(1!==t[2].dims.length||t[2].dims[0]!==r))throw Error("invalid bias");let n=t[0].dims.length-2;if(e.dilations.length!==n)throw Error(`dilations should be ${n}D`);if(e.strides.length!==n)throw Error(`strides should be ${n}D`);if(e.pads.length!==2*n)throw Error(`pads should be ${2*n}D`);if(e.outputPadding.length!==n)throw Error(`output_padding should be ${n}D`);if(0!==e.kernelShape.length&&e.kernelShape.length!==t[1].dims.length-2)throw Error("invalid kernel shape");if(0!==e.outputShape.length&&e.outputShape.length!==t[0].dims.length-2)throw Error("invalid output shape");if("float32"!==t[0].type||"float32"!==t[1].type)throw Error("ConvTranspose input(X,W) should be float tensor");if(3===t.length&&"float32"!==t[2].type)throw Error("ConvTranspose input(bias) should be float tensor")}}),Nn=O(()=>{"use strict";It(),Y(),j(),vf={name:"Transpose",inputNames:["A"],inputTypes:[0]},je=(t,e,r)=>(ab(e),[t.run({...vf,cacheHint:r.cacheKey,get:()=>nb(t,e[0],r.perm)},e)]),If=t=>W({perm:t.attributes.getInts("perm",[])}),nb=(t,e,r)=>{let n=e.dims;r=_f(n,r);let o=ob(n,r),s=n.length,a=`
723      ${ib("perm",r,s)}
724      float process(int indices[${s}]) {
725        int a[${s}];
726        perm(a, indices);
727        return _A(a);
728      }`;return{...vf,output:{dims:o,type:e.type,textureType:0},shaderSource:a}},_f=(t,e)=>(e&&e.length!==t.length&&(e=[...t.keys()].reverse()),e),ob=(t,e)=>(e=_f(t,e),B.sortBasedOnPerm(t,e)),ib=(t,e,r)=>{let n=[];n.push(`void ${t}(out int a[${r}], int src[${r}]) {`);for(let t=0;t<r;++t)n.push(`	a[${e[t]}]=src[${t}];`);return n.push("	}"),n.join(`
729`)},ab=t=>{if(!t||1!==t.length)throw Error("Transpose requires 1 input.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw Error("input should be float tensor")}}),Af=O(()=>{"use strict";Nn(),Of=(t,e,r)=>{sb(e);let n=r.blocksize,o=n*n,s="DCR"===r.mode?[0,3,4,1,5,2]:[0,1,4,2,5,3],a="DCR"===r.mode?[e[0].dims[0],n,n,e[0].dims[1]/o,e[0].dims[2],e[0].dims[3]]:[e[0].dims[0],e[0].dims[1]/o,n,n,e[0].dims[2],e[0].dims[3]],u=t.reshapeUnpacked(e[0],a),l={perm:s,cacheKey:`${s}`},[p]=je(t,[u],l),c=[e[0].dims[0],e[0].dims[1]/o,e[0].dims[2]*n,e[0].dims[3]*n];return[t.reshapeUnpacked(p,c)]},Sf=t=>{let e=t.attributes.getInt("blocksize");if(e<1)throw Error(`blocksize must be >= 1, but got : ${e} for DepthToSpace`);let r=t.attributes.getString("mode","DCR");if("DCR"!==r&&"CRD"!==r)throw Error(`unrecognized mode: ${r} for DepthToSpace`);return{mode:r,blocksize:e}},sb=t=>{if(1!==t.length)throw Error(`DepthToSpace expect 1 inputs, but got ${t.length}`);if("string"===t[0].type||4!==t[0].dims.length)throw TypeError("DepthToSpace input should be a 4-D numeric tensor")}}),Df=O(()=>{"use strict";Y(),Pf=(t,e,r)=>{ub(e,r);let n=B.flattenShape(e[0].dims,r);return[t.reshapeUnpacked(e[0],n)]},Ef=t=>t.attributes.getInt("axis",1),ub=(t,e)=>{if(!t||1!==t.length)throw Error("Flatten requires 1 input.");let r=t[0].dims.length;if(0===r)throw Error("scalar tensor is not supported.");if(e<-r||e>r)throw Error("Invalid axis");if("string"===t[0].type)throw Error("string tensor is not supported.")}}),Rr=O(()=>{"use strict";Pe=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),kf=O(()=>{"use strict";It(),Rr(),Y(),j(),Lf=(t,e,r)=>
729(pb(e,r.axis),[t.run(cb(t,e,r),e)]),$f=t=>W({axis:t.attributes.getInt("axis",0)}),lb={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},fb=(t,e,r,n)=>{let o=r[0].dims.slice(),s=r[1].dims.slice(),a=Array(o.length+s.length-1);n=B.normalizeAxis(n,o.length);let u=[];for(let t=0;t<a.length;t++)t<n?(a[t]=o[t],u.push(`inputIdx[${t}] = outputIdx[${t}];`)):t<n+s.length?(a[t]=s[t-n],u.push(`indexDataIdx[${t-n}] = outputIdx[${t}];`)):(a[t]=o[t-s.length+1],u.push(`inputIdx[${t-s.length+1}] = outputIdx[${t}];`));let l=a.length||1,p=o.length,c=s.length||1,d=`
730      float process(int outputIdx[${l}]) {
731        int inputIdx[${p}];
732        int indexDataIdx[${c}];
733        indexDataIdx[0] = 0;
734        ${u.join(`
735        `)}
736        int idx = int(_B(indexDataIdx));
737        inputIdx[${n}] = idx < 0 ? idx + ${o[n]} : idx;
738        return _A(inputIdx);
739      }`;return{...e,output:{dims:a,type:r[0].type,textureType:0},shaderSource:d}},cb=(t,e,r)=>{let n={...lb,cacheHint:r.cacheKey};return{...n,get:()=>fb(t,n,e,r.axis)}},pb=(t,e)=>{if(!t||2!==t.length)throw Error("Gather requires 2 inputs.");let r=t[0].dims.length;if(r<1)throw Error("Invalid input shape.");if(e<-r||e>r-1)throw Error("Invalid axis.");if(-1===Pe.indexOf(t[0].type)||"int32"!==t[1].type&&"int16"!==t[1].type)throw Error("Invaid input type.")}}),Nf=O(()=>{"use strict";It(),Y(),j(),Ai=(t,e,r)=>(mb(e,r),[t.run(db(e,r),e)]),Bf=(t,e)=>{let r=0!==t.attributes.getInt("transA",0),n=0!==t.attributes.getInt("transB",0),o=t.attributes.getFloat("alpha",1),s=t.attributes.getFloat("beta",1);return W({transA:r,transB:n,alpha:o,beta:s,isOptionalC:e})},Ff=t=>Bf(t,!1),Cf=t=>Bf(t,!0),db=(t,e)=>{let r={name:"Gemm",inputNames:3===t.length?["A","B","C"]:["A","B"],inputTypes:3===t.length?[0,0,0]:[0,0],key:e.cacheKey};return{...r,get:()=>hb(r,t,e)}},hb=(t,e,r)=>{let n=e[0].dims.slice(),o=e[1].dims.slice(),[s,a]=Sn.getShapeOfGemmResult(n,r.transA,o,r.transB,3===e.length?e[2].dims:void 0),u=[s,a];if(!u)throw Error("Can't use gemm on the given tensors");let l=n[n.length-1],p="";r.transA&&(l=n[0]),r.transA&&r.transB?p="value += _A_T(a) * _B_T(b);":r.transA&&!r.transB?p="value += _A_T(a) * _B(b);":!r.transA&&r.transB?p="value += _A(a) * _B_T(b);":r.transA||r.transB||(p="value += _A(a) * _B(b);");let c=u.length,d=3===e.length?`int c[${e[2].dims.length}];`:"",h=3===e.length?"bcastIndices_C(indices, c);":"",f=3===e.length?"value += beta * _C(c);":"",g=`
740      float process(int indices[${c}]) {
741          int a[${c}];
742          int b[${c}];
743          ${d}
744
745          copyVec(indices, a);
746          copyVec(indices, b);
747          ${h}
748
749          float value = 0.0;
750          for (int k=0; k<${l}; ++k) {
751              a[${c-1}] = k;
752              b[${c-2}] = k;
753              ${p}
754          }
755
756          value = value * alpha;
757          ${f}
758          return value;
759      }`;return{...t,output:{dims:u,type:e[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:r.alpha},{name:"beta",type:"float",data:r.beta}],shaderSource:g}},mb=(t,e)=>{if(!t)throw Error("Input is missing");if(e.isOptionalC&&(t.length<2||t.length>3))throw Error("Invaid input shape.");if(!e.isOptionalC&&3!==t.length)throw Error("Gemm requires 3 inputs");if(3===t.length&&1!==t[2].dims.length&&2!==t[2].dims.length)throw Error("Invalid input shape of C");if("float32"!==t[0].type&&"float64"!==t[0].type||"float32"!==t[1].type&&"float64"!==t[1].type||3===t.length&&"float32"!==t[2].type&&"float64"!==t[2].type)throw Error("Invalid input type.");if(t[0].type!==t[1].type||3===t.length&&t[0].type!==t[2].type)throw Error("Input types are mismatched")}}),Mf=O(()=>{"use strict";It(),j(),Rf=(t,e,r)=>(Tb(e),[t.run(yb(t,e,r),e)]),Gf=t=>{let e=t.attributes.getFloat("scale"),r=t.attributes.getFloats("bias");return W({scale:e,bias:r})},bb={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},gb=(t,e,r,n)=>{let o=r[0].dims.slice(),s=o.length,a=`
760      ${xb(n.bias.length)}
761      float process(int indices[${s}]) {
762        return _X(indices) * scale + getBias(bias, indices[1]);
763      }`;return{...e,output:{dims:o,type:r[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:n.bias.length,data:n.bias},{name:"scale",type:"float",data:n.scale}],shaderSource:a}},yb=(t,e,r)=>{let n={...bb,cacheHint:r.cacheKey};return{...n,get:()=>gb(t,n,e,r)}},xb=t=>{let e=[`float getBias(float bias[${t}], int channel) {`];for(let r=0;r<t;++r)0===r?e.push(`	if (channel == ${r}) { return bias[${r}]; }`):r===t-1?e.push(`	else { return bias[${r}]; }`):e.push(`	else if (channel == ${r}) { return bias[${r}]; }`);return e.push("	}"),e.join(`
764`)},Tb=t=>{if(!t||1!==t.length)throw Error("ImageScaler requires 1 input.");if(4!==t[0].dims.length)throw Error("Invalid input shape.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw Error("Invalid input type.")}}),Wf=O(()=>{"use strict";ut(),j(),Vf=(t,e,r)=>{Sb(e);let n=t.run(vb(e[0]),e);return[t.run(Ob(t,e[0],r,n.dims),[e[0],n,e[1],e[2]])]},zf=t=>t.attributes.getFloat("epsilon",1e-5),Uf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},wb=(t,e)=>{let r=e.dims.slice(),n=r[1],o=r[2]*r[3],s=[r[0],n],a=`
765      vec4 process(int[2] indices) {
766        vec4 v = vec4(0.0);
767        int a[4];
768        a[0] = indices[0];
769        a[1] = indices[1];
770        float temp = 0.0;
771        for(int a2=0; a2<${r[2]}; a2++) {
772          a[2] = a2;
773          for(int a3=0; a3<${r[3]}; a3++) {
774            a[3] = a3;
775            float x = _X(a);
776            temp += x;
777          }
778        }
779        float mean = temp / float(${o});
780        temp = 0.0;
781        for(int a2=0; a2<${r[2]}; a2++) {
782          a[2] = a2;
783          for(int a3=0; a3<${r[3]}; a3++) {
784            a[3] = a3;
785            float x = _X(a);
786            temp += (x - mean) * (x - mean);
787          }
788        }
789        v.r = mean;
790        v.g = temp / float(${o});
791
792        return v;
793      }`;return{...t,output:{dims:s,type:e.type,textureType:4},shaderSource:a}},vb=t=>({...Uf,get:()=>wb(Uf,t)}),Ib={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},_b=(t,e,r,n,o)=>{let s=G(t.session.backend.glContext.version),[a,u]=t.calculateTextureWidthAndHeight(o,4),[l,p]=[a/4,u],c=`
794      vec4 get_MeanAndVariance(int[2] mv) {
795        int offset = indicesToOffset_MeanAndVariance(mv);
796        vec2 coords = offsetToCoords(offset, ${l}, ${p});
797        return ${s.texture2D}(MeanAndVariance, coords);
798      }
799
800      float process(int[4] indices) {
801        int mv[2];
802        mv[0] = indices[0];
803        mv[1] = indices[1];
804        vec4 mean_and_variance = get_MeanAndVariance(mv);
805        float mean = mean_and_variance.r;
806        float variance = mean_and_variance.g;
807
808        int sb[1];
809        sb[0] = indices[1];
810        float scale = _Scale(sb);
811        float b = _B(sb);
812
813        return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
814      }`;return{...e,output:{dims:r.dims,type:r.type,textureType:0},variables:[{name:"epsilon",type:"float",data:n}],shaderSource:c}},Ob=(t,e,r,n)=>{let o={...Ib,cacheHint:`${r}`};return{...o,get:()=>_b(t,o,e,r,n)}},Sb=t=>{if(!t||3!==t.length)throw Error("InstanceNormalization requires 3 inputs.");let e=t[0],r=t[1],n=t[2];if(e.dims.length<3||1!==r.dims.length||1!==n.dims.length)throw Error("Invalid input shape.");if(r.dims[0]!==e.dims[1]||n.dims[0]!==e.dims[1])throw Error("Input shapes are mismatched.");if("float32"!==e.type&&"float64"!==e.type||"float32"!==r.type&&"float64"!==r.type||"float32"!==n.type&&"float64"!==n.type)throw Error("Invalid input type.");if(4!==t[0].dims.length)throw Error("Only support 4-D input shape.")}});function Ab(t,e){let r=t[0].dims[1],n=t[0].dims.length,o=-Math.floor((e.size-1)/2),s=Math.ceil((e.size-1)/2),a=`float(${e.alpha}) / float(${e.size})`,u=`float(${e.bias})`,l=`float(${e.beta})`,p=`
815    float process(int indices[${n}]) {
816        int c = indices[1];
817        float x = _X(indices);
818        float square_sum = 0.0;
819
820        for (int i = ${o}; i <= ${s}; i++) {
821          int idx = c + i;
822          if (c >= 0 && c < ${r}) {
823            indices[1] = idx;
824            float j = _X(indices);
825            square_sum += j * j;
826          }
827        }
828        return x / pow(${u} + ${a} * square_sum, ${l});
829    }`;return{...jf,cacheHint:e.cacheKey,output:{dims:t[0].dims,type:t[0].type,textureType:0},shaderSource:p}}function Pb(t,e){return{...jf,cacheHint:e.cacheKey,get:()=>Ab(t,e)}}var Hf,qf,jf,Eb,Db,Pi,Kf,Jf,Yf,Lb,$b,kb,Bb,Fb,Cb,Nb,Rb,tc,ec,rc,nc,oc,ic,ac,sc,uc,Gb,Qf,lc,Gn,fc,Rn,Mb,Xe,Ee,Ub,Vb,pc,dc,hc,mc,bc,gc,yc,Tc,vc,Ei,Ic,_c,Gr,zb,Di,Mn,$i,ki,Oc,Sc,Wb,Hb,qb,jb,Pc,Xb,Bi,Dc,Lc,$c,Kb,kc,Jb,Yb,Fc,Cc,Nc,Rc,Gc,Mc,Uc,Vc,Zb,Qb,tg,zc,Hc,qc,jc,eg,rg,ng,Fi,Kc,Jc,og,ig,Zc,ag,sg,tp,ug,lg,Ci,rp,np,fg,cg,ip,Xf=O(()=>{"use strict";It(),j(),Hf=(t,e,r)=>(Eb(e),[t.run(Pb(e,r),e)]),qf=t=>{let e=t.attributes.getFloat("alpha",1e-4),r=t.attributes.getFloat("beta",.75),n=t.attributes.getFloat("bias",1),o=t.attributes.getInt("size");return W({alpha:e,beta:r,bias:n,size:o})},jf={name:"LRN",inputNames:["X"],inputTypes:[0]},Eb=t=>{if(!t||1!==t.length)throw Error("LRN requires 1 input.");if(4!==t[0].dims.length)throw Error('currently only support LRN for input with "NCHW" format');if("float32"!==t[0].type)throw Error("input should be float type")}}),Zf=O(()=>{"use strict";It(),Y(),ut(),j(),Db={name:"Pad",inputNames:["A"],inputTypes:[0]},Pi=(t,e,r)=>(kb(e),[t.run({...Db,cacheHint:r.cacheKey,get:()=>$b(t,e[0],r)},e)]),Kf=t=>{let e=t.attributes.getString("mode","constant"),r=t.attributes.getFloat("value",0),n=t.attributes.getInts("pads");return W({mode:e,value:r,pads:n})},Jf=(t,e,r)=>{Bb(e);let n=Lb(t,e,r);return Pi(t,[e[0]],n)},Yf=t=>t.attributes.getString("mode","constant"),Lb=(t,e,r)=>{if(!t.session.isInitializer(e[1].dataId)||e.length>=3&&!t.session.isInitializer(e[2].dataId))throw Error("dynamic pad attributes are not allowed");let n=Array.from(e[1].integerData),o=e.length>=3?e[2].floatData[0]:0;return W({mode:r,pads:n,value:o})},$b=(t,e,r)=>{let n=B.padShape(e.dims.slice(),r.pads),o=n.length,s=`
830      ${Fb(t,e,r)}
831      float process(int[${o}] indices) {
832          return padA(indices);
833      }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:n,type:e.type,textureType:0},shaderSource:s}},kb=t=>{if(!t||1!==t.length)throw Error("Pad requires 1 input");if("float32"!==t[0].type&&"float64"!==t[0].type)throw Error("Invalid input type.")},Bb=t=>{if(!t||2!==t.length&&3!==t.length)throw Error("Pad requires 2 or 3 inputs");if("int32"!==t[1].type||t.length>=3&&"string"===t[2].type)throw Error("Invalid input type.")},Fb=(t,e,r)=>{let n=G(t.session.backend.glContext.version),[o,s]=t.calculateTextureWidthAndHeight(e.dims,0),a=B.computeStrides(e.dims);switch(r.mode){case"constant":return Cb(n,e.dims,a,o,s,r.pads,r.value);case"reflect":return Nb(n,e.dims,a,o,s,r.pads);case"edge":return Rb(n,e.dims,a,o,s,r.pads);default:throw Error("Invalid mode")}},Cb=(t,e,r,n,o,s,a)=>{let u=e.length,l="";for(let t=u-1;t>=0;--t)l+=`
834        k = m[${t}] - ${s[t]};
835        if (k < 0)  return constant;
836        if (k >= ${e[t]}) return constant;
837        offset += k * ${r[t]};
838        `;return`
839      float padA(int m[${u}]) {
840        const float constant = float(${a});
841        int offset = 0;
842        int k = 0;
843        ${l}
844        vec2 coords = offsetToCoords(offset, ${n}, ${o});
845        float value = getColorAsFloat(${t.texture2D}(A, coords));
846        return value;
847      }
848      `},Nb=(t,e,r,n,o,s)=>{let a=e.length,u="";for(let t=a-1;t>=0;--t)u+=`
849        k = m[${t}] - ${s[t]};
850        if (k < 0) { k = -k; }
851        {
852          const int _2n_1 = ${2*(e[t]-1)};
853          k = int( mod( float(k), float(_2n_1) ) ) ;
854          if(k >= ${e[t]}) { k = _2n_1 - k; }
855        }
856        offset += k * ${r[t]};
857        `;return`
858      float padA(int m[${a}]) {
859        int offset = 0;
860        int k = 0;
861        ${u}
862        vec2 coords = offsetToCoords(offset, ${n}, ${o});
863        float value = getColorAsFloat(${t.texture2D}(A, coords));
864        return value;
865      }
866      `},Rb=(t,e,r,n,o,s)=>{let a=e.length,u="";for(let t=a-1;t>=0;--t)u+=`
867        k = m[${t}] - ${s[t]};
868        if (k < 0)  k = 0;
869        if (k >= ${e[t]}) k = ${e[t]-1};
870        offset += k * ${r[t]};
871      `;return`
872      float padA(int m[${a}]) {
873        int offset = 0;
874        int k = 0;
875        ${u}
876        vec2 coords = offsetToCoords(offset, ${n}, ${o});
877        float value = getColorAsFloat(${t.texture2D}(A, coords));
878        return value;
879      }
880      `}}
880),cc=O(()=>{"use strict";It(),Y(),j(),tc=(t,e,r)=>{Gn(e);let n={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:r.cacheKey};return[t.run({...n,get:()=>rc(e,n,!1,r)},e)]},ec=t=>{let e=t.attributes.getString("auto_pad","NOTSET"),r=t.attributes.getInt("ceil_mode",0),n=0!==t.attributes.getInt("count_include_pad",0),o=t.attributes.getInts("kernel_shape"),s=t.attributes.getInts("strides",[]),a=t.attributes.getInts("pads",[]);if(0!==r)throw Error("using ceil() in shape computation is not yet supported for AveragePool");return W({autoPad:e,ceilMode:r,countIncludePad:n,kernelShape:o,strides:s,pads:a})},rc=(t,e,r,n)=>{let[o,s]=uc(t,n,r),a=B.size(o.kernelShape),u="value += _X(x);",l="";o.countIncludePad?l+=`value /= float(${a});`:l+=`value /= float(${a} - pad);`;let p=`
881        ${fc(t[0].dims,o,u,l,"0.0")}
882      `;return{...e,output:{dims:s,type:t[0].type,textureType:0},shaderSource:p}},nc=(t,e,r)=>{Gn(e);let n={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${r.countIncludePad}`};return[t.run({...n,get:()=>rc(e,n,!0,r)},e)]},oc=t=>{let e=0!==t.attributes.getInt("count_include_pad",0);return W({autoPad:"",ceilMode:0,countIncludePad:e,kernelShape:[],strides:[],pads:[]})},ic=(t,e,r)=>{Gn(e);let n={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:r.cacheKey};return[t.run({...n,get:()=>sc(e,n,!1,r)},e)]},ac=t=>{let e=t.attributes.getString("auto_pad","NOTSET"),r=t.attributes.getInt("ceil_mode",0),n=t.attributes.getInts("kernel_shape"),o=t.attributes.getInts("strides",[]),s=t.attributes.getInts("pads",[]),a=t.attributes.getInt("storage_order",0),u=t.attributes.getInts("dilations",[]);if(0!==a)throw Error("column major storage order is not yet supported for MaxPool");if(0!==r)throw Error("using ceil() in shape computation is not yet supported for MaxPool");return W({autoPad:e,ceilMode:r,countIncludePad:!1,kernelShape:n,strides:o,pads:s,storageOrder:a,dilations:u})},sc=(t,e,r,n)=>{let[o,s]=uc(t,n,r),a=`
883      value = max(_X(x), value);
884    `,u="",l=`
885      ${fc(t[0].dims,o,a,u,"-1e5")}
886    `;return{...e,output:{dims:s,type:t[0].type,textureType:0},shaderSource:l}},uc=(t,e,r)=>{let n=t[0].dims.slice(),o=Object.hasOwnProperty.call(e,"dilations"),s=e.kernelShape.slice(),a=e.strides.slice(),u=o?e.dilations.slice():[],l=e.pads.slice();Ue.adjustPoolAttributes(r,n,s,a,u,l);let p=Ue.computePoolOutputShape(r,n,a,u,s,l,e.autoPad),c=Object.assign({},e);return o?Object.assign(c,{kernelShape:s,strides:a,pads:l,dilations:u,cacheKey:e.cacheKey}):Object.assign(c,{kernelShape:s,strides:a,pads:l,cacheKey:e.cacheKey}),[c,p]},Gb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Qf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},lc=(t,e)=>(Gn(e),[t.run({...Qf,get:()=>sc(e,Qf,!0,Gb)},e)]),Gn=t=>{if(!t||1!==t.length)throw Error("Pool ops requires 1 input.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw Error("Invalid input type.")},fc=(t,e,r,n,o)=>{let s=t.length;if(e.kernelShape.length<=2){let a=e.kernelShape[e.kernelShape.length-1],u=e.strides[e.strides.length-1],l=e.pads[e.pads.length/2-1],p=e.pads[e.pads.length-1],c=t[s-1],d="",h="",f="";if(d=l+p!==0?`
887          for (int i = 0; i < ${a}; i++) {
888            x[${s} - 1] = indices[${s} - 1] * ${u} - ${l} + i;
889            if (x[${s} - 1] < 0 || x[${s} - 1] >= ${c}) {
890              pad++;
891              continue;
892            }
893            ${r}
894          }`:`
895          for (int i = 0; i < ${a}; i++) {
896            x[${s} - 1] = indices[${s} - 1] * ${u} - ${l} + i;
897            ${r}
898          }`,2===e.kernelShape.length){let r=e.kernelShape[e.kernelShape.length-2],n=e.strides[e.strides.length-2],o=e.pads[e.pads.length/2-2],u=e.pads[e.pads.length-2],l=t[s-2];h=o+u!==0?`
899            for (int j = 0; j < ${r}; j++) {
900              x[${s} - 2] = indices[${s} - 2] * ${n} - ${o} + j;
901              if (x[${s} - 2] < 0 || x[${s} - 2] >= ${l}) {
902                pad+= ${a};
903                continue;
904              }
905          `:`
906            for (int j = 0; j < ${r}; j++) {
907              x[${s} - 2] = indices[${s} - 2] * ${n} - ${o} + j;
908            `,f=`
909          }
910        `}return`
911        float process(int indices[${s}]) {
912          int x[${s}];
913          copyVec(indices, x);
914
915          float value = ${o};
916          int pad = 0;
917          ${h}
918          ${d}
919          ${f}
920          ${n}
921          return value;
922        }
923      `}{let a=B.size(e.kernelShape),u=B.computeStrides(e.kernelShape),l=u.length,p=e.pads.length,c=Mb(l),d=Rn(t,"inputDims"),h=Rn(e.pads,"pads"),f=Rn(u,"kernelStrides"),g=Rn(e.strides,"strides"),m=e.pads.reduce((t,e)=>t+e),b="";return b=m?`
924            if (x[j] >= inputDims[j] || x[j] < 0) {
925              pad++;
926              isPad = true;
927              break;
928            }
929          }
930          if (!isPad) {
931            ${r}
932          }`:`
933          }
934          ${r}
935        `,`
936        ${c}
937        float process(int indices[${s}]) {
938          int x[${s}];
939          copyVec(indices, x);
940          int offset[${l}];
941          int pads[${p}];
942          int inputDims[${s}];
943          int kernelStrides[${l}];
944          int strides[${l}];
945          ${h}
946          ${d}
947          ${g}
948          ${f}
949
950          float value = ${o};
951          int pad = 0;
952          bool isPad = false;
953          for (int i = 0; i < ${a}; i++) {
954            offsetToIndices(i, kernelStrides, offset);
955            isPad = false;
956            for (int j = ${s} - ${l}; j < ${s}; j++) {
957              x[j] = indices[j] * strides[j - ${s} + ${l}]
958                + offset[j - ${s} + ${l}] - pads[j - 2];
959              ${b}
960          }
961          ${n}
962
963          return value;
964        }
965      `}},Rn=(t,e)=>{let r="";for(let n=0;n<t.length;n++)r+=`
966      ${e}[${n}] = ${t[n]};
967    `;return r},Mb=t=>`
968  void offsetToIndices(int offset, int[${t}] strides, out int[${t}] indices) {
969    if (${t} == 0) {
970      return;
971    }
972    for (int i = 0; i < ${t} - 1; ++i) {
973      indices[i] = offset / strides[i];
974      offset -= indices[i] * strides[i];
975    }
976    indices[${t} - 1] = offset;
977  }`}),xc=O(()=>{"use strict";It(),Rr(),Y(),j(),Xe=(t,e,r,n,o)=>{Vb(e);let s={name:n,inputNames:["A"],inputTypes:[0]};return[t.run({...s,cacheHint:r.cacheKey,get:()=>Ub(t,e,r,n,o,s)},e)]},Ee=t=>{let e=t.attributes.getInts("axes",[]),r=1===t.attributes.getInt("keepdims",1);return W({axes:e,keepDims:r})},Ub=(t,e,r,n,o,s)=>{let a=[],u=e[0].dims.length||1,l=[],p=B.normalizeAxes(r.axes,e[0].dims.length),c=o(e,p),d=c[1];for(let t=0;t<e[0].dims.length;t++)p.indexOf(t)>=0||0===p.length?(r.keepDims&&a.push(1),d=`
978          for(int j${t} = 0; j${t} < ${e[0].dims[t]}; j${t}++) {
979            inputIdx[${t}] = j${t};
980            ${d}
981          }`):(l.push(`inputIdx[${t}] = outputIdx[${a.length}];`),a.push(e[0].dims[t]));let h=`
982      float process(int outputIdx[${a.length||1}]) {
983        float value;                 // final result
984        int inputIdx[${u}];      // addressing input data
985        ${l.join(`
986`)}
987        ${c[0]}       // init ops for reduce max/min
988        ${d}
989        ${c[2]}       // final computation for reduce mean
990        return value;
991      }`;return{...s,output:{dims:a,type:e[0].type,textureType:0},shaderSource:h}},Vb=t=>{if(!t||1!==t.length)throw Error("Reduce op requires 1 input.");if(-1===Pe.indexOf(t[0].type))throw Error("Invalid input type.")},pc=(t,e,r)=>Xe(t,e,r,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),dc=(t,e,r)=>Xe(t,e,r,"ReduceMean",(t,e)=>{let r=1;for(let n=0;n<t[0].dims.length;n++)(e.indexOf(n)>=0||0===e.length)&&(r*=t[0].dims[n]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${r}.;`]}),hc=(t,e,r)=>Xe(t,e,r,"ReduceMax",(t,e)=>{let r=[];for(let n=0;n<t[0].dims.length;n++)(e.indexOf(n)>=0||0===e.length)&&r.push(`inputIdx[${n}] = 0;`);return[`${r.join(`
992`)}
993value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),mc=(t,e,r)=>Xe(t,e,r,"ReduceMin",(t,e)=>{let r=[];for(let n=0;n<t[0].dims.length;n++)(e.indexOf(n)>=0||0===e.length)&&r.push(`inputIdx[${n}] = 0;`);return[`${r.join(`
994`)}
995value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),bc=(t,e,r)=>Xe(t,e,r,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),gc=(t,e,r)=>Xe(t,e,r,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),yc=(t,e,r)=>Xe(t,e,r,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),wc=O(()=>{"use strict";Y(),Tc=(t,e)=>{let r=B.calculateReshapedDims(e[0].dims,e[1].integerData);return t.session.pack?[t.reshapePacked(e[0],r)]:[t.reshapeUnpacked(e[0],r)]}}),Li=O(()=>{"use strict";It(),ut(),j(),vc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Ei=(t,e,r)=>(Di(e,r),[t.run({...vc,cacheHint:r.cacheKey,get:()=>zb(t,e,r)},e)]),Ic=t=>Gr(t,7),_c=t=>Gr(t,9),Gr=(t,e)=>{let r=e>=10,n=t.attributes.getString("mode","nearest");
995if("nearest"!==n&&"linear"!==n&&(e<11||"cubic"!==n))throw Error(`unrecognized mode: ${n}`);let o=[];e<9&&(o=t.attributes.getFloats("scales"),Mn(o,n,r));let s=t.attributes.getFloat("extrapolation_value",0),a=e>10?t.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(-1===["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(a))throw Error(`coordinate_transform_mode '${a}' is not supported`);let u="tf_crop_and_resize"===a,l=u,p="nearest"===n&&e>=11?t.attributes.getString("nearest_mode","round_prefer_floor"):"";if(-1===["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(p))throw Error(`nearest_mode '${p}' is not supported`);let c=t.attributes.getFloat("cubic_coeff_a",-.75),d=0!==t.attributes.getInt("exclude_outside",0);if(d&&"cubic"!==n)throw Error("exclude_outside can be set to 1 only when mode is CUBIC.");let h=e<11||"nearest"===n&&"asymmetric"===a&&"floor"===p,f=0,g=0,m=0;return e>10?t.inputs.length>2?(f=1,g=2,m=3):(g=1,m=2):9===e&&(g=1),W({opset:e,isResize:r,mode:n,scales:o,extrapolationValue:s,coordinateTransformMode:a,useExtrapolation:l,needRoiInput:u,nearestMode:p,cubicCoefficientA:c,excludeOutside:d,useNearest2xOptimization:h,roiInputIdx:f,scalesInputIdx:g,sizesInputIdx:m})},zb=(t,e,r)=>{let n=G(t.session.backend.glContext.version),[o,s]=t.calculateTextureWidthAndHeight(e[0].dims,0),a=e[0].dims.map((t,e)=>Math.floor(t*r.scales[e])),[u,l]=t.calculateTextureWidthAndHeight(a,0),p=a.length,c=Array(p),d=Array(p),h=`
996      int output_pitches[${p}];
997      int input_pitches[${p}];
998      `;for(let t=p-1;t>=0;t--)c[t]=t===p-1?1:c[t+1]*a[t+1],d[t]=t===p-1?1:d[t+1]*e[0].dims[t+1],h+=`
999        output_pitches[${t}] = ${c[t]};
1000        input_pitches[${t}] = ${d[t]};
1001        `;let f=`
1002      float getInputFloat(int index) {
1003        vec2 coords = offsetToCoords(index, ${o}, ${s});
1004        float value = getColorAsFloat(${n.texture2D}(X, coords));
1005        return value;
1006      }
1007      `,g="nearest"===r.mode?`
1008    ${f}
1009    float process(int indices[${p}]) {
1010      int input_index = 0;
1011      int output_index = coordsToOffset(TexCoords, ${u}, ${l});
1012
1013      ${h}
1014
1015      int d, m;
1016      for (int dim = 0; dim < ${p}; ++dim) {
1017        d = output_index / output_pitches[dim];
1018        m = output_index - d * output_pitches[dim];
1019        output_index = m;
1020
1021        if (scales[dim] != 1 && d > 0) {
1022          int d2 = d / scales[dim];
1023          m = d - d2 * scales[dim];
1024          d = d2;
1025        }
1026        input_index += input_pitches[dim] * d;
1027      }
1028
1029      return getInputFloat(input_index);
1030    }`:4===p?`
1031    ${f}
1032    float process(int indices[4]) {
1033      int input_index = 0;
1034      int output_index = coordsToOffset(TexCoords, ${u}, ${l});
1035
1036      ${h}
1037
1038      int m;
1039      int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
1040      index_of_dim0 = output_index / output_pitches[0];
1041      m = output_index - index_of_dim0 * output_pitches[0];
1042      index_of_dim1 = m / output_pitches[1];
1043      m = m - index_of_dim1 * output_pitches[1];
1044      index_of_dim2 = m / output_pitches[2];
1045      m = m - index_of_dim2 * output_pitches[2];
1046      index_of_dim3 = m;
1047
1048      int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;
1049      index_of_input_dim2 = index_of_dim2 / scales[2];
1050      y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];
1051      index_of_input_dim3 = index_of_dim3 / scales[3];
1052      x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];
1053
1054      input_index = index_of_dim0 * input_pitches[0] +
1055            index_of_dim1 * input_pitches[1] +
1056            index_of_input_dim2 * input_pitches[2] +
1057            index_of_input_dim3;
1058
1059      float x00 = getInputFloat(input_index);
1060      float x10, x01, x11;
1061
1062      bool end_of_dim2 = false;
1063      if (index_of_input_dim2 == (${e[0].dims[2]} - 1)) {
1064        // It's the end in dimension 2
1065        x01 = x00;
1066        end_of_dim2 = true;
1067      } else {
1068        x01 = getInputFloat(input_index + input_pitches[2]);
1069      }
1070
1071      if (index_of_input_dim3 == (input_pitches[2] - 1)) {
1072        // It's the end in dimension 3
1073        x10 = x00;
1074        x11 = x01;
1075      }
1076      else {
1077        x10 = getInputFloat(input_index + 1);
1078        x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);
1079      }
1080
1081      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);
1082      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
1083      return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
1084    }`:`
1085    ${f}
1086    float process(int indices[2]) {
1087      int input_index = 0;
1088      int output_index = coordsToOffset(TexCoords, ${u}, ${l});
1089
1090      ${h}
1091
1092      int m;
1093      int index_of_dim0, index_of_dim1;
1094      index_of_dim0 = output_index / output_pitches[0];
1095      m = output_index - index_of_dim0 * output_pitches[0];
1096      index_of_dim1 = m;
1097
1098      int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;
1099      index_of_input_dim0 = index_of_dim0 / scales[0];
1100      y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];
1101      index_of_input_dim1 = index_of_dim1 / scales[1];
1102      x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];
1103
1104      input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;
1105
1106      float x00 = getInputFloat(input_index);
1107      float x10, x01, x11;
1108
1109      bool end_of_dim0 = false;
1110      if (index_of_input_dim0 == (${e[0].dims[0]} - 1)) {
1111        // It's the end in dimension 0
1112        x01 = x00;
1113        end_of_dim0 = true;
1114      } else {
1115        x01 = getInputFloat(input_index + input_pitches[0]);
1116      }
1117
1118      if (index_of_input_dim1 == (input_pitches[0] - 1)) {
1119        // It's the end in dimension 1
1120        x10 = x00;
1121        x11 = x01;
1122      }
1123      else {
1124        x10 = getInputFloat(input_index + 1);
1125        x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);
1126      }
1127
1128      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
1129      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
1130      return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
1131    }`;return{...vc,output:{dims:a,type:e[0].type,textureType:0},shaderSource:g,variables:[{name:"scales",type:"int",arrayLength:r.scales.length,data:r.scales.map(t=>Math.ceil(t))}]}},Di=(t,e)=>{if(!t||e.opset<9&&1!==t.length||e.opset>=9&&e.opset<11&&2!==t.length||e.opset>=11&&t.length<2)throw Error("invalid inputs.");if(e.scales.length>0&&t[0].dims.length!==e.scales.length)throw Error("Invalid input shape.");if("string"===t[0].type)throw Error("Invalid input tensor types.")},Mn=(t,e,r)=>{if(r){for(let e of t)if(e<=0)throw Error("Scale value should be greater than 0.")}else for(let e of t)if(e<1)throw Error("Scale value should be greater than or equal to 1.");if(("linear"===e||"cubic"===e)&&2!==t.length&&(4!==t.length||1!==t[0]||1!==t[1]))throw 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 ${r?"Resize":"Upsample"} opeartor.`)}}),Ac=O(()=>{"use strict";ut(),j(),pe(),He(),Li(),$i={name:"Resize",inputNames:["A"],inputTypes:[2]},ki=(t,e,r)=>(Di(e,r),[t.run({...$i,cacheHint:r.cacheKey,get:()=>Wb(t,e,r)},e)]),Oc=t=>Gr(t,10),Sc=t=>Gr(t,11),Wb=(t,e,r)=>{let n=G(t.session.backend.glContext.version),[o,s]=Hb(e,r);if(o.every(t=>1===t)&&"tf_crop_and_resize"!==r.coordinateTransformMode)return{...$i,output:{dims:s,type:e[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {
1132                    vec4 v = ${n.texture2D}(X, TexCoords);
1133                    ${n.output} = v;
1134                }`};let a=s.length;if(a<2)throw Error(`output dimension should be at least 2, but got ${a}`);let u=s[a-2],l=s[a-1],p=e[0].dims;if(a!==p.length)throw Error(`output dimension should match input ${p.length}, but got ${a}`);let c=p[a-2],d=p[a-1],h=o[a-2],f=o[a-1],g="";if("linear"!==r.mode)throw Error(`resize (packed) does not support mode: '${r.mode}'`);switch(r.coordinateTransformMode){case"asymmetric":g=`
1135                    vec4 getSourceFracIndex(ivec4 coords) {
1136                        return vec4(coords) / scaleWHWH;
1137                    }
1138                `;break;case"half_pixel":g=`
1139                    vec4 getSourceFracIndex(ivec4 coords) {
1140                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
1141                    }
1142                `;break;case"pytorch_half_pixel":g=`
1143                    vec4 getSourceFracIndex(ivec4 coords) {
1144                        vec4 fcoords = vec4(coords);
1145                        return vec4(
1146                            ${l}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
1147                            ${u}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
1148                            ${l}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
1149                            ${u}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
1150                          );
1151                    }
1152                `;break;case"align_corners":g=`
1153                    vec4 getSourceFracIndex(ivec4 coords) {
1154                        vec4 resized = vec4(${l}.0 - 1.0, ${u}.0 - 1.0, ${l}.0 - 1.0,
1155                            ${u}.0 - 1.0);
1156                        vec4 original = vec4(${d}.0 - 1.0, ${c}.0 - 1.0, ${d}.0 - 1.0,
1157                            ${c}.0 - 1.0);
1158                        vec4 new_scale = original / resized;
1159                        return vec4(coords) * new_scale;
1160                    }
1161                `;break;default:throw Error(`resize (packed) does not support coordinateTransformMode:                                 '${r.coordinateTransformMode}'`)}let m=Bt(a),b=de(),y=`
1162            const vec2 inputWH = vec2(${c}.0, ${d}.0);
1163            const vec4 scaleWHWH = vec4(float(${h}), float(${f}), float(${h}), float(${f}));
1164            ${b}
1165            ${g}
1166            float getAValue(int x10, int r, int c, int d) {
1167                return getChannel(getA(x10, r, c, d), vec2(c, d));
1168            }
1169            void main() {
1170                ${m
vendor: 3,192 bytes, lines 1170-1226
1170} rc = getOutputCoords();
1171
1172                int batch = rc[0];
1173                int depth = rc[1];
1174
1175                // retrieve the 4 coordinates that is used in the 4 packed output values.
1176                ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);
1177
1178                // calculate the source index in fraction
1179                vec4 sourceFrac = getSourceFracIndex(coords);
1180
1181                // get the lower and upper bound of the 4 values that will be packed into one texel.
1182                ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));
1183                ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));
1184                ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
1185                ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));
1186
1187                bool hasNextRow = rc.w < ${u-1};
1188                bool hasNextCol = rc.z < ${l-1};
1189
1190                // pack x00, x01, x10, x11's top-left corner into one vec4 structure
1191                vec4 topLeft = vec4(
1192                    getAValue(batch, depth, x00.x, x00.y),
1193                    hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,
1194                    hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,
1195                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);
1196
1197                // pack x00, x01, x10, x11's top-right corner into one vec4 structure
1198                vec4 topRight = vec4(
1199                    getAValue(batch, depth, x00.x, x00.w),
1200                    hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,
1201                    hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,
1202                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);
1203
1204                // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure
1205                vec4 bottomLeft = vec4(
1206                    getAValue(batch, depth, x00.z, x00.y),
1207                    hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,
1208                    hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,
1209                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);
1210
1211                // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure
1212                vec4 bottomRight = vec4(
1213                    getAValue(batch, depth, x00.z, x00.w),
1214                    hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,
1215                    hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,
1216                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);
1217
1218                // calculate the interpolation fraction on u and v direction
1219                vec4 frac = vec4(sourceFrac) - floor(sourceFrac);
1220                vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));
1221
1222                vec4 top = mix(topLeft, topRight, clampFrac.ywyw);
1223                vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);
1224                vec4 newValue = mix(top, bottom, clampFrac.xxzz);
1225
1226                ${
1226n.output} = vec4(newValue);
1227            }
1228        `;return{...$i,output:{dims:s,type:e[0].type,textureType:2},hasMain:!0,shaderSource:y}},Hb=(t,e)=>{let r=t[0].dims,n=e.scales,o;if(0===n.length){let s=t[e.scalesInputIdx];if(s&&0!==s.size){if(t[e.sizesInputIdx])throw Error("Only one of scales or sizes must be provided as input.");n=qb(s,e.mode,e.isResize)}else{let s=t[e.sizesInputIdx];if(!s||0===s.size)throw Error("Either scales or sizes MUST be provided as input.");o=Array.from(s.integerData),n=jb(o,r,e.mode,e.isResize)}}else if(t[e.sizesInputIdx])throw Error("Only one of scales or sizes must be provided as input.");let s=o||r.map((t,e)=>Math.floor(t*n[e]));return[n,s]},qb=(t,e,r)=>{let n=Array.from(t.floatData);return Mn(n,e,r),n},jb=(t,e,r,n)=>{let o=e.length,s=Array(o);for(let r=0,n=o;r<n;r++)if(0===e[r]){if(0!==t[r])throw Error("Input dim is zero but required output dim is non-zero.");s[r]=1}else s[r]=t[r]/e[r];return Mn(s,r,n),s}}),Ec=O(()=>{"use strict";We(),Pc=(t,e)=>(Xb(e),[new bt([e[0].dims.length],"int32",void 0,void 0,new Int32Array(e[0].dims))]),Xb=t=>{if(!t||1!==t.length)throw Error("Shape requires 1 input.")}}),Bc=O(()=>{"use strict";It(),Rr(),Y(),j(),Bi={name:"Slice",inputNames:["A"],inputTypes:[0]},Dc=(t,e,r)=>(Kb(e),[t.run({...Bi,cacheHint:r.cacheKey,get:()=>$c(t,e[0],r)},e)]),Lc=t=>{let e=t.attributes.getInts("starts"),r=t.attributes.getInts("ends"),n=t.attributes.getInts("axes",[]);return W({starts:e,ends:r,axes:n})},$c=(t,e,r)=>{let n=0===r.axes.length?e.dims.slice(0).map((t,e)=>e):r.axes,o=B.normalizeAxes(n,e.dims.length),s=r.starts.map((t,r)=>t>e.dims[o[r]]-1?e.dims[o[r]]:B.normalizeAxis(t,e.dims[o[r]])),a=r.ends.map((t,r)=>t>e.dims[o[r]]-1?e.dims[o[r]]:B.normalizeAxis(t,e.dims[o[r]])),u=e.dims.slice(),l=[];for(let t=0;t<o.length;t++)u[o[t]]=a[t]-s[t],s[t]>0&&l.push(`outputIdx[${o[t]}] += ${s[t]};`);let p=`
1229      float process(int outputIdx[${u.length}]) {
1230        ${l.join(`
1231      `)}
1232        return _A(outputIdx);
1233      }`;return{...Bi,output:{dims:u,type:e.type,textureType:0},shaderSource:p}},Kb=t=>{if(!t||1!==t.length)throw Error("Slice requires 1 input.");if(-1===Pe.indexOf(t[0].type))throw Error("Invalid input type.")},kc=(t,e)=>{Yb(e);let r=Jb(t,e);return[t.run({...Bi,cacheHint:r.cacheKey,get:()=>$c(t,e[0],r)},[e[0]])]},Jb=(t,e)=>{if(!t.session.isInitializer(e[1].dataId)||!t.session.isInitializer(e[2].dataId)||e.length>=4&&!t.session.isInitializer(e[3].dataId)||e.length>=5&&!t.session.isInitializer(e[4].dataId))throw Error("dynamic slice attributes are not allowed");if(e.length>=5&&e[4].integerData.some(t=>1!==t))throw Error("currently non-1 steps is not supported for Slice");let r=Array.from(e[1].integerData),n=Array.from(e[2].integerData),o=e.length>=4?Array.from(e[3].integerData):[],s=`${o};${r};${n}`;return{starts:r,ends:n,axes:o,cacheKey:s}},Yb=t=>{if(!t||t.length<3||t.length>5)throw Error("Invalid input number.");if("int32"!==t[1].type||1!==t[1].dims.length||"int32"!==t[2].type||1!==t[2].dims.length||t.length>=4&&("int32"!==t[3].type||1!==t[3].dims.length)||t.length>=5&&("int32"!==t[4].type||1!==t[4].dims.length))throw Error("Invalid input type.")}}),Wc=O(()=>{"use strict";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=(t,e,r)=>{zc(e);let n=e[0].dims.slice(),o=B.normalizeAxis(r.axis,n.length),s=B.sizeToDimension(n,o),a=B.sizeFromDimension(n,o);return Vc(t,e,r,s,a)},Gc=t=>W({axis:t.attributes.getInt("axis",1)}),Mc=t=>W({axis:t.attributes.getInt("axis",-1)}),Uc=(t,e,r)=>{zc(e);let n=e[0].dims.slice(),o=B.normalizeAxis(r.axis,n.length),s=n.length,a=o!==s-1,u=[],l=[],p=[],c;a&&((l=Array.from({length:s}).map((t,e)=>e))[o]=s-1,l[s-1]=o,l.map(t=>u.push(n[t])),c=W({perm:l}),p=je(t,e,c));let d=a?B.sizeToDimension(u,s-1):B.sizeToDimension(n,s-1),h=a?B.sizeFromDimension(u,s-1):B.sizeFromDimension(n,s-1),f=Vc(t,a?p:e,r,d,h);return a?je(t,f,c):f},Vc=(t,e,r,n,o)=>{let s=Zb(t,e[0],n,o,[n]),a=t.run({...Fc,cacheHint:r.cacheKey,get:()=>s},e),u=Qb(t,e[0],n,o,s.output.dims,[n]),l=t.run({...Cc,cacheHint:r.cacheKey,get:()=>u},[e[0],a]),p=tg(t,e[0],n,o,s.output.dims,u.output.dims);return[t.run({...Nc,cacheHint:r.cacheKey,get:()=>p},[e[0],a,l])]},Zb=(t,e,r,n,o)=>{let[s,a]=t.calculateTextureWidthAndHeight(e.dims,0),u=o.length;if(r<1||n<1)throw Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length)throw Error("Dimensionality of the output should be 1");if(o[0]!==r)throw Error("Shape of the output should be equal to logical row count");let l=G(t.session.backend.glContext.version),p=`
1234      float process(int[${u}] indices) {
1235        int logical_row_start_offset = indices[0] * ${n};
1236
1237        float max = getColorAsFloat(${l.texture2D}(A, offsetToCoords(logical_row_start_offset, ${s},
1238        ${a} )));
1239        for(int i=1; i<${n}; ++i)
1240        {
1241          float current = getColorAsFloat(${l.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1242            ${s}, ${a})));
1243          if(current > max)
1244          max = current;
1245        }
1246
1247        return max;
1248      }`;return{...Fc,output:{dims:o,type:e.type,textureType:0},shaderSource:p}},Qb=(t,e,r,n,o,s)=>{let[a,u]=t.calculateTextureWidthAndHeight(e.dims,0),l=s.length;if(r<1||n<1)throw Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==s.length)throw Error("Dimensionality of the output should be 1");if(s[0]!==r)throw Error("Shape of the output should be equal to logical row count");if(1!==o.length)throw Error("Dimensionality of the intermediate results should be 1");if(o[0]!==r)throw Error("Shape of the intermediate results should be equal to logical row count");let p=G(t.session.backend.glContext.version),c=`
1249      float process(int[${l}] indices) {
1250        int logical_row_start_offset = indices[0] * ${n};
1251
1252        float norm_factor = 0.0;
1253        float max = _Max(indices);
1254        for(int i=0; i<${n}; ++i)
1255        {
1256          norm_factor += exp(getColorAsFloat(${p.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
1257            ${a}, ${u}))) - max);
1258        }
1259
1260        return norm_factor;
1261      }`;return{...Cc,output:{dims:s,type:e.type,textureType:0},shaderSource:c}},tg=(t,e,r,n,o,s)=>{let[a,u]=t.calculateTextureWidthAndHeight(e.dims,0),l=e.dims.length;if(r<1||n<1)throw Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length||1!==s.length)throw Error("Dimensionality of the intermediate results should be 1");if(o[0]!==r||s[0]!==r)throw Error("Shape of the intermediate results should be equal to logical row count");let p=`
1262      float process(int[${l}] indices) {
1263
1264      // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
1265      int offset = coordsToOffset(TexCoords, ${a}, ${u});
1266
1267      //determine the logical row for this index
1268      int logical_row_index[1];
1269      logical_row_index[0] = offset / ${n};
1270
1271      float norm_factor = _Norm(logical_row_index);
1272
1273      // avoid possible division by 0
1274      // if norm_facor is 0, all elements are zero
1275      // if so, return 0
1276      if(norm_factor == 0.0)
1277        return 0.0;
1278
1279      return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
1280    }`;return{...Nc,output:{dims:e.dims,type:e.type,textureType:0},shaderSource:p}},zc=t=>{if(!t||1!==t.length)throw Error("Softmax requires 1 input.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw Error("Invalid input type")}}),Xc=O(()=>{"use strict";It(),Y(),j(),Hc={name:"Split",inputNames:["A"],inputTypes:[0]},qc=(t,e,r)=>{ng(e);let n=B.normalizeAxis(r.axis,e[0].dims.length),o=eg(t,e,n,r),s=[];for(let a=0;a<o;++a)s.push(t.run({...Hc,cacheHint:`${r.cacheKey};${a}`,get:()=>rg(t,e[0],r,n,a)},e));return s},jc=t=>{let e=t.attributes.getInt("axis",0),r=t.attributes.getInts("split",[]),n=t.outputs.length;return W({axis:e,split:r,numOutputs:n})},eg=(t,e,r,n)=>{let[,o]=$r.splitShape(e[0].dims,r,n.split,n.numOutputs);return o.length},rg=(t,e,r,n,o)=>{let[s,a]=$r.splitShape(e.dims,n,r.split,r.numOutputs),u=a[o],l=s[o],p=`
1281      float process(int indices[${l.length}]) {
1282        indices[${n}] += ${u};
1283        return _A(indices);
1284      }
1285    `;return{...Hc,cacheHint:`${r.cacheKey}:${o}`,output:{dims:l,type:e.type,textureType:0},shaderSource:p}},ng=t=>{if(!t||1!==t.length)throw Error("Split requires one input.");if("int8"!==t[0].type&&"uint8"!==t[0].type&&"int16"!==t[0].type&&"uint16"!==t[0].type&&"int32"!==t[0].type&&"uint32"!==t[0].type&&"float32"!==t[0].type&&"float64"!==t[0].type&&"bool"!==t[0].type)throw Error("Invalid input type.")}}),Yc=O(()=>{"use strict";Y(),Fi=(t,e,r)=>{og(e);let n=B.squeezeShape(e[0].dims,r);return[t.reshapeUnpacked(e[0],n)]},Kc=(t,e)=>(ig(e),Fi(t,[e[0]],Array.from(e[1].integerData))),Jc=t=>t.attributes.getInts("axes"),og=t=>{if(!t||1!==t.length)throw Error("Squeeze requires 1 input.");if("string"===t[0].type)throw Error("invalid input tensor types.")},ig=t=>{if(!t||2!==t.length)throw Error("Squeeze requires 2 inputs.");if("int32"!==t[1].type)throw Error("Invalid input type.")}}),Qc=O(()=>{"use strict";ut(),j(),Zc=(t,e)=>{sg(e);let r={name:"Sum",inputNames:e.map((t,e)=>`X${e}`),inputTypes:Array(e.length).fill(0)};return[t.run({...r,get:()=>ag(t,e,r)},e)]},ag=(t,e,r)=>{let n=G(t.session.backend.glContext.version),o=e[0].dims.slice(),s=`
1286      void main() {
1287        vec4 result = ${e.map((t,e)=>`${n.texture2D}(X${e},TexCoords)`).join(" + ")};
1288        ${n.output} = result;
1289      }
1290    `;return{...r,output:{dims:o,type:e[0].type,textureType:0},hasMain:!0,shaderSource:s}},sg=t=>{if(!t||0===t.length)throw Error("Sum requires inputs.");let e=t[0].dims.length;for(let r=1;r<t.length;r++){if(e!==t[r].dims.length)throw Error("Input shapes are mismatched.");for(let n=0;n<e;n++)if(t[0].dims[n]!==t[r].dims[n])throw Error("Input shapes are not matched.")}if("float32"!==t[0].type&&"float64"!==t[0].type)throw Error("Invalid input type.");for(let e=1;e<t.length;e++)if(t[0].type!==t[e].type)throw Error("Input types are not matched.")}}),ep=O(()=>{"use strict";Rr(),j(),tp=(t,e)=>{lg(e);let r={name:"Tile",inputNames:["A"],inputTypes:[0]};return[t.run({...r,get:()=>ug(t,e,r)},e)]},ug=(t,e,r)=>{let n=e[0].dims.slice(),o=Array(n.length),s=[];for(let t=0;t<n.length;t++)o[t]=n[t]*e[1].numberData[t],s.push(`inputIdx[${t}] = int(mod(float(outputIdx[${t}]), ${n[t]}.));`);let a=o.length,u=`
1291      float process(int outputIdx[${a}]) {
1292        int inputIdx[${a}];
1293        ${s.join(`
1294`)}
1295        return _A(inputIdx);
1296      }
1297    `;return{...r,output:{dims:o,type:e[0].type,textureType:0},shaderSource:u}},lg=t=>{if(!t||2!==t.length)throw Error("Tile requires 2 input.");if(1!==t[1].dims.length)throw Error("The second input shape must 1 dimension.");
1297if(t[1].dims[0]!==t[0].dims.length)throw Error("Invalid input shape.");if(-1===Pe.indexOf(t[0].type))throw Error("Invalid input type.");if("int32"!==t[1].type&&"int16"!==t[1].type)throw Error("Invalid repeat type.")}}),op=O(()=>{"use strict";Y(),Ci=(t,e,r)=>{fg(e);let n=B.unsqueezeShape(e[0].dims,r);return[t.reshapeUnpacked(e[0],n)]},rp=(t,e)=>(cg(e),Ci(t,[e[0]],Array.from(e[1].integerData))),np=t=>t.attributes.getInts("axes"),fg=t=>{if(!t||1!==t.length)throw Error("Unsqueeze requires 1 input.");if("string"===t[0].type)throw Error("invalid input tensor types.")},cg=t=>{if(!t||2!==t.length)throw Error("Unsqueeze requires 2 inputs.");if("int32"!==t[1].type)throw Error("Invalid input type.")}}),ap=O(()=>{"use strict";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(t){let e={},r;for(;null!==(r=sp.exec(t));){let t=r[3].split(",").map(t=>{let e=t.trim().split(" ");return e&&2===e.length?{type:e[0],name:e[1]}:null}).filter(t=>null!==t);e[r[2]]={params:t,body:r[4]}}for(let n in e){let o=RegExp(pg.replace("__FUNC__",n),"gm");for(;null!==(r=o.exec(t));){let o=r[1],s=r[2],a=r[3].split(","),u=o?`${o} ${s};`:"",l=e[n].body,p="";e[n].params.forEach((t,e)=>{t&&(p+=`${t.type} ${t.name} = ${a[e]};
1298`)}),l=(l=`${p}
1299 ${l}`).replace("return",`${s} = `);let c=`
1300      ${u}
1301      {
1302        ${l}
1303      }
1304      `;t=t.replace(r[0],c)}}return t=t.replace(sp,"")}var sp,pg,lp=O(()=>{"use strict";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(t,e){let r=[],n=[],o=null!=e&&Array.isArray(e)&&0===e.length,s=null==e||o?null:dg(e,t).sort(),a=0;for(let e=0;e<t.length;++e){if(null!=s){if(s[a]===e&&1!==t[e])throw Error(`Can't squeeze axis ${e} since its dim '${t[e]}' is not 1`);(null==s[a]||s[a]>e)&&1===t[e]&&(r.push(t[e]),n.push(e)),s[a]<=e&&a++}1!==t[e]&&(r.push(t[e]),n.push(e))}return{newShape:r,keptDims:n}}function dg(t,e){let r=e.length;return ur((t=null==t?e.map((t,e)=>e):[].concat(t)).every(t=>t>=-r&&t<r),()=>`All values in axis param must be in range [-${r}, ${r}) but got axis ${t}`),ur(t.every(hg),()=>`All values in axis param must be integers but got axis ${t}`),t.map(t=>t<0?r+t:t)}function hg(t){return t%1==0}function mg(t){if(0===t.length)return 1;let e=t[0];for(let r=1;r<t.length;r++)e*=t[r];return e}function fp(t){let e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}var Un,Vn,zn,Wn,Hn,qn,Ri,jn,Xn,Kn,Jn,Ni=O(()=>{"use strict";Ut(),Y(),Un=class{constructor(t){this.maxTextureSize=t}computeTextureWH(t,e){let r=this.computeTexture(t,e);return e&&e.isPacked&&(r[0]/=2,r[1]/=2),e&&e.reverseWH?[r[1],r[0]]:r}computeTexture(t,e){let r=e&&e.isPacked;if(0===t.length)return r?[2,2]:[1,1];let n=this.maxTextureSize;if(e&&void 0!==e.breakAxis){let r=e.breakAxis>=t.length?1:t.slice(e.breakAxis).reduce((t,e)=>t*e),o=e.breakAxis<=0?1:t.slice(0,e.breakAxis).reduce((t,e)=>t*e);if(!(r>n)&&!(o>n))return[r,o];tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${t}, breakAxis:${e.breakAxis}`)}let o=t.slice(0);r&&(n*=2,1===(o=o.map((t,e)=>e>=o.length-2?o[e]%2==0?o[e]:o[e]+1:o[e])).length&&(o=[2,o[0]])),2!==o.length&&(o=hr(o).newShape);let s=mg(o);return o.length<=1&&s<=n?[1,s]:2===o.length&&o[0]<=n&&o[1]<=n?o:3===o.length&&o[0]*o[1]<=n&&o[2]<=n?[o[0]*o[1],o[2]]:3===o.length&&o[0]<=n&&o[1]*o[2]<=n?[o[0],o[1]*o[2]]:4===o.length&&o[0]*o[1]*o[2]<=n&&o[3]<=n?[o[0]*o[1]*o[2],o[3]]:4===o.length&&o[0]<=n&&o[1]*o[2]*o[3]<=n?[o[0],o[1]*o[2]*o[3]]:r?fp(s/4).map(t=>2*t):fp(s)}}}),cp=O(()=>{"use strict";Y(),Te(),ut(),Ni(),pe(),Vn=class extends Ht{constructor(t){super(t)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSampl
vendor: 4,210 bytes, lines 1304-1380
1304ingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){let t="offsetToCoords";return{offsetToCoords:new k(`
1305      vec2 ${t}(int offset, int width, int height) {
1306        int t = offset / width;
1307        int s = offset - t*width;
1308        vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
1309        return coords;
1310      }
1311      `)}}coordsToOffset(){let t="coordsToOffset";return{coordsToOffset:new k(`
1312      int ${t}(vec2 coords, int width, int height) {
1313        float s = coords.s * float(width);
1314        float t = coords.t * float(height);
1315        int offset = int(t) * width + int(s);
1316        return offset;
1317      }
1318      `)}}getOutputSamplingSnippet(){let t=this.context.outputTextureLayout;return t.isPacked?this.getPackedOutputSamplingSnippet(t):this.getUnpackedOutputSamplingSnippet(t)}getPackedOutputSamplingSnippet(t){let e=t.unpackedShape,r=[t.width,t.height],n={},o="getOutputCoords";switch(e.length){case 0:n[o]=this.getOutputScalarCoords();break;case 1:n[o]=this.getOutputPacked1DCoords(e,r);break;case 2:n[o]=this.getOutputPacked2DCoords(e,r);break;case 3:n[o]=this.getOutputPacked3DCoords(e,r);break;default:n[o]=this.getOutputPackedNDCoords(e,r)}let s=`
1319      void setOutput(vec4 val) {
1320        ${G(this.context.glContext.version).output} = val;
1321      }
1322    `;return n.floatTextureSetRGBA=new k(s),n}getUnpackedOutputSamplingSnippet(t){let e=t.unpackedShape,r=[t.width,t.height],n={},o="getOutputCoords";switch(e.length){case 0:n[o]=this.getOutputScalarCoords();break;case 1:n[o]=this.getOutputUnpacked1DCoords(e,r);break;case 2:n[o]=this.getOutputUnpacked2DCoords(e,r);break;case 3:n[o]=this.getOutputUnpacked3DCoords(e,r);break;case 4:n[o]=this.getOutputUnpacked4DCoords(e,r);break;case 5:n[o]=this.getOutputUnpacked5DCoords(e,r);break;case 6:n[o]=this.getOutputUnpacked6DCoords(e,r);break;default:throw Error(`Unsupported output dimensionality: ${e.length}`)}let s=`
1323        void setOutput(float val) {
1324          ${G(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
1325        }
1326    `;return n.floatTextureSetR=new k(s),n}getOutputScalarCoords(){return new k(`
1327      int getOutputCoords() {
1328        return 0;
1329      }
1330    `)}getOutputPacked1DCoords(t,e){let r=e,n="";return n=1===r[0]?`
1331          int getOutputCoords() {
1332            return 2 * int(TexCoords.y * ${r[1]}.0);
1333          }
1334        `:1===r[1]?`
1335          int getOutputCoords() {
1336            return 2 * int(TexCoords.x * ${r[0]}.0);
1337          }
1338        `:`
1339        int getOutputCoords() {
1340          ivec2 resTexRC = ivec2(TexCoords.xy *
1341                                 vec2(${r[0]}, ${r[1]}));
1342          return 2 * (resTexRC.y * ${r[0]} + resTexRC.x);
1343        }
1344      `,new k(n)}getOutputPacked2DCoords(t,e){let r="";if(Me.arraysEqual(t,e))return r=`
1345        ivec2 getOutputCoords() {
1346          return 2 * ivec2(TexCoords.xy * vec2(${e[0]}, ${e[1]}));
1347        }
1348      `,new k(r);let n=e,o=Math.ceil(t[1]/2);return r=`
1349        ivec2 getOutputCoords() {
1350          ivec2 resTexRC = ivec2(TexCoords.xy *
1351                                vec2(${n[0]}, ${n[1]}));
1352
1353          int index = resTexRC.y * ${n[0]} + resTexRC.x;
1354
1355          // reverse r and c order for packed texture
1356          int r = imod(index, ${o}) * 2;
1357          int c = 2 * (index / ${o});
1358
1359          return ivec2(r, c);
1360        }
1361      `,new k(r)}getOutputPacked3DCoords(t,e){let r=[e[0],e[1]],n=Math.ceil(t[2]/2),o=n*Math.ceil(t[1]/2),s=`
1362        ivec3 getOutputCoords() {
1363          ivec2 resTexRC = ivec2(TexCoords.xy *
1364                                vec2(${r[0]}, ${r[1]}));
1365          int index = resTexRC.y * ${r[0]} + resTexRC.x;
1366
1367          int b = index / ${o};
1368          index -= b * ${o};
1369
1370          // reverse r and c order for packed texture
1371          int r = imod(index, ${n}) * 2;
1372          int c = 2 * (index / ${n});
1373
1374          return ivec3(b, r, c);
1375        }
1376      `;return new k(s)}getOutputPackedNDCoords(t,e){let r=[e[0],e[1]],n=Math.ceil(t[t.length-1]/2),o=n*Math.ceil(t[t.length-2]/2),s=o,a="",u="b, r, c";for(let e=2;e<t.length-1;e++)s*=t[t.length-e-1],a=`
1377      int b${e} = index / ${s};
1378      index -= b${e} * ${s};
1379    `+a,u=`b${e}, `+u;let l=`
1380      ivec${t.length} getOutputCoords() {
1381        ivec2 resTexRC = ivec2(TexCoords.xy *
1382                              vec2(${r[0]}, ${r[1]}));
1383        int index = resTexRC.y * ${r[0]} + resTexRC.x;
1384
1385        ${a}
1386
1387        int b = index / ${o};
1388        index -= b * ${o};
1389
1390        // reverse r and c order for packed texture
1391        int r = imod(index, ${n}) * 2;
1392        int c = 2 * (index / ${n});
1393
1394        return ivec${t.length}(${u});
1395      }
1396    `;return new k(l)}getOutputUnpacked1DCoords(t,e){let r=`
1397        int getOutputCoords() {
1398          ivec2 resTexRC = ivec2(TexCoords.xy *
1399                                vec2(${e[0]}, ${e[1]}));
1400          return resTexRC.y * ${e[0]} + resTexRC.x;
1401        }
1402      `;return new k(r)}getOutputUnpacked2DCoords(t,e){let r=`
1403        ivec2 getOutputCoords() {
1404          ivec2 resTexRC = ivec2(TexCoords.xy *
1405                                vec2(${e[0]}, ${e[1]}));
1406          int index = resTexRC.y * ${e[0]} + resTexRC.x;
1407          int r = index / ${t[1]};
1408          int c = index - r * ${t[1]};
1409          return ivec2(r, c);
1410        }
1411      `;return new k(r)}getOutputUnpacked3DCoords(t,e){let r="",n=t.length,o=null;n<2&&(o=[]),(o=Array(n-1))[n-2]=t[n-1];for(let e=n-3;e>=0;--e)o[e]=o[e+1]*t[e+1];let s=["r","c","d"],a=o.map((t,e)=>{let r=`int ${s[e]} = index / ${t}`,n=e===o.length-1?`int ${s[e+1]} = index - ${s[e]} * ${t}`:`index -= ${s[e]} * ${t}`;return`${r}; ${n};`}).join("");return r=`
1412        ivec3 getOutputCoords() {
1413          ivec2 resTexRC = ivec2(TexCoords.xy *
1414                                vec2(${e[0]}, ${e[1]}));
1415          int index = resTexRC.y * ${e[0]} + resTexRC.x;
1416          ${a}
1417          return ivec3(r, c, d);
1418        }
1419      `,new k(r)}getOutputUnpacked4DCoords(t,e){let r="",n=t.length,o=null;n<2&&(o=[]),(o=Array(n-1))[n-2]=t[n-1];for(let e=n-3;e>=0;--e)o[e]=o[e+1]*t[e+1];let s=["r","c","d","d2"],a=o.map((t,e)=>{let r=`int ${s[e]} = index / ${t}`,n=e===o.length-1?`int ${s[e+1]} = index - ${s[e]} * ${t}`:`index -= ${s[e]} * ${t}`;return`${r}; ${n};`}).join("");return r=`
1420      ivec4 getOutputCoords() {
1421          ivec2 resTexRC = ivec2(TexCoords.xy *
1422                                vec2(${e[0]}, ${e[1]}));
1423          int index = resTexRC.y * ${e[0]} + resTexRC.x;
1424          ${a}
1425          return ivec4(r, c, d, d2);
1426        }
1427      `,new k(r)}getOutputUnpacked5DCoords(t,e){let r="",n=t.length,o=null;n<2&&(o=[]),(o=Array(n-1))[n-2]=t[n-1];for(let e=n-3;e>=0;--e)o[e]=o[e+1]*t[e+1];let s=["r","c","d","d2","d3"],a=o.map((t,e)=>{let r=`int ${s[e]} = index / ${t}`,n=e===o.length-1?`int ${s[e+1]} = index - ${s[e]} * ${t}`:`index -= ${s[e]} * ${t}`;return`${r}; ${n};`}).join("");return r=`
1428      ivec5 getOutputCoords() {
1429          ivec2 resTexRC = ivec2(TexCoords.xy *
1430                                vec2(${e[0]}, ${e[1]}));
1431          int index = resTexRC.y * ${e[0]} + resTexRC.x;
1432          ${a}
1433          return ivec5(r, c, d, d2, d3);
1434        }
1435      `,new k(r)}getOutputUnpacked6DCoords(t,e){let r="",n=t.length,o=null;n<2&&(o=[]),(o=Array(n-1))[n-2]=t[n-1];for(let e=n-3;e>=0;--e)o[e]=o[e+1]*t[e+1];let s=["r","c","d","d2","d3","d4"],a=o.map((t,e)=>{let r=`int ${s[e]} = index / ${t}`,n=e===o.length-1?`int ${s[e+1]} = index - ${s[e]} * ${t}`:`index -= ${s[e]} * ${t}`;return`${r}; ${n};`}).join("");return r=`
1436     ivec6 getOutputCoords() {
1437         ivec2 resTexRC = ivec2(TexCoords.xy *
1438                               vec2(${e[0]}, ${e[1]}));
1439         int index = resTexRC.y * ${e[0]} + resTexRC.x;
1440         ${a}
1441         return ivec6(r, c, d, d2, d3, d4);
1442       }
1443     `,new k(r)}getCommonUtilFuncs(){let t={},e="uvFromFlat";t[e]=new k(`
1444    vec2 uvFromFlat(int texNumR, int texNumC, int index) {
1445      int texC = index / texNumR;
1446      int texR = index - texC * texNumR;
1447      // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to
1448      //       v.
1449      return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);
1450    }
1451    `),t[e="packedUVfrom1D"]=new k(`
1452      vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
1453        int texelIndex = index / 2;
1454        int texR = texelIndex / texNumC;
1455        int texC = texelIndex - texR * texNumC;
1456        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1457      }
1458      `),t[e="packedUVfrom2D"]=new k(`
1459      vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {
1460        int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
1461        int texR = texelIndex / texNumC;
1462        int texC = texelIndex - texR * texNumC;
1463        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1464      }
1465      `),t[e="packedUVfrom3D"]=new k(`
1466      vec2 packedUVfrom3D(int texNumR, int texNumC,
1467          int texelsInBatch, int texelsInLogicalRow, int b,
1468          int row, int col) {
1469        int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
1470        int texR = index / texNumC;
1471        int texC = index - texR * texNumC;
1472        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
1473      }
1474      `),e="sampleTexture";let r=G(this.context.glContext.version);return t[e]=new k(`
1475        float sampleTexture(sampler2D textureSampler, vec2 uv) {
1476            return ${r.texture2D}(textureSampler, uv).r;
1477        }`),t}
1477getInputsSamplingSnippets(){let t={},e=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((r,n)=>{let o=this.context.inputTextureLayouts[n],s=An(r);o.isPacked?t[s]=this.getPackedSamplerFromInput(s,r,o):t[s]=this.getUnpackedSamplerFromInput(s,r,o);let a=Yu(r);o.unpackedShape.length<=e.unpackedShape.length&&(o.isPacked?t[a]=this.getPackedSamplerAtOutputCoords(a,o,e,r):t[a]=this.getUnpackedSamplerAtOutputCoords(a,o,e,r))}),t}getPackedSamplerAtOutputCoords(t,e,r,n){let o=e.unpackedShape,s=r.unpackedShape,a=An(n),u=o.length,l=s.length,p=kt.getBroadcastDims(o,s),c=Bt(l),d=l-u,h,f=ne();h=0===u?"":l<2&&p.length>=1?"coords = 0;":p.map(t=>`coords.${f[t+d]} = 0;`).join(`
1478`);let g="";g=l<2&&u>0?"coords":o.map((t,e)=>`coords.${f[e+d]}`).join(", ");let m="return outputValue;",b=1===B.size(o),y=1===B.size(s);if(1!==u||b||y){if(b&&!y)m=1===l?`
1479          return vec4(outputValue.x, outputValue.x, 0., 0.);
1480        `:`
1481          return vec4(outputValue.x);
1482        `;else if(p.length){let t=u-2,e=u-1;p.indexOf(t)>-1&&p.indexOf(e)>-1?m="return vec4(outputValue.x);":p.indexOf(t)>-1?m="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":p.indexOf(e)>-1&&(m="return vec4(outputValue.xx, outputValue.zz);")}}else m=`
1483        return vec4(outputValue.xy, outputValue.xy);
1484      `;let x=`
1485        int lastDim = coords.${f[l-1]};
1486        coords.${f[l-1]} = coords.${f[l-2]};
1487        coords.${f[l-2]} = lastDim;
1488      `,v=`
1489      vec4 ${t}() {
1490        ${c} coords = getOutputCoords();
1491        ${x}
1492        ${h}
1493        vec4 outputValue = ${a}(${g});
1494        ${m}
1495      }
1496    `;return new k(v,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(t,e,r,n){let o=[r.width,r.height],s=[e.width,e.height],a=e.unpackedShape.length,u=r.unpackedShape.length,l=e.unpackedShape,p=r.unpackedShape,c=An(n);if(a===u&&Me.arraysEqual(s,o)){let e=`
1497          float ${t}() {
1498            return sampleTexture(${n}, TexCoords);
1499          }
1500        `;return new k(e,["coordinates.sampleTexture"])}let d=Bt(u),h=kt.getBroadcastDims(l,p),f=u-a,g,m=ne();g=0===a?"":u<2&&h.length>=1?"coords = 0;":h.map(t=>`coords.${m[t+f]} = 0;`).join(`
1501`);let b="";b=u<2&&a>0?"coords":e.unpackedShape.map((t,e)=>`coords.${m[e+f]}`).join(", ");let y=`
1502        float ${t}() {
1503          ${d} coords = getOutputCoords();
1504          ${g}
1505          return ${c}(${b});
1506        }
1507      `;return new k(y,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(t,e,r){switch(r.unpackedShape.length){case 0:return this.getPackedSamplerScalar(t,e);case 1:return this.getPackedSampler1D(t,e,r);case 2:return this.getPackedSampler2D(t,e,r);case 3:return this.getPackedSampler3D(t,e,r);default:return this.getPackedSamplerND(t,e,r)}}getUnpackedSamplerFromInput(t,e,r){let n=r.unpackedShape;switch(n.length){case 0:return this.getUnpackedSamplerScalar(t,e,r);case 1:return this.getUnpackedSampler1D(t,e,r);case 2:return this.getUnpackedSampler2D(t,e,r);case 3:return this.getUnpackedSampler3D(t,e,r);case 4:return this.getUnpackedSampler4D(t,e,r);case 5:return this.getUnpackedSampler5D(t,e,r);case 6:return this.getUnpackedSampler6D(t,e,r);default:throw Error(`Unsupported dimension ${n.length}-D`)}}getPackedSamplerScalar(t,e){let r=G(this.context.glContext.version),n=`
1508          vec4 ${t}() {
1509            return ${r.texture2D}(${e}, halfCR);
1510          }
1511        `;return new k(n)}getPackedSampler1D(t,e,r){let n=[r.width,r.height],o=[n[1],n[0]],s=G(this.context.glContext.version),a=`vec4 ${t}(int index) {
1512      vec2 uv = packedUVfrom1D(
1513      ${o[0]}, ${o[1]}, index);
1514      return ${s.texture2D}(${e}, uv);
1515    }`;return new k(a,["coordinates.packedUVfrom1D"])}getPackedSampler2D(t,e,r){let n=r.unpackedShape,o=[r.width,r.height],s=G(this.context.glContext.version),a=o[0],u=o[1];if(null!=o&&Me.arraysEqual(n,o)){let r=`vec4 ${t}(int row, int col) {
1516        vec2 uv = (vec2(col, row) + halfCR) / vec2(${u}.0, ${a}.0);
1517        return ${s.texture2D}(${e}, uv);
1518      }`;return new k(r)}let l=o,p=Math.ceil(n[1]/2),c=`vec4 ${t}(int row, int col) {
1519      vec2 uv = packedUVfrom2D(${l[1]}, ${l[0]}, ${p}
1519, row, col);
1520      return ${s.texture2D}(${e}, uv);
1521    }`;return new k(c,["coordinates.packedUVfrom2D"])}getPackedSampler3D(t,e,r){let n=r.unpackedShape,o=[r.width,r.height],s=[o[0],o[1]],a=G(this.context.glContext.version);if(1===n[0]){let o=n.slice(1),s=[1,2],a=lr(n,o),u=["b","row","col"],l=JSON.parse(JSON.stringify(r));l.unpackedShape=a;let p=this.getPackedSamplerFromInput(t,e,l),c=`${p.routineBody}
1522      vec4 ${t}(int b, int row, int col) {
1523        return ${t}(${fr(u,s)});
1524      } `;return new k(c,p.dependencies)}let u=s[0],l=s[1],p=Math.ceil(n[2]/2),c=p*Math.ceil(n[1]/2),d=`vec4 ${t}(int b, int row, int col) {
1525      vec2 uv = packedUVfrom3D(
1526        ${l}, ${u}, ${c}, ${p}, b, row, col);
1527      return ${a.texture2D}(${e}, uv);}`;return new k(d,["coordinates.packedUVfrom3D"])}getPackedSamplerND(t,e,r){let n=r.unpackedShape,o=n.length,s=[r.width,r.height],a=G(this.context.glContext.version),u=[s[0],s[1]],l=u[1],p=u[0],c=Math.ceil(n[o-1]/2),d=c*Math.ceil(n[o-2]/2),h="int b, int row, int col",f=`b * ${d} + (row / 2) * ${c} + (col / 2)`;for(let t=2;t<o-1;t++)h=`int b${t}, `+h,d*=n[o-t-1],f=`b${t} * ${d} + `+f;let g=`vec4 ${t}(${h}) {
1528      int index = ${f};
1529      int texR = index / ${p};
1530      int texC = index - texR * ${p};
1531      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${p}, ${l});
1532      return ${a.texture2D}(${e}, uv);
1533    }`;return new k(g)}getUnpackedSamplerScalar(t,e,r){let[n,o]=[r.width,r.height];if(1===n&&1===o){let r=`
1534          float ${t}() {
1535            return sampleTexture(${e}, halfCR);
1536          }
1537        `;return new k(r,["coordinates.sampleTexture"])}let s=`
1538        float ${t}() {
1539          int offset_${e} = coordsToOffset(TexCoords, ${n}, ${o});
1540          vec2 uv = uvFromFlat(${n}, ${o}, offset_${e});
1541          return sampleTexture(${e}, uv);
1542        }
1543      `;return new k(s,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(t,e,r){let n=r.width,o=r.height;if(1===o&&1===n){let r=`
1544        float ${t}(int index) {
1545          return sampleTexture(${e}, halfCR);
1546        }
1547      `;return new k(r,["coordinates.sampleTexture"])}if(1===o){let r=`
1548          float ${t}(int index) {
1549            vec2 uv = vec2((float(index) + 0.5) / ${n}.0, 0.5);
1550            return sampleTexture(${e}, uv);
1551          }
1552        `;return new k(r,["coordinates.sampleTexture"])}if(1===n){let r=`
1553          float ${t}(int index) {
1554            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${o}.0);
1555            return sampleTexture(${e}, uv);
1556          }
1557        `;return new k(r,["coordinates.sampleTexture"])}let s=`
1558        float ${t}(int index) {
1559          vec2 uv = uvFromFlat(${n}, ${o}, index);
1560          return sampleTexture(${e}, uv);
1561        }
1562      `;return new k(s,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(t,e,r){let n=r.unpackedShape,o=[r.height,r.width];if(null!=o&&Me.arraysEqual(n,o)){let r=o[1],n=o[0],s=`
1563          float ${t}(int row, int col) {
1564            vec2 uv = (vec2(row, col) + halfCR) / vec2(${r}.0, ${n}.0);
1565            return sampleTexture(${e}, uv);
1566          }
1567        `;return new k(s,["coordinates.sampleTexture"])}let{newShape:s,keptDims:a}=hr(n),u=s;if(u.length<n.length){let o=lr(n,u),s=JSON.parse(JSON.stringify(r));s.unpackedShape=o;let l=["col","row"],p=`
1568          ${this.getUnpackedSamplerFromInput(t,e,s).routineBody}
1569          float ${t}(int row, int col) {
1570            return ${t}(${fr(l,a)});
1571          }
1572        `;return new k(p,["coordinates.sampleTexture"])}let l=o[1],p=o[0];if(1===p){let r=`
1573          float ${t}(int row, int col) {
1574            int offset_${e} = coordsToOffset(TexCoords, ${l}, ${p});
1575            float index = dot(vec3(row, col, offset_${e}), vec3(${n[1]}, 1, 1));
1576            vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);
1577            return sampleTexture(${e}, uv);
1578          }
1579        `;return new k(r,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(1===l){let r=`
1580          float ${t}(int row, int col) {
1581            int offset_${e} = coordsToOffset(TexCoords, ${l}, ${p});
1582            float index = dot(vec3(row, col, offset_${e}), vec3(${n[1]}, 1, 1));
1583            vec2 uv = vec2((index + 0.5) / ${p}.0, 0.5);
1584            return sampleTexture(${e}, uv);
1585          }
1586        `;return new k(r,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let c=`
1587        float ${t}(int row, int col) {
1588          int index = col * ${n[1]} + row;
1589          vec2 uv = uvFromFlat(${l}, ${p}, index);
1590          return sampleTexture(${e}, uv);
1591        }
1592      `;return new k(c,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(t,e,r){let n=r.unpackedShape,o=n[1]*n[2],s=n[2],{newShape:a,keptDims:u}=hr(n),l=a;if(l.length<n.length){let o=lr(n,l),s=["batch","col","row"],a=JSON.parse(JSON.stringify(r));a.unpackedShape=o;let p=this.getUnpackedSamplerFromInput(t,e,a),c=u.reverse(),d=`
1593          ${p.routineBody}
1594          float ${t}(int batch, int row, int col) {
1595            return ${t}(${fr(s,c)});
1596          }
1597        `;return new k(d,p.dependencies)}let p=r.width,c=r.height,d=`
1598          float ${t}(int depth, int row, int col) {
1599            // Explicitly use integer operations as dot() only w
1599orks on floats.
1600            int index = depth * ${o} + col * ${s} + row;
1601            vec2 uv = uvFromFlat(${p}, ${c}, index);
1602            return sampleTexture(${e}, uv);
1603          }
1604      `;return new k(d,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(t,e,r){let n=r.unpackedShape,o=n[3],s=n[2]*o,a=n[1]*s,u=r.width,l=r.height,p=`
1605        float ${t}(int row, int col, int depth, int depth2) {
1606          int index = row * ${a} + col * ${s} +
1607              depth2 * ${o} + depth;
1608          vec2 uv = uvFromFlat(${u}, ${l}, index);
1609          return sampleTexture(${e}, uv);
1610        }
1611      `;return new k(p,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(t,e,r){let n=r.unpackedShape,o=n[4],s=n[3]*o,a=n[2]*s,u=n[1]*a,{newShape:l,keptDims:p}=hr(n);if(l.length<n.length){let o=lr(n,l),s=["row","col","depth","depth2","depth3"],a=JSON.parse(JSON.stringify(r));a.unpackedShape=o;let u=`
1612          ${this.getUnpackedSamplerFromInput(t,e,a).routineBody}
1613          float ${t}(int row, int col, int depth, int depth2, int depth3) {
1614            return ${t}(${fr(s,p)});
1615          }
1616        `;return new k(u,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let c=r.width,d=r.height,h=`
1617        float ${t}(int row, int col, int depth, int depth2, int depth3) {
1618          int index = row * ${u} + col * ${a} + depth * ${s} +
1619          depth3 * ${o} + depth2;
1620          vec2 uv = uvFromFlat(${c}, ${d}, index);
1621          return sampleTexture(${e}, uv);
1622        }
1623      `;return new k(h,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(t,e,r){let n=r.unpackedShape,o=n[5],s=n[4]*o,a=n[3]*s,u=n[2]*a,l=n[1]*u,{newShape:p,keptDims:c}=hr(n);if(p.length<n.length){let o=lr(n,p),s=["row","col","depth","depth2","depth3","depth4"],a=JSON.parse(JSON.stringify(r));a.unpackedShape=o;let u=`
1624            ${this.getUnpackedSamplerFromInput(t,e,a).routineBody}
1625            float ${t}(int row, int col, int depth,
1626              int depth2, int depth3, int depth4) {
1627              return ${t}(${fr(s,c)});
1628            }
1629          `;return new k(u,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let d=r.width,h=r.height,f=`
1630          float ${t}(int row, int col, int depth,
1631            int depth2, int depth3, int depth4) {
1632            int index = row * ${l} + col * ${u} + depth * ${a} +
1633            depth2 * ${s} + depth3 * ${o} + depth4;
1634            vec2 uv = uvFromFlat(${d}, ${h}, index);
1635            return sampleTexture(${e}, uv);
1636          }
1637        `;return new k(f,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}
vendor: 3,328 bytes, lines 1637-1688
1637toVec(){let t=this.context.outputTextureLayout,e=t.shape.length,r=t.strides,n=t.width,o=t.height,s=[];for(let t=0;t<e-1;++t)s.push(`
1638        c[${t}] = offset / ${r[t]};`),s.push(`
1639        offset -= c[${t}] * ${r[t]};`);s.push(`
1640        c[${e-1}] = offset;`);let a=`
1641      void toVec(vec2 texCoords, out int c[${e}]) {
1642        int offset = coordsToOffset(texCoords, ${n}, ${o});
1643        ${s.join("")}
1644      }
1645      void toVec(int offset, out int c[${e}]) {
1646        ${s.join("")}
1647      }
1648    `;return{toVec:new k(a,["coordinates.coordsToOffset"])}}valueFrom(){let t={};return this.context.programInfo.inputNames.forEach((e,r)=>{let n=this.context.inputTextureLayouts[r],o=(n.unpackedShape.length>0?n.unpackedShape:n.shape).length,s=`_${e}`;t[s]=new k(this.getValueFromSingle(e,o,n.width,n.height,!1),[`shapeUtils.indicesToOffset${s}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),t[s+="_T"]=new k(this.getValueFromSingle(e,o,n.width,n.height,!0),[`shapeUtils.indicesToOffset${s}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),t}getValueFromSingle(t,e,r,n,o){let s=`_${t}`;o&&(s+="_T");let a=G(this.context.glContext.version);return`
1649        float ${s}(int m[${e}]) {
1650          int offset = indicesToOffset${s}(m);
1651          vec2 coords = offsetToCoords(offset, ${r}, ${n});
1652          float value = getColorAsFloat(${a.texture2D}(${t}, coords));
1653          return value;
1654        }
1655        `}getPackedValueFrom(t,e,r,n,o){let s=`_${t}_Pack`;o&&(s+="_T");let a=G(this.context.glContext.version);return`
1656        vec4 ${s}(int m[${e}]) {
1657          int offset = indicesToOffset_${t}(m);
1658          vec2 coords = offsetToCoords(offset, ${r}, ${n});
1659          return ${a.texture2D}(${t}, coords);
1660        }
1661        `}}}),pp=O(()=>{"use strict";Te(),zn=class t extends Ht{constructor(t){super(t)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new k(`highp vec4 encode(highp float f) {
1662        return vec4(f, 0.0, 0.0, 0.0);
1663      }
1664        `)}}decodeFloat32(){return{decode:new k(`highp float decode(highp vec4 rgba) {
1665        return rgba.r;
1666      }
1667        `)}}encodeUint8(){let e=t.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new k(`
1668      highp vec4 encode(highp float f) {
1669        highp float F = abs(f);
1670        highp float Sign = step(0.0,-f);
1671        highp float Exponent = floor(log2(F));
1672        highp float Mantissa = (exp2(- Exponent) * F);
1673        Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));
1674        highp vec4 rgba;
1675        rgba[0] = 128.0 * Sign  + floor(Exponent*exp2(-1.0));
1676        rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);
1677        rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));
1678        rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));
1679        ${e}
1680        rgba = rgba / 255.0; // values need to be normalized to [0,1]
1681        return rgba;
1682    }
1683        `)}}decodeUint8(){let e=t.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new k(`
1684        highp float decode(highp vec4 rgba) {
1685          rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
1686          ${e}
1687          highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;
1688          highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) 
1688- 127.0;
1689          highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);
1690          highp float Result =  Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
1691          return Result;
1692      }
1693        `)}}static isLittleEndian(){let t=new ArrayBuffer(4),e=new Uint32Array(t),r=new Uint8Array(t);if(e[0]=3735928559,239===r[0])return!0;if(222===r[0])return!1;throw Error("unknown endianness")}}}),dp=O(()=>{"use strict";Te(),ut(),Wn=class extends Ht{constructor(t){super(t)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let t=G(this.context.glContext.version);return{setFragColor:new k(`
1694        void setFragColor(float value) {
1695            ${t.output} = encode(value);
1696        }
1697        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new k(`
1698        float getColorAsFloat(vec4 color) {
1699            return decode(color);
1700        }
1701        `,["encoding.decode"])}}}}),hp=O(()=>{"use strict";Te(),Hn=class t extends Ht{constructor(t){super(t)}getFunctions(){return{...this.bcastIndex(),...this.bcastMatmulIndex(),...this.offsetToIndices(),...this.indicesToOffset(),...this.incrementIndices()}}getCustomTypes(){return{}}bcastIndex(){let t=this.context.outputTextureLayout.shape.length,e={};return this.context.programInfo.inputNames.forEach((r,n)=>{let o=this.context.inputTextureLayouts[n].unpackedShape;if(o.length<=t){let n=o.length,s=t-n,a=`bcastIndices_${r}`,u="";for(let t=0;t<n;++t)u+=`
1702          realIndices[${t}] = int( mod(float(bcastedIndices[${s+t}]), ${o[t]}.0) );
1703          `;let l=`
1704        void ${a} (int bcastedIndices[${t}], out int realIndices[${n}]) {
1705          ${u}
1706        }
1707        `;e[a]=new k(l)}}),e}bcastMatmulIndex(){let t=this.context.outputTextureLayout.shape.length,e={};return this.context.programInfo.inputNames.forEach((r,n)=>{let o=this.context.inputTextureLayouts[n].shape;if(!(o.length<2||o.length>t)){let n=o.length,s=t-n,a=`bcastMatmulIndices_${r}`,u="";for(let t=0;t<n-2;++t)u+=`
1708          realIndices[${t}] = int( mod(float(bcastedIndices[${s+t}]), ${o[t]}.0) );
1709          `;let l=`
1710        void ${a}(int bcastedIndices[${t}], out int realIndices[${n}]) {
1711          ${u}
1712          realIndices[${n-1}] = bcastedIndices[${t-1}];
1713          realIndices[${n-2}] = bcastedIndices[${t-2}];
1714        }
1715        `;e[a]=new k(l)}}),e}indicesToOffset(){let e={};return this.context.programInfo.inputNames.forEach((r,n)=>{let o=this.context.inputTextureLayouts[n].shape,s=this.context.inputTextureLayouts[n].strides,a=o.length,u=`indicesToOffset_${r}`;e[u]=new k(t.indexToOffsetSingle(u,a,s)),e[u=`indicesToOffset_${r}_T`]=new k(t.indexToOffsetSingle(u,a,s.slice().reverse()))}),e}static indexToOffsetSingle(t,e,r){let n="";for(let t=e-1;t>=0;--t)n+=`
1716        offset += indices[${t}] * ${r[t]};
1717        `;return`
1718      int ${t}(int indices[${e}]) {
1719        int offset = 0;
1720        ${n}
1721        return offset;
1722      }
1723      `}offsetToIndices(){let e={};return this.context.programInfo.inputNames.forEach((r,n)=>{let o=this.context.inputTextureLayouts[n].shape,s=this.context.inputTextureLayouts[n].strides,a=o.length,u=`offsetToIndices_${r}`;e[u]=new k(t.offsetToIndicesSingle(u,a,s)),e[u=`offsetToIndices_${r}_T`]=new k(t.offsetToIndicesSingle(u,a,s.slice().reverse()))}),e}static offsetToIndicesSingle(t,e,r){let n=[];for(let t=0;t<e-1;++t)n.push(`
1724      indices[${t}] = offset / ${r[t]};`),n.push(`
1725        offset -= indices[${t}] * ${r[t]};`);return n.push(`
1726      indices[${e-1}] = offset;`),`
1727      void ${t}(int offset, out int indices[${e}]) {
1728        ${n.join("")}
1729      }
1730      `}incrementIndices(){let t={};return this.context.programInfo.inputNames.forEach((e,r)=>{let n=this.context.inputTextureLayouts[r].shape,o=n.length,s=`incrementIndices_${e}`,a="";for(let t=0;t<o;++t)a+=`
1731        shape[${t}] = ${n[t]};`;let u=`
1732        void ${s}(int axis, out int indices[${o}]) {
1733          int shape[${o}];
1734          ${a};
1735          for(int i = ${o} -1 ; i >= 0; --i) {
1736            if(i > axis) continue;
1737            indices[i] += 1;
1738            if(indices[i] < shape[i]) {
1739              break;
1740            }
1741            indices[i] = 0;
1742          }
1743        }
1744        `;t[s]=new k(u)}),t}}}),mp=O(()=>{"use strict";Te(),qn=class extends Ht{constructor(t){super(t)}getCustomTypes(){return{}}getFunctions(){return{...this.binaryVecFunctions(),...this.copyVec(),...this.setVecItem(),...this.getVecItem()}}binaryVecFunctions(){let t=this.context.outputTextureLayout.shape.length,e={add:"+=",
1744sub:"-=",mul:"*=",div:"/="},r={};for(let n in e){let o=`${n}Vec`,s="";for(let r=0;r<t;++r)s+=`
1745          dest[${r}] ${e[n]} src[${r}];
1746          `;let a=`
1747        void ${o}(int src[${t}], out int dest[${t}]) {
1748          ${s}
1749        }
1750        `;r[o]=new k(a)}return r}copyVec(){let t=this.context.outputTextureLayout.shape.length,e="";for(let r=0;r<t;++r)e+=`
1751        dest[${r}] = src[${r}];
1752        `;let r=`
1753      void copyVec(int src[${t}], out int dest[${t}]) {
1754        ${e}
1755      }
1756      `;return{copyVec:new k(r)}}setVecItem(){let t=this.context.outputTextureLayout.shape.length,e=`
1757        if(index < 0)
1758            index =${t} + index;
1759        if (index == 0)
1760            m[0] = value;
1761        `;for(let r=1;r<t-1;++r)e+=`
1762        else if (index == ${r})
1763            m[${r}] = value;
1764            `;e+=`
1765        else
1766            m[${t-1}] = value;
1767        `;let r=`
1768      void setVecItem(out int m[${t}], int index, int value) {
1769        ${e}
1770      }
1771        `;return{setVecItem:new k(r)}}getVecItem(){let t=this.context.outputTextureLayout.shape.length,e=`
1772        if(index < 0)
1773            index = ${t} + index;
1774        if (index == 0)
1775            return m[0];
1776      `;for(let r=1;r<t-1;++r)e+=`
1777        else if (index == ${r})
1778            return m[${r}];
1779      `;e+=`
1780        else
1781            return m[${t-1}];
1782        `;let r=`
1783      int getVecItem(int m[${t}], int index) {
1784        ${e}
1785      }
1786    `;return{getVecItem:new k(r)}}}}),bp=O(()=>{"use strict";cp(),pp(),dp(),hp(),mp(),Ri={encoding:zn,fragcolor:Wn,vec:qn,shapeUtils:Hn,coordinates:Vn}}),gp=O(()=>{"use strict";Te(),lp(),bp(),ut(),jn=class{constructor(t,e,r,n){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new Ln(t,e,r,n),Object.keys(Ri).forEach(t=>{let e=new Ri[t](this.context);this.libs[t]=e});let o=this.glslLibRoutineDependencyGraph;for(let t in this.libs){let e=this.libs[t].getFunctions();for(let r in e){let n=t+"."+r,s;o[n]?(s=o[n]).routineBody=e[r].routineBody:(s=new Nr(n,e[r].routineBody),o[n]=s);let a=e[r].dependencies;if(a)for(let t=0;t<a.length;++t)if(o[a[t]])s.addDependency(o[a[t]]);else{let e=new Nr(a[t]);o[a[t]]=e,s.addDependency(e)}}}}preprocess(){let t=this.context.programInfo,e=t.shaderSource;return this.context.programInfo.hasMain||(e=`${e}
1787      ${Ju(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),e=up(e),`${Ku(this.context.glContext.version)}
1788    ${this.getUniforms(t.inputNames,t.variables)}
1789    ${this.getImports(e)}
1790    ${e}`}getImports(t){let e=this.selectGlslLibRoutinesToBeIncluded(t);if(0===e.length)return"";let r="";for(let t=0;t<e.length;++t)if(e[t].routineBody)r+=e[t].routineBody+`
1791`;else throw Error(`Missing body for the Glsl Library routine: ${e[t].name}`);return r}selectGlslLibRoutinesToBeIncluded(t){let e=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(r=>{let n=r.split(".")[1];-1!==t.indexOf(n)&&e.push(this.glslLibRoutineDependencyGraph[r])}),$n.returnOrderedNodes(e)}getUniforms(t,e){let r=[];if(t)for(let e of t)r.push(`uniform sampler2D ${e};`);if(e)for(let t of e)r.push(`uniform ${t.type} ${t.name}${t.arrayLength?`[${t.arrayLength}]`:""};`);return r.join(`
1792`)}}}),yp=O(()=>{"use strict";Yt(),Ut(),gp(),ut(),Xn=class{constructor(t,e,r){this.profiler=t,this.glContext=e,this.textureLayoutStrategy=r,this.repo=new Map,this.attributesBound=!1}getArtifact(t){return this.repo.get(t)}setArtifact(t,e){this.repo.set(t,e)}run(t,e,r){this.profiler.event("op",`ProgramManager.run ${t.programInfo.name??"unknown kernel"}`,()=>{let n=this.glContext.gl,o=t.program;n.useProgram(o);try{this.bindOutput(r),this.attributesBound||this.bindAttributes(t.attribLocations),this.bindUniforms(t.uniformLocations,t.programInfo.variables??[],e)}catch(e){throw tt.error("ProgramManager",t.programInfo.shaderSource),e}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEac
vendor: 13,953 bytes, lines 1792-1796
1792h(t=>this.glContext.deleteProgram(t.program))}build(t,e,r){return this.profiler.event("backend","ProgramManager.build",()=>{let n=new jn(this.glContext,t,e,r),o=n.preprocess(),s=this.compile(o);return{programInfo:t,program:s,uniformLocations:this.getUniformLocations(s,n.context.programInfo.inputNames,n.context.programInfo.variables),attribLocations:this.getAttribLocations(s)}})}compile(t){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let t=Xu(this.glContext.version);this.vertexShader=this.glContext.compileShader(t,this.glContext.gl.VERTEX_SHADER)}z.debug&&tt.verbose("ProrgramManager",`FragShader:
1793${t}
1794`);let e=this.glContext.compileShader(t,this.glContext.gl.FRAGMENT_SHADER),r=this.glContext.createProgram(this.vertexShader,e);return this.glContext.deleteShader(e),r}bindOutput(t){let e=t.width,r=t.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${e}/${r}, shape=${t.shape}, type=${t.tensor.type}`),this.glContext.attachFramebuffer(t.texture,e,r)}bindAttributes(t){let e=t.position,r=t.textureCoord;this.glContext.setVertexAttributes(e,r),this.attributesBound=!0}bindUniforms(t,e,r){let n=this.glContext.gl,o=0;for(let{name:s,type:a,location:u,arrayLength:l}of t){let t=e.find(t=>t.name===s)?.data;if("sampler2D"!==a&&!t)throw Error(`variable '${s}' does not have data defined in program info`);switch(a){case"sampler2D":this.bindTexture(r[o],u,o),o++;break;case"float":l?n.uniform1fv(u,t):n.uniform1f(u,t);break;case"int":l?n.uniform1iv(u,t):n.uniform1i(u,t);break;default:throw Error(`Uniform not implemented: ${a}`)}}}bindTexture(t,e,r){this.glContext.bindTextureToUniform(t.texture,r,e)}getAttribLocations(t){return{position:this.getAttribLocation(t,"position"),textureCoord:this.getAttribLocation(t,"textureCoord")}}getUniformLocations(t,e,r){let n=[];if(e)for(let r of e)n.push({name:r,type:"sampler2D",location:this.getUniformLocation(t,r)});if(r)for(let e of r)n.push({...e,location:this.getUniformLocation(t,e.name)});return n}getUniformLocation(t,e){let r=this.glContext.gl.getUniformLocation(t,e);if(null===r)throw Error(`Uniform ${e} not found.`);return r}getAttribLocation(t,e){return this.glContext.gl.getAttribLocation(t,e)}}}),xp=O(()=>{"use strict";Ut(),Fr(),Kn=class{constructor(t,e,r,n){this.glContext=t,this.layoutStrategy=e,this.profiler=r,this.config=n,this.pendingRead=new Map,n.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(t,e,r,n){let o=this.toEncoderType(t),s=this.glContext.getEncoder(o,e.channels||1,n);if(e.isPacked&&1===n)throw Error("not implemented");let a=e.width,u=e.height,l,p;if(this.config.reuseTextures){l=`${a}x${u}_${s.format}_${s.internalFormat}_${s.textureType}`,(p=this.inUseTextures.get(l))||(p=[],this.inUseTextures.set(l,p));let e=this.idleTextures.get(l);if(e&&e.length>0){let o=e.pop();return p.push(o),1===n&&this.glContext.updateTexture(o,a,u,s,this.toTextureData(t,r)),o}}tt.verbose("TextureManager",`Creating new texture of size ${e.width}x${e.height}`);let c=this.glContext.allocateTexture(a,u,s,this.toTextureData(t,r));return this.config.reuseTextures&&(p.push(c),this.textureLookup.set(c,l)),c}readTexture(t,e,r){return r||(r=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let n=t.shape.reduce((t,e)=>t*e)*r,o=this.glContext.readTexture(t.texture,t.width,t.height,n,this.toEncoderType(e),r);return this.toTensorData(e,o)})}async readTextureAsync(t,e,r){let n=t.tensor.dataId;if(r||(r=1),this.pendingRead.has(n)){let t=this.pendingRead.get(n);return new Promise(e=>t?.push(e))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(n,[]);let o=t.shape.reduce((t,e)=>t*e)*r;await this.glContext.createAndWaitForFence();let s=this.glContext.readTexture(t.texture,t.width,t.height,o,this.toEncoderType(e),r),a=this.toTensorData(e,s),u=this.pendingRead.get(n);return this.pendingRead.delete(n),u?.forEach(t=>t(a)),a})}readUint8TextureAsFloat(t){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let e=t.shape.reduce((t,e)=>t*e),r=this.glContext.readTexture(t.texture,t.width,t.height,4*e,"byte",4);return new Float32Array(r.buffer,r.byteOffset,e)})}releaseTexture(t,e){let r;if(this.config.reuseTextures&&(r=this.textureLookup.get(t.texture))){e&&this.textureLookup.delete(r);let n=this.inUseTextures.get(r);if(n){let e=n.indexOf(t.texture);if(-1!==e){n.splice(e,1);let o=this.idleTextures.get(r);o||(o=[],this.idleTextures.set(r,o)),o.push(t.texture)}}}(!r||e)&&(tt.verbose("TextureManager",`Deleting texture of size ${t.width}x${t.height}`),this.glContext.deleteTexture(t.texture))}toTensorData(t,e){switch(t){case"int16":return e instanceof Int16Array?e:Int16Array.from(e);case"int32":return e instanceof Int32Array?e:Int32Array.from(e);case"int8":return e instanceof Int8Array?e:Int8Array.from(e);case"uint16":return e instanceof Uint16Array?e:Uint16Array.from(e);case"uint32":return e instanceof Uint32Array?e:Uint32Array.from(e);case"uint8":case"bool":return e instanceof Uint8Array?e:Uint8Array.from(e);case"float32":return e instanceof Float32Array?e:Float32Array.from(e);case"float64":return e instanceof Float64Array?e:Float64Array.from(e);default:throw Error(`TensorData type ${t} is not supported`)}}toTextureData(t,e){if(e)return e instanceof Float32Array?e:new Float32Array(e)}toEncoderType(t){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}}),Tp=O(()=>{"use strict";Ut(),Bs(),cl(),ap(),yp(),Ni(),xp(),Jn=class{constructor(t,e){this.backend=t,this.context=e,this.layoutStrategy=new Un(t.glContext.maxTextureSize),this.programManager=new Xn(this.context.profiler,t.glContext,this.layoutStrategy),this.textureManager=new Kn(t.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:"full"===t.textureCacheMode}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=t.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new Dn(this)}onGraphInitialized(t){let e=t.getValues().filter(t=>-1===t.from&&t.tensor).map(t=>t.tensor.dataId);this.initializers=new Set(e)}isInitializer(t){return!!this.initializers&&this.initializers.has(t)}addInitializer(t){this.initializers.add(t)}getTextureData(t,e){return e?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,e,r=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),r?this.packedTextureDataCache.set(t,e):this.unpackedTextureDataCache.set(t,e)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(t=>this.textureManager.releaseTexture(t,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(t=>this.textureManager.releaseTexture(t,!0)),this.unpackedTextureDataCache=new Map}resolve(t,e,r){let n=ks(t,e,ip);return{impl:n.opImpl,context:n.opInit?n.opInit(t,r):t}}}});function bg(t){let e=0;for(;e<t.length&&t[e]();++e);return e-1}var Mr,wp=O(()=>{"use strict";Yt(),Fr(),Fr(),pe(),Mr=class{constructor(t,e){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=t,this.version=e,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(t,e,r,n){let o=this.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);let a=n?r.encode(n,t*e):null;return o.texImage2D(o.TEXTURE_2D,0,r.internalFormat,t,e,0,r.format,r.textureType,a),this.checkError(),s}updateTexture(t,e,r,n,o){let s=this.gl;s.bindTexture(s.TEXTURE_2D,t);let a=n.encode(o,e*r);s.texSubImage2D(s.TEXTURE_2D,0,0,0,e,r,n.format,n.textureType,a),this.checkError()}attachFramebuffer(t,e,r){let n=this.gl;n.bindTexture(n.TEXTURE_2D,t),n.bindFramebuffer(n.FRAMEBUFFER,this.framebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.checkError(),n.viewport(0,0,e,r),n.scissor(0,0,e,r)}readTexture(t,e,r,n,o,s){let a=this.gl;s||(s=1),this.frameBufferBound||this.attachFramebuffer(t,e,r);let u=this.getEncoder(o,s),l=u.allocate(e*r);return a.bindTexture(a.TEXTURE_2D,t),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,t,0),a.readPixels(0,0,e,r,a.RGBA,u.textureType,l),this.checkError(),u.decode(l,n)}isFramebufferReady(){return!0}getActiveTexture(){let t=this.gl;return`TEXTURE${t.getParameter(this.gl.ACTIVE_TEXTURE)-t.TEXTURE0}`}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(t,e){let r=this.gl;r.vertexAttribPointer(t,3,r.FLOAT,!1,20,0),r.enableVertexAttribArray(t),-1!==e&&(r.vertexAttribPointer(e,2,r.FLOAT,!1,20,12),r.enableVertexAttribArray(e)),this.checkError()}createProgram(t,e){let r=this.gl,n=r.createProgram();return r.attachShader(n,t),r.attachShader(n,e),r.linkProgram(n),n}compileShader(t,e){let r=this.gl,n=r.createShader(e);if(!n)throw Error(`createShader() returned null with type ${e}`);if(r.shaderSource(n,t),r.compileShader(n),!1===r.getShaderParameter(n,r.COMPILE_STATUS))throw Error(`Failed to compile shader: ${r.getShaderInfoLog(n)}
1795Shader source:
1796${t}`);return n}deleteShader(t){this.gl.deleteShader(t)}bindTextureToUniform(t,e,r){let n=this.gl;n.activeTexture(n.TEXTURE0+e),this.checkError(),n.bindTexture(n.TEXTURE_2D,t),this.checkError(),n.uniform1i(r,e),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(z.debug){let t=this.gl,e=t.getError(),r="";switch(e){case t.NO_ERROR:return;case t.INVALID_ENUM:r="INVALID_ENUM";break;case t.INVALID_VALUE:r="INVALID_VALUE";break;case t.INVALID_OPERATION:r="INVALID_OPERATION";break;case t.INVALID_FRAMEBUFFER_OPERATION:r="INVALID_FRAMEBUFFER_OPERATION";break;case t.OUT_OF_MEMORY:r="OUT_OF_MEMORY";break;case t.CONTEXT_LOST_WEBGL:r="CONTEXT_LOST_WEBGL";break;default:r=`Unknown WebGL Error: ${e.toString(16)}`}throw Error(r)}}deleteTexture(t){this.gl.deleteTexture(t)}deleteProgram(t){this.gl.deleteProgram(t)}getEncoder(t,e,r=0){if(2===this.version)return new Pn(this.gl,e);switch(t){case"float":return 1===r||this.isRenderFloat32Supported?new Br(this.gl,e):new Br(this.gl,e,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw Error("not implemented");case"byte":return new En(this.gl,e);default:throw Error(`Invalid dataType: ${t}`)}}clearActiveTextures(){let t=this.gl;for(let e=0;e<this.maxTextureImageUnits;++e)t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,null)}dispose(){if(this.disposed)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteFramebuffer(this.framebuffer),t.bindBuffer(t.ARRAY_BUFFER,null),t.deleteBuffer(this.vertexbuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),t.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 t=this.gl,e=t.createBuffer();if(!e)throw Error("createBuffer() returned null");let r=this.createDefaultGeometry();return t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW),this.checkError(),e}createFramebuffer(){let t=this.gl.createFramebuffer();if(!t)throw Error("createFramebuffer returned null");return t}queryVitalParameters(){let t=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),1===this.version&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){2===this.version?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){let t=this.gl,e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);let r=2===this.version?t.RGBA32F:t.RGBA;t.texImage2D(t.TEXTURE_2D,0,r,1,1,0,t.RGBA,t.FLOAT,null);let n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0);let o=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(e),t.deleteFramebuffer(n),o}checkRenderFloat32(){if(2===this.version){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(2===this.version){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){let t=this.gl,e,r,n,o,s;try{e=t.createTexture(),r=t.createFramebuffer(),t.bindTexture(t.TEXTURE_2D,e);let a=2===this.version?t.RGBA32F:t.RGBA;return t.texImage2D(t.TEXTURE_2D,0,a,1,1,0,t.RGBA,t.FLOAT,null),t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),t.enable(t.BLEND),!!(n=t.createShader(t.VERTEX_SHADER))&&(t.shaderSource(n,"void main(){}"),t.compileShader(n),!!(o=t.createShader(t.FRAGMENT_SHADER)))&&
1796(t.shaderSource(o,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),t.compileShader(o),!!(s=t.createProgram()))&&(t.attachShader(s,n),t.attachShader(s,o),t.linkProgram(s),t.useProgram(s),t.drawArrays(t.POINTS,0,1),t.getError()===t.NO_ERROR)}finally{t.disable(t.BLEND),s&&t.deleteProgram(s),n&&t.deleteShader(n),o&&t.deleteShader(o),r&&(t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteFramebuffer(r)),e&&(t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(e))}}beginTimer(){if(2===this.version&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,e=this.disjointTimerQueryWebgl2Extension,r=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,r),r}throw Error("WebGL1 profiling currently not supported.")}endTimer(){if(2===this.version&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,e=this.disjointTimerQueryWebgl2Extension;t.endQuery(e.TIME_ELAPSED_EXT);return}throw Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(t){let e=!1,r=!1;if(2===this.version&&this.disjointTimerQueryWebgl2Extension){let n=this.gl,o=this.disjointTimerQueryWebgl2Extension;e=n.getQueryParameter(t,n.QUERY_RESULT_AVAILABLE),r=n.getParameter(o.GPU_DISJOINT_EXT)}else throw Error("WebGL1 profiling currently not supported");return e&&!r}getTimerResult(t){let e=0;if(2===this.version){let r=this.gl;e=r.getQueryParameter(t,r.QUERY_RESULT),r.deleteQuery(t)}else throw Error("WebGL1 profiling currently not supported");return e/1e6}async waitForQueryAndGetTime(t){return await li(()=>this.isTimerResultAvailable(t)),this.getTimerResult(t)}async createAndWaitForFence(){let t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let e,r=t,n=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);return t.flush(),e=null===n?()=>!0:()=>{let t=r.clientWaitSync(n,0,0);return t===r.ALREADY_SIGNALED||t===r.CONDITION_SATISFIED},{query:n,isFencePassed:e}}async pollFence(t){return new Promise(e=>{this.addItemToPoll(()=>t.isFencePassed(),()=>e())})}pollItems(){let t=bg(this.itemsToPoll.map(t=>t.isDoneFn));for(let e=0;e<=t;++e){let{resolveFn:t}=this.itemsToPoll[e];t()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}async addItemToPoll(t,e){this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1||await li(()=>(this.pollItems(),0===this.itemsToPoll.length))}}});function Gi(t){let e;if((!t||"webgl2"===t)&&"webgl2"in mr?e=mr.webgl2:(!t||"webgl"===t)&&"webgl"in mr&&(e=mr.webgl),!e)try{let r=yg();e=vp(r,t)}catch{e=vp(gg(),t)}t=t||1===e.version?"webgl":"webgl2";let r=e.gl;return mr[t]=e,r.isContextLost()?(delete mr[t],Gi(t)):(r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.disable(r.BLEND),r.disable(r.DITHER),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SAMPLE_COVERAGE),r.enable(r.SCISSOR_TEST),r.enable(r.CULL_FACE),r.cullFace(r.BACK),e)}function vp(t,e){let r,n={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!e||"webgl2"===e)&&(r=t.getContext("webgl2",n)))try{return new Mr(r,2)}catch(t){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${t}`)}if((!e||"webgl"===e)&&(r=t.getContext("webgl",n)||t.getContext("experimental-webgl",n)))try{return new Mr(r,1)}catch(t){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${t}`)}throw Error("WebGL is not supported")}function gg(){if(typeof document>"u")throw TypeError("failed to create canvas: document is not supported");let t=document.createElement("canvas");return t.width=1,t.height=1,t}function yg(){if(typeof OffscreenCanvas>"u")throw TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var mr,Yn,Ip=O(()=>{"use strict";Ut(),wp(),mr={}}),_p=O(()=>{"use strict";Yt(),Ut(),Tp(),Ip(),Yn=class{get contextId(){return z.webgl.contextId}set contextId(t){z.webgl.contextId=t}get matmulMaxBatchSize(){return z.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(t){z.webgl.matmulMaxBatchSize=t}get textureCacheMode(){return z.webgl.textureCacheMode}set textureCacheMode(t){z.webgl.textureCacheMode=t}get pack(){return z.webgl.pack}set pack(t){z.webgl.pack=t}get async(){return z.webgl.async}set async(t){z.webgl.async=t}initialize(){try{return this.glContext=Gi(this.contextId),"number"!=typeof this.matmulMaxBatchSize&&(this.matmulMaxBatchSize=16),"string"!=typeof this.textureCacheMode&&(this.textureCacheMode="full"),"boolean"!=typeof this.pack&&(this.pack=!1),"boolean"!=typeof this.async&&(this.async=!1),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(t){return tt.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${t}`),!1}}createSessionHandler(t){return new Jn(this,t)}dispose(){this.glContext.dispose()}}});async function Mi(t){if(!t)return Mi(["webgl"]);for(let e of"string"==typeof t?[t]:t){let t=Op.get(e);if(t)return t;let r=await Tg(e);if(r)return r}throw Error("no available backend to use")}async function Tg(t){let e=xg;if("u">typeof e[t]&&wg(e[t])){let r=e[t],n=r.initialize();
1796if("object"==typeof n&&"then"in n&&(n=await n),n)return Op.set(t,r),r}}function wg(t){let e=t;return"initialize"in e&&"function"==typeof e.initialize&&"createSessionHandler"in e&&"function"==typeof e.createSessionHandler&&"dispose"in e&&"function"==typeof e.dispose}var Op,xg,Ui,Zn,q,Xt,Ur,zi,Qn,Wi,me,to,Vi,Dp,vg,eo,ro,no,Sp=O(()=>{"use strict";_p(),Op=new Map,xg={webgl:new Yn}}),Ap=O(()=>{"use strict";Ut(),Ui=class{constructor(t,e){this.op=t,this.node=e}},Zn=class{constructor(t,e,r){this.graph=t,this.profiler=r,this.initialize(e)}initialize(t){this.profiler.event("session","ExecutionPlan.initialize",()=>{let e=this.graph.getNodes();if(e.length!==t.length)throw Error("The size of nodes and OPs do not match.");this._ops=t.map((t,r)=>new Ui(t,e[r])),this.reset(),this._starter=[],this._ops.forEach((t,e)=>{let r=!0;for(let e of t.node.inputs)if(!this._values[e]&&-1===this.graph.getInputIndices().indexOf(e)){r=!1;break}r&&this._starter.push(e)})})}reset(){this._values=this.graph.getValues().map(t=>t.tensor)}async execute(t,e){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();let r=t.createInferenceHandler(),n=this.graph.getInputIndices();if(e.length!==n.length)throw Error(`number of input tensors don't match the number of inputs to the model: actual: ${e.length} expected: ${n.length}`);e.forEach((t,e)=>{let r=n[e];this._values[r]=t});let o=this._starter.slice(0),s=this.graph.getValues(),a=this.graph.getNodes(),u=0;for(;u<o.length;){let t=o[u++],e=this._ops[t],n=e.node.inputs.map(t=>this._values[t]);if(-1!==n.indexOf(void 0))throw Error(`unresolved input detected: op: ${e.node}`);let l=n;tt.verbose("ExecPlan",`Running op:${e.node.name} (${l.map((t,r)=>`'${e.node.inputs[r]}': ${t.type}[${t.dims.join(",")}]`).join(", ")})`);let p=await this.profiler.event("node",e.node.name,async()=>e.op.impl(r,l,e.op.context));if(p.length!==e.node.outputs.length)throw Error("the size of output does not match model definition.");p.forEach((t,r)=>{let n=e.node.outputs[r];if(this._values[n])throw Error(`output [${n}] already has value: op:${e.node.name}`);this._values[n]=t});let c=new Set;p.forEach((t,r)=>{for(let t of s[e.node.outputs[r]].to){let e=a[t],r=!0;for(let t of e.inputs)if(!this._values[t]){r=!1;break}r&&c.add(t)}}),o.push(...c)}let l=[];for(let t=0;t<this.graph.getOutputIndices().length;t++){let e=this.graph.getOutputIndices()[t],r=this._values[e];if(void 0===r)throw Error(`required output [${e}] does not have value`);0===e?await r.getData():r.data,l.push(r)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),r.dispose(),l})}}}),Pp=O(()=>{"use strict";Pr(),q=rr(sr()),We(),Y(),Xt=F.experimental.fbs,Ur=class t{constructor(e){if(this._attributes=new Map,null!=e){for(let r of e)r instanceof q.onnx.AttributeProto?this._attributes.set(r.name,[t.getValue(r),t.getType(r)]):r instanceof Xt.Attribute&&this._attributes.set(r.name(),[t.getValue(r),t.getType(r)]);if(this._attributes.size<e.length)throw Error("duplicated attribute names")}}set(t,e,r){this._attributes.set(t,[r,e])}delete(t){this._attributes.delete(t)}getFloat(t,e){return this.get(t,"float",e)}getInt(t,e){return this.get(t,"int",e)}getString(t,e){return this.get(t,"string",e)}getTensor(t,e){return this.get(t,"tensor",e)}getFloats(t,e){return this.get(t,"floats",e)}getInts(t,e){return this.get(t,"ints",e)}getStrings(t,e){return this.get(t,"strings",e)}getTensors(t,e){return this.get(t,"tensors",e)}get(t,e,r){let n=this._attributes.get(t);if(void 0===n){if(void 0!==r)return r;throw Error(`required attribute not found: ${t}`)}if(n[1]!==e)throw Error(`type mismatch: expected ${e} but got ${n[1]}`);return n[0]}static getType(t){let e=t instanceof q.onnx.AttributeProto?t.type:t.type();switch(e){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 Error(`attribute type is not supported yet: ${q.onnx.AttributeProto.AttributeType[e]}`)}}static getValue(t){let e=t instanceof q.onnx.AttributeProto?t.type:t.type();if(e===q.onnx.AttributeProto.AttributeType.GRAPH||e===q.onnx.AttributeProto.AttributeType.GRAPHS)throw Error("graph attribute is not supported yet");let r=this.getValueNoCheck(t);if(e===q.onnx.AttributeProto.AttributeType.INT&&Rt.isLong(r))return Rt.longToNumber(r);
1796if(e===q.onnx.AttributeProto.AttributeType.INTS){let t=r,e=Array(t.length);for(let r=0;r<t.length;r++){let n=t[r];e[r]=Rt.longToNumber(n)}return e}if(e===q.onnx.AttributeProto.AttributeType.TENSOR)return t instanceof q.onnx.AttributeProto?bt.fromProto(r):bt.fromOrtTensor(r);if(e===q.onnx.AttributeProto.AttributeType.TENSORS){if(t instanceof q.onnx.AttributeProto)return r.map(t=>bt.fromProto(t));if(t instanceof Xt.Attribute)return r.map(t=>bt.fromOrtTensor(t))}return e===q.onnx.AttributeProto.AttributeType.STRING&&t instanceof q.onnx.AttributeProto?kr(r):e===q.onnx.AttributeProto.AttributeType.STRINGS&&t instanceof q.onnx.AttributeProto?r.map(kr):r}static getValueNoCheck(t){return t instanceof q.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(t):this.getValueNoCheckFromOrtFormat(t)}static getValueNoCheckFromOnnxFormat(t){switch(t.type){case q.onnx.AttributeProto.AttributeType.FLOAT:return t.f;case q.onnx.AttributeProto.AttributeType.INT:return t.i;case q.onnx.AttributeProto.AttributeType.STRING:return t.s;case q.onnx.AttributeProto.AttributeType.TENSOR:return t.t;case q.onnx.AttributeProto.AttributeType.GRAPH:return t.g;case q.onnx.AttributeProto.AttributeType.FLOATS:return t.floats;case q.onnx.AttributeProto.AttributeType.INTS:return t.ints;case q.onnx.AttributeProto.AttributeType.STRINGS:return t.strings;case q.onnx.AttributeProto.AttributeType.TENSORS:return t.tensors;case q.onnx.AttributeProto.AttributeType.GRAPHS:return t.graphs;default:throw Error(`unsupported attribute type: ${q.onnx.AttributeProto.AttributeType[t.type]}`)}}static getValueNoCheckFromOrtFormat(t){switch(t.type()){case Xt.AttributeType.FLOAT:return t.f();case Xt.AttributeType.INT:return t.i();case Xt.AttributeType.STRING:return t.s();case Xt.AttributeType.TENSOR:return t.t();case Xt.AttributeType.GRAPH:return t.g();case Xt.AttributeType.FLOATS:return t.floatsArray();case Xt.AttributeType.INTS:{let e=[];for(let r=0;r<t.intsLength();r++)e.push(t.ints(r));return e}case Xt.AttributeType.STRINGS:{let e=[];for(let r=0;r<t.stringsLength();r++)e.push(t.strings(r));return e}case Xt.AttributeType.TENSORS:{let e=[];for(let r=0;r<t.tensorsLength();r++)e.push(t.tensors(r));return e}default:throw Error(`unsupported attribute type: ${Xt.AttributeType[t.type()]}`)}}}}),Ep=O(()=>{"use strict";Pp(),Pr(),zi=rr(sr()),We(),Y(),Qn=F.experimental.fbs,Wi={from:(t,e)=>new Vi(t,e)},me=class{constructor(t){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,t&&(this.t
1796ype=At.tensorValueTypeFromProto(t.type.tensorType))}get from(){return this._from}get to(){return this._to}},to=class{constructor(t,e){t instanceof zi.onnx.NodeProto?(this.name=t.name,this.opType=t.opType,this.attributes=new Ur(t.attribute)):t instanceof Qn.Node&&(this.name=e??t.name(),this.opType=t.opType(),this.attributes=new Ur(At.tensorAttributesFromORTFormat(t))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Vi=class{constructor(t,e){if(!t)throw TypeError("graph is empty");this.buildGraph(t),this.transformGraph(e),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(t){if(t instanceof zi.onnx.GraphProto)this.buildGraphFromOnnxFormat(t);else if(t instanceof Qn.Graph)this.buildGraphFromOrtFormat(t);else throw TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(t){let e=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let r=new Map;if(!t.input)throw Error("missing information in graph: input");let n=[];for(let r of t.input){if(e.has(r.name))throw Error(`duplicated input name: ${r.name}`);let t=this._allData.push(new me(r))-1;e.set(r.name,t),n.push(r.name)}if(!t.initializer)throw Error("missing information in graph: initializer");for(let r of t.initializer){let t=e.get(r.name);if(void 0===t){let n=new me;n.type={shape:{dims:At.tensorDimsFromProto(r.dims)},tensorType:At.tensorDataTypeFromProto(r.dataType)},t=this._allData.push(n)-1,e.set(r.name,t)}this._allData[t]._from=-1,this._allData[t].tensor=bt.fromProto(r)}for(let t=0;t<this._allData.length;t++)this._allData[t].tensor||(this._allInputIndices.push(t),this._allInputNames.push(n[t]));if(!t.output)throw Error("missing information in graph: output");for(let r of t.output){if(e.has(r.name))throw Error(`duplicated output name: ${r.name}`);let t=this._allData.push(new me(r))-1;e.set(r.name,t),this._allOutputIndices.push(t),this._allOutputNames.push(r.name)}if(!t.node)throw Error("missing information in graph: node");for(let e of t.node){if(!e.name)for(let t=0;;t++){let n=`unnamed_${e.opType}_${t}`;if(!r.has(n)){e.name=n;break}}if(r.has(e.name))throw Error(`duplicated node name: ${e.name}`);let t=this._nodes.push(new to(e))-1;r.set(e.name,t)}for(let r=0;r<this._nodes.length;r++){let n=this._nodes[r],o=t.node[r];if(!o.output)throw Error(`missing output for node: ${o.name}`);for(let t of o.output){let s=e.get(t);if(typeof s>"u"&&(s=this._allData.push(new me)-1,e.set(t,s)),n.outputs.push(s),void 0!==this._allData[s]._from)throw Error(`multiple nodes output to one data value: ${s}`);if(this._allData[s]._from=r,"Constant"===o.opType){if(!o.attribute||1!==o.attribute.length||!o.attribute[0].t)throw Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!o.output||1!==o.output.length)throw Error("missing output or incorrect number of outputs for this Constant operator");n.outputs.pop(),n.executeNode=!1,this._allData[s]._from=-1,this._allData[s].tensor=bt.fromProto(o.attribute[0].t)}}}for(let r=0;r<this._nodes.length;r++){let n=this._nodes[r],o=t.node[r];if(!o.input)throw Error(`missing input for node: ${o.name}`);for(let t of o.input){let s=e.get(t);if(typeof s>"u"){if(""===t&&(3===o.input.length||4===o.input.length)&&"Resize"===o.opType)continue;throw Error(`unrecognized input '${t}' for node: ${o.name}`)}n.inputs.push(s),this._allData[s]._to.push(r)}}return!0}buildGraphFromOrtFormat(t){let e=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let r=new Map,n=[];for(let r=0;r<t.inputsLength();r++){let o=t.inputs(r);if(e.has(o))throw Error(`duplicated input name: ${o}`);for(let r=0;r<t.nodeArgsLength();r++)if(t.nodeArgs(r)?.name()===o){let s=new me;if(t.nodeArgs(r)?.type()?.valueType()!==Qn.TypeInfoValue.tensor_type)throw Error("Unexpected value type for the nodeArg.");let a=t.nodeArgs(r).type().value(new Qn.TensorTypeAndShape),u=At.tensorDataTypeFromProto(a.elemType()),l=a.shape(),p=[];for(let t=0;t<l.dimLength();t++)p.push(Rt.longToNumber(l.dim(t).value().dimValue()));s.type={shape:{dims:p},tensorType:u};let c=this._allData.push(s)-1;e.set(o,c),n.push(o)}}for(let r=0;
1796r<t.initializersLength();r++){let n=t.initializers(r),o=e.get(n.name());if(void 0===o){let t=new me,r=At.tensorDimsFromORTFormat(n),s=At.tensorDataTypeFromProto(n.dataType());t.type={shape:{dims:r},tensorType:s},o=this._allData.push(t)-1,e.set(n.name(),o)}this._allData[o]._from=-1,this._allData[o].tensor=bt.fromOrtTensor(n)}for(let t=0;t<this._allData.length;t++)this._allData[t].tensor||(this._allInputIndices.push(t),this._allInputNames.push(n[t]));for(let r=0;r<t.outputsLength();r++){let n=t.outputs(r);if(e.has(n))throw Error(`duplicated output name: ${n}`);let o=this._allData.push(new me)-1;e.set(n,o),this._allOutputIndices.push(o),this._allOutputNames.push(n)}if(!t.nodes)throw Error("missing information in graph: node");for(let e=0;e<t.nodesLength();e++){let n=t.nodes(e),o=n.name();if(!o)for(let t=0;o=`unnamed_${n.opType()}_${t}`,r.has(o);t++);if(r.has(o))throw Error(`duplicated node name: ${o}`);let s=this._nodes.push(new to(n,o))-1;r.set(o,s)}for(let r=0;r<this._nodes.length;r++){let n=this._nodes[r],o=t.nodes(r);if(null==o)throw Error(`No node exists at index ${r}`);if(o?.outputsLength()===0)throw Error(`missing output for node: ${o.name}`);for(let t=0;t<o?.outputsLength();t++){let s=o?.outputs(t),a=e.get(s);if(typeof a>"u"&&(a=this._allData.push(new me)-1,e.set(s,a)),n.outputs.push(a),void 0!==this._allData[a]._from)throw Error(`multiple nodes output to one data value: ${a}`);if(this._allData[a]._from=r,"Constant"===o.opType()){if(1!==o.attributesLength()||!o.attributes(0).t())throw Error("missing attributes or missing tensor value in attributes for this Constant operator");if(1!==o.outputsLength())throw Error("missing output or incorrect number of outputs for this Constant operator");n.outputs.pop(),n.executeNode=!1,this._allData[a]._from=-1,this._allData[a].tensor=bt.fromOrtTensor(o.attributes(0).t())}}}for(let r=0;r<this._nodes.length;r++){let n=this._nodes[r],o=t.nodes(r);if(0===o.inputsLength())throw Error(`missing input for node: ${o.name}`);for(let t=0;t<o.inputsLength();t++){let s=o.inputs(t),a=e.get(s);if(typeof a>"u")throw Error(`unrecognized input '${s}' for node: ${o.name()}`);n.inputs.push(a),this._allData[a]._to.push(r)}}}checkIsAcyclic(){let t=new Set;this._allInputIndices.forEach(e=>{this._allData[e]._to.forEach(e=>{t.add(e)})});let e=Array.from(t),r=Array(this._nodes.length).fill("white");for(;e.length>0;){let t=e.pop();"gray"===r[t]?r[t]="black":(e.push(t),r[t]="gray",this._nodes[t].outputs.forEach(n=>{let o=this._allData[n];if("u">typeof o.tensor)throw Error("node outputs should not be initialized");if(o._from!==t)throw Error("from property of the Value object doesn't match index of Node being processed");o._to.forEach(t=>{if("gray"===r[t])throw Error("model graph is cyclic");"white"===r[t]&&e.push(t)})}))}}transformGraph(t){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),t&&t.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let t=0,e=[this._nodes.length,0],r=0;for(let t=0;t<this._nodes.length;t++)e[t]=r,this._nodes[t].executeNode?(r!==t&&(this._nodes[r]=this._nodes[t]),r++):this._nodes[t].outputs.forEach(t=>{this._allData[t]._from=-2});this._nodes.splice(r,this._nodes.length-r);for(let t=0;t<this._allData.length;t++){let r=this._allData[t];void 0!==r._from&&-1!==r._from&&-2!==r._from&&(r._from=e[r._from]);for(let t=0;t<r._to.length;t++)if(r._to[t]>=0)r._to[t]=e[r._to[t]];else throw Error("Trying to update a removed node")}t=0;for(let e=0;e<this._allData.length;e++){if(-2===this._allData[e].from&&-1===this._allOutputIndices.indexOf(e+t)){t++,this._allData.splice(e,1),e--;continue}if(t>0){let r=-1;void 0!==this._allData[e].from&&-1!==this._allData[e].from?-1!==(r=this._nodes[this._allData[e].from].outputs.indexOf(e+t))&&(this._nodes[this._allData[e].from].outputs[r]=e):-1!==(r=this._allInputIndices.indexOf(e+t))&&(this._allInputIndices[r]=e),this._allData[e].to.forEach(n=>{-1!==(r=this._nodes[n].inputs.indexOf(e+t))&&(this._nodes[n].inputs[r]=e)}),0===this._allData[e].to.length&&-1!==(r=this._allOutputIndices.indexOf(e+t))&&(this._allOutputIndices[r]=e)}}}deleteNode(t){let e=this._nodes[t];
1796if(e.outputs.length>1){for(let t=1;t<e.outputs.length;t++)if(this._allData[e.outputs[t]].to.length>0)throw Error("Node deletion with more than one output connected to other nodes is not supported. ")}e.executeNode=!1;let r=e.inputs[0],n=e.outputs[0],o=this._allData[n].to;for(let r=0;r<e.inputs.length;r++){let n=this._allData[e.inputs[r]].to.indexOf(t);if(-1===n)throw Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[e.inputs[r]].to.splice(n,1)}this._allData[n]._to=[];let s=this._allOutputIndices.indexOf(n);if(-1!==s&&(this._allOutputIndices[s]=r),o&&o.length>0)for(let t of o){let e=this._nodes[t].inputs.indexOf(n);if(-1===e)throw Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[t].inputs[e]=r,this._allData[r].to.push(t)}}removeAllDropoutNodes(){let t=0;for(let e of this._nodes){if("Dropout"===e.opType){if(1!==e.inputs.length)throw Error("Dropout nodes should only contain one input. ");if(1!==e.outputs.length&&2!==e.outputs.length)throw Error("Dropout nodes should contain either 1 or 2 output(s)");if(2===e.outputs.length&&0!==this._allData[e.outputs[1]]._to.length)throw Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(t)}t++}}removeAllIdentityNodes(){let t=0;for(let e of this._nodes)"Identity"===e.opType&&this.deleteNode(t),t++}isActivation(t){switch(t.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(let t of this._nodes)if("Conv"===t.opType){let e=this._allData[t.outputs[0]]._to;if(1===e.length&&this.isActivation(this._nodes[e[0]])){let r=this._nodes[e[0]];if("Clip"===r.opType){if(1===r.inputs.length)try{t.attributes.set("activation_params","floats",[r.attributes.getFloat("min"),r.attributes.getFloat("max")])}catch{t.attributes.set("activation_params","floats",[Ve,ze])}else{if(!(r.inputs.length>=3)||void 0===this._allData[r.inputs[1]].tensor||void 0===this._allData[r.inputs[2]].tensor)continue;t.attributes.set("activation_params","floats",[this._allData[r.inputs[1]].tensor.floatData[0],this._allData[r.inputs[2]].tensor.floatData[0]])}}t.attributes.set("activation","string",r.opType),this.deleteNode(e[0])}}}}}),Lp=O(()=>{"use strict";wn(),Ep(),Pr(),Dp=rr(sr()),Y(),vg=F.experimental.fbs,eo=class{constructor(){}load(t,e,r){let n;if(!r)try{this.loadFromOnnxFormat(t,e);return}catch(t){if(void 0!==r)throw t;n=t}try{this.loadFromOrtFormat(t,e)}catch(t){throw void 0!==r?t:Error(`Failed to load model as ONNX format: ${n}
1797as ORT format: ${t}`)}}loadFromOnnxFormat(t,e){let r=Dp.onnx.ModelProto.decode(t);if(3>Rt.longToNumber(r.irVersion))throw Error("only support ONNX model with IR_VERSION>=3");this._opsets=r.opsetImport.map(t=>({domain:t.domain,version:Rt.longToNumber(t.version)})),this._graph=Wi.from(r.graph,e)}loadFromOrtFormat(t,e){let r=new w.ByteBuffer(t),n=vg.InferenceSession.getRootAsInferenceSession(r).model();if(3>Rt.longToNumber(n.irVersion()))throw Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let t=0;t<n.opsetImportLength();t++){let e=n.opsetImport(t);this._opsets.push({domain:e?.domain(),version:Rt.longToNumber(e.version())})}this._graph=Wi.from(n.graph(),e)}get graph(){return this._graph}get opsets(){return this._opsets}}}),$p=O(()=>{"use strict";Sp(),Ap(),Ut(),Lp(),ro=class{constructor(t={}){this._initialized=!1,this.backendHint=t.backendHint,this.profiler=xn.create(t.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(t,e,r){await this.profiler.event("session","Session.loadModel",async()=>{let n=await Mi(this.backendHint);if(this.sessionHandler=n.createSessionHandler(this.context),this._model=new eo,"string"==typeof t){let e=t.endsWith(".ort");{let r=await (await fetch(t)).arrayBuffer();this.initialize(new Uint8Array(r),e)}}else if(ArrayBuffer.isView(t))this.initialize(t);else{let n=new Uint8Array(t,e||0,r||t.byteLength);this.initialize(n)}})}initialize(t,e){if(this._initialized)throw Error("already initialized");
1797this.profiler.event("session","Session.initialize",()=>{let r=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(t,r,e),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(t){if(!this._initialized)throw Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{let e=this.normalizeAndValidateInputs(t),r=await this._executionPlan.execute(this.sessionHandler,e);return this.createOutput(r)})}normalizeAndValidateInputs(t){let e=this._model.graph.getInputNames();if(Array.isArray(t)){if(t.length!==e.length)throw Error(`incorrect input array length: expected ${e.length} but got ${t.length}`)}else{if(t.size!==e.length)throw Error(`incorrect input map size: expected ${e.length} but got ${t.size}`);let r=Array(t.size),n=0;for(let o=0;o<e.length;++o){let s=t.get(e[o]);if(!s)throw Error(`missing input tensor for: '${name}'`);r[n++]=s}t=r}if(this.context.graphInputTypes&&0!==this.context.graphInputTypes.length&&this.context.graphInputDims&&0!==this.context.graphInputDims.length)this.validateInputTensorDims(this.context.graphInputDims,t,!1);else{let e=this._model.graph.getInputIndices(),r=this._model.graph.getValues(),n=Array(e.length);for(let o=0;o<e.length;++o){let s=r[e[o]];n[o]=s.type.shape.dims,this.context.graphInputTypes.push(s.type.tensorType),this.context.graphInputDims.push(t[o].dims)}this.validateInputTensorDims(n,t,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,t),t}validateInputTensorTypes(t,e){for(let r=0;r<e.length;r++){let n=t[r],o=e[r].type;if(n!==o)throw Error(`input tensor[${r}] check failed: expected type '${n}' but got ${o}`)}}validateInputTensorDims(t,e,r){for(let n=0;n<e.length;n++){let o=t[n],s=e[n].dims;if(!this.compareTensorDims(o,s,r))throw Error(`input tensor[${n}] check failed: expected shape '[${o.join(",")}]' but got [${s.join(",")}]`)}}compareTensorDims(t,e,r){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(t[n]!==e[n]&&(!r||0!==t[n]))return!1;return!0}createOutput(t){let e=this._model.graph.getOutputNames();if(t.length!==e.length)throw Error("expected number of outputs do not match number of generated outputs");let r=new Map;for(let n=0;n<e.length;++n)r.set(e[n],t[n]);return r}initializeOps(t){let e=t.getNodes();this._ops=Array(e.length);for(let r=0;r<e.length;r++)this._ops[r]=this.sessionHandler.resolve(e[r],this._model.opsets,t)}}}),kp=O(()=>{"use strict";Yt(),We(),no=class{constructor(t){this.session=t,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(t,e,r){let n=new Map;for(let e in t)if(Object.hasOwnProperty.call(t,e)){let r=t[e];n.set(e,new bt(r.dims,r.type,void 0,void 0,r.data))}let o=await this.session.run(n),s={};return o.forEach((t,e)=>{s[e]=new yt(t.type,t.data,t.dims)}),s}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),Bp={};Or(Bp,{onnxjsBackend:()=>Ig});var Ig,Fp=O(()=>{"use strict";$p(),kp(),Ig=new class{async init(){}async createInferenceSessionHandler(t,e){let r=new ro(e);return await r.loadModel(t),new no(r)}}}),oo=O(()=>{}),Rp={};Or(Rp,{default:()=>_g});var Cp,Np,_g,Gp=O(()=>{"use strict";qi(),Ke(),Vr(),Cp="ort-wasm-proxy-worker",(Np=globalThis.self?.name===Cp)&&(self.onmessage=t=>{let{type:e,in:r}=t.data;try{switch(e){case"init-wasm":io(r.wasm).then(()=>{ao(r).then(()=>{postMessage({type:e})},t=>{postMessage({type:e,err:t})})},t=>{postMessage({type:e,err:t})});break;case"init-ep":{let{epName:t,env:n}=r;so(n,t).then(()=>{postMessage({type:e})},t=>{postMessage({type:e,err:t})});break}case"copy-from":{let{buffer:t}=r,n=zr(t);postMessage({type:e,out:n});break}case"create":{let{model:t,options:n}=r;uo(t,n).then(t=>{postMessage({type:e,out:t})},t=>{postMessage({type:e,err:t})});break}case"release":lo(r),postMessage({type:e});break;case"run":{let{sessionId:t,inputIndices:n,inputs:o,outputIndices:s,options:a}=r;fo(t,n,o,s,Array(s.length).fill(null),a).then(t=>{t.some(t=>"cpu"!==t[3])?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:t},po([...o,...t]))},t=>{postMessage({type:e,err:t})});break}case"end-profiling":co(r),postMessage({type:e})}}catch(t){postMessage({type:e,err:t})}}),_g=Np?null:t=>
1797new Worker(t??br,{type:"module",name:Cp})}),Up={};Or(Up,{default:()=>Og});var ji,Mp,Og,br,Sg,Ag,Pg,zp,Wp,Eg,Hp,Xi,Ki,ho,qp,Dg,Lg,io,xt,Tt,Wr,ht,jp,$g,kg,Bg,Fg,Kp,Hr,Yp,qr,Zp,Qp,bo,go,td,jr,Cg,ao,so,yr,Ng,zr,uo,lo,ed,fo,co,po,Je,Kt,Xr,xo,To,yo,Zi,Qi,xr,Tr,Gg,rd,nd,od,id,ad,sd,ud,ld,Mg,wo,Vp=O(()=>{"use strict";ji="file:///vercel/path0/node_modules/.pnpm/[email protected]/node_modules/onnxruntime-web/dist/ort.bundle.min.mjs",Og=Mp=async function(t={}){function e(){return P.buffer!=D.buffer&&j(),D}function r(){return P.buffer!=D.buffer&&j(),N}function n(){return P.buffer!=D.buffer&&j(),k}function o(){return P.buffer!=D.buffer&&j(),F}function s(){return P.buffer!=D.buffer&&j(),L}var a,u,l=Object.assign({},t),p=new Promise((t,e)=>{a=t,u=e}),c="object"==typeof window,d="function"==typeof importScripts,h=d&&"em-pthread"==self.name;l.mountExternalData=(t,e)=>{t.startsWith("./")&&(t=t.substring(2)),(l.Ua||(l.Ua=new Map)).set(t,e)},l.unmountExternalData=()=>{delete l.Ua};var f,g,m=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,b=Object.assign({},l),y="./this.program",x=(t,e)=>{throw e},v="";(c||d)&&(d?v=self.location.href:"u">typeof document&&document.currentScript&&(v=document.currentScript.src),ji&&(v=ji),v=v.startsWith("blob:")?"":v.substr(0,v.replace(/[?#].*/,"").lastIndexOf("/")+1),d&&(g=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),f=(t,e,r)=>{var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?e(n.response):r()},n.onerror=r,n.send(null)});var T,_=console.log.bind(console),w=console.error.bind(console),O=_,S=w;if(Object.assign(l,b),b=null,h){let t=function(e){try{var r=e.data,n=r.cmd;if("load"===n){let e=[];for(let n of(self.onmessage=t=>e.push(t),self.startWorker=()=>{for(let r of(postMessage({cmd:"loaded"}),e))t(r);self.onmessage=t},r.handlers))l[n]&&!l[n].proxy||(l[n]=(...t)=>{postMessage({Za:"callHandler",kb:n,args:t})},"print"==n&&(O=l[n]),"printErr"==n&&(S=l[n]));P=r.wasmMemory,j(),I(r.wasmModule)}else if("run"===n){eC(r.pthread_ptr,0,0,1,0,0),tX(r.pthread_ptr),tx(),tf(),E||=!0;try{tT(r.start_routine,r.arg)}catch(t){if("unwind"!=t)throw t}}else"cancel"===n?ek()&&eB(-1):"setimmediate"!==r.target&&("checkMailbox"===n?E&&tK():n&&(S(`worker: received unknown command ${n}`),S(r)))}catch(t){throw eL(),t}};var I,E=!1;S=function(...t){console.error(t=t.join(" "))},self.alert=function(...t){postMessage({Za:"alert",text:t.join(" "),nb:ek()})},l.instantiateWasm=(t,e)=>new Promise(t=>{I=r=>{e(r=new WebAssembly.Instance(r,Y())),t()}}),self.onunhandledrejection=t=>{throw t.reason||t},self.onmessage=t}l.wasmBinary&&(T=l.wasmBinary);var P,A,$,D,N,k,F,C,L,R=!1;function j(){var t=P.buffer;l.HEAP8=D=new Int8Array(t),l.HEAP16=new Int16Array(t),l.HEAPU8=N=new Uint8Array(t),l.HEAPU16=new Uint16Array(t),l.HEAP32=k=new Int32Array(t),l.HEAPU32=F=new Uint32Array(t),l.HEAPF32=new Float32Array(t),l.HEAPF64=L=new Float64Array(t),l.HEAP64=C=new BigInt64Array(t),l.HEAPU64=new BigUint64Array(t)}if(!h){if(!((P=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof m))throw S("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 
1797need to set a flag"),Error("bad memory");j()}var B=[],V=[],M=[],z=0,U=null,G=null;function H(){if(0==--z&&(null!==U&&(clearInterval(U),U=null),G)){var t=G;G=null,t()}}function q(t){throw S(t="Aborted("+t+")"),R=!0,$=1,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),u(t),t}var W,X=t=>t.startsWith("data:application/octet-stream;base64,"),K=t=>t.startsWith("file://");function Z(t){if(t==W&&T)return new Uint8Array(T);if(g)return g(t);throw"both async and sync fetching of the wasm failed"}function J(t,e,r){return(function(t){if(!T&&(c||d)){if("function"==typeof fetch&&!K(t))return fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw`failed to load wasm binary file at '${t}'`;return e.arrayBuffer()}).catch(()=>Z(t));if(f)return new Promise((e,r)=>{f(t,t=>e(new Uint8Array(t)),r)})}return Promise.resolve().then(()=>Z(t))})(t).then(t=>WebAssembly.instantiate(t,e)).then(r,t=>{S(`failed to asynchronously prepare wasm: ${t}`),q(t)})}function Y(){return{a:{j:tt,b:tw,E:tS,g:tA,V:t$,A:tF,C:tC,W:tL,T:tR,L:tj,S:tB,o:tV,B:tM,y:tz,U:tU,z:tG,_:tH,Z:tq,P:tW,w:tZ,F:tY,k:tQ,O:tX,Y:t0,I:t1,J:t6,K:t8,G:t5,H:t7,v:t9,q:ee,l:er,p:en,e:ei,X:es,x:ea,d:eo,f:eu,i:el,u:ep,t:ef,s:eg,Q:ex,R:ev,D:tu,h:eT,n:e_,M:ew,m:eS,a:P,r:ts,N:eA,c:e$}}}var Q={837620:(t,e,n,o,s)=>{if(void 0===l||!l.Ua)return 1;if((t=tP(t>>>0)).startsWith("./")&&(t=t.substring(2)),!(t=l.Ua.get(t)))return 2;if(o>>>=0,(e>>>=0)+(n>>>=0)>t.byteLength)return 3;try{let a=t.subarray(e,e+n);switch(s){case 0:r().set(a,o>>>0);break;case 1:l.mb(o,a);break;default:return 4}return 0}catch{return 4}},838303:()=>"u">typeof wasmOffsetConverter};function tt(){return"u">typeof wasmOffsetConverter}function te(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var tr=t=>{t.terminate(),t.onmessage=()=>{}},tn=t=>{0==tl.length&&(tm(),tg(tl[0]));var e=tl.pop();if(!e)return 6;tp.push(e),td[t.Ra]=e,e.Ra=t.Ra;var r={cmd:"run",start_routine:t.cb,arg:t.ab,pthread_ptr:t.Ra};return e.postMessage(r,t.ib),0},ti=0,to=(t,e,...r)=>{for(var n=2*r.length,o=eG(),a=eU(8*n),u=a>>>3,l=0;l<r.length;l++){var p=r[l];"bigint"==typeof p?(C[u+2*l]=1n,C[u+2*l+1]=p):(C[u+2*l]=0n,s()[u+2*l+1>>>0]=p)}return t=eR(t,0,n,a,e),ez(o),t};function ts(t){if(h)return to(0,1,t);if($=t,!(0<ti)){for(var e of tp)tr(e);for(e of tl)tr(e);tl=[],tp=[],td=[],R=!0}x(t,new te(t))}function ta(t){if(h)return to(1,0,t);tu(t)}var tu=t=>{if($=t,h)throw ta(t),"unwind";ts(t)},tl=[],tp=[],tc=[],td={},th=t=>{var e=t.Ra;delete td[e],tl.push(t),tp.splice(tp.indexOf(t),1),t.Ra=0,ej(e)};function tf(){tc.forEach(t=>t())}var tg=t=>new Promise(e=>{t.onmessage=r=>{var n=(r=r.data).cmd;if(r.targetThread&&r.targetThread!=ek()){var o=td[r.targetThread];o?o.postMessage(r,r.transferList):S(`Internal error! Worker sent a message "${n}" to target pthread ${r.targetThread}, but that thread no longer exists!`)}else"checkMailbox"===n?tK():"spawnThread"===n?tn(r):"cleanupThread"===n?th(td[r.thread]):"killThread"===n?(n=td[r=r.thread],delete td[r],tr(n),ej(r),tp.splice(tp.indexOf(n),1),n.Ra=0):"cancelThread"===n?td[r.thread].postMessage({cmd:"cancel"}):"loaded"===n?(t.loaded=!0,e(t)):"alert"===n?alert(`Thread ${r.threadId}: ${r.text}`):"setimmediate"===r.target?t.postMessage(r):"callHandler"===n?l[r.handler](...r.args):n&&S(`worker sent an unknown command ${n}`)},t.onerror=t=>{throw S(`worker sent an error! ${t.filename}:${t.lineno}: ${t.message}`),t};var r,n=[];for(r of[])l.hasOwnProperty(r)&&n.push(r);t.postMessage({cmd:"load",handlers:n,wasmMemory:P,wasmModule:A})});function tm(){var t=new Worker(new URL("file:///vercel/path0/node_modules/.pnpm/[email protected]/node_modules/onnxruntime-web/dist/ort.bundle.min.mjs"),{type:"module",workerData:"em-pthread",name:"em-pthread"});tl.push(t)}var tb,ty=t=>{for(;0<t.length;)t.shift()(l)},tx=()=>{var t=ek(),e=o()[t+52>>>2>>>0];t=o()[t+56>>>2>>>0],eM(e,e-t),ez(e)},tv=[],tT=(t,e)=>{ti=0;var r=tv[t];r||(t>=tv.length&&(tv.length=t+1),tv[t]=r=tb.get(t)),t=r(e),0<ti?$=t:eB(t)};class t_{constructor(t){this.Xa=t-24}}function tw(t,e,r){var n=new t_(t>>>=0);throw e>>>=0,r>>>=0,o()[n.Xa+16>>>2>>>0]=0,o()[n.Xa+4>>>2>>>0]=e,o()[n.Xa+8>>>2>>>0]=r,t}function tO(t,e,r,n){return h?to(2,1,t,e,r,n):tS(t,e,r,n)}function tS(t,e,r,n){if(t>>>=0,e>>>=0,r>>>=0,n>>>=0,void 0===m)return S("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var o=[];return h&&0===o.length?tO(t,e,r,n):(t={cb:r,Ra:t,ab:n,ib:o},h?(t.Za="spawnThread",postMessage(t,o),0):tn(t))}var tI="u">typeof TextDecoder?new TextDecoder("utf8"):void 0,tE=(t,e,r)=>{var n=(e>>>=0)+r;for(r=e;t[r]&&!(r>=n);)++r;if(16<r-e&&t.buffer&&tI)return tI.decode(t.buffer instanceof m?t.slice(e,r):t.subarray(e,r));for(n="";e<r;){var o=t[e++];if(128&o){var s=63&t[e++];if((224&o)==192)n+=String.fromCharCode((31&o)<<6|s);else{var a=63&t[e++];65536>(o=(240&o)==224?(15&o)<<12|s<<6|a:(7&o)<<18|s<<12|a<<6|63&t[e++])?n+=String.fromCharCode(o):(o-=65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else n+=String.fromCharCode(o)}return n},tP=(t,e)=>(t>>>=0)?tE(r(),t,e):"";function tA(t,e,r){return h?to(3,1,t,e,r):0}function t$(t,e){if(h)return to(4,1,t,e)}var tD=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);127>=n?e++:2047>=n?e+=2:55296<=n&&57343>=n?(e+=4,++r):e+=3}return e},tN=(t,e,r,n)=>{if(!(0<n))return 0;var o=r>>>=0;n=r+n-1;for(var s=0;s<t.length;++s){var a=t.charCodeAt(s);if(55296<=a&&57343>=a&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++s)),127>
1797=a){if(r>=n)break;e[r++>>>0]=a}else{if(2047>=a){if(r+1>=n)break;e[r++>>>0]=192|a>>6}else{if(65535>=a){if(r+2>=n)break;e[r++>>>0]=224|a>>12}else{if(r+3>=n)break;e[r++>>>0]=240|a>>18,e[r++>>>0]=128|a>>12&63}e[r++>>>0]=128|a>>6&63}e[r++>>>0]=128|63&a}}return e[r>>>0]=0,r-o},tk=(t,e,n)=>tN(t,r(),e,n);function tF(t,e){if(h)return to(5,1,t,e)}function tC(t,e,r){if(h)return to(6,1,t,e,r)}function tL(t,e,r){return h?to(7,1,t,e,r):0}function tR(t,e){if(h)return to(8,1,t,e)}function tj(t,e,r){if(h)return to(9,1,t,e,r)}function tB(t,e,r,n){if(h)return to(10,1,t,e,r,n)}function tV(t,e,r,n){if(h)return to(11,1,t,e,r,n)}function tM(t,e,r,n){if(h)return to(12,1,t,e,r,n)}function tz(t){if(h)return to(13,1,t)}function tU(t,e){if(h)return to(14,1,t,e)}function tG(t,e,r){if(h)return to(15,1,t,e,r)}var tH=()=>{q("")},tq=()=>1;function tW(t){eC(t>>>0,!d,1,!c,131072,!1),tf()}function tX(t){t>>>=0,"function"==typeof Atomics.jb&&(Atomics.jb(n(),t>>>2,t).value.then(tK),t+=128,Atomics.store(n(),t>>>2,1))}var tK=()=>{var t=ek();if(t&&(tX(t),t=eV,!R))try{if(t(),!(0<ti))try{h?eB($):tu($)}catch(t){t instanceof te||"unwind"==t||x(1,t)}}catch(t){t instanceof te||"unwind"==t||x(1,t)}};function tZ(t,e){(t>>>=0)==e>>>0?setTimeout(tK):h?postMessage({targetThread:t,cmd:"checkMailbox"}):(t=td[t])&&t.postMessage({cmd:"checkMailbox"})}var tJ=[];function tY(t,e,r,n,o){for(e>>>=0,n/=2,tJ.length=n,r=o>>>0>>>3,o=0;o<n;o++)tJ[o]=C[r+2*o]?C[r+2*o+1]:s()[r+2*o+1>>>0];return(e?Q[e]:eD[t])(...tJ)}function tQ(t){t>>>=0,h?postMessage({cmd:"cleanupThread",thread:t}):th(td[t])}function t0(t){}function t1(t,e){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t),e>>>=0,t=new Date(1e3*t),n()[e>>>2>>>0]=t.getUTCSeconds(),n()[e+4>>>2>>>0]=t.getUTCMinutes(),n()[e+8>>>2>>>0]=t.getUTCHours(),n()[e+12>>>2>>>0]=t.getUTCDate(),n()[e+16>>>2>>>0]=t.getUTCMonth(),n()[e+20>>>2>>>0]=t.getUTCFullYear()-1900,n()[e+24>>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,n()[e+28>>>2>>>0]=t}var t2=t=>t%4==0&&(t%100!=0||t%400==0),t3=[0,31,60,91,121,152,182,213,244,274,305,335],t4=[0,31,59,90,120,151,181,212,243,273,304,334];function t6(t,e){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t),e>>>=0,t=new Date(1e3*t),n()[e>>>2>>>0]=t.getSeconds(),n()[e+4>>>2>>>0]=t.getMinutes(),n()[e+8>>>2>>>0]=t.getHours(),n()[e+12>>>2>>>0]=t.getDate(),n()[e+16>>>2>>>0]=t.getMonth(),n()[e+20>>>2>>>0]=t.getFullYear()-1900,n()[e+24>>>2>>>0]=t.getDay();var r=(t2(t.getFullYear())?t3:t4)[t.getMonth()]+t.getDate()-1|0;n()[e+28>>>2>>>0]=r,n()[e+36>>>2>>>0]=-60*t.getTimezoneOffset(),r=new Date(t.getFullYear(),6,1).getTimezoneOffset();var o=new Date(t.getFullYear(),0,1).getTimezoneOffset();t=0|(r!=o&&t.getTimezoneOffset()==Math.min(o,r)),n()[e+32>>>2>>>0]=t}function t8(t){t>>>=0;var e=new Date(n()[t+20>>>2>>>0]+1900,n()[t+16>>>2>>>0],n()[t+12>>>2>>>0],n()[t+8>>>2>>>0],n()[t+4>>>2>>>0],n()[t>>>2>>>0],0),r=n()[t+32>>>2>>>0],o=e.getTimezoneOffset(),s=new Date(e.getFullYear(),6,1).getTimezoneOffset(),a=new Date(e.getFullYear(),0,1).getTimezoneOffset(),u=Math.min(a,s);return 0>r?n()[t+32>>>2>>>0]=+(s!=a&&u==o):0<r!=(u==o)&&(s=Math.max(a,s),e.setTime(e.getTime()+6e4*((0<r?u:s)-o))),n()[t+24>>>2>>>0]=e.getDay(),r=(t2(e.getFullYear())?t3:t4)[e.getMonth()]+e.getDate()-1|0,n()[t+28>>>2>>>0]=r,n()[t>>>2>>>0]=e.getSeconds(),n()[t+4>>>2>>>0]=e.getMinutes(),n()[t+8>>>2>>>0]=e.getHours(),n()[t+12>>>2>>>0]=e.getDate(),n()[t+16>>>2>>>0]=e.getMonth(),n()[t+20>>>2>>>0]=e.getYear(),BigInt(isNaN(t=e.getTime())?-1:t/1e3)}function t5(t,e,r,n,o,s,a){return h?to(16,1,t,e,r,n,o,s,a):-52}function t7(t,e,r,n,o,s){if(h)return to(17,1,t,e,r,n,o,s)}function t9(t,e,r,s){t>>>=0,e>>>=0,r>>>=0,s>>>=0;var a=new Date().getFullYear(),u=new Date(a,0,1),l=new Date(a,6,1);a=u.getTimezoneOffset();var p=l.getTimezoneOffset(),c=Math.max(a,p);o()[t>>>2>>>0]=60*c,n()[e>>>2>>>0]=+(a!=p),u=(t=t=>t.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(u),l=t(l),p<a?(tk(u,r,17),tk(l,s,17)):(tk(u,s,17),tk(l,r,17))}var et=[];function ee(t,e,a){t>>>=0,e>>>=0,a>>>=0,et.length=0;for(var u;u=r()[e++>>>0];){var l=105!=u;a+=(l&=112!=u)&&a%8?4:0,et.push(112==u?o()[a>>>2>>>0]:106==u?C[a>>>3]:105==u?n()[a>>>2>>>0]:s()[a>>>3>>>0]),a+=l?8:4}return Q[t](...et)}var er=()=>{},en=()=>Date.now();function ei(t,e){return S(tP(t>>>0,e>>>0))}var eo,es=()=>{throw ti+=1,"unwind"};function ea(){return 4294901760}eo=()=>performance.timeOrigin+performance.now();var eu=()=>navigator.hardwareConcurrency;function el(){return q("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function ep(t){t>>>=0;var e=r().length;if(t<=e||4294901760<t)return!1;for(var n=1;4>=n;n*=2){var o=e*(1+.2/n);o=Math.min(o,t+100663296);var s=Math;o=Math.max(t,o);t:{s=(s.min.call(s,4294901760,o+(65536-o%65536)%65536)-P.buffer.byteLength+65535)/65536;try{P.grow(s),j();var a=1;break t}catch{}a=void 0}if(a)return!0}return!1}var ec=()=>(q("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),ed={},eh=t=>{t.forEach(t=>{var e=ec();e&&(ed[e]=t)})};function ef(){var t=Error().stack.toString().split(`
1798`);return"Error"==t[0]&&t.shift(),eh(t),ed.$a=ec(),ed.bb=t,ed.$a}function eg(t,e,r){if(t>>>=0,e>>>=0,ed.$a==t)var o=ed.bb;else"Error"==(o=Error().stack.toString().split(`
1799`))[0]&&o.shift(),eh(o);for(var s=3;o[s]&&ec()!=t;)++s;for(t=0;t<r&&o[t+s];++t)n()[e+4*t>>>2>>>0]=ec();return t}var em,eb={},ey=()=>
1799{if(!em){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:y||"./this.program"};for(t in eb)void 0===eb[t]?delete e[t]:e[t]=eb[t];var r=[];for(t in e)r.push(`${t}=${e[t]}`);em=r}return em};function ex(t,r){if(h)return to(18,1,t,r);t>>>=0,r>>>=0;var n=0;return ey().forEach((s,a)=>{var u=r+n;for(a=o()[t+4*a>>>2>>>0]=u,u=0;u<s.length;++u)e()[a++>>>0]=s.charCodeAt(u);e()[a>>>0]=0,n+=s.length+1}),0}function ev(t,e){if(h)return to(19,1,t,e);t>>>=0,e>>>=0;var r=ey();o()[t>>>2>>>0]=r.length;var n=0;return r.forEach(t=>n+=t.length+1),o()[e>>>2>>>0]=n,0}function eT(t){return h?to(20,1,t):52}function e_(t,e,r,n){return h?to(21,1,t,e,r,n):52}function ew(t,e,r,n){return h?to(22,1,t,e,r,n):70}var eO=[null,[],[]];function eS(t,e,n,s){if(h)return to(23,1,t,e,n,s);e>>>=0,n>>>=0,s>>>=0;for(var a=0,u=0;u<n;u++){var l=o()[e>>>2>>>0],p=o()[e+4>>>2>>>0];e+=8;for(var c=0;c<p;c++){var d=r()[l+c>>>0],f=eO[t];0===d||10===d?((1===t?O:S)(tE(f,0)),f.length=0):f.push(d)}a+=p}return o()[s>>>2>>>0]=a,0}var eI=[31,29,31,30,31,30,31,31,30,31,30,31],eE=[31,28,31,30,31,30,31,31,30,31,30,31],eP=(t,r)=>{e().set(t,r>>>0)};function eA(t,e,r,s){function a(t,e,r){for(t="number"==typeof t?t.toString():t||"";t.length<e;)t=r[0]+t;return t}function u(t,e){return a(t,e,"0")}function l(t,e){var r;function n(t){return 0>t?-1:0<t?1:0}return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function p(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function c(t){var e=t.Sa;for(t=new Date(new Date(t.Ta+1900,0,1).getTime());0<e;){var r=t.getMonth(),n=(t2(t.getFullYear())?eI:eE)[r];if(!(e>n-t.getDate())){t.setDate(t.getDate()+e);break}e-=n-t.getDate()+1,t.setDate(1),11>r?t.setMonth(r+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return r=new Date(t.getFullYear()+1,0,4),e=p(new Date(t.getFullYear(),0,4)),r=p(r),0>=l(e,t)?0>=l(r,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}t>>>=0,e>>>=0,r>>>=0,s>>>=0;var d=o()[s+40>>>2>>>0];for(var h in s={gb:n()[s>>>2>>>0],fb:n()[s+4>>>2>>>0],Va:n()[s+8>>>2>>>0],Ya:n()[s+12>>>2>>>0],Wa:n()[s+16>>>2>>>0],Ta:n()[s+20>>>2>>>0],Qa:n()[s+24>>>2>>>0],Sa:n()[s+28>>>2>>>0],ob:n()[s+32>>>2>>>0],eb:n()[s+36>>>2>>>0],hb:d?tP(d):""},r=tP(r),d={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(RegExp(h,"g"),d[h]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),g="January February March April May June July August September October November December".split(" ");for(h in d={"%a":t=>f[t.Qa].substring(0,3),"%A":t=>f[t.Qa],"%b":t=>g[t.Wa].substring(0,3),"%B":t=>g[t.Wa],"%C":t=>u((t.Ta+1900)/100|0,2),"%d":t=>u(t.Ya,2),"%e":t=>a(t.Ya,2," "),"%g":t=>c(t).toString().substring(2),"%G":c,"%H":t=>u(t.Va,2),"%I":t=>(0==(t=t.Va)?t=12:12<t&&(t-=12),u(t,2)),"%j":t=>{for(var e=0,r=0;r<=t.Wa-1;e+=(t2(t.Ta+1900)?eI:eE)[r++]);return u(t.Ya+e,3)},"%m":t=>u(t.Wa+1,2),"%M":t=>u(t.fb,2),"%n":()=>`
1800`,"%p":t=>0<=t.Va&&12>t.Va?"AM":"PM","%S":t=>u(t.gb,2),"%t":()=>"	","%u":t=>t.Qa||7,"%U":t=>u(Math.floor((t.Sa+7-t.Qa)/7),2),"%V":t=>{var e=Math.floor((t.Sa+7-(t.Qa+6)%7)/7);if(2>=(t.Qa+371-t.Sa-2)%7&&e++,e)53==e&&(4==(r=(t.Qa+371-t.Sa)%7)||3==r&&t2(t.Ta)||(e=1));else{e=52;var r=(t.Qa+7-t.Sa-1)%7;(4==r||5==r&&t2(t.Ta%400-1))&&e++}return u(e,2)},"%w":t=>t.Qa,"%W":t=>u(Math.floor((t.Sa+7-(t.Qa+6)%7)/7),2),"%y":t=>(t.Ta+1900).toString().substring(2),"%Y":t=>t.Ta+1900,"%z":t=>{var e=0<=(t=t.eb);return(e?"+":"-")+("0000"+((t=Math.abs(t)/60)/60*100+t%60)).slice(-4)},"%Z":t=>t.hb,"%%":()=>"%"}
1800,r=r.replace(/%%/g,"\0\0"),d)r.includes(h)&&(r=r.replace(RegExp(h,"g"),d[h](s)));return(h=function(t){var e=Array(tD(t)+1);return tN(t,e,0,e.length),e}(r=r.replace(/\0\0/g,"%"))).length>e?0:(eP(h,t),h.length-1)}function e$(t,e,r,n){return eA(t>>>0,e>>>0,r>>>0,n>>>0)}h||function(){for(var t=l.numThreads-1;t--;)tm();B.unshift(()=>{z++,function(t){h?t():Promise.all(tl.map(tg)).then(t)}(()=>H())})}();var eD=[ts,ta,tO,tA,t$,tF,tC,tL,tR,tj,tB,tV,tM,tz,tU,tG,t5,t7,ex,ev,eT,e_,ew,eS],eN=function(){function t(t,e){return eN=t.exports,eN=function(){var t=eN,e=t=>()=>t()>>>0,r=t=>e=>t(e)>>>0;return(t=Object.assign({},t)).Ba=e(t.Ba),t.Ca=r(t.Ca),t.emscripten_main_runtime_thread_id=e(t.emscripten_main_runtime_thread_id),t.Oa=r(t.Oa),t.Pa=e(t.Pa),t}(),tc.push(eN.Ea),tb=eN.Fa,V.unshift(eN.$),A=e,H(),eN}var e=Y();if(z++,l.instantiateWasm)try{return l.instantiateWasm(e,t)}catch(t){S(`Module.instantiateWasm callback failed with error: ${t}`),u(t)}return W||=l.locateFile?X("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":l.locateFile?l.locateFile("ort-wasm-simd-threaded.wasm",v):v+"ort-wasm-simd-threaded.wasm":new __webpack_require__.U(__webpack_require__(28737)).href,(function(t,e){var r=W;return T||"function"!=typeof WebAssembly.instantiateStreaming||X(r)||K(r)||"function"!=typeof fetch?J(r,t,e):fetch(r,{credentials:"same-origin"}).then(n=>WebAssembly.instantiateStreaming(n,t).then(e,function(n){return S(`wasm streaming compile failed: ${n}`),S("falling back to ArrayBuffer instantiation"),J(r,t,e)}))})(e,function(e){t(e.instance,e.module)}).catch(u),{}}();l._OrtInit=(t,e)=>(l._OrtInit=eN.aa)(t,e),l._OrtGetLastError=(t,e)=>(l._OrtGetLastError=eN.ba)(t,e),l._OrtCreateSessionOptions=(t,e,r,n,o,s,a,u,p,c)=>(l._OrtCreateSessionOptions=eN.ca)(t,e,r,n,o,s,a,u,p,c),l._OrtAppendExecutionProvider=(t,e)=>(l._OrtAppendExecutionProvider=eN.da)(t,e),l._OrtAddFreeDimensionOverride=(t,e,r)=>(l._OrtAddFreeDimensionOverride=eN.ea)(t,e,r),l._OrtAddSessionConfigEntry=(t,e,r)=>(l._OrtAddSessionConfigEntry=eN.fa)(t,e,r),l._OrtReleaseSessionOptions=t=>(l._OrtReleaseSessionOptions=eN.ga)(t),l._OrtCreateSession=(t,e,r)=>(l._OrtCreateSession=eN.ha)(t,e,r),l._OrtReleaseSession=t=>(l._OrtReleaseSession=eN.ia)(t),l._OrtGetInputOutputCount=(t,e,r)=>(l._OrtGetInputOutputCount=eN.ja)(t,e,r),l._OrtGetInputName=(t,e)=>(l._OrtGetInputName=eN.ka)(t,e),l._OrtGetOutputName=(t,e)=>(l._OrtGetOutputName=eN.la)(t,e),l._OrtFree=t=>(l._OrtFree=eN.ma)(t),l._OrtCreateTensor=(t,e,r,n,o,s)=>(l._OrtCreateTensor=eN.na)(t,e,r,n,o,s),l._OrtGetTensorData=(t,e,r,n,o)=>(l._OrtGetTensorData=eN.oa)(t,e,r,n,o),l._OrtReleaseTensor=t=>(l._OrtReleaseTensor=eN.pa)(t),l._OrtCreateRunOptions=(t,e,r,n)=>(l._OrtCreateRunOptions=eN.qa)(t,e,r,n),l._OrtAddRunConfigEntry=(t,e,r)=>(l._OrtAddRunConfigEntry=eN.ra)(t,e,r),l._OrtReleaseRunOptions=t=>(l._OrtReleaseRunOptions=eN.sa)(t),l._OrtCreateBinding=t=>(l._OrtCreateBinding=eN.ta)(t),l._OrtBindInput=(t,e,r)=>(l._OrtBindInput=eN.ua)(t,e,r),l._OrtBindOutput=(t,e,r,n)=>(l._OrtBindOutput=eN.va)(t,e,r,n),l._OrtClearBoundOutputs=t=>(l._OrtClearBoundOutputs=eN.wa)(t),l._OrtReleaseBinding=t=>(l._OrtReleaseBinding=eN.xa)(t),l._OrtRunWithBinding=(t,e,r,n,o)=>(l._OrtRunWithBinding=eN.ya)(t,e,r,n,o),l._OrtRun=(t,e,r,n,o,s,a,u)=>(l._OrtRun=eN.za)(t,e,r,n,o,s,a,u),l._OrtEndProfiling=t=>(l._OrtEndProfiling=eN.Aa)(t);var ek=()=>(ek=eN.Ba)();l._malloc=t=>(l._malloc=eN.Ca)(t),l._free=t=>(l._free=eN.Da)(t);var eF,eC=(t,e,r,n,o,s)=>(eC=eN.Ga)(t,e,r,n,o,s),eL=()=>(eL=eN.Ha)(),eR=(t,e,r,n,o)=>(eR=eN.Ia)(t,e,r,n,o),ej=t=>(ej=eN.Ja)(t),eB=t=>(eB=eN.Ka)(t),eV=()=>(eV=eN.La)(),eM=(t,e)=>(eM=eN.Ma)(t,e),ez=t=>(ez=eN.Na)(t),eU=t=>(eU=eN.Oa)(t),eG=()=>(eG=eN.Pa)();function eH(){0<z||(h?(a(l),h||ty(V),startWorker(l)):(ty(B),0<z||eF||(eF=!0,l.calledRun=!0,R||(h||ty(V),a(l),h||ty(M)))))}return l.___start_em_js=838360,l.___stop_em_js=838421,l.stackSave=()=>eG(),l.stackRestore=t=>ez(t),l.stackAlloc=t=>eU(t),l.UTF8ToString=tP,l.stringToUTF8=tk,l.lengthBytesUTF8=tD,G=function t(){eF||eH(),eF||(G=t)},eH(),p},globalThis.self?.name==="em-pthread"&&Mp()}),Vr=O(()=>{"use strict";oo(),br="file:///vercel/path0/node_modules/.pnpm/[email protected]/node_modules/onnxruntime-web/dist/ort.bundle.min.mjs",Sg=typeof location>"u"?void 0:location.origin,Ag=(t,e)=>{try{let r=e??br;return(r?new URL(t,r):new URL(t)).origin===Sg}catch{return!1}},Pg=async t=>{let e=await (await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},zp=(Gp(),sn(Rp)).default,Wp=async()=>
1800{if(!br)throw Error("Failed to load proxy worker: cannot determine the script source URL.");if(Ag(br))return[void 0,zp()];let t=await Pg(br);return[t,zp(t)]},Eg=(Vp(),sn(Up)).default,Hp=async(t,e,r)=>[void 0,Eg]}),Ke=O(()=>{"use strict";Vr(),Ki=!1,ho=!1,qp=!1,Dg=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return"u">typeof MessageChannel&&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 t=>{if(Ki)return Promise.resolve();if(ho)throw Error("multiple calls to 'initializeWebAssembly()' detected.");if(qp)throw Error("previous call to 'initializeWebAssembly()' failed.");ho=!0;let e=t.initTimeout,r=t.numThreads;if(!Lg())throw Error("WebAssembly SIMD is not supported in the current environment.");let n=Dg();r>1&&!n&&("u">typeof self&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+r+", 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."),t.numThreads=r=1);let o=t.wasmPaths,s="string"==typeof o?o:void 0,a=o?.mjs,u=a?.href??a,l=o?.wasm,p=l?.href??l,c=t.wasmBinary,[d,h]=await Hp(u,s,r>1),f=!1,g=[];if(e>0&&g.push(new Promise(t=>{setTimeout(()=>{f=!0,t()},e)})),g.push(new Promise((t,e)=>{let n={numThreads:r};c?n.wasmBinary=c:(p||s)&&(n.locateFile=(t,e)=>p??(s??e)+t),h(n).then(e=>{ho=!1,Ki=!0,Xi=e,t(),d&&URL.revokeObjectURL(d)},t=>{ho=!1,qp=!0,e(t)})})),await Promise.race(g),f)throw Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},xt=()=>{if(Ki&&Xi)return Xi;throw Error("WebAssembly is not initialized yet.")}}),mo=O(()=>{"use strict";Ke(),Tt=(t,e)=>{let r=xt(),n=r.lengthBytesUTF8(t)+1,o=r._malloc(n);return r.stringToUTF8(t,o,n),e.push(o),o},Wr=(t,e,r,n)=>{if("object"==typeof t&&null!==t){if(r.has(t))throw Error("Circular reference in options");r.add(t)}Object.entries(t).forEach(([t,o])=>{let s=e?e+t:t;if("object"==typeof o)Wr(o,s+".",r,n);else if("string"==typeof o||"number"==typeof o)n(s,o.toString());else if("boolean"==typeof o)n(s,o?"1":"0");else throw Error(`Can't handle extra config type: ${typeof o}`)})},ht=t=>{let e=xt(),r=e.stackSave();try{let r=e.stackAlloc(8);e._OrtGetLastError(r,r+4);let n=e.HEAP32[r/4],o=e.HEAPU32[r/4+1],s=o?e.UTF8ToString(o):"";throw Error(`${t} ERROR_CODE: ${n}, ERROR_MESSAGE: ${s}`)}finally{e.stackRestore(r)}}}),Xp=O(()=>{"use strict";Ke(),mo(),jp=t=>{let e=xt(),r=0,n=[],o=t||{};try{if(t?.logSeverityLevel===void 0)o.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(t?.logVerbosityLevel===void 0)o.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);t?.terminate===void 0&&(o.terminate=!1);let s=0;return t?.tag!==void 0&&(s=Tt(t.tag,n)),r=e._OrtCreateRunOptions(o.logSeverityLevel,o.logVerbosityLevel,!!o.terminate,s),0===r&&ht("Can't create run options."),t?.extra!==void 0&&Wr(t.extra,"",new WeakSet,(t,o)=>{let s=Tt(t,n),a=Tt(o,n);0!==e._OrtAddRunConfigEntry(r,s,a)&&ht(`Can't set a run config entry: ${t} - ${o}.`)}),[r,n]}catch(t){throw 0!==r&&e._OrtReleaseRunOptions(r),n.forEach(t=>e._free(t)),t}}}),Jp=O(()=>{"use strict";Ke(),mo(),$g=t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw Error(`unsupported graph optimization level: ${t}`)}},kg=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw Error(`unsupported execution mode: ${t}`)}},Bg=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some(t=>("string"==typeof t?t:t.name)==="webgpu")&&(t.enableMemPattern=!1)},Fg=(t,e,r)=>{for(let n of e){let e="string"==typeof n?n:n.name;switch(e){case"webnn":if(e="WEBNN","string"!=typeof n){let e=n?.deviceType;if(e){let n=Tt("deviceType",r),o=Tt(e,r);0!==xt()._OrtAddSessionConfigEntry(t,n,o)&&ht(`Can't set a session config entry: 'deviceType' - ${e}.`)}}break;case"webgpu":if(e="JS","string"!=typeof n){let e=n;if(e?.preferredLayout){if("NCHW"!==e.preferredLayout&&"NHWC"!==e.preferredLayout)throw Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${e.preferredLayout}`);let n=Tt("preferredLayout",r),o=Tt(e.preferredLayout,r);0!==xt()._OrtAddSessionConfigEntry(t,n,o)&&ht(`Can't set a session config entry: 'preferredLayout' - ${e.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw Error(`not supported execution provider: ${e}`)}let o=Tt(e,r);0!==xt()._OrtAppendExecutionProvider(t,o)&&ht(`Can't append execution provider: ${e}.`)}},Kp=t=>{let e=xt(),r=0,n=[],o=t||{};Bg(o);try{let t=$g(o.graphOptimizationLevel??"all"),s=kg(o.executionMode??"sequential"),a="string"==typeof o.logId?Tt(o.logId,n):0,u=o.logSeverityLevel??2;if(!Number.isInteger(u)||u<0||u>
18004)throw Error(`log serverity level is not valid: ${u}`);let l=o.logVerbosityLevel??0;if(!Number.isInteger(l)||l<0||l>4)throw Error(`log verbosity level is not valid: ${l}`);let p="string"==typeof o.optimizedModelFilePath?Tt(o.optimizedModelFilePath,n):0;if(r=e._OrtCreateSessionOptions(t,!!o.enableCpuMemArena,!!o.enableMemPattern,s,!!o.enableProfiling,0,a,u,l,p),0===r&&ht("Can't create session options."),o.executionProviders&&Fg(r,o.executionProviders,n),void 0!==o.enableGraphCapture){if("boolean"!=typeof o.enableGraphCapture)throw Error(`enableGraphCapture must be a boolean value: ${o.enableGraphCapture}`);let t=Tt("enableGraphCapture",n),s=Tt(o.enableGraphCapture.toString(),n);0!==e._OrtAddSessionConfigEntry(r,t,s)&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${o.enableGraphCapture}.`)}if(o.freeDimensionOverrides)for(let[t,s]of Object.entries(o.freeDimensionOverrides)){if("string"!=typeof t)throw Error(`free dimension override name must be a string: ${t}`);if("number"!=typeof s||!Number.isInteger(s)||s<0)throw Error(`free dimension override value must be a non-negative integer: ${s}`);let o=Tt(t,n);0!==e._OrtAddFreeDimensionOverride(r,o,s)&&ht(`Can't set a free dimension override: ${t} - ${s}.`)}return void 0!==o.extra&&Wr(o.extra,"",new WeakSet,(t,o)=>{let s=Tt(t,n),a=Tt(o,n);0!==e._OrtAddSessionConfigEntry(r,s,a)&&ht(`Can't set a session config entry: ${t} - ${o}.`)}),[r,n]}catch(t){throw 0!==r&&e._OrtReleaseSessionOptions(r),n.forEach(t=>e._free(t)),t}}}),Ji=O(()=>{"use strict";Hr=t=>{switch(t){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 Error(`unsupported data type: ${t}`)}},Yp=t=>{switch(t){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 Error(`unsupported data type: ${t}`)}},qr=(t,e)=>{let r=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][t],n="number"==typeof e?e:e.reduce((t,e)=>t*e,1);return r>0?Math.ceil(n*r):void 0},Zp=t=>{switch(t){case"float16":return"u">typeof Float16Array&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw Error(`unsupported type: ${t}`)}},Qp=t=>{switch(t){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw Error(`unsupported logging level: ${t}`)}},bo=t=>"float32"===t||"float16"===t||"int32"===t||"int64"===t||"uint32"===t||"uint8"===t||"bool"===t||"uint4"===t||"int4"===t,go=t=>"float32"===t||"float16"===t||"int32"===t||"int64"===t||"uint32"===t||"uint64"===t||"int8"===t||"uint8"===t||"bool"===t,td=t=>{switch(t){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 Error(`unsupported data location: ${t}`)}}}),Yi=O(()=>{"use strict";oo(),jr=async t=>{if("string"!=typeof t)return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t);{let e=await fetch(t);if(!e.ok)throw Error(`failed to load external data file: ${t}`);let r=e.headers.get("Content-Length"),n=r?parseInt(r,10):0;if(n<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw Error(`failed to load external data file: ${t}, no response body.`);let r=e.body.getReader(),o;try{o=new ArrayBuffer(n)}catch(t){if(t instanceof RangeError){let t=Math.ceil(n/65536);o=new WebAssembly.Memory({initial:t,maximum:t}).buffer}else throw t}let s=0;for(;;){let{done:t,value:e}=await r.read();if(t)break;let n=e.byteLength;new Uint8Array(o,s,n).set(e),s+=n}return new Uint8Array(o,0,n)}}}}),qi=O(()=>{"use strict";Xp(),Jp(),Ji(),Ke(),mo(),Yi(),Cg=(t,e)=>{0!==xt()._OrtInit(t,e)&&ht("Can't initialize onnxruntime.")},ao=async t=>{Cg(t.wasm.numThreads,Qp(t.logLevel))},so=async(t,e)=>{},yr=new Map,Ng=t=>{let e=xt(),r=e.stackSave();try{let r=e.stackAlloc(8);return 0!==e._OrtGetInputOutputCount(t,r,r+4)&&ht("Can't get session input/output count."),[e.HEAP32[r/4],e.HEAP32[r/4+1]]}
1800finally{e.stackRestore(r)}},zr=t=>{let e=xt(),r=e._malloc(t.byteLength);if(0===r)throw Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,r),[r,t.byteLength]},uo=async(t,e)=>{let r,n,o=xt();Array.isArray(t)?[r,n]=t:t.buffer===o.HEAPU8.buffer?[r,n]=[t.byteOffset,t.byteLength]:[r,n]=zr(t);let s=0,a=0,u=0,l=[],p=[],c=[];try{if([a,l]=Kp(e),e?.externalData&&o.mountExternalData){let t=[];for(let r of e.externalData){let e="string"==typeof r?r:r.path;t.push(jr("string"==typeof r?r:r.data).then(t=>{o.mountExternalData(e,t)}))}await Promise.all(t)}for(let t of e?.executionProviders??[])if(("string"==typeof t?t:t.name)==="webnn"){if(o.shouldTransferToMLTensor=!1,o.currentContext)throw Error("WebNN execution provider is already set.");if("string"!=typeof t){let e=t,r=e?.context,n=e?.gpuDevice,s=e?.deviceType,a=e?.numThreads,u=e?.powerPreference;r?o.currentContext=r:n?o.currentContext=await navigator.ml.createContext(n):o.currentContext=await navigator.ml.createContext({deviceType:s,numThreads:a,powerPreference:u})}else o.currentContext=await navigator.ml.createContext();break}s=await o._OrtCreateSession(r,n,a),0===s&&ht("Can't create a session."),o.currentContext&&(o.jsepRegisterMLContext(s,o.currentContext),o.currentContext=void 0,o.shouldTransferToMLTensor=!0);let[t,u]=Ng(s),d=!!e?.enableGraphCapture,h=[],f=[];for(let e=0;e<t;e++){let t=o._OrtGetInputName(s,e);0===t&&ht("Can't get an input name."),p.push(t),h.push(o.UTF8ToString(t))}for(let t=0;t<u;t++){let e=o._OrtGetOutputName(s,t);0===e&&ht("Can't get an output name."),c.push(e);let r=o.UTF8ToString(e);f.push(r)}let g=null;return yr.set(s,[s,p,c,g,d,!1]),[s,h,f]}catch(t){throw p.forEach(t=>o._OrtFree(t)),c.forEach(t=>o._OrtFree(t)),0!==u&&o._OrtReleaseBinding(u),0!==s&&o._OrtReleaseSession(s),t}finally{o._free(r),0!==a&&o._OrtReleaseSessionOptions(a),l.forEach(t=>o._free(t)),o.unmountExternalData?.()}},lo=t=>{let e=xt(),r=yr.get(t);if(!r)throw Error(`cannot release session. invalid session id: ${t}`);let[n,o,s,a,u]=r;a&&(u&&e._OrtClearBoundOutputs(a.handle),e._OrtReleaseBinding(a.handle)),e.jsepOnReleaseSession?.(t),o.forEach(t=>e._OrtFree(t)),s.forEach(t=>e._OrtFree(t)),e._OrtReleaseSession(n),yr.delete(t)},ed=(t,e,r,n,o,s=!1)=>{if(!t){e.push(0);return}let a=xt(),u=t[0],l=t[1],p=t[3],c,d;if("string"===u&&("gpu-buffer"===p||"ml-tensor"===p))throw Error("String tensor is not supported on GPU.");if(s&&"gpu-buffer"!==p)throw Error(`External buffer must be provided for input/output index ${o} when enableGraphCapture is true.`);if("gpu-buffer"===p){let e=t[2].gpuBuffer;d=qr(Hr(u),l);let r=a.jsepRegisterBuffer;if(!r)throw Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');c=r(n,o,e,d)}else if("ml-tensor"===p){let e=t[2].mlTensor;d=qr(Hr(u),l);let r=a.jsepRegisterMLTensor;if(!r)throw Error('Tensor location "ml-tensor" is not supported without using WebNN.');c=r(e,Hr(u),l)}else{let e=t[2];if(Array.isArray(e)){d=4*e.length,c=a._malloc(d),r.push(c);let t=c/4;for(let n=0;n<e.length;n++){if("string"!=typeof e[n])throw TypeError(`tensor data at index ${n} is not a string`);a.HEAPU32[t++]=Tt(e[n],r)}}else d=e.byteLength,c=a._malloc(d),r.push(c),a.HEAPU8.set(new Uint8Array(e.buffer,e.byteOffset,d),c)}let h=a.stackSave(),f=a.stackAlloc(4*l.length);try{let t=f/4;l.forEach(e=>a.HEAP32[t++]=e);let r=a._OrtCreateTensor(Hr(u),c,d,f,l.length,td(p));0===r&&ht(`Can't create tensor for input/output. session=${n}, index=${o}.`),e.push(r)}finally{a.stackRestore(h)}},fo=async(t,e,r,n,o,s)=>{let a=xt(),u=yr.get(t);if(!u)throw Error(`cannot run inference. invalid session id: ${t}`);let l=u[0],p=u[1],c=u[2],d=u[3],h=u[4],f=(u[5],e.length),g=n.length,m=0,b=[],y=[],x=[],v=[],T=a.stackSave(),_=a.stackAlloc(4*f),w=a.stackAlloc(4*f),O=a.stackAlloc(4*g),S=a.stackAlloc(4*g);try{let u;a.jsepOnRunStart?.(l),[m,b]=jp(s);for(let n=0;n<f;n++)ed(r[n],y,v,t,e[n],h);for(let e=0;e<g;e++)ed(o[e],x,v,t,f+n[e],h);let T=_/4,I=w/4,E=O/4,P=S/4;for(let t=0;t<f;t++)a.HEAPU32[T++]=y[t],a.HEAPU32[I++]=p[e[t]];for(let t=0;t<g;t++)a.HEAPU32[E++]=x[t],a.HEAPU32[P++]=c[n[t]];u=await a._OrtRun(l,w,_,f,S,g,O,m),0!==u&&ht("failed to call OrtRun().");let A=[];for(let t=0;t<g;t++){let e=a.HEAPU32[O/4+t];if(e===x[t]){A.push(o[t]);continue}let r=a.stackSave(),s=a.stackAlloc(16),u=!1,l,p=0;try{0!==a._OrtGetTensorData(e,s,s+4,s+8,s+12)&&ht(`Can't access output tensor data on index ${t}.`);let r=s/4,o=a.HEAPU32[r++];p=a.HEAPU32[r++];let c=a.HEAPU32[r++],h=a.HEAPU32[r++],f=[];for(let t=0;t<h;t++)f.push(a.HEAPU32[c/4+t]);a._OrtFree(c);let g=f.reduce((t,e)=>t*e,1);l=Yp(o);let m=d?.outputPreferredLocations[n[t]];if("string"===l){if("gpu-buffer"===m||"ml-tensor"===m)throw Error("String tensor is not supported on GPU.");let t=[],e=p/4;for(let r=0;r<g;r++){let n=a.HEAPU32[e++],o=r===g-1?void 0:a.HEAPU32[e]-n;t.push(a.UTF8ToString(n,o))}A.push([l,f,t,"cpu"])}else if("gpu-buffer"===m&&g>0){let t=a.jsepGetBuffer;if(!t)throw Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let r=t(p),n=qr(o,g);if(void 0===n||!bo(l))throw Error(`Unsupported data type: ${l}`);u=!0,A.push([l,f,{gpuBuffer:r,download:a.jsepCreateDownloader(r,n,l),dispose:()=>{a._OrtReleaseTensor(e)}},"gpu-buffer"])}else if("ml-tensor"===m&&g>0){let t=a.jsepEnsureTensor;if(!t)throw Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(void 0===qr(o,g)||!go(l))throw Error(`Unsupported data type: ${l}`);let r=await t(p,o,f,!1);u=!0,A.push([l,f,{mlTensor:r,download:a.jsepCreateMLTensorDownloader(p,l),dispose:()=>{a.jsepReleaseTensorId(p),a._OrtReleaseTensor(e)}},"ml-tensor"])}else{let t=new(Zp(l))(g);new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(a.HEAPU8.subarray(p,p+t.byteLength)),A.push([l,f,t,"cpu"])}}finally{a.stackRestore(r),"string"===l&&p&&a._free(p),u||a._OrtReleaseTensor(e)}}return d&&!h&&(a._OrtClearBoundOutputs(d.handle),yr.set(t,[l,p,c,d,h,!1])),A}
1800finally{a.stackRestore(T),y.forEach(t=>a._OrtReleaseTensor(t)),x.forEach(t=>a._OrtReleaseTensor(t)),v.forEach(t=>a._free(t)),0!==m&&a._OrtReleaseRunOptions(m),b.forEach(t=>a._free(t))}},co=t=>{let e=xt(),r=yr.get(t);if(!r)throw Error("invalid session id");let n=r[0],o=e._OrtEndProfiling(n);0===o&&ht("Can't get an profile file name."),e._OrtFree(o)},po=t=>{let e=[];for(let r of t){let t=r[2];!Array.isArray(t)&&"buffer"in t&&e.push(t.buffer)}return e}}),ta=O(()=>{"use strict";Yt(),qi(),Ke(),Vr(),Je=()=>!!z.wasm.proxy&&"u">typeof document,Xr=!1,xo=!1,To=!1,Qi=new Map,xr=(t,e)=>{let r=Qi.get(t);r?r.push(e):Qi.set(t,[e])},Tr=()=>{if(Xr||!xo||To||!Kt)throw Error("worker not ready")},Gg=t=>{switch(t.data.type){case"init-wasm":Xr=!1,t.data.err?(To=!0,Zi[1](t.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 e=Qi.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out)}}},rd=async()=>{if(!xo){if(Xr)throw Error("multiple calls to 'initWasm()' detected.");if(To)throw Error("previous call to 'initWasm()' failed.");if(Xr=!0,Je())return new Promise((t,e)=>{Kt?.terminate(),Wp().then(([r,n])=>{try{(Kt=n).onerror=t=>e(t),Kt.onmessage=Gg,Zi=[t,e];let o={type:"init-wasm",in:z};Kt.postMessage(o),yo=r}catch(t){e(t)}},e)});try{await io(z.wasm),await ao(z),xo=!0}catch(t){throw To=!0,t}finally{Xr=!1}}},nd=async t=>{if(Je())return Tr(),new Promise((e,r)=>{xr("init-ep",[e,r]);let n={type:"init-ep",in:{epName:t,env:z}};Kt.postMessage(n)});await so(z,t)},od=async t=>Je()?(Tr(),new Promise((e,r)=>{xr("copy-from",[e,r]);let n={type:"copy-from",in:{buffer:t}};Kt.postMessage(n,[t.buffer])})):zr(t),id=async(t,e)=>{if(!Je())return uo(t,e);if(e?.preferredOutputLocation)throw Error('session option "preferredOutputLocation" is not supported for proxy.');return Tr(),new Promise((r,n)=>{xr("create",[r,n]);let o={type:"create",in:{model:t,options:{...e}}},s=[];t instanceof Uint8Array&&s.push(t.buffer),Kt.postMessage(o,s)})},ad=async t=>{if(Je())return Tr(),new Promise((e,r)=>{xr("release",[e,r]);let n={type:"release",in:t};Kt.postMessage(n)});lo(t)},sd=async(t,e,r,n,o,s)=>{if(!Je())return fo(t,e,r,n,o,s);if(r.some(t=>"cpu"!==t[3]))throw Error("input tensor on GPU is not supported for proxy.");if(o.some(t=>t))throw Error("pre-allocated output tensor is not supported for proxy.");return Tr(),new Promise((o,a)=>{xr("run",[o,a]);let u=r,l={type:"run",in:{sessionId:t,inputIndices:e,inputs:u,outputIndices:n,options:s}};Kt.postMessage(l,po(u))})},ud=async t=>{if(Je())return Tr(),new Promise((e,r)=>{xr("end-profiling",[e,r]);let n={type:"end-profiling",in:t};Kt.postMessage(n)});co(t)}}),fd=O(()=>{"use strict";Yt(),ta(),Ji(),oo(),Yi(),ld=(t,e)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[t.type,t.dims,{mlTensor:t.mlTensor},"ml-tensor"];default:throw Error(`invalid data location: ${t.location} for ${e()}`)}},Mg=t=>{switch(t[3]){case"cpu":return new yt(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!bo(e))throw Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:r,download:n,dispose:o}=t[2];return yt.fromGpuBuffer(r,{dataType:e,dims:t[1],download:n,dispose:o})}case"ml-tensor":{let e=t[0];if(!go(e))throw Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:r,download:n,dispose:o}=t[2];return yt.fromMLTensor(r,{dataType:e,dims:t[1],download:n,dispose:o})}default:throw Error(`invalid data location: ${t[3]}`)}},wo=class{async fetchModelAndCopyToWasmMemory(t){return od(await jr(t))}async loadModel(t,e){let r;Fe(),r="string"==typeof t?await this.fetchModelAndCopyToWasmMemory(t):t,[this.sessionId,this.inputNames,this.outputNames]=await id(r,e),Ce()}async dispose(){return ad(this.sessionId)}async run(t,e,r){Fe();let n=[],o=[];Object.entries(t).forEach(t=>{let e=t[0],r=t[1],s=this.inputNames.indexOf(e);if(-1===s)throw Error(`invalid input '${e}'`);n.push(r),o.push(s)});let s=[],a=[];Object.entries(e).forEach(t=>{let e=t[0],r=t[1],n=this.outputNames.indexOf(e);if(-1===n)throw Error(`invalid output '${e}'`);s.push(r),a.push(n)});let u=n.map((t,e)=>ld(t,()=>`input "${this.inputNames[o[e]]}"`)),l=s.map((t,e)=>t?ld(t,()=>`output "${this.outputNames[a[e]]}"`):null),p=await sd(this.sessionId,o,u,a,l,r),c={};for(let t=0;t<p.length;t++)c[this.outputNames[a[t]]]=s[t]??Mg(p[t]);return Ce(),c}startProfiling(){}endProfiling(){ud(this.sessionId)}}}),pd={};Or(pd,{OnnxruntimeWebAssemblyBackend:()=>vo,initializeFlags:()=>cd,wasmBackend:()=>Ug});var cd,vo,Ug,dd=O(()=>{"use strict";Yt(),ta(),fd(),Vr(),cd=()=>
1800{if(("number"!=typeof z.wasm.initTimeout||z.wasm.initTimeout<0)&&(z.wasm.initTimeout=0),!1===z.wasm.simd&&console.warn('Deprecated property "env.wasm.simd" is set to false. non-SIMD build is no longer provided, and this setting will be ignored.'),"boolean"!=typeof z.wasm.proxy&&(z.wasm.proxy=!1),"boolean"!=typeof z.wasm.trace&&(z.wasm.trace=!1),"number"!=typeof z.wasm.numThreads||!Number.isInteger(z.wasm.numThreads)||z.wasm.numThreads<=0){if("u">typeof self&&!self.crossOriginIsolated)z.wasm.numThreads=1;else{let t=typeof navigator>"u"?Co("node:os").cpus().length:navigator.hardwareConcurrency;z.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}}},Ug=new(vo=class{async init(t){cd(),await rd(),await nd(t)}async createInferenceSessionHandler(t,e){let r=new wo;return await r.loadModel(t,e),Promise.resolve(r)}})});Yt(),Yt(),Yt();var Ds="1.20.1",mO=Mo;{let i=(Fp(),sn(Bp)).onnxjsBackend;nr("webgl",i,-10)}{let i=(dd(),sn(pd)).wasmBackend;nr("cpu",i,10),nr("wasm",i,10)}Object.defineProperty(z.versions,"web",{value:Ds,enumerable:!0})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.