PageSourceSearch

https://manhastro.net/assets/ort.bundle.min-DIx0Zd_n.js

js manhastro.net collected 2026-10-09 23:19:41 UTC 460,449 bytes, 30 lines download raw bytes

1/*!
2 * ONNX Runtime Web v1.19.2
3 * Copyright (c) Microsoft Corporation. All rights reserved.
4 * Licensed under the MIT License.
5 */
6var zd=Object.create,nn=Object.defineProperty,Wd=Object.getOwnPropertyDescriptor,Hd=Object.getOwnPropertyNames,qd=Object.getPrototypeOf,jd=Object.prototype.hasOwnProperty,ko=(i=function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')},typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i),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 n in e)nn(t,n,{get:e[n],enumerable:!0})},Za=(t,e,n,r)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let i of Hd(e))!jd.call(t,i)&&i!==n&&nn(t,i,{get:()=>e[i],enumerable:!(r=Wd(e,i))||r.enumerable});return t},rr=(t,e,n)=>(n=null!=t?zd(qd(t)):{},Za(t&&t.__esModule?n:nn(n,"default",{value:t,enumerable:!0}),t)),on=t=>Za(nn({},"__esModule",{value:!0}),t),an,$e,nr,Xd,sn,un=O(()=>{an=new Map,$e=[],nr=(t,e,n)=>{if(e&&"function"==typeof e.init&&"function"==typeof e.createInferenceSessionHandler){let r=an.get(t);if(void 0===r)an.set(t,{backend:e,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){let e=$e.indexOf(t);-1!==e&&$e.splice(e,1);for(let r=0;r<$e.length;r++)if(an.get($e[r]).priority<=n)return void $e.splice(r,0,t);$e.push(t)}return}throw new TypeError("not a valid backend")},Xd=async t=>{let e=an.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(n){return r||(e.error=`${n}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},sn=async t=>{let e,n=t.executionProviders||[],r=n.map(t=>"string"==typeof t?t:t.name),i=0===r.length?$e:r,o=[],s=new Set;for(let u of i){let t=await Xd(u);"string"==typeof t?o.push({name:u,err:t}):(e||(e=t),e===t&&s.add(u))}if(!e)throw new Error(`no available backend found. ERR: ${o.map(t=>`[${t.name}] ${t.err}`).join(", ")}`);for(let{name:u,err:l}of o)r.includes(u);let a=n.filter(t=>s.has("string"==typeof t?t:t.name));return[e,new Proxy(t,{get:(t,e)=>"executionProviders"===e?a:Reflect.get(t,e)})]}}),Qa=O(()=>{un()}),ts,es=O(()=>{ts="1.19.2"}),rs,Rt,Bo=O(()=>{es(),rs="warning",Rt={wasm:{},webgl:{},webgpu:{},versions:{common:ts},set logLevel(t){if(void 0!==t){if("string"!=typeof t||-1===["verbose","info","warning","error","fatal"].indexOf(t))throw new Error(`Unsupported logging level: ${t}`);rs=t}},get logLevel(){return rs}},Object.defineProperty(Rt,"logLevel",{enumerable:!0})}),z,ns=O(()=>{Bo(),z=Rt}),os,is,as=O(()=>{os=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];let r=n.getContext("2d");if(null!=r){let i,o;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(i=t.dims[2],o=t.dims[3]):(i=t.dims[3],o=t.dims[2]);let s,a,u=void 0!==e?.format?e.format:"RGB",l=e?.norm;void 0===l||void 0===l.mean?s=[255,255,255,255]:"number"==typeof l.mean?s=[l.mean,l.mean,l.mean,l.mean]:(s=[l.mean[0],l.mean[1],l.mean[2],0],void 0!==l.mean[3]&&(s[3]=l.mean[3])),void 0===l||void 0===l.bias?a=[0,0,0,0]:"number"==typeof l.bias?a=[l.bias,l.bias,l.bias,l.bias]:(a=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(a[3]=l.bias[3]));let p=o*i,c=0,d=p,h=2*p,f=-1;"RGBA"===u?(c=0,d=p,h=2*p,f=3*p):"RGB"===u?(c=0,d=p,h=2*p):"RBG"===u&&(c=0,h=p,d=2*p);for(let e=0;e<o;e++)for(let n=0;n<i;n++){let i=(t.data[c++]-a[0])*s[0],o=(t.data[d++]-a[1])*s[1],u=(t.data[h++]-a[2])*s[2],l=-1===f?255:(t.data[f++]-a[3])*s[3];r.fillStyle="rgba("+i+","+o+","+u+","+l+")",r.fillRect(n,e,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},is=(t,e)=>{let n,r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");if(null==r)throw new Error("Can not access image data");{let i,o,s;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(i=t.dims[2],o=t.dims[1],s=t.dims[3]):(i=t.dims[3],o=t.dims[2],s=t.dims[1]);let a,u,l=void 0!==e&&void 0!==e.format?e.format:"RGB",p=e?.norm;void 0===p||void 0===p.mean?a=[255,255,255,255]:"number"==typeof p.mean?a=[p.mean,p.mean,p.mean,p.mean]:(a=[p.mean[0],p.mean[1],p.mean[2],255],void 0!==p.mean[3]&&(a[3]=p.mean[3])),void 0===p||void 0===p.bias?u=[0,0,0,0]:"number"==typeof p.bias?u=[p.bias,p.bias,p.bias,p.bias]:(u=[p.bias[0],p.bias[1],p.bias[2],0],void 0!==p.bias[3]&&(u[3]=p.bias[3]));let c=o*i;if(void 0!==e&&(void 0!==e.format&&4===s&&"RGBA"!==e.format||3===s&&"RGB"!==e.format&&"BGR"!==e.format))throw new Error("Tensor format doesn't match input tensor dims");let d=4,h=0,f=1,g=2,m=3,b=0,y=c,w=2*c,T=-1;"RGBA"===l?(b=0,y=c,w=2*c,T=3*c):"RGB"===l?(b=0,y=c,w=2*c):"RBG"===l&&(b=0,w=c,y=2*c),n=r.createImageData(i,o);for(let e=0;e<o*i;h+=d,f+=d,g+=d,m+=d,e++)n.data[h]=(t.data[b++]-u[0])*a[0],n.data[f]=(t.data[y++]-u[1])*a[1],n.data[g]=(t.data[w++]-u[2])*a[2],n.data[m]=-1===T?255:(t.data[T++]-u[3])*a[3]}return n}}),Fo,ss,us,ls,fs,cs=O(()=>{ln(),Fo=(t,e)=>{if(void 0===t)throw new Error("Image buffer must be defined");if(void 0===e.height||void 0===e.width)throw new Error("Image height and width must be defined");if("NHWC"===e.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");let n,r,{height:i,width:o}=e,s=e.norm??{mean:255,bias:0};n="number"==typeof s.mean?[s.mean,s.mean,s.mean,s.mean]:[s.mean[0],s.mean[1],s.mean[2],s.mean[3]??255],r="number"==typeof s.bias?[s.bias,s.bias,s.bias,s.bias]:[s.bias[0],s.bias[1],s.bias[2],s.bias[3]??0];let a=void 0!==e.format?e.format:"RGBA",u=void 0!==e.tensorFormat&&void 0!==e.tensorFormat?e.tensorFormat:"RGB",l=i*o,p="RGBA"===u?new Float32Array(4*l):new Float32Array(3*l),c=4,d=0,h=1,f=2,g=3,m=0,b=l,y=2*l,w=-1;"RGB"===a&&(c=3,d=0,h=1,f=2,g=-1),"RGBA"===u?w=3*l:"RBG"===u?(m=0,y=l,b=2*l):"BGR"===u&&(y=0,b=l,m=2*l);for(let T=0;T<l;T++,d+=c,f+=c,h+=c,g+=c)p[m++]=(t[d]+r[0])/n[0],p[b++]=(t[h]+r[1])/n[1],p[y++]=(t[f]+r[2])/n[2],-1!==w&&-1!==g&&(p[w++]=(t[g]+r[3])/n[3]);return new Lt("float32",p,"RGBA"===u?[1,4,i,o]:[1,3,i,o])},ss=async(t,e)=>{let n,r=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,i=typeof ImageData<"u"&&t instanceof ImageData,o=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,s="string"==typeof t,a=e??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=t=>t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas?t.getContext("2d"):null;if(r){let r=u();r.width=t.width,r.height=t.height;let i=l(r);if(null==i)throw new Error("Can not access image data");{let r=t.height,o=t.width;if(void 0!==e&&void 0!==e.resizedHeight&&void 0!==e.resizedWidth&&(r=e.resizedHeight,o=e.resizedWidth),void 0!==e){if(a=e,void 0!==e.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=r,a.width=o}else a.tensorFormat="RGBA",a.height=r,a.width=o;i.drawImage(t,0,0),n=i.getImageData(0,0,o,r).data}}else{if(!i){if(o){if(void 0===e)throw new Error("Please provide image config with format for Imagebitmap");let r=u();r.width=t.width,r.height=t.height;let i=l(r);if(null!=i){let e=t.height,r=t.width;return i.drawImage(t,0,0,r,e),n=i.getImageData(0,0,r,e).data,a.height=e,a.width=r,Fo(n,a)}throw new Error("Can not access image data")}
vendor: 8,316 bytes, line 6
6if(s)return new Promise((e,n)=>{let r=u(),i=l(r);if(!t||!i)return n();let o=new Image;o.crossOrigin="Anonymous",o.src=t,o.onload=()=>{r.width=o.width,r.height=o.height,i.drawImage(o,0,0,r.width,r.height);let t=i.getImageData(0,0,r.width,r.height);a.height=r.height,a.width=r.width,e(Fo(t.data,a))}});throw new Error("Input data provided is not supported - aborted tensor creation")}{let r,i;if(void 0!==e&&void 0!==e.resizedWidth&&void 0!==e.resizedHeight?(r=e.resizedHeight,i=e.resizedWidth):(r=t.height,i=t.width),void 0!==e&&(a=e),a.format="RGBA",a.height=r,a.width=i,void 0!==e){let e=u();e.width=i,e.height=r;let o=l(e);if(null==o)throw new Error("Can not access image data");o.putImageData(t,0,0),n=o.getImageData(0,0,i,r).data}else n=t.data}}if(void 0!==n)return Fo(n,a);throw new Error("Input data provided is not supported - aborted tensor creation")},us=(t,e)=>{let{width:n,height:r,download:i,dispose:o}=e;return new Lt({location:"texture",type:"float32",texture:t,dims:[1,r,n,4],download:i,dispose:o})},ls=(t,e)=>{let{dataType:n,dims:r,download:i,dispose:o}=e;return new Lt({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:r,download:i,dispose:o})},fs=(t,e,n)=>new Lt({location:"cpu-pinned",type:t,data:e,dims:n??[e.length]})}),ke,Sr,ps,ds,hs=O(()=>{ke=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),Sr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ps=!1,ds=()=>{if(!ps){ps=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;t&&(ke.set("int64",BigInt64Array),Sr.set(BigInt64Array,"int64")),e&&(ke.set("uint64",BigUint64Array),Sr.set(BigUint64Array,"uint64")),n?(ke.set("float16",Float16Array),Sr.set(Float16Array,"float16")):ke.set("float16",Uint16Array)}}}),ms,bs,gs=O(()=>{ln(),ms=t=>{let e=1;for(let n=0;n<t.length;n++){let r=t[n];if("number"!=typeof r||!Number.isSafeInteger(r))throw new TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);e*=r}return e},bs=(t,e)=>{switch(t.location){case"cpu":return new Lt(t.type,t.data,e);case"cpu-pinned":return new Lt({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new Lt({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new Lt({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),Lt,ln=O(()=>{as(),cs(),hs(),gs(),Lt=class{constructor(t,e,n){let r,i;if(ds(),"object"==typeof t&&"location"in t)switch(this.dataLocation=t.location,r=t.type,i=t.dims,t.location){case"cpu-pinned":{let e=ke.get(r);if(!e)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(t.data instanceof e))throw new TypeError(`buffer should be of type ${e.name}`);this.cpuData=t.data;break}case"texture":if("float32"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break;case"gpu-buffer":if("float32"!==r&&"float16"!==r&&"int32"!==r&&"int64"!==r&&"uint32"!==r&&"uint8"!==r&&"bool"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break;default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let o,s;if("string"==typeof t)if(r=t,s=n,"string"===t){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");o=e}else{let n=ke.get(t);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if("float16"===t&&n===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");o="uint64"===t||"int64"===t?n.from(e,BigInt):n.from(e)}else{if(!(e instanceof n))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);o=e}}else if(s=e,Array.isArray(t)){if(0===t.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");let e=typeof t[0];if("string"===e)r="string",o=t;else{if("boolean"!==e)throw new TypeError(`Invalid element type of data array: ${e}.`);r="bool",o=Uint8Array.from(t)}}else{let e=Sr.get(t.constructor);if(void 0===e)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);r=e,o=t}if(void 0===s)s=[o.length];else if(!Array.isArray(s))throw new TypeError("A tensor's dims must be a number array");i=s,this.cpuData=o,this.dataLocation="cpu"}let o=ms(i);if(this.cpuData&&o!==this.cpuData.length)throw new Error(`Tensor's size(${o}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=o}static async fromImage(t,e){return ss(t,e)}static fromTexture(t,e){return us(t,e)}static fromGpuBuffer(t,e){return ls(t,e)}static fromPinnedBuffer(t,e,n){return fs(t,e,n)}toDataURL(t){return os(this,t)}toImageData(t){return is(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}finally{this.isDownloading=!1}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if("none"===this.dataLocation)throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return bs(this,t)}}}),Tt,fn=O(()=>{ln(),Tt=Lt}),ys,xs,Be,Fe,Co=O(()=>{Bo(),ys=(t,e)=>{typeof Rt.trace>"u"?Rt.wasm.trace:Rt.trace},xs=(t,e)=>{let n=(new Error).stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes("TRACE_FUNC")){let r=`FUNC_${t}::${n[i].trim().split(" ")[1]}`;return e&&(r+=`::${e}`),void ys("CPU",r)}n[i].includes("TRACE_FUNC")&&(r=!0)}},Be=t=>{(typeof Rt.trace>"u"?!Rt.wasm.trace:!Rt.trace)||xs("BEGIN",t)},Fe=t=>{(typeof Rt.trace>"u"?!Rt.wasm.trace:!Rt.trace)||xs("END",t)}}),cn,Ts=O(()=>{un(),fn(),Co(),cn=class t{constructor(t){this.handler=t}async run(t,e,n){Be();let r={},i={};if("object"!=typeof t||null===t||t instanceof Tt||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let o=!0;if("object"==typeof e){if(null===e)throw new TypeError("Unexpected argument[1]: cannot be null.");if(e instanceof Tt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(e)){if(0===e.length)throw new TypeError("'fetches' cannot be an empty array.");o=!1;for(let t of e){if("string"!=typeof t)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(t))throw new RangeError(`'fetches' contains invali
6d output name: ${t}.`);r[t]=null}if("object"==typeof n&&null!==n)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,s=Object.getOwnPropertyNames(e);for(let n of this.outputNames)if(-1!==s.indexOf(n)){let i=e[n];(null===i||i instanceof Tt)&&(t=!0,o=!1,r[n]=i)}if(t){if("object"==typeof n&&null!==n)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else i=e}}else if(typeof e<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let u of this.inputNames)if(typeof t[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(o)for(let u of this.outputNames)r[u]=null;let s=await this.handler.run(t,r,i),a={};for(let u in s)if(Object.hasOwnProperty.call(s,u)){let t=s[u];a[u]=t instanceof Tt?t:new Tt(t.type,t.data,t.dims)}return Fe(),a}async release(){return this.handler.dispose()}static async create(e,n,r,i){Be();let o,s={};if("string"==typeof e){if(o=e,"object"==typeof n&&null!==n)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(o=e,"object"==typeof n&&null!==n)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{if(!(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{let t=e,a=0,u=e.byteLength;if("object"==typeof n&&null!==n)s=n;else if("number"==typeof n){if(a=n,!Number.isSafeInteger(a))throw new RangeError("'byteOffset' must be an integer.");if(a<0||a>=t.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(u=e.byteLength-a,"number"==typeof r){if(u=r,!Number.isSafeInteger(u))throw new RangeError("'byteLength' must be an integer.");if(u<=0||a+u>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-a}].`);if("object"==typeof i&&null!==i)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof r<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");o=new Uint8Array(t,a,u)}}let[a,u]=await sn(s),l=await a.createInferenceSessionHandler(o,u);return Fe(),new t(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}}),Kd,ws=O(()=>{Ts(),Kd=cn}),vs=O(()=>{}),Is=O(()=>{}),_s=O(()=>{}),Os=O(()=>{}),Jd,pn,Ss=O(()=>{un(),fn(),Jd="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",pn=class t{constructor(t,e,n){this.handler=t,this.hasOptimizerModel=e,this.hasEvalModel=n}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(e,n){let r=e.evalModel||"",i=e.optimizerModel||"",o=n||{},[s,a]=await sn(o);if(s.createTrainingSessionHandler){let n=await s.createTrainingSessionHandler(e.checkpointState,e.trainModel,r,i,a);return new t(n,!!e.optimizerModel,!!e.evalModel)}throw new Error(Jd)}typeNarrowingForRunStep(t,e,n,r,i){let o={},s={};if("object"!=typeof n||null===n||n instanceof Tt||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if("object"==typeof r){if(null===r)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Tt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(0===r.length)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let t of r){if("string"!=typeof t)throw new TypeError("'fetches' must be a string array or an object.");if(-1===e.indexOf(t))throw new RangeError(`'fetches' contains invali
6d output name: ${t}.`);o[t]=null}if("object"==typeof i&&null!==i)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let t=!1,n=Object.getOwnPropertyNames(r);for(let i of e)if(-1!==n.indexOf(i)){let e=r[i];(null===e||e instanceof Tt)&&(t=!0,a=!1,o[i]=e)}if(t){if("object"==typeof i&&null!==i)s=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else s=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let u of t)if(typeof n[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(a)for(let u of e)o[u]=null;return[o,s]}convertHandlerReturnTypeToMapOfTensors(t){let e={};for(let n in t)if(Object.hasOwnProperty.call(t,n)){let r=t[n];e[n]=r instanceof Tt?r:new Tt(r.type,r.data,r.dims)}return e}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,e,n){let[r,i]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,e,n),o=await this.handler.runTrainStep(t,r,i);return this.convertHandlerReturnTypeToMapOfTensors(o)}async runOptimizerStep(t){if(!this.hasOptimizerModel)throw new Error("This TrainingSession has no OptimizerModel loaded.");await this.handler.runOptimizerStep(t||{})}async runEvalStep(t,e,n){if(this.hasEvalModel){let[r,i]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,e,n),o=await this.handler.runEvalStep(t,r,i);return this.convertHandlerReturnTypeToMapOfTensors(o)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,e=!0){let n=await this.getParametersSize(e);if(t.length!==4*n)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(t,e)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}}),Yd,As=O(()=>{Ss(),Yd=pn}),No={};Or(No,{InferenceSession:()=>Kd,TRACE:()=>ys,TRACE_FUNC_BEGIN:()=>Be,TRACE_FUNC_END:()=>Fe,Tensor:()=>Tt,TrainingSession:()=>Yd,env:()=>z,registerBackend:()=>nr});var Kt=O(()=>{Qa(),ns(),ws(),fn(),vs(),Is(),Co(),_s(),Os(),As()});function Ie(t,e,n,r){if(void 0===e)return Qd(t);if(void 0===n)dn(t,e);else if("number"==typeof n&&void 0===r)dn(t,e);else if("string"==typeof n&&void 0===r)dn(t,n,1,e);else{if("string"!=typeof n||"number"!=typeof r)throw new TypeError("input is valid");dn(t,n,r,e)}}function Qd(t){return{verbose:Ie.verbose.bind(null,t),info:Ie.info.bind(null,t),warning:Ie.warning.bind(null,t),error:Ie.error.bind(null,t),fatal:Ie.fatal.bind(null,t)}}function dn(t,e,n,r){let i=Ar[r||""]||Ar[""];Es[t]<Es[i.minimalSeverity]||(i.logDateTime&&(e=`${(new Date).toISOString()}|${e}`),i.logSourceLocation,Zd[i.provider].log(t,e,r))}var Ro,Go,Es,Zd,Ds,Ar,tt,mn,bn,gn,hn,Mt=O(()=>{Ro=class{log(t,e,n){}},Go=class{log(t,e,n){}color(t){switch(t){case"verbose":return"�[34;40mv�[0m";case"info":return"�[32mi�[0m";case"warning":return"�[30;43mw�[0m";case"error":return"�[31;40me�[0m";case"fatal":return"�[101mf�[0m";default:throw new Error(`unsupported severity: ${t}`)}}},Es={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Zd={none:new Ro,console:new Go},Ar={"":Ds={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(t=>{function e(t){Ar={},n("",t||{})}function n(t,n){if("*"===t)e(n);else{let e=Ar[t]||Ds;Ar[t]={provider:n.provider||e.provider,minimalSeverity:n.minimalSeverity||e.minimalSeverity,logDateTime:void 0===n.logDateTime?e.logDateTime:n.logDateTime,logSourceLocation:void 0===n.logSourceLocation?e.logSourceLocation:n.logSourceLocation}}}t.verbose=function(e,n){t("verbose",e,n)},t.info=function(e,n){t("info",e,n)},t.warning=function(e,n){t("warning",e,n)},t.error=function(e,n){t("error",e,n)},t.fatal=function(e,n){t("fatal",e,n)},t.reset=e,t.set=n,t.setWithEnv=function(t){let e={};t.logLevel&&(e.minimalSeverity=t.logLevel),n("",e)}})(Ie||(Ie={})),tt=Ie,mn=class{constructor(t,e,n,r,i,o){this.category=t,this.name=e,this.startTime=n,this.endCallback=r,this.timer=i,this.ctx=o}async end(){return this.endCallback(this)}async checkTimer(){if(void 0===this.ctx||void 0===this.timer)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},bn=class{constructor(t,e,n,r){this.category=t,this.name=e,this.startTime=n,this.endTime=r}},gn=class{constructor(t,e,n){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=void 0===t?1e4:t,this._flushBatchSize=void 0===e?10:e,this._flushIntervalInMilliseconds=void 0===n?5e3:n}static create(t){return void 0===t?new this:new this(t.maxNumberEvents,t.flushBatchSize,t.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=hn(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(t,e,n,r){let i=this._started?this.begin(t,e,r):void 0,o=!1,s=n();if(s&&"function"==typeof s.then)return o=!0,new Promise((t,e)=>{s.then(async e=>{i&&await i.end(),t(e)},async t=>{i&&await i.end(),e(t)})});if(!o&&i){let t=i.end();
6if(t&&"function"==typeof t.then)return new Promise((e,n)=>{t.then(()=>{e(s)},t=>{n(t)})})}return s}begin(t,e,n){if(!this._started)throw new Error("profiler is not started yet");if(void 0===n){let n=hn();return this.flush(n),new mn(t,e,n,t=>this.endSync(t))}{let r=n.beginTimer();return new mn(t,e,0,async t=>this.end(t),r,n)}}async end(t){let e=await t.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new bn(t.category,t.name,t.startTime,e)),this.flush(e))}endSync(t){let e=hn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new bn(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=hn()}}get started(){return this._started}},hn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Ls(t,e,n){for(let r of n){let n=r[0],i=r[1],o=r[2],s=r[3],a=r[4];if(t.opType===n)for(let t of e)if((t.domain===i||"ai.onnx"===t.domain&&""===i)&&th(t.version,o))return{opImpl:s,opInit:a}}throw new TypeError(`cannot resolve operator '${t.opType}' with opsets: ${e.map(t=>`${t.domain||"ai.onnx"} v${t.version}`).join(", ")}`)}function th(t,e){if(e.endsWith("+")){let n=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(n)&&n<=t}if(2===e.split("-").length){let n=e.split("-"),r=Number.parseInt(n[0],10),i=Number.parseInt(n[1],10);return!isNaN(r)&&!isNaN(i)&&r<=t&&t<=i}return Number.parseInt(e,10)===t}var $s=O(()=>{}),ks=mt(t=>{t.__esModule=!0;var e=function(){function t(e){if(!e)throw new TypeError("Invalid argument; `value` has no value.");this.value=t.EMPTY,e&&t.isGuid(e)&&(this.value=e)}return t.isGuid=function(e){var n=e.toString();return e&&(e instanceof t||t.validator.test(n))},t.create=function(){return new t([t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-"))},t.createEmpty=function(){return new t("emptyguid")},t.parse=function(e){return new t(e)},t.raw=function(){return[t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-")},t.gen=function(t){for(var e="",n=0;n<t;n++)e+=(65536*(1+Math.random())|0).toString(16).substring(1);return e},t.prototype.equals=function(e){return t.isGuid(e)&&this.value===e.toString()},t.prototype.isEmpty=function(){return this.value===t.EMPTY},t.prototype.toString=function(){return this.value},t.prototype.toJSON=function(){return{value:this.value}},t.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),t.EMPTY="00000000-0000-0000-0000-000000000000",t}();t.Guid=e});function rt(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function Pt(t){return!0===(t&&t.__isLong__)}function Bs(t){var e=Math.clz32(t&-t);return t?31-e:e}function Ce(t,e){var n,r,i;return e?(i=0<=(t>>>=0)&&t<256)&&(r=Cs[t])?r:(n=J(t,0,!0),i&&(Cs[t]=n),n):(i=-128<=(t|=0)&&t<128)&&(r=Fs[t])?r:(n=J(t,t<0?-1:0,!1),i&&(Fs[t]=n),n)}function Vt(t,e){if(isNaN(t))return e?he:Jt;if(e){if(t<0)return he;if(t>=Ms)return zs}else{if(t<=-Rs)return Ft;if(t+1>=Rs)return Vs}return t<0?Vt(-t,e).neg():J(t%ir|0,t/ir|0,e)}function J(t,e,n){return new rt(t,e,n)}function Vo(t,e,n){if(0===t.length)throw Error("empty string");if("number"==typeof e?(n=e,e=!1):e=!!e,"NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e?he:Jt;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Vo(t.substring(1),e,n).neg();for(var i=Vt(yn(n,8)),o=Jt,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),n);if(a<8){var l=Vt(yn(n,a));o=o.mul(l).add(Vt(u))}else o=(o=o.mul(i)).add(Vt(u))}return o.unsigned=e,o}function Yt(t,e){return"number"==typeof t?Vt(t,e):"string"==typeof t?Vo(t,e):J(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}var Ut,Fs,Cs,yn,Ns,rh,ir,Ms,Rs,Gs,Jt,he,or,Us,Uo,Vs,zs,Ft,D,me,zo=O(()=>{Ut=null;try{Ut=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=Pt,Fs={},Cs={},rt.fromInt=Ce,rt.fromNumber=Vt,rt.fromBits=J,yn=Math.pow,rt.fromString=Vo,rt.fromValue=Yt,Rs=(Ms=(ir=(Ns=65536)*Ns)*ir)/2,Gs=Ce(rh=1<<24),Jt=Ce(0),rt.ZERO=Jt,he=Ce(0,!0),rt.UZERO=he,or=Ce(1),rt.ONE=or,Us=Ce(1,!0),rt.UONE=Us,Uo=Ce(-1),rt.NEG_ONE=Uo,Vs=J(-1,2147483647,!1),rt.MAX_VALUE=Vs,zs=J(-1,-1,!0),rt.MAX_UNSIGNED_VALUE=zs,Ft=J(0,-2147483648,!1),rt.MIN_VALUE=Ft,(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(Ft)){var e=Vt(t),n=this.div(e),r=n.mul(e).sub(this);return n.toString(t)+r.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var i=Vt(yn(t,6),this.unsigned),o=this,s="";;){var a=o.div(i),u=(o.sub(a.mul(i)).toInt()>>>0).toString(t);if((o=a).isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0}
vendor: 5,357 bytes, line 6
6,D.getLowBits=function(){return this.low},D.getLowBitsUnsigned=function(){return this.low>>>0},D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ft)?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)},D.isEven=function(){return!(1&this.low)},D.equals=function(t){return Pt(t)||(t=Yt(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 this.comp(t)<0},D.lt=D.lessThan,D.lessThanOrEqual=function(t){return this.comp(t)<=0},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(Pt(t)||(t=Yt(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},D.comp=D.compare,D.negate=function(){return!this.unsigned&&this.eq(Ft)?Ft:this.not().add(or)},D.neg=D.negate,D.add=function(t){Pt(t)||(t=Yt(t));var e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=t.high>>>16,s=65535&t.high,a=t.low>>>16,u=0,l=0,p=0,c=0;return p+=(c+=i+(65535&t.low))>>>16,l+=(p+=r+a)>>>16,u+=(l+=n+s)>>>16,u+=e+o,J((p&=65535)<<16|(c&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},D.subtract=function(t){return Pt(t)||(t=Yt(t)),this.add(t.neg())},D.sub=D.subtract,D.multiply=function(t){if(this.isZero())return this;if(Pt(t)||(t=Yt(t)),Ut)return J(Ut.mul(this.low,this.high,t.low,t.high),Ut.get_high(),this.unsigned);if(t.isZero())return this.unsigned?he:Jt;if(this.eq(Ft))return t.isOdd()?Ft:Jt;if(t.eq(Ft))return this.isOdd()?Ft:Jt;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(Gs)&&t.lt(Gs))return Vt(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=t.high>>>16,s=65535&t.high,a=t.low>>>16,u=65535&t.low,l=0,p=0,c=0,d=0;return c+=(d+=i*u)>>>16,p+=(c+=r*u)>>>16,c&=65535,p+=(c+=i*a)>>>16,l+=(p+=n*u)>>>16,p&=65535,l+=(p+=r*a)>>>16,p&=65535,l+=(p+=i*s)>>>16,l+=e*u+n*a+r*s+i*o,J((c&=65535)<<16|(d&=65535),(l&=65535)<<16|(p&=65535),this.unsigned)},D.mul=D.multiply,D.divide=function(t){if(Pt(t)||(t=Yt(t)),t.isZero())throw Error("division by zero");var e,n,r;if(Ut)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?J((this.unsigned?Ut.div_u:Ut.div_s)(this.low,this.high,t.low,t.high),Ut.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?he:Jt;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return he;if(t.gt(this.shru(1)))return Us;r=he}else{if(this.eq(Ft))return t.eq(or)||t.eq(Uo)?Ft:t.eq(Ft)?or:(e=this.shr(1).div(t).shl(1)).eq(Jt)?t.isNegative()?or:Uo:(n=this.sub(t.mul(e)),r=e.add(n.div(t)));if(t.eq(Ft))return this.unsigned?he:Jt;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=Jt}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var i=Math.ceil(Math.log(e)/Math.LN2),o=i<=48?1:yn(2,i-48),s=Vt(e),a=s.mul(t);a.isNegative()||a.gt(n);)a=(s=Vt(e-=o,this.unsigned)).mul(t);s.isZero()&&(s=or),r=r.add(s),n=n.sub(a)}return r},D.div=D.divide,D.modulo=function(t){return Pt(t)||(t=Yt(t)),Ut?J((this.unsigned?Ut.rem_u:Ut.rem_s)(this.low,this.high,t.low,t.high),Ut.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?Bs(this.low):Bs(this.high)+32},D.ctz=D.countTrailingZeros,D.and=function(t){return Pt(t)||(t=Yt(t)),J(this.low&t.low,this.high&t.high,this.unsigned)},D.or=function(t){return Pt(t)||(t=Yt(t)),J(this.low|t.low,this.high|t.high,this.unsigned)},D.xor=function(t){return Pt(t)||(t=Yt(t)),J(this.low^t.low,this.high^t.high,this.unsigned)},D.shiftLeft=function(t){return Pt(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 Pt(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 Pt(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?J(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):J(32===t?this.high:this.high>>>t-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.rotateLeft=function(t){var e;return Pt(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?J(this.high,this.low,this.unsigned):t<32?
6(e=32-t,J(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)):(e=32-(t-=32),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 Pt(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)):(e=32-(t-=32),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,n){return n?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)},me=rt}),T,xn=O(()=>{(T={}).Table,T.SIZEOF_SHORT=2,T.SIZEOF_INT=4,T.FILE_IDENTIFIER_LENGTH=4,T.SIZE_PREFIX_LENGTH=4,T.Encoding={UTF8_BYTES:1,UTF16_STRING:2},T.int32=new Int32Array(2),T.float32=new Float32Array(T.int32.buffer),T.float64=new Float64Array(T.int32.buffer),T.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],T.Long=function(t,e){this.low=0|t,this.high=0|e},T.Long.create=function(t,e){return 0==t&&0==e?T.Long.ZERO:new T.Long(t,e)},T.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},T.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},T.Long.ZERO=new T.Long(0,0),T.Builder=function(t){if(t)var e=t;else e=1024;this.bb=T.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},T.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},T.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},T.Builder.prototype.dataBuffer=function(){return this.bb},T.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},T.Builder.prototype.prep=function(t,e){t>this.minalign&&(this.minalign=t);for(var n=1+~(this.bb.capacity()-this.space+e)&t-1;this.space<n+t+e;){var r=this.bb.capacity();this.bb=T.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(n)},T.Builder.prototype.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},T.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},T.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},T.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},T.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},T.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},T.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},T.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},T.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},T.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},T.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},T.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},T.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},T.Builder.prototype.addFieldInt8=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))},T.Builder.prototype.addFieldInt16=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))},T.Builder.prototype.addFieldInt32=function(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))},T.Builder.prototype.addFieldInt64=function(t,e,n){(this.force_defaults||!e.equals(n))&&(this.addInt64(e),this.slot(t))},T.Builder.prototype.addFieldFloat32=function(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))},T.Builder.prototype.addFieldFloat64=function(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))},T.Builder.prototype.addFieldOffset=function(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))},T.Builder.prototype.addFieldStruct=function(t,e,n){e!=n&&(this.nested(e),this.slot(t))},T.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},T.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},T.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},T.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},T.Builder.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var n=e<<1,r=T.ByteBuffer.allocate(n);return r.setPosition(n-e),r.bytes().set(t.bytes(),n-e),r},T.Builder.prototype.addOffset=function(t){this.prep(T.SIZEOF_INT,0),this.writeInt32(this.offset()-t+T.SIZEOF_INT)},T.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()},T.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var n=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var r=(n+2)*T.SIZEOF_SHORT;this.addInt16(r);var i=0,o=this.space;t:for(e=0;e<this.vtables.length;e++){var s=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(s)){for(var a=T.SIZEOF_SHORT;a<r;a+=T.SIZEOF_SHORT)if(this.bb.readInt16(o+a)!=this.bb.readInt16(s+a))continue t;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,i-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},T.Builder.prototype.finish=function(t,e,n){var r=n?T.SIZE_PREFIX_LENGTH:0;
vendor: 6,333 bytes, line 6
6if(e){var i=e;if(this.prep(this.minalign,T.SIZEOF_INT+T.FILE_IDENTIFIER_LENGTH+r),i.length!=T.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+T.FILE_IDENTIFIER_LENGTH);for(var o=T.FILE_IDENTIFIER_LENGTH-1;o>=0;o--)this.writeInt8(i.charCodeAt(o))}this.prep(this.minalign,T.SIZEOF_INT+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},T.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},T.Builder.prototype.requiredField=function(t,e){var n=this.bb.capacity()-t,r=n-this.bb.readInt32(n);if(0==this.bb.readInt16(r+e))throw new Error("FlatBuffers: field "+e+" must be set")},T.Builder.prototype.startVector=function(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(T.SIZEOF_INT,t*e),this.prep(n,t*e)},T.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},T.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var n=0;n<t.length;){var r,i=t.charCodeAt(n++);(r=i<55296||i>=56320?i:(i<<10)+t.charCodeAt(n++)+-56613888)<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),n=0;for(var o=this.space,s=this.bb.bytes();n<e.length;n++)s[o++]=e[n];return this.endVector()},T.Builder.prototype.createLong=function(t,e){return T.Long.create(t,e)},T.ByteBuffer=function(t){this.bytes_=t,this.position_=0},T.ByteBuffer.allocate=function(t){return new T.ByteBuffer(new Uint8Array(t))},T.ByteBuffer.prototype.clear=function(){this.position_=0},T.ByteBuffer.prototype.bytes=function(){return this.bytes_},T.ByteBuffer.prototype.position=function(){return this.position_},T.ByteBuffer.prototype.setPosition=function(t){this.position_=t},T.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},T.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},T.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},T.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},T.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},T.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},T.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},T.ByteBuffer.prototype.readInt64=function(t){return new T.Long(this.readInt32(t),this.readInt32(t+4))},T.ByteBuffer.prototype.readUint64=function(t){return new T.Long(this.readUint32(t),this.readUint32(t+4))},T.ByteBuffer.prototype.readFloat32=function(t){return T.int32[0]=this.readInt32(t),T.float32[0]},T.ByteBuffer.prototype.readFloat64=function(t){return T.int32[T.isLittleEndian?0:1]=this.readInt32(t),T.int32[T.isLittleEndian?1:0]=this.readInt32(t+4),T.float64[0]},T.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},T.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},T.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},T.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},T.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},T.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},T.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},T.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},T.ByteBuffer.prototype.writeFloat32=function(t,e){T.float32[0]=e,this.writeInt32(t,T.int32[0])},T.ByteBuffer.prototype.writeFloat64=function(t,e){T.float64[0]=e,this.writeInt32(t,T.int32[T.isLittleEndian?0:1]),this.writeInt32(t+4,T.int32[T.isLittleEndian?1:0])},T.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+T.SIZEOF_INT+T.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<T.FILE_IDENTIFIER_LENGTH;e++)t+=String.fromCharCode(this.readInt8(this.position_+T.SIZEOF_INT+e));return t},T.ByteBuffer.prototype.__offset=function(t,e){var n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0},T.ByteBuffer.prototype.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},T.ByteBuffer.prototype.__string=function(t,e){t+=this.readInt32(t);var n=this.readInt32(t),r="",i=0;if(t+=T.SIZEOF_INT,e===T.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+n);for(;i<n;){var o,s=this.readUint8(t+i++);if(s<192)o=s;else{var a=this.readUint8(t+i++);if(s<224)o=(31&s)<<6|63&a;else{var u=this.readUint8(t+i++);o=s<240?(15&s)<<12|(63&a)<<6|63&u:(7&s)<<18|(63&a)<<12|(63&u)<<6|63&this.readUint8(t+i++)}}o<65536?r+=String.fromCharCode(o):(o-=65536,r+=String.fromCharCode(55296+(o>>10),56320+(1023&o)))}return r},T.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},T.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+T.SIZEOF_INT},T.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},T.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=T.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+T.FILE_IDENTIFIER_LENGTH);for(var e=0;e<T.FILE_IDENTIFIER_LENGTH;e++)if(t.charCodeAt(e)!=this.readInt8(this.position_+T.SIZEOF_INT+e))return!1;return!0},T.ByteBuffer.prototype.createLong=function(t,e){return T.Long.create(t,e)}}),F,Pr=O(()=>{var t,e,n,r;xn(),(r=(n=(e=(t=F||(F={})).experimental||(t.experimental={})).fbs||(e.fbs={})).AttributeType||(n.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",(t=>{(t=>{(t=>{var e;(e=t.DimensionValueType||(t.DimensionValueType={}))[e.UNKNOWN=0]="UNKNOWN",e[e.VALUE=1]="VALUE",e[e.PARAM=2]="PARAM"}
6)(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(t=>{var e;(e=t.TensorDataType||(t.TensorDataType={}))[e.UNDEFINED=0]="UNDEFINED",e[e.FLOAT=1]="FLOAT",e[e.UINT8=2]="UINT8",e[e.INT8=3]="INT8",e[e.UINT16=4]="UINT16",e[e.INT16=5]="INT16",e[e.INT32=6]="INT32",e[e.INT64=7]="INT64",e[e.STRING=8]="STRING",e[e.BOOL=9]="BOOL",e[e.FLOAT16=10]="FLOAT16",e[e.DOUBLE=11]="DOUBLE",e[e.UINT32=12]="UINT32",e[e.UINT64=13]="UINT64",e[e.COMPLEX64=14]="COMPLEX64",e[e.COMPLEX128=15]="COMPLEX128",e[e.BFLOAT16=16]="BFLOAT16",e[e.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",e[e.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",e[e.FLOAT8E5M2=19]="FLOAT8E5M2",e[e.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(t=>{var e;(e=t.NodeType||(t.NodeType={}))[e.Primitive=0]="Primitive",e[e.Fused=1]="Fused"})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(t=>{var e;(e=t.TypeInfoValue||(t.TypeInfoValue={}))[e.NONE=0]="NONE",e[e.tensor_type=1]="tensor_type",e[e.sequence_type=2]="sequence_type",e[e.map_type=3]="map_type"})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsShape(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__init(t.readInt32(t.position())+t.position(),t)}dim(e,n){let r=this.bb.__offset(this.bb_pos,4);return r?(n||new t.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startDimVector(t,e){t.startVector(4,e,4)}static endShape(t){return t.endObject()}static createShape(t,e){return n.startShape(t),n.addDim(t,e),n.endShape(t)}}e.Shape=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimension(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__init(t.readInt32(t.position())+t.position(),t)}value(e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new t.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+n),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,r){return n.startDimension(t),n.addValue(t,e),n.addDenotation(t,r),n.endDimension(t)}}e.Dimension=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(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,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimensionValue(t,n){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(n||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,n,r,i){return e.startDimensionValue(t),e.addDimType(t,n),e.addDimValue(t,r),e.addDimParam(t,i),e.endDimensionValue(t)}}t.DimensionValue=e})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensorTypeAndShape(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+n),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,r){return n.startTensorTypeAndShape(t),n.addElemType(t,e),n.addShape(t,r),n.endTensorTypeAndShape(t)}}e.TensorTypeAndShape=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMapType(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),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,r){return n.startMapType(t),n.addKeyType(t,e),n.addValueType(t,r),n.endMapType(t)}}e.MapType=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSequenceType(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__init(t.readInt32(t.position())+t.position(),t)}elemType(e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),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 n.startSequenceType(t),n.addElemType(t,e),n.endSequenceType(t)}}e.SequenceType=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(t=>{t.EdgeEnd=class{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,n,r){return t.prep(4,12),t.writeInt32(r),t.writeInt32(n),t.writeInt32(e),t.offset()}}})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodeEdge(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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}
vendor: 32,316 bytes, line 6
6inputEdges(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+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,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new t.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+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,r,i){return n.startNodeEdge(t),n.addNodeIndex(t,e),n.addInputEdges(t,r),n.addOutputEdges(t,i),n.endNodeEdge(t)}}e.NodeEdge=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNode(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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 n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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,n){let r=this.bb.__offset(this.bb_pos,24);return r?(n||new t.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addInt32(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startImplicitInputsVector(t,e){t.startVector(4,e,4)}static endNode(t){return t.endObject()}static createNode(t,e,r,i,o,s,a,u,l,p,c,d,h,f){return n.startNode(t),n.addName(t,e),n.addDocString(t,r),n.addDomain(t,i),n.addSinceVersion(t,o),n.addIndex(t,s),n.addOpType(t,a),n.addType(t,u),n.addExecutionProviderType(t,l),n.addInputs(t,p),n.addOutputs(t,c),n.addAttributes(t,d),n.addInputArgCounts(t,h),n.addImplicitInputs(t,f),n.endNode(t)}}e.Node=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsValueInfo(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,8);return n?(e||new t.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),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,r,i){return n.startValueInfo(t),n.addName(t,e),n.addDocString(t,r),n.addType(t,i),n.endValueInfo(t)}}e.ValueInfo=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(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,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTypeInfo(t,n){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(n||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,n,r,i){return e.startTypeInfo(t),e.addDenotation(t,n),e.addValueType(t,r),e.addValue(t,i),e.endTypeInfo(t)}}t.TypeInfo=e})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(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,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOperatorSetId(t,n){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(n||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,n,r){return e.startOperatorSetId(t),e.addDomain(t,n),e.addVersion(t,r),e.endOperatorSetId(t)}}t.OperatorSetId=e})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(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,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensor(t,n){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(n||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 n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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 n=e.length-1;n>=0;n--)t.addInt64(e[n]);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 n=e.length-1;n>=0;n--)t.addInt8(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startStringDataVector(t,e){t.startVector(4,e,4)}static endTensor(t){return t.endObject()}static createTensor(t,n,r,i,o,s,a){return e.startTensor(t),e.addName(t,n),e.addDocString(t,r),e.addDims(t,i),e.addDataType(t,o),e.addRawData(t,s),e.addStringData(t,a),e.endTensor(t)}}t.Tensor=e})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSparseTensor(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__init(t.readInt32(t.position())+t.position(),t)}values(e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}indices(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),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 n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static endSparseTensor(t){return t.endObject()}static createSparseTensor(t,e,r,i){return n.startSparseTensor(t),n.addValues(t,e),n.addIndices(t,r),n.addDims(t,i),n.endSparseTensor(t)}}e.SparseTensor=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsAttribute(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,16);return n?(e||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}g(e){let n=this.bb.__offset(this.bb_pos,18);return n?(e||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+n),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 n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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,n){let r=this.bb.__offset(this.bb_pos,26);return r?(n||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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,n){let r=this.bb.__offset(this.bb_pos,28);return r?(n||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=e.length-1;n>=0;n--)t.addFloat32(e[n]);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 n=e.length-1;n>=0;n--)t.addInt64(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startGraphsVector(t,e){t.startVector(4,e,4)}static endAttribute(t){return t.endObject()}static createAttribute(t,e,r,i,o,s,a,u,l,p,c,d,h,f){return n.startAttribute(t),n.addName(t,e),n.addDocString(t,r),n.addType(t,i),n.addF(t,o),n.addI(t,s),n.addS(t,a),n.addT(t,u),n.addG(t,l),n.addFloats(t,p),n.addInts(t,c),n.addStrings(t,d),n.addTensors(t,h),n.addGraphs(t,f),n.endAttribute(t)}}e.Attribute=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGraph(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__init(t.readInt32(t.position())+t.position(),t)}initializers(e,n){let r=this.bb.__offset(this.bb_pos,4);return r?(n||new t.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new t.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new t.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new t.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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 n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+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,n){let r=this.bb.__offset(this.bb_pos,18);return r?(n||new t.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startSparseInitializersVector(t,e){t.startVector(4,e,4)}static endGraph(t){return t.endObject()}static createGraph(t,e,r,i,o,s,a,u,l){return n.startGraph(t),n.addInitializers(t,e),n.addNodeArgs(t,r),n.addNodes(t,i),n.addMaxNodeIndex(t,o),n.addNodeEdges(t,s),n.addInputs(t,a),n.addOutputs(t,u),n.addSparseInitializers(t,l),n.endGraph(t)}}e.Graph=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsModel(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new t.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=this.bb.__offset(this.bb_pos,18);return n?(e||new t.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+n),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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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,r,i,o,s,a,u,l,p){return n.startModel(t),n.addIrVersion(t,e),n.addOpsetImport(t,r),n.addProducerName(t,i),n.addProducerVersion(t,o),n.addDomain(t,s),n.addModelVersion(t,a),n.addDocString(t,u),n.addGraph(t,l),n.addGraphDocString(t,p),n.endModel(t)}}e.Model=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(t=>{(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,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelCreateInfos(t,n){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(n||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 n=e.length-1;n>=0;n--)t.addInt32(e[n]);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 n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startKernelDefHashesVector(t,e){t.startVector(8,e,8)}static endKernelCreateInfos(t){return t.endObject()}static createKernelCreateInfos(t,n,r){return e.startKernelCreateInfos(t),e.addNodeIndices(t,n),e.addKernelDefHashes(t,r),e.endKernelCreateInfos(t)}}t.KernelCreateInfos=e})(t.fbs||(t.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSubGraphSessionState(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+n),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,r){return n.startSubGraphSessionState(t),n.addGraphId(t,e),n.addSessionState(t,r),n.endSubGraphSessionState(t)}}e.SubGraphSessionState=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSessionState(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__init(t.readInt32(t.position())+t.position(),t)}kernels(e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new t.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}subGraphSessionStates(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new t.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startSubGraphSessionStatesVector(t,e){t.startVector(4,e,4)}static endSessionState(t){return t.endObject()}static createSessionState(t,e,r){return n.startSessionState(t),n.addKernels(t,e),n.addSubGraphSessionStates(t,r),n.endSessionState(t)}}e.SessionState=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={})),(t=>{(e=>{(e=>{class n{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 n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInferenceSession(t,e){return t.setPosition(t.position()+T.SIZE_PREFIX_LENGTH),(e||new n).__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 n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}sessionState(e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new t.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+n),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,r,i){return n.startInferenceSession(t),n.addOrtVersion(t,e),n.addModel(t,r),n.addSessionState(t,i),n.endInferenceSession(t)}}e.InferenceSession=n})(e.fbs||(e.fbs={}))})(t.experimental||(t.experimental={}))})(F||(F={}))}),Hs=mt((t,e)=>{e.exports=function(t,e){for(var n=new Array(arguments.length-1),r=0,i=2,o=!0;i<arguments.length;)n[r++]=arguments[i++];return new Promise(function(i,s){n[r]=function(t){if(o)if(o=!1,t)s(t);else{for(var e=new Array(arguments.length-1),n=0;n<e.length;)e[n++]=arguments[n];i.apply(null,e)}};try{t.apply(e||null,n)}catch(a){o&&(o=!1,s(a))}})}}),Ks=mt(t=>{var e=t;e.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&"="===t.charAt(e);)++n;return Math.ceil(3*t.length)/4-n};var n,r=new Array(64),i=new Array(123);for(n=0;n<64;)i[r[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;e.encode=function(t,e,n){for(var i,o=null,s=[],a=0,u=0;e<n;){var l=t[e++];switch(u){case 0:s[a++]=r[l>>2],i=(3&l)<<4,u=1;break;case 1:s[a++]=r[i|l>>4],i=(15&l)<<2,u=2;break;case 2:s[a++]=r[i|l>>6],s[a++]=r[63&l],u=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return u&&(s[a++]=r[i],s[a++]=61,1===u&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var o="invalid encoding";e.decode=function(t,e,n){for(var r,s=n,a=0,u=0;u<t.length;){var l=t.charCodeAt(u++);if(61===l&&a>1)break;if(void 0===(l=i[l]))throw Error(o);switch(a){case 0:r=l,a=1;break;case 1:e[n++]=r<<2|(48&l)>>4,r=l,a=2;break;case 2:e[n++]=(15&r)<<4|(60&l)>>2,r=l,a=3;break;case 3:e[n++]=(3&r)<<6|l,a=0}}if(1===a)throw Error(o);return n-s},e.test=function(t){return/^(?:[A-Za-z0-9+/]{4}
vendor: 4,082 bytes, line 6
6)*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}),Ys=mt((t,e)=>{function n(){this._listeners={}}e.exports=n,n.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this},n.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var n=this._listeners[t],r=0;r<n.length;)n[r].fn===e?n.splice(r,1):++r;return this},n.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<e.length;)e[r].fn.apply(e[r++].ctx,n)}return this}}),ou=mt((t,e)=>{function n(t){return typeof Float32Array<"u"?function(){var e=new Float32Array([-0]),n=new Uint8Array(e.buffer),r=128===n[3];function i(t,r,i){e[0]=t,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function o(t,r,i){e[0]=t,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function s(t,r){return n[0]=t[r],n[1]=t[r+1],n[2]=t[r+2],n[3]=t[r+3],e[0]}function a(t,r){return n[3]=t[r],n[2]=t[r+1],n[1]=t[r+2],n[0]=t[r+3],e[0]}t.writeFloatLE=r?i:o,t.writeFloatBE=r?o:i,t.readFloatLE=r?s:a,t.readFloatBE=r?a:s}():function(){function e(t,e,n,r){var i=e<0?1:0;if(i&&(e=-e),0===e)t(1/e>0?0:2147483648,n,r);else if(isNaN(e))t(2143289344,n,r);else if(e>34028234663852886e22)t((i<<31|2139095040)>>>0,n,r);else if(e<11754943508222875e-54)t((i<<31|Math.round(e/1401298464324817e-60))>>>0,n,r);else{var o=Math.floor(Math.log(e)/Math.LN2);t((i<<31|o+127<<23|8388607&Math.round(e*Math.pow(2,-o)*8388608))>>>0,n,r)}}function n(t,e,n){var r=t(e,n),i=2*(r>>31)+1,o=r>>>23&255,s=8388607&r;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}t.writeFloatLE=e.bind(null,r),t.writeFloatBE=e.bind(null,i),t.readFloatLE=n.bind(null,o),t.readFloatBE=n.bind(null,s)}(),typeof Float64Array<"u"?function(){var e=new Float64Array([-0]),n=new Uint8Array(e.buffer),r=128===n[7];function i(t,r,i){e[0]=t,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function o(t,r,i){e[0]=t,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function s(t,r){return n[0]=t[r],n[1]=t[r+1],n[2]=t[r+2],n[3]=t[r+3],n[4]=t[r+4],n[5]=t[r+5],n[6]=t[r+6],n[7]=t[r+7],e[0]}function a(t,r){return n[7]=t[r],n[6]=t[r+1],n[5]=t[r+2],n[4]=t[r+3],n[3]=t[r+4],n[2]=t[r+5],n[1]=t[r+6],n[0]=t[r+7],e[0]}t.writeDoubleLE=r?i:o,t.writeDoubleBE=r?o:i,t.readDoubleLE=r?s:a,t.readDoubleBE=r?a:s}():function(){function e(t,e,n,r,i,o){var s=r<0?1:0;if(s&&(r=-r),0===r)t(0,i,o+e),t(1/r>0?0:2147483648,i,o+n);else if(isNaN(r))t(0,i,o+e),t(2146959360,i,o+n);else if(r>17976931348623157e292)t(0,i,o+e),t((s<<31|2146435072)>>>0,i,o+n);else{var a;if(r<22250738585072014e-324)t((a=r/5e-324)>>>0,i,o+e),t((s<<31|a/4294967296)>>>0,i,o+n);else{var u=Math.floor(Math.log(r)/Math.LN2);1024===u&&(u=1023),t(4503599627370496*(a=r*Math.pow(2,-u))>>>0,i,o+e),t((s<<31|u+1023<<20|1048576*a&1048575)>>>0,i,o+n)}}}function n(t,e,n,r,i){var o=t(r,i+e),s=t(r,i+n),a=2*(s>>31)+1,u=s>>>20&2047,l=4294967296*(1048575&s)+o;return 2047===u?l?NaN:a*(1/0):0===u?5e-324*a*l:a*Math.pow(2,u-1075)*(l+4503599627370496)}t.writeDoubleLE=e.bind(null,r,0,4),t.writeDoubleBE=e.bind(null,i,4,0),t.readDoubleLE=n.bind(null,o,0,4),t.readDoubleBE=n.bind(null,s,4,0)}(),t}function r(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}function i(t,e,n){e[n]=t>>>24,e[n+1]=t>>>16&255,e[n+2]=t>>>8&255,e[n+3]=255&t}function o(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function s(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}e.exports=n(n)}),iu=mt((exports,module)=>{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}),su=mt(t=>{var e=t;e.length=function(t){for(var e=0,n=0,r=0;r<t.length;++r)(n=t.charCodeAt(r))<128?e+=1:n<2048?e+=2:55296==(64512&n)&&56320==(64512&t.charCodeAt(r+1))?(++r,e+=4):e+=3;return e},e.read=function(t,e,n){if(n-e<1)return"";for(var r,i=null,o=[],s=0;e<n;
vendor: 13,604 bytes, line 6
6)(r=t[e++])<128?o[s++]=r:r>191&&r<224?o[s++]=(31&r)<<6|63&t[e++]:r>239&&r<365?(r=((7&r)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,o[s++]=55296+(r>>10),o[s++]=56320+(1023&r)):o[s++]=(15&r)<<12|(63&t[e++])<<6|63&t[e++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},e.write=function(t,e,n){for(var r,i,o=n,s=0;s<t.length;++s)(r=t.charCodeAt(s))<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=t.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&i),++s,e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=63&r|128):(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=63&r|128);return n-o}}),lu=mt((t,e)=>{e.exports=function(t,e,n){var r=n||8192,i=r>>>1,o=null,s=r;return function(n){if(n<1||n>i)return t(n);s+n>r&&(o=t(r),s=0);var a=e.call(o,s,s+=n);return 7&s&&(s=1+(7|s)),a}}}),cu=mt((t,e)=>{e.exports=r;var n=Oe();function r(t,e){this.lo=t>>>0,this.hi=e>>>0}var i=r.zero=new r(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var o=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(t){if(0===t)return i;var e=t<0;e&&(t=-t);var n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)},r.from=function(t){if("number"==typeof t)return r.fromNumber(t);if(n.isString(t)){if(!n.Long)return r.fromNumber(parseInt(t,10));t=n.Long.fromString(t)}return t.low||t.high?new r(t.low>>>0,t.high>>>0):i},r.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=1+~this.lo>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+4294967296*n)}return this.lo+4294967296*this.hi},r.prototype.toLong=function(t){return n.Long?new n.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var s=String.prototype.charCodeAt;r.fromHash=function(t){return t===o?i:new r((s.call(t,0)|s.call(t,1)<<8|s.call(t,2)<<16|s.call(t,3)<<24)>>>0,(s.call(t,4)|s.call(t,5)<<8|s.call(t,6)<<16|s.call(t,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},r.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},r.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}}),Oe=mt(t=>{var e=t;function n(t,e,n){for(var r=Object.keys(e),i=0;i<r.length;++i)(void 0===t[r[i]]||!n)&&(t[r[i]]=e[r[i]]);return t}function r(t){function e(t,r){if(!(this instanceof e))return new e(t,r);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&n(this,r)}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=Hs(),e.base64=Ks(),e.EventEmitter=Ys(),e.float=ou(),e.inquire=iu(),e.utf8=su(),e.pool=lu(),e.LongBits=cu(),e.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),e.global=e.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||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 n=t[e];return!(null==n||!t.hasOwnProperty(e))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).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=typeof Uint8Array<"u"?Uint8Array:Array,e.Long=e.global.dcodeIO&&e.global.dcodeIO.Long||e.global.Long||e.inquire("long"),e.key2Re=/^true|false|0|1$/,e.key32Re=/^-?(?:0|[1-9][0-9]*)$/,e.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,e.longToHash=function(t){return t?e.LongBits.from(t).toHash():e.LongBits.zeroHash},e.longFromHash=function(t,n){var r=e.LongBits.fromHash(t);return e.Long?e.Long.fromBits(r.lo,r.hi,n):r.toNumber(!!n)},e.merge=n,e.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},e.newError=r,e.ProtocolError=r("ProtocolError"),e.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var t=Object.keys(this),n=t.length-1;n>-1;--n)if(1===e[t[n]]&&void 0!==this[t[n]]&&null!==this[t[n]])return t[n]}},e.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}},e.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},e._configure=function(){var t=e.Buffer;t?(e._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,n){return new t(e,n)},e._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):e._Buffer_from=e._Buffer_allocUnsafe=null}}),Zo=mt((t,e)=>{e.exports=p;var n,r=Oe(),i=r.LongBits,o=r.base64,s=r.utf8;function a(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}function u(){}function l(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function p(){this.len=0,this.head=new a(u,0,0),this.tail=this.head,this.states=null}var c=function(){return r.Buffer?function(){return(p.create=function(){return new n})()}:function(){return new p}};function d(t,e,n){e[n]=255&t}function h(t,e){this.len=t,this.next=void 0,this.val=e}function f(t,e,n){for(;t.hi;)e[n++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[n++]=127&t.lo|128,t.lo=t.lo>>>7;e[n++]=t.lo}function g(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}p.create=c(),p.alloc=function(t){return new r.Array(t)},r.Array!==Array&&(p.alloc=r.pool(p.alloc,r.Array.prototype.subarray)),p.prototype._push=function(t,e,n){return this.tail=this.tail.next=new a(t,e,n),this.len+=e,this},h.prototype=Object.create(a.prototype),h.prototype.fn=function(t,e,n){for(;t>127;)e[n++]=127&t|128,t>>>=7;e[n]=t},p.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new h((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},p.prototype.int32=function(t){return t<0?this._push(f,10,i.fromNumber(t)):this.uint32(t)},p.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},p.prototype.uint64=function(t){var e=i.from(t);return this._push(f,e.length(),e)},p.prototype.int64=p.prototype.uint64,p.prototype.sint64=function(t){var e=i.from(t).zzEncode();return this._push(f,e.length(),e)},p.prototype.bool=function(t){return this._push(d,1,t?1:0)},p.prototype.fixed32=function(t){return this._push(g,4,t>>>0)},p.prototype.sfixed32=p.prototype.fixed32,p.prototype.fixed64=function(t){var e=i.from(t);return this._push(g,4,e.lo)._push(g,4,e.hi)},p.prototype.sfixed64=p.prototype.fixed64,p.prototype.float=function(t){return this._push(r.float.writeFloatLE,4,t)},p.prototype.double=function(t){return this._push(r.float.writeDoubleLE,8,t)};var m=r.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var r=0;r<t.length;++r)e[n+r]=t[r]};p.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(d,1,0);if(r.isString(t)){var n=p.alloc(e=o.length(t));o.decode(t,n,0),t=n}return this.uint32(e)._push(m,e,t)},p.prototype.string=function(t){var e=s.length(t);return e?this.uint32(e)._push(s.write,e,t):this._push(d,1,0)},p.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new a(u,0,0),this.len=0,this},p.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 a(u,0,0),this.len=0),this},p.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this},p.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e},p._configure=function(t){n=t,p.create=c(),n._configure()}}),Tu=mt((t,e)=>{e.exports=i;var n=Zo();(i.prototype=Object.create(n.prototype)).constructor=i;var r=Oe();function i(){n.call(this)}function o(t,e,n){t.length<40?r.utf8.write(t,e,n):e.utf8Write?e.utf8Write(t,n):e.write(t,n)}i._configure=function(){i.alloc=r._Buffer_allocUnsafe,i.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&"set"===r.Buffer.prototype.set.name?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var r=0;r<t.length;)e[n++]=t[r++]}},i.prototype.bytes=function(t){r.isString(t)&&(t=r._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(i.writeBytesBuffer,e,t),this},i.prototype.string=function(t){var e=r.Buffer.byteLength(t);return this.uint32(e),e&&this._push(o,e,t),this},i._configure()}),ei=mt((t,e)=>{e.exports=a;var n,r=Oe(),i=r.LongBits,o=r.utf8;function s(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function a(t){this.buf=t,this.pos=0,this.len=t.length}var u=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new a(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new a(t);throw Error("illegal buffer")},l=function(){return r.Buffer?function(t){return(a.create=function(t){return r.Buffer.isBuffer(t)?new n(t):u(t)})(t)}:u};function p(){var t=new i(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw s(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}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;if(e=0,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 s(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 c(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function d(){if(this.pos+8>this.len)throw s(this,8);return new i(c(this.buf,this.pos+=4),c(this.buf,this.pos+=4))}a.create=l(),a.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice,a.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,s(this,10);return t}}(),a.prototype.int32=function(){return 0|this.uint32()},a.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)},a.prototype.bool=function(){return 0!==this.uint32()},a.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return c(this.buf,this.pos+=4)},a.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|c(this.buf,this.pos+=4)},a.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var t=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},a.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var t=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},a.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw s(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(e,n);if(e===n){var i=r.Buffer;return i?i.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,e,n)},a.prototype.string=function(){var t=this.bytes();return o.read(t,0,t.length)},a.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw s(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw s(this)}while(128&this.buf[this.pos++]);return this},a.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},a._configure=function(t){n=t,a.create=l(),n._configure();var e=r.Long?"toLong":"toNumber";r.merge(a.prototype,{int64:function(){return p.call(this)[e](!1)},uint64:function(){return p.call(this)[e](!0)},sint64:function(){return p.call(this).zzDecode()[e](!1)},fixed64:function(){return d.call(this)[e](!0)},sfixed64:function(){return d.call(this)[e](!1)}})}}),Eu=mt((t,e)=>{e.exports=i;
6var n=ei();(i.prototype=Object.create(n.prototype)).constructor=i;var r=Oe();function i(t){n.call(this,t)}i._configure=function(){r.Buffer&&(i.prototype._slice=r.Buffer.prototype.slice)},i.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))},i._configure()}),Lu=mt((t,e)=>{e.exports=r;var n=Oe();function r(t,e,r){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!e,this.responseDelimited=!!r}(r.prototype=Object.create(n.EventEmitter.prototype)).constructor=r,r.prototype.rpcCall=function t(e,r,i,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return n.asPromise(t,a,e,r,i,o);if(a.rpcImpl)try{return a.rpcImpl(e,r[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(t,n){if(t)return a.emit("error",t,e),s(t);if(null!==n){if(!(n instanceof i))try{n=i[a.responseDelimited?"decodeDelimited":"decode"](n)}catch(r){return a.emit("error",r,e),s(r)}return a.emit("data",n,e),s(null,n)}a.end(!0)})}catch(u){return a.emit("error",u,e),void setTimeout(function(){s(u)},0)}else setTimeout(function(){s(Error("already ended"))},0)},r.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}}),ku=mt(t=>{t.Service=Lu()}),Fu=mt((t,e)=>{e.exports={}}),Ru=mt(t=>{var e=t;function n(){e.util._configure(),e.Writer._configure(e.BufferWriter),e.Reader._configure(e.BufferReader)}e.build="minimal",e.Writer=Zo(),e.BufferWriter=Tu(),e.Reader=ei(),e.BufferReader=Eu(),e.util=Oe(),e.rpc=ku(),e.roots=Fu(),e.configure=n,n()}),Mu=mt((t,e)=>{e.exports=Ru()}),sr=mt((t,e)=>{var n=Mu(),r=n.Reader,i=n.Writer,o=n.util,s=n.roots.default||(n.roots.default={});s.onnx=function(){var t,e,a={};return a.Version=(t={},(e=Object.create(t))[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),a.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),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.name="",t.prototype.refAttrName="",t.prototype.docString="",t.prototype.type=0,t.prototype.f=0,t.prototype.i=o.Long?o.Long.fromBits(0,0,!1):0,t.prototype.s=o.newBuffer([]),t.prototype.t=null,t.prototype.g=null,t.prototype.sparseTensor=null,t.prototype.tp=null,t.prototype.floats=o.emptyArray,t.prototype.ints=o.emptyArray,t.prototype.strings=o.emptyArray,t.prototype.tensors=o.emptyArray,t.prototype.graphs=o.emptyArray,t.prototype.sparseTensors=o.emptyArray,t.prototype.typeProtos=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.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")&&s.onnx.TensorProto.encode(t.t,e.uint32(42).fork()).ldelim(),null!=t.g&&Object.hasOwnProperty.call(t,"g")&&s.onnx.GraphProto.encode(t.g,e.uint32(50).fork()).ldelim(),null!=t.floats&&t.floats.length){e.uint32(58).fork();for(var n=0;n<t.floats.length;++n)e.float(t.floats[n]);e.ldelim()}if(null!=t.ints&&t.ints.length){for(e.uint32(66).fork(),n=0;n<t.ints.length;++n)e.int64(t.ints[n]);e.ldelim()}if(null!=t.strings&&t.strings.length)for(n=0;n<t.strings.length;++n)e.uint32(74).bytes(t.strings[n]);if(null!=t.tensors&&t.tensors.length)for(n=0;n<t.tensors.length;++n)s.onnx.TensorProto.encode(t.tensors[n],e.uint32(82).fork()).ldelim();if(null!=t.graphs&&t.graphs.length)for(n=0;n<t.graphs.length;++n)s.onnx.GraphProto.encode(t.graphs[n],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")&&s.onnx.TypeProto.encode(t.tp,e.uint32(114).fork()).ldelim(),null!=t.typeProtos&&t.typeProtos.length)for(n=0;n<t.typeProtos.length;++n)s.onnx.TypeProto.encode(t.typeProtos[n],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")&&s.onnx.SparseTensorProto.encode(t.sparseTensor,e.uint32(178).fork()).ldelim(),null!=t.sparseTensors&&t.sparseTensors.length)for(n=0;n<t.sparseTensors.length;++n)s.onnx.SparseTensorProto.encode(t.sparseTensors[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.AttributeProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.name=t.string();break;case 21:i.refAttrName=t.string();break;case 13:i.docString=t.string();break;case 20:i.type=t.int32();break;case 2:i.f=t.float();break;case 3:i.i=t.int64();break;case 4:i.s=t.bytes();break;case 5:i.t=s.onnx.TensorProto.decode(t,t.uint32());break;case 6:i.g=s.onnx.GraphProto.decode(t,t.uint32());break;case 22:i.sparseTensor=s.onnx.SparseTensorProto.decode(t,t.uint32());break;case 14:i.tp=s.onnx.TypeProto.decode(t,t.uint32());break;case 7:if(i.floats&&i.floats.length||(i.floats=[]),2==(7&o))for(var a=t.uint32()+t.pos;t.pos<a;)i.floats.push(t.float());else i.floats.push(t.float());break;case 8:if(i.ints&&i.ints.length||(i.ints=[]),2==(7&o))for(a=t.uint32()+t.pos;t.pos<a;)i.ints.push(t.int64());else i.ints.push(t.int64());break;case 9:i.strings&&i.strings.length||(i.strings=[]),i.strings.push(t.bytes());break;case 10:i.tensors&&i.tensors.length||(i.tensors=[]),i.tensors.push(s.onnx.TensorProto.decode(t,t.uint32()));break;case 11:i.graphs&&i.graphs.length||(i.graphs=[]),i.graphs.push(s.onnx.GraphProto.decode(t,t.uint32()));break;case 23:i.sparseTensors&&i.sparseTensors.length||(i.sparseTensors=[]),i.sparseTensors.push(s.onnx.SparseTensorProto.decode(t,t.uint32()));break;case 15:i.typeProtos&&i.typeProtos.length||(i.typeProtos=[]),i.typeProtos.push(s.onnx.TypeProto.decode(t,t.uint32()));break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.isString(t.name))return"name: string expected";if(null!=t.refAttrName&&t.hasOwnProperty("refAttrName")&&!o.isString(t.refAttrName))return"refAttrName: string expected";if(null!=t.docString&&t.hasOwnProperty("docString")&&!o.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")&&!o.isInteger(t.i)&&!(t.i&&o.isInteger(t.i.low)&&o.isInteger(t.i.high)))return"i: integer|Long expected";if(null!=t.s&&t.hasOwnProperty("s")&&!(t.s&&"number"==typeof t.s.length||o.isString(t.s)))return"s: buffer expected";if(null!=t.t&&t.hasOwnProperty("t")&&(n=s.onnx.TensorProto.verify(t.t)))return"t."+n;if(null!=t.g&&t.hasOwnProperty("g")&&(n=s.onnx.GraphProto.verify(t.g)))return"g."+n;if(null!=t.sparseTensor&&t.hasOwnProperty("sparseTensor")&&(n=s.onnx.SparseTensorProto.verify(t.sparseTensor)))return"sparseTensor."+n;if(null!=t.tp&&t.hasOwnProperty("tp")&&(n=s.onnx.TypeProto.verify(t.tp)))return"tp."+n;if(null!=t.floats&&t.hasOwnProperty("floats")){if(!Array.isArray(t.floats))return"floats: array expected";for(var e=0;e<t.floats.length;++e)if("number"!=typeof t.floats[e])return"floats: number[] expected"}if(null!=t.ints&&t.hasOwnProperty("ints")){if(!Array.isArray(t.ints))return"ints: array expected";for(e=0;e<t.ints.length;++e)if(!(o.isInteger(t.ints[e])||t.ints[e]&&o.isInteger(t.ints[e].low)&&o.isInteger(t.ints[e].high)))return"ints: integer|Long[] expected"}
vendor: 72,782 bytes, line 6
6if(null!=t.strings&&t.hasOwnProperty("strings")){if(!Array.isArray(t.strings))return"strings: array expected";for(e=0;e<t.strings.length;++e)if(!(t.strings[e]&&"number"==typeof t.strings[e].length||o.isString(t.strings[e])))return"strings: buffer[] expected"}if(null!=t.tensors&&t.hasOwnProperty("tensors")){if(!Array.isArray(t.tensors))return"tensors: array expected";for(e=0;e<t.tensors.length;++e)if(n=s.onnx.TensorProto.verify(t.tensors[e]))return"tensors."+n}if(null!=t.graphs&&t.hasOwnProperty("graphs")){if(!Array.isArray(t.graphs))return"graphs: array expected";for(e=0;e<t.graphs.length;++e)if(n=s.onnx.GraphProto.verify(t.graphs[e]))return"graphs."+n}if(null!=t.sparseTensors&&t.hasOwnProperty("sparseTensors")){if(!Array.isArray(t.sparseTensors))return"sparseTensors: array expected";for(e=0;e<t.sparseTensors.length;++e)if(n=s.onnx.SparseTensorProto.verify(t.sparseTensors[e]))return"sparseTensors."+n}if(null!=t.typeProtos&&t.hasOwnProperty("typeProtos")){if(!Array.isArray(t.typeProtos))return"typeProtos: array expected";for(e=0;e<t.typeProtos.length;++e){var n;if(n=s.onnx.TypeProto.verify(t.typeProtos[e]))return"typeProtos."+n}}return null},t.fromObject=function(t){if(t instanceof s.onnx.AttributeProto)return t;var e=new s.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:if("number"==typeof t.type){e.type=t.type;break}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&&(o.Long?(e.i=o.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 o.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber())),null!=t.s&&("string"==typeof t.s?o.base64.decode(t.s,e.s=o.newBuffer(o.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=s.onnx.TensorProto.fromObject(t.t)}if(null!=t.g){if("object"!=typeof t.g)throw TypeError(".onnx.AttributeProto.g: object expected");e.g=s.onnx.GraphProto.fromObject(t.g)}if(null!=t.sparseTensor){if("object"!=typeof t.sparseTensor)throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");e.sparseTensor=s.onnx.SparseTensorProto.fromObject(t.sparseTensor)}if(null!=t.tp){if("object"!=typeof t.tp)throw TypeError(".onnx.AttributeProto.tp: object expected");e.tp=s.onnx.TypeProto.fromObject(t.tp)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");e.floats=[];for(var n=0;n<t.floats.length;++n)e.floats[n]=Number(t.floats[n])}if(t.ints){if(!Array.isArray(t.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");for(e.ints=[],n=0;n<t.ints.length;++n)o.Long?(e.ints[n]=o.Long.fromValue(t.ints[n])).unsigned=!1:"string"==typeof t.ints[n]?e.ints[n]=parseInt(t.ints[n],10):"number"==typeof t.ints[n]?e.ints[n]=t.ints[n]:"object"==typeof t.ints[n]&&(e.ints[n]=new o.LongBits(t.ints[n].low>>>0,t.ints[n].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(e.strings=[],n=0;n<t.strings.length;++n)"string"==typeof t.strings[n]?o.base64.decode(t.strings[n],e.strings[n]=o.newBuffer(o.base64.length(t.strings[n])),0):t.strings[n].length>=0&&(e.strings[n]=t.strings[n])}if(t.tensors){if(!Array.isArray(t.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");for(e.tensors=[],n=0;n<t.tensors.length;++n){if("object"!=typeof t.tensors[n])throw TypeError(".onnx.AttributeProto.tensors: object expected");e.tensors[n]=s.onnx.TensorProto.fromObject(t.tensors[n])}}if(t.graphs){if(!Array.isArray(t.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");for(e.graphs=[],n=0;n<t.graphs.length;++n){if("object"!=typeof t.graphs[n])throw TypeError(".onnx.AttributeProto.graphs: object expected");e.graphs[n]=s.onnx.GraphProto.fromObject(t.graphs[n])}}if(t.sparseTensors){if(!Array.isArray(t.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");for(e.sparseTensors=[],n=0;n<t.sparseTensors.length;++n){if("object"!=typeof t.sparseTensors[n])throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");e.sparseTensors[n]=s.onnx.SparseTensorProto.fromObject(t.sparseTensors[n])}}if(t.typeProtos){if(!Array.isArray(t.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");for(e.typeProtos=[],n=0;n<t.typeProtos.length;++n){if("object"!=typeof t.typeProtos[n])throw TypeError(".onnx.AttributeProto.typeProtos: object expected");e.typeProtos[n]=s.onnx.TypeProto.fromObject(t.typeProtos[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.floats=[],n.ints=[],n.strings=[],n.tensors=[],n.graphs=[],n.typeProtos=[],n.sparseTensors=[]),e.defaults){if(n.name="",n.f=0,o.Long){var r=new o.Long(0,0,!1);n.i=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.i=e.longs===String?"0":0;e.bytes===String?n.s="":(n.s=[],e.bytes!==Array&&(n.s=o.newBuffer(n.s))),n.t=null,n.g=null,n.docString="",n.tp=null,n.type=e.enums===String?"UNDEFINED":0,n.refAttrName="",n.sparseTensor=null}if(null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),null!=t.f&&t.hasOwnProperty("f")&&(n.f=e.json&&!isFinite(t.f)?String(t.f):t.f),null!=t.i&&t.hasOwnProperty("i")&&("number"==typeof t.i?n.i=e.longs===String?String(t.i):t.i:n.i=e.longs===String?o.Long.prototype.toString.call(t.i):e.longs===Number?new o.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber():t.i),null!=t.s&&t.hasOwnProperty("s")&&(n.s=e.bytes===String?o.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")&&(n.t=s.onnx.TensorProto.toObject(t.t,e)),null!=t.g&&t.hasOwnProperty("g")&&(n.g=s.onnx.GraphProto.toObject(t.g,e)),t.floats&&t.floats.length){n.floats=[];for(var i=0;i<t.floats.length;++i)n.floats[i]=e.json&&!isFinite(t.floats[i])?String(t.floats[i]):t.floats[i]}if(t.ints&&t.ints.length)for(n.ints=[],i=0;i<t.ints.length;++i)"number"==typeof t.ints[i]?n.ints[i]=e.longs===String?String(t.ints[i]):t.ints[i]:n.ints[i]=e.longs===String?o.Long.prototype.toString.call(t.ints[i]):e.longs===Number?new o.LongBits(t.ints[i].low>>>0,t.ints[i].high>>>0).toNumber():t.ints[i];if(t.strings&&t.strings.length)for(n.strings=[],i=0;i<t.strings.length;++i)n.strings[i]=e.bytes===String?o.base64.encode(t.strings[i],0,t.strings[i].length):e.bytes===Array?Array.prototype.slice.call(t.strings[i]):t.strings[i];if(t.tensors&&t.tensors.length)for(n.tensors=[],i=0;i<t.tensors.length;++i)n.tensors[i]=s.onnx.TensorProto.toObject(t.tensors[i],e);if(t.graphs&&t.graphs.length)for(n.graphs=[],i=0;i<t.graphs.length;++i)n.graphs[i]=s.onnx.GraphProto.toObject(t.graphs[i],e);if(null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),null!=t.tp&&t.hasOwnProperty("tp")&&(n.tp=s.onnx.TypeProto.toObject(t.tp,e)),t.typeProtos&&t.typeProtos.length)for(n.typeProtos=[],i=0;i<t.typeProtos.length;++i)n.typeProtos[i]=s.onnx.TypeProto.toObject(t.typeProtos[i],e);if(null!=t.type&&t.hasOwnProperty("type")&&(n.type=e.enums===String?void 0===s.onnx.AttributeProto.AttributeType[t.type]?t.type:s.onnx.AttributeProto.AttributeType[t.type]:t.type),null!=t.refAttrName&&t.hasOwnProperty("refAttrName")&&(n.refAttrName=t.refAttrName),null!=t.sparseTensor&&t.hasOwnProperty("sparseTensor")&&(n.sparseTensor=s.onnx.SparseTensorProto.toObject(t.sparseTensor,e)),t.sparseTensors&&t.sparseTensors.length)for(n.sparseTensors=[],i=0;i<t.sparseTensors.length;++i)n.sparseTensors[i]=s.onnx.SparseTensorProto.toObject(t.sparseTensors[i],e);return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.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}(),a.ValueInfoProto=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}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=i.create()),null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(10).string(t.name),null!=t.type&&Object.hasOwnProperty.call(t,"type")&&s.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.ValueInfoProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.name=t.string();break;case 2:i.type=s.onnx.TypeProto.decode(t,t.uint32());break;case 3:i.docString=t.string();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.isString(t.name))return"name: string expected";if(null!=t.type&&t.hasOwnProperty("type")){var e=s.onnx.TypeProto.verify(t.type);if(e)return"type."+e}return null!=t.docString&&t.hasOwnProperty("docString")&&!o.isString(t.docString)?"docString: string expected":null},t.fromObject=function(t){if(t instanceof s.onnx.ValueInfoProto)return t;var e=new s.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=s.onnx.TypeProto.fromObject(t.type)}return null!=t.docString&&(e.docString=String(t.docString)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.name="",n.type=null,n.docString=""),null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),null!=t.type&&t.hasOwnProperty("type")&&(n.type=s.onnx.TypeProto.toObject(t.type,e)),null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.ValueInfoProto"},t}(),a.NodeProto=function(){function t(t){if(this.input=[],this.output=[],this.attribute=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.input=o.emptyArray,t.prototype.output=o.emptyArray,t.prototype.name="",t.prototype.opType="",t.prototype.domain="",t.prototype.attribute=o.emptyArray,t.prototype.docString="",t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.input&&t.input.length)for(var n=0;n<t.input.length;++n)e.uint32(10).string(t.input[n]);if(null!=t.output&&t.output.length)for(n=0;n<t.output.length;++n)e.uint32(18).string(t.output[n]);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(n=0;n<t.attribute.length;++n)s.onnx.AttributeProto.encode(t.attribute[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.NodeProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.input&&i.input.length||(i.input=[]),i.input.push(t.string());break;case 2:i.output&&i.output.length||(i.output=[]),i.output.push(t.string());break;case 3:i.name=t.string();break;case 4:i.opType=t.string();break;case 7:i.domain=t.string();break;case 5:i.attribute&&i.attribute.length||(i.attribute=[]),i.attribute.push(s.onnx.AttributeProto.decode(t,t.uint32()));break;case 6:i.docString=t.string();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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(!o.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(e=0;e<t.output.length;++e)if(!o.isString(t.output[e]))return"output: string[] expected"}if(null!=t.name&&t.hasOwnProperty("name")&&!o.isString(t.name))return"name: string expected";if(null!=t.opType&&t.hasOwnProperty("opType")&&!o.isString(t.opType))return"opType: string expected";if(null!=t.domain&&t.hasOwnProperty("domain")&&!o.isString(t.domain))return"domain: string expected";if(null!=t.attribute&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(e=0;e<t.attribute.length;++e){var n=s.onnx.AttributeProto.verify(t.attribute[e]);if(n)return"attribute."+n}}return null!=t.docString&&t.hasOwnProperty("docString")&&!o.isString(t.docString)?"docString: string expected":null},t.fromObject=function(t){if(t instanceof s.onnx.NodeProto)return t;var e=new s.onnx.NodeProto;if(t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.NodeProto.input: array expected");e.input=[];for(var n=0;n<t.input.length;++n)e.input[n]=String(t.input[n])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.NodeProto.output: array expected");for(e.output=[],n=0;n<t.output.length;++n)e.output[n]=String(t.output[n])}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");for(e.attribute=[],n=0;n<t.attribute.length;++n){if("object"!=typeof t.attribute[n])throw TypeError(".onnx.NodeProto.attribute: object expected");e.attribute[n]=s.onnx.AttributeProto.fromObject(t.attribute[n])}}return null!=t.docString&&(e.docString=String(t.docString)),e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.input=[],n.output=[],n.attribute=[]),e.defaults&&(n.name="",n.opType="",n.docString="",n.domain=""),t.input&&t.input.length){n.input=[];for(var r=0;r<t.input.length;++r)n.input[r]=t.input[r]}if(t.output&&t.output.length)for(n.output=[],r=0;r<t.output.length;++r)n.output[r]=t.output[r];if(null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),null!=t.opType&&t.hasOwnProperty("opType")&&(n.opType=t.opType),t.attribute&&t.attribute.length)for(n.attribute=[],r=0;r<t.attribute.length;++r)n.attribute[r]=s.onnx.AttributeProto.toObject(t.attribute[r],e);return null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),null!=t.domain&&t.hasOwnProperty("domain")&&(n.domain=t.domain),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.NodeProto"},t}(),a.TrainingInfoProto=function(){function t(t){if(this.initializationBinding=[],this.updateBinding=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.initialization=null,t.prototype.algorithm=null,t.prototype.initializationBinding=o.emptyArray,t.prototype.updateBinding=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.initialization&&Object.hasOwnProperty.call(t,"initialization")&&s.onnx.GraphProto.encode(t.initialization,e.uint32(10).fork()).ldelim(),null!=t.algorithm&&Object.hasOwnProperty.call(t,"algorithm")&&s.onnx.GraphProto.encode(t.algorithm,e.uint32(18).fork()).ldelim(),null!=t.initializationBinding&&t.initializationBinding.length)for(var n=0;n<t.initializationBinding.length;++n)s.onnx.StringStringEntryProto.encode(t.initializationBinding[n],e.uint32(26).fork()).ldelim();if(null!=t.updateBinding&&t.updateBinding.length)for(n=0;n<t.updateBinding.length;++n)s.onnx.StringStringEntryProto.encode(t.updateBinding[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TrainingInfoProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.initialization=s.onnx.GraphProto.decode(t,t.uint32());break;case 2:i.algorithm=s.onnx.GraphProto.decode(t,t.uint32());break;case 3:i.initializationBinding&&i.initializationBinding.length||(i.initializationBinding=[]),i.initializationBinding.push(s.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 4:i.updateBinding&&i.updateBinding.length||(i.updateBinding=[]),i.updateBinding.push(s.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&(n=s.onnx.GraphProto.verify(t.initialization)))return"initialization."+n;if(null!=t.algorithm&&t.hasOwnProperty("algorithm")&&(n=s.onnx.GraphProto.verify(t.algorithm)))return"algorithm."+n;if(null!=t.initializationBinding&&t.hasOwnProperty("initializationBinding")){if(!Array.isArray(t.initializationBinding))return"initializationBinding: array expected";for(var e=0;e<t.initializationBinding.length;++e)if(n=s.onnx.StringStringEntryProto.verify(t.initializationBinding[e]))return"initializationBinding."+n}if(null!=t.updateBinding&&t.hasOwnProperty("updateBinding")){if(!Array.isArray(t.updateBinding))return"updateBinding: array expected";for(e=0;e<t.updateBinding.length;++e){var n;if(n=s.onnx.StringStringEntryProto.verify(t.updateBinding[e]))return"updateBinding."+n}}return null},t.fromObject=function(t){if(t instanceof s.onnx.TrainingInfoProto)return t;var e=new s.onnx.TrainingInfoProto;if(null!=t.initialization){if("object"!=typeof t.initialization)throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");e.initialization=s.onnx.GraphProto.fromObject(t.initialization)}if(null!=t.algorithm){if("object"!=typeof t.algorithm)throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");e.algorithm=s.onnx.GraphProto.fromObject(t.algorithm)}if(t.initializationBinding){if(!Array.isArray(t.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");e.initializationBinding=[];for(var n=0;n<t.initializationBinding.length;++n){if("object"!=typeof t.initializationBinding[n])throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");e.initializationBinding[n]=s.onnx.StringStringEntryProto.fromObject(t.initializationBinding[n])}}if(t.updateBinding){if(!Array.isArray(t.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");for(e.updateBinding=[],n=0;n<t.updateBinding.length;++n){if("object"!=typeof t.updateBinding[n])throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");e.updateBinding[n]=s.onnx.StringStringEntryProto.fromObject(t.updateBinding[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.initializationBinding=[],n.updateBinding=[]),e.defaults&&(n.initialization=null,n.algorithm=null),null!=t.initialization&&t.hasOwnProperty("initialization")&&(n.initialization=s.onnx.GraphProto.toObject(t.initialization,e)),null!=t.algorithm&&t.hasOwnProperty("algorithm")&&(n.algorithm=s.onnx.GraphProto.toObject(t.algorithm,e)),t.initializationBinding&&t.initializationBinding.length){n.initializationBinding=[];for(var r=0;r<t.initializationBinding.length;++r)n.initializationBinding[r]=s.onnx.StringStringEntryProto.toObject(t.initializationBinding[r],e)}if(t.updateBinding&&t.updateBinding.length)for(n.updateBinding=[],r=0;r<t.updateBinding.length;++r)n.updateBinding[r]=s.onnx.StringStringEntryProto.toObject(t.updateBinding[r],e);return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TrainingInfoProto"},t}(),a.ModelProto=function(){function t(t){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.irVersion=o.Long?o.Long.fromBits(0,0,!1):0,t.prototype.opsetImport=o.emptyArray,t.prototype.producerName="",t.prototype.producerVersion="",t.prototype.domain="",t.prototype.modelVersion=o.Long?o.Long.fromBits(0,0,!1):0,t.prototype.docString="",t.prototype.graph=null,t.prototype.metadataProps=o.emptyArray,t.prototype.trainingInfo=o.emptyArray,t.prototype.functions=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.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")&&s.onnx.GraphProto.encode(t.graph,e.uint32(58).fork()).ldelim(),null!=t.opsetImport&&t.opsetImport.length)for(var n=0;n<t.opsetImport.length;++n)s.onnx.OperatorSetIdProto.encode(t.opsetImport[n],e.uint32(66).fork()).ldelim();if(null!=t.metadataProps&&t.metadataProps.length)for(n=0;n<t.metadataProps.length;++n)s.onnx.StringStringEntryProto.encode(t.metadataProps[n],e.uint32(114).fork()).ldelim();if(null!=t.trainingInfo&&t.trainingInfo.length)for(n=0;n<t.trainingInfo.length;++n)s.onnx.TrainingInfoProto.encode(t.trainingInfo[n],e.uint32(162).fork()).ldelim();if(null!=t.functions&&t.functions.length)for(n=0;n<t.functions.length;++n)s.onnx.FunctionProto.encode(t.functions[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.ModelProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.irVersion=t.int64();break;case 8:i.opsetImport&&i.opsetImport.length||(i.opsetImport=[]),i.opsetImport.push(s.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 2:i.producerName=t.string();break;case 3:i.producerVersion=t.string();break;case 4:i.domain=t.string();break;case 5:i.modelVersion=t.int64();break;case 6:i.docString=t.string();break;case 7:i.graph=s.onnx.GraphProto.decode(t,t.uint32());break;case 14:i.metadataProps&&i.metadataProps.length||(i.metadataProps=[]),i.metadataProps.push(s.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 20:i.trainingInfo&&i.trainingInfo.length||(i.trainingInfo=[]),i.trainingInfo.push(s.onnx.TrainingInfoProto.decode(t,t.uint32()));break;case 25:i.functions&&i.functions.length||(i.functions=[]),i.functions.push(s.onnx.FunctionProto.decode(t,t.uint32()));break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.isInteger(t.irVersion)&&!(t.irVersion&&o.isInteger(t.irVersion.low)&&o.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)if(n=s.onnx.OperatorSetIdProto.verify(t.opsetImport[e]))return"opsetImport."+n}if(null!=t.producerName&&t.hasOwnProperty("producerName")&&!o.isString(t.producerName))return"producerName: string expected";if(null!=t.producerVersion&&t.hasOwnProperty("producerVersion")&&!o.isString(t.producerVersion))return"producerVersion: string expected";if(null!=t.domain&&t.hasOwnProperty("domain")&&!o.isString(t.domain))return"domain: string expected";if(null!=t.modelVersion&&t.hasOwnProperty("modelVersion")&&!o.isInteger(t.modelVersion)&&!(t.modelVersion&&o.isInteger(t.modelVersion.low)&&o.isInteger(t.modelVersion.high)))return"modelVersion: integer|Long expected";if(null!=t.docString&&t.hasOwnProperty("docString")&&!o.isString(t.docString))return"docString: string expected";if(null!=t.graph&&t.hasOwnProperty("graph")&&(n=s.onnx.GraphProto.verify(t.graph)))return"graph."+n;if(null!=t.metadataProps&&t.hasOwnProperty("metadataProps")){if(!Array.isArray(t.metadataProps))return"metadataProps: array expected";for(e=0;e<t.metadataProps.length;++e)if(n=s.onnx.StringStringEntryProto.verify(t.metadataProps[e]))return"metadataProps."+n}if(null!=t.trainingInfo&&t.hasOwnProperty("trainingInfo")){if(!Array.isArray(t.trainingInfo))return"trainingInfo: array expected";for(e=0;e<t.trainingInfo.length;++e)if(n=s.onnx.TrainingInfoProto.verify(t.trainingInfo[e]))return"trainingInfo."+n}if(null!=t.functions&&t.hasOwnProperty("functions")){if(!Array.isArray(t.functions))return"functions: array expected";for(e=0;e<t.functions.length;++e){var n;if(n=s.onnx.FunctionProto.verify(t.functions[e]))return"functions."+n}}return null},t.fromObject=function(t){if(t instanceof s.onnx.ModelProto)return t;var e=new s.onnx.ModelProto;if(null!=t.irVersion&&(o.Long?(e.irVersion=o.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 o.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 n=0;n<t.opsetImport.length;++n){if("object"!=typeof t.opsetImport[n])throw TypeError(".onnx.ModelProto.opsetImport: object expected");e.opsetImport[n]=s.onnx.OperatorSetIdProto.fromObject(t.opsetImport[n])}}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&&(o.Long?(e.modelVersion=o.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 o.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=s.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(e.metadataProps=[],n=0;n<t.metadataProps.length;++n){if("object"!=typeof t.metadataProps[n])throw TypeError(".onnx.ModelProto.metadataProps: object expected");e.metadataProps[n]=s.onnx.StringStringEntryProto.fromObject(t.metadataProps[n])}}if(t.trainingInfo){if(!Array.isArray(t.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");for(e.trainingInfo=[],n=0;n<t.trainingInfo.length;++n){if("object"!=typeof t.trainingInfo[n])throw TypeError(".onnx.ModelProto.trainingInfo: object expected");e.trainingInfo[n]=s.onnx.TrainingInfoProto.fromObject(t.trainingInfo[n])}}if(t.functions){if(!Array.isArray(t.functions))throw TypeError(".onnx.ModelProto.functions: array expected");for(e.functions=[],n=0;n<t.functions.length;++n){if("object"!=typeof t.functions[n])throw TypeError(".onnx.ModelProto.functions: object expected");e.functions[n]=s.onnx.FunctionProto.fromObject(t.functions[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.opsetImport=[],n.metadataProps=[],n.trainingInfo=[],n.functions=[]),e.defaults){if(o.Long){var r=new o.Long(0,0,!1);n.irVersion=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.irVersion=e.longs===String?"0":0;n.producerName="",n.producerVersion="",n.domain="",o.Long?(r=new o.Long(0,0,!1),n.modelVersion=e.longs===String?r.toString():e.longs===Number?r.toNumber():r):n.modelVersion=e.longs===String?"0":0,n.docString="",n.graph=null}if(null!=t.irVersion&&t.hasOwnProperty("irVersion")&&("number"==typeof t.irVersion?n.irVersion=e.longs===String?String(t.irVersion):t.irVersion:n.irVersion=e.longs===String?o.Long.prototype.toString.call(t.irVersion):e.longs===Number?new o.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber():t.irVersion),null!=t.producerName&&t.hasOwnProperty("producerName")&&(n.producerName=t.producerName),null!=t.producerVersion&&t.hasOwnProperty("producerVersion")&&(n.producerVersion=t.producerVersion),null!=t.domain&&t.hasOwnProperty("domain")&&(n.domain=t.domain),null!=t.modelVersion&&t.hasOwnProperty("modelVersion")&&("number"==typeof t.modelVersion?n.modelVersion=e.longs===String?String(t.modelVersion):t.modelVersion:n.modelVersion=e.longs===String?o.Long.prototype.toString.call(t.modelVersion):e.longs===Number?new o.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),null!=t.graph&&t.hasOwnProperty("graph")&&(n.graph=s.onnx.GraphProto.toObject(t.graph,e)),t.opsetImport&&t.opsetImport.length){n.opsetImport=[];for(var i=0;i<t.opsetImport.length;++i)n.opsetImport[i]=s.onnx.OperatorSetIdProto.toObject(t.opsetImport[i],e)}if(t.metadataProps&&t.metadataProps.length)for(n.metadataProps=[],i=0;i<t.metadataProps.length;++i)n.metadataProps[i]=s.onnx.StringStringEntryProto.toObject(t.metadataProps[i],e);if(t.trainingInfo&&t.trainingInfo.length)for(n.trainingInfo=[],i=0;i<t.trainingInfo.length;++i)n.trainingInfo[i]=s.onnx.TrainingInfoProto.toObject(t.trainingInfo[i],e);if(t.functions&&t.functions.length)for(n.functions=[],i=0;i<t.functions.length;++i)n.functions[i]=s.onnx.FunctionProto.toObject(t.functions[i],e);return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.ModelProto"},t}(),a.StringStringEntryProto=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.key="",t.prototype.value="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.StringStringEntryProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.key=t.string();break;case 2:i.value=t.string();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.key&&t.hasOwnProperty("key")&&!o.isString(t.key)?"key: string expected":null!=t.value&&t.hasOwnProperty("value")&&!o.isString(t.value)?"value: string expected":null},t.fromObject=function(t){if(t instanceof s.onnx.StringStringEntryProto)return t;var e=new s.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 n={};return e.defaults&&(n.key="",n.value=""),null!=t.key&&t.hasOwnProperty("key")&&(n.key=t.key),null!=t.value&&t.hasOwnProperty("value")&&(n.value=t.value),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.StringStringEntryProto"},t}(),a.TensorAnnotation=function(){function t(t){if(this.quantParameterTensorNames=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.tensorName="",t.prototype.quantParameterTensorNames=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.tensorName&&Object.hasOwnProperty.call(t,"tensorName")&&e.uint32(10).string(t.tensorName),null!=t.quantParameterTensorNames&&t.quantParameterTensorNames.length)for(var n=0;n<t.quantParameterTensorNames.length;++n)s.onnx.StringStringEntryProto.encode(t.quantParameterTensorNames[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TensorAnnotation;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.tensorName=t.string();break;case 2:i.quantParameterTensorNames&&i.quantParameterTensorNames.length||(i.quantParameterTensorNames=[]),i.quantParameterTensorNames.push(s.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.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 n=s.onnx.StringStringEntryProto.verify(t.quantParameterTensorNames[e]);if(n)return"quantParameterTensorNames."+n}}return null},t.fromObject=function(t){if(t instanceof s.onnx.TensorAnnotation)return t;var e=new s.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 n=0;n<t.quantParameterTensorNames.length;++n){if("object"!=typeof t.quantParameterTensorNames[n])throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");e.quantParameterTensorNames[n]=s.onnx.StringStringEntryProto.fromObject(t.quantParameterTensorNames[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.quantParameterTensorNames=[]),e.defaults&&(n.tensorName=""),null!=t.tensorName&&t.hasOwnProperty("tensorName")&&(n.tensorName=t.tensorName),t.quantParameterTensorNames&&t.quantParameterTensorNames.length){n.quantParameterTensorNames=[];for(var r=0;r<t.quantParameterTensorNames.length;++r)n.quantParameterTensorNames[r]=s.onnx.StringStringEntryProto.toObject(t.quantParameterTensorNames[r],e)}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorAnnotation"},t}(),a.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),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.node=o.emptyArray,t.prototype.name="",t.prototype.initializer=o.emptyArray,t.prototype.sparseInitializer=o.emptyArray,t.prototype.docString="",t.prototype.input=o.emptyArray,t.prototype.output=o.emptyArray,t.prototype.valueInfo=o.emptyArray,t.prototype.quantizationAnnotation=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.node&&t.node.length)for(var n=0;n<t.node.length;++n)s.onnx.NodeProto.encode(t.node[n],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(n=0;n<t.initializer.length;++n)s.onnx.TensorProto.encode(t.initializer[n],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(n=0;n<t.input.length;++n)s.onnx.ValueInfoProto.encode(t.input[n],e.uint32(90).fork()).ldelim();if(null!=t.output&&t.output.length)for(n=0;n<t.output.length;++n)s.onnx.ValueInfoProto.encode(t.output[n],e.uint32(98).fork()).ldelim();if(null!=t.valueInfo&&t.valueInfo.length)for(n=0;n<t.valueInfo.length;++n)s.onnx.ValueInfoProto.encode(t.valueInfo[n],e.uint32(106).fork()).ldelim();if(null!=t.quantizationAnnotation&&t.quantizationAnnotation.length)for(n=0;n<t.quantizationAnnotation.length;++n)s.onnx.TensorAnnotation.encode(t.quantizationAnnotation[n],e.uint32(114).fork()).ldelim();if(null!=t.sparseInitializer&&t.sparseInitializer.length)for(n=0;n<t.sparseInitializer.length;++n)s.onnx.SparseTensorProto.encode(t.sparseInitializer[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.GraphProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.node&&i.node.length||(i.node=[]),i.node.push(s.onnx.NodeProto.decode(t,t.uint32()));break;case 2:i.name=t.string();break;case 5:i.initializer&&i.initializer.length||(i.initializer=[]),i.initializer.push(s.onnx.TensorProto.decode(t,t.uint32()));break;case 15:i.sparseInitializer&&i.sparseInitializer.length||(i.sparseInitializer=[]),i.sparseInitializer.push(s.onnx.SparseTensorProto.decode(t,t.uint32()));break;case 10:i.docString=t.string();break;case 11:i.input&&i.input.length||(i.input=[]),i.input.push(s.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 12:i.output&&i.output.length||(i.output=[]),i.output.push(s.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 13:i.valueInfo&&i.valueInfo.length||(i.valueInfo=[]),i.valueInfo.push(s.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 14:i.quantizationAnnotation&&i.quantizationAnnotation.length||(i.quantizationAnnotation=[]),i.quantizationAnnotation.push(s.onnx.TensorAnnotation.decode(t,t.uint32()));break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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)if(n=s.onnx.NodeProto.verify(t.node[e]))return"node."+n}if(null!=t.name&&t.hasOwnProperty("name")&&!o.isString(t.name))return"name: string expected";if(null!=t.initializer&&t.hasOwnProperty("initializer")){if(!Array.isArray(t.initializer))return"initializer: array expected";for(e=0;e<t.initializer.length;++e)if(n=s.onnx.TensorProto.verify(t.initializer[e]))return"initializer."+n}if(null!=t.sparseInitializer&&t.hasOwnProperty("sparseInitializer")){if(!Array.isArray(t.sparseInitializer))return"sparseInitializer: array expected";for(e=0;e<t.sparseInitializer.length;++e)if(n=s.onnx.SparseTensorProto.verify(t.sparseInitializer[e]))return"sparseInitializer."+n}if(null!=t.docString&&t.hasOwnProperty("docString")&&!o.isString(t.docString))return"docString: string expected";if(null!=t.input&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(e=0;e<t.input.length;++e)if(n=s.onnx.ValueInfoProto.verify(t.input[e]))return"input."+n}if(null!=t.output&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(e=0;e<t.output.length;++e)if(n=s.onnx.ValueInfoProto.verify(t.output[e]))return"output."+n}if(null!=t.valueInfo&&t.hasOwnProperty("valueInfo")){if(!Array.isArray(t.valueInfo))return"valueInfo: array expected";for(e=0;e<t.valueInfo.length;++e)if(n=s.onnx.ValueInfoProto.verify(t.valueInfo[e]))return"valueInfo."+n}if(null!=t.quantizationAnnotation&&t.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(t.quantizationAnnotation))return"quantizationAnnotation: array expected";for(e=0;e<t.quantizationAnnotation.length;++e){var n;if(n=s.onnx.TensorAnnotation.verify(t.quantizationAnnotation[e]))return"quantizationAnnotation."+n}}return null},t.fromObject=function(t){if(t instanceof s.onnx.GraphProto)return t;var e=new s.onnx.GraphProto;if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.GraphProto.node: array expected");e.node=[];for(var n=0;n<t.node.length;++n){if("object"!=typeof t.node[n])throw TypeError(".onnx.GraphProto.node: object expected");e.node[n]=s.onnx.NodeProto.fromObject(t.node[n])}}if(null!=t.name&&(e.name=String(t.name)),t.initializer){if(!Array.isArray(t.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");for(e.initializer=[],n=0;n<t.initializer.length;++n){if("object"!=typeof t.initializer[n])throw TypeError(".onnx.GraphProto.initializer: object expected");e.initializer[n]=s.onnx.TensorProto.fromObject(t.initializer[n])}}if(t.sparseInitializer){if(!Array.isArray(t.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");for(e.sparseInitializer=[],n=0;n<t.sparseInitializer.length;++n){if("object"!=typeof t.sparseInitializer[n])throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");e.sparseInitializer[n]=s.onnx.SparseTensorProto.fromObject(t.sparseInitializer[n])}}if(null!=t.docString&&(e.docString=String(t.docString)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.GraphProto.input: array expected");for(e.input=[],n=0;n<t.input.length;++n){if("object"!=typeof t.input[n])throw TypeError(".onnx.GraphProto.input: object expected");e.input[n]=s.onnx.ValueInfoProto.fromObject(t.input[n])}}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.GraphProto.output: array expected");for(e.output=[],n=0;n<t.output.length;++n){if("object"!=typeof t.output[n])throw TypeError(".onnx.GraphProto.output: object expected");e.output[n]=s.onnx.ValueInfoProto.fromObject(t.output[n])}}if(t.valueInfo){if(!Array.isArray(t.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");for(e.valueInfo=[],n=0;n<t.valueInfo.length;++n){if("object"!=typeof t.valueInfo[n])throw TypeError(".onnx.GraphProto.valueInfo: object expected");e.valueInfo[n]=s.onnx.ValueInfoProto.fromObject(t.valueInfo[n])}}if(t.quantizationAnnotation){if(!Array.isArray(t.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");for(e.quantizationAnnotation=[],n=0;n<t.quantizationAnnotation.length;++n){if("object"!=typeof t.quantizationAnnotation[n])throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");e.quantizationAnnotation[n]=s.onnx.TensorAnnotation.fromObject(t.quantizationAnnotation[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.node=[],n.initializer=[],n.input=[],n.output=[],n.valueInfo=[],n.quantizationAnnotation=[],n.sparseInitializer=[]),e.defaults&&(n.name="",n.docString=""),t.node&&t.node.length){n.node=[];for(var r=0;r<t.node.length;++r)n.node[r]=s.onnx.NodeProto.toObject(t.node[r],e)}if(null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),t.initializer&&t.initializer.length)for(n.initializer=[],r=0;r<t.initializer.length;++r)n.initializer[r]=s.onnx.TensorProto.toObject(t.initializer[r],e);if(null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.input&&t.input.length)for(n.input=[],r=0;r<t.input.length;++r)n.input[r]=s.onnx.ValueInfoProto.toObject(t.input[r],e);if(t.output&&t.output.length)for(n.output=[],r=0;r<t.output.length;++r)n.output[r]=s.onnx.ValueInfoProto.toObject(t.output[r],e);if(t.valueInfo&&t.valueInfo.length)for(n.valueInfo=[],r=0;r<t.valueInfo.length;++r)n.valueInfo[r]=s.onnx.ValueInfoProto.toObject(t.valueInfo[r],e);if(t.quantizationAnnotation&&t.quantizationAnnotation.length)for(n.quantizationAnnotation=[],r=0;r<t.quantizationAnnotation.length;++r)n.quantizationAnnotation[r]=s.onnx.TensorAnnotation.toObject(t.quantizationAnnotation[r],e);if(t.sparseInitializer&&t.sparseInitializer.length)for(n.sparseInitializer=[],r=0;r<t.sparseInitializer.length;++r)n.sparseInitializer[r]=s.onnx.SparseTensorProto.toObject(t.sparseInitializer[r],e);return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.GraphProto"},t}(),a.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),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.dims=o.emptyArray,t.prototype.dataType=0,t.prototype.segment=null,t.prototype.floatData=o.emptyArray,t.prototype.int32Data=o.emptyArray,t.prototype.stringData=o.emptyArray,t.prototype.int64Data=o.emptyArray,t.prototype.name="",t.prototype.docString="",t.prototype.rawData=o.newBuffer([]),t.prototype.externalData=o.emptyArray,t.prototype.dataLocation=0,t.prototype.doubleData=o.emptyArray,t.prototype.uint64Data=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.dims&&t.dims.length){e.uint32(10).fork();for(var n=0;n<t.dims.length;++n)e.int64(t.dims[n]);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")&&s.onnx.TensorProto.Segment.encode(t.segment,e.uint32(26).fork()).ldelim(),null!=t.floatData&&t.floatData.length){for(e.uint32(34).fork(),n=0;n<t.floatData.length;++n)e.float(t.floatData[n]);e.ldelim()}if(null!=t.int32Data&&t.int32Data.length){for(e.uint32(42).fork(),n=0;n<t.int32Data.length;++n)e.int32(t.int32Data[n]);e.ldelim()}if(null!=t.stringData&&t.stringData.length)for(n=0;n<t.stringData.length;++n)e.uint32(50).bytes(t.stringData[n]);if(null!=t.int64Data&&t.int64Data.length){for(e.uint32(58).fork(),n=0;n<t.int64Data.length;++n)e.int64(t.int64Data[n]);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){for(e.uint32(82).fork(),n=0;n<t.doubleData.length;++n)e.double(t.doubleData[n]);e.ldelim()}if(null!=t.uint64Data&&t.uint64Data.length){for(e.uint32(90).fork(),n=0;n<t.uint64Data.length;++n)e.uint64(t.uint64Data[n]);e.ldelim()}if(null!=t.docString&&Object.hasOwnProperty.call(t,"docString")&&e.uint32(98).string(t.docString),null!=t.externalData&&t.externalData.length)for(n=0;n<t.externalData.length;++n)s.onnx.StringStringEntryProto.encode(t.externalData[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TensorProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:if(i.dims&&i.dims.length||(i.dims=[]),2==(7&o))for(var a=t.uint32()+t.pos;t.pos<a;)i.dims.push(t.int64());else i.dims.push(t.int64());break;case 2:i.dataType=t.int32();break;case 3:i.segment=s.onnx.TensorProto.Segment.decode(t,t.uint32());break;case 4:if(i.floatData&&i.floatData.length||(i.floatData=[]),2==(7&o))for(a=t.uint32()+t.pos;t.pos<a;)i.floatData.push(t.float());else i.floatData.push(t.float());break;case 5:if(i.int32Data&&i.int32Data.length||(i.int32Data=[]),2==(7&o))for(a=t.uint32()+t.pos;t.pos<a;)i.int32Data.push(t.int32());else i.int32Data.push(t.int32());break;case 6:i.stringData&&i.stringData.length||(i.stringData=[]),i.stringData.push(t.bytes());break;case 7:if(i.int64Data&&i.int64Data.length||(i.int64Data=[]),2==(7&o))for(a=t.uint32()+t.pos;t.pos<a;)i.int64Data.push(t.int64());else i.int64Data.push(t.int64());break;case 8:i.name=t.string();break;case 12:i.docString=t.string();break;case 9:i.rawData=t.bytes();break;case 13:i.externalData&&i.externalData.length||(i.externalData=[]),i.externalData.push(s.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 14:i.dataLocation=t.int32();break;case 10:if(i.doubleData&&i.doubleData.length||(i.doubleData=[]),2==(7&o))for(a=t.uint32()+t.pos;t.pos<a;)i.doubleData.push(t.double());else i.doubleData.push(t.double());break;case 11:if(i.uint64Data&&i.uint64Data.length||(i.uint64Data=[]),2==(7&o))for(a=t.uint32()+t.pos;t.pos<a;)i.uint64Data.push(t.uint64());else i.uint64Data.push(t.uint64());break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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(!(o.isInteger(t.dims[e])||t.dims[e]&&o.isInteger(t.dims[e].low)&&o.isInteger(t.dims[e].high)))return"dims: integer|Long[] expected"}if(null!=t.dataType&&t.hasOwnProperty("dataType")&&!o.isInteger(t.dataType))return"dataType: integer expected";if(null!=t.segment&&t.hasOwnProperty("segment")&&(n=s.onnx.TensorProto.Segment.verify(t.segment)))return"segment."+n;if(null!=t.floatData&&t.hasOwnProperty("floatData")){if(!Array.isArray(t.floatData))return"floatData: array expected";for(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(e=0;e<t.int32Data.length;++e)if(!o.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(e=0;e<t.stringData.length;++e)if(!(t.stringData[e]&&"number"==typeof t.stringData[e].length||o.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(e=0;e<t.int64Data.length;++e)if(!(o.isInteger(t.int64Data[e])||t.int64Data[e]&&o.isInteger(t.int64Data[e].low)&&o.isInteger(t.int64Data[e].high)))return"int64Data: integer|Long[] expected"}if(null!=t.name&&t.hasOwnProperty("name")&&!o.isString(t.name))return"name: string expected";if(null!=t.docString&&t.hasOwnProperty("docString")&&!o.isString(t.docString))return"docString: string expected";if(null!=t.rawData&&t.hasOwnProperty("rawData")&&!(t.rawData&&"number"==typeof t.rawData.length||o.isString(t.rawData)))return"rawData: buffer expected";if(null!=t.externalData&&t.hasOwnProperty("externalData")){if(!Array.isArray(t.externalData))return"externalData: array expected";for(e=0;e<t.externalData.length;++e){var n;if(n=s.onnx.StringStringEntryProto.verify(t.externalData[e]))return"externalData."+n}}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(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(e=0;e<t.uint64Data.length;++e)if(!(o.isInteger(t.uint64Data[e])||t.uint64Data[e]&&o.isInteger(t.uint64Data[e].low)&&o.isInteger(t.uint64Data[e].high)))return"uint64Data: integer|Long[] expected"}return null},t.fromObject=function(t){if(t instanceof s.onnx.TensorProto)return t;var e=new s.onnx.TensorProto;if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.TensorProto.dims: array expected");e.dims=[];for(var n=0;n<t.dims.length;++n)o.Long?(e.dims[n]=o.Long.fromValue(t.dims[n])).unsigned=!1:"string"==typeof t.dims[n]?e.dims[n]=parseInt(t.dims[n],10):"number"==typeof t.dims[n]?e.dims[n]=t.dims[n]:"object"==typeof t.dims[n]&&(e.dims[n]=new o.LongBits(t.dims[n].low>>>0,t.dims[n].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=s.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(e.floatData=[],n=0;n<t.floatData.length;++n)e.floatData[n]=Number(t.floatData[n])}if(t.int32Data){if(!Array.isArray(t.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");for(e.int32Data=[],n=0;n<t.int32Data.length;++n)e.int32Data[n]=0|t.int32Data[n]}if(t.stringData){if(!Array.isArray(t.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");for(e.stringData=[],n=0;n<t.stringData.length;++n)"string"==typeof t.stringData[n]?o.base64.decode(t.stringData[n],e.stringData[n]=o.newBuffer(o.base64.length(t.stringData[n])),0):t.stringData[n].length>=0&&(e.stringData[n]=t.stringData[n])}if(t.int64Data){if(!Array.isArray(t.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");for(e.int64Data=[],n=0;n<t.int64Data.length;++n)o.Long?(e.int64Data[n]=o.Long.fromValue(t.int64Data[n])).unsigned=!1:"string"==typeof t.int64Data[n]?e.int64Data[n]=parseInt(t.int64Data[n],10):"number"==typeof t.int64Data[n]?e.int64Data[n]=t.int64Data[n]:"object"==typeof t.int64Data[n]&&(e.int64Data[n]=new o.LongBits(t.int64Data[n].low>>>0,t.int64Data[n].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?o.base64.decode(t.rawData,e.rawData=o.newBuffer(o.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");for(e.externalData=[],n=0;n<t.externalData.length;++n){if("object"!=typeof t.externalData[n])throw TypeError(".onnx.TensorProto.externalData: object expected");e.externalData[n]=s.onnx.StringStringEntryProto.fromObject(t.externalData[n])}}switch(t.dataLocation){default:if("number"==typeof t.dataLocation){e.dataLocation=t.dataLocation;break}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");for(e.doubleData=[],n=0;n<t.doubleData.length;++n)e.doubleData[n]=Number(t.doubleData[n])}if(t.uint64Data){if(!Array.isArray(t.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");for(e.uint64Data=[],n=0;n<t.uint64Data.length;++n)o.Long?(e.uint64Data[n]=o.Long.fromValue(t.uint64Data[n])).unsigned=!0:"string"==typeof t.uint64Data[n]?e.uint64Data[n]=parseInt(t.uint64Data[n],10):"number"==typeof t.uint64Data[n]?e.uint64Data[n]=t.uint64Data[n]:"object"==typeof t.uint64Data[n]&&(e.uint64Data[n]=new o.LongBits(t.uint64Data[n].low>>>0,t.uint64Data[n].high>>>0).toNumber(!0))}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.dims=[],n.floatData=[],n.int32Data=[],n.stringData=[],n.int64Data=[],n.doubleData=[],n.uint64Data=[],n.externalData=[]),e.defaults&&(n.dataType=0,n.segment=null,n.name="",e.bytes===String?n.rawData="":(n.rawData=[],e.bytes!==Array&&(n.rawData=o.newBuffer(n.rawData))),n.docString="",n.dataLocation=e.enums===String?"DEFAULT":0),t.dims&&t.dims.length){n.dims=[];for(var r=0;r<t.dims.length;++r)"number"==typeof t.dims[r]?n.dims[r]=e.longs===String?String(t.dims[r]):t.dims[r]:n.dims[r]=e.longs===String?o.Long.prototype.toString.call(t.dims[r]):e.longs===Number?new o.LongBits(t.dims[r].low>>>0,t.dims[r].high>>>0).toNumber():t.dims[r]}if(null!=t.dataType&&t.hasOwnProperty("dataType")&&(n.dataType=t.dataType),null!=t.segment&&t.hasOwnProperty("segment")&&(n.segment=s.onnx.TensorProto.Segment.toObject(t.segment,e)),t.floatData&&t.floatData.length)for(n.floatData=[],r=0;r<t.floatData.length;++r)n.floatData[r]=e.json&&!isFinite(t.floatData[r])?String(t.floatData[r]):t.floatData[r];if(t.int32Data&&t.int32Data.length)for(n.int32Data=[],r=0;r<t.int32Data.length;++r)n.int32Data[r]=t.int32Data[r];if(t.stringData&&t.stringData.length)for(n.stringData=[],r=0;r<t.stringData.length;++r)n.stringData[r]=e.bytes===String?o.base64.encode(t.stringData[r],0,t.stringData[r].length):e.bytes===Array?Array.prototype.slice.call(t.stringData[r]):t.stringData[r];if(t.int64Data&&t.int64Data.length)for(n.int64Data=[],r=0;r<t.int64Data.length;++r)"number"==typeof t.int64Data[r]?n.int64Data[r]=e.longs===String?String(t.int64Data[r]):t.int64Data[r]:n.int64Data[r]=e.longs===String?o.Long.prototype.toString.call(t.int64Data[r]):e.longs===Number?new o.LongBits(t.int64Data[r].low>>>0,t.int64Data[r].high>>>0).toNumber():t.int64Data[r];if(null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),null!=t.rawData&&t.hasOwnProperty("rawData")&&(n.rawData=e.bytes===String?o.base64.encode(t.rawData,0,t.rawData.length):e.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length)for(n.doubleData=[],r=0;r<t.doubleData.length;++r)n.doubleData[r]=e.json&&!isFinite(t.doubleData[r])?String(t.doubleData[r]):t.doubleData[r];if(t.uint64Data&&t.uint64Data.length)for(n.uint64Data=[],r=0;r<t.uint64Data.length;++r)"number"==typeof t.uint64Data[r]?n.uint64Data[r]=e.longs===String?String(t.uint64Data[r]):t.uint64Data[r]:n.uint64Data[r]=e.longs===String?o.Long.prototype.toString.call(t.uint64Data[r]):e.longs===Number?new o.LongBits(t.uint64Data[r].low>>>0,t.uint64Data[r].high>>>0).toNumber(!0):t.uint64Data[r];if(null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.externalData&&t.externalData.length)for(n.externalData=[],r=0;r<t.externalData.length;++r)n.externalData[r]=s.onnx.StringStringEntryProto.toObject(t.externalData[r],e);return null!=t.dataLocation&&t.hasOwnProperty("dataLocation")&&(n.dataLocation=e.enums===String?void 0===s.onnx.TensorProto.DataLocation[t.dataLocation]?t.dataLocation:s.onnx.TensorProto.DataLocation[t.dataLocation]:t.dataLocation),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.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),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.begin=o.Long?o.Long.fromBits(0,0,!1):0,t.prototype.end=o.Long?o.Long.fromBits(0,0,!1):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TensorProto.Segment;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.begin=t.int64();break;case 2:i.end=t.int64();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null==t.begin||!t.hasOwnProperty("begin")||o.isInteger(t.begin)||t.begin&&o.isInteger(t.begin.low)&&o.isInteger(t.begin.high)?null==t.end||!t.hasOwnProperty("end")||o.isInteger(t.end)||t.end&&o.isInteger(t.end.low)&&o.isInteger(t.end.high)?null:"end: integer|Long expected":"begin: integer|Long expected"},t.fromObject=function(t){if(t instanceof s.onnx.TensorProto.Segment)return t;var e=new s.onnx.TensorProto.Segment;return null!=t.begin&&(o.Long?(e.begin=o.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 o.LongBits(t.begin.low>>>0,t.begin.high>>>0).toNumber())),null!=t.end&&(o.Long?(e.end=o.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 o.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults){if(o.Long){var r=new o.Long(0,0,!1);n.begin=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.begin=e.longs===String?"0":0;o.Long?(r=new o.Long(0,0,!1),n.end=e.longs===String?r.toString():e.longs===Number?r.toNumber():r):n.end=e.longs===String?"0":0}return null!=t.begin&&t.hasOwnProperty("begin")&&("number"==typeof t.begin?n.begin=e.longs===String?String(t.begin):t.begin:n.begin=e.longs===String?o.Long.prototype.toString.call(t.begin):e.longs===Number?new o.LongBits(t.begin.low>>>0,t.begin.high>>>0).toNumber():t.begin),null!=t.end&&t.hasOwnProperty("end")&&("number"==typeof t.end?n.end=e.longs===String?String(t.end):t.end:n.end=e.longs===String?o.Long.prototype.toString.call(t.end):e.longs===Number?new o.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber():t.end),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.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}(),a.SparseTensorProto=function(){function t(t){if(this.dims=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.values=null,t.prototype.indices=null,t.prototype.dims=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.values&&Object.hasOwnProperty.call(t,"values")&&s.onnx.TensorProto.encode(t.values,e.uint32(10).fork()).ldelim(),null!=t.indices&&Object.hasOwnProperty.call(t,"indices")&&s.onnx.TensorProto.encode(t.indices,e.uint32(18).fork()).ldelim(),null!=t.dims&&t.dims.length){e.uint32(26).fork();for(var n=0;n<t.dims.length;++n)e.int64(t.dims[n]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.SparseTensorProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.values=s.onnx.TensorProto.decode(t,t.uint32());break;case 2:i.indices=s.onnx.TensorProto.decode(t,t.uint32());break;case 3:if(i.dims&&i.dims.length||(i.dims=[]),2==(7&o))for(var a=t.uint32()+t.pos;t.pos<a;)i.dims.push(t.int64());else i.dims.push(t.int64());break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e;if(null!=t.values&&t.hasOwnProperty("values")&&(e=s.onnx.TensorProto.verify(t.values)))return"values."+e;if(null!=t.indices&&t.hasOwnProperty("indices")&&(e=s.onnx.TensorProto.verify(t.indices)))return"indices."+e;if(null!=t.dims&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var n=0;n<t.dims.length;++n)if(!(o.isInteger(t.dims[n])||t.dims[n]&&o.isInteger(t.dims[n].low)&&o.isInteger(t.dims[n].high)))return"dims: integer|Long[] expected"}return null},t.fromObject=function(t){if(t instanceof s.onnx.SparseTensorProto)return t;var e=new s.onnx.SparseTensorProto;if(null!=t.values){if("object"!=typeof t.values)throw TypeError(".onnx.SparseTensorProto.values: object expected");e.values=s.onnx.TensorProto.fromObject(t.values)}if(null!=t.indices){if("object"!=typeof t.indices)throw TypeError(".onnx.SparseTensorProto.indices: object expected");e.indices=s.onnx.TensorProto.fromObject(t.indices)}if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");e.dims=[];for(var n=0;n<t.dims.length;++n)o.Long?(e.dims[n]=o.Long.fromValue(t.dims[n])).unsigned=!1:"string"==typeof t.dims[n]?e.dims[n]=parseInt(t.dims[n],10):"number"==typeof t.dims[n]?e.dims[n]=t.dims[n]:"object"==typeof t.dims[n]&&(e.dims[n]=new o.LongBits(t.dims[n].low>>>0,t.dims[n].high>>>0).toNumber())}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.dims=[]),e.defaults&&(n.values=null,n.indices=null),null!=t.values&&t.hasOwnProperty("values")&&(n.values=s.onnx.TensorProto.toObject(t.values,e)),null!=t.indices&&t.hasOwnProperty("indices")&&(n.indices=s.onnx.TensorProto.toObject(t.indices,e)),t.dims&&t.dims.length){n.dims=[];for(var r=0;r<t.dims.length;++r)"number"==typeof t.dims[r]?n.dims[r]=e.longs===String?String(t.dims[r]):t.dims[r]:n.dims[r]=e.longs===String?o.Long.prototype.toString.call(t.dims[r]):e.longs===Number?new o.LongBits(t.dims[r].low>>>0,t.dims[r].high>>>0).toNumber():t.dims[r]}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.SparseTensorProto"},t}(),a.TensorShapeProto=function(){function t(t){if(this.dim=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.dim=o.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.dim&&t.dim.length)for(var n=0;n<t.dim.length;++n)s.onnx.TensorShapeProto.Dimension.encode(t.dim[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TensorShapeProto;t.pos<n;){var o=t.uint32();o>>>3==1?(i.dim&&i.dim.length||(i.dim=[]),i.dim.push(s.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()))):t.skipType(7&o)}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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 n=s.onnx.TensorShapeProto.Dimension.verify(t.dim[e]);if(n)return"dim."+n}}return null},t.fromObject=function(t){if(t instanceof s.onnx.TensorShapeProto)return t;var e=new s.onnx.TensorShapeProto;if(t.dim){if(!Array.isArray(t.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");e.dim=[];for(var n=0;n<t.dim.length;++n){if("object"!=typeof t.dim[n])throw TypeError(".onnx.TensorShapeProto.dim: object expected");e.dim[n]=s.onnx.TensorShapeProto.Dimension.fromObject(t.dim[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.dim=[]),t.dim&&t.dim.length){n.dim=[];for(var r=0;r<t.dim.length;++r)n.dim[r]=s.onnx.TensorShapeProto.Dimension.toObject(t.dim[r],e)}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorShapeProto"},t.Dimension=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var e;return t.prototype.dimValue=null,t.prototype.dimParam=null,t.prototype.denotation="",Object.defineProperty(t.prototype,"value",{get:o.oneOfGetter(e=["dimValue","dimParam"]),set:o.oneOfSetter(e)}),t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.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},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TensorShapeProto.Dimension;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.dimValue=t.int64();break;case 2:i.dimParam=t.string();break;case 3:i.denotation=t.string();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.dimValue&&t.hasOwnProperty("dimValue")&&(e.value=1,!(o.isInteger(t.dimValue)||t.dimValue&&o.isInteger(t.dimValue.low)&&o.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,!o.isString(t.dimParam))return"dimParam: string expected"}return null!=t.denotation&&t.hasOwnProperty("denotation")&&!o.isString(t.denotation)?"denotation: string expected":null},t.fromObject=function(t){if(t instanceof s.onnx.TensorShapeProto.Dimension)return t;var e=new s.onnx.TensorShapeProto.Dimension;return null!=t.dimValue&&(o.Long?(e.dimValue=o.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 o.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},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.denotation=""),null!=t.dimValue&&t.hasOwnProperty("dimValue")&&("number"==typeof t.dimValue?n.dimValue=e.longs===String?String(t.dimValue):t.dimValue:n.dimValue=e.longs===String?o.Long.prototype.toString.call(t.dimValue):e.longs===Number?new o.LongBits(t.dimValue.low>>>0,t.dimValue.high>>>0).toNumber():t.dimValue,e.oneofs&&(n.value="dimValue")),null!=t.dimParam&&t.hasOwnProperty("dimParam")&&(n.dimParam=t.dimParam,e.oneofs&&(n.value="dimParam")),null!=t.denotation&&t.hasOwnProperty("denotation")&&(n.denotation=t.denotation),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TensorShapeProto.Dimension"},t}(),t}(),a.TypeProto=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var e;return t.prototype.tensorType=null,t.prototype.sequenceType=null,t.prototype.mapType=null,t.prototype.optionalType=null,t.prototype.sparseTensorType=null,t.prototype.denotation="",Object.defineProperty(t.prototype,"value",{get:o.oneOfGetter(e=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:o.oneOfSetter(e)}),t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.tensorType&&Object.hasOwnProperty.call(t,"tensorType")&&s.onnx.TypeProto.Tensor.encode(t.tensorType,e.uint32(10).fork()).ldelim(),null!=t.sequenceType&&Object.hasOwnProperty.call(t,"sequenceType")&&s.onnx.TypeProto.Sequence.encode(t.sequenceType,e.uint32(34).fork()).ldelim(),null!=t.mapType&&Object.hasOwnProperty.call(t,"mapT
6ype")&&s.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")&&s.onnx.TypeProto.SparseTensor.encode(t.sparseTensorType,e.uint32(66).fork()).ldelim(),null!=t.optionalType&&Object.hasOwnProperty.call(t,"optionalType")&&s.onnx.TypeProto.Optional.encode(t.optionalType,e.uint32(74).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TypeProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.tensorType=s.onnx.TypeProto.Tensor.decode(t,t.uint32());break;case 4:i.sequenceType=s.onnx.TypeProto.Sequence.decode(t,t.uint32());break;case 5:i.mapType=s.onnx.TypeProto.Map.decode(t,t.uint32());break;case 9:i.optionalType=s.onnx.TypeProto.Optional.decode(t,t.uint32());break;case 8:i.sparseTensorType=s.onnx.TypeProto.SparseTensor.decode(t,t.uint32());break;case 6:i.denotation=t.string();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";var e={};if(null!=t.tensorType&&t.hasOwnProperty("tensorType")&&(e.value=1,n=s.onnx.TypeProto.Tensor.verify(t.tensorType)))return"tensorType."+n;if(null!=t.sequenceType&&t.hasOwnProperty("sequenceType")){if(1===e.value)return"value: multiple values";if(e.value=1,n=s.onnx.TypeProto.Sequence.verify(t.sequenceType))return"sequenceType."+n}if(null!=t.mapType&&t.hasOwnProperty("mapType")){if(1===e.value)return"value: multiple values";if(e.value=1,n=s.onnx.TypeProto.Map.verify(t.mapType))return"mapType."+n}if(null!=t.optionalType&&t.hasOwnProperty("optionalType")){if(1===e.value)return"value: multiple values";if(e.value=1,n=s.onnx.TypeProto.Optional.verify(t.optionalType))return"optionalType."+n}if(null!=t.sparseTensorType&&t.hasOwnProperty("sparseTensorType")){if(1===e.value)return"value: multiple values";var n;if(e.value=1,n=s.onnx.TypeProto.SparseTensor.verify(t.sparseTensorType))return"sparseTensorType."+n}return null!=t.denotation&&t.hasOwnProperty("denotation")&&!o.isString(t.denotation)?"denotation: string expected":null},t.fromObject=function(t){if(t instanceof s.onnx.TypeProto)return t;var e=new s.onnx.TypeProto;if(null!=t.tensorType){if("object"!=typeof t.tensorType)throw TypeError(".onnx.TypeProto.tensorType: object expected");e.tensorType=s.onnx.TypeProto.Tensor.fromObject(t.tensorType)}if(null!=t.sequenceType){if("object"!=typeof t.sequenceType)throw TypeError(".onnx.TypeProto.sequenceType: object expected");e.sequenceType=s.onnx.TypeProto.Sequence.fromObject(t.sequenceType)}if(null!=t.mapType){if("object"!=typeof t.mapType)throw TypeError(".onnx.TypeProto.mapType: object expected");e.mapType=s.onnx.TypeProto.Map.fromObject(t.mapType)}if(null!=t.optionalType){if("object"!=typeof t.optionalType)throw TypeError(".onnx.TypeProto.optionalType: object expected");e.optionalType=s.onnx.TypeProto.Optional.fromObject(t.optionalType)}if(null!=t.sparseTensorType){if("object"!=typeof t.sparseTensorType)throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");e.sparseTensorType=s.onnx.TypeProto.SparseTensor.fromObject(t.sparseTensorType)}return null!=t.denotation&&(e.denotation=String(t.denotation)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.denotation=""),null!=t.tensorType&&t.hasOwnProperty("tensorType")&&(n.tensorType=s.onnx.TypeProto.Tensor.toObject(t.tensorType,e),e.oneofs&&(n.value="tensorType")),null!=t.sequenceType&&t.hasOwnProperty("sequenceType")&&(n.sequenceType=s.onnx.TypeProto.Sequence.toObject(t.sequenceType,e),e.oneofs&&(n.value="sequenceType")),null!=t.mapType&&t.hasOwnProperty("mapType")&&(n.mapType=s.onnx.TypeProto.Map.toObject(t.mapType,e),e.oneofs&&(n.value="mapType")),null!=t.denotation&&t.hasOwnProperty("denotation")&&(n.denotation=t.denotation),null!=t.sparseTensorType&&t.hasOwnProperty("sparseTensorType")&&(n.sparseTensorType=s.onnx.TypeProto.SparseTensor.toObject(t.sparseTensorType,e),e.oneofs&&(n.value="sparseTensorType")),null!=t.optionalType&&t.hasOwnProperty("optionalType")&&(n.optionalType=s.onnx.TypeProto.Optional.toObject(t.optionalType,e),e.oneofs&&(n.value="optionalType")),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto"},t.Tensor=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}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=i.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&e.uint32(8).int32(t.elemType),null!=t.shape&&Object.hasOwnProperty.call(t,"shape")&&s.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TypeProto.Tensor;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.elemType=t.int32();break;case 2:i.shape=s.onnx.TensorShapeProto.decode(t,t.uint32());break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.isInteger(t.elemType))return"elemType: integer expected";if(null!=t.shape&&t.hasOwnProperty("shape")){var e=s.onnx.TensorShapeProto.verify(t.shape);if(e)return"shape."+e}return null},t.fromObject=function(t){if(t instanceof s.onnx.TypeProto.Tensor)return t;var e=new s.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");
6e.shape=s.onnx.TensorShapeProto.fromObject(t.shape)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.elemType=0,n.shape=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(n.elemType=t.elemType),null!=t.shape&&t.hasOwnProperty("shape")&&(n.shape=s.onnx.TensorShapeProto.toObject(t.shape,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Tensor"},t}(),t.Sequence=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.elemType=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&s.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TypeProto.Sequence;t.pos<n;){var o=t.uint32();o>>>3==1?i.elemType=s.onnx.TypeProto.decode(t,t.uint32()):t.skipType(7&o)}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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=s.onnx.TypeProto.verify(t.elemType);if(e)return"elemType."+e}return null},t.fromObject=function(t){if(t instanceof s.onnx.TypeProto.Sequence)return t;var e=new s.onnx.TypeProto.Sequence;if(null!=t.elemType){if("object"!=typeof t.elemType)throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");e.elemType=s.onnx.TypeProto.fromObject(t.elemType)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.elemType=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(n.elemType=s.onnx.TypeProto.toObject(t.elemType,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Sequence"},t}(),t.Map=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}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=i.create()),null!=t.keyType&&Object.hasOwnProperty.call(t,"keyType")&&e.uint32(8).int32(t.keyType),null!=t.valueType&&Object.hasOwnProperty.call(t,"valueType")&&s.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TypeProto.Map;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.keyType=t.int32();break;case 2:i.valueType=s.onnx.TypeProto.decode(t,t.uint32());break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.isInteger(t.keyType))return"keyType: integer expected";if(null!=t.valueType&&t.hasOwnProperty("valueType")){var e=s.onnx.TypeProto.verify(t.valueType);if(e)return"valueType."+e}return null},t.fromObject=function(t){if(t instanceof s.onnx.TypeProto.Map)return t;var e=new s.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=s.onnx.TypeProto.fromObject(t.valueType)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.keyType=0,n.valueType=null),null!=t.keyType&&t.hasOwnProperty("keyType")&&(n.keyType=t.keyType),null!=t.valueType&&t.hasOwnProperty("valueType")&&(n.valueType=s.onnx.TypeProto.toObject(t.valueType,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Map"},t}(),t.Optional=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.elemType=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&s.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TypeProto.Optional;t.pos<n;){var o=t.uint32();o>>>3==1?i.elemType=s.onnx.TypeProto.decode(t,t.uint32()):t.skipType(7&o)}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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=s.onnx.TypeProto.verify(t.elemType);if(e)return"elemType."+e}return null},t.fromObject=function(t){if(t instanceof s.onnx.TypeProto.Optional)return t;var e=new s.onnx.TypeProto.Optional;if(null!=t.elemType){if("object"!=typeof t.elemType)throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");e.elemType=s.onnx.TypeProto.fromObject(t.elemType)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.elemType=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(n.elemType=s.onnx.TypeProto.toObject(t.elemType,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.Optional"},t}(),t.SparseTensor=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}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=i.create()),null!=t.elemType&&Object.hasOwnProperty.call(t,"elemType")&&e.uint32(8).int32(t.elemType),null!=t.shape&&Object.hasOwnProperty.call(t,"shape")&&s.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.TypeProto.SparseTensor;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.elemType=t.int32();break;case 2:i.shape=s.onnx.TensorShapeProto.decode(t,t.uint32());break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.isInteger(t.elemType))return"elemType: integer expected";if(null!=t.shape&&t.hasOwnProperty("shape")){var e=s.onnx.TensorShapeProto.verify(t.shape);if(e)return"shape."+e}return null},t.fromObject=function(t){if(t instanceof s.onnx.TypeProto.SparseTensor)return t;var e=new s.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");
vendor: 9,855 bytes, line 6
6e.shape=s.onnx.TensorShapeProto.fromObject(t.shape)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.elemType=0,n.shape=null),null!=t.elemType&&t.hasOwnProperty("elemType")&&(n.elemType=t.elemType),null!=t.shape&&t.hasOwnProperty("shape")&&(n.shape=s.onnx.TensorShapeProto.toObject(t.shape,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.TypeProto.SparseTensor"},t}(),t}(),a.OperatorSetIdProto=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.domain="",t.prototype.version=o.Long?o.Long.fromBits(0,0,!1):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.OperatorSetIdProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.domain=t.string();break;case 2:i.version=t.int64();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.domain&&t.hasOwnProperty("domain")&&!o.isString(t.domain)?"domain: string expected":null==t.version||!t.hasOwnProperty("version")||o.isInteger(t.version)||t.version&&o.isInteger(t.version.low)&&o.isInteger(t.version.high)?null:"version: integer|Long expected"},t.fromObject=function(t){if(t instanceof s.onnx.OperatorSetIdProto)return t;var e=new s.onnx.OperatorSetIdProto;return null!=t.domain&&(e.domain=String(t.domain)),null!=t.version&&(o.Long?(e.version=o.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 o.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults)if(n.domain="",o.Long){var r=new o.Long(0,0,!1);n.version=e.longs===String?r.toString():e.longs===Number?r.toNumber():r}else n.version=e.longs===String?"0":0;return null!=t.domain&&t.hasOwnProperty("domain")&&(n.domain=t.domain),null!=t.version&&t.hasOwnProperty("version")&&("number"==typeof t.version?n.version=e.longs===String?String(t.version):t.version:n.version=e.longs===String?o.Long.prototype.toString.call(t.version):e.longs===Number?new o.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.OperatorSetIdProto"},t}(),a.OperatorStatus=function(){var t={},e=Object.create(t);return e[t[0]="EXPERIMENTAL"]=0,e[t[1]="STABLE"]=1,e}(),a.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),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.name="",t.prototype.input=o.emptyArray,t.prototype.output=o.emptyArray,t.prototype.attribute=o.emptyArray,t.prototype.attributeProto=o.emptyArray,t.prototype.node=o.emptyArray,t.prototype.docString="",t.prototype.opsetImport=o.emptyArray,t.prototype.domain="",t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.name&&Object.hasOwnProperty.call(t,"name")&&e.uint32(10).string(t.name),null!=t.input&&t.input.length)for(var n=0;n<t.input.length;++n)e.uint32(34).string(t.input[n]);if(null!=t.output&&t.output.length)for(n=0;n<t.output.length;++n)e.uint32(42).string(t.output[n]);if(null!=t.attribute&&t.attribute.length)for(n=0;n<t.attribute.length;++n)e.uint32(50).string(t.attribute[n]);if(null!=t.node&&t.node.length)for(n=0;n<t.node.length;++n)s.onnx.NodeProto.encode(t.node[n],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(n=0;n<t.opsetImport.length;++n)s.onnx.OperatorSetIdProto.encode(t.opsetImport[n],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(n=0;n<t.attributeProto.length;++n)s.onnx.AttributeProto.encode(t.attributeProto[n],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 r||(t=r.create(t));for(var n=void 0===e?t.len:t.pos+e,i=new s.onnx.FunctionProto;t.pos<n;){var o=t.uint32();switch(o>>>3){case 1:i.name=t.string();break;case 4:i.input&&i.input.length||(i.input=[]),i.input.push(t.string());break;case 5:i.output&&i.output.length||(i.output=[]),i.output.push(t.string());break;case 6:i.attribute&&i.attribute.length||(i.attribute=[]),i.attribute.push(t.string());break;case 11:i.attributeProto&&i.attributeProto.length||(i.attributeProto=[]),i.attributeProto.push(s.onnx.AttributeProto.decode(t,t.uint32()));break;case 7:i.node&&i.node.length||(i.node=[]),i.node.push(s.onnx.NodeProto.decode(t,t.uint32()));break;case 8:i.docString=t.string();break;case 9:i.opsetImport&&i.opsetImport.length||(i.opsetImport=[]),i.opsetImport.push(s.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 10:i.domain=t.string();break;default:t.skipType(7&o)}}return i},t.decodeDelimited=function(t){return t instanceof r||(t=new r(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")&&!o.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(!o.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(e=0;e<t.output.length;++e)if(!o.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(e=0;e<t.attribute.length;++e)if(!o.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(e=0;e<t.attributeProto.length;++e)if(n=s.onnx.AttributeProto.verify(t.attributeProto[e]))return"attributeProto."+n}if(null!=t.node&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(e=0;e<t.node.length;++e)if(n=s.onnx.NodeProto.verify(t.node[e]))return"node."+n}if(null!=t.docString&&t.hasOwnProperty("docString")&&!o.isString(t.docString))return"docString: string expected";if(null!=t.opsetImport&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(e=0;e<t.opsetImport.length;++e){var n;if(n=s.onnx.OperatorSetIdProto.verify(t.opsetImport[e]))return"opsetImport."+n}}return null!=t.domain&&t.hasOwnProperty("domain")&&!o.isString(t.domain)?"domain: string expected":null},t.fromObject=function(t){if(t instanceof s.onnx.FunctionProto)return t;var e=new s.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 n=0;n<t.input.length;++n)e.input[n]=String(t.input[n])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.FunctionProto.output: array expected");for(e.output=[],n=0;n<t.output.length;++n)e.output[n]=String(t.output[n])}if(t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");for(e.attribute=[],n=0;n<t.attribute.length;++n)e.attribute[n]=String(t.attribute[n])}if(t.attributeProto){if(!Array.isArray(t.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");for(e.attributeProto=[],n=0;n<t.attributeProto.length;++n){if("object"!=typeof t.attributeProto[n])throw TypeError(".onnx.FunctionProto.attributeProto: object expected");e.attributeProto[n]=s.onnx.AttributeProto.fromObject(t.attributeProto[n])}}if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.FunctionProto.node: array expected");for(e.node=[],n=0;n<t.node.length;++n){if("object"!=typeof t.node[n])throw TypeError(".onnx.FunctionProto.node: object expected");e.node[n]=s.onnx.NodeProto.fromObject(t.node[n])}}if(null!=t.docString&&(e.docString=String(t.docString)),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");for(e.opsetImport=[],n=0;n<t.opsetImport.length;++n){if("object"!=typeof t.opsetImport[n])throw TypeError(".onnx.FunctionProto.opsetImport: object expected");e.opsetImport[n]=s.onnx.OperatorSetIdProto.fromObject(t.opsetImport[n])}}return null!=t.domain&&(e.domain=String(t.domain)),e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.input=[],n.output=[],n.attribute=[],n.node=[],n.opsetImport=[],n.attributeProto=[]),e.defaults&&(n.name="",n.docString="",n.domain=""),null!=t.name&&t.hasOwnProperty("name")&&(n.name=t.name),t.input&&t.input.length){n.input=[];for(var r=0;r<t.input.length;++r)n.input[r]=t.input[r]}if(t.output&&t.output.length)for(n.output=[],r=0;r<t.output.length;++r)n.output[r]=t.output[r];if(t.attribute&&t.attribute.length)for(n.attribute=[],r=0;r<t.attribute.length;++r)n.attribute[r]=t.attribute[r];
6if(t.node&&t.node.length)for(n.node=[],r=0;r<t.node.length;++r)n.node[r]=s.onnx.NodeProto.toObject(t.node[r],e);if(null!=t.docString&&t.hasOwnProperty("docString")&&(n.docString=t.docString),t.opsetImport&&t.opsetImport.length)for(n.opsetImport=[],r=0;r<t.opsetImport.length;++r)n.opsetImport[r]=s.onnx.OperatorSetIdProto.toObject(t.opsetImport[r],e);if(null!=t.domain&&t.hasOwnProperty("domain")&&(n.domain=t.domain),t.attributeProto&&t.attributeProto.length)for(n.attributeProto=[],r=0;r<t.attributeProto.length;++r)n.attributeProto[r]=s.onnx.AttributeProto.toObject(t.attributeProto[r],e);return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/onnx.FunctionProto"},t}(),a}(),e.exports=s});function ur(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function kr(t){return(new TextDecoder).decode(t)}var ot,Ge,ni,$t,_n,_t,Nt,B,$r,Me,Ue,Ve,Y=O(()=>{xn(),zo(),ot=rr(sr()),ze(),Ge=class{static arraysEqual(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}},ni=class{static preprocessInputShapes(t,e){return[1===t.length?[1,t[0]]:t,1===e.length?[e[0],1]:e]}static postprocessOutputShape(t,e,n){1===e&&t.splice(t.length-2,1),1===n&&t.pop()}static calcMatMulShape(t,e){return t[1]!==e[0]?void 0:[t[0],e[1]]}},$t=class t{static calcShape(t,e,n=!1){let r=t.length,i=e.length;if(0===r)return e;if(0===i)return t;let o=Math.max(t.length,e.length),s=new Array(o);if(n){if(r<2||i<2)return;let n=ni.calcMatMulShape([t[r-2],t[r-1]],[e[i-2],e[i-1]]);if(void 0===n)return;[s[o-2],s[o-1]]=n}for(let a=n?3:1;a<=o;a++){let n=r-a<0?1:t[r-a],u=i-a<0?1:e[i-a];if(n!==u&&n>1&&u>1)return;s[o-a]=Math.max(n,u)}return s}static index(e,n){let r=new Array(n.length);return t.fillIndex(e,n,r),r}static fillIndex(t,e,n){let r=t.length-e.length;for(let i=0;i<e.length;i++)n[i]=t[r+i]%e[i]}static calc(e,n,r,i,o){let s=t.calcShape(e.dims,n.dims);if(s){if(i&&!B.areEqual(s,e.dims))return;let a=B.size(s),u=i?e:new bt(s,o||e.type);if(0===s.length)u.set([],r(e.get([]),n.get([])));else{let i,o=new Array(s.length),l=new Array(e.dims.length),p=new Array(n.dims.length),c=0,d=0,h=!1,f=!1;0===e.dims.length&&(c=e.get([]),h=!0),0===n.dims.length&&(d=n.get([]),f=!0);for(let g=0;g<a;g++){i=g;for(let t=s.length-1;t>=0;t--)o[t]=i%s[t],i=Math.floor(i/s[t]);h||(t.fillIndex(o,e.dims,l),c=e.get(l)),f||(t.fillIndex(o,n.dims,p),d=n.get(p)),u.set(o,r(c,d))}}return u}}static isValidBroadcast(t,e){let n=t.length,r=e.length;if(n>r)return!1;for(let i=1;i<=n;i++)if(1!==t[n-i]&&t[n-i]!==e[r-i])return!1;return!0}static getBroadcastDims(t,e){let n=t.length,r=[];for(let i=0;i<n;i++){let o=n-1-i,s=t[o]||1;(e[e.length-1-i]||1)>1&&1===s&&r.unshift(o)}return r}},_n=class{static getShapeOfGemmResult(t,e,n,r,i){if(2!==t.length||2!==n.length)throw new Error("shape need to be of size 2");let o,s,a;e?(o=t[1],s=t[0]):(o=t[0],s=t[1]);let u=-1;if(r?(a=n[0],u=1):(a=n[1],u=0),n[u]!==s)throw new Error("dimension mismatch");if(o<=0||a<=0||s<=0)throw new Error("invalid shape specified");if(i&&!$t.isValidBroadcast(i,[o,a]))throw new Error("gemm: invalid bias shape for broadcast");return[o,a,s]}},_t=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 new 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 new Error(`unsupported data type: ${t}`)}}static tensorDimsFromProto(t){return t.map(t=>me.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 n=0;n<t.dimsLength();n++)e.push(Nt.longToNumber(t.dims(n)));return e}static tensorAttributesFromORTFormat(t){let e=[];for(let n=0;n<t.attributesLength();n++)e.push(t.attributes(n));return e}},Nt=class{static longToNumber(t,e){return me.isLong(t)?t.toNumber():t instanceof T.Long?me.fromValue({low:t.low,high:t.high,unsigned:e??!1}).toNumber():t}static isLong(t){return me.isLong(t)||t instanceof T.Long}},B=class t{static size(e){return t.getSizeFromDimensionRange(e,0,e.length)}static sizeFromDimension(e,n){if(n<0||n>e.length)throw new Error(`invalid dimension of ${n} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return t.getSizeFromDimensionRange(e,n,e.length)}static sizeToDimension(e,n){if(n<0||n>e.length)throw new Error(`invalid dimension of ${n} for sizeToDimension as Tensor has ${e.length} dimensions.`);return t.getSizeFromDimensionRange(e,0,n)}static getSizeFromDimensionRange(t,e,n){let r=1;for(let i=e;i<n;i++){if(t[i]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");r*=t[i]}return r}static computeStrides(t){let e=t.length;if(0===e)return[];if(1===e)return[1];let n=new Array(e);n[e-1]=1,n[e-2]=t[e-1];for(let r=e-3;r>=0;--r)n[r]=n[r+1]*t[r+1];return n}static transpose(t){return t.slice().reverse()}static indicesToOffset(t,e,n){void 0===n&&(n=t.length);let r=0;for(let i=0;i<n;++i)r+=e[i]*t[i];return r}static offsetToIndices(t,e){let n=e.length;if(0===n)return[];if(1===n)return[t*e[0]];let r=new Array(e.length);for(let i=0;i<r.length-1;++i)r[i]=Math.floor(t/e[i]),t-=r[i]*e[i];return r[r.length-1]=t,r}static normalizeAxis(t,e){if(t<-e&&t>=e)throw new 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,n){if(0===e.length||0===t.length)throw new Error("Index incrementing unsupported for scalar Tensor");if(void 0===n)n=e.length;else if(n<=0||n>e.length)throw new Error("Incorrect axis to increment on");for(let r=n-1;r>=0&&(t[r]++,!(t[r]<e[r]));
6--r)t[r]=0}static calculateReshapedDims(e,n){if(0===n.length){if(0===e.length||1===t.size(e))return[];throw new Error("cannot reshape to a scalar Tensor")}let r=n.length,i=new Array(r),o=-1,s=1;for(let t=0;t<r;t++){if(n[t]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(-1===n[t]){if(-1!==o)throw new Error("at most one dimension in shape hints can be -1");o=t}else{if(0===n[t]){if(t>=e.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");i[t]=e[t]}else i[t]=n[t];s*=i[t]}}let a=t.size(e);if(-1!==o){if(a%s!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${e}] Output shape: [${n}]`);i[o]=a/s}else if(s!==a)throw new Error("reshapedDims and originalDims don't have matching sizes");return i}static sortBasedOnPerm(t,e){return e?e.map(e=>t[e]):t.slice().reverse()}static padShape(t,e){let n=t.length;return t.map((t,r)=>t+e[r]+e[r+n])}static areEqual(t,e){return t.length===e.length&&t.every((t,n)=>t===e[n])}static validateDimsAndCalcSize(t){if(t.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let e=1;for(let n of t){if(!Number.isInteger(n))throw new TypeError(`Invalid shape: ${n} is not an integer`);if(n<0||n>2147483647)throw new TypeError(`Invalid shape: length ${n} is not allowed`);e*=n}return e}static flattenShape(t,e){e<0&&(e+=t.length);let n=t.reduce((t,e)=>t*e,1),r=t.slice(e).reduce((t,e)=>t*e,1);return[n/r,r]}static squeezeShape(e,n){let r=new Array;n=t.normalizeAxes(n,e.length);for(let t=0;t<e.length;t++){let i=n.indexOf(t)>=0;if(i&&1!==e[t])throw new Error("squeeze an axis of size different than 1");(0===n.length&&e[t]>1||n.length>0&&!i)&&r.push(e[t])}return r}static unsqueezeShape(e,n){let r=new Array(e.length+n.length);r.fill(0);for(let o=0;o<n.length;o++){let e=t.normalizeAxis(n[o],r.length);if(e>=r.length)throw new Error("'axes' has an out of range axis");if(0!==r[e])throw new Error("'axes' has a duplicate axis");r[e]=1}let i=0;for(let t=0;t<r.length;t++)0===r[t]&&(r[t]=e[i++]);if(i!==e.length)throw new Error("the unsqueezed dimension could not be established");return r}},$r=class t{static splitShape(e,n,r,i){if(0===r.length){if(!i)throw new Error("need to know number of outputs when the 'split' attribute is not specified");t.determineSplit(e[n],i,r)}let o=[],s=[0];for(let t=0;t<r.length;++t){0!==t&&s.push(s[t-1]+r[t-1]);let i=e.slice();i[n]=r[t],o.push(i)}return[o,s]}static determineSplit(t,e,n){if(t%e!==0)throw new Error("cannot split tensor to equal sized parts");for(let r=0;r<e;++r)n.push(t/e)}},Me=class t{static adjustPoolAttributes(t,e,n,r,i,o){if(!t&&n.length!==e.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(t)for(let s=0;s<e.length-2;s++)s>=n.length?n.push(e[s+2]):n[s]=e[s+2];for(let s=0;s<n.length;s++)if(s<r.length){if(r[s]<0)throw new Error("strides should be greater than or equal to 1")}else r.push(1);for(let s=0;s<n.length;s++)if(s<i.length){if(i[s]<0)throw new Error("dilations should be greater than or equal to 1")}else i.push(1);for(let s=0;s<2*n.length;s++)if(s<o.length){if(o[s]<0)throw new Error("pad should be greater than or equal to 1")}else o.push(0);for(let s=0;s<n.length;s++){if(n[s]<=0)throw new Error("kernel shapes need to be greater than 0");if(o[s]>=n[s]||o[s+n.length]>=n[s])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,n,r,i,o,s){if(s){if(o.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(n.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(i.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let a=0;a<e.length-2;a++)t.adjustPadAndReturnShape(e[a+2],n[a],r[a],i[a],o,a,a+e.length-2,s)}}static computePoolOutputShape(e,n,r,i,o,s,a){if(n.length<=0)throw new Error("input shape must be of size greater than 0");let u=[n[0],n[1]];return t.computeShapeHelper(e,n,u,r,i,o,s,a),u}static computeConvOutputShape(e,n,r,i,o,s,a){if(e.length<=0||n.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let u=[e[0],n[0]];return t.computeShapeHelper(!1,e,u,r,i,o,s,a),u}static computeShapeHelper(e,n,r,i,o,s,a,u){if(e)for(let t=0;t<n.length-2;t++)r.push(1);else for(let l=0;l<n.length-2;l++)r.push(t.adjustPadAndReturnShape(n[l+2],i[l],o[l],s[l],a,l,l+n.length-2,u))}static adjustPadAndReturnShape(t,e,n,r,i,o,s,a){let u=n*(r-1)+1;if(!a||"NOTSET"===a)return Math.floor((t+i[o]+i[s]-u)/e+1);switch(a){case"VALID":return i[o]=0,i[s]=0,Math.floor((t-u)/e+1);case"SAME_LOWER":case"SAME_UPPER":if(1!==n)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let n=((t+e-1)/e-1)*e+r-t;return i[o]=Math.floor("SAME_LOWER"===a?(n+1)/2:n/2),i[s]=n-i[o],Math.floor((t+n-r)/e+1)}default:throw new Error("Unsupported AutoPad type")}}},Ue=-34028234663852886e22,Ve=34028234663852886e22});function ph(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 new Error(`cannot calculate sizeof() on type ${t}`)}}function Vu(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 new Error(`cannot calculate sizeof() on type ${H.onnx.TensorProto.DataType[t]}`)}}function dh(t,e){return new(Hu(e))(t)}function Hu(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 new Error("unspecified error")}}function ii(t,e){if(e===H.onnx.TensorProto.DataType.INT64||e===oi.TensorDataType.INT64){if(t.greaterThanOrEqual(2147483648)||t.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else{if(e!==H.onnx.TensorProto.DataType.UINT32&&e!==oi.TensorDataType.UINT32&&e!==H.onnx.TensorProto.DataType.UINT64&&e!==oi.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${H.onnx.TensorProto.DataType[e]}`);
6if(t.greaterThanOrEqual(4294967296)||t.lessThan(0))throw new TypeError("uint64 is not supported")}return t.toNumber()}function zu(t,e,n){switch(e){case H.onnx.TensorProto.DataType.BOOL:case H.onnx.TensorProto.DataType.UINT8:return t.getUint8(n);case H.onnx.TensorProto.DataType.INT8:return t.getInt8(n);case H.onnx.TensorProto.DataType.UINT16:return t.getUint16(n,!0);case H.onnx.TensorProto.DataType.INT16:return t.getInt16(n,!0);case H.onnx.TensorProto.DataType.FLOAT:return t.getFloat32(n,!0);case H.onnx.TensorProto.DataType.INT32:return t.getInt32(n,!0);case H.onnx.TensorProto.DataType.UINT32:return t.getUint32(n,!0);case H.onnx.TensorProto.DataType.INT64:return ii(me.fromBits(t.getUint32(n,!0),t.getUint32(n+4,!0),!1),e);case H.onnx.TensorProto.DataType.DOUBLE:return t.getFloat64(n,!0);case H.onnx.TensorProto.DataType.UINT64:return ii(me.fromBits(t.getUint32(n,!0),t.getUint32(n+4,!0),!0),e);default:throw new Error(`cannot read from DataView for type ${H.onnx.TensorProto.DataType[e]}`)}}var Wu,H,oi,bt,ze=O(()=>{Wu=rr(ks()),zo(),Pr(),H=rr(sr()),Y(),oi=F.experimental.fbs,bt=class t{constructor(t,e,n,r,i,o=Wu.Guid.create()){this.dims=t,this.type=e,this.dataProvider=n,this.asyncDataProvider=r,this.cache=i,this.dataId=o,this.size=B.validateDimsAndCalcSize(t);let s=this.size,a=void 0===n&&void 0===r&&void 0===i;if(void 0!==i&&i.length!==s)throw new RangeError("Input dims doesn't match data length.");if("string"===e){if(!(void 0===i||Array.isArray(i)&&i.every(t=>"string"==typeof t)))throw new TypeError("cache should be a string array");a&&(this.cache=new Array(s))}else{if(void 0!==i){let t=Hu(e);if(!(i instanceof t))throw new TypeError(`cache should be type ${t.name}`)}if(a){let t=new ArrayBuffer(s*ph(e));this.cache=dh(t,e)}}}get data(){if(void 0===this.cache){let t=this.dataProvider(this.dataId);if(t.length!==this.size)throw new 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 new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if("string"!==this.type)return this.data;throw new TypeError("type cannot be non-number (string)")}get(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 new Error("cannot construct Value from an empty tensor");let n=_t.tensorDataTypeFromProto(e.dataType),r=_t.tensorDimsFromProto(e.dims),i=new t(r,n);if("string"===n)e.stringData.forEach((t,e)=>{i.data[e]=kr(t)});else if(e.rawData&&"number"==typeof e.rawData.byteLength&&e.rawData.byteLength>0){let t=i.data,n=new DataView(e.rawData.buffer,e.rawData.byteOffset,e.rawData.byteLength),r=Vu(e.dataType),o=e.rawData.byteLength/r;if(e.rawData.byteLength%r!==0)throw new Error("invalid buffer length");if(t.length!==o)throw new Error("buffer length mismatch");for(let i=0;i<o;i++){let o=zu(n,e.dataType,i*r);t[i]=o}}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 new Error("unspecific error")}if(null==t)throw new Error("failed to populate data from a tensorproto value");let n=i.data;if(n.length!==t.length)throw new Error("array length mismatch");for(let r=0;r<t.length;r++){let i=t[r];me.isLong(i)?n[r]=ii(i,e.dataType):n[r]=i}}return i}static fromData(e,n,r){return new t(n,r,void 0,void 0,e)}static fromOrtTensor(e){if(!e)throw new Error("cannot construct V
6alue from an empty tensor");let n=_t.tensorDimsFromORTFormat(e),r=_t.tensorDataTypeFromProto(e.dataType()),i=new t(n,r);if("string"===r)for(let t=0;t<e.stringDataLength();t++)i.data[t]=e.stringData(t);else if(e.rawDataArray()&&"number"==typeof e.rawDataLength()&&e.rawDataLength()>0){let t=i.data,n=new DataView(e.rawDataArray().buffer,e.rawDataArray().byteOffset,e.rawDataLength()),r=Vu(e.dataType()),o=e.rawDataLength()/r;if(e.rawDataLength()%r!==0)throw new Error("invalid buffer length");if(t.length!==o)throw new Error("buffer length mismatch");for(let i=0;i<o;i++){let o=zu(n,e.dataType(),i*r);t[i]=o}}return i}}});function G(t){return 1===t?hh:mh}function qu(t){let e=G(t);return`${e.version}\n      precision highp float;\n      ${e.attribute} vec3 position;\n      ${e.attribute} vec2 textureCoord;\n\n      ${e.varyingVertex} vec2 TexCoords;\n\n      void main()\n      {\n          gl_Position = vec4(position, 1.0);\n          TexCoords = textureCoord;\n      }`}function ju(t){let e=G(t);return`${e.version}\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    ${e.varyingFrag} vec2 TexCoords;\n    ${e.outputDeclaration}\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    // Custom vector types to handle higher dimenalities.\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    int imod(int x, int y) {\n      return x - y * (x / y);\n    }\n\n    `}function Xu(t,e){return`\n  void main() {\n    int indices[${e}];\n    toVec(TexCoords, indices);\n    vec4 result = vec4(process(indices));\n    ${G(t).output} = result;\n  }\n  `}var hh,mh,st=O(()=>{hh={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},mh={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"}}),j=O(()=>{});async function ai(t,e=t=>0,n){return new Promise((n,r)=>{let i=0,o=()=>{if(t())return void n();i++;let r=e(i);setTimeout(o,r)};o()})}function On(t){return ur(typeof t<"u"&&0!==t.length,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)}function Ku(t){return ur(typeof t<"u"&&0!==t.length,()=>"empty string found for sampler name"),"get"+t.charAt(0).toUpperCase()+t.slice(1)+"AtOutCoords"}function lr(t,e){let n=JSON.parse(JSON.stringify(t));return n=e,n}function fr(t,e){return e.map(e=>t[e]).join(", ")}function kt(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 ee(t=6){return["x","y","z","w","u","v"].slice(0,t)}var ue=O(()=>{Y()});function bh(t,e){return ee(e).map(e=>`${t}.${e}`)}function cr(t,e){return 1===e?[t]:bh(t,e)}function le(){return"\n    float getChannel(vec4 frag, int dim) {\n      int modCoord = imod(dim, 2);\n      return modCoord == 0 ? frag.r : frag.g;\n    }\n\n    float getChannel(vec4 frag, vec2 innerDims) {\n      vec2 modCoord = mod(innerDims, 2.);\n      return modCoord.x == 0. ?\n        (modCoord.y == 0. ? frag.r : frag.g) :\n        (modCoord.y == 0. ? frag.b : frag.a);\n    }\n  "}var We=O(()=>{ue()});function yh(t,e,n){if(0===t)return"false";if(1===t)return`rc > ${e[0]}`;let r="";for(let i=t-2;i<t;i++)r+=`${n[i]} >= ${e[i-t+2]}`,i<t-1&&(r+="||");return r}function xh(t,e){let n=t.length;if(0===n)return"getA(), 0, 0, 0";if(1===n)return`getA(rc),\n            rc + 1 >= ${t[0]} ? 0. : getA(rc + 1),\n            0, 0`;let r="";if(n>2)for(let i=0;i<n-2;++i)r+=`${e[i]},`;return`getA(${r}r, c),\n          rEdge ? 0. : getA(${r}rp1, c),\n          cEdge ? 0. : getA(${r}r, cp1),\n          rEdge || cEdge ? 0. : getA(${r}rp1, cp1)`}function Th(t,e,n,r){return 0===t||1===t?"":`\n    int r = ${e[t-2]};\n    int c = ${e[t-1]};\n    int rp1 = ${e[t-2]} + 1;\n    int cp1 = ${e[t-1]} + 1;\n    bool rEdge = rp1 >= ${r};\n    bool cEdge = cp1 >= ${n};\n    `}var Ju,gh,Yu,Zu=O(()=>{st(),j(),ue(),We(),Ju={name:"pack",inputNames:["A"],inputTypes:[1]},gh=(t,e)=>{let n,r=G(t.session.backend.glContext.version),i=e.dims,o=i.length,s=e.dims.length,a=kt(s),u=cr
6("rc",s),l=Th(s,u,i[i.length-2],i[i.length-1]);n=0===o?[1,1]:1===o?[i[0],1]:[i[s-1],i[s-2]];let p=yh(s,n,u),c=xh(i,u),d=`\n        void main() {\n          ${a} rc = getOutputCoords();\n\n          if(${p}) {\n            ${r.output} = vec4(0);\n          } else {\n            ${l}\n\n            ${r.output} = vec4(${c});\n          }\n        }\n      `;return{...Ju,hasMain:!0,output:{dims:e.dims,type:e.type,textureType:2},shaderSource:d}},Yu=(t,e)=>({...Ju,get:()=>gh(t,e)})});function si(t){if(0===t.length)return[1,1,1];let e=1;for(let n=0;n<t.length-2;++n)e*=t[n];return[e,t.length>1?t[t.length-2]:1,t[t.length-1]]}function tl(t,e){let n=!1;return n=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]),n}function Ih(t){let e=B.computeStrides(t),n=["b","r","c"],r="index";return`\n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      ${e.map((t,i)=>`int ${n[i]} = ${r} / ${t}; ${i===e.length-1?`int ${n[i+1]} = ${r} - ${n[i]} * ${t}`:`index -= ${n[i]} * ${t}`};`).join("")}\n      return ivec3(b, r, c);\n    }\n  `}function _h(t){let e=B.computeStrides(t);return`\n  int getFlattenedIndex(ivec3 coords) {\n    // reverse y, z order\n    return coords.x * ${e[0]} + coords.z * ${e[1]} + coords.y;\n  }\n`}var wh,vh,Qu,el=O(()=>{Y(),st(),j(),We(),wh=t=>({name:"Reshape (packed)",inputTypes:[2],inputNames:["A"],cacheHint:`${t}`}),vh=(t,e,n,r)=>{let i=e.dims,o=r,s="";for(let l=0;l<4;l++){let t="";switch(l){case 0:t="outputCoords = rc;";break;case 1:t="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:t="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:t="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}s+=`\n        ${t}\n        ${l>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}\n          int flattenedIndex = getFlattenedIndex(outputCoords);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);\n          vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result[${l}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);\n\n        ${l>0?"}":""}\n      `}let a=G(t.session.backend.glContext.version),u=`\n      ${Ih(i)}\n      ${_h(o)}\n      ${le()}\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.0);\n\n        ivec3 outputCoords;\n        int rows = ${o[2]};\n        int cols = ${o[1]};\n\n        ${s}\n        ${a.output} = result;\n      }\n    `;return{...n,output:{dims:o,type:e.type,textureType:2},shaderSource:u,hasMain:!0}},Qu=(t,e,n)=>{let r=wh(n);return{...r,get:()=>vh(t,e,r,n)}}}),ui,rl=O(()=>{st(),j(),ui=(t,e)=>{let n=e.shape,r=G(t.session.backend.glContext.version),i=`\n    const float FLOAT_MAX = 1.70141184e38;\n    const float FLOAT_MIN = 1.17549435e-38;\n\n    bool isNaN(float val) {\n      return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;\n    }\n\n    highp vec4 encodeAsUint8(highp float v) {\n      if (isNaN(v)) {\n        return vec4(255, 255, 255, 255);\n      }\n\n      highp float av = abs(v);\n\n      if(av < FLOAT_MIN) {\n        return vec4(0.0, 0.0, 0.0, 0.0);\n      } else if(v > FLOAT_MAX) {\n        return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n      } else if(v < -FLOAT_MAX) {\n        return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n      }\n\n      highp vec4 c = vec4(0,0,0,0);\n\n      highp float e = floor(log2(av));\n      highp float m = exp2(fract(log2(av))) - 1.0;\n\n      c[2] = floor(128.0 * m);\n      m -= c[2] / 128.0;\n      c[1] = floor(32768.0 * m);\n      m -= c[1] / 32768.0;\n      c[0] = floor(8388608.0 * m);\n\n      highp float ebias = e + 127.0;\n      c[3] = floor(ebias / 2.0);\n      ebias -= c[3] * 2.0;\n      c[2] += floor(ebias) * 128.0;\n\n      c[3] += 128.0 * step(0.0, -v);\n\n      return c / 255.0;\n    }\n\n    void main() {\n      float value = ${r.texture2D}(X,TexCoords).r;\n      ${r.output} = encodeAsUint8(value);\n    }`,o={name:"Uint8Encode",inputTypes:[0],inputNames:["X"],output:{dims:n,type:e.tensor.type,textureType:3},shaderSource:i,hasMain:!0};return t.executeProgram(o,[e.tensor])}});function Sh(t,e){if(1===t)return"rc";let n="";for(let r=0;r<t;r++)n+=e[r],r<t-1&&(n+=",");return n}var nl,Oh,ol,il=O(()=>{st(),j(),ue(),We(),nl={name:"unpack",inputNames:["A"],inputTypes:[2]},Oh=(t,e)=>{let n=e.dims.length,r=cr("rc",n),i=r.slice(-2),o=kt(n),s=le(),a=0===e.dims.length?"":Sh(n,r),u=n<=1?"rc":`vec2(${i.join(",")})`,l=`\n    ${s}\n    void main() {\n      ${o} rc = getOutputCoords();\n\n       // Sample the texture with the coords to get the rgba channel value.\n       vec4 packedInput = getA(${a});\n\n       ${G(t.session.backend.glContext.version).output} = vec4(getChannel(packedInput, ${u}), 0, 0, 0);\n     }\n   `;return{...nl,hasMain:!0,output:{dims:e.dims,type:e.type,textureType:0},shaderSource:l}},ol=(t,e)=>({...nl,get:()=>Oh(t,e)})}),Sn,Br,An,Fr=O(()=>{Mt(),Sn=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)throw new Error(`Invalid number of channels: ${e}`);this.internalFormat=t.RGBA32F,this.format=t.RGBA,this.textureType=t.FLOAT,this.channelSize=e}}encode(t,e){let n,r;return t.constructor!==Float32Array&&(tt.warning("Encoder","data was not of type Float32; creating new Float32Array"),r=new Float32Array(t)),e*this.channelSize>t.length?(tt.warning("Encoder","Source data too small. Allocating larger array"),r=t,n=this.allocate(e*this.channelSize),r.forEach((t,e)=>n[e]=t)):(r=t,n=r),n}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,n){if(1!==e&&4!==e)throw new Error(`Invalid number of channels: ${e}`);this.internalFormat=t.RGBA,this.format=t.RGBA,this.channelSize=e,this.textureType=n||t.FLOAT}encode(t,e){let n=t;return 1===this.channelSize&&(tt.verbose("Encoder","Exploding into a larger array"),n=this.allocate(e),t.forEach((t,e)=>n[4*e]=t)),n}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)}},An=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)throw new Error(`Invalid number of channels: ${e}`);this.internalFormat=t.RGBA,this.format=t.RGBA,this.textureType=t.UNSIGNED_BYTE,this.channelSize=e}}encode(t,e){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}allocate(t){return new Uint8Array(t*this.channelSize)}
6decode(t,e){if(t instanceof Uint8Array)return t.subarray(0,e);throw new Error(`Invalid array type: ${t.constructor}`)}}}),Cr,al,li,sl=O(()=>{Y(),j(),Cr=(t,e,n)=>{let r=0===n||1===n?1:4,i=2===n,o=1===n||2===n,s=4===n?e.length-1:void 0,a=4===n?e.map((t,n)=>n===e.length-1?4*t:t):void 0;return li(t,e,r,a,{isPacked:i,reverseWH:o,breakAxis:s})},al=(t,e,n)=>{let r=Cr(t,e,n);return[r.width,r.height]},li=(t,e,n=1,r,i)=>{let o=!(!i||!i.isPacked),[s,a]=t.computeTextureWH(o&&r||e,i),u=e.length,l=e.slice(0);if(0===u&&(l=[1]),1===n)r=e;else if(o){if(4!==n)throw new Error("a packed texture must be 4-channel");r=e,u>0&&(l[u-1]=Math.ceil(l[u-1]/2)),u>1&&(l[u-2]=Math.ceil(l[u-2]/2))}else if(!r)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:a,channels:n,isPacked:o,shape:l,strides:B.computeStrides(l),unpackedShape:r,reversedWH:i&&i.reverseWH}}}),Ph,Pn,ll=O(()=>{Mt(),ze(),Y(),Zu(),el(),rl(),il(),Fr(),sl(),j(),Ph=(t,e)=>{let n=e.map(t=>`${t.unpackedShape.join(",")};${t.width}x${t.height}`).join("_"),r=t.name;return t.cacheHint&&(r+="["+t.cacheHint+"]"),r+=":"+n,r},Pn=class{constructor(t){this.session=t,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(t,e){return al(this.session.layoutStrategy,t,e)}executeProgram(t,e){if(e.length<t.inputNames.length)throw new Error(`Input size mustn't be less than ${t.inputNames.length}.`);if(t.inputNames.length!==t.inputTypes.length)throw new Error("input names size does not match input types");let n=[];for(let u=0;u<t.inputNames.length;++u)n[u]=this.getOrCreateTextureData(e[u],t.inputTypes[u]);let r=Ph(t,n),i=this.session.programManager.getArtifact(r),o=i?i.programInfo:"function"==typeof t.get?t.get():t,s=Cr(this.session.layoutStrategy,o.output.dims,o.output.textureType),a=this.createTextureData(s,o.output.type);return i||(i=this.session.programManager.build(o,n,a),this.session.programManager.setArtifact(r,i)),this.runProgram(i,n,a),a}run(t,e){return this.executeProgram(t,e).tensor}runProgram(t,e,n){for(let r=0;r<e.length;++r)if(!!e[r].isPacked!=(2===t.programInfo.inputTypes[r]))throw new Error(`input[${r}] property packed inconsistent`);if(!!n.isPacked!=(2===t.programInfo.output.textureType))throw new Error("output property packed inconsistent");this.session.programManager.run(t,e,n)}getOrCreateTextureData(t,e){let n=this.getTextureData(t.dataId,2===e);if(!n&&(n=this.getTextureData(t.dataId,2!==e),n))return 2===e?this.pack(n):this.unpack(n);if(!n){let r=Cr(this.session.layoutStrategy,t.dims,e);if(4===e){let n=t.dims;if(4===n.length){let r=[n[0],Math.ceil(n[1]*n[2]*n[3]/4)],i=Cr(this.session.layoutStrategy,r,e),o=t.numberData;if(n[1]*n[2]*n[3]%4!=0){let e=n[0],r=n[1]*n[2]*n[3],i=4*Math.ceil(1*r/4);o=new Float32Array(e*i);for(let n=0;n<e;++n){let e=n*r,s=n*i+n%1*r;o.set(t.numberData.subarray(e,e+r),s)}}return this.createTextureData(i,t.type,o,t,1)}}if(2===e){let e=li(this.session.layoutStrategy,t.dims,1,[],{reverseWH:!0}),r=this.createTextureData(e,t.type,t.numberData,t,1);n=this.pack(r)}else n=this.createTextureData(r,t.type,t.numberData,t,1)}return n}createTextureDataFromLayoutBindTensor(t,e,n,r){return this.createTextureData(t,e,n,r,1)}createTextureData(t,e,n,r,i){tt.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(t)}]`);let o=this.session.textureManager.createTextureFromLayout(e,t,n,i);return this.createTextureDataFromTexture(t,e,o,r)}reshapeUnpacked(t,e){let n=this.getOrCreateTextureData(t,0),r={channels:n.channels,height:n.height,width:n.width,shape:0!==e.length?e:[1],strides:B.computeStrides(e),unpackedShape:e};return this.createTextureDataFromTexture(r,t.type,n.texture).tensor}reshapePacked(t,e){let n=this.getOrCreateTextureData(t,2);if(tl(t.dims,e)){let r={channels:n.channels,height:n.height,width:n.width,shape:0!==e.length?e:[1],strides:B.computeStrides(e),unpackedShape:e,isPacked:!0};return this.createTextureDataFromTexture(r,t.type,n.texture).tensor}let r=si(t.dims),i=si(e),o=this.reshapePacked(t,r),s=this.run(Qu(this,o,i),[o]);return this.reshapePacked(s,e)}cast(t,e){let n=this.getOrCreateTextureData(t,0);return this.createTextureDataFromTexture(n,e,n.texture).tensor}createTextureDataFromTexture(t,e,n,r,i){let o={...t,tensor:r||new bt(t.unpackedShape,e,t=>this.readTexture(o),async t=>this.readTextureAsync(o),void 0,i),texture:n};return this.setTextureData(o.tensor.dataId,o,t.isPacked),o}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,n=!1){this.session.isInitializer(t)?this.session.setTextureData(t,e,n):(n?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.
6isFloat32DownloadSupported?this.session.textureManager.readTexture(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat(ui(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(ui(this,t))}pack(t){return this.executeProgram(Yu(this,t.tensor),[t.tensor])}unpack(t){return this.executeProgram(ol(this,t.tensor),[t.tensor])}}}),fi,W,vt=O(()=>{fi=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 fi(t)}),fl,cl,pl,Eh,Dh,dl=O(()=>{vt(),st(),j(),fl={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[0,0,0,0,0]},cl=(t,e,n)=>(Dh(e),[t.run({...fl,cacheHint:n.cacheKey,get:()=>Eh(t,e,n)},e)]),pl=t=>{let e=t.attributes.getFloat("epsilon",1e-5),n=t.attributes.getFloat("momentum",.9),r=t.attributes.getInt("spatial",1);return W({epsilon:e,momentum:n,spatial:r})},Eh=(t,e,n)=>{let r=G(t.session.backend.glContext.version),i=e[0].dims.length,[o,s]=t.calculateTextureWidthAndHeight(e[1].dims,0),a=`\n  float process(int[${i}] indices) {\n    vec2 position = offsetToCoords(indices[1], ${o}, ${s});\n    float scale = getColorAsFloat(${r.texture2D}(Scale, position));\n    float mean = getColorAsFloat(${r.texture2D}(Mean, position));\n    float variance = getColorAsFloat(${r.texture2D}(Variance, position));\n    float b = getColorAsFloat(${r.texture2D}(B, position));\n\n    return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b;\n  }`;return{...fl,output:{dims:e[0].dims,type:e[0].type,textureType:0},shaderSource:a}},Dh=t=>{if(!t||5!==t.length)throw new Error("BatchNormalization requires 5 inputs.");let e=t[0],n=t[1],r=t[2],i=t[3],o=t[4];if(e.dims.length<3||1!==n.dims.length||1!==r.dims.length||1!==i.dims.length||1!==o.dims.length)throw new Error("invalid input shape.");if(n.dims[0]!==e.dims[1]||r.dims[0]!==e.dims[1]||i.dims[0]!==e.dims[1]||o.dims[
60]!==e.dims[1])throw new Error("invalid input shape.");if("float32"!==e.type&&"float64"!==e.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type||"float32"!==i.type&&"float64"!==i.type||"float32"!==o.type&&"float64"!==o.type)throw new Error("invalid input tensor types.")}}),En,Wt,k,Nr,Dn,be=O(()=>{En=class{constructor(t,e,n,r){this.glContext=t,this.programInfo=e,this.inputTextureLayouts=n,this.outputTextureLayout=r}},Wt=class{constructor(t){this.context=t}},k=class{constructor(t,e){this.routineBody=t,this.dependencies=e}},Nr=class{constructor(t,e,n){this.name=t,this.dependencies=n||[],e&&(this.routineBody=e)}addDependency(t){t&&this.dependencies.push(t)}},Dn=class{static returnOrderedNodes(t){if(!t||0===t.length)return[];if(1===t.length)return t;let e=new Set,n=new Set,r=new Array;return this.createOrderedNodes(t,e,n,r),r}static createOrderedNodes(t,e,n,r){for(let i=0;i<t.length;++i)this.dfsTraverse(t[i],e,n,r)}static dfsTraverse(t,e,n,r){if(!t||n.has(t.name))return;if(e.has(t.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");e.add(t.name);let i=t.dependencies;if(i&&i.length>0)for(let o=0;o<i.length;++o)this.dfsTraverse(i[o],e,n,r);r.push(t),n.add(t.name),e.delete(t.name)}}});function $h(){let t="add_";return{body:`\n  float ${t}(float a, float b) {\n    return a + b;\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return v1 + v2;\n  }\n  `,name:t,type:0}}function kh(){let t="div_";return{body:`\n  float ${t}(float a, float b) {\n    return a / b;\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return v1 / v2;\n  }\n  `,name:t,type:0}}function Bh(){let t="mul_";return{body:`\n  float ${t}(float a, float b) {\n    return a * b;\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return v1 * v2;\n  }\n  `,name:t,type:0}}function Fh(){let t="sub_";return{body:`\n  float ${t}(float a, float b) {\n    return a - b;\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return v1 - v2;\n  }\n  `,name:t,type:0}}function Ch(){let t="equal_";return{body:`\n  float ${t}(float a, float b) {\n    return float(a == b);\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return vec4(equal(v1, v2));\n  }\n  `,name:t,type:0}}function Nh(){let t="greater_";return{body:`\n  float ${t}(float a, float b) {\n    return float(a > b);\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return vec4( v1.r > v2.r ,\n      v1.g > v2.g,\n      v1.b > v2.b,\n      v1.a > v2.a );\n  }\n  `,name:t,type:0}}function Rh(){let t="less_";return{body:`\n  float ${t}(float a, float b) {\n    return float(a < b);\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return vec4( v1.r < v2.r ,\n                v1.g < v2.g,\n                v1.b < v2.b,\n                v1.a < v2.a );\n  }\n  `,name:t,type:0}}function Gh(){let t="and_";return{body:`\n  float ${t}(float a, float b) {\n    return float( bool(a) && bool(b) );\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    bvec4 b1 = bvec4(v1);\n    bvec4 b2 = bvec4(v2);\n    return vec4( b1.r && b2.r ,\n                b1.g && b2.g,\n                b1.b && b2.b,\n                b1.a && b2.a );\n  }\n  `,name:t,type:0}}function Mh(){let t="or_";return{body:`\n  float ${t}(float a, float b) {\n    return float( bool(a) || bool(b) );\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    bvec4 b1 = bvec4(v1);\n    bvec4 b2 = bvec4(v2);\n    return vec4( b1.r || b2.r ,\n                b1.g || b2.g,\n                b1.b || b2.b,\n                b1.a || b2.a );\n  }\n  `,name:t,type:0}}function Uh(){let t="xor_";return{body:`\n  float ${t}(float a, float b) {\n    return float( bool(a) ^^ bool(b) );\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    bvec4 b1 = bvec4(v1);\n    bvec4 b2 = bvec4(v2);\n    return vec4( b1.r ^^ b2.r ,\n                b1.g ^^ b2.g,\n                b1.b ^^ b2.b,\n                b1.a ^^ b2.a );\n  }\n  `,name:t,type:0}}function Vh(){return Wh("pow")}function zh(){let t="prelu_";return{body:`\n  float ${t}(float a, float b) {\n    return a < 0.0 ? a * b: a;\n  }\n  vec4 ${t}(vec4 v1, vec4 v2) {\n    return vec4(\n      v1.r < 0.0 ? v1.r * v2.r: v1.r,\n      v1.g < 0.0 ? v1.g * v2.g: v1.g,\n      v1.b < 0.0 ? v1.b * v2.b: v1.b,\n      v1.a < 0.0 ? v1.a * v2.a: v1.a\n      );\n  }\n  `,name:t,type:0}}function Wh(t){let e=`${t}_`;return{body:`\n  float ${e}(float a, float b) {\n    return ${t}(a, b);\n  }\n  vec4 ${e}(vec4 v1, vec4 v2) {\n    return ${t}(v1, v2);\n  }\n  `,name:e,type:0}}var Ht,Hh,hl,ml,bl,gl,yl,xl,Tl,wl,vl,Il,_l,Ol,Sl=O(()=>{Y(),be(),st(),j(),Ht=(t,e,n,r=e[0].type,i)=>{let o=t.session.pack?2:0;return{name:n.name,inputNames:["A","B"],inputTypes:[o,o],cacheHint:i,get:()=>Hh(t,e,n,r)}},Hh=(t,e,n,r=e[0].type)=>{let i=t.session.pack?2:0,o=!B.areEqual(e[0].dims,e[1].dims),s=e[0].dims,a=t.session.pack;
6if(o){let o=$t.calcShape(e[0].dims,e[1].dims,!1);if(!o)throw new Error("Can't perform binary op on the given tensors");s=o;let u=s.length,l=0!==e[0].dims.length?e[0].dims.length:1,p=0!==e[1].dims.length?e[1].dims.length:1,c=0!==e[0].dims.length?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",d=0!==e[1].dims.length?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",h=G(t.session.backend.glContext.version),f=a?`\n      ${n.body}\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n        vec4 result = ${n.name}(a, b);\n        ${h.output} = result;\n      }`:`\n      ${n.body}\n      float process(int indices[${u}]) {\n        int aindices[${l}];\n        int bindices[${p}];\n        ${c}\n        ${d}\n        return ${n.name}(_A(aindices), _B(bindices));\n      }`;return{name:n.name,inputNames:["A","B"],inputTypes:[i,i],output:{dims:s,type:r,textureType:i},shaderSource:f,hasMain:a}}let u=G(t.session.backend.glContext.version),l=`\n    ${n.body}\n    void main() {\n      vec4 v1 = ${u.texture2D}(A, TexCoords);\n      vec4 v2 = ${u.texture2D}(B, TexCoords);\n      vec4 result = ${n.name}(v1, v2);\n      ${u.output} = result;\n    }\n    `;return{name:n.name,inputNames:["A","B"],inputTypes:[i,i],output:{dims:e[0].dims,type:r,textureType:i},shaderSource:l,hasMain:!0}},hl=(t,e)=>[t.run(Ht(t,e,$h()),e)],ml=(t,e)=>[t.run(Ht(t,e,Gh(),"bool"),e)],bl=(t,e)=>[t.run(Ht(t,e,kh()),e)],gl=(t,e)=>[t.run(Ht(t,e,Ch(),"bool"),e)],yl=(t,e)=>[t.run(Ht(t,e,Nh(),"bool"),e)],xl=(t,e)=>[t.run(Ht(t,e,Rh(),"bool"),e)],Tl=(t,e)=>[t.run(Ht(t,e,Bh()),e)],wl=(t,e)=>[t.run(Ht(t,e,Mh(),"bool"),e)],vl=(t,e)=>[t.run(Ht(t,e,Vh()),e)],Il=(t,e)=>[t.run(Ht(t,e,zh()),e)],_l=(t,e)=>[t.run(Ht(t,e,Fh()),e)],Ol=(t,e)=>[t.run(Ht(t,e,Uh(),"bool"),e)]}),Al,Pl,jh,El=O(()=>{Y(),Al=(t,e,n)=>(jh(e),[t.cast(e[0],n)]),Pl=t=>_t.tensorDataTypeFromProto(t.attributes.getInt("to")),jh=t=>{if(!t||1!==t.length)throw new Error("Cast requires 1 input.");if("string"===t[0].type)throw new Error("Invalid input type.")}}),Xh,Kh,Dl,Ln,Ll=O(()=>{st(),j(),ue(),We(),Xh=(t,e)=>({name:"Concat (packed)",inputNames:Array.from({length:t},(t,e)=>`X${e}`),inputTypes:Array(t).fill(2),cacheHint:e}),Kh=(t,e,n,r)=>{let i=n[0].dims.slice();if(r>=i.length||r<-1*i.length)throw new Error("axis specified for concat doesn't match input dimensionality");r<0&&(r=i.length+r);let o=i.slice(0);for(let x=1;x<n.length;x++){let t=n[x].dims.slice();for(let e=0;e<i.length;e++)if(e===r)o[r]+=t[e];else if(i[e]!==t[e])throw new Error("non concat dimensions must match")}let s=o.length,a=cr("coords",s),u=kt(s),l=le(),p=n.map(t=>t.dims),c=ee(s),d=new Array(p.length-1);d[0]=p[0][r];for(let x=1;x<d.length;x++)d[x]=d[x-1]+p[x][r];let h=c[r],f=c.slice(-2),g=c.join(),m=`if (${h} < ${d[0]}) {\n        return getChannel(\n            getX0(${g}), vec2(${f.join()}));\n        }`;for(let x=1;x<d.length;x++){let t=d[x-1];m+=`\n            if (${h} < ${d[x]}  && ${h} >= ${d[x-1]}) {\n              return getChannel(\n                getX${x}(${Ln(c,h,t)}),\n                vec2(${Ln(f,h,t)}));\n            }`}let b=d.length,y=d[d.length-1];m+=`\n            return getChannel(\n              getX${b}(${Ln(c,h,y)}),\n              vec2(${Ln(f,h,y)}));`;let w=G(t.session.backend.glContext.version),T=`\n          ${l}\n          float getValue(${c.map(t=>"int "+t)}) {\n            ${m}\n          }\n\n          void main() {\n            ${u} coords = getOutputCoords();\n            int lastDim = coords.${c[s-1]};\n            coords.${c[s-1]} = coords.${c[s-2]};\n            coords.${c[s-2]} = lastDim;\n\n            vec4 result = vec4(getValue(${a}), 0., 0., 0.);\n\n            ${a[s-1]} = ${a[s-1]} + 1;\n            if (${a[s-1]} < ${o[s-1]}) {\n              result.g = getValue(${a});\n            }\n\n            ${a[s-2]} = ${a[s-2]} + 1;\n            if (${a[s-2]} < ${o[s-2]}) {\n              result.a = getValue(${a});\n            }\n\n            ${a[s-1]} = ${a[s-1]} - 1;\n            if (${a[s-2]} < ${o[s-2]} &&\n                ${a[s-1]} < ${o[s-1]}) {\n              result.b = getValue(${a});\n            }\n            ${w.output} = result;\n          }\n        `;return{...e,output:{dims:o,type:n[0].type,textureType:2},shaderSource:T,hasMain:!0}},Dl=(t,e,n)=>{let r=Xh(e.length,n.cacheKey);return{...r,get:()=>Kh(t,r,e,n.axis)}},Ln=(t,e,n)=>{let r=t.indexOf(e);return t.map((t,e)=>e===r?`${t} - ${n}`:t).join()}}),$l,Jh,Yh,Zh,kl,Qh,tm,em,Bl,rm,Fl=O(()=>{vt(),j(),Ll(),$l=(t,e,n)=>(rm(e),t.session.pack&&e[0].dims.length>1?[t.run(Dl(t,e,n),e)]:[t.run(Zh(t,e,n),e)]),Jh=(t,e)=>({name:"Concat",inputNames:Array.from({length:t},(t,e)=>`X${e}`),inputTypes:Array(t).fill(0),cacheHint:e}),Yh=(t,e,n,r)=>{let i=n[0].dims.slice();if(r>
vendor: 4,482 bytes, line 6
6=i.length||r<-1*i.length)throw new Error("axis specified for concat doesn't match input dimensionality");r<0&&(r=i.length+r);let o=i.slice(0);for(let c=1;c<n.length;c++){let t=n[c].dims.slice();for(let e=0;e<i.length;e++)if(e===r)o[r]+=t[e];else if(i[e]!==t[e])throw new Error("non concat dimensions must match")}let s=o.length,a=new Array(n.length),u=0;for(let c=0;c<a.length;++c)u+=n[c].dims[r],a[c]=u;let l="";l=n.length<5?kl(a):Qh(a);let p=`\n        ${tm(n.length,s)}\n        ${em(a)}\n        ${l}\n        float process(int indices[${s}]) {\n          int textureIndex = getTextureWhereDataResides (indices[${r}]);\n\n          if(textureIndex != 0) {\n            indices[${r}] = indices[${r}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));\n          }\n\n          return fetchDataFromCorrectTexture(textureIndex, indices);\n        }`;return{...e,output:{dims:o,type:n[0].type,textureType:0},shaderSource:p}},Zh=(t,e,n)=>{let r=Jh(e.length,n.cacheKey);return{...r,get:()=>Yh(t,r,e,n.axis)}},kl=t=>`int getTextureWhereDataResides(int index) {\n      ${t.map((t,e)=>`if(index<${t}) {return ${e};}\n`).join("")}\n    }`,Qh=t=>kl(t),tm=(t,e)=>{let n=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${e}]) {`];for(let r=0;r<t;++r)0===r?n.push(`\tif (textureIndex == ${r}) { return _X${r}(indices); }`):r===t-1?n.push(`\telse { return _X${r}(indices); }`):n.push(`\telse if (textureIndex == ${r}) { return _X${r}(indices); }`);return n.push("\t}"),n.join("\n")},em=t=>{let e=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let n=0;n<t.length;++n)0===n?e.push(`\tif (index == ${n}) { return ${t[n]}; }`):n===t.length-1?e.push(`\telse { return ${t[n]}; }`):e.push(`\telse if (index == ${n}) { return ${t[n]}; }`);return e.push("\t}"),e.join("\n")},Bl=t=>W({axis:t.attributes.getInt("axis")}),rm=t=>{if(!t||t.length<1)throw new Error("too few inputs");let e=t[0].type,n=t[0].dims.length;if("string"===e)throw new Error("string tensor is not supported yet");for(let r of t){if(r.type!==e)throw new Error("input tensors should be one type");if(r.dims.length!==n)throw new Error("input tensors should have the same shape")}}});function nm(){return qt("abs")}function om(){return qt("acos")}function im(){return qt("asin")}function am(){return qt("atan")}function sm(){return qt("ceil")}function um(){return qt("cos")}function lm(t){let e="elu";return{body:`\n  const float alpha = float(${t});\n\n  float ${e}_(float a) {\n    return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;\n  }\n  vec4 ${e}_(vec4 v) {\n    return vec4(${e}_(v.x), ${e}_(v.y), ${e}_(v.z), ${e}_(v.w));\n  }\n  `,name:e,type:0}}function fm(){return qt("exp")}function cm(){return qt("floor")}function ci(t,e){let n="clip";return{body:`\n  const float min = float(${t});\n  const float max = float(${e});\n\n  float ${n}_(float a) {\n    return clamp(a, min, max);\n  }\n  vec4 ${n}_(vec4 v) {\n    return clamp(v, min, max);\n  }\n  `,name:n,type:0}}function pm(){let t="indentity";return{body:`\n  float ${t}_(float a) {\n    return a;\n  }\n  vec4 ${t}_(vec4 v) {\n    return v;\n  }\n  `,name:t,type:0}}function dm(t){let e="leakyRelu";return{body:`\n  const float alpha = float(${t});\n\n  float ${e}_(float a) {\n    return a < 0.0 ? a * alpha : a;\n  }\n  vec4 ${e}_(vec4 v) {\n    return vec4(${e}_(v.x), ${e}_(v.y), ${e}_(v.z), ${e}_(v.w));\n  }\n  `,name:e,type:0}}function hm(){return qt("log")}function mm(){let t="neg";return{body:`\n  float ${t}_(float a) {\n    return -a;\n  }\n  vec4 ${t}_(vec4 v) {\n    return -v;\n  }\n  `,name:t,type:0}}function bm(){let t="not";return{body:`\n  float ${t}_(float a) {\n    return float( ! bool(a) );\n  }\n  bool ${t}_(bool a) {\n    return !a;\n  }\n  vec4 ${t}_(vec4 v) {\n    return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));\n  }\n  bvec4 ${t}_(bvec4 v) {\n    return bvec4(!v.x, !v.y, !v.z, !v.w);\n  }\n  `,name:t,type:0}}function gm(){return qt("sin")}function pi(){let t="relu";return{body:`\n  float ${t}_(float a) {\n    return max( a, 0.0 );\n  }\n  vec4 ${t}_(vec4 v) {\n    return max( v, 0.0 );\n  }\n  `,name:t,type:0}}function di(){let t="sigmoid";return{body:`\n  float ${t}_(float a) {\n    return 1.0 / (1.0 + exp(-a));\n  }\n  vec4 ${t}_(vec4 v) {\n    return 1.0 / (1.0 + exp(-v));\n  }\n  `,name:t,type:0}}function ym(){return qt("sqrt")}function xm(){return qt("tan")}function Tm(){let t="tanh";return{body:`\n  float ${t}_(float a) {\n    a = clamp(a, -10., 10.);\n    a = exp(2.*a);
6\n    return (a - 1.) / (a + 1.);\n  }\n  vec4 ${t}_(vec4 v) {\n    v = clamp(v, -10., 10.);\n    v = exp(2.*v);\n    return (v - 1.) / (v + 1.);\n  }\n  `,name:t,type:0}}function qt(t){return{body:`\n  float ${t}_(float a) {\n    return ${t}(a);\n  }\n  vec4 ${t}_(vec4 v) {\n    return ${t}(v);\n  }\n  `,name:t,type:0}}var wm,dt,Cl,Nl,Rl,Gl,hi,Ml,Ul,vm,Vl,zl,Wl,Hl,ql,jl,mi,Xl,Kl,Jl,Yl,Zl,Ql,tf,ef,rf,nf,of,bi=O(()=>{vt(),Y(),be(),st(),j(),wm=(t,e,n,r)=>{let i=t.session.pack?2:0,o=G(t.session.backend.glContext.version);return{...e,output:{dims:n.dims,type:n.type,textureType:i},shaderSource:`\n     ${r.body}\n     void main() {\n       vec4 v = ${o.texture2D}(A, TexCoords);\n       v = ${r.name}_(v);\n       ${o.output} = v;\n     }\n     `,hasMain:!0}},dt=(t,e,n,r)=>{let i=t.session.pack?2:0,o={name:n.name,inputTypes:[i],inputNames:["A"],cacheHint:r};return{...o,get:()=>wm(t,o,e,n)}},Cl=(t,e)=>[t.run(dt(t,e[0],nm()),e)],Nl=(t,e)=>[t.run(dt(t,e[0],om()),e)],Rl=(t,e)=>[t.run(dt(t,e[0],im()),e)],Gl=(t,e)=>[t.run(dt(t,e[0],am()),e)],hi=(t,e,n)=>[t.run(dt(t,e[0],ci(n.min,n.max),n.cacheKey),e)],Ml=t=>W({min:t.attributes.getFloat("min",Ue),max:t.attributes.getFloat("max",Ve)}),Ul=(t,e)=>{let n=vm(t,e);return hi(t,[e[0]],n)},vm=(t,e)=>{if(e.length>=3&&(!t.session.isInitializer(e[1].dataId)||!t.session.isInitializer(e[2].dataId)))throw new Error("dynamic clip attributes are not allowed");let n=e.length>=3?e[1].numberData[0]:Ue,r=e.length>=3?e[2].numberData[0]:Ve;return W({min:n,max:r})},Vl=(t,e)=>[t.run(dt(t,e[0],sm()),e)],zl=(t,e)=>[t.run(dt(t,e[0],um()),e)],Wl=(t,e,n)=>[t.run(dt(t,e[0],lm(n.alpha),n.cacheKey),e)],Hl=t=>W({alpha:t.attributes.getFloat("alpha",1)}),ql=(t,e)=>[t.run(dt(t,e[0],fm()),e)],jl=(t,e)=>[t.run(dt(t,e[0],cm()),e)],mi=(t,e)=>[t.run(dt(t,e[0],pm()),e)],Xl=(t,e,n)=>[t.run(dt(t,e[0],dm(n.alpha),n.cacheKey),e)],Kl=t=>W({alpha:t.attributes.getFloat("alpha",.01)}),Jl=(t,e)=>[t.run(dt(t,e[0],hm()),e)],Yl=(t,e)=>[t.run(dt(t,e[0],mm()),e)],Zl=(t,e)=>[t.run(dt(t,e[0],bm()),e)],Ql=(t,e)=>[t.run(dt(t,e[0],pi()),e)],tf=(t,e)=>[t.run(dt(t,e[0],di()),e)],ef=(t,e)=>[t.run(dt(t,e[0],gm()),e)],rf=(t,e)=>[t.run(dt(t,e[0],ym()),e)],nf=(t,e)=>[t.run(dt(t,e[0],xm()),e)],of=(t,e)=>[t.run(dt(t,e[0],Tm()),e)]});function fe(t){let e;switch(t.activation){case"Relu":e=pi();break;case"Sigmoid":e=di();break;case"Clip":e=ci(t.clipMin,t.clipMax);break;default:return{activationFunction:"",applyActivation:""}}let n=e.name;return{activationFunction:e.body,applyActivation:`value = ${n}_(value);`}}var pr,He=O(()=>{Y(),bi(),pr=t=>{let e=t.getString("activation","");if("Clip"===e){let[n,r]=t.getFloats("activation_params",[Ue,Ve]);return{activation:e,clipMax:r,clipMin:n,activationCacheKey:`${e}:${n},${r}`}}return{activation:e,activationCacheKey:e}}}),_m,Om,af,sf=O(()=>{Mt(),st(),j(),$n(),He(),_m=(t,e)=>({name:"GroupedConv",inputNames:t?["X","W","Bias"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:e}),Om=(t,e,n,r)=>{let i=e.length>2?"value += getBias(output_channel);":"",o=e[0].dims.slice(),s=e[1].dims.slice(),a=s[0]/r.group;tt.verbose("GroupedConv",`autpPad:${r.autoPad}, dilations:${r.dilations}, group:${r.group}, kernelShape:${r.kernelShape}, pads:${r.pads}, strides:${r.strides}`);let u=dr(o,s,r.dilations,r.pads,r.strides),l=G(t.session.backend.glContext.version),{activationFunction:p,applyActivation:c}=fe(r),d=`\n  const ivec2 strides = ivec2(${r.strides[0]}, ${r.strides[1]});\n  const ivec2 pads = ivec2(${r.pads[0]}, ${r.pads[1]});\n  ${p}\n  void main() {\n    ivec4 coords = getOutputCoords();\n    int batch = coords.x;\n    int output_channel = coords.y;\n    ivec2 xRCCorner = coords.zw * strides - pads;\n    int group_id = output_channel / ${a};\n\n    float value = 0.0;\n    for (int wInChannel = 0; wInChannel < ${s[1]}; wInChannel++) {\n      int input_channel = group_id * ${s[1]} + wInChannel;\n      for (int wHeight = 0; wHeight < ${s[2]}; wHeight++) {\n        int xHeight = xRCCorner.x + wHeight * ${r.dilations[0]};\n\n        if (xHeight < 0 || xHeight >= ${o[2]}) {\n          continue;\n        }\n\n        for (int wWidth = 0; wWidth < ${s[3]}; wWidth++) {\n          int xWidth = xRCCorner.y + wWidth * ${r.dilations[1]};\n          if (xWidth < 0 || xWidth >= ${o[3]}) {\n            continue;\n          }\n\n          float xVal = getX(batch, input_channel, xWidth, xHeight);\n          float wVal = getW(output_channel, wInChannel, wWidth, wHeight);\n          value += xVal*wVal;\n        }\n      }\n    }\n    ${i}\n    ${c}\n    ${l.output} = vec4(value, .0, .0, .0);\n  }\n`;return{...n,output:{dims:u,type:e[0].type,textureType:0},shaderSource:d,hasMain:!0}},af=(t,e,n)=>{let r=_m(e.length>2,n.cacheKey);return{...r,get:()=>Om(t,e,r,n)}}}),Sm,Am,uf,lf=O(()=>{st(),j(),We(),Sm=t=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[2],cacheHint:t}),Am=(t,e,n,r,i,o)=>{let s=n.dims,a=r.dims,u=i.length,l=[a[1]*a[2]*a[3],i[2]*i[3]],p=a[2]*a[3],c=le(),d=G(t.session.backend.glContext.version),h="";for(let g=0;g<=1;g++)for(let t=0;t<=1;t++)h+=`\n            blockIndex = rc.x + ${t};\n            pos = rc.y + ${g};\n\n            if(blockIndex < ${l[1]} && pos < ${l[0]}) {\n              offsetY = int(blockIndex / (${i[u-1]})) * ${o.strides[0]} -\n                ${o.pads[0]};\n              d0 = offsetY + ${o.dilations[0]} * (imod(pos, ${p}) / ${a[2]});\n\n              if(d0 < ${s[2]} && d0 >= 0) {\n                offsetX = imod(blockIndex, ${i[u-1]}) * ${o.strides[1]} -\n                  ${o.pads[1]};\n                d1 = offsetX + ${o.dilations[1]} * imod(imod(pos, ${p}), ${a[2]});\n\n                if(d1 < ${s[3]} && d1 >= 0) {\n\n                  ch = int(float(pos)/ ${p}.);\n                    innerDims = vec2(d0, d1);\n                    result[${2*g+t}] = getChannel(\n                      getA(0, ch, int(innerDims.x),\n                      int(innerDims.y)), innerDims);\n                }\n              }\n            }\n\n          `;let f=`\n      ${c}\n\n      void main() {\n        ivec2 rc = getOutputCoords();\n          vec4 result = vec4(0.0);\n          int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n          vec2 innerDims;\n          ${h}\n          ${d.output} = result;\n      }\n            `;return{...e,output:{dims:l,type:n.type,textureType:2},shaderSource:f,hasMain:!0}},uf=(t,e,n,r,i)=>{let o=Sm(i.cacheKey);return{...o,get:()=>Am(t,o,e,n,r,i)}}});
6function Em(t,e,n){let r=e[0].dims,i=e[1].dims,o=$t.calcShape(r,i,!0);if(!o)throw new Error("Can't use matmul on the given tensors");let s=kt(o.length),a=ee(),{activationFunction:u,applyActivation:l}=fe(n),p=e.length>2,c=p?"value += getBiasForMatmul();":"",d=p?`${yi(s,a,e[2].dims,o,!1)}`:"",h=o.length,f=r.length,g=i.length,m=`\n    ${u}\n    ${d}\n    float process(int indices[${h}]) {\n        int a[${f}];\n        int b[${g}];\n        bcastMatmulIndices_A(indices, a);\n        bcastMatmulIndices_B(indices, b);\n\n        float value;\n        for (int k=0; k<${r[r.length-1]}; ++k) {\n            a[${f-1}] = k;\n            b[${g-2}] = k;\n            value += _A(a) * _B(b);\n        }\n        ${c}\n        ${l}\n        return value;\n    }`;return{...t,output:{dims:o,type:e[0].type,textureType:0},shaderSource:m}}function gi(t,e){let n=Pm(t.length>2,e.activationCacheKey);return{...n,get:()=>Em(n,t,e)}}function yi(t,e,n,r,i){let o="",s=n.length,a=r.length,u=a-s;o=a<2&&s>0?"coords":n.map((t,n)=>`coords.${e[n+u]}`).join(", ");let l=$t.getBroadcastDims(n,r).map(t=>`coords.${e[t+u]} = 0;`).join("\n"),p="vec4(outputValue.xx, outputValue.yy)";return 1===B.size(n)&&(p="vec4(outputValue.x)"),i?`\nvec4 getBiasForMatmul() {\n  ${t} coords = getOutputCoords();\n  ${l}\n  vec4 outputValue = getBias(${o});\n  return ${p};\n}`:`\nfloat getBiasForMatmul() {\n  ${t} coords = getOutputCoords();\n  ${l}\n  return getBias(coords.x);\n}`}var ff,cf,Pm,Dm,kn=O(()=>{Y(),j(),ue(),He(),xi(),ff=(t,e,n)=>(Dm(e),t.session.pack?[t.run(Bn(t,e,n),e)]:[t.run(gi(e,n),e)]),cf=t=>pr(t.attributes),Pm=(t,e)=>({name:"MatMul",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[0,0,0]:[0,0],cacheHint:e}),Dm=t=>{if(!t||2!==t.length)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.");if("float32"!==t[0].type&&"float64"!==t[0].type||"float32"!==t[1].type&&"float64"!==t[1].type)throw new Error("inputs should be float type");if(t[0].type!==t[1].type)throw new Error("inputs types should match")}});function km(t,e,n,r){let i=[],o=[],s=n[0].dims,a=n[1].dims,u=s.length,l=a.length,p=r.length,c=p-u,d=p-l;i=s.map((t,n)=>`coords.${e[n+c]}`),i[u-1]="i*2",i.join(", "),o=a.map((t,n)=>`coords.${e[n+d]}`),o[l-2]="i*2",o.join(", ");let h=$t.getBroadcastDims(s,r),f=$t.getBroadcastDims(a,r),g=h.map(t=>`coords.${e[t+c]} = 0;`).join("\n"),m=f.map(t=>`coords.${e[t+d]} = 0;`).join("\n"),b=`int lastDim = coords.${e[p-1]};\n  coords.${e[p-1]} = coords.${e[p-2]};\n  coords.${e[p-2]} = lastDim;`;return`\nvec4 getAAtOutCoordsMatmul(int i) {\n  ${t} coords = getOutputCoords();\n  ${b}\n  ${g}\n  vec4 outputValue = getA(${i});\n  return outputValue;\n}\n\nvec4 getBAtOutCoordsMatmul(int i) {\n  ${t} coords = getOutputCoords();\n  ${b}\n  ${m}\n  vec4 outputValue = getB(${o});\n  return outputValue;\n}`}function Bm(t,e){let n="";for(let r=0;r<e-2;r++)n+=`rc.${t[r]}, `;return n+=`rc.${t[e-2]}, i*2`,n}function Fm(t,e){let n="";for(let r=0;r<e-2;r++)n+=`rc.${t[r]}, `;return n+=`i*2, rc.${t[e-1]}`,n}var Lm,$m,Bn,xi=O(()=>{Y(),st(),j(),ue(),He(),kn(),Lm=(t,e)=>({name:"MatMul (packed)",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[2,2,2]:[2,2],cacheHint:e}),$m=(t,e,n,r)=>{let i=n.length>2,o=i?"value += getBiasForMatmul();":"",s=n[0].dims,a=n[1].dims,u=$t.calcShape(s,a,!0),l=!B.areEqual(n[0].dims,n[1].dims);if(!u)throw new Error("Can't use matmul on the given tensors");let p=s[s.length-1],c=Math.ceil(p/2),d=s.length,h=a.length,f=G(t.session.backend.glContext.version),g=kt(u.length),m=u.length,b=ee(),{activationFunction:y,applyActivation:w}=fe(r),T=i?`${yi(g,b,n[2].dims,u,!0)}`:"",x=l?`${km(g,b,n,u)}`:"",v=l?"getAAtOutCoordsMatmul(i)":`getA(${Bm(b,d)})`,_=l?"getBAtOutCoordsMatmul(i)":`getB(${Fm(b,h)})`,O=`\n            ${x}\n            ${T}\n            ${y}\n            void main() {\n              ${l?"":`${g} rc =\n          getOutputCoords(); int lastDim = rc.${b[m-1]}; rc.${b[m-1]} =\n          rc.${b[m-2]}; rc.${b[m-2]} = lastDim;\n      `}\n\n              vec4 value = vec4(0);\n              for (int i = 0; i < ${c};
6 i++) {\n                vec4 a = ${v};\n                vec4 b = ${_};\n\n                value += (a.rrbb * b.rgrg);\n                value += (a.ggaa * b.baba);\n              }\n              ${o}\n              ${w}\n              ${f.output} = value;\n            }`;return{...e,output:{dims:u,type:n[0].type,textureType:2},shaderSource:O,hasMain:!0}},Bn=(t,e,n)=>{let r=Lm(e.length>2,n.activationCacheKey);return{...r,get:()=>$m(t,r,e,n)}}}),pf,df=O(()=>{$n(),lf(),xi(),pf=(t,e,n)=>{let r=e[0].dims,i=e[1].dims,o=dr(r,i,n.dilations,n.pads,n.strides),s=t.run(uf(t,e[0],e[1],o,n),[e[0]]),a=t.reshapePacked(e[1],[i[0],i[1]*i[2]*i[3]]),u=3===e.length?[a,s,e[2]]:[a,s],l=t.run(Bn(t,u,n),u);return t.reshapePacked(l,o)}}),Cm,Nm,hf,Ti,wi=O(()=>{j(),Cm=t=>({name:"Im2Col",inputNames:["X"],inputTypes:[0],cacheHint:t}),Nm=(t,e,n,r,i,o)=>{let s=n.dims,a=r.dims,u=i.length,l=Ti(s,a,i,4),p=`\n        const int XC = ${s[1]};\n        const int XH = ${s[2]};\n        const int XW = ${s[3]};\n        const int KH = ${o.kernelShape[0]};\n        const int KW = ${o.kernelShape[1]};\n        const int dilationH = ${o.dilations[0]};\n        const int dilationW = ${o.dilations[1]};\n        const int strideH = ${o.strides[0]};\n        const int strideW = ${o.strides[1]};\n        const int padH = ${o.pads[0]};\n        const int padW = ${o.pads[1]};\n        const int KHKW = KH*KW;\n        const int XCKHKW = XC * KHKW;\n        const int outputChannels = 4;\n        vec4 process(int indices[${u}]) {\n          int b  = indices[0]; // batch size\n          int oh = indices[1] * strideH - padH; //output height\n          int ow = indices[2] * strideW - padW; //output width\n          int p = indices[3] * outputChannels; //patch\n          vec4 value = vec4(0.0);\n          for(int i=0; i < outputChannels; ++i) {\n            if(p < XCKHKW) {\n              int patchC = p / KHKW;\n              int patchH = (p - patchC*KHKW) / KW;\n              int patchW = (p - patchC*KHKW) - patchH * KW;\n              int xh2 = oh + patchH * dilationH;\n              int xw2 = ow + patchW * dilationW;\n              int x[${s.length}];\n              x[0] = b;\n              x[1] = patchC;\n              x[2] = xh2;\n              x[3] = xw2;\n              if(xh2 >= 0 &&\n                  xh2 < XH &&\n                  xw2 >= 0 &&\n                  xw2 < XW) {\n                value[i] = _X(x);\n              }\n            }\n            ++p;\n          }\n          return value;\n        }\n        `;return{...e,output:{dims:l,type:n.type,textureType:4},shaderSource:p}},hf=(t,e,n,r,i)=>{let o=Cm(i.cacheKey);return{...o,get:()=>Nm(t,o,e,n,r,i)}},Ti=(t,e,n,r=4)=>[n[0],n[2],n[3],Math.ceil(t[1]*e[2]*e[3]/r)]}),Rm,Gm,mf,bf=O(()=>{Y(),st(),j(),He(),wi(),Rm=(t,e)=>({name:"ConvDotProduct",inputNames:t?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:t?[0,4,0]:[0,4],cacheKey:e.activationCacheKey}),Gm=(t,e,n,r,i)=>{let o=n[0].dims,s=n[1].dims,a=[s[0],Math.ceil(o[1]*s[2]*s[3]/4)],u=Ti(o,s,r),[l,p]=t.calculateTextureWidthAndHeight(a,4),c=B.computeStrides(u),[d,h]=t.calculateTextureWidthAndHeight(u,4),f=r.length,g=n.length<3?"0.0":"_B(b)",m=Math.ceil(o[1]*s[2]*s[3]/4),{activationFunction:b,applyActivation:y}=fe(i),w=G(t.session.backend.glContext.version),T=`\n${b}\nfloat process(int indices[${f}]) {\n  int b[1];\n  b[0] = indices[1];\n  int im2col[4];\n  im2col[0] = indices[0];\n  im2col[1] = indices[2];\n  im2col[2] = indices[3];\n  int im2colOffset = im2col[0] * ${c[0]} + im2col[1] * ${c[1]} + im2col[2] * ${c[2]};\n  int kernelOffset = indices[1] * ${a[1]};\n  float value = ${g};\n  for (int i = 0; i < ${m}; ++i) {\n    vec2 im2colCoords = offsetToCoords(im2colOffset, ${d}, ${h});\n    vec2 kernelCoords = offsetToCoords(kernelOffset, ${l}, ${p});\n    value += dot(${w.texture2D}(Im2Col, im2colCoords), ${w.texture2D}(K, kernelCoords));\n    ++im2colOffset;\n    ++kernelOffset;\n  }\n  ${y}\n  return value;\n}`;return{...e,output:{dims:r,type:n[0].type,textureType:0},shaderSource:T}},mf=(t,e,n,r)=>{let i=Rm(e.length>2,r);return{...i,get:()=>Gm(t,i,e,n,r)}}}),dr,vi,Mm,Um,Vm,zm,Ii,Wm,$n=O(()=>{vt(),Y(),sf(),df(),bf(),He(),wi(),kn(),dr=(t,e,n,r,i)=>{let o=t[0],s=t.slice(2),a=s.length,u=e[0],l=e.slice(2).map((t,e)=>t+(t-1)*(n[e]-1)),p=s.map((t,e)=>t+r[e]+r[e+a]).map((t,e)=>Math.floor((t-l[e]+i[e])/i[e]));return[o,u].concat(...p)},vi=(t,e,n)=>(Wm(e,n),Mm(t,e,n)),Mm=(t,e,n)=>{let r=zm(n,e),i=t.session.pack,o=1===r.kernelShape[0]&&1===r.kernelShape[1];return r.group>1?[t.run(af(t,e,r),e)]:o&&i?[Um(t,e,r)]:i&&4===e[0].dims.length&&1===e[0].dims[0]&&!o?[pf(t,e,r)]:[Vm(t,e,r)]},Um=(t,e,n)=>{let r=e[0].dims,i=e[1].dims,o=dr(r,i,n.dilations,n.pads,n.strides),s=t.reshapeUnpacked(e[0],[r[1],r[2]*r[3]]),a=t.reshapeUnpacked(e[1],[i[0],i[1]]),u=e.length>2?[a,s,e[2]]:[a,s],l=t.run(gi(u,n),u);return t.reshapeUnpacked(l,o)},Vm=(t,e,n)=>{let r=e[0].dims,i=e[1].dims,o=dr(r,i,n.dilations,n.pads,n.strides),s=t.run(hf(t,e[0],e[1],o,n),[e[0]]),a=3===e.length?[s,e[1],e[2]]:[s,e[1]];return t.run(mf(t,e,o,n),a)},zm=(t,e)=>{let n=t.kernelShape.slice();if(0===t.kernelShape.length)for(let o=2;o<e[1].dims.length;++o)n.push(e[1].dims[o]);let r=t.pads.slice();Me.adjustPadsBasedOnAutoPad(e[0].dims,t.strides,t.dilations,n,r,t.autoPad);let i=Object.assign({},t);return Object.assign(i,{kernelShape:n,pads:r,cacheKey:t.cacheKey}),i},Ii=t=>{let e=t.attributes,n=pr(e),r=e.getString("auto_pad","NOTSET"),i=e.getInts("dilations",[1,1]),o=e.getInt("group",1),s=e.getInts("kernel_shape",[]),a=e.getInts("pads",[0,0,0,0]),u=e.getInts("strides",[1,1]);return W({autoPad:r,dilations:i,group:o,kernelShape:s,pads:a,strides:u,...n})},Wm=(t,e)=>{if(!t||2!==t.length&&3!==t.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==t[0].dims.length||4!==t[1].dims.length)throw new Error("currently only support 2-dimensional conv");if(t[0].dims[1]!==t[1].dims[1]*e.group)throw new 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[
60]))throw new Error("invalid bias");let n=t[0].dims.length-2;if(e.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(e.strides.length!==n)throw new Error(`strides should be ${n}D`);if(e.pads.length!==2*n)throw new Error(`pads should be ${2*n}D`);if(0!==e.kernelShape.length&&e.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape");if("float32"!==t[0].type||"float32"!==t[1].type)throw new Error("Conv input(X,W) should be float tensor");if(3===t.length&&"float32"!==t[2].type)throw new Error("Conv input(bias) should be float tensor")}}),Hm,qm,jm,gf,Xm,Km,Jm,Ym,Zm,Qm,yf,tb,xf=O(()=>{vt(),st(),j(),He(),Hm=(t,e,n,r,i,o)=>(t-1)*e+n+(r-1)*i+1-o,qm=(t,e,n,r,i)=>{let o=Math.floor(t/2);"SAME_UPPER"===e?(n[r]=o,n[i]=t-o):"SAME_LOWER"===e&&(n[r]=t-o,n[i]=o)},jm=(t,e,n,r,i,o,s,a)=>{let u=t.length-2,l=0===a.length;for(let p=0;p<u;++p){let c=l?t[p+2]*o[p]:a[p],d=Hm(t[p+2],o[p],i[p],e[p],n[p],c);qm(d,r,i,p,p+u),l&&a.push(o[p]*(t[p+2]-1)+s[p]+(e[p]-1)*n[p]+1-i[p]-i[p+u])}},gf=(t,e,n)=>(tb(e,n),Xm(t,e,n)),Xm=(t,e,n)=>{let r=Qm(n,e);return[Zm(t,e,r)]},Km=(t,e)=>({name:"ConvTranspose",inputNames:t?["X","W","B"]:["X","W"],inputTypes:t?[0,0,0]:[0,0],cacheHint:e}),Jm=(t,e,n,r)=>{let i=e.length>2?"getB(output_channel)":"0.0",o=e[0].dims,s=e[1].dims,a=s[1],u=s[0]/r.group,l=[e[0].dims[0],e[1].dims[1]*r.group,...r.outputShape],p=G(t.session.backend.glContext.version),{activationFunction:c,applyActivation:d}=fe(r),h=`\n  const ivec2 strides = ivec2(${r.strides[0]}, ${r.strides[1]});\n  const ivec2 pads = ivec2(${r.pads[0]}, ${r.pads[1]});\n  ${c}\n  void main() {\n    ivec4 coords = getOutputCoords();\n    int batch = coords.x;\n    int output_channel = coords.y;\n\n    ivec2 loc = coords.zw + pads;\n\n    int group_id = output_channel / ${a};\n    int wOutChannel = output_channel - group_id * ${a};\n\n    float value = ${i};\n    for (int inChannelOffset = 0; inChannelOffset < ${u}; inChannelOffset++) {\n      int input_channel = group_id * ${u} + inChannelOffset;\n      for (int wWOff = 0; wWOff < ${s[2]}; wWOff++) {\n        for (int wHOff = 0; wHOff < ${s[3]}; wHOff++) {\n          ivec2 wOff = ivec2(wWOff * ${r.dilations[0]}, wHOff * ${r.dilations[1]});\n          ivec2 wLoc = loc - wOff;\n          ivec2 wLocIn = wLoc / strides;\n          if (\n            wLocIn * strides == wLoc &&\n            wLocIn.x >= 0 && wLocIn.x < ${o[2]} &&\n            wLocIn.y >= 0 && wLocIn.y < ${o[3]}\n          ) {\n            float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);\n            float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);\n            value += xVal * wVal;\n          }\n        }\n      }\n    }\n    ${d}\n    ${p.output} = vec4(value, .0, .0, .0);\n  }\n`;return{...n,output:{dims:l,type:e[0].type,textureType:0},shaderSource:h,hasMain:!0}},Ym=(t,e,n)=>{let r=Km(e.length>2,n.cacheKey);return{...r,get:()=>Jm(t,e,r,n)}},Zm=(t,e,n)=>t.run(Ym(t,e,n),e),Qm=(t,e)=>{let n=t.kernelShape.slice();if(0===t.kernelShape.length)for(let a=2;a<e[1].dims.length;++a)n.push(e[1].dims[a]);let r=t.pads.slice(),i=t.outputShape.slice(),o=e[0].dims;jm(o,n,t.dilations,t.autoPad,r,t.strides,t.outputPadding,i);let s=Object.assign({},t);return Object.assign(s,{kernelShape:n,pads:r,outputShape:i,cacheKey:t.cacheKey}),s},yf=t=>{let e=t.attributes,n=pr(e),r=e.getString("auto_pad","NOTSET"),i=e.getInts("dilations",[1,1]),o=e.getInt("group",1),s=e.getInts("kernel_shape",[]),a=e.getInts("output_padding",[0,0]),u=e.getInts("output_shape",[]),l=e.getInts("pads",[0,0,0,0]),p=e.getInts("strides",[1,1]);return W({autoPad:r,dilations:i,group:o,kernelShape:s,outputPadding:a,outputShape:u,pads:l,strides:p,...n})},tb=(t,e)=>{if(!t||2!==t.length&&3!==t.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==t[0].dims.length||4!==t[1].dims.length)throw new Error("currently only support 2-dimensional conv");if(t[0].dims[1]!==t[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");let n=t[1].dims[1]*e.group;if(3===t.length&&(1!==t[2].dims.length||t[2].dims[0]!==n))throw new Error("invalid bias");let r=t[0].dims.length-2;if(e.dilations.length!==r)throw new Error(`dilations should be ${r}D`);if(e.strides.length!==r)throw new Error(`strides should be ${r}D`);if(e.pads.length!==2*r)throw new Error(`pads should be ${2*r}D`);if(e.outputPadding.length!==r)throw new Error(`output_padding should be ${r}D`);if(0!==e.kernelShape.length&&e.kernelShape.length!==t[1].dims.length-2)throw new Error("invalid kernel shape");if(0!==e.outputShape.length&&e.outputShape.length!==t[0].dims.length-2)throw new Error("invalid output shape");if("float32"!==t[0].type||"float32"!==t[1].type)throw new Error("ConvTranspose input(X,W) should be float tensor");if(3===t.length&&"float32"!==t[2].type)throw new Error("ConvTranspose input(bias) should be float tensor")}}),Tf,qe,wf,eb,vf,rb,nb,ob,Fn=O(()=>
6{vt(),Y(),j(),Tf={name:"Transpose",inputNames:["A"],inputTypes:[0]},qe=(t,e,n)=>(ob(e),[t.run({...Tf,cacheHint:n.cacheKey,get:()=>eb(t,e[0],n.perm)},e)]),wf=t=>W({perm:t.attributes.getInts("perm",[])}),eb=(t,e,n)=>{let r=e.dims;n=vf(r,n);let i=rb(r,n),o=r.length,s=`\n      ${nb("perm",n,o)}\n      float process(int indices[${o}]) {\n        int a[${o}];\n        perm(a, indices);\n        return _A(a);\n      }`;return{...Tf,output:{dims:i,type:e.type,textureType:0},shaderSource:s}},vf=(t,e)=>(e&&e.length!==t.length&&(e=[...t.keys()].reverse()),e),rb=(t,e)=>(e=vf(t,e),B.sortBasedOnPerm(t,e)),nb=(t,e,n)=>{let r=[];r.push(`void ${t}(out int a[${n}], int src[${n}]) {`);for(let i=0;i<n;++i)r.push(`\ta[${e[i]}]=src[${i}];`);return r.push("\t}"),r.join("\n")},ob=t=>{if(!t||1!==t.length)throw new Error("Transpose requires 1 input.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw new Error("input should be float tensor")}}),If,_f,ib,Of=O(()=>{Fn(),If=(t,e,n)=>{ib(e);let r=n.blocksize,i=r*r,o="DCR"===n.mode?[0,3,4,1,5,2]:[0,1,4,2,5,3],s="DCR"===n.mode?[e[0].dims[0],r,r,e[0].dims[1]/i,e[0].dims[2],e[0].dims[3]]:[e[0].dims[0],e[0].dims[1]/i,r,r,e[0].dims[2],e[0].dims[3]],a=t.reshapeUnpacked(e[0],s),u={perm:o,cacheKey:`${o}`},[l]=qe(t,[a],u),p=[e[0].dims[0],e[0].dims[1]/i,e[0].dims[2]*r,e[0].dims[3]*r];return[t.reshapeUnpacked(l,p)]},_f=t=>{let e=t.attributes.getInt("blocksize");if(e<1)throw new Error(`blocksize must be >= 1, but got : ${e} for DepthToSpace`);let n=t.attributes.getString("mode","DCR");if("DCR"!==n&&"CRD"!==n)throw new Error(`unrecognized mode: ${n} for DepthToSpace`);return{mode:n,blocksize:e}},ib=t=>{if(1!==t.length)throw new Error(`DepthToSpace expect 1 inputs, but got ${t.length}`);if("string"===t[0].type||4!==t[0].dims.length)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}}),Sf,Af,ab,Pf=O(()=>{Y(),Sf=(t,e,n)=>{ab(e,n);let r=B.flattenShape(e[0].dims,n);return[t.reshapeUnpacked(e[0],r)]},Af=t=>t.attributes.getInt("axis",1),ab=(t,e)=>{if(!t||1!==t.length)throw new Error("Flatten requires 1 input.");let n=t[0].dims.length;if(0===n)throw new Error("scalar tensor is not supported.");if(e<-n||e>n)throw new Error("Invalid axis");if("string"===t[0].type)throw new Error("string tensor is not supported.")}}),Ae,Rr=O(()=>{Ae=["float32","float64","int32","int16","int8","uint16","uint32","uint8"]}),Ef,Df,sb,ub,lb,fb,Lf=O(()=>{vt(),Rr(),Y(),j(),Ef=(t,e,n)=>(fb(e,n.axis),[t.run(lb(t,e,n),e)]),Df=t=>W({axis:t.attributes.getInt("axis",0)}),sb={name:"Gather",inputNames:["A","B"],inputTypes:[0,0]},ub=(t,e,n,r)=>{let i=n[0].dims.slice(),o=n[1].dims.slice(),s=new Array(i.length+o.length-1);r=B.normalizeAxis(r,i.length);let a=[];for(let l=0;l<s.length;l++)l<r?(s[l]=i[l],a.push(`inputIdx[${l}] = outputIdx[${l}];`)):l<r+o.length?(s[l]=o[l-r],a.push(`indexDataIdx[${l-r}] = outputIdx[${l}];`)):(s[l]=i[l-o.length+1],a.push(`inputIdx[${l-o.length+1}] = outputIdx[${l}];`));let u=`\n      float process(int outputIdx[${s.length||1}]) {\n        int inputIdx[${i.length}];\n        int indexDataIdx[${o.length||1}];\n        indexDataIdx[0] = 0;\n        ${a.join("\n        ")}\n        int idx = int(_B(indexDataIdx));\n        inputIdx[${r}] = idx < 0 ? idx + ${i[r]} : idx;\n        return _A(inputIdx);\n      }`;return{...e,output:{dims:s,type:n[0].type,textureType:0},shaderSource:u}},lb=(t,e,n)=>{let r={...sb,cacheHint:n.cacheKey};return{...r,get:()=>ub(t,r,e,n.axis)}},fb=(t,e)=>{if(!t||2!==t.length)throw new Error("Gather requires 2 inputs.");let n=t[0].dims.length;if(n<1)throw new Error("Invalid input shape.");if(e<-n||e>n-1)throw new Error("Invalid axis.");if(-1===Ae.indexOf(t[0].type))throw new Error("Invaid input type.");if("int32"!==t[1].type&&"int16"!==t[1].type)throw new Error("Invaid input type.")}}),_i,$f,kf,Bf,cb,pb,db,Ff=O(()=>{vt(),Y(),j(),_i=(t,e,n)=>(db(e,n),[t.run(cb(e,n),e)]),$f=(t,e)=>{let n=0!==t.attributes.getInt("transA",0),r=0!==t.attributes.getInt("transB",0),i=t.attributes.getFloat("alpha",1),o=t.attributes.getFloat("beta",1);return W({transA:n,transB:r,alpha:i,beta:o,isOptionalC:e})},kf=t=>$f(t,!1),Bf=t=>$f(t,!0),cb=(t,e)=>{let n={name:"Gemm",inputNames:3===t.length?["A","B","C"]:["A","B"],inputTypes:3===t.length?[0,0,0]:[0,0],key:e.cacheKey};return{...n,get:()=>pb(n,t,e)}},pb=(t,e,n)=>{let r=e[0].dims.slice(),i=e[1].dims.slice(),[o,s]=_n.getShapeOfGemmResult(r,n.transA,i,n.transB,3===e.length?e[2].dims:void 0),a=[o,s];if(!a)throw new Error("Can't use gemm on the given tensors");let u=r[r.length-1],l="";n.transA&&(u=r[0]),n.transA&&n.transB?l="value += _A_T(a) * _B_T(b);":n.transA&&!n.transB?l="value += _A_T(a) * _B(b);":!n.transA&&n.transB?l="value += _A(a) * _B_T(b);":!n.transA&&!n.transB&&(l="value += _A(a) * _B(b);");let p=a.length,c=`\n      float process(int indices[${p}]) {\n          int a[${p}];\n          int b[${p}];\n          ${3===e.length?`int c[${e[2].dims.length}];`:""}\n\n          copyVec(indices, a);\n          copyVec(indices, b);\n          ${3===e.length?"bcastIndices_C(indices, c);":""}\n\n          float value = 0.0;
6\n          for (int k=0; k<${u}; ++k) {\n              a[${p-1}] = k;\n              b[${p-2}] = k;\n              ${l}\n          }\n\n          value = value * alpha;\n          ${3===e.length?"value += beta * _C(c);":""}\n          return value;\n      }`;return{...t,output:{dims:a,type:e[0].type,textureType:0},variables:[{name:"alpha",type:"float",data:n.alpha},{name:"beta",type:"float",data:n.beta}],shaderSource:c}},db=(t,e)=>{if(!t)throw new Error("Input is missing");if(e.isOptionalC&&(t.length<2||t.length>3))throw new Error("Invaid input shape.");if(!e.isOptionalC&&3!==t.length)throw new Error("Gemm requires 3 inputs");if(3===t.length&&1!==t[2].dims.length&&2!==t[2].dims.length)throw new 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 new Error("Invalid input type.");if(t[0].type!==t[1].type||3===t.length&&t[0].type!==t[2].type)throw new Error("Input types are mismatched")}}),Cf,Nf,hb,mb,bb,gb,yb,Rf=O(()=>{vt(),j(),Cf=(t,e,n)=>(yb(e),[t.run(bb(t,e,n),e)]),Nf=t=>{let e=t.attributes.getFloat("scale"),n=t.attributes.getFloats("bias");return W({scale:e,bias:n})},hb={name:"ImageScaler",inputNames:["X"],inputTypes:[0]},mb=(t,e,n,r)=>{let i=n[0].dims.slice(),o=i.length,s=`\n      ${gb(r.bias.length)}\n      float process(int indices[${o}]) {\n        return _X(indices) * scale + getBias(bias, indices[1]);\n      }`;return{...e,output:{dims:i,type:n[0].type,textureType:0},variables:[{name:"bias",type:"float",arrayLength:r.bias.length,data:r.bias},{name:"scale",type:"float",data:r.scale}],shaderSource:s}},bb=(t,e,n)=>{let r={...hb,cacheHint:n.cacheKey};return{...r,get:()=>mb(t,r,e,n)}},gb=t=>{let e=[`float getBias(float bias[${t}], int channel) {`];for(let n=0;n<t;++n)0===n?e.push(`\tif (channel == ${n}) { return bias[${n}]; }`):n===t-1?e.push(`\telse { return bias[${n}]; }`):e.push(`\telse if (channel == ${n}) { return bias[${n}]; }`);return e.push("\t}"),e.join("\n")},yb=t=>{if(!t||1!==t.length)throw new Error("ImageScaler requires 1 input.");if(4!==t[0].dims.length)throw new Error("Invalid input shape.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw new Error("Invalid input type.")}}),Mf,Uf,Gf,xb,Tb,wb,vb,Ib,_b,Vf=O(()=>{st(),j(),Mf=(t,e,n)=>{_b(e);let r=t.run(Tb(e[0]),e);return[t.run(Ib(t,e[0],n,r.dims),[e[0],r,e[1],e[2]])]},Uf=t=>t.attributes.getFloat("epsilon",1e-5),Gf={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[0]},xb=(t,e)=>{let n=e.dims.slice(),r=n[1],i=n[2]*n[3],o=[n[0],r],s=`\n      vec4 process(int[2] indices) {\n        vec4 v = vec4(0.0);\n        int a[4];\n        a[0] = indices[0];\n        a[1] = indices[1];\n        float temp = 0.0;\n        for(int a2=0; a2<${n[2]}; a2++) {\n          a[2] = a2;\n          for(int a3=0; a3<${n[3]}; a3++) {\n            a[3] = a3;\n            float x = _X(a);\n            temp += x;\n          }\n        }\n        float mean = temp / float(${i});\n        temp = 0.0;\n        for(int a2=0; a2<${n[2]}; a2++) {\n          a[2] = a2;\n          for(int a3=0; a3<${n[3]}; a3++) {\n            a[3] = a3;\n            float x = _X(a);\n            temp += (x - mean) * (x - mean);\n          }\n        }\n        v.r = mean;\n        v.g = temp / float(${i});\n\n        return v;\n      }`;return{...t,output:{dims:o,type:e.type,textureType:4},shaderSource:s}},Tb=t=>({...Gf,get:()=>xb(Gf,t)}),wb={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[0,4,0,0]},vb=(t,e,n,r,i)=>{let o=G(t.session.backend.glContext.version),[s,a]=t.calculateTextureWidthAndHeight(i,4),[u,l]=[s/4,a],p=`\n      vec4 get_MeanAndVariance(int[2] mv) {\n        int offset = indicesToOffset_MeanAndVariance(mv);\n        vec2 coords = offsetToCoords(offset, ${u}, ${l});\n        return ${o.texture2D}(MeanAndVariance, coords);\n      }\n\n      float process(int[4] indices) {\n        int mv[2];\n        mv[0] = indices[0];\n        mv[1] = indices[1];\n        vec4 mean_and_variance = get_MeanAndVariance(mv);\n        float mean = mean_and_variance.r;\n        float variance = mean_and_variance.g;\n\n        int sb[1];\n        sb[0] = indices[1];\n        float scale = _Scale(sb);\n        float b = _B(sb);\n\n        return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;\n      }`;return{...e,output:{dims:n.dims,type:n.type,textureType:0},variables:[{name:"epsilon",type:"float",data:r}],shaderSource:p}},Ib=(t,e,n,r)=>{let i={...wb,cacheHint:`${n}`};return{...i,get:()=>
6vb(t,i,e,n,r)}},_b=t=>{if(!t||3!==t.length)throw new Error("InstanceNormalization requires 3 inputs.");let e=t[0],n=t[1],r=t[2];if(e.dims.length<3||1!==n.dims.length||1!==r.dims.length)throw new Error("Invalid input shape.");if(n.dims[0]!==e.dims[1]||r.dims[0]!==e.dims[1])throw new Error("Input shapes are mismatched.");if("float32"!==e.type&&"float64"!==e.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type)throw new Error("Invalid input type.");if(4!==t[0].dims.length)throw new Error("Only support 4-D input shape.")}});function Ob(t,e){let n=t[0].dims[1],r=t[0].dims.length,i=-Math.floor((e.size-1)/2),o=Math.ceil((e.size-1)/2),s=`float(${e.alpha}) / float(${e.size})`,a=`\n    float process(int indices[${r}]) {\n        int c = indices[1];\n        float x = _X(indices);\n        float square_sum = 0.0;\n\n        for (int i = ${i}; i <= ${o}; i++) {\n          int idx = c + i;\n          if (c >= 0 && c < ${n}) {\n            indices[1] = idx;\n            float j = _X(indices);\n            square_sum += j * j;\n          }\n        }\n        return x / pow(float(${e.bias}) + ${s} * square_sum, float(${e.beta}));\n    }`;return{...Hf,cacheHint:e.cacheKey,output:{dims:t[0].dims,type:t[0].type,textureType:0},shaderSource:a}}function Sb(t,e){return{...Hf,cacheHint:e.cacheKey,get:()=>Ob(t,e)}}var zf,Wf,Hf,Ab,qf=O(()=>{vt(),j(),zf=(t,e,n)=>(Ab(e),[t.run(Sb(e,n),e)]),Wf=t=>{let e=t.attributes.getFloat("alpha",1e-4),n=t.attributes.getFloat("beta",.75),r=t.attributes.getFloat("bias",1),i=t.attributes.getInt("size");return W({alpha:e,beta:n,bias:r,size:i})},Hf={name:"LRN",inputNames:["X"],inputTypes:[0]},Ab=t=>{if(!t||1!==t.length)throw new Error("LRN requires 1 input.");if(4!==t[0].dims.length)throw new Error('currently only support LRN for input with "NCHW" format');if("float32"!==t[0].type)throw new Error("input should be float type")}}),Pb,Oi,jf,Xf,Kf,Eb,Db,Lb,$b,kb,Bb,Fb,Cb,Jf=O(()=>{vt(),Y(),st(),j(),Pb={name:"Pad",inputNames:["A"],inputTypes:[0]},Oi=(t,e,n)=>(Lb(e),[t.run({...Pb,cacheHint:n.cacheKey,get:()=>Db(t,e[0],n)},e)]),jf=t=>{let e=t.attributes.getString("mode","constant"),n=t.attributes.getFloat("value",0),r=t.attributes.getInts("pads");return W({mode:e,value:n,pads:r})},Xf=(t,e,n)=>{$b(e);let r=Eb(t,e,n);return Oi(t,[e[0]],r)},Kf=t=>t.attributes.getString("mode","constant"),Eb=(t,e,n)=>{if(!t.session.isInitializer(e[1].dataId)||e.length>=3&&!t.session.isInitializer(e[2].dataId))throw new Error("dynamic pad attributes are not allowed");let r=Array.from(e[1].integerData),i=e.length>=3?e[2].floatData[0]:0;return W({mode:n,pads:r,value:i})},Db=(t,e,n)=>{let r=B.padShape(e.dims.slice(),n.pads),i=r.length,o=`\n      ${kb(t,e,n)}\n      float process(int[${i}] indices) {\n          return padA(indices);\n      }`;return{name:"Pad",inputNames:["A"],inputTypes:[0],output:{dims:r,type:e.type,textureType:0},shaderSource:o}},Lb=t=>{if(!t||1!==t.length)throw new Error("Pad requires 1 input");if("float32"!==t[0].type&&"float64"!==t[0].type)throw new Error("Invalid input type.")},$b=t=>{if(!t||2!==t.length&&3!==t.length)throw new Error("Pad requires 2 or 3 inputs");if("int32"!==t[1].type)throw new Error("Invalid input type.");if(t.length>=3&&"string"===t[2].type)throw new Error("Invalid input type.")},kb=(t,e,n)=>{let r=G(t.session.backend.glContext.version),[i,o]=t.calculateTextureWidthAndHeight(e.dims,0),s=B.computeStrides(e.dims);switch(n.mode){case"constant":return Bb(r,e.dims,s,i,o,n.pads,n.value);case"reflect":return Fb(r,e.dims,s,i,o,n.pads);case"edge":return Cb(r,e.dims,s,i,o,n.pads);default:throw new Error("Invalid mode")}},Bb=(t,e,n,r,i,o,s)=>{let a=e.length,u="";for(let l=a-1;l>=0;--l)u+=`\n        k = m[${l}] - ${o[l]};\n        if (k < 0)  return constant;\n        if (k >= ${e[l]}) return constant;\n        offset += k * ${n[l]};\n        `;return`\n      float padA(int m[${a}]) {\n        const float constant = float(${s});\n        int offset = 0;\n        int k = 0;\n        ${u}\n        vec2 coords = offsetToCoords(offset, ${r}, ${i});\n        float value = getColorAsFloat(${t.texture2D}(A, coords));\n        return value;\n      }\n      `},Fb=(t,e,n,r,i,o)=>{let s=e.length,a="";for(let u=s-1;u>=0;--u)a+=`\n        k = m[${u}] - ${o[u]};\n        if (k < 0) { k = -k; }\n        {\n          const int _2n_1 = ${2*(e[u]-1)};\n          k = int( mod( float(k), float(_2n_1) ) ) ;\n          if(k >= ${e[u]}) { k = _2n_1 - k; }\n        }\n        offset += k * ${n[u]};\n        `;return`\n      float padA(int m[${s}]) {\n        int offset = 0;\n        int k = 0;\n        ${a}\n        vec2 coords = offsetToCoords(offset, ${r}, ${i});\n        float value = getColorAsFloat(${t.texture2D}(A, coords));\n        return value;\n      }\n      `},Cb=(t,e,n,r,i,o)=>{let s=e.length,a="";for(let u=s-1;u>=0;--u)a+=`\n        k = m[${u}] - ${o[u]};\n        if (k < 0)  k = 0;\n        if (k >= ${e[u]}) k = ${e[u]-1};\n        offset += k * ${n[u]};\n      `;return`\n      float padA(int m[${s}]) {\n        int offset = 0;\n        int k = 0;\n        ${a}\n        vec2 coords = offsetToCoords(offset, ${r}, ${i});\n        float value = getColorAsFloat(${t.texture2D}(A, coords));\n        return value;\n      }\n      `}}),Zf,Qf,tc,ec,rc,nc,oc,ic,ac,Nb,Yf,sc,Nn,uc,Cn,Rb,lc=O(()=>{vt(),Y(),j(),Zf=(t,e,n)=>{Nn(e);
6let r={name:"AveragePool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[t.run({...r,get:()=>tc(e,r,!1,n)},e)]},Qf=t=>{let e=t.attributes.getString("auto_pad","NOTSET"),n=t.attributes.getInt("ceil_mode",0),r=0!==t.attributes.getInt("count_include_pad",0),i=t.attributes.getInts("kernel_shape"),o=t.attributes.getInts("strides",[]),s=t.attributes.getInts("pads",[]);if(0!==n)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return W({autoPad:e,ceilMode:n,countIncludePad:r,kernelShape:i,strides:o,pads:s})},tc=(t,e,n,r)=>{let[i,o]=ac(t,r,n),s=B.size(i.kernelShape),a="";i.countIncludePad?a+=`value /= float(${s});`:a+=`value /= float(${s} - pad);`;let u=`\n        ${uc(t[0].dims,i,"value += _X(x);",a,"0.0")}\n      `;return{...e,output:{dims:o,type:t[0].type,textureType:0},shaderSource:u}},ec=(t,e,n)=>{Nn(e);let r={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[0],cacheHint:`${n.countIncludePad}`};return[t.run({...r,get:()=>tc(e,r,!0,n)},e)]},rc=t=>{let e=0!==t.attributes.getInt("count_include_pad",0);return W({autoPad:"",ceilMode:0,countIncludePad:e,kernelShape:[],strides:[],pads:[]})},nc=(t,e,n)=>{Nn(e);let r={name:"MaxPool",inputNames:["X"],inputTypes:[0],cacheHint:n.cacheKey};return[t.run({...r,get:()=>ic(e,r,!1,n)},e)]},oc=t=>{let e=t.attributes.getString("auto_pad","NOTSET"),n=t.attributes.getInt("ceil_mode",0),r=t.attributes.getInts("kernel_shape"),i=t.attributes.getInts("strides",[]),o=t.attributes.getInts("pads",[]),s=t.attributes.getInt("storage_order",0),a=t.attributes.getInts("dilations",[]);if(0!==s)throw new Error("column major storage order is not yet supported for MaxPool");if(0!==n)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return W({autoPad:e,ceilMode:n,countIncludePad:!1,kernelShape:r,strides:i,pads:o,storageOrder:s,dilations:a})},ic=(t,e,n,r)=>{let[i,o]=ac(t,r,n),s=`\n      ${uc(t[0].dims,i,"\n      value = max(_X(x), value);\n    ","","-1e5")}\n    `;return{...e,output:{dims:o,type:t[0].type,textureType:0},shaderSource:s}},ac=(t,e,n)=>{let r=t[0].dims.slice(),i=Object.hasOwnProperty.call(e,"dilations"),o=e.kernelShape.slice(),s=e.strides.slice(),a=i?e.dilations.slice():[],u=e.pads.slice();Me.adjustPoolAttributes(n,r,o,s,a,u);let l=Me.computePoolOutputShape(n,r,s,a,o,u,e.autoPad),p=Object.assign({},e);return i?Object.assign(p,{kernelShape:o,strides:s,pads:u,dilations:a,cacheKey:e.cacheKey}):Object.assign(p,{kernelShape:o,strides:s,pads:u,cacheKey:e.cacheKey}),[p,l]},Nb={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},Yf={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[0]},sc=(t,e)=>(Nn(e),[t.run({...Yf,get:()=>ic(e,Yf,!0,Nb)},e)]),Nn=t=>{if(!t||1!==t.length)throw new Error("Pool ops requires 1 input.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw new Error("Invalid input type.")},uc=(t,e,n,r,i)=>{let o=t.length;if(e.kernelShape.length<=2){let s=e.kernelShape[e.kernelShape.length-1],a=e.strides[e.strides.length-1],u=e.pads[e.pads.length/2-1],l=e.pads[e.pads.length-1],p=t[o-1],c="",d="",h="";if(c=u+l!==0?`\n          for (int i = 0; i < ${s}; i++) {\n            x[${o} - 1] = indices[${o} - 1] * ${a} - ${u} + i;\n            if (x[${o} - 1] < 0 || x[${o} - 1] >= ${p}) {\n              pad++;\n              continue;\n            }\n            ${n}\n          }`:`\n          for (int i = 0; i < ${s}; i++) {\n            x[${o} - 1] = indices[${o} - 1] * ${a} - ${u} + i;\n            ${n}\n          }`,2===e.kernelShape.length){let n=e.kernelShape[e.kernelShape.length-2],r=e.strides[e.strides.length-2],i=e.pads[e.pads.length/2-2],a=e.pads[e.pads.length-2],u=t[o-2];d=i+a!==0?`\n            for (int j = 0; j < ${n}; j++) {\n              x[${o} - 2] = indices[${o} - 2] * ${r} - ${i} + j;\n              if (x[${o} - 2] < 0 || x[${o} - 2] >= ${u}) {\n                pad+= ${s};\n                continue;\n              }\n          `:`\n            for (int j = 0; j < ${n}; j++) {\n              x[${o} - 2] = indices[${o} - 2] * ${r} - ${i} + j;\n            `,h="\n          }\n        "}return`\n        float process(int indices[${o}]) {\n          int x[${o}];\n          copyVec(indices, x);\n\n          float value = ${i};\n          int pad = 0;\n          ${d}\n          ${c}\n          ${h}\n          ${r}\n          return value;\n        }\n      `}{let s=B.size(e.kernelShape),a=B.computeStrides(e.kernelShape),u=a.length,l=e.pads.length,p=Rb(u),c=Cn(t,"inputDims"),d=Cn(e.pads,"pads"),h=Cn(a,"kernelStrides"),f=Cn(e.strides,"strides"),g="";return g=e.pads.reduce((t,e)=>t+e)?`\n            if (x[j] >= inputDims[j] || x[j] < 0) {\n              pad++;\n              isPad = true;\n              break;\n            }\n          }\n          if (!isPad) {\n            ${n}\n          }`:`\n          }\n          ${n}\n        `,`\n        ${p}\n        float process(int indices[${o}]) {\n          int x[${o}];\n          copyVec(indices, x);\n          int offset[${u}];\n          int pads[${l}];\n          int inputDims[${o}];\n          int kernelStrides[${u}];
6\n          int strides[${u}];\n          ${d}\n          ${c}\n          ${f}\n          ${h}\n\n          float value = ${i};\n          int pad = 0;\n          bool isPad = false;\n          for (int i = 0; i < ${s}; i++) {\n            offsetToIndices(i, kernelStrides, offset);\n            isPad = false;\n            for (int j = ${o} - ${u}; j < ${o}; j++) {\n              x[j] = indices[j] * strides[j - ${o} + ${u}]\n                + offset[j - ${o} + ${u}] - pads[j - 2];\n              ${g}\n          }\n          ${r}\n\n          return value;\n        }\n      `}},Cn=(t,e)=>{let n="";for(let r=0;r<t.length;r++)n+=`\n      ${e}[${r}] = ${t[r]};\n    `;return n},Rb=t=>`\n  void offsetToIndices(int offset, int[${t}] strides, out int[${t}] indices) {\n    if (${t} == 0) {\n      return;\n    }\n    for (int i = 0; i < ${t} - 1; ++i) {\n      indices[i] = offset / strides[i];\n      offset -= indices[i] * strides[i];\n    }\n    indices[${t} - 1] = offset;\n  }`}),je,Pe,Gb,Mb,fc,cc,pc,dc,hc,mc,bc,gc=O(()=>{vt(),Rr(),Y(),j(),je=(t,e,n,r,i)=>{Mb(e);let o={name:r,inputNames:["A"],inputTypes:[0]};return[t.run({...o,cacheHint:n.cacheKey,get:()=>Gb(t,e,n,r,i,o)},e)]},Pe=t=>{let e=t.attributes.getInts("axes",[]),n=1===t.attributes.getInt("keepdims",1);return W({axes:e,keepDims:n})},Gb=(t,e,n,r,i,o)=>{let s=[],a=e[0].dims.length||1,u=[],l=B.normalizeAxes(n.axes,e[0].dims.length),p=i(e,l),c=p[1];for(let h=0;h<e[0].dims.length;h++)l.indexOf(h)>=0||0===l.length?(n.keepDims&&s.push(1),c=`\n          for(int j${h} = 0; j${h} < ${e[0].dims[h]}; j${h}++) {\n            inputIdx[${h}] = j${h};\n            ${c}\n          }`):(u.push(`inputIdx[${h}] = outputIdx[${s.length}];`),s.push(e[0].dims[h]));let d=`\n      float process(int outputIdx[${s.length||1}]) {\n        float value;                 // final result\n        int inputIdx[${a}];      // addressing input data\n        ${u.join("\n")}\n        ${p[0]}       // init ops for reduce max/min\n        ${c}\n        ${p[2]}       // final computation for reduce mean\n        return value;\n      }`;return{...o,output:{dims:s,type:e[0].type,textureType:0},shaderSource:d}},Mb=t=>{if(!t||1!==t.length)throw new Error("Reduce op requires 1 input.");if(-1===Ae.indexOf(t[0].type))throw new Error("Invalid input type.")},fc=(t,e,n)=>je(t,e,n,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),cc=(t,e,n)=>je(t,e,n,"ReduceMean",(t,e)=>{let n=1;for(let r=0;r<t[0].dims.length;r++)(e.indexOf(r)>=0||0===e.length)&&(n*=t[0].dims[r]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${n}.;`]}),pc=(t,e,n)=>je(t,e,n,"ReduceMax",(t,e)=>{let n=[];for(let r=0;r<t[0].dims.length;r++)(e.indexOf(r)>=0||0===e.length)&&n.push(`inputIdx[${r}] = 0;`);return[`${n.join("\n")}\nvalue = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),dc=(t,e,n)=>je(t,e,n,"ReduceMin",(t,e)=>{let n=[];for(let r=0;r<t[0].dims.length;r++)(e.indexOf(r)>=0||0===e.length)&&n.push(`inputIdx[${r}] = 0;`);return[`${n.join("\n")}\nvalue = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),hc=(t,e,n)=>je(t,e,n,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),mc=(t,e,n)=>je(t,e,n,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),bc=(t,e,n)=>je(t,e,n,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])}),yc,xc=O(()=>{Y(),yc=(t,e)=>{let n=B.calculateReshapedDims(e[0].dims,e[1].integerData);return t.session.pack?[t.reshapePacked(e[0],n)]:[t.reshapeUnpacked(e[0],n)]}}),Tc,Si,wc,vc,Gr,Ub,Ai,Rn,Pi=O(()=>{vt(),st(),j(),Tc={name:"Upsample",inputNames:["X"],inputTypes:[0]},Si=(t,e,n)=>(Ai(e,n),[t.run({...Tc,cacheHint:n.cacheKey,get:()=>Ub(t,e,n)},e)]),wc=t=>Gr(t,7),vc=t=>Gr(t,9),Gr=(t,e)=>{let n=e>=10,r=t.attributes.getString("mode","nearest");
6if("nearest"!==r&&"linear"!==r&&(e<11||"cubic"!==r))throw new Error(`unrecognized mode: ${r}`);let i=[];e<9&&(i=t.attributes.getFloats("scales"),Rn(i,r,n));let o=t.attributes.getFloat("extrapolation_value",0),s=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(s))throw new Error(`coordinate_transform_mode '${s}' is not supported`);let a="tf_crop_and_resize"===s,u=a,l="nearest"===r&&e>=11?t.attributes.getString("nearest_mode","round_prefer_floor"):"";if(-1===["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(l))throw new Error(`nearest_mode '${l}' is not supported`);let p=t.attributes.getFloat("cubic_coeff_a",-.75),c=0!==t.attributes.getInt("exclude_outside",0);if(c&&"cubic"!==r)throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");let d=e<11||"nearest"===r&&"asymmetric"===s&&"floor"===l,h=0,f=0,g=0;return e>10?t.inputs.length>2?(h=1,f=2,g=3):(f=1,g=2):9===e&&(f=1),W({opset:e,isResize:n,mode:r,scales:i,extrapolationValue:o,coordinateTransformMode:s,useExtrapolation:u,needRoiInput:a,nearestMode:l,cubicCoefficientA:p,excludeOutside:c,useNearest2xOptimization:d,roiInputIdx:h,scalesInputIdx:f,sizesInputIdx:g})},Ub=(t,e,n)=>{let r=G(t.session.backend.glContext.version),[i,o]=t.calculateTextureWidthAndHeight(e[0].dims,0),s=e[0].dims.map((t,e)=>Math.floor(t*n.scales[e])),[a,u]=t.calculateTextureWidthAndHeight(s,0),l=s.length,p=new Array(l),c=new Array(l),d=`\n      int output_pitches[${l}];\n      int input_pitches[${l}];\n      `;for(let g=l-1;g>=0;g--)p[g]=g===l-1?1:p[g+1]*s[g+1],c[g]=g===l-1?1:c[g+1]*e[0].dims[g+1],d+=`\n        output_pitches[${g}] = ${p[g]};\n        input_pitches[${g}] = ${c[g]};\n        `;let h=`\n      float getInputFloat(int index) {\n        vec2 coords = offsetToCoords(index, ${i}, ${o});\n        float value = getColorAsFloat(${r.texture2D}(X, coords));\n        return value;\n      }\n      `,f="nearest"===n.mode?`\n    ${h}\n    float process(int indices[${l}]) {\n      int input_index = 0;\n      int output_index = coordsToOffset(TexCoords, ${a}, ${u});\n\n      ${d}\n\n      int d, m;\n      for (int dim = 0; dim < ${l}; ++dim) {\n        d = output_index / output_pitches[dim];\n        m = output_index - d * output_pitches[dim];\n        output_index = m;\n\n        if (scales[dim] != 1 && d > 0) {\n          int d2 = d / scales[dim];\n          m = d - d2 * scales[dim];\n          d = d2;\n        }\n        input_index += input_pitches[dim] * d;\n      }\n\n      return getInputFloat(input_index);\n    }`:4===l?`\n    ${h}\n    float process(int indices[4]) {\n      int input_index = 0;\n      int output_index = coordsToOffset(TexCoords, ${a}, ${u});\n\n      ${d}\n\n      int m;\n      int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;\n      index_of_dim0 = output_index / output_pitches[0];\n      m = output_index - index_of_dim0 * output_pitches[0];\n      index_of_dim1 = m / output_pitches[1];\n      m = m - index_of_dim1 * output_pitches[1];\n      index_of_dim2 = m / output_pitches[2];\n      m = m - index_of_dim2 * output_pitches[2];\n      index_of_dim3 = m;\n\n      int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;\n      index_of_input_dim2 = index_of_dim2 / scales[2];\n      y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];\n      index_of_input_dim3 = index_of_dim3 / scales[3];\n      x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];\n\n      input_index = index_of_dim0 * input_pitches[0] +\n            index_of_dim1 * input_pitches[1] +\n            index_of_input_dim2 * input_pitches[2] +\n            index_of_input_dim3;\n\n      float x00 = getInputFloat(input_index);\n      float x10, x01, x11;\n\n      bool end_of_dim2 = false;\n      if (index_of_input_dim2 == (${e[0].dims[2]} - 1)) {\n        // It's the end in dimension 2\n        x01 = x00;\n        end_of_dim2 = true;\n      } else {\n        x01 = getInputFloat(input_index + input_pitches[2]);\n      }\n\n      if (index_of_input_dim3 == (input_pitches[2] - 1)) {\n        // It's the end in dimension 3\n        x10 = x00;\n        x11 = x01;\n      }\n      else {\n        x10 = getInputFloat(input_index + 1);\n        x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);\n      }\n\n      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);\n      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);\n      return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);\n    }`:`\n    ${h}\n    float process(int indices[2]) {\n      int input_index = 0;\n      int output_index = coordsToOffset(TexCoords, ${a}, ${u});\n\n      ${d}\n\n      int m;\n      int index_of_dim0, index_of_dim1;\n      index_of_dim0 = output_index / output_pitches[0];\n      m = output_index - index_of_dim0 * output_pitches[0];\n      index_of_dim1 = m;\n\n      int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;\n      index_of_input_dim0 = index_of_dim0 / scales[0];\n      y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];\n      index_of_input_dim1 = index_of_dim1 / scales[1];\n      x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];\n\n      input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;\n\n      float x00 = getInputFloat(input_index);\n      float x10, x01, x11;\n\n      bool end_of_dim0 = false;\n      if (index_of_input_dim0 == (${e[0].dims[0]} - 1)) {\n        // It's the end in dimension 0\n        x01 = x00;\n        end_of_dim0 = true;\n      } else {\n        x01 = getInputFloat(input_index + input_pitches[0]);\n      }\n\n      if (index_of_input_dim1 == (input_pitches[0] - 1)) {\n        // It's the end in dimension 1\n        x10 = x00;\n        x11 = x01;\n      }\n      else {\n        x10 = getInputFloat(input_index + 1);\n        x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);\n      }\n\n      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);\n      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);\n      return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);\n    }`;return{...Tc,output:{dims:s,type:e[0].type,textureType:0},shaderSource:f,variables:[{name:"scales",type:"int",arrayLength:n.scales.length,data:n.scales.map(t=>Math.ceil(t))}]}},Ai=(t,e)=>{if(!t||e.opset<9&&1!==t.length||e.opset>=9&&e.opset<11&&2!==t.length||e.opset>
6=11&&t.length<2)throw new Error("invalid inputs.");if(e.scales.length>0&&t[0].dims.length!==e.scales.length)throw new Error("Invalid input shape.");if("string"===t[0].type)throw new Error("Invalid input tensor types.")},Rn=(t,e,n)=>{if(n){for(let r of t)if(r<=0)throw new Error("Scale value should be greater than 0.")}else for(let r of t)if(r<1)throw new 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 new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic')         or 4-D inputs with the corresponding outermost 2 scale values being 1         in the ${n?"Resize":"Upsample"} opeartor.`)}}),Ei,Di,Ic,_c,Vb,zb,Wb,Hb,Oc=O(()=>{st(),j(),ue(),We(),Pi(),Ei={name:"Resize",inputNames:["A"],inputTypes:[2]},Di=(t,e,n)=>(Ai(e,n),[t.run({...Ei,cacheHint:n.cacheKey,get:()=>Vb(t,e,n)},e)]),Ic=t=>Gr(t,10),_c=t=>Gr(t,11),Vb=(t,e,n)=>{let r=G(t.session.backend.glContext.version),[i,o]=zb(e,n);if(i.every(t=>1===t)&&"tf_crop_and_resize"!==n.coordinateTransformMode)return{...Ei,output:{dims:o,type:e[0].type,textureType:2},hasMain:!0,shaderSource:`void main() {\n                    vec4 v = ${r.texture2D}(X, TexCoords);\n                    ${r.output} = v;\n                }`};let s=o.length;if(s<2)throw new Error(`output dimension should be at least 2, but got ${s}`);let a=o[s-2],u=o[s-1],l=e[0].dims;if(s!==l.length)throw new Error(`output dimension should match input ${l.length}, but got ${s}`);let p=l[s-2],c=l[s-1],d=i[s-2],h=i[s-1],f="";if("linear"!==n.mode)throw new Error(`resize (packed) does not support mode: '${n.mode}'`);switch(n.coordinateTransformMode){case"asymmetric":f="\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        return vec4(coords) / scaleWHWH;\n                    }\n                ";break;case"half_pixel":f="\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;\n                    }\n                ";break;case"pytorch_half_pixel":f=`\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        vec4 fcoords = vec4(coords);\n                        return vec4(\n                            ${u}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,\n                            ${a}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,\n                            ${u}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,\n                            ${a}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0\n                          );\n                    }\n                `;break;case"align_corners":f=`\n                    vec4 getSourceFracIndex(ivec4 coords) {\n                        vec4 resized = vec4(${u}.0 - 1.0, ${a}.0 - 1.0, ${u}.0 - 1.0,\n                            ${a}.0 - 1.0);\n                        vec4 original = vec4(${c}.0 - 1.0, ${p}.0 - 1.0, ${c}.0 - 1.0,\n                            ${p}.0 - 1.0);\n                        vec4 new_scale = original / resized;\n                        return vec4(coords) * new_scale;\n                    }\n                `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode:                                 '${n.coordinateTransformMode}'`)}let g=kt(s),m=`\n            const vec2 inputWH = vec2(${p}.0, ${c}.0);\n            const vec4 scaleWHWH = vec4(float(${d}), float(${h}), float(${d}), float(${h}));\n            ${le()}\n            ${f}\n            float getAValue(int x10, int r, int c, int d) {\n                return getChannel(getA(x10, r, c, d), vec2(c, d));\n            }\n            void main() {\n                ${g} rc = getOutputCoords();\n\n                int batch = rc[0];\n                int depth = rc[1];\n\n                // retrieve the 4 coordinates that is used in the 4 packed output values.\n                ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);\n\n                // calculate the source index in fraction\n                vec4 sourceFrac = getSourceFracIndex(coords);\n\n                // get the lower and upper bound of the 4 values that will be packed into one texel.\n                ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));\n                ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));\n                ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));\n                ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));\n\n                bool hasNextRow = rc.w < ${a-1};\n                bool hasNextCol = rc.z < ${u-1};\n\n                // pack x00, x01, x10, x11's top-left corner into one vec4 structure\n                vec4 topLeft = vec4(\n                    getA
6Value(batch, depth, x00.x, x00.y),\n                    hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);\n\n                // pack x00, x01, x10, x11's top-right corner into one vec4 structure\n                vec4 topRight = vec4(\n                    getAValue(batch, depth, x00.x, x00.w),\n                    hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);\n\n                // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure\n                vec4 bottomLeft = vec4(\n                    getAValue(batch, depth, x00.z, x00.y),\n                    hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);\n\n                // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure\n                vec4 bottomRight = vec4(\n                    getAValue(batch, depth, x00.z, x00.w),\n                    hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,\n                    hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,\n                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);\n\n                // calculate the interpolation fraction on u and v direction\n                vec4 frac = vec4(sourceFrac) - floor(sourceFrac);\n                vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));
6\n\n                vec4 top = mix(topLeft, topRight, clampFrac.ywyw);\n                vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);\n                vec4 newValue = mix(top, bottom, clampFrac.xxzz);\n\n                ${r.output} = vec4(newValue);\n            }\n        `;return{...Ei,output:{dims:o,type:e[0].type,textureType:2},hasMain:!0,shaderSource:m}},zb=(t,e)=>{let n,r=t[0].dims,i=e.scales;if(0===i.length){let o=t[e.scalesInputIdx];if(o&&0!==o.size){if(t[e.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");i=Wb(o,e.mode,e.isResize)}else{let o=t[e.sizesInputIdx];if(!o||0===o.size)throw new Error("Either scales or sizes MUST be provided as input.");n=Array.from(o.integerData),i=Hb(n,r,e.mode,e.isResize)}}else if(t[e.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");let o=n||r.map((t,e)=>Math.floor(t*i[e]));return[i,o]},Wb=(t,e,n)=>{let r=Array.from(t.floatData);return Rn(r,e,n),r},Hb=(t,e,n,r)=>{let i=e.length,o=new Array(i);for(let s=0,a=i;s<a;s++)if(0===e[s]){if(0!==t[s])throw new Error("Input dim is zero but required output dim is non-zero.");o[s]=1}else o[s]=t[s]/e[s];return Rn(o,n,r),o}}),Sc,qb,Ac=O(()=>{ze(),Sc=(t,e)=>(qb(e),[new bt([e[0].dims.length],"int32",void 0,void 0,new Int32Array(e[0].dims))]),qb=t=>
6{if(!t||1!==t.length)throw new Error("Shape requires 1 input.")}}),Li,Pc,Ec,Dc,jb,Lc,Xb,Kb,$c=O(()=>{vt(),Rr(),Y(),j(),Li={name:"Slice",inputNames:["A"],inputTypes:[0]},Pc=(t,e,n)=>(jb(e),[t.run({...Li,cacheHint:n.cacheKey,get:()=>Dc(t,e[0],n)},e)]),Ec=t=>{let e=t.attributes.getInts("starts"),n=t.attributes.getInts("ends"),r=t.attributes.getInts("axes",[]);return W({starts:e,ends:n,axes:r})},Dc=(t,e,n)=>{let r=0===n.axes.length?e.dims.slice(0).map((t,e)=>e):n.axes,i=B.normalizeAxes(r,e.dims.length),o=n.starts.map((t,n)=>t>e.dims[i[n]]-1?e.dims[i[n]]:B.normalizeAxis(t,e.dims[i[n]])),s=n.ends.map((t,n)=>t>e.dims[i[n]]-1?e.dims[i[n]]:B.normalizeAxis(t,e.dims[i[n]])),a=e.dims.slice(),u=[];for(let p=0;p<i.length;p++)a[i[p]]=s[p]-o[p],o[p]>0&&u.push(`outputIdx[${i[p]}] += ${o[p]};`);let l=`\n      float process(int outputIdx[${a.length}]) {\n        ${u.join("\n      ")}\n        return _A(outputIdx);\n      }`;return{...Li,output:{dims:a,type:e.type,textureType:0},shaderSource:l}},jb=t=>{if(!t||1!==t.length)throw new Error("Slice requires 1 input.");if(-1===Ae.indexOf(t[0].type))throw new Error("Invalid input type.")},Lc=(t,e)=>{Kb(e);let n=Xb(t,e);return[t.run({...Li,cacheHint:n.cacheKey,get:()=>Dc(t,e[0],n)},[e[0]])]},Xb=(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 new Error("dynamic slice attributes are not allowed");if(e.length>=5&&e[4].integerData.some(t=>1!==t))throw new Error("currently non-1 steps is not supported for Slice");let n=Array.from(e[1].integerData),r=Array.from(e[2].integerData),i=e.length>=4?Array.from(e[3].integerData):[];return{starts:n,ends:r,axes:i,cacheKey:`${i};${n};${r}`}},Kb=t=>{if(!t||t.length<3||t.length>5)throw new Error("Invalid input number.");if("int32"!==t[1].type||1!==t[1].dims.length)throw new Error("Invalid input type.");if("int32"!==t[2].type||1!==t[2].dims.length)throw new Error("Invalid input type.");if(t.length>=4&&("int32"!==t[3].type||1!==t[3].dims.length))throw new Error("Invalid input type.");if(t.length>=5&&("int32"!==t[4].type||1!==t[4].dims.length))throw new Error("Invalid input type.")}}),kc,Bc,Fc,Cc,Nc,Rc,Gc,Mc,Jb,Yb,Zb,Uc,Vc=O(()=>{vt(),Y(),st(),j(),Fn(),kc={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[0]},Bc={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[0,0]},Fc={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[0,0,0]},Cc=(t,e,n)=>{Uc(e);let r=e[0].dims.slice(),i=B.normalizeAxis(n.axis,r.length),o=B.sizeToDimension(r,i),s=B.sizeFromDimension(r,i);return Mc(t,e,n,o,s)},Nc=t=>W({axis:t.attributes.getInt("axis",1)}),Rc=t=>W({axis:t.attributes.getInt("axis",-1)}),Gc=(t,e,n)=>{Uc(e);let r,i=e[0].dims.slice(),o=B.normalizeAxis(n.axis,i.length),s=i.length,a=o!==s-1,u=[],l=[],p=[];a&&(l=Array.from({length:s}).map((t,e)=>e),l[o]=s-1,l[s-1]=o,l.map(t=>u.push(i[t])),r=W({perm:l}),p=qe(t,e,r));let c=a?B.sizeToDimension(u,s-1):B.sizeToDimension(i,s-1),d=a?B.sizeFromDimension(u,s-1):B.sizeFromDimension(i,s-1),h=Mc(t,a?p:e,n,c,d);return a?qe(t,h,r):h},Mc=(t,e,n,r,i)=>{let o=Jb(t,e[0],r,i,[r]),s=t.run({...kc,cacheHint:n.cacheKey,get:()=>o},e),a=Yb(t,e[0],r,i,o.output.dims,[r]),u=t.run({...Bc,cacheHint:n.cacheKey,get:()=>a},[e[0],s]),l=Zb(t,e[0],r,i,o.output.dims,a.output.dims);return[t.run({...Fc,cacheHint:n.cacheKey,get:()=>l},[e[0],s,u])]},Jb=(t,e,n,r,i)=>{let[o,s]=t.calculateTextureWidthAndHeight(e.dims,0),a=i.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==i.length)throw new Error("Dimensionality of the output should be 1");if(i[0]!==n)throw new Error("Shape of the output should be equal to logical row count");let u=G(t.session.backend.glContext.version),l=`\n      float process(int[${a}] indices) {\n        int logical_row_start_offset = indices[0] * ${r};\n\n        float max = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset, ${o},\n        ${s} )));\n        for(int i=1; i<${r}; ++i)\n        {\n          float current = getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset + i,\n            ${o}, ${s})));\n          if(current > max)\n          max = current;\n        }\n\n        return max;\n      }`;return{...kc,output:{dims:i,type:e.type,textureType:0},shaderSource:l}},Yb=(t,e,n,r,i,o)=>{let[s,a]=t.calculateTextureWidthAndHeight(e.dims,0),u=o.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length)throw new Error("Dimensionality of the output should be 1");if(o[0]!==n)throw new Error("Shape of the output should be equal to logical row count");if(1!==i.length)throw new Error("Dimensionality of the intermediate results should be 1");if(i[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=`\n      float process(int[${u}
6] indices) {\n        int logical_row_start_offset = indices[0] * ${r};\n\n        float norm_factor = 0.0;\n        float max = _Max(indices);\n        for(int i=0; i<${r}; ++i)\n        {\n          norm_factor += exp(getColorAsFloat(${G(t.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i,\n            ${s}, ${a}))) - max);\n        }\n\n        return norm_factor;\n      }`;return{...Bc,output:{dims:o,type:e.type,textureType:0},shaderSource:l}},Zb=(t,e,n,r,i,o)=>{let[s,a]=t.calculateTextureWidthAndHeight(e.dims,0),u=e.dims.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==i.length||1!==o.length)throw new Error("Dimensionality of the intermediate results should be 1");if(i[0]!==n||o[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");let l=`\n      float process(int[${u}] indices) {\n\n      // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)\n      int offset = coordsToOffset(TexCoords, ${s}, ${a});\n\n      //determine the logical row for this index\n      int logical_row_index[1];\n      logical_row_index[0] = offset / ${r};\n\n      float norm_factor = _Norm(logical_row_index);\n\n      // avoid possible division by 0\n      // if norm_facor is 0, all elements are zero\n      // if so, return 0\n      if(norm_factor == 0.0)\n        return 0.0;\n\n      return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;\n    }`;return{...Fc,output:{dims:e.dims,type:e.type,textureType:0},shaderSource:l}},Uc=t=>{if(!t||1!==t.length)throw new Error("Softmax requires 1 input.");if("float32"!==t[0].type&&"float64"!==t[0].type)throw new Error("Invalid input type")}}),zc,Wc,Hc,Qb,tg,eg,qc=O(()=>{vt(),Y(),j(),zc={name:"Split",inputNames:["A"],inputTypes:[0]},Wc=(t,e,n)=>{eg(e);let r=B.normalizeAxis(n.axis,e[0].dims.length),i=Qb(t,e,r,n),o=[];for(let s=0;s<i;++s)o.push(t.run({...zc,cacheHint:`${n.cacheKey};${s}`,get:()=>tg(t,e[0],n,r,s)},e));return o},Hc=t=>{let e=t.attributes.getInt("axis",0),n=t.attributes.getInts("split",[]),r=t.outputs.length;return W({axis:e,split:n,numOutputs:r})},Qb=(t,e,n,r)=>{let[,i]=$r.splitShape(e[0].dims,n,r.split,r.numOutputs);return i.length},tg=(t,e,n,r,i)=>{let[o,s]=$r.splitShape(e.dims,r,n.split,n.numOutputs),a=s[i],u=o[i],l=`\n      float process(int indices[${u.length}]) {\n        indices[${r}] += ${a};\n        return _A(indices);\n      }\n    `;return{...zc,cacheHint:`${n.cacheKey}:${i}`,output:{dims:u,type:e.type,textureType:0},shaderSource:l}},eg=t=>{if(!t||1!==t.length)throw new 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 new Error("Invalid input type.")}}),$i,jc,Xc,rg,ng,Kc=O(()=>{Y(),$i=(t,e,n)=>{rg(e);let r=B.squeezeShape(e[0].dims,n);return[t.reshapeUnpacked(e[0],r)]},jc=(t,e)=>(ng(e),$i(t,[e[0]],Array.from(e[1].integerData))),Xc=t=>t.attributes.getInts("axes"),rg=t=>{if(!t||1!==t.length)throw new Error("Squeeze requires 1 input.");if("string"===t[0].type)throw new Error("invalid input tensor types.")},ng=t=>{if(!t||2!==t.length)throw new Error("Squeeze requires 2 inputs.");if("int32"!==t[1].type)throw new Error("Invalid input type.")}}),Jc,og,ig,Yc=O(()=>{st(),j(),Jc=(t,e)=>{ig(e);let n={name:"Sum",inputNames:e.map((t,e)=>`X${e}`),inputTypes:new Array(e.length).fill(0)};return[t.run({...n,get:()=>og(t,e,n)},e)]},og=(t,e,n)=>{let r=G(t.session.backend.glContext.version),i=e[0].dims.slice(),o=`\n      void main() {\n        vec4 result = ${e.map((t,e)=>`${r.texture2D}(X${e},TexCoords)`).join(" + ")};\n        ${r.output} = result;\n      }\n    `;return{...n,output:{dims:i,type:e[0].type,textureType:0},hasMain:!0,shaderSource:o}},ig=t=>{if(!t||0===t.length)throw new Error("Sum requires inputs.");let e=t[0].dims.length;for(let n=1;n<t.length;n++){if(e!==t[n].dims.length)throw new Error("Input shapes are mismatched.");for(let r=0;r<e;r++)if(t[0].dims[r]!==t[n].dims[r])throw new Error("Input shapes are not matched.")}if("float32"!==t[0].type&&"float64"!==t[0].type)throw new Error("Invalid input type.");for(let n=1;n<t.length;n++)if(t[0].type!==t[n].type)throw new Error("Input types are not matched.")}}
6),Zc,ag,sg,Qc=O(()=>{Rr(),j(),Zc=(t,e)=>{sg(e);let n={name:"Tile",inputNames:["A"],inputTypes:[0]};return[t.run({...n,get:()=>ag(t,e,n)},e)]},ag=(t,e,n)=>{let r=e[0].dims.slice(),i=new Array(r.length),o=[];for(let u=0;u<r.length;u++)i[u]=r[u]*e[1].numberData[u],o.push(`inputIdx[${u}] = int(mod(float(outputIdx[${u}]), ${r[u]}.));`);let s=i.length,a=`\n      float process(int outputIdx[${s}]) {\n        int inputIdx[${s}];\n        ${o.join("\n")}\n        return _A(inputIdx);\n      }\n    `;return{...n,output:{dims:i,type:e[0].type,textureType:0},shaderSource:a}},sg=t=>{if(!t||2!==t.length)throw new Error("Tile requires 2 input.");if(1!==t[1].dims.length)throw new Error("The second input shape must 1 dimension.");if(t[1].dims[0]!==t[0].dims.length)throw new Error("Invalid input shape.");if(-1===Ae.indexOf(t[0].type))throw new Error("Invalid input type.");if("int32"!==t[1].type&&"int16"!==t[1].type)throw new Error("Invalid repeat type.")}}),ki,tp,ep,ug,lg,rp=O(()=>{Y(),ki=(t,e,n)=>{ug(e);let r=B.unsqueezeShape(e[0].dims,n);return[t.reshapeUnpacked(e[0],r)]},tp=(t,e)=>(lg(e),ki(t,[e[0]],Array.from(e[1].integerData))),ep=t=>t.attributes.getInts("axes"),ug=t=>{if(!t||1!==t.length)throw new Error("Unsqueeze requires 1 input.");if("string"===t[0].type)throw new Error("invalid input tensor types.")},lg=t=>{if(!t||2!==t.length)throw new Error("Unsqueeze requires 2 inputs.");if("int32"!==t[1].type)throw new Error("Invalid input type.")}}),np,op=O(()=>{dl(),Sl(),El(),Fl(),$n(),xf(),Of(),Pf(),Lf(),Ff(),Rf(),Vf(),qf(),kn(),Jf(),lc(),gc(),xc(),Oc(),Ac(),$c(),Vc(),qc(),Kc(),Yc(),Qc(),Fn(),bi(),rp(),Pi(),np=[["Abs","","6+",Cl],["Acos","","7+",Nl],["Add","","7+",hl],["And","","7+",ml],["Asin","","7+",Rl],["Atan","","7+",Gl],["AveragePool","","7+",Zf,Qf],["BatchNormalization","","7+",cl,pl],["Cast","","6+",Al,Pl],["Ceil","","6+",Vl],["Clip","","6-10",hi,Ml],["Clip","","11+",Ul],["Concat","","4+",$l,Bl],["Conv","","1+",vi,Ii],["ConvTranspose","","1+",gf,yf],["Cos","","7+",zl],["Div","","7+",bl],["Dropout","","7+",mi],["DepthToSpace","","1+",If,_f],["Equal","","7+",gl],["Elu","","6+",Wl,Hl],["Exp","","6+",ql],["Flatten","","1+",Sf,Af],["Floor","","6+",jl],["FusedConv","com.microsoft","1+",vi,Ii],["Gather","","1+",Ef,Df],["Gemm","","7-10",_i,kf],["Gemm","","11+",_i,Bf],["GlobalAveragePool","","1+",ec,rc],["GlobalMaxPool","","1+",sc],["Greater","","7+",yl],["Identity","","1+",mi],["ImageScaler","","1+",Cf,Nf],["InstanceNormalization","","6+",Mf,Uf],["LeakyRelu","","6+",Xl,Kl],["Less","","7+",xl],["LRN","","1+",zf,Wf],["Log","","6+",Jl],["MatMul","","1+",ff,cf],["MaxPool","","1+",nc,oc],["Mul","","7+",Tl],["Neg","","6+",Yl],["Not","","1+",Zl],["Or","","7+",wl],["Pad","","2-10",Oi,jf],["Pad","","11+",Xf,Kf],["Pow","","7+",vl],["PRelu","","7+",Il],["ReduceLogSum","","1+",mc,Pe],["ReduceMax","","1+",pc,Pe],["ReduceMean","","1+",cc,Pe],["ReduceMin","","1+",dc,Pe],["ReduceProd","","1+",hc,Pe],["ReduceSum","","1-12",fc,Pe],["ReduceSumSquare","","1+",bc,Pe],["Relu","","6+",Ql],["Reshape","","5+",yc],["Resize","","10",Di,Ic],["Resize","","11+",Di,_c],["Shape","","1+",Sc],["Sigmoid","","6+",tf],["Sin","","7+",ef],["Slice","","10+",Lc],["Slice","","1-9",Pc,Ec],["Softmax","","1-12",Cc,Nc],["Softmax","","13+",Gc,Rc],["Split","","2-12",Wc,Hc],["Sqrt","","6+",rf],["Squeeze","","1-12",$i,Xc],["Squeeze","","13+",jc],["Sub","","7+",_l],["Sum","","6+",Jc],["Tan","","7+",nf],["Tanh","","6+",of],["Tile","","6+",Zc],["Transpose","","1+",qe,wf],["Upsample","","7-8",Si,wc],["Upsample","","9",Si,vc],["Unsqueeze","","1-12",ki,ep],["Unsqueeze","","13+",tp],["Xor","","7+",Ol]]});function ap(t){let e,n={};for(;null!==(e=ip.exec(t));){let t=e[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);n[e[2]]={params:t,body:e[4]}}for(let r in n){let i=fg.replace("__FUNC__",r),o=new RegExp(i,"gm");for(;null!==(e=o.exec(t));){let i=e[1],o=e[2],s=e[3].split(","),a=i?`${i} ${o};`:"",u=n[r].body,l="";n[r].params.forEach((t,e)=>{t&&(l+=`${t.type} ${t.name} = ${s[e]};\n`)}),u=`${l}\n ${u}`,u=u.replace("return",`${o} = `);let p=`\n      ${a}\n      {\n        ${u}\n      }\n      `;t=t.replace(e[0],p)}}return t.replace(ip,"")}var ip,fg,sp=O(()=>{ip=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,fg="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;"});function hr(t,e){let n=[],r=[];for(let i=0;i<t.length;++i)1!==t[i]&&(n.push(t[i]),r.push(i));return{newShape:n,keptDims:r}}function dg(t){if(0===t.length)return 1;let e=t[0];for(let n=1;n<t.length;n++)e*=t[n];return e}function up(t){let e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}var Gn,Bi=O(()=>{Mt(),Y(),Gn=class{constructor(t){this.maxTextureSize=t}computeTextureWH(t,e){let n=this.computeTexture(t,e);return e&&e.isPacked&&(n[0]/=2,n[1]/=2),e&&e.reverseWH?[n[1],n[0]]:n}computeTexture(t,e){let n=e&&e.isPacked;if(0===t.length)return n?[2,2]:[1,1];let r=this.maxTextureSize;if(e&&void 0!==e.breakAxis){let n=e.breakAxis>=t.length?1:t.slice(e.breakAxis).reduce((t,e)=>t*e),i=e.breakAxis<=0?1:t.slice(0,e.breakAxis).reduce((t,e)=>t*e);if(!(n>r||i>r))return[n,i];tt.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${t}, breakAxis:${e.breakAxis}`)}let i=t.slice(0);n&&(r*=2,i=i.map((t,e)=>e>=i.length-2?i[e]%2==0?i[e]:i[e]+1:i[e]),1===i.length&&(i=[2,i[0]])),2!==i.length&&(i=hr(i).newShape);let o=dg(i);return i.length<=1&&o<=r?[1,o]:2===i.length&&i[0]<=r&&i[1]<=r?i:3===i.length&&i[0]*i[1]<=r&&i[2]<=r?[i[0]*i[1],i[2]]:3===i.length&&i[0]<=r&&i[1]*i[2]<=r?[i[0],i[1]*i[2]]:4===i.length&&i[0]*i[1]*i[2]<=r&&i[3]<=r?[i[0]*i[1]*i[2],i[3]]:4===i.length&&i[0]<=r&&i[1]*i[2]*i[3]<=r?[i[0],i[1]*i[2]*i[3]]:n?up(o/4).map(t=>2*t):up(o)}}}),Mn,lp=O(()=>{Y(),be(),st(),Bi(),ue(),Mn=class extends Wt{constructor(t){super(t)}getFunctions(){return{...this.offsetToCoords(),...this.coordsToOffset(),...this.toVec(),...this.valueFrom(),...this.getCommonUtilFuncs(),...this.getInputsSampl
6ingSnippets(),...this.getOutputSamplingSnippet()}}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new k("\n      vec2 offsetToCoords(int offset, int width, int height) {\n        int t = offset / width;\n        int s = offset - t*width;\n        vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);\n        return coords;\n      }\n      ")}}coordsToOffset(){return{coordsToOffset:new k("\n      int coordsToOffset(vec2 coords, int width, int height) {\n        float s = coords.s * float(width);\n        float t = coords.t * float(height);\n        int offset = int(t) * width + int(s);\n        return offset;\n      }\n      ")}}getOutputSamplingSnippet(){let t=this.context.outputTextureLayout;return t.isPacked?this.getPackedOutputSamplingSnippet(t):this.getUnpackedOutputSamplingSnippet(t)}getPackedOutputSamplingSnippet(t){let e=t.unpackedShape,n=[t.width,t.height],r={},i="getOutputCoords";switch(e.length){case 0:r[i]=this.getOutputScalarCoords();break;case 1:r[i]=this.getOutputPacked1DCoords(e,n);break;case 2:r[i]=this.getOutputPacked2DCoords(e,n);break;case 3:r[i]=this.getOutputPacked3DCoords(e,n);break;default:r[i]=this.getOutputPackedNDCoords(e,n)}let o=`\n      void setOutput(vec4 val) {\n        ${G(this.context.glContext.version).output} = val;\n      }\n    `;return r.floatTextureSetRGBA=new k(o),r}getUnpackedOutputSamplingSnippet(t){let e=t.unpackedShape,n=[t.width,t.height],r={},i="getOutputCoords";switch(e.length){case 0:r[i]=this.getOutputScalarCoords();break;case 1:r[i]=this.getOutputUnpacked1DCoords(e,n);break;case 2:r[i]=this.getOutputUnpacked2DCoords(e,n);break;case 3:r[i]=this.getOutputUnpacked3DCoords(e,n);break;case 4:r[i]=this.getOutputUnpacked4DCoords(e,n);break;case 5:r[i]=this.getOutputUnpacked5DCoords(e,n);break;case 6:r[i]=this.getOutputUnpacked6DCoords(e,n);break;default:throw new Error(`Unsupported output dimensionality: ${e.length}`)}let o=`\n        void setOutput(float val) {\n          ${G(this.context.glContext.version).output} = vec4(val, 0, 0, 0);\n        }\n    `;return r.floatTextureSetR=new k(o),r}getOutputScalarCoords(){return new k("\n      int getOutputCoords() {\n        return 0;\n      }\n    ")}getOutputPacked1DCoords(t,e){let n=e,r="";return 1===n[0]?(r=`\n          int getOutputCoords() {\n            return 2 * int(TexCoords.y * ${n[1]}.0);\n          }\n        `,new k(r)):1===n[1]?(r=`\n          int getOutputCoords() {\n            return 2 * int(TexCoords.x * ${n[0]}.0);\n          }\n        `,new k(r)):(r=`\n        int getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                 vec2(${n[0]}, ${n[1]}));\n          return 2 * (resTexRC.y * ${n[0]} + resTexRC.x);\n        }\n      `,new k(r))}getOutputPacked2DCoords(t,e){let n="";if(Ge.arraysEqual(t,e))return n=`\n        ivec2 getOutputCoords() {\n          return 2 * ivec2(TexCoords.xy * vec2(${e[0]}, ${e[1]}));\n        }\n      `,new k(n);let r=e,i=Math.ceil(t[1]/2);return n=`\n        ivec2 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${r[0]}, ${r[1]}));\n\n          int index = resTexRC.y * ${r[0]} + resTexRC.x;\n\n          // reverse r and c order for packed texture\n          int r = imod(index, ${i}) * 2;\n          int c = 2 * (index / ${i});\n\n          return ivec2(r, c);\n        }\n      `,new k(n)}getOutputPacked3DCoords(t,e){let n=[e[0],e[1]],r=Math.ceil(t[2]/2),i=r*Math.ceil(t[1]/2);return new k(`\n        ivec3 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${n[0]}, ${n[1]}));\n          int index = resTexRC.y * ${n[0]} + resTexRC.x;\n\n          int b = index / ${i};\n          index -= b * ${i};\n\n          // reverse r and c order for packed texture\n          int r = imod(index, ${r}) * 2;\n          int c = 2 * (index / ${r});\n\n          return ivec3(b, r, c);\n        }\n      `)}getOutputPackedNDCoords(t,e){let n=[e[0],e[1]],r=Math.ceil(t[t.length-1]/2),i=r*Math.ceil(t[t.length-2]/2),o=i,s="",a="b, r, c";for(let l=2;l<t.length-1;l++)o*=t[t.length-l-1],s=`\n      int b${l} = index / ${o};\n      index -= b${l} * ${o};\n    `+s,a=`b${l}, `+a;let u=`\n      ivec${t.length}
6 getOutputCoords() {\n        ivec2 resTexRC = ivec2(TexCoords.xy *\n                              vec2(${n[0]}, ${n[1]}));\n        int index = resTexRC.y * ${n[0]} + resTexRC.x;\n\n        ${s}\n\n        int b = index / ${i};\n        index -= b * ${i};\n\n        // reverse r and c order for packed texture\n        int r = imod(index, ${r}) * 2;\n        int c = 2 * (index / ${r});\n\n        return ivec${t.length}(${a});\n      }\n    `;return new k(u)}getOutputUnpacked1DCoords(t,e){let n=`\n        int getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${e[0]}, ${e[1]}));\n          return resTexRC.y * ${e[0]} + resTexRC.x;\n        }\n      `;return new k(n)}getOutputUnpacked2DCoords(t,e){let n=`\n        ivec2 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${e[0]}, ${e[1]}));\n          int index = resTexRC.y * ${e[0]} + resTexRC.x;\n          int r = index / ${t[1]};\n          int c = index - r * ${t[1]};\n          return ivec2(r, c);\n        }\n      `;return new k(n)}getOutputUnpacked3DCoords(t,e){let n="",r=t.length,i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=t[r-1];for(let a=r-3;a>=0;--a)i[a]=i[a+1]*t[a+1];let o=["r","c","d"],s=i.map((t,e)=>`int ${o[e]} = index / ${t}; ${e===i.length-1?`int ${o[e+1]} = index - ${o[e]} * ${t}`:`index -= ${o[e]} * ${t}`};`).join("");return n=`\n        ivec3 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${e[0]}, ${e[1]}));\n          int index = resTexRC.y * ${e[0]} + resTexRC.x;\n          ${s}\n          return ivec3(r, c, d);\n        }\n      `,new k(n)}getOutputUnpacked4DCoords(t,e){let n="",r=t.length,i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=t[r-1];for(let a=r-3;a>=0;--a)i[a]=i[a+1]*t[a+1];let o=["r","c","d","d2"],s=i.map((t,e)=>`int ${o[e]} = index / ${t}; ${e===i.length-1?`int ${o[e+1]} = index - ${o[e]} * ${t}`:`index -= ${o[e]} * ${t}`};`).join("");return n=`\n      ivec4 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${e[0]}, ${e[1]}));\n          int index = resTexRC.y * ${e[0]} + resTexRC.x;\n          ${s}\n          return ivec4(r, c, d, d2);\n        }\n      `,new k(n)}getOutputUnpacked5DCoords(t,e){let n="",r=t.length,i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=t[r-1];for(let a=r-3;a>=0;--a)i[a]=i[a+1]*t[a+1];let o=["r","c","d","d2","d3"],s=i.map((t,e)=>`int ${o[e]} = index / ${t}; ${e===i.length-1?`int ${o[e+1]} = index - ${o[e]} * ${t}`:`index -= ${o[e]} * ${t}`};`).join("");return n=`\n      ivec5 getOutputCoords() {\n          ivec2 resTexRC = ivec2(TexCoords.xy *\n                                vec2(${e[0]}, ${e[1]}));\n          int index = resTexRC.y * ${e[0]} + resTexRC.x;\n          ${s}\n          return ivec5(r, c, d, d2, d3);\n        }\n      `,new k(n)}getOutputUnpacked6DCoords(t,e){let n="",r=t.length,i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=t[r-1];for(let a=r-3;a>=0;--a)i[a]=i[a+1]*t[a+1];let o=["r","c","d","d2","d3","d4"],s=i.map((t,e)=>`int ${o[e]} = index / ${t}; ${e===i.length-1?`int ${o[e+1]} = index - ${o[e]} * ${t}`:`index -= ${o[e]} * ${t}`};`).join("");return n=`\n     ivec6 getOutputCoords() {\n         ivec2 resTexRC = ivec2(TexCoords.xy *\n                               vec2(${e[0]}, ${e[1]}));\n         int index = resTexRC.y * ${e[0]} + resTexRC.x;\n         ${s}\n         return ivec6(r, c, d, d2, d3, d4);\n       }\n     `,new k(n)}getCommonUtilFuncs(){let t={},e="uvFromFlat";t[e]=new k("\n    vec2 uvFromFlat(int texNumR, int texNumC, int index) {\n      int texC = index / texNumR;\n      int texR = index - texC * texNumR;\n      // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to\n      //       v.\n      return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);\n    }\n    "),e="packedUVfrom1D",t[e]=new k("\n      vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n        int texelIndex = index / 2;\n        int texR = texelIndex / texNumC;\n        int texC = texelIndex - texR * texNumC;\n        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n      }\n      "),e="packedUVfrom2D",t[e]=new k("\n      vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {\n        int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n        int texR = texelIndex / texNumC;\n        int texC = texelIndex - texR * texNumC;\n        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n      }\n      "),e="packedUVfrom3D",t[e]=new k("\n      vec2 packedUVfrom3D(int texNumR, int texNumC,\n          int texelsInBatch, int texelsInLogicalRow, int b,\n          int row, int col) {\n        int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n        int texR = index / texNumC;\n        int texC = index - texR * texNumC;\n        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n      }\n      "),e="sampleTexture";let n=G(this.context.glContext.version);return t[e]=new k(`\n        float sampleTexture(sampler2D textureSampler, vec2 uv) {\n            return ${n.texture2D}(textureSampler, uv).r;\n        }`),t}
6getInputsSamplingSnippets(){let t={},e=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((n,r)=>{let i=this.context.inputTextureLayouts[r],o=On(n);i.isPacked?t[o]=this.getPackedSamplerFromInput(o,n,i):t[o]=this.getUnpackedSamplerFromInput(o,n,i);let s=Ku(n);i.unpackedShape.length<=e.unpackedShape.length&&(i.isPacked?t[s]=this.getPackedSamplerAtOutputCoords(s,i,e,n):t[s]=this.getUnpackedSamplerAtOutputCoords(s,i,e,n))}),t}getPackedSamplerAtOutputCoords(t,e,n,r){let i,o=e.unpackedShape,s=n.unpackedShape,a=On(r),u=o.length,l=s.length,p=$t.getBroadcastDims(o,s),c=kt(l),d=l-u,h=ee();i=0===u?"":l<2&&p.length>=1?"coords = 0;":p.map(t=>`coords.${h[t+d]} = 0;`).join("\n");let f="";f=l<2&&u>0?"coords":o.map((t,e)=>`coords.${h[e+d]}`).join(", ");let g="return outputValue;",m=1===B.size(o),b=1===B.size(s);if(1!==u||m||b){if(m&&!b)g=1===l?"\n          return vec4(outputValue.x, outputValue.x, 0., 0.);\n        ":"\n          return vec4(outputValue.x);\n        ";else if(p.length){let t=u-2,e=u-1;p.indexOf(t)>-1&&p.indexOf(e)>-1?g="return vec4(outputValue.x);":p.indexOf(t)>-1?g="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":p.indexOf(e)>-1&&(g="return vec4(outputValue.xx, outputValue.zz);")}}else g="\n        return vec4(outputValue.xy, outputValue.xy);\n      ";let y=`\n        int lastDim = coords.${h[l-1]};\n        coords.${h[l-1]} = coords.${h[l-2]};\n        coords.${h[l-2]} = lastDim;\n      `;return new k(`\n      vec4 ${t}
6() {\n        ${c} coords = getOutputCoords();\n        ${y}\n        ${i}\n        vec4 outputValue = ${a}(${f});\n        ${g}\n      }\n    `,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(t,e,n,r){let i=[n.width,n.height],o=[e.width,e.height],s=e.unpackedShape.length,a=n.unpackedShape.length,u=e.unpackedShape,l=n.unpackedShape,p=On(r);if(s===a&&Ge.arraysEqual(o,i))return new k(`\n          float ${t}() {\n            return sampleTexture(${r}, TexCoords);\n          }\n        `,["coordinates.sampleTexture"]);let c,d=kt(a),h=$t.getBroadcastDims(u,l),f=a-s,g=ee();c=0===s?"":a<2&&h.length>=1?"coords = 0;":h.map(t=>`coords.${g[t+f]} = 0;`).join("\n");let m="";return m=a<2&&s>0?"coords":e.unpackedShape.map((t,e)=>`coords.${g[e+f]}`).join(", "),new k(`\n        float ${t}() {\n          ${d} coords = getOutputCoords();\n          ${c}\n          return ${p}(${m});\n        }\n      `,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(t,e,n){switch(n.unpackedShape.length){case 0:return this.getPackedSamplerScalar(t,e);case 1:return this.getPackedSampler1D(t,e,n);case 2:return this.getPackedSampler2D(t,e,n);case 3:return this.getPackedSampler3D(t,e,n);default:return this.getPackedSamplerND(t,e,n)}}getUnpackedSamplerFromInput(t,e,n){let r=n.unpackedShape;switch(r.length){case 0:return this.getUnpackedSamplerScalar(t,e,n);case 1:return this.getUnpackedSampler1D(t,e,n);case 2:return this.getUnpackedSampler2D(t,e,n);case 3:return this.getUnpackedSampler3D(t,e,n);case 4:return this.getUnpackedSampler4D(t,e,n);case 5:return this.getUnpackedSampler5D(t,e,n);case 6:return this.getUnpackedSampler6D(t,e,n);default:throw new Error(`Unsupported dimension ${r.length}-D`)}}getPackedSamplerScalar(t,e){let n=`\n          vec4 ${t}
6() {\n            return ${G(this.context.glContext.version).texture2D}(${e}, halfCR);\n          }\n        `;return new k(n)}getPackedSampler1D(t,e,n){let r=[n.width,n.height],i=[r[1],r[0]],o=G(this.context.glContext.version),s=`vec4 ${t}(int index) {\n      vec2 uv = packedUVfrom1D(\n      ${i[0]}, ${i[1]}, index);\n      return ${o.texture2D}(${e}, uv);\n    }`;return new k(s,["coordinates.packedUVfrom1D"])}getPackedSampler2D(t,e,n){let r=n.unpackedShape,i=[n.width,n.height],o=G(this.context.glContext.version),s=i[0],a=i[1];if(null!=i&&Ge.arraysEqual(r,i)){let n=`vec4 ${t}(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2(${a}.0, ${s}.0);\n        return ${o.texture2D}(${e}, uv);\n      }`;return new k(n)}let u=i,l=Math.ceil(r[1]/2),p=`vec4 ${t}(int row, int col) {\n      vec2 uv = packedUVfrom2D(${u[1]}, ${u[0]}, ${l}, row, col);\n      return ${o.texture2D}(${e}, uv);\n    }`;return new k(p,["coordinates.packedUVfrom2D"])}getPackedSampler3D(t,e,n){let r=n.unpackedShape,i=[n.width,n.height],o=[i[0],i[1]],s=G(this.context.glContext.version);if(1===r[0]){let i=r.slice(1),o=[1,2],s=lr(r,i),a=["b","row","col"],u=JSON.parse(JSON.stringify(n));u.unpackedShape=s;let l=this.getPackedSamplerFromInput(t,e,u),p=`${l.routineBody}\n      vec4 ${t}(int b, int row, int col) {\n        return ${t}(${fr(a,o)});\n      } `;return new k(p,l.dependencies)}let a=o[0],u=o[1],l=Math.ceil(r[2]/2),p=`vec4 ${t}(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        ${u}, ${a}, ${l*Math.ceil(r[1]/2)}, ${l}, b, row, col);\n      return ${s.texture2D}(${e}, uv);}`;return new k(p,["coordinates.packedUVfrom3D"])}getPackedSamplerND(t,e,n){let r=n.unpackedShape,i=r.length,o=[n.width,n.height],s=G(this.context.glContext.version),a=[o[0],o[1]],u=a[1],l=a[0],p=Math.ceil(r[i-1]/2),c=p*Math.ceil(r[i-2]/2),d="int b, int row, int col",h=`b * ${c} + (row / 2) * ${p} + (col / 2)`;for(let g=2;g<i-1;g++)d=`int b${g}, `+d,c*=r[i-g-1],h=`b${g} * ${c} + `+h;let f=`vec4 ${t}(${d}) {\n      int index = ${h};\n      int texR = index / ${l};\n      int texC = index - texR * ${l};\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${u});\n      return ${s.texture2D}(${e}, uv);\n    }`;return new k(f)}getUnpackedSamplerScalar(t,e,n){let[r,i]=[n.width,n.height];return 1===r&&1===i?new k(`\n          float ${t}() {\n            return sampleTexture(${e}, halfCR);\n          }\n        `,["coordinates.sampleTexture"]):new k(`\n        float ${t}() {\n          int offset_${e} = coordsToOffset(TexCoords, ${r}, ${i});\n          vec2 uv = uvFromFlat(${r}, ${i}, offset_${e});\n          return sampleTexture(${e}, uv);\n        }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(t,e,n){let r=n.width,i=n.height;return 1===i&&1===r?new k(`\n        float ${t}(int index) {\n          return sampleTexture(${e}, halfCR);\n        }\n      `,["coordinates.sampleTexture"]):1===i?new k(`\n          float ${t}(int index) {\n            vec2 uv = vec2((float(index) + 0.5) / ${r}.0, 0.5);\n            return sampleTexture(${e}, uv);\n          }\n        `,["coordinates.sampleTexture"]):1===r?new k(`\n          float ${t}(int index) {\n            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${i}.0);\n            return sampleTexture(${e}, uv);\n          }\n        `,["coordinates.sampleTexture"]):new k(`\n        float ${t}(int index) {\n          vec2 uv = uvFromFlat(${r}, ${i}, index);\n          return sampleTexture(${e}, uv);\n        }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(t,e,n){let r=n.unpackedShape,i=[n.height,n.width];if(null!=i&&Ge.arraysEqual(r,i))return new k(`\n          float ${t}(int row, int col) {\n            vec2 uv = (vec2(row, col) + halfCR) / vec2(${i[1]}.0, ${i[0]}.0);\n            return sampleTexture(${e}, uv);\n          }\n        `,["coordinates.sampleTexture"]);let{newShape:o,keptDims:s}=hr(r),a=o;if(a.length<r.length){let i=lr(r,a),o=JSON.parse(JSON.stringify(n));o.unpackedShape=i;let u=["col","row"],l=`\n          ${this.getUnpackedSamplerFromInput(t,e,o).routineBody}\n          float ${t}(int row, int col) {\n            return ${t}(${fr(u,s)});\n          }\n        `;return new k(l,["coordinates.sampleTexture"])}let u=i[1],l=i[0];if(1===l){let n=`\n          float ${t}(int row, int col) {\n            int offset_${e} = coordsToOffset(TexCoords, ${u}, ${l});\n            float index = dot(vec3(row, col, offset_${e}), vec3(${r[1]}, 1, 1));\n            vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);\n            return sampleTexture(${e}, uv);\n          }\n        `;return new k(n,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(1===u){let n=`\n          float ${t}(int row, int col) {\n            int offset_${e} = coordsToOffset(TexCoords, ${u}, ${l});\n            float index = dot(vec3(row, col, offset_${e}), vec3(${r[1]}, 1, 1));\n            vec2 uv = vec2((index + 0.5) / ${l}.0, 0.5);\n            return sampleTexture(${e}, uv);\n          }\n        `;return new k(n,["coordinates.sampleTexture","coordinates.coordsToOffset"])}let p=`\n        float ${t}(int row, int col) {\n          int index = col * ${r[1]} + row;\n          vec2 uv = uvFromFlat(${u}, ${l}, index);\n          return sampleTexture(${e}, uv);\n        }\n      `;return new k(p,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(t,e,n){let r=n.unpackedShape,i=r[1]*r[2],o=r[2],{newShape:s,keptDims:a}=hr(r),u=s;if(u.length<r.length){let i=lr(r,u),o=["batch","col","row"],s=JSON.parse(JSON.stringify(n));s.unpackedShape=i;let l=this.getUnpackedSamplerFromInput(t,e,s),p=a.reverse(),c=`\n          ${l.rout
6ineBody}\n          float ${t}(int batch, int row, int col) {\n            return ${t}(${fr(o,p)});\n          }\n        `;return new k(c,l.dependencies)}let l=n.width,p=n.height;return new k(`\n          float ${t}(int depth, int row, int col) {\n            // Explicitly use integer operations as dot() only works on floats.\n            int index = depth * ${i} + col * ${o} + row;\n            vec2 uv = uvFromFlat(${l}, ${p}, index);\n            return sampleTexture(${e}, uv);\n          }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(t,e,n){let r=n.unpackedShape,i=r[3],o=r[2]*i,s=r[1]*o,a=n.width,u=n.height;return new k(`\n        float ${t}(int row, int col, int depth, int depth2) {\n          int index = row * ${s} + col * ${o} +\n              depth2 * ${i} + depth;\n          vec2 uv = uvFromFlat(${a}, ${u}, index);\n          return sampleTexture(${e}, uv);\n        }\n      `,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(t,e,n){let r=n.unpackedShape,i=r[4],o=r[3]*i,s=r[2]*o,a=r[1]*s,{newShape:u,keptDims:l}=hr(r);if(u.length<r.length){let i=lr(r,u),o=["row","col","depth","depth2","depth3"],s=JSON.parse(JSON.stringify(n));s.unpackedShape=i;let a=`\n          ${this.getUnpackedSamplerFromInput(t,e,s).routineBody}\n          float ${t}(int row, int col, int depth, int depth2, int depth3) {\n            return ${t}(${fr(o,l)});\n          }\n        `;return new k(a,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let p=n.width,c=n.height;return new k(`\n        float ${t}(int row, int col, int depth, int depth2, int depth3) {\n          int index = row * ${a} + col * ${s} + depth * ${o} +\n          depth3 * ${i} + depth2;\n          vec2 uv = uvFromFlat(${p}, ${c}, index);\n          return sampleTexture(${e}, uv);\n        }\n      `,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(t,e,n){let r=n.unpackedShape,i=r[5],o=r[4]*i,s=r[3]*o,a=r[2]*s,u=r[1]*a,{newShape:l,keptDims:p}=hr(r);if(l.length<r.length){let i=lr(r,l),o=["row","col","depth","depth2","depth3","depth4"],s=JSON.parse(JSON.stringify(n));s.unpackedShape=i;let a=`\n            ${this.getUnpackedSamplerFromInput(t,e,s).routineBody}\n            float ${t}(int row, int col, int depth,\n              int depth2, int depth3, int depth4) {\n              return ${t}(${fr(o,p)});\n            }\n          `;return new k(a,["coordinates.sampleTexture","coordinates.uvFromFlat"])}let c=n.width,d=n.height;return new k(`\n          float ${t}(int row, int col, int depth,\n            int depth2, int depth3, int depth4) {\n            int index = row * ${u} + col * ${a} + depth * ${s} +\n            depth2 * ${o} + depth3 * ${i} + depth4;\n            vec2 uv = uvFromFlat(${c}, ${d}, index);\n            return sampleTexture(${e}, uv);\n          }\n        `,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}
6toVec(){let t=this.context.outputTextureLayout,e=t.shape.length,n=t.strides,r=t.width,i=t.height,o=[];for(let a=0;a<e-1;++a)o.push(`\n        c[${a}] = offset / ${n[a]};`),o.push(`\n        offset -= c[${a}] * ${n[a]};`);o.push(`\n        c[${e-1}] = offset;`);let s=`\n      void toVec(vec2 texCoords, out int c[${e}]) {\n        int offset = coordsToOffset(texCoords, ${r}, ${i});\n        ${o.join("")}\n      }\n      void toVec(int offset, out int c[${e}]) {\n        ${o.join("")}\n      }\n    `;return{toVec:new k(s,["coordinates.coordsToOffset"])}}valueFrom(){let t={};return this.context.programInfo.inputNames.forEach((e,n)=>{let r=this.context.inputTextureLayouts[n],i=(r.unpackedShape.length>0?r.unpackedShape:r.shape).length,o=`_${e}`;t[o]=new k(this.getValueFromSingle(e,i,r.width,r.height,!1),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),o+="_T",t[o]=new k(this.getValueFromSingle(e,i,r.width,r.height,!0),[`shapeUtils.indicesToOffset${o}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),t}getValueFromSingle(t,e,n,r,i){let o=`_${t}`;return i&&(o+="_T"),`\n        float ${o}(int m[${e}]) {\n          int offset = indicesToOffset${o}(m);\n          vec2 coords = offsetToCoords(offset, ${n}, ${r});\n          float value = getColorAsFloat(${G(this.context.glContext.version).texture2D}(${t}, coords));\n          return value;\n        }\n        `}getPackedValueFrom(t,e,n,r,i){let o=`_${t}_Pack`;return i&&(o+="_T"),`\n        vec4 ${o}(int m[${e}]) {\n          int offset = indicesToOffset_${t}(m);\n          vec2 coords = offsetToCoords(offset, ${n}, ${r});\n          return ${G(this.context.glContext.version).texture2D}(${t}, coords);\n        }\n        `}}}),Un,fp=O(()=>{be(),Un=class t extends Wt{constructor(t){super(t)}getFunctions(){return{...this.encodeFloat32(),...this.decodeFloat32()}}getCustomTypes(){return{}}encodeFloat32(){return{encode:new k("highp vec4 encode(highp float f) {\n        return vec4(f, 0.0, 0.0, 0.0);\n      }\n        ")}}decodeFloat32(){return{decode:new k("highp float decode(highp vec4 rgba) {\n        return rgba.r;\n      }\n        ")}}encodeUint8(){let e=t.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new k(`\n      highp vec4 encode(highp float f) {\n        highp float F = abs(f);\n        highp float Sign = step(0.0,-f);\n        highp float Exponent = floor(log2(F));\n        highp float Mantissa = (exp2(- Exponent) * F);\n        Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));\n        highp vec4 rgba;\n        rgba[0] = 128.0 * Sign  + floor(Exponent*exp2(-1.0));\n        rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);\n        rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));\n        rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));\n        ${e}\n        rgba = rgba / 255.0; // values need to be normalized to [0,1]\n        return rgba;\n    }\n        `)}}decodeUint8(){let e=t.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new k(`\n        highp float decode(highp vec4 rgba) {\n          rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]\n          ${e}\n          highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;\n          highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) 
6- 127.0;\n          highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);\n          highp float Result =  Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));\n          return Result;\n      }\n        `)}}static isLittleEndian(){let t=new ArrayBuffer(4),e=new Uint32Array(t),n=new Uint8Array(t);if(e[0]=3735928559,239===n[0])return!0;if(222===n[0])return!1;throw new Error("unknown endianness")}}}),Vn,cp=O(()=>{be(),st(),Vn=class extends Wt{constructor(t){super(t)}getFunctions(){return{...this.setFragColor(),...this.getColorAsFloat()}}getCustomTypes(){return{}}setFragColor(){let t=G(this.context.glContext.version);return{setFragColor:new k(`\n        void setFragColor(float value) {\n            ${t.output} = encode(value);\n        }\n        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new k("\n        float getColorAsFloat(vec4 color) {\n            return decode(color);\n        }\n        ",["encoding.decode"])}}}}),zn,pp=O(()=>{be(),zn=class t extends Wt{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((n,r)=>{let i=this.context.inputTextureLayouts[r].unpackedShape;if(i.length<=t){let r=i.length,o=t-r,s=`bcastIndices_${n}`,a="";for(let t=0;t<r;++t)a+=`\n          realIndices[${t}] = int( mod(float(bcastedIndices[${o+t}]), ${i[t]}.0) );\n          `;let u=`\n        void ${s} (int bcastedIndices[${t}], out int realIndices[${r}]) {\n          ${a}\n        }\n        `;e[s]=new k(u)}}),e}bcastMatmulIndex(){let t=this.context.outputTextureLayout.shape.length,e={};return this.context.programInfo.inputNames.forEach((n,r)=>{let i=this.context.inputTextureLayouts[r].shape;if(!(i.length<2||i.length>t)){let r=i.length,o=t-r,s=`bcastMatmulIndices_${n}`,a="";for(let t=0;t<r-2;++t)a+=`\n          realIndices[${t}] = int( mod(float(bcastedIndices[${o+t}]), ${i[t]}.0) );\n          `;let u=`\n        void ${s}(int bcastedIndices[${t}], out int realIndices[${r}]) {\n          ${a}\n          realIndices[${r-1}] = bcastedIndices[${t-1}];\n          realIndices[${r-2}] = bcastedIndices[${t-2}];\n        }\n        `;e[s]=new k(u)}}),e}indicesToOffset(){let e={};return this.context.programInfo.inputNames.forEach((n,r)=>{let i=this.context.inputTextureLayouts[r].shape,o=this.context.inputTextureLayouts[r].strides,s=i.length,a=`indicesToOffset_${n}`;e[a]=new k(t.indexToOffsetSingle(a,s,o)),a=`indicesToOffset_${n}_T`,e[a]=new k(t.indexToOffsetSingle(a,s,o.slice().reverse()))}),e}static indexToOffsetSingle(t,e,n){let r="";for(let i=e-1;i>=0;--i)r+=`\n        offset += indices[${i}] * ${n[i]};\n        `;return`\n      int ${t}(int indices[${e}]) {\n        int offset = 0;\n        ${r}\n        return offset;\n      }\n      `}offsetToIndices(){let e={};return this.context.programInfo.inputNames.forEach((n,r)=>{let i=this.context.inputTextureLayouts[r].shape,o=this.context.inputTextureLayouts[r].strides,s=i.length,a=`offsetToIndices_${n}`;e[a]=new k(t.offsetToIndicesSingle(a,s,o)),a=`offsetToIndices_${n}_T`,e[a]=new k(t.offsetToIndicesSingle(a,s,o.slice().reverse()))}),e}static offsetToIndicesSingle(t,e,n){let r=[];for(let i=0;i<e-1;++i)r.push(`\n      indices[${i}] = offset / ${n[i]};`),r.push(`\n        offset -= indices[${i}] * ${n[i]};`);return r.push(`\n      indices[${e-1}] = offset;`),`\n      void ${t}(int offset, out int indices[${e}]) {\n        ${r.join("")}\n      }\n      `}incrementIndices(){let t={};return this.context.programInfo.inputNames.forEach((e,n)=>{let r=this.context.inputTextureLayouts[n].shape,i=r.length,o=`incrementIndices_${e}`,s="";for(let t=0;t<i;++t)s+=`\n        shape[${t}] = ${r[t]};`;let a=`\n        void ${o}(int axis, out int indices[${i}]) {\n          int shape[${i}];\n          ${s};\n          for(int i = ${i} -1 ; i >= 0; --i) {\n            if(i > axis) continue;\n            indices[i] += 1;\n            if(indices[i] < shape[i]) {\n              break;\n            }\n            indices[i] = 0;\n          }\n        }\n        `;t[o]=new k(a)}),t}}}),Wn,dp=O(()=>{be(),Wn=class extends Wt{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:"+=",
6sub:"-=",mul:"*=",div:"/="},n={};for(let r in e){let i=`${r}Vec`,o="";for(let n=0;n<t;++n)o+=`\n          dest[${n}] ${e[r]} src[${n}];\n          `;let s=`\n        void ${i}(int src[${t}], out int dest[${t}]) {\n          ${o}\n        }\n        `;n[i]=new k(s)}return n}copyVec(){let t=this.context.outputTextureLayout.shape.length,e="";for(let n=0;n<t;++n)e+=`\n        dest[${n}] = src[${n}];\n        `;return{copyVec:new k(`\n      void copyVec(int src[${t}], out int dest[${t}]) {\n        ${e}\n      }\n      `)}}setVecItem(){let t=this.context.outputTextureLayout.shape.length,e=`\n        if(index < 0)\n            index =${t} + index;\n        if (index == 0)\n            m[0] = value;\n        `;for(let n=1;n<t-1;++n)e+=`\n        else if (index == ${n})\n            m[${n}] = value;\n            `;return e+=`\n        else\n            m[${t-1}] = value;\n        `,{setVecItem:new k(`\n      void setVecItem(out int m[${t}], int index, int value) {\n        ${e}\n      }\n        `)}}getVecItem(){let t=this.context.outputTextureLayout.shape.length,e=`\n        if(index < 0)\n            index = ${t} + index;\n        if (index == 0)\n            return m[0];\n      `;for(let n=1;n<t-1;++n)e+=`\n        else if (index == ${n})\n            return m[${n}];\n      `;return e+=`\n        else\n            return m[${t-1}];\n        `,{getVecItem:new k(`\n      int getVecItem(int m[${t}], int index) {\n        ${e}\n      }\n    `)}}}}),Fi,hp=O(()=>{lp(),fp(),cp(),pp(),dp(),Fi={encoding:Un,fragcolor:Vn,vec:Wn,shapeUtils:zn,coordinates:Mn}}),Hn,mp=O(()=>{be(),sp(),hp(),st(),Hn=class{constructor(t,e,n,r){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new En(t,e,n,r),Object.keys(Fi).forEach(t=>{let e=new Fi[t](this.context);this.libs[t]=e});let i=this.glslLibRoutineDependencyGraph;for(let o in this.libs){let t=this.libs[o].getFunctions();for(let e in t){let n,r=o+"."+e;i[r]?(n=i[r],n.routineBody=t[e].routineBody):(n=new Nr(r,t[e].routineBody),i[r]=n);let s=t[e].dependencies;if(s)for(let t=0;t<s.length;++t)if(i[s[t]])n.addDependency(i[s[t]]);else{let e=new Nr(s[t]);i[s[t]]=e,n.addDependency(e)}}}}preprocess(){let t=this.context.programInfo,e=t.shaderSource;return this.context.programInfo.hasMain||(e=`${e}\n      ${Xu(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),e=ap(e),`${ju(this.context.glContext.version)}\n    ${this.getUniforms(t.inputNames,t.variables)}\n    ${this.getImports(e)}\n    ${e}`}getImports(t){let e=this.selectGlslLibRoutinesToBeIncluded(t);if(0===e.length)return"";let n="";for(let r=0;r<e.length;++r){if(!e[r].routineBody)throw new Error(`Missing body for the Glsl Library routine: ${e[r].name}`);n+=e[r].routineBody+"\n"}return n}selectGlslLibRoutinesToBeIncluded(t){let e=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(n=>{let r=n.split(".")[1];-1!==t.indexOf(r)&&e.push(this.glslLibRoutineDependencyGraph[n])}),Dn.returnOrderedNodes(e)}getUniforms(t,e){let n=[];if(t)for(let r of t)n.push(`uniform sampler2D ${r};`);if(e)for(let r of e)n.push(`uniform ${r.type} ${r.name}${r.arrayLength?`[${r.arrayLength}]`:""};`);return n.join("\n")}}}),qn,bp=O(()=>{Kt(),Mt(),mp(),st(),qn=class{constructor(t,e,n){this.profiler=t,this.glContext=e,this.textureLayoutStrategy=n,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,n){this.profiler.event("op",`ProgramManager.run ${t.programInfo.name??"unknown kernel"}`,()=>{let r=this.glContext.gl,i=t.program;r.useProgram(i);try{this.bindOutput(n),this.attributesBound||this.bindAttributes(t.attribLocations),this.bindUniforms(t.uniformLocations,t.programInfo.variables??[],e)}catch(o){throw tt.error("ProgramManager",t.programInfo.shaderSource),o}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEac
6h(t=>this.glContext.deleteProgram(t.program))}build(t,e,n){return this.profiler.event("backend","ProgramManager.build",()=>{let r=new Hn(this.glContext,t,e,n),i=r.preprocess(),o=this.compile(i);return{programInfo:t,program:o,uniformLocations:this.getUniformLocations(o,r.context.programInfo.inputNames,r.context.programInfo.variables),attribLocations:this.getAttribLocations(o)}})}compile(t){if(!this.vertexShader){tt.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");let t=qu(this.glContext.version);this.vertexShader=this.glContext.compileShader(t,this.glContext.gl.VERTEX_SHADER)}z.debug&&tt.verbose("ProrgramManager",`FragShader:\n${t}\n`);let e=this.glContext.compileShader(t,this.glContext.gl.FRAGMENT_SHADER),n=this.glContext.createProgram(this.vertexShader,e);return this.glContext.deleteShader(e),n}bindOutput(t){let e=t.width,n=t.height;tt.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${e}/${n}, shape=${t.shape}, type=${t.tensor.type}`),this.glContext.attachFramebuffer(t.texture,e,n)}bindAttributes(t){let e=t.position,n=t.textureCoord;this.glContext.setVertexAttributes(e,n),this.attributesBound=!0}bindUniforms(t,e,n){let r=this.glContext.gl,i=0;for(let{name:o,type:s,location:a,arrayLength:u}of t){let t=e.find(t=>t.name===o)?.data;if("sampler2D"!==s&&!t)throw new Error(`variable '${o}' does not have data defined in program info`);switch(s){case"sampler2D":this.bindTexture(n[i],a,i),i++;break;case"float":u?r.uniform1fv(a,t):r.uniform1f(a,t);break;case"int":u?r.uniform1iv(a,t):r.uniform1i(a,t);break;default:throw new Error(`Uniform not implemented: ${s}`)}}}bindTexture(t,e,n){this.glContext.bindTextureToUniform(t.texture,n,e)}getAttribLocations(t){return{position:this.getAttribLocation(t,"position"),textureCoord:this.getAttribLocation(t,"textureCoord")}}getUniformLocations(t,e,n){let r=[];if(e)for(let i of e)r.push({name:i,type:"sampler2D",location:this.getUniformLocation(t,i)});if(n)for(let i of n)r.push({...i,location:this.getUniformLocation(t,i.name)});return r}getUniformLocation(t,e){let n=this.glContext.gl.getUniformLocation(t,e);if(null===n)throw new Error(`Uniform ${e} not found.`);return n}getAttribLocation(t,e){return this.glContext.gl.getAttribLocation(t,e)}}}),jn,gp=O(()=>{Mt(),Fr(),jn=class{constructor(t,e,n,r){this.glContext=t,this.layoutStrategy=e,this.profiler=n,this.config=r,this.pendingRead=new Map,r.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(t,e,n,r){let i=this.toEncoderType(t),o=this.glContext.getEncoder(i,e.channels||1,r);if(e.isPacked&&1===r)throw new Error("not implemented");let s,a,u=e.width,l=e.height;if(this.config.reuseTextures){s=`${u}x${l}_${o.format}_${o.internalFormat}_${o.textureType}`,a=this.inUseTextures.get(s),a||(a=[],this.inUseTextures.set(s,a));let e=this.idleTextures.get(s);if(e&&e.length>0){let i=e.pop();return a.push(i),1===r&&this.glContext.updateTexture(i,u,l,o,this.toTextureData(t,n)),i}}tt.verbose("TextureManager",`Creating new texture of size ${e.width}x${e.height}`);let p=this.glContext.allocateTexture(u,l,o,this.toTextureData(t,n));return this.config.reuseTextures&&(a.push(p),this.textureLookup.set(p,s)),p}readTexture(t,e,n){return n||(n=1),this.profiler.event("backend","TextureManager.readTexture",()=>{let r=t.shape.reduce((t,e)=>t*e)*n,i=this.glContext.readTexture(t.texture,t.width,t.height,r,this.toEncoderType(e),n);return this.toTensorData(e,i)})}async readTextureAsync(t,e,n){let r=t.tensor.dataId;if(n||(n=1),this.pendingRead.has(r)){let t=this.pendingRead.get(r);return new Promise(e=>t?.push(e))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(r,[]);let i=t.shape.reduce((t,e)=>t*e)*n;await this.glContext.createAndWaitForFence();let o=this.glContext.readTexture(t.texture,t.width,t.height,i,this.toEncoderType(e),n),s=this.toTensorData(e,o),a=this.pendingRead.get(r);return this.pendingRead.delete(r),a?.forEach(t=>t(s)),s})}readUint8TextureAsFloat(t){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{let e=t.shape.reduce((t,e)=>t*e),n=this.glContext.readTexture(t.texture,t.width,t.height,4*e,"byte",4);return new Float32Array(n.buffer,n.byteOffset,e)})}releaseTexture(t,e){let n;if(this.config.reuseTextures&&(n=this.textureLookup.get(t.texture),n)){e&&this.textureLookup.delete(n);let r=this.inUseTextures.get(n);if(r){let e=r.indexOf(t.texture);if(-1!==e){r.splice(e,1);let i=this.idleTextures.get(n);i||(i=[],this.idleTextures.set(n,i)),i.push(t.texture)}}}(!n||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 new 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()}}}),Xn,yp=O(()=>{Mt(),$s(),ll(),op(),bp(),Bi(),gp(),Xn=class{constructor(t,e){this.backend=t,this.context=e,this.layoutStrategy=new Gn(t.glContext.maxTextureSize),this.programManager=new qn(this.context.profiler,t.glContext,this.layoutStrategy),this.textureManager=new jn(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 Pn(this)}onGraphInitialized(t){let e=t.getValues().filter(t=>-1===t.from&&t.tensor).map(t=>t.tensor.dataId);
6this.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,n=!1){tt.verbose("WebGLSessionHandler","Storing Texture data in cache"),n?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,n){let r=Ls(t,e,np);return{impl:r.opImpl,context:r.opInit?r.opInit(t,n):t}}}});function hg(t){let e=0;for(;e<t.length&&t[e]();++e);return e-1}var Mr,xp=O(()=>{Kt(),Fr(),Fr(),ue(),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,n,r){let i=this.gl,o=i.createTexture();i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);let s=r?n.encode(r,t*e):null;return i.texImage2D(i.TEXTURE_2D,0,n.internalFormat,t,e,0,n.format,n.textureType,s),this.checkError(),o}updateTexture(t,e,n,r,i){let o=this.gl;o.bindTexture(o.TEXTURE_2D,t);let s=r.encode(i,e*n);o.texSubImage2D(o.TEXTURE_2D,0,0,0,e,n,r.format,r.textureType,s),this.checkError()}attachFramebuffer(t,e,n){let r=this.gl;r.bindTexture(r.TEXTURE_2D,t),r.bindFramebuffer(r.FRAMEBUFFER,this.framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),this.checkError(),r.viewport(0,0,e,n),r.scissor(0,0,e,n)}readTexture(t,e,n,r,i,o){let s=this.gl;o||(o=1),this.frameBufferBound||this.attachFramebuffer(t,e,n);let a=this.getEncoder(i,o),u=a.allocate(e*n);return s.bindTexture(s.TEXTURE_2D,t),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,t,0),s.readPixels(0,0,e,n,s.RGBA,a.textureType,u),this.checkError(),a.decode(u,r)}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 n=this.gl;n.vertexAttribPointer(t,3,n.FLOAT,!1,20,0),n.enableVertexAttribArray(t),-1!==e&&(n.vertexAttribPointer(e,2,n.FLOAT,!1,20,12),n.enableVertexAttribArray(e)),this.checkError()}createProgram(t,e){let n=this.gl,r=n.createProgram();return n.attachShader(r,t),n.attachShader(r,e),n.linkProgram(r),r}compileShader(t,e){let n=this.gl,r=n.createShader(e);if(!r)throw new Error(`createShader() returned null with type ${e}`);if(n.shaderSource(r,t),n.compileShader(r),!1===n.getShaderParameter(r,n.COMPILE_STATUS))throw new Error(`Failed to compile shader: ${n.getShaderInfoLog(r)}\nShader source:\n${t}`);return r}deleteShader(t){this.gl.deleteShader(t)}bindTextureToUniform(t,e,n){let r=this.gl;r.activeTexture(r.TEXTURE0+e),this.checkError(),r.bindTexture(r.TEXTURE_2D,t),this.checkError(),r.uniform1i(n,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(),n="";switch(e){case t.NO_ERROR:return;case t.INVALID_ENUM:n="INVALID_ENUM";break;case t.INVALID_VALUE:n="INVALID_VALUE";break;case t.INVALID_OPERATION:n="INVALID_OPERATION";break;case t.INVALID_FRAMEBUFFER_OPERATION:n="INVALID_FRAMEBUFFER_OPERATION";break;case t.OUT_OF_MEMORY:n="OUT_OF_MEMORY";break;case t.CONTEXT_LOST_WEBGL:n="CONTEXT_LOST_WEBGL";break;default:n=`Unknown WebGL Error: ${e.toString(16)}`}throw new Error(n)}}deleteTexture(t){this.gl.deleteTexture(t)}deleteProgram(t){this.gl.deleteProgram(t)}getEncoder(t,e,n=0){if(2===this.version)return new Sn(this.gl,e);switch(t){case"float":return 1===n||this.isRenderFloat32Supported?new Br(this.gl,e):new Br(this.gl,e,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new An(this.gl,e);default:throw new 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 new Error("createBuffer() returned null");let n=this.createDefaultGeometry();return t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,n,t.STATIC_DRAW),this.checkError(),e}createFramebuffer(){let t=this.gl.createFramebuffer();if(!t)throw new 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 new 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 n=2===this.version?t.RGBA32F:t.RGBA;t.texImage2D(t.TEXTURE_2D,0,n,1,1,0,t.RGBA,t.FLOAT,null);let r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0);let i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(e),t.deleteFramebuffer(r),i}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,e,n,r,i,o=this.gl;try{t=o.createTexture(),e=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,t);let s=2===this.version?o.RGBA32F:o.RGBA;return o.texImage2D(o.TEXTURE_2D,0,s,1,1,0,o.RGBA,o.FLOAT,null),o.bindFramebuffer(o.FRAMEBUFFER,e),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,t,0),o.enable(o.BLEND),n=o.createShader(o.VERTEX_SHADER),!!(n&&(o.shaderSource(n,"void main(){}"),o.compileShader(n),r=o.createShader(o.FRAGMENT_SHADER),r)&&(o.shaderSource(r,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),o.compileShader(r),i=o.createProgram(),i))&&(o.attachShader(i,n),o.attachShader(i,r),o.linkProgram(i),o.useProgram(i),o.drawArrays(o.POINTS,0,1),o.getError()===o.NO_ERROR)}finally{o.disable(o.BLEND),i&&o.deleteProgram(i),n&&o.deleteShader(n),r&&o.deleteShader(r),e&&(o.bindFramebuffer(o.FRAMEBUFFER,null),o.deleteFramebuffer(e)),t&&(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(t))}}beginTimer(){if(2===this.version&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,e=this.disjointTimerQueryWebgl2Extension,n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n}throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(2===this.version&&this.disjointTimerQueryWebgl2Extension){let t=this.gl,e=this.disjointTimerQueryWebgl2Extension;return void t.endQuery(e.TIME_ELAPSED_EXT)}throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(t){let e=!1,n=!1;if(2!==this.version||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{let r=this.gl,i=this.disjointTimerQueryWebgl2Extension;e=r.getQueryParameter(t,r.QUERY_RESULT_AVAILABLE),n=r.getParameter(i.GPU_DISJOINT_EXT)}return e&&!n}getTimerResult(t){let e=0;if(2!==this.version)throw new Error("WebGL1 profiling currently not supported");{let n=this.gl;e=n.getQueryParameter(t,n.QUERY_RESULT),n.deleteQuery(t)}return e/1e6}async waitForQueryAndGetTime(t){return await ai(()=>this.isTimerResultAvailable(t)),this.getTimerResult(t)}async createAndWaitForFence(){let t=this.createFence(this.gl);
6return this.pollFence(t)}createFence(t){let e,n=t,r=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);return t.flush(),e=null===r?()=>!0:()=>{let t=n.clientWaitSync(r,0,0);return t===n.ALREADY_SIGNALED||t===n.CONDITION_SATISFIED},{query:r,isFencePassed:e}}async pollFence(t){return new Promise(e=>{this.addItemToPoll(()=>t.isFencePassed(),()=>e())})}pollItems(){let t=hg(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 ai(()=>(this.pollItems(),0===this.itemsToPoll.length))}}});function Ci(t){let e;if(t&&"webgl2"!==t||!("webgl2"in mr)?(!t||"webgl"===t)&&"webgl"in mr&&(e=mr.webgl):e=mr.webgl2,!e)try{e=Tp(bg(),t)}catch{e=Tp(mg(),t)}t=t||1===e.version?"webgl":"webgl2";let n=e.gl;return mr[t]=e,n.isContextLost()?(delete mr[t],Ci(t)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),e)}function Tp(t,e){let n,r={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!e||"webgl2"===e)&&(n=t.getContext("webgl2",r),n))try{return new Mr(n,2)}catch(i){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${i}`)}if((!e||"webgl"===e)&&(n=t.getContext("webgl",r)||t.getContext("experimental-webgl",r),n))try{return new Mr(n,1)}catch(i){tt.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${i}`)}throw new Error("WebGL is not supported")}function mg(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");let t=document.createElement("canvas");return t.width=1,t.height=1,t}function bg(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}var mr,wp=O(()=>{Mt(),xp(),mr={}}),Kn,vp=O(()=>{Kt(),Mt(),yp(),wp(),Kn=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=Ci(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 Xn(this,t)}dispose(){this.glContext.dispose()}}});async function Ni(t){if(!t)return Ni(["webgl"]);{let e="string"==typeof t?[t]:t;for(let t of e){let e=Ip.get(t);if(e)return e;let n=await yg(t);if(n)return n}}throw new Error("no available backend to use")}async function yg(t){let e=gg;if(typeof e[t]<"u"&&xg(e[t])){let n=e[t],r=n.initialize();if("object"==typeof r&&"then"in r&&(r=await r),r)return Ip.set(t,n),n}}function xg(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 Ip,gg,_p=O(()=>{vp(),Ip=new Map,gg={webgl:new Kn}}),Ri,Jn,Op=O(()=>{Mt(),Ri=class{constructor(t,e){this.op=t,this.node=e}},Jn=class{constructor(t,e,n){this.graph=t,this.profiler=n,this.initialize(e)}
6initialize(t){this.profiler.event("session","ExecutionPlan.initialize",()=>{let e=this.graph.getNodes();if(e.length!==t.length)throw new Error("The size of nodes and OPs do not match.");this._ops=t.map((t,n)=>new Ri(t,e[n])),this.reset(),this._starter=[],this._ops.forEach((t,e)=>{let n=!0;for(let r of t.node.inputs)if(!this._values[r]&&-1===this.graph.getInputIndices().indexOf(r)){n=!1;break}n&&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 n=t.createInferenceHandler(),r=this.graph.getInputIndices();if(e.length!==r.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${e.length} expected: ${r.length}`);e.forEach((t,e)=>{let n=r[e];this._values[n]=t});let i=this._starter.slice(0),o=this.graph.getValues(),s=this.graph.getNodes(),a=0;for(;a<i.length;){let t=i[a++],e=this._ops[t],r=e.node.inputs.map(t=>this._values[t]);if(-1!==r.indexOf(void 0))throw new Error(`unresolved input detected: op: ${e.node}`);let u=r;tt.verbose("ExecPlan",`Running op:${e.node.name} (${u.map((t,n)=>`'${e.node.inputs[n]}': ${t.type}[${t.dims.join(",")}]`).join(", ")})`);let l=await this.profiler.event("node",e.node.name,async()=>e.op.impl(n,u,e.op.context));if(l.length!==e.node.outputs.length)throw new Error("the size of output does not match model definition.");l.forEach((t,n)=>{let r=e.node.outputs[n];if(this._values[r])throw new Error(`output [${r}] already has value: op:${e.node.name}`);this._values[r]=t});let p=new Set;l.forEach((t,n)=>{let r=e.node.outputs[n];for(let e of o[r].to){let t=s[e],n=!0;for(let e of t.inputs)if(!this._values[e]){n=!1;break}n&&p.add(e)}}),i.push(...p)}let u=[];for(let t=0;t<this.graph.getOutputIndices().length;t++){let e=this.graph.getOutputIndices()[t],n=this._values[e];if(void 0===n)throw new Error(`required output [${e}] does not have value`);0===e?await n.getData():n.data,u.push(n)}return tt.verbose("ExecPlan","disposing of inferenceHandler"),n.dispose(),u})}}}),q,jt,Ur,Sp=O(()=>{Pr(),q=rr(sr()),ze(),Y(),jt=F.experimental.fbs,Ur=class t{constructor(e){if(this._attributes=new Map,null!=e){for(let n of e)n instanceof q.onnx.AttributeProto?this._attributes.set(n.name,[t.getValue(n),t.getType(n)]):n instanceof jt.Attribute&&this._attributes.set(n.name(),[t.getValue(n),t.getType(n)]);if(this._attributes.size<e.length)throw new Error("duplicated attribute names")}}set(t,e,n){this._attributes.set(t,[n,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,n){let r=this._attributes.get(t);if(void 0===r){if(void 0!==n)return n;throw new Error(`required attribute not found: ${t}`)}if(r[1]!==e)throw new Error(`type mismatch: expected ${e} but got ${r[1]}`);return r[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 new 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 new Error("graph attribute is not supported yet");let n=this.getValueNoCheck(t);if(e===q.onnx.AttributeProto.AttributeType.INT&&Nt.isLong(n))return Nt.longToNumber(n);if(e===q.onnx.AttributeProto.AttributeType.INTS){let t=n,e=new Array(t.length);for(let n=0;n<t.length;n++){let r=t[n];e[n]=Nt.longToNumber(r)}return e}if(e===q.onnx.AttributeProto.AttributeType.TENSOR)return t instanceof q.onnx.AttributeProto?bt.fromProto(n):bt.fromOrtTensor(n);if(e===q.onnx.AttributeProto.AttributeType.TENSORS){if(t instanceof q.onnx.AttributeProto)return n.map(t=>bt.fromProto(t));if(t instanceof jt.Attribute)return n.map(t=>bt.fromOrtTensor(t))}return e===q.onnx.AttributeProto.AttributeType.STRING&&t instanceof q.onnx.AttributeProto?kr(n):e===q.onnx.AttributeProto.AttributeType.STRINGS&&t instanceof q.onnx.AttributeProto?n.map(kr):n}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 new Error(`unsupported attribute type: ${q.onnx.AttributeProto.AttributeType[t.type]}`)}}static getValueNoCheckFromOrtFormat(t){switch(t.type()){case jt.AttributeType.FLOAT:return t.f();case jt.AttributeType.INT:return t.i();case jt.AttributeType.STRING:return t.s();case jt.AttributeType.TENSOR:return t.t();case jt.AttributeType.GRAPH:return t.g();case jt.AttributeType.FLOATS:return t.floatsArray();case jt.AttributeType.INTS:{let e=[];for(let n=0;n<t.intsLength();n++)e.push(t.ints(n));return e}case jt.AttributeType.STRINGS:{let e=[];for(let n=0;n<t.stringsLength();n++)e.push(t.strings(n));return e}case jt.AttributeType.TENSORS:{let e=[];for(let n=0;n<t.tensorsLength();n++)e.push(t.tensors(n));return e}default:throw new Error(`unsupported attribute type: ${jt.AttributeType[t.type()]}`)}}}}),Mi,Yn,Ui,ce,Zn,Gi,Ap=O(()=>{Sp(),Pr(),Mi=rr(sr()),ze(),Y(),Yn=F.experimental.fbs,Ui={from:(t,e)=>new Gi(t,e)},ce=class{constructor(t){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,t&&(this.t
6ype=_t.tensorValueTypeFromProto(t.type.tensorType))}get from(){return this._from}get to(){return this._to}},Zn=class{constructor(t,e){t instanceof Mi.onnx.NodeProto?(this.name=t.name,this.opType=t.opType,this.attributes=new Ur(t.attribute)):t instanceof Yn.Node&&(this.name=e??t.name(),this.opType=t.opType(),this.attributes=new Ur(_t.tensorAttributesFromORTFormat(t))),this.inputs=[],this.outputs=[],this.executeNode=!0}},Gi=class{constructor(t,e){if(!t)throw new 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 Mi.onnx.GraphProto)this.buildGraphFromOnnxFormat(t);else{if(!(t instanceof Yn.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(t)}}buildGraphFromOnnxFormat(t){let e=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let n=new Map;if(!t.input)throw new Error("missing information in graph: input");let r=[];for(let i of t.input){if(e.has(i.name))throw new Error(`duplicated input name: ${i.name}`);let t=this._allData.push(new ce(i))-1;e.set(i.name,t),r.push(i.name)}if(!t.initializer)throw new Error("missing information in graph: initializer");for(let i of t.initializer){let t=e.get(i.name);if(void 0===t){let n=new ce;n.type={shape:{dims:_t.tensorDimsFromProto(i.dims)},tensorType:_t.tensorDataTypeFromProto(i.dataType)},t=this._allData.push(n)-1,e.set(i.name,t)}this._allData[t]._from=-1,this._allData[t].tensor=bt.fromProto(i)}for(let i=0;i<this._allData.length;i++)this._allData[i].tensor||(this._allInputIndices.push(i),this._allInputNames.push(r[i]));if(!t.output)throw new Error("missing information in graph: output");for(let i of t.output){if(e.has(i.name))throw new Error(`duplicated output name: ${i.name}`);let t=this._allData.push(new ce(i))-1;e.set(i.name,t),this._allOutputIndices.push(t),this._allOutputNames.push(i.name)}if(!t.node)throw new Error("missing information in graph: node");for(let i of t.node){if(!i.name)for(let e=0;;e++){let t=`unnamed_${i.opType}_${e}`;if(!n.has(t)){i.name=t;break}}if(n.has(i.name))throw new Error(`duplicated node name: ${i.name}`);let t=this._nodes.push(new Zn(i))-1;n.set(i.name,t)}for(let i=0;i<this._nodes.length;i++){let n=this._nodes[i],r=t.node[i];if(!r.output)throw new Error(`missing output for node: ${r.name}`);for(let t of r.output){let o=e.get(t);if(typeof o>"u"&&(o=this._allData.push(new ce)-1,e.set(t,o)),n.outputs.push(o),void 0!==this._allData[o]._from)throw new Error(`multiple nodes output to one data value: ${o}`);if(this._allData[o]._from=i,"Constant"===r.opType){if(!r.attribute||1!==r.attribute.length||!r.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!r.output||1!==r.output.length)throw new Error("missing output or incorrect number of outputs for this Constant operator");n.outputs.pop(),n.executeNode=!1,this._allData[o]._from=-1,this._allData[o].tensor=bt.fromProto(r.attribute[0].t)}}}for(let i=0;i<this._nodes.length;i++){let n=this._nodes[i],r=t.node[i];if(!r.input)throw new Error(`missing input for node: ${r.name}`);for(let t of r.input){let o=e.get(t);if(typeof o>"u"){if(""===t&&(3===r.input.length||4===r.input.length)&&"Resize"===r.opType)continue;throw new Error(`unrecognized input '${t}' for node: ${r.name}`)}n.inputs.push(o),this._allData[o]._to.push(i)}}return!0}buildGraphFromOrtFormat(t){let e=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];let n=new Map,r=[];for(let i=0;i<t.inputsLength();i++){let n=t.inputs(i);if(e.has(n))throw new Error(`duplicated input name: ${n}`);for(let i=0;i<t.nodeArgsLength();i++)if(t.nodeArgs(i)?.name()===n){let o=new ce;if(t.nodeArgs(i)?.type()?.valueType()!==Yn.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");let s=t.nodeArgs(i).type().value(new Yn.TensorTypeAndShape),a=_t.tensorDataTypeFromProto(s.elemType()),u=s.shape(),l=[];for(let t=0;t<u.dimLength();t++)l.push(Nt.longToNumber(u.dim(t).value().dimValue()));o.type={shape:{dims:l},tensorType:a};let p=this._allData.push(o)-1;e.set(n,p),r.push(n)}}for(let i=0;
6i<t.initializersLength();i++){let n=t.initializers(i),r=e.get(n.name());if(void 0===r){let t=new ce,i=_t.tensorDimsFromORTFormat(n),o=_t.tensorDataTypeFromProto(n.dataType());t.type={shape:{dims:i},tensorType:o},r=this._allData.push(t)-1,e.set(n.name(),r)}this._allData[r]._from=-1,this._allData[r].tensor=bt.fromOrtTensor(n)}for(let i=0;i<this._allData.length;i++)this._allData[i].tensor||(this._allInputIndices.push(i),this._allInputNames.push(r[i]));for(let i=0;i<t.outputsLength();i++){let n=t.outputs(i);if(e.has(n))throw new Error(`duplicated output name: ${n}`);let r=this._allData.push(new ce)-1;e.set(n,r),this._allOutputIndices.push(r),this._allOutputNames.push(n)}if(!t.nodes)throw new Error("missing information in graph: node");for(let i=0;i<t.nodesLength();i++){let e=t.nodes(i),r=e.name();if(!r)for(let t=0;r=`unnamed_${e.opType()}_${t}`,n.has(r);t++);if(n.has(r))throw new Error(`duplicated node name: ${r}`);let o=this._nodes.push(new Zn(e,r))-1;n.set(r,o)}for(let i=0;i<this._nodes.length;i++){let n=this._nodes[i],r=t.nodes(i);if(null==r)throw new Error(`No node exists at index ${i}`);if(0===r?.outputsLength())throw new Error(`missing output for node: ${r.name}`);for(let t=0;t<r?.outputsLength();t++){let o=r?.outputs(t),s=e.get(o);if(typeof s>"u"&&(s=this._allData.push(new ce)-1,e.set(o,s)),n.outputs.push(s),void 0!==this._allData[s]._from)throw new Error(`multiple nodes output to one data value: ${s}`);if(this._allData[s]._from=i,"Constant"===r.opType()){if(1!==r.attributesLength()||!r.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(1!==r.outputsLength())throw new 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.fromOrtTensor(r.attributes(0).t())}}}for(let i=0;i<this._nodes.length;i++){let n=this._nodes[i],r=t.nodes(i);if(0===r.inputsLength())throw new Error(`missing input for node: ${r.name}`);for(let t=0;t<r.inputsLength();t++){let o=r.inputs(t),s=e.get(o);if(typeof s>"u")throw new Error(`unrecognized input '${o}' for node: ${r.name()}`);n.inputs.push(s),this._allData[s]._to.push(i)}}}checkIsAcyclic(){let t=new Set;this._allInputIndices.forEach(e=>{this._allData[e]._to.forEach(e=>{t.add(e)})});let e=Array.from(t),n=new Array(this._nodes.length).fill("white");for(;e.length>0;){let t=e.pop();"gray"===n[t]?n[t]="black":(e.push(t),n[t]="gray",this._nodes[t].outputs.forEach(r=>{let i=this._allData[r];if(typeof i.tensor<"u")throw new Error("node outputs should not be initialized");if(i._from!==t)throw new Error("from property of the Value object doesn't match index of Node being processed");i._to.forEach(t=>{if("gray"===n[t])throw new Error("model graph is cyclic");"white"===n[t]&&e.push(t)})}))}}transformGraph(t){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),t&&t.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let t=0,e=new Array(this._nodes.length,0),n=0;for(let r=0;r<this._nodes.length;r++)e[r]=n,this._nodes[r].executeNode?(n!==r&&(this._nodes[n]=this._nodes[r]),n++):this._nodes[r].outputs.forEach(t=>{this._allData[t]._from=-2});this._nodes.splice(n,this._nodes.length-n);for(let r=0;r<this._allData.length;r++){let t=this._allData[r];void 0!==t._from&&-1!==t._from&&-2!==t._from&&(t._from=e[t._from]);for(let n=0;n<t._to.length;n++){if(!(t._to[n]>=0))throw new Error("Trying to update a removed node");t._to[n]=e[t._to[n]]}}t=0;for(let r=0;r<this._allData.length;r++)if(-2!==this._allData[r].from||-1!==this._allOutputIndices.indexOf(r+t)){if(t>0){let e=-1;void 0!==this._allData[r].from&&-1!==this._allData[r].from?(e=this._nodes[this._allData[r].from].outputs.indexOf(r+t),-1!==e&&(this._nodes[this._allData[r].from].outputs[e]=r)):(e=this._allInputIndices.indexOf(r+t),-1!==e&&(this._allInputIndices[e]=r)),this._allData[r].to.forEach(n=>{e=this._nodes[n].inputs.indexOf(r+t),-1!==e&&(this._nodes[n].inputs[e]=r)}),0===this._allData[r].to.length&&(e=this._allOutputIndices.indexOf(r+t),-1!==e&&(this._allOutputIndices[e]=r))}}else t++,this._allData.splice(r,1),r--}deleteNode(t){let e=this._nodes[t];
6if(e.outputs.length>1)for(let s=1;s<e.outputs.length;s++)if(this._allData[e.outputs[s]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ");e.executeNode=!1;let n=e.inputs[0],r=e.outputs[0],i=this._allData[r].to;for(let s=0;s<e.inputs.length;s++){let n=this._allData[e.inputs[s]].to.indexOf(t);if(-1===n)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[e.inputs[s]].to.splice(n,1)}this._allData[r]._to=[];let o=this._allOutputIndices.indexOf(r);if(-1!==o&&(this._allOutputIndices[o]=n),i&&i.length>0)for(let s of i){let t=this._nodes[s].inputs.indexOf(r);if(-1===t)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[s].inputs[t]=n,this._allData[n].to.push(s)}}removeAllDropoutNodes(){let t=0;for(let e of this._nodes){if("Dropout"===e.opType){if(1!==e.inputs.length)throw new Error("Dropout nodes should only contain one input. ");if(1!==e.outputs.length&&2!==e.outputs.length)throw new 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 new 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 n=this._nodes[e[0]];if("Clip"===n.opType)if(1===n.inputs.length)try{t.attributes.set("activation_params","floats",[n.attributes.getFloat("min"),n.attributes.getFloat("max")])}catch{t.attributes.set("activation_params","floats",[Ue,Ve])}else{if(!(n.inputs.length>=3&&void 0!==this._allData[n.inputs[1]].tensor&&void 0!==this._allData[n.inputs[2]].tensor))continue;t.attributes.set("activation_params","floats",[this._allData[n.inputs[1]].tensor.floatData[0],this._allData[n.inputs[2]].tensor.floatData[0]])}t.attributes.set("activation","string",n.opType),this.deleteNode(e[0])}}}}}),Pp,Tg,Qn,Ep=O(()=>{xn(),Ap(),Pr(),Pp=rr(sr()),Y(),Tg=F.experimental.fbs,Qn=class{constructor(){}load(t,e,n){let r;if(!n)try{return void this.loadFromOnnxFormat(t,e)}catch(i){if(void 0!==n)throw i;r=i}try{this.loadFromOrtFormat(t,e)}catch(i){throw void 0!==n?i:new Error(`Failed to load model as ONNX format: ${r}\nas ORT format: ${i}`)}}loadFromOnnxFormat(t,e){let n=Pp.onnx.ModelProto.decode(t);if(Nt.longToNumber(n.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=n.opsetImport.map(t=>({domain:t.domain,version:Nt.longToNumber(t.version)})),this._graph=Ui.from(n.graph,e)}loadFromOrtFormat(t,e){let n=new T.ByteBuffer(t),r=Tg.InferenceSession.getRootAsInferenceSession(n).model();if(Nt.longToNumber(r.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let i=0;i<r.opsetImportLength();i++){let t=r.opsetImport(i);this._opsets.push({domain:t?.domain(),version:Nt.longToNumber(t.version())})}this._graph=Ui.from(r.graph(),e)}get graph(){return this._graph}get opsets(){return this._opsets}}}),to,Dp=O(()=>{_p(),Op(),Mt(),Ep(),to=class{constructor(t={}){this._initialized=!1,this.backendHint=t.backendHint,this.profiler=gn.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,n){await this.profiler.event("session","Session.loadModel",async()=>{let r=await Ni(this.backendHint);if(this.sessionHandler=r.createSessionHandler(this.context),this._model=new Qn,"string"==typeof t){let e=t.endsWith(".ort");{let n=await(await fetch(t)).arrayBuffer();this.initialize(new Uint8Array(n),e)}}else if(ArrayBuffer.isView(t))this.initialize(t);else{let r=new Uint8Array(t,e||0,n||t.byteLength);this.initialize(r)}})}initialize(t,e){if(this._initialized)throw new Error("already initialized");
6this.profiler.event("session","Session.initialize",()=>{let n=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(t,n,e),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new Jn(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(t){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{let e=this.normalizeAndValidateInputs(t),n=await this._executionPlan.execute(this.sessionHandler,e);return this.createOutput(n)})}normalizeAndValidateInputs(t){let e=this._model.graph.getInputNames();if(Array.isArray(t)){if(t.length!==e.length)throw new Error(`incorrect input array length: expected ${e.length} but got ${t.length}`)}else{if(t.size!==e.length)throw new Error(`incorrect input map size: expected ${e.length} but got ${t.size}`);let n=new Array(t.size),r=0;for(let i=0;i<e.length;++i){let o=t.get(e[i]);if(!o)throw new Error(`missing input tensor for: '${name}'`);n[r++]=o}t=n}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(),n=this._model.graph.getValues(),r=new Array(e.length);for(let i=0;i<e.length;++i){let o=n[e[i]];r[i]=o.type.shape.dims,this.context.graphInputTypes.push(o.type.tensorType),this.context.graphInputDims.push(t[i].dims)}this.validateInputTensorDims(r,t,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,t),t}validateInputTensorTypes(t,e){for(let n=0;n<e.length;n++){let r=t[n],i=e[n].type;if(r!==i)throw new Error(`input tensor[${n}] check failed: expected type '${r}' but got ${i}`)}}validateInputTensorDims(t,e,n){for(let r=0;r<e.length;r++){let i=t[r],o=e[r].dims;if(!this.compareTensorDims(i,o,n))throw new Error(`input tensor[${r}] check failed: expected shape '[${i.join(",")}]' but got [${o.join(",")}]`)}}compareTensorDims(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r]&&(!n||0!==t[r]))return!1;return!0}createOutput(t){let e=this._model.graph.getOutputNames();if(t.length!==e.length)throw new Error("expected number of outputs do not match number of generated outputs");let n=new Map;for(let r=0;r<e.length;++r)n.set(e[r],t[r]);return n}initializeOps(t){let e=t.getNodes();this._ops=new Array(e.length);for(let n=0;n<e.length;n++)this._ops[n]=this.sessionHandler.resolve(e[n],this._model.opsets,t)}}}),eo,Lp=O(()=>{Kt(),ze(),eo=class{constructor(t){this.session=t,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(t,e,n){let r=new Map;for(let s in t)if(Object.hasOwnProperty.call(t,s)){let e=t[s];r.set(s,new bt(e.dims,e.type,void 0,void 0,e.data))}let i=await this.session.run(r),o={};return i.forEach((t,e)=>{o[e]=new Tt(t.type,t.data,t.dims)}),o}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}}),$p={};Or($p,{onnxjsBackend:()=>wg});var Vi,wg,kp=O(()=>{Dp(),Lp(),wg=new(Vi=class{async init(){}async createInferenceSessionHandler(t,e){let n=new to(e);return await n.loadModel(t),new eo(n)}})}),ro=O(()=>{}),Cp={};Or(Cp,{default:()=>vg});var Bp,Fp,vg,Np=O(()=>{zi(),Xe(),Vr(),Bp="ort-wasm-proxy-worker",(Fp=globalThis.self?.name===Bp)&&(self.onmessage=t=>{let{type:e,in:n}=t.data;try{switch(e){case"init-wasm":no(n.wasm).then(()=>{oo(n).then(()=>{postMessage({type:e})},t=>{postMessage({type:e,err:t})})},t=>{postMessage({type:e,err:t})});break;case"init-ep":{let{epName:t,env:r}=n;io(r,t).then(()=>{postMessage({type:e})},t=>{postMessage({type:e,err:t})});break}case"copy-from":{let{buffer:t}=n,r=zr(t);postMessage({type:e,out:r});break}case"create":{let{model:t,options:r}=n;ao(t,r).then(t=>{postMessage({type:e,out:t})},t=>{postMessage({type:e,err:t})});break}case"release":so(n),postMessage({type:e});break;case"run":{let{sessionId:t,inputIndices:r,inputs:i,outputIndices:o,options:s}=n;uo(t,r,i,o,new Array(o.length).fill(null),s).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},fo([...i,...t]))},t=>{postMessage({type:e,err:t})});break}case"end-profiling":lo(n),postMessage({type:e})}}catch(r){postMessage({type:e,err:r})}}),vg=Fp?null:t=>new Worker(t??br,{type:"module",name:Bp})}),Gp={};Or(Gp,{default:()=>Ig});var Wi,Rp,Ig,Mp=O(()=>{Wi=import.meta.url,Rp=async function(t={}){function e(){return I.buffer!=A.buffer&&j(),A}function n(){return I.buffer!=A.buffer&&j(),$}function r(){return I.buffer!=A.buffer&&j(),D}function i(){return I.buffer!=A.buffer&&j(),N}function o(){return I.buffer!=A.buffer&&j(),F}var s,a,u=Object.assign({},t),l=new Promise((t,e)=>{s=t,a=e}),p="object"==typeof window,c="function"==typeof importScripts,d=c&&"em-pthread"==self.name;u.mountExternalData=(t,e)=>{(u.Ua||(u.Ua=new Map)).set(t,e)},u.unmountExternalData=()=>{delete u.Ua};var h,f,g=globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor,m=Object.assign({},u),b=(t,e)=>{throw e},y="";(p||c)&&(c?y=self.location.href:typeof document<"u"&&document.currentScript&&(y=document.currentScript.src),Wi&&(y=Wi),y=y.startsWith("blob:")?"":y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1),c&&(f=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),h=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var w,T=function(){}.bind(),x=function(){}.bind(),v=T,_=x;if(Object.assign(u,m),m=null,d){let t=function(e){try{var n=e.data,r=n.cmd;if("load"===r){let e=[];self.onmessage=t=>e.push(t),self.startWorker=()=>{postMessage({cmd:"loaded"});for(let n of e)t(n);self.onmessage=t};for(let t of n.handlers)u[t]&&!u[t].proxy||(u[t]=(...e)=>{postMessage({Za:"callHandler",kb:t,args:e})},"print"==t&&(v=u[t]),"printErr"==t&&(_=u[t]));I=n.wasmMemory,j(),O(n.wasmModule)}else if("run"===r){Me(n.pthread_ptr,0,0,1,0,0),Ht(n.pthread_ptr),mt(),ct(),S||(S=!0);try{yt(n.start_routine,n.arg)}catch(i){if("unwind"!=i)throw i}}else"cancel"===r?Ve()&&qe(-1):"setimmediate"!==n.target&&("checkMailbox"===r?S&&qt():r&&(_(`worker: received unknown command ${r}`),_(n)))}catch(i){throw Ue(),i}};var O,S=!1;_=function(...t){t=t.join(" ")},self.alert=function(...t){postMessage({Za:"alert",text:t.join(" "),mb:Ve()})},u.instantiateWasm=(t,e)=>new Promise(t=>{O=n=>{n=new WebAssembly.Instance(n,Y()),e(n),t()}}),self.onunhandledrejection=t=>{throw t.reason||t},self.onmessage=t}u.wasmBinary&&(w=u.wasmBinary);var I,E,P,A,$,D,N,k,F,C=!1;function j(){var t=I.buffer;u.HEAP8=A=new Int8Array(t),u.HEAP16=new Int16Array(t),u.HEAPU8=$=new Uint8Array(t),u.HEAPU16=new Uint16Array(t),u.HEAP32=D=new Int32Array(t),u.HEAPU32
6=N=new Uint32Array(t),u.HEAPF32=new Float32Array(t),u.HEAPF64=F=new Float64Array(t),u.HEAP64=k=new BigInt64Array(t),u.HEAPU64=new BigUint64Array(t)}if(!d){if(!((I=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})).buffer instanceof g))throw _("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),Error("bad memory");j()}var R=[],B=[],L=[],V=0,z=null;function M(){if(0==--V&&z){var t=z;z=null,t()}}function U(t){throw _(t="Aborted("+t+")"),C=!0,P=1,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),a(t),t}var G,H=t=>t.startsWith("data:application/octet-stream;base64,"),q=t=>t.startsWith("file://");function W(t){if(t==G&&w)return new Uint8Array(w);if(f)return f(t);throw"both async and sync fetching of the wasm failed"}function X(t,e,n){return function(t){if(!w&&(p||c)){if("function"==typeof fetch&&!q(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(()=>W(t));if(h)return new Promise((e,n)=>{h(t,t=>e(new Uint8Array(t)),n)})}return Promise.resolve().then(()=>W(t))}(t).then(t=>WebAssembly.instantiate(t,e)).then(n,t=>{_(`failed to asynchronously prepare wasm: ${t}`),U(t)})}function Y(){return{a:{j:J,b:Tt,E:vt,g:It,V:Et,A:Dt,C:Nt,W:kt,T:Ft,L:Ct,S:jt,o:Rt,B:Bt,y:Lt,U:Vt,z:zt,_:Mt,Z:Ut,P:Gt,w:Wt,F:Yt,k:Kt,O:Ht,Y:Jt,I:Zt,J:ne,K:re,G:ie,H:oe,v:se,q:ue,l:le,p:pe,e:ce,X:he,x:fe,d:de,f:ge,i:me,u:be,t:xe,s:ve,Q:Ie,R:Ee,D:ot,h:Pe,n:Ae,M:$e,m:Ne,a:I,r:rt,N:je,c:Re}}}var K={822132:(t,e,r,i)=>{if(void 0===u||!u.Ua)return 1;if((t=St(t>>>0)).startsWith("./")&&(t=t.substring(2)),!(t=u.Ua.get(t)))return 2;if(i>>>=0,(e>>>=0)+(r>>>=0)>t.byteLength)return 3;try{return n().set(t.subarray(e,e+r),i>>>0),0}catch{return 4}},822633:()=>typeof wasmOffsetConverter<"u"};function J(){return typeof wasmOffsetConverter<"u"}function Z(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var Q=t=>{t.terminate(),t.onmessage=()=>{}},tt=t=>{0==st.length&&(ht(),dt(st[0]));var e=st.pop();if(!e)return 6;at.push(e),lt[t.Ra]=e,e.Ra=t.Ra;var n={cmd:"run",start_routine:t.cb,arg:t.ab,pthread_ptr:t.Ra};return e.postMessage(n,t.ib),0},et=0,nt=(t,e,...n)=>{for(var r=2*n.length,i=Je(),s=Ke(8*r),a=s>>>3,u=0;u<n.length;u++){var l=n[u];"bigint"==typeof l?(k[a+2*u]=1n,k[a+2*u+1]=l):(k[a+2*u]=0n,o()[a+2*u+1>>>0]=l)}return t=Ge(t,0,r,s,e),Ye(i),t};function rt(t){if(d)return nt(0,1,t);if(P=t,!(0<et)){for(var e of at)Q(e);for(e of st)Q(e);st=[],at=[],lt=[],C=!0}b(0,new Z(t))}function it(t){if(d)return nt(1,0,t);ot(t)}var ot=t=>{if(P=t,d)throw it(t),"unwind";rt(t)},st=[],at=[],ut=[],lt={},pt=t=>{var e=t.Ra;delete lt[e],st.push(t),at.splice(at.indexOf(t),1),t.Ra=0,He(e)};function ct(){ut.forEach(t=>t())}var dt=t=>new Promise(e=>{t.onmessage=n=>{var r=(n=n.data).cmd;if(n.targetThread&&n.targetThread!=Ve()){var i=lt[n.targetThread];i?i.postMessage(n,n.transferList):_(`Internal error! Worker sent a message "${r}" to target pthread ${n.targetThread}, but that thread no longer exists!`)}else"checkMailbox"===r?qt():"spawnThread"===r?tt(n):"cleanupThread"===r?pt(lt[n.thread]):"killThread"===r?(n=n.thread,r=lt[n],delete lt[n],Q(r),He(n),at.splice(at.indexOf(r),1),r.Ra=0):"cancelThread"===r?lt[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(t.loaded=!0,e(t)):"alert"===r?alert(`Thread ${n.threadId}: ${n.text}`):"setimmediate"===n.target?t.postMessage(n):"callHandler"===r?u[n.handler](...n.args):r&&_(`worker sent an unknown command ${r}`)},t.onerror=t=>{throw _(`worker sent an error! ${t.filename}:${t.lineno}: ${t.message}`),t};var n,r=[];for(n of[])u.hasOwnProperty(n)&&r.push(n);t.postMessage({cmd:"load",handlers:r,wasmMemory:I,wasmModule:E})});function ht(){var t=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});st.push(t)}var ft,gt=t=>{for(;0<t.length;)t.shift()(u)},mt=()=>{var t=Ve(),e=i()[t+52>>>2>>>0];t=i()[t+56>>>2>>>0],Xe(e,e-t),Ye(e)},bt=[],yt=(t,e)=>{et=0;var n=bt[t];n||(t>=bt.length&&(bt.length=t+1),bt[t]=n=ft.get(t)),t=n(e),0<et?P=t:qe(t)};class wt{constructor(t){this.Xa=t-24}}function Tt(t,e,n){var r=new wt(t>>>=0);throw e>>>=0,n>>>=0,i()[r.Xa+16>>>2>>>0]=0,i()[r.Xa+4>>>2>>>0]=e,i()[r.Xa+8>>>2>>>0]=n,t}function xt(t,e,n,r){return d?nt(2,1,t,e,n,r):vt(t,e,n,r)}function vt(t,e,n,r){if(t>>>=0,e>>>=0,n>>>=0,r>>>=0,void 0===g)return _("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var i=[];return d&&0===i.length?xt(t,e,n,r):(t={cb:n,Ra:t,ab:r,ib:i},d?(t.Za="spawnThread",postMessage(t,i),0):tt(t))}var _t=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ot=(t,e,n)=>{var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16<n-e&&t.buffer&&_t)return _t.decode(t.buffer instanceof g?t.slice(e,n):t.subarray(e,n));for(r="";e<n;){var i=t[e++];if(128&i){var o=63&t[e++];if(192==(224&i))r+=String.fromCharCode((31&i)<<6|o);else{var s=63&t[e++];65536>(i=224==(240&i)?(15&i)<<12|o<<6|s:(7&i)<<18|o<<12|s<<6|63&t[e++])?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else r+=String.fromCharCode(i)}return r},St=(t,e)=>(t>>>=0)?Ot(n(),t,e):"";function It(t,e,n){return d?nt(3,1,t,e,n):0}function Et(t,e){if(d)return nt(4,1,t,e)}var Pt=t=>{for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);127>=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e},At=(t,e,n,r)=>{if(!(0<r))return 0;var i=n>>>=0;r=n+r-1;for(var o=0;o<t.length;++o){var s=t.charCodeAt(o);if(55296<=s&&57343>=s&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++o)),127>=s){if(n>=r)break;e[n++>>>0]=s}else{if(2047>=s){if(n+1>=r)break;e[n++>>>0]=192|s>>6}else{if(65535>=s){if(n+2>=r)break;e[n++>>>0]=224|s>>12}else{if(n+3>=r)break;e[n++>>>0]=240|s>>18,e[n++>>>0]=128|s>>12&63}e[n++>>>0]=128|s>>6&63}e[n++>>>0]=128|63&s}}return e[n>>>0]=0,n-i},$t=(t,e,r)=>At(t,n(),e,r);function Dt(t,e){if(d)return nt(5,1,t,e)}
6function Nt(t,e,n){if(d)return nt(6,1,t,e,n)}function kt(t,e,n){return d?nt(7,1,t,e,n):0}function Ft(t,e){if(d)return nt(8,1,t,e)}function Ct(t,e,n){if(d)return nt(9,1,t,e,n)}function jt(t,e,n,r){if(d)return nt(10,1,t,e,n,r)}function Rt(t,e,n,r){if(d)return nt(11,1,t,e,n,r)}function Bt(t,e,n,r){if(d)return nt(12,1,t,e,n,r)}function Lt(t){if(d)return nt(13,1,t)}function Vt(t,e){if(d)return nt(14,1,t,e)}function zt(t,e,n){if(d)return nt(15,1,t,e,n)}var Mt=()=>{U("")},Ut=()=>1;function Gt(t){Me(t>>>0,!c,1,!p,131072,!1),ct()}function Ht(t){t>>>=0,"function"==typeof Atomics.jb&&(Atomics.jb(r(),t>>>2,t).value.then(qt),t+=128,Atomics.store(r(),t>>>2,1))}var qt=()=>{var t=Ve();if(t&&(Ht(t),t=We,!C))try{if(t(),!(0<et))try{d?qe(P):ot(P)}catch(e){e instanceof Z||"unwind"==e||b(0,e)}}catch(e){e instanceof Z||"unwind"==e||b(0,e)}};function Wt(t,e){(t>>>=0)==e>>>0?setTimeout(qt):d?postMessage({targetThread:t,cmd:"checkMailbox"}):(t=lt[t])&&t.postMessage({cmd:"checkMailbox"})}var Xt=[];function Yt(t,e,n,r,i){for(e>>>=0,r/=2,Xt.length=r,n=i>>>0>>>3,i=0;i<r;i++)Xt[i]=k[n+2*i]?k[n+2*i+1]:o()[n+2*i+1>>>0];return(e?K[e]:Be[t])(...Xt)}function Kt(t){t>>>=0,d?postMessage({cmd:"cleanupThread",thread:t}):pt(lt[t])}function Jt(t){}function Zt(t,e){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t),e>>>=0,t=new Date(1e3*t),r()[e>>>2>>>0]=t.getUTCSeconds(),r()[e+4>>>2>>>0]=t.getUTCMinutes(),r()[e+8>>>2>>>0]=t.getUTCHours(),r()[e+12>>>2>>>0]=t.getUTCDate(),r()[e+16>>>2>>>0]=t.getUTCMonth(),r()[e+20>>>2>>>0]=t.getUTCFullYear()-1900,r()[e+24>>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,r()[e+28>>>2>>>0]=t}var Qt=t=>t%4==0&&(t%100!=0||t%400==0),te=[0,31,60,91,121,152,182,213,244,274,305,335],ee=[0,31,59,90,120,151,181,212,243,273,304,334];function ne(t,e){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t),e>>>=0,t=new Date(1e3*t),r()[e>>>2>>>0]=t.getSeconds(),r()[e+4>>>2>>>0]=t.getMinutes(),r()[e+8>>>2>>>0]=t.getHours(),r()[e+12>>>2>>>0]=t.getDate(),r()[e+16>>>2>>>0]=t.getMonth(),r()[e+20>>>2>>>0]=t.getFullYear()-1900,r()[e+24>>>2>>>0]=t.getDay();var n=(Qt(t.getFullYear())?te:ee)[t.getMonth()]+t.getDate()-1|0;r()[e+28>>>2>>>0]=n,r()[e+36>>>2>>>0]=-60*t.getTimezoneOffset(),n=new Date(t.getFullYear(),6,1).getTimezoneOffset();var i=new Date(t.getFullYear(),0,1).getTimezoneOffset();t=0|(n!=i&&t.getTimezoneOffset()==Math.min(i,n)),r()[e+32>>>2>>>0]=t}function re(t){t>>>=0;var e=new Date(r()[t+20>>>2>>>0]+1900,r()[t+16>>>2>>>0],r()[t+12>>>2>>>0],r()[t+8>>>2>>>0],r()[t+4>>>2>>>0],r()[t>>>2>>>0],0),n=r()[t+32>>>2>>>0],i=e.getTimezoneOffset(),o=new Date(e.getFullYear(),6,1).getTimezoneOffset(),s=new Date(e.getFullYear(),0,1).getTimezoneOffset(),a=Math.min(s,o);return 0>n?r()[t+32>>>2>>>0]=+(o!=s&&a==i):0<n!=(a==i)&&(o=Math.max(s,o),e.setTime(e.getTime()+6e4*((0<n?a:o)-i))),r()[t+24>>>2>>>0]=e.getDay(),n=(Qt(e.getFullYear())?te:ee)[e.getMonth()]+e.getDate()-1|0,r()[t+28>>>2>>>0]=n,r()[t>>>2>>>0]=e.getSeconds(),r()[t+4>>>2>>>0]=e.getMinutes(),r()[t+8>>>2>>>0]=e.getHours(),r()[t+12>>>2>>>0]=e.getDate(),r()[t+16>>>2>>>0]=e.getMonth(),r()[t+20>>>2>>>0]=e.getYear(),t=e.getTime(),BigInt(isNaN(t)?-1:t/1e3)}function ie(t,e,n,r,i,o,s){return d?nt(16,1,t,e,n,r,i,o,s):-52}function oe(t,e,n,r,i,o){if(d)return nt(17,1,t,e,n,r,i,o)}function se(t,e,n,o){t>>>=0,e>>>=0,n>>>=0,o>>>=0;var s=(new Date).getFullYear(),a=new Date(s,0,1),u=new Date(s,6,1);s=a.getTimezoneOffset();var l=u.getTimezoneOffset(),p=Math.max(s,l);i()[t>>>2>>>0]=60*p,r()[e>>>2>>>0]=+(s!=l),a=(t=t=>t.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1])(a),u=t(u),l<s?($t(a,n,17),$t(u,o,17)):($t(a,o,17),$t(u,n,17))}var ae=[];function ue(t,e,s){t>>>=0,e>>>=0,s>>>=0,ae.length=0;for(var a;a=n()[e++>>>0];){var u=105!=a;s+=(u&=112!=a)&&s%8?4:0,ae.push(112==a?i()[s>>>2>>>0]:106==a?k[s>>>3]:105==a?r()[s>>>2>>>0]:o()[s>>>3>>>0]),s+=u?8:4}return K[t](...ae)}var le=()=>{},pe=()=>Date.now();function ce(t,e){return _(St(t>>>0,e>>>0))}var de,he=()=>{throw et+=1,"unwind"};function fe(){return 4294901760}de=()=>performance.timeOrigin+performance.now();var ge=()=>navigator.hardwareConcurrency;function me(){return U("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER"),0}function be(t){t>>>=0;var e=n().length;if(t<=e||4294901760<t)return!1;for(var r=1;4>=r;r*=2){var i=e*(1+.2/r);i=Math.min(i,t+100663296);var o=Math;i=Math.max(t,i);t:{o=(o.min.call(o,4294901760,i+(65536-i%65536)%65536)-I.buffer.byteLength+65535)/65536;try{I.grow(o),j();var s=1;break t}catch{}s=void 0}if(s)return!0}return!1}var ye=()=>(U("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER"),0),we={},Te=t=>{t.forEach(t=>{ye()})};function xe(){var t=Error().stack.toString().split("\n");return"Error"==t[0]&&t.shift(),Te(t),we.$a=ye(),we.bb=t,we.$a}function ve(t,e,n){if(t>>>=0,e>>>=0,we.$a==t)var i=we.bb;else"Error"==(i=Error().stack.toString().split("\n"))[0]&&i.shift(),Te(i);for(var o=3;i[o]&&ye()!=t;)++o;for(t=0;t<n&&i[t+o];++t)r()[e+4*t>>>2>>>0]=ye();return t}var _e,Oe={},Se=()=>{if(!_e){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",_:"./this.program"};for(t in Oe)void 0===Oe[t]?delete e[t]:e[t]=Oe[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);_e=n}return _e};function Ie(t,n){if(d)return nt(18,1,t,n);t>>>=0,n>>>=0;var r=0;
6return Se().forEach((o,s)=>{var a=n+r;for(s=i()[t+4*s>>>2>>>0]=a,a=0;a<o.length;++a)e()[s++>>>0]=o.charCodeAt(a);e()[s>>>0]=0,r+=o.length+1}),0}function Ee(t,e){if(d)return nt(19,1,t,e);t>>>=0,e>>>=0;var n=Se();i()[t>>>2>>>0]=n.length;var r=0;return n.forEach(t=>r+=t.length+1),i()[e>>>2>>>0]=r,0}function Pe(t){return d?nt(20,1,t):52}function Ae(t,e,n,r){return d?nt(21,1,t,e,n,r):52}function $e(t,e,n,r){return d?nt(22,1,t,e,n,r):70}var De=[null,[],[]];function Ne(t,e,r,o){if(d)return nt(23,1,t,e,r,o);e>>>=0,r>>>=0,o>>>=0;for(var s=0,a=0;a<r;a++){var u=i()[e>>>2>>>0],l=i()[e+4>>>2>>>0];e+=8;for(var p=0;p<l;p++){var c=n()[u+p>>>0],h=De[t];0===c||10===c?((1===t?v:_)(Ot(h,0)),h.length=0):h.push(c)}s+=l}return i()[o>>>2>>>0]=s,0}var ke=[31,29,31,30,31,30,31,31,30,31,30,31],Fe=[31,28,31,30,31,30,31,31,30,31,30,31],Ce=(t,n)=>{e().set(t,n>>>0)};function je(t,e,n,o){function s(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.length<e;)t=n[0]+t;return t}function a(t,e){return s(t,e,"0")}function u(t,e){function n(t){return 0>t?-1:0<t?1:0}var r;return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function l(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 p(t){var e=t.Sa;for(t=new Date(new Date(t.Ta+1900,0,1).getTime());0<e;){var n=t.getMonth(),r=(Qt(t.getFullYear())?ke:Fe)[n];if(!(e>r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=l(new Date(t.getFullYear(),0,4)),n=l(n),0>=u(e,t)?0>=u(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}t>>>=0,e>>>=0,n>>>=0,o>>>=0;var c=i()[o+40>>>2>>>0];for(var d in o={gb:r()[o>>>2>>>0],fb:r()[o+4>>>2>>>0],Va:r()[o+8>>>2>>>0],Ya:r()[o+12>>>2>>>0],Wa:r()[o+16>>>2>>>0],Ta:r()[o+20>>>2>>>0],Qa:r()[o+24>>>2>>>0],Sa:r()[o+28>>>2>>>0],nb:r()[o+32>>>2>>>0],eb:r()[o+36>>>2>>>0],hb:c?St(c):""},n=St(n),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(d,"g"),c[d]);var h,f,g="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),m="January February March April May June July August September October November December".split(" ");for(d in c={"%a":t=>g[t.Qa].substring(0,3),"%A":t=>g[t.Qa],"%b":t=>m[t.Wa].substring(0,3),"%B":t=>m[t.Wa],"%C":t=>a((t.Ta+1900)/100|0,2),"%d":t=>a(t.Ya,2),"%e":t=>s(t.Ya,2," "),"%g":t=>p(t).toString().substring(2),"%G":p,"%H":t=>a(t.Va,2),"%I":t=>(0==(t=t.Va)?t=12:12<t&&(t-=12),a(t,2)),"%j":t=>{for(var e=0,n=0;n<=t.Wa-1;e+=(Qt(t.Ta+1900)?ke:Fe)[n++]);return a(t.Ya+e,3)},"%m":t=>a(t.Wa+1,2),"%M":t=>a(t.fb,2),"%n":()=>"\n","%p":t=>0<=t.Va&&12>t.Va?"AM":"PM","%S":t=>a(t.gb,2),"%t":()=>"\t","%u":t=>t.Qa||7,"%U":t=>a(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==(n=(t.Qa+371-t.Sa)%7)||3==n&&Qt(t.Ta)||(e=1));else{e=52;var n=(t.Qa+7-t.Sa-1)%7;(4==n||5==n&&Qt(t.Ta%400-1))&&e++}return a(e,2)},"%w":t=>t.Qa,"%W":t=>a(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=>(0<=(t=t.eb)?"+":"-")+("0000"+((t=Math.abs(t)/60)/60*100+t%60)).slice(-4),"%Z":t=>t.hb,"%%":()=>"%"},n=n.replace(/%%/g,"\0\0"),c)n.includes(d)&&(n=n.replace(new RegExp(d,"g"),c[d](o)));return h=n=n.replace(/\0\0/g,"%"),f=Array(Pt(h)+1),At(h,f,0,f.length),(d=f).length>e?0:(Ce(d,t),d.length-1)}function Re(t,e,n,r){return je(t>>>0,e>>>0,n>>>0,r>>>0)}d||function(){for(var t=u.numThreads-1;t--;)ht();R.unshift(()=>{var t;V++,t=()=>M(),d?t():Promise.all(st.map(dt)).then(t)})}();var Be=[rt,it,xt,It,Et,Dt,Nt,kt,Ft,Ct,jt,Rt,Bt,Lt,Vt,zt,ie,oe,Ie,Ee,Pe,Ae,$e,Ne],Le=function(){function t(t,e){return n=Le=t.exports,r=t=>()=>t()>>>0,i=t=>e=>t(e)>>>0,(n=Object.assign({},n)).Ba=r(n.Ba),n.Ca=i(n.Ca),n.emscripten_main_runtime_thread_id=r(n.emscripten_main_runtime_thread_id),n.Oa=i(n.Oa),n.Pa=r(n.Pa),Le=n,ut.push(Le.Ea),ft=Le.Fa,B.unshift(Le.$),E=e,M(),Le;var n,r,i}var e,n,r,i=Y();if(V++,u.instantiateWasm)try{return u.instantiateWasm(i,t)}catch(e){_(`Module.instantiateWasm callback failed with error: ${e}`),a(e)}return G||(G=u.locateFile?H("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":u.locateFile?u.locateFile("ort-wasm-simd-threaded.wasm",y):y+"ort-wasm-simd-threaded.wasm":new 
6URL("/assets/ort-wasm-simd-threaded-B92PF46Y.wasm",import.meta.url).href),(e=i,n=function(e){t(e.instance,e.module)},r=G,w||"function"!=typeof WebAssembly.instantiateStreaming||H(r)||q(r)||"function"!=typeof fetch?X(r,e,n):fetch(r,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,e).then(n,function(t){return _(`wasm streaming compile failed: ${t}`),_("falling back to ArrayBuffer instantiation"),X(r,e,n)}))).catch(a),{}}();u._OrtInit=(t,e)=>(u._OrtInit=Le.aa)(t,e),u._OrtGetLastError=(t,e)=>(u._OrtGetLastError=Le.ba)(t,e),u._OrtCreateSessionOptions=(t,e,n,r,i,o,s,a,l,p)=>(u._OrtCreateSessionOptions=Le.ca)(t,e,n,r,i,o,s,a,l,p),u._OrtAppendExecutionProvider=(t,e)=>(u._OrtAppendExecutionProvider=Le.da)(t,e),u._OrtAddFreeDimensionOverride=(t,e,n)=>(u._OrtAddFreeDimensionOverride=Le.ea)(t,e,n),u._OrtAddSessionConfigEntry=(t,e,n)=>(u._OrtAddSessionConfigEntry=Le.fa)(t,e,n),u._OrtReleaseSessionOptions=t=>(u._OrtReleaseSessionOptions=Le.ga)(t),u._OrtCreateSession=(t,e,n)=>(u._OrtCreateSession=Le.ha)(t,e,n),u._OrtReleaseSession=t=>(u._OrtReleaseSession=Le.ia)(t),u._OrtGetInputOutputCount=(t,e,n)=>(u._OrtGetInputOutputCount=Le.ja)(t,e,n),u._OrtGetInputName=(t,e)=>(u._OrtGetInputName=Le.ka)(t,e),u._OrtGetOutputName=(t,e)=>(u._OrtGetOutputName=Le.la)(t,e),u._OrtFree=t=>(u._OrtFree=Le.ma)(t),u._OrtCreateTensor=(t,e,n,r,i,o)=>(u._OrtCreateTensor=Le.na)(t,e,n,r,i,o),u._OrtGetTensorData=(t,e,n,r,i)=>(u._OrtGetTensorData=Le.oa)(t,e,n,r,i),u._OrtReleaseTensor=t=>(u._OrtReleaseTensor=Le.pa)(t),u._OrtCreateRunOptions=(t,e,n,r)=>(u._OrtCreateRunOptions=Le.qa)(t,e,n,r),u._OrtAddRunConfigEntry=(t,e,n)=>(u._OrtAddRunConfigEntry=Le.ra)(t,e,n),u._OrtReleaseRunOptions=t=>(u._OrtReleaseRunOptions=Le.sa)(t),u._OrtCreateBinding=t=>(u._OrtCreateBinding=Le.ta)(t),u._OrtBindInput=(t,e,n)=>(u._OrtBindInput=Le.ua)(t,e,n),u._OrtBindOutput=(t,e,n,r)=>(u._OrtBindOutput=Le.va)(t,e,n,r),u._OrtClearBoundOutputs=t=>(u._OrtClearBoundOutputs=Le.wa)(t),u._OrtReleaseBinding=t=>(u._OrtReleaseBinding=Le.xa)(t),u._OrtRunWithBinding=(t,e,n,r,i)=>(u._OrtRunWithBinding=Le.ya)(t,e,n,r,i),u._OrtRun=(t,e,n,r,i,o,s,a)=>(u._OrtRun=Le.za)(t,e,n,r,i,o,s,a),u._OrtEndProfiling=t=>(u._OrtEndProfiling=Le.Aa)(t);var Ve=()=>(Ve=Le.Ba)();u._malloc=t=>(u._malloc=Le.Ca)(t),u._free=t=>(u._free=Le.Da)(t);var ze,Me=(t,e,n,r,i,o)=>(Me=Le.Ga)(t,e,n,r,i,o),Ue=()=>(Ue=Le.Ha)(),Ge=(t,e,n,r,i)=>(Ge=Le.Ia)(t,e,n,r,i),He=t=>(He=Le.Ja)(t),qe=t=>(qe=Le.Ka)(t),We=()=>(We=Le.La)(),Xe=(t,e)=>(Xe=Le.Ma)(t,e),Ye=t=>(Ye=Le.Na)(t),Ke=t=>(Ke=Le.Oa)(t),Je=()=>(Je=Le.Pa)();function Ze(){0<V||(d?(s(u),d||gt(B),startWorker(u)):(gt(R),0<V||ze||(ze=!0,u.calledRun=!0,C||(d||gt(B),s(u),d||gt(L)))))}return u.___start_em_js=822690,u.___stop_em_js=822751,u.stackSave=()=>Je(),u.stackRestore=t=>Ye(t),u.stackAlloc=t=>Ke(t),u.UTF8ToString=St,u.stringToUTF8=$t,u.lengthBytesUTF8=Pt,z=function t(){ze||Ze(),ze||(z=t)},Ze(),l},Ig=Rp,"em-pthread"===globalThis.self?.name&&Rp()}),br,_g,Og,Sg,Up,Vp,Ag,zp,Vr=O(()=>{ro(),br=import.meta.url??(typeof document<"u"?document.currentScript?.src:typeof self<"u"?self.location?.href:void 0),_g=typeof location>"u"?void 0:location.origin,Og=(t,e)=>{try{let n=e??br;return(n?new URL(t,n):new URL(t)).origin===_g}catch{return!1}},Sg=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},Up=(Np(),on(Cp)).default,Vp=async()=>{if(!br)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Og(br))return[void 0,Up()];let t=await Sg(br);return[t,Up(t)]},Ag=(Mp(),on(Gp)).default,zp=async(t,e,n)=>[void 0,Ag]}),Hi,qi,co,Wp,Pg,Eg,no,gt,Xe=O(()=>{Vr(),qi=!1,co=!1,Wp=!1,Pg=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Eg=()=>{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}},no=async t=>{if(qi)return Promise.resolve();if(co)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");
6if(Wp)throw new Error("previous call to 'initializeWebAssembly()' failed.");co=!0;let e=t.initTimeout,n=t.numThreads;if(!Eg())throw new Error("WebAssembly SIMD is not supported in the current environment.");let r=Pg();n>1&&!r&&(typeof self<"u"&&self.crossOriginIsolated,t.numThreads=n=1);let i=t.wasmPaths,o="string"==typeof i?i:void 0,s=i?.mjs,a=s?.href??s,u=i?.wasm,l=u?.href??u,p=t.wasmBinary,[c,d]=await zp(a,o,n>1),h=!1,f=[];if(e>0&&f.push(new Promise(t=>{setTimeout(()=>{h=!0,t()},e)})),f.push(new Promise((t,e)=>{let r={numThreads:n};p?r.wasmBinary=p:(l||o)&&(r.locateFile=(t,e)=>l??(o??e)+t),d(r).then(e=>{co=!1,qi=!0,Hi=e,t(),c&&URL.revokeObjectURL(c)},t=>{co=!1,Wp=!0,e(t)})})),await Promise.race(f),h)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},gt=()=>{if(qi&&Hi)return Hi;throw new Error("WebAssembly is not initialized yet.")}}),yt,Wr,ht,po=O(()=>{Xe(),yt=(t,e)=>{let n=gt(),r=n.lengthBytesUTF8(t)+1,i=n._malloc(r);return n.stringToUTF8(t,i,r),e.push(i),i},Wr=(t,e,n,r)=>{if("object"==typeof t&&null!==t){if(n.has(t))throw new Error("Circular reference in options");n.add(t)}Object.entries(t).forEach(([t,i])=>{let o=e?e+t:t;if("object"==typeof i)Wr(i,o+".",n,r);else if("string"==typeof i||"number"==typeof i)r(o,i.toString());else{if("boolean"!=typeof i)throw new Error("Can't handle extra config type: "+typeof i);r(o,i?"1":"0")}})},ht=t=>{let e=gt(),n=e.stackSave();try{let n=e.stackAlloc(8);e._OrtGetLastError(n,n+4);let r=e.HEAP32[n/4],i=e.HEAPU32[n/4+1],o=i?e.UTF8ToString(i):"";throw new Error(`${t} ERROR_CODE: ${r}, ERROR_MESSAGE: ${o}`)}finally{e.stackRestore(n)}}}),Hp,qp=O(()=>{Xe(),po(),Hp=t=>{let e=gt(),n=0,r=[],i=t||{};try{if(void 0===t?.logSeverityLevel)i.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===t?.logVerbosityLevel)i.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);void 0===t?.terminate&&(i.terminate=!1);let o=0;return void 0!==t?.tag&&(o=yt(t.tag,r)),n=e._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,o),0===n&&ht("Can't create run options."),void 0!==t?.extra&&Wr(t.extra,"",new WeakSet,(t,i)=>{let o=yt(t,r),s=yt(i,r);0!==e._OrtAddRunConfigEntry(n,o,s)&&ht(`Can't set a run config entry: ${t} - ${i}.`)}),[n,r]}catch(o){throw 0!==n&&e._OrtReleaseRunOptions(n),r.forEach(t=>e._free(t)),o}}}),Dg,Lg,$g,kg,jp,Xp=O(()=>{Xe(),po(),Dg=t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}},Lg=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},$g=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=>"webgpu"===("string"==typeof t?t:t.name))&&(t.enableMemPattern=!1)},kg=(t,e,n)=>{for(let r of e){let e="string"==typeof r?r:r.name;switch(e){case"webnn":if(e="WEBNN","string"!=typeof r){let e=r?.deviceType;if(e){let r=yt("deviceType",n),i=yt(e,n);0!==gt()._OrtAddSessionConfigEntry(t,r,i)&&ht(`Can't set a session config entry: 'deviceType' - ${e}.`)}}break;case"webgpu":if(e="JS","string"!=typeof r){let e=r;if(e?.preferredLayout){if("NCHW"!==e.preferredLayout&&"NHWC"!==e.preferredLayout)throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${e.preferredLayout}`);let r=yt("preferredLayout",n),i=yt(e.preferredLayout,n);0!==gt()._OrtAddSessionConfigEntry(t,r,i)&&ht(`Can't set a session config entry: 'preferredLayout' - ${e.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${e}`)}let i=yt(e,n);0!==gt()._OrtAppendExecutionProvider(t,i)&&ht(`Can't append execution provider: ${e}.`)}},jp=t=>{let e=gt(),n=0,r=[],i=t||{};$g(i);try{let t=Dg(i.graphOptimizationLevel??"all"),o=Lg(i.executionMode??"sequential"),s="string"==typeof i.logId?yt(i.logId,r):0,a=i.logSeverityLevel??2;if(!Number.isInteger(a)||a<0||a>
64)throw new Error(`log serverity level is not valid: ${a}`);let u=i.logVerbosityLevel??0;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log verbosity level is not valid: ${u}`);let l="string"==typeof i.optimizedModelFilePath?yt(i.optimizedModelFilePath,r):0;if(n=e._OrtCreateSessionOptions(t,!!i.enableCpuMemArena,!!i.enableMemPattern,o,!!i.enableProfiling,0,s,a,u,l),0===n&&ht("Can't create session options."),i.executionProviders&&kg(n,i.executionProviders,r),void 0!==i.enableGraphCapture){if("boolean"!=typeof i.enableGraphCapture)throw new Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);let t=yt("enableGraphCapture",r),o=yt(i.enableGraphCapture.toString(),r);0!==e._OrtAddSessionConfigEntry(n,t,o)&&ht(`Can't set a session config entry: 'enableGraphCapture' - ${i.enableGraphCapture}.`)}if(i.freeDimensionOverrides)for(let[p,c]of Object.entries(i.freeDimensionOverrides)){if("string"!=typeof p)throw new Error(`free dimension override name must be a string: ${p}`);if("number"!=typeof c||!Number.isInteger(c)||c<0)throw new Error(`free dimension override value must be a non-negative integer: ${c}`);let t=yt(p,r);0!==e._OrtAddFreeDimensionOverride(n,t,c)&&ht(`Can't set a free dimension override: ${p} - ${c}.`)}return void 0!==i.extra&&Wr(i.extra,"",new WeakSet,(t,i)=>{let o=yt(t,r),s=yt(i,r);0!==e._OrtAddSessionConfigEntry(n,o,s)&&ht(`Can't set a session config entry: ${t} - ${i}.`)}),[n,r]}catch(o){throw 0!==n&&e._OrtReleaseSessionOptions(n),r.forEach(t=>e._free(t)),o}}}),ji,Kp,Xi,Jp,Yp,ho,Zp,Ki=O(()=>{ji=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;default:throw new Error(`unsupported data type: ${t}`)}},Kp=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";default:throw new Error(`unsupported data type: ${t}`)}},Xi=t=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][t],Jp=t=>{switch(t){case"float16":return typeof Float16Array<"u"&&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 new Error(`unsupported type: ${t}`)}},Yp=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 new Error(`unsupported logging level: ${t}`)}},ho=t=>"float32"===t||"float16"===t||"int32"===t||"int64"===t||"uint32"===t||"uint8"===t||"bool"===t,Zp=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;default:throw new Error(`unsupported data location: ${t}`)}}}),Hr,Ji=O(()=>{ro(),Hr=async t=>{if("string"==typeof t){let n=await fetch(t);if(!n.ok)throw new Error(`failed to load external data file: ${t}`);let r=n.headers.get("Content-Length"),i=r?parseInt(r,10):0;if(i<1073741824)return new Uint8Array(await n.arrayBuffer());{if(!n.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let r,o=n.body.getReader();try{r=new ArrayBuffer(i)}catch(e){if(!(e instanceof RangeError))throw e;{let t=Math.ceil(i/65536);r=new WebAssembly.Memory({initial:t,maximum:t}).buffer}}let s=0;for(;;){let{done:t,value:e}=await o.read();if(t)break;let n=e.byteLength;new Uint8Array(r,s,n).set(e),s+=n}return new Uint8Array(r,0,i)}}return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}}),Bg,oo,io,yr,Fg,zr,ao,so,Qp,uo,lo,fo,zi=O(()=>{qp(),Xp(),Ki(),Xe(),po(),Ji(),Bg=(t,e)=>{0!==gt()._OrtInit(t,e)&&ht("Can't initialize onnxruntime.")},oo=async t=>{Bg(t.wasm.numThreads,Yp(t.logLevel))},io=async(t,e)=>{},yr=new Map,Fg=t=>{let e=gt(),n=e.stackSave();try{let n=e.stackAlloc(8);return 0!==e._OrtGetInputOutputCount(t,n,n+4)&&ht("Can't get session input/output count."),[e.HEAP32[n/4],e.HEAP32[n/4+1]]}
6finally{e.stackRestore(n)}},zr=t=>{let e=gt(),n=e._malloc(t.byteLength);if(0===n)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,n),[n,t.byteLength]},ao=async(t,e)=>{let n,r,i=gt();Array.isArray(t)?[n,r]=t:t.buffer===i.HEAPU8.buffer?[n,r]=[t.byteOffset,t.byteLength]:[n,r]=zr(t);let o=0,s=0,a=[],u=[],l=[];try{if([s,a]=jp(e),e?.externalData&&i.mountExternalData){let t=[];for(let n of e.externalData){let e="string"==typeof n?n:n.path;t.push(Hr("string"==typeof n?n:n.data).then(t=>{i.mountExternalData(e,t)}))}await Promise.all(t)}for(let n of e?.executionProviders??[])if("webnn"===("string"==typeof n?n:n.name)){if(i.currentContext)throw new Error("WebNN execution provider is already set.");if("string"!=typeof n){let t=n,e=t?.context,r=t?.gpuDevice,o=t?.deviceType,s=t?.numThreads,a=t?.powerPreference;i.currentContext=e||(r?await navigator.ml.createContext(r):await navigator.ml.createContext({deviceType:o,numThreads:s,powerPreference:a}))}else i.currentContext=await navigator.ml.createContext();break}o=await i._OrtCreateSession(n,r,s),0===o&&ht("Can't create a session."),i.currentContext&&(i.currentContext=void 0);let[t,p]=Fg(o),c=!!e?.enableGraphCapture,d=[],h=[];for(let e=0;e<t;e++){let t=i._OrtGetInputName(o,e);0===t&&ht("Can't get an input name."),u.push(t),d.push(i.UTF8ToString(t))}for(let e=0;e<p;e++){let t=i._OrtGetOutputName(o,e);0===t&&ht("Can't get an output name."),l.push(t);let n=i.UTF8ToString(t);h.push(n)}let f=null;return yr.set(o,[o,u,l,f,c,!1]),[o,d,h]}catch(p){throw u.forEach(t=>i._OrtFree(t)),l.forEach(t=>i._OrtFree(t)),0!==o&&i._OrtReleaseSession(o),p}finally{i._free(n),0!==s&&i._OrtReleaseSessionOptions(s),a.forEach(t=>i._free(t)),i.unmountExternalData?.()}},so=t=>{let e=gt(),n=yr.get(t);if(!n)throw new Error(`cannot release session. invalid session id: ${t}`);let[r,i,o,s,a]=n;s&&(a&&e._OrtClearBoundOutputs(s.handle),e._OrtReleaseBinding(s.handle)),e.jsepOnReleaseSession?.(t),i.forEach(t=>e._OrtFree(t)),o.forEach(t=>e._OrtFree(t)),e._OrtReleaseSession(r),yr.delete(t)},Qp=(t,e,n,r,i,o=!1)=>{if(!t)return void e.push(0);let s,a,u=gt(),l=t[0],p=t[1],c=t[3];if("string"===l&&"gpu-buffer"===c)throw new Error("String tensor is not supported on GPU.");if(o&&"gpu-buffer"!==c)throw new Error(`External buffer must be provided for input/output index ${i} when enableGraphCapture is true.`);if("gpu-buffer"===c){let e=t[2].gpuBuffer,n=Xi(ji(l));a=p.reduce((t,e)=>t*e,1)*n;let o=u.jsepRegisterBuffer;if(!o)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');s=o(r,i,e,a)}else{let e=t[2];if(Array.isArray(e)){a=4*e.length,s=u._malloc(a),n.push(s);let t=s/4;for(let r=0;r<e.length;r++){if("string"!=typeof e[r])throw new TypeError(`tensor data at index ${r} is not a string`);u.HEAPU32[t++]=yt(e[r],n)}}else a=e.byteLength,s=u._malloc(a),n.push(s),u.HEAPU8.set(new Uint8Array(e.buffer,e.byteOffset,a),s)}let d=u.stackSave(),h=u.stackAlloc(4*p.length);try{let t=h/4;p.forEach(e=>u.HEAP32[t++]=e);let n=u._OrtCreateTensor(ji(l),s,a,h,p.length,Zp(c));0===n&&ht(`Can't create tensor for input/output. session=${r}, index=${i}.`),e.push(n)}finally{u.stackRestore(d)}},uo=async(t,e,n,r,i,o)=>{let s=gt(),a=yr.get(t);if(!a)throw new Error(`cannot run inference. invalid session id: ${t}`);let u=a[0],l=a[1],p=a[2],c=a[3],d=a[4];a[5];let h=e.length,f=r.length,g=0,m=[],b=[],y=[],w=[],T=s.stackSave(),x=s.stackAlloc(4*h),v=s.stackAlloc(4*h),_=s.stackAlloc(4*f),O=s.stackAlloc(4*f);try{[g,m]=Hp(o);for(let r=0;r<h;r++)Qp(n[r],b,w,t,e[r],d);for(let e=0;e<f;e++)Qp(i[e],y,w,t,h+r[e],d);let a,T=x/4,S=v/4,I=_/4,E=O/4;for(let t=0;t<h;t++)s.HEAPU32[T++]=b[t],s.HEAPU32[S++]=l[e[t]];for(let t=0;t<f;t++)s.HEAPU32[I++]=y[t],s.HEAPU32[E++]=p[r[t]];s.jsepOnRunStart?.(u),a=await s._OrtRun(u,v,x,h,O,f,_,g),0!==a&&ht("failed to call OrtRun().");let P=[];for(let t=0;t<f;t++){let e=s.HEAPU32[_/4+t];if(e===y[t]){P.push(i[t]);continue}let n,o=s.stackSave(),a=s.stackAlloc(16),u=!1,l=0;try{0!==s._OrtGetTensorData(e,a,a+4,a+8,a+12)&&ht(`Can't access output tensor data on index ${t}.`);
6let i=a/4,o=s.HEAPU32[i++];l=s.HEAPU32[i++];let p=s.HEAPU32[i++],d=s.HEAPU32[i++],h=[];for(let t=0;t<d;t++)h.push(s.HEAPU32[p/4+t]);s._OrtFree(p);let f=h.reduce((t,e)=>t*e,1);n=Kp(o);let g=c?.outputPreferredLocations[r[t]];if("string"===n){if("gpu-buffer"===g)throw new Error("String tensor is not supported on GPU.");let t=[],e=l/4;for(let n=0;n<f;n++){let r=s.HEAPU32[e++],i=n===f-1?void 0:s.HEAPU32[e]-r;t.push(s.UTF8ToString(r,i))}P.push([n,h,t,"cpu"])}else if("gpu-buffer"===g&&f>0){let t=s.jsepGetBuffer;if(!t)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let r=t(l),i=Xi(o);if(void 0===i||!ho(n))throw new Error(`Unsupported data type: ${n}`);u=!0,P.push([n,h,{gpuBuffer:r,download:s.jsepCreateDownloader(r,f*i,n),dispose:()=>{s._OrtReleaseTensor(e)}},"gpu-buffer"])}else{let t=new(Jp(n))(f);new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(s.HEAPU8.subarray(l,l+t.byteLength)),P.push([n,h,t,"cpu"])}}finally{s.stackRestore(o),"string"===n&&l&&s._free(l),u||s._OrtReleaseTensor(e)}}return c&&!d&&(s._OrtClearBoundOutputs(c.handle),yr.set(t,[u,l,p,c,d,!1])),P}finally{s.stackRestore(T),b.forEach(t=>s._OrtReleaseTensor(t)),y.forEach(t=>s._OrtReleaseTensor(t)),w.forEach(t=>s._free(t)),0!==g&&s._OrtReleaseRunOptions(g),m.forEach(t=>s._free(t))}},lo=t=>{let e=gt(),n=yr.get(t);if(!n)throw new Error("invalid session id");let r=n[0],i=e._OrtEndProfiling(r);0===i&&ht("Can't get an profile file name."),e._OrtFree(i)},fo=t=>{let e=[];for(let n of t){let t=n[2];!Array.isArray(t)&&"buffer"in t&&e.push(t.buffer)}return e}}),Ke,Xt,qr,bo,go,mo,Yi,Zi,xr,Tr,Ng,td,ed,rd,nd,od,id,ad,Qi=O(()=>{Kt(),zi(),Xe(),Vr(),Ke=()=>!!z.wasm.proxy&&typeof document<"u",qr=!1,bo=!1,go=!1,Zi=new Map,xr=(t,e)=>{let n=Zi.get(t);n?n.push(e):Zi.set(t,[e])},Tr=()=>{if(qr||!bo||go||!Xt)throw new Error("worker not ready")},Ng=t=>{switch(t.data.type){case"init-wasm":qr=!1,t.data.err?(go=!0,Yi[1](t.data.err)):(bo=!0,Yi[0]()),mo&&(URL.revokeObjectURL(mo),mo=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=Zi.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}}},td=async()=>{if(!bo){if(qr)throw new Error("multiple calls to 'initWasm()' detected.");if(go)throw new Error("previous call to 'initWasm()' failed.");if(qr=!0,Ke())return new Promise((t,e)=>{Xt?.terminate(),Vp().then(([n,r])=>{try{(Xt=r).onerror=t=>e(t),Xt.onmessage=Ng,Yi=[t,e];let i={type:"init-wasm",in:z};Xt.postMessage(i),mo=n}catch(i){e(i)}},e)});try{await no(z.wasm),await oo(z),bo=!0}catch(i){throw go=!0,i}finally{qr=!1}}},ed=async t=>{if(Ke())return Tr(),new Promise((e,n)=>{xr("init-ep",[e,n]);let r={type:"init-ep",in:{epName:t,env:z}};Xt.postMessage(r)});await io(z,t)},rd=async t=>Ke()?(Tr(),new Promise((e,n)=>{xr("copy-from",[e,n]);let r={type:"copy-from",in:{buffer:t}};Xt.postMessage(r,[t.buffer])})):zr(t),nd=async(t,e)=>{if(Ke()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Tr(),new Promise((n,r)=>{xr("create",[n,r]);let i={type:"create",in:{model:t,options:{...e}}},o=[];t instanceof Uint8Array&&o.push(t.buffer),Xt.postMessage(i,o)})}return ao(t,e)},od=async t=>{if(Ke())return Tr(),new Promise((e,n)=>{xr("release",[e,n]);let r={type:"release",in:t};Xt.postMessage(r)});so(t)},id=async(t,e,n,r,i,o)=>{if(Ke()){if(n.some(t=>"cpu"!==t[3]))throw new Error("input tensor on GPU is not supported for proxy.");if(i.some(t=>t))throw new Error("pre-allocated output tensor is not supported for proxy.");return Tr(),new Promise((i,s)=>{xr("run",[i,s]);let a=n,u={type:"run",in:{sessionId:t,inputIndices:e,inputs:a,outputIndices:r,options:o}};Xt.postMessage(u,fo(a))})}return uo(t,e,n,r,i,o)},ad=async t=>{if(Ke())return Tr(),new Promise((e,n)=>{xr("end-profiling",[e,n]);let r={type:"end-profiling",in:t};Xt.postMessage(r)});lo(t)}}),sd,Rg,yo,ud=O(()=>{Kt(),Qi(),Ki(),ro(),Ji(),sd=(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"];default:throw new Error(`invalid data location: ${t.location} for ${e()}`)}},Rg=t=>{switch(t[3]){case"cpu":return new Tt(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!ho(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=t[2];return Tt.fromGpuBuffer(n,{dataType:e,dims:t[1],download:r,dispose:i})}default:throw new Error(`invalid data location: ${t[3]}`)}},yo=class{async fetchModelAndCopyToWasmMemory(t){return rd(await Hr(t))}async loadModel(t,e){let n;Be(),n="string"==typeof t?await this.fetchModelAndCopyToWasmMemory(t):t,[this.sessionId,this.inputNames,this.outputNames]=await nd(n,e),Fe()}async dispose(){return od(this.sessionId)}async run(t,e,n){Be();let r=[],i=[];Object.entries(t).forEach(t=>{let e=t[0],n=t[1],o=this.inputNames.indexOf(e);if(-1===o)throw new Error(`invalid input '${e}'`);r.push(n),i.push(o)});let o=[],s=[];Object.entries(e).forEach(t=>{let e=t[0],n=t[1],r=this.outputNames.indexOf(e);if(-1===r)throw new Error(`invalid output '${e}'`);o.push(n),s.push(r)});let a=r.map((t,e)=>sd(t,()=>`input "${this.inputNames[i[e]]}"`)),u=o.map((t,e)=>t?sd(t,()=>`output "${this.outputNames[s[e]]}"`):null),l=await id(this.sessionId,i,a,s,u,n),p={};for(let c=0;c<l.length;c++)p[this.outputNames[s[c]]]=o[c]??Rg(l[c]);return Fe(),p}startProfiling(){}endProfiling(){ad(this.sessionId)}}}),Gg,xo,ld=O(()=>{Kt(),Qi(),ud(),Vr(),Gg=()=>{if(("number"!=typeof z.wasm.initTimeout||z.wasm.initTimeout<0)&&(z.wasm.initTimeout=0),z.wasm.simd,"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(typeof self<"u"&&!self.crossOriginIsolated)z.wasm.numThreads=1;else{let t=typeof navigator>"u"?ko("node:os").cpus().length:navigator.hardwareConcurrency;z.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}},xo=class{async init(t){Gg(),await td(),await ed(t)}async createInferenceSessionHandler(t,e){let n=new yo;return await n.loadModel(t,e),Promise.resolve(n)}}}),fd={};Or(fd,{wasmBackend:()=>Mg});var Mg,cd=O(()=>{ld(),Mg=new xo});Kt(),Kt(),Kt();var Ps="1.19.2",bO=No;
6{let t=(kp(),on($p)).onnxjsBackend;nr("webgl",t,-10)}{let t=(cd(),on(fd)).wasmBackend;nr("cpu",t,10),nr("wasm",t,10)}Object.defineProperty(z.versions,"web",{value:Ps,enumerable:!0});
7/*! Bundled license information:
8
9long/index.js:
10  (**
11   * @license
12   * Copyright 2009 The Closure Library Authors
13   * Copyright 2020 Daniel Wirtz / The long.js Authors.
14   *
15   * Licensed under the Apache License, Version 2.0 (the "License");
16   * you may not use this file except in compliance with the License.
17   * You may obtain a copy of the License at
18   *
19   *     http://www.apache.org/licenses/LICENSE-2.0
20   *
21   * Unless required by applicable law or agreed to in writing, software
22   * distributed under the License is distributed on an "AS IS" BASIS,
23   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24   * See the License for the specific language governing permissions and
25   * limitations under the License.
26   *
27   * SPDX-License-Identifier: Apache-2.0
28   *)
29*/
30export{Kd as InferenceSession,ys as TRACE,Be as TRACE_FUNC_BEGIN,Fe as TRACE_FUNC_END,Tt as Tensor,Yd as TrainingSession,bO as default,z as env,nr as registerBackend};

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.