/* Human homepage: author: ' */ var AT=Object.create,Bd=Object.defineProperty,ET=Object.getOwnPropertyDescriptor,Ow=Object.getOwnPropertyNames,RT=Object.getPrototypeOf,DT=Object.prototype.hasOwnProperty,FT=e=>Bd(e,"__esModule",{value:!0}),zt=(e,t)=>function(){return t||(0,e[Ow(e)[0]])((t={exports:{}}).exports,t),t.exports},Ae=(e,t)=>{for(var n in t)Bd(e,n,{get:t[n],enumerable:!0})},OT=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ow(t))!DT.call(e,r)&&(n||r!=="default")&&Bd(e,r,{get:()=>t[r],enumerable:!(s=ET(t,r))||s.enumerable});return e},ya=(e,t)=>OT(FT(Bd(e!=null?AT(RT(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),PT=zt({"src/node_modules/long/src/long.js"(e,t){t.exports=s;var n=null;try{n=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(F){}function s(F,$,z){this.low=F|0,this.high=$|0,this.unsigned=!!z}s.prototype.__isLong__,Object.defineProperty(s.prototype,"__isLong__",{value:!0});function r(F){return(F&&F.__isLong__)===!0}s.isLong=r;var a={},i={};function o(F,$){var z,W,q;return $?(F>>>=0,(q=0<=F&&F<256)&&(W=i[F],W)?W:(z=l(F,(F|0)<0?-1:0,!0),q&&(i[F]=z),z)):(F|=0,(q=-128<=F&&F<128)&&(W=a[F],W)?W:(z=l(F,F<0?-1:0,!1),q&&(a[F]=z),z))}s.fromInt=o;function u(F,$){if(isNaN(F))return $?x:v;if($){if(F<0)return x;if(F>=g)return A}else{if(F<=-b)return P;if(F+1>=b)return E}return F<0?u(-F,$).neg():l(F%m|0,F/m|0,$)}s.fromNumber=u;function l(F,$,z){return new s(F,$,z)}s.fromBits=l;var c=Math.pow;function p(F,$,z){if(F.length===0)throw Error("empty string");if(F==="NaN"||F==="Infinity"||F==="+Infinity"||F==="-Infinity")return v;if(typeof $=="number"?(z=$,$=!1):$=!!$,z=z||10,z<2||360)throw Error("interior hyphen");if(W===0)return p(F.substring(1),$,z).neg();for(var q=u(c(z,8)),K=v,Y=0;Y>>0:this.low},R.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},R.toString=function($){if($=$||10,$<2||36<$)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(P)){var z=u($),W=this.div(z),q=W.mul(z).sub(this);return W.toString($)+q.toInt().toString($)}else return"-"+this.neg().toString($);for(var K=u(c($,6),this.unsigned),Y=this,Z="";;){var te=Y.div(K),ee=Y.sub(te.mul(K)).toInt()>>>0,se=ee.toString($);if(Y=te,Y.isZero())return se+Z;for(;se.length<6;)se="0"+se;Z=""+se+Z}},R.getHighBits=function(){return this.high},R.getHighBitsUnsigned=function(){return this.high>>>0},R.getLowBits=function(){return this.low},R.getLowBitsUnsigned=function(){return this.low>>>0},R.getNumBitsAbs=function(){if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(var $=this.high!=0?this.high:this.low,z=31;z>0&&($&1<=0},R.isOdd=function(){return(this.low&1)===1},R.isEven=function(){return(this.low&1)===0},R.equals=function($){return r($)||($=d($)),this.unsigned!==$.unsigned&&this.high>>>31===1&&$.high>>>31===1?!1:this.high===$.high&&this.low===$.low},R.eq=R.equals,R.notEquals=function($){return!this.eq($)},R.neq=R.notEquals,R.ne=R.notEquals,R.lessThan=function($){return this.comp($)<0},R.lt=R.lessThan,R.lessThanOrEqual=function($){return this.comp($)<=0},R.lte=R.lessThanOrEqual,R.le=R.lessThanOrEqual,R.greaterThan=function($){return this.comp($)>0},R.gt=R.greaterThan,R.greaterThanOrEqual=function($){return this.comp($)>=0},R.gte=R.greaterThanOrEqual,R.ge=R.greaterThanOrEqual,R.compare=function($){if(r($)||($=d($)),this.eq($))return 0;var z=this.isNegative(),W=$.isNegative();return z&&!W?-1:!z&&W?1:this.unsigned?$.high>>>0>this.high>>>0||$.high===this.high&&$.low>>>0>this.low>>>0?-1:1:this.sub($).isNegative()?-1:1},R.comp=R.compare,R.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(k)},R.neg=R.negate,R.add=function($){r($)||($=d($));var z=this.high>>>16,W=this.high&65535,q=this.low>>>16,K=this.low&65535,Y=$.high>>>16,Z=$.high&65535,te=$.low>>>16,ee=$.low&65535,se=0,ne=0,oe=0,re=0;return re+=K+ee,oe+=re>>>16,re&=65535,oe+=q+te,ne+=oe>>>16,oe&=65535,ne+=W+Z,se+=ne>>>16,ne&=65535,se+=z+Y,se&=65535,l(oe<<16|re,se<<16|ne,this.unsigned)},R.subtract=function($){return r($)||($=d($)),this.add($.neg())},R.sub=R.subtract,R.multiply=function($){if(this.isZero())return v;if(r($)||($=d($)),n){var z=n.mul(this.low,this.high,$.low,$.high);return l(z,n.get_high(),this.unsigned)}if($.isZero())return v;if(this.eq(P))return $.isOdd()?P:v;if($.eq(P))return this.isOdd()?P:v;if(this.isNegative())return $.isNegative()?this.neg().mul($.neg()):this.neg().mul($).neg();if($.isNegative())return this.mul($.neg()).neg();if(this.lt(y)&&$.lt(y))return u(this.toNumber()*$.toNumber(),this.unsigned);var W=this.high>>>16,q=this.high&65535,K=this.low>>>16,Y=this.low&65535,Z=$.high>>>16,te=$.high&65535,ee=$.low>>>16,se=$.low&65535,ne=0,oe=0,re=0,le=0;return le+=Y*se,re+=le>>>16,le&=65535,re+=K*se,oe+=re>>>16,re&=65535,re+=Y*ee,oe+=re>>>16,re&=65535,oe+=q*se,ne+=oe>>>16,oe&=65535,oe+=K*ee,ne+=oe>>>16,oe&=65535,oe+=Y*te,ne+=oe>>>16,oe&=65535,ne+=W*se+q*ee+K*te+Y*Z,ne&=65535,l(re<<16|le,ne<<16|oe,this.unsigned)},R.mul=R.multiply,R.divide=function($){if(r($)||($=d($)),$.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&$.low===-1&&$.high===-1)return this;var z=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,$.low,$.high);return l(z,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?x:v;var W,q,K;if(this.unsigned){if($.unsigned||($=$.toUnsigned()),$.gt(this))return x;if($.gt(this.shru(1)))return C;K=x}else{if(this.eq(P)){if($.eq(k)||$.eq(T))return P;if($.eq(P))return k;var Y=this.shr(1);return W=Y.div($).shl(1),W.eq(v)?$.isNegative()?k:T:(q=this.sub($.mul(W)),K=W.add(q.div($)),K)}else if($.eq(P))return this.unsigned?x:v;if(this.isNegative())return $.isNegative()?this.neg().div($.neg()):this.neg().div($).neg();if($.isNegative())return this.div($.neg()).neg();K=v}for(q=this;q.gte($);){W=Math.max(1,Math.floor(q.toNumber()/$.toNumber()));for(var Z=Math.ceil(Math.log(W)/Math.LN2),te=Z<=48?1:c(2,Z-48),ee=u(W),se=ee.mul($);se.isNegative()||se.gt(q);)W-=te,ee=u(W,this.unsigned),se=ee.mul($);ee.isZero()&&(ee=k),K=K.add(ee),q=q.sub(se)}return K},R.div=R.divide,R.modulo=function($){if(r($)||($=d($)),n){var z=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,$.low,$.high);return l(z,n.get_high(),this.unsigned)}return this.sub(this.div($).mul($))},R.mod=R.modulo,R.rem=R.modulo,R.not=function(){return l(~this.low,~this.high,this.unsigned)},R.and=function($){return r($)||($=d($)),l(this.low&$.low,this.high&$.high,this.unsigned)},R.or=function($){return r($)||($=d($)),l(this.low|$.low,this.high|$.high,this.unsigned)},R.xor=function($){return r($)||($=d($)),l(this.low^$.low,this.high^$.high,this.unsigned)},R.shiftLeft=function($){return r($)&&($=$.toInt()),($&=63)===0?this:$<32?l(this.low<<$,this.high<<$|this.low>>>32-$,this.unsigned):l(0,this.low<<$-32,this.unsigned)},R.shl=R.shiftLeft,R.shiftRight=function($){return r($)&&($=$.toInt()),($&=63)===0?this:$<32?l(this.low>>>$|this.high<<32-$,this.high>>$,this.unsigned):l(this.high>>$-32,this.high>=0?0:-1,this.unsigned)},R.shr=R.shiftRight,R.shiftRightUnsigned=function($){if(r($)&&($=$.toInt()),$&=63,$===0)return this;var z=this.high;if($<32){var W=this.low;return l(W>>>$|z<<32-$,z>>>$,this.unsigned)}else return $===32?l(z,0,this.unsigned):l(z>>>$-32,0,this.unsigned)},R.shru=R.shiftRightUnsigned,R.shr_u=R.shiftRightUnsigned,R.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},R.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},R.toBytes=function($){return $?this.toBytesLE():this.toBytesBE()},R.toBytesLE=function(){var $=this.high,z=this.low;return[z&255,z>>>8&255,z>>>16&255,z>>>24,$&255,$>>>8&255,$>>>16&255,$>>>24]},R.toBytesBE=function(){var $=this.high,z=this.low;return[$>>>24,$>>>16&255,$>>>8&255,$&255,z>>>24,z>>>16&255,z>>>8&255,z&255]},s.fromBytes=function($,z,W){return W?s.fromBytesLE($,z):s.fromBytesBE($,z)},s.fromBytesLE=function($,z){return new s($[0]|$[1]<<8|$[2]<<16|$[3]<<24,$[4]|$[5]<<8|$[6]<<16|$[7]<<24,z)},s.fromBytesBE=function($,z){return new s($[4]<<24|$[5]<<16|$[6]<<8|$[7],$[0]<<24|$[1]<<16|$[2]<<8|$[3],z)}}}),zT=zt({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),MT=zt({"(disabled):util"(){}}),LT=zt({"src/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,s,r){function a(l){var c=this,p=u();c.next=function(){var d=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=d-(c.c=d|0)},c.c=1,c.s0=p(" "),c.s1=p(" "),c.s2=p(" "),c.s0-=p(l),c.s0<0&&(c.s0+=1),c.s1-=p(l),c.s1<0&&(c.s1+=1),c.s2-=p(l),c.s2<0&&(c.s2+=1),p=null}function i(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var p=new a(l),d=c&&c.state,h=p.next;return h.int32=function(){return p.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d=="object"&&i(d,p),h.state=function(){return i(p,{})}),h}function u(){var l=4022871197,c=function(p){p=String(p);for(var d=0;d>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),BT=zt({"src/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,s,r){function a(u){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var d=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^d^d>>>8},u===(u|0)?l.x=u:c+=u;for(var p=0;p>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p=="object"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),VT=zt({"src/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,s,r){function a(u){var l=this,c="";l.next=function(){var d=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(d^d<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,u===(u|0)?l.x=u:c+=u;for(var p=0;p>>4),l.next()}function i(u,l){return l.x=u.x,l.y=u.y,l.z=u.z,l.w=u.w,l.v=u.v,l.d=u.d,l}function o(u,l){var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p=="object"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),WT=zt({"src/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,s,r){function a(u){var l=this;l.next=function(){var p=l.x,d=l.i,h,f,m;return h=p[d],h^=h>>>7,f=h^h<<24,h=p[d+1&7],f^=h^h>>>10,h=p[d+3&7],f^=h^h>>>3,h=p[d+4&7],f^=h^h<<7,h=p[d+7&7],h=h^h<<13,f^=h^h<<9,p[d]=f,l.i=d+1&7,f};function c(p,d){var h,f,m=[];if(d===(d|0))f=m[0]=d;else for(d=""+d,h=0;h0;--h)p.next()}c(l,u)}function i(u,l){return l.x=u.x.slice(),l.i=u.i,l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.x&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),UT=zt({"src/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,s,r){function a(u){var l=this;l.next=function(){var p=l.w,d=l.X,h=l.i,f,m;return l.w=p=p+1640531527|0,m=d[h+34&127],f=d[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=d[h]=m^f,l.i=h,m+(p^p>>>16)|0};function c(p,d){var h,f,m,g,b,y=[],v=128;for(d===(d|0)?(f=d,d=null):(d=d+"\0",f=0,v=Math.max(v,d.length)),m=0,g=-32;g>>15,f^=f<<4,f^=f>>>13,g>=0&&(b=b+1640531527|0,h=y[g&127]^=f+b,m=h==0?m+1:0);for(m>=128&&(y[(d&&d.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=y[m+34&127],h=y[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,y[m]=f^h;p.w=b,p.X=y,p.i=m}c(l,u)}function i(u,l){return l.i=u.i,l.w=u.w,l.X=u.X.slice(),l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.X&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),GT=zt({"src/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,s,r){function a(u){var l=this,c="";l.next=function(){var d=l.b,h=l.c,f=l.d,m=l.a;return d=d<<25^d>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-d|0,l.b=d=d<<20^d>>>12^h,l.c=h=h-f|0,l.d=f<<16^h>>>16^m,l.a=m-d|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,u===Math.floor(u)?(l.a=u/4294967296|0,l.b=u|0):c+=u;for(var p=0;p>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p=="object"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),HT=zt({"(disabled):crypto"(){}}),qT=zt({"src/node_modules/seedrandom/seedrandom.js"(e,t){(function(n,s,r){var a=256,i=6,o=52,u="random",l=r.pow(a,i),c=r.pow(2,o),p=c*2,d=a-1,h;function f(k,C,T){var E=[];C=C==!0?{entropy:!0}:C||{};var A=y(b(C.entropy?[k,x(s)]:k==null?v():k,3),E),P=new m(E),R=function(){for(var F=P.g(i),$=l,z=0;F=p;)F/=2,$/=2,z>>>=1;return(F+z)/$};return R.int32=function(){return P.g(4)|0},R.quick=function(){return P.g(4)/4294967296},R.double=R,y(x(P.S),s),(C.pass||T||function(F,$,z,W){return W&&(W.S&&g(W,P),F.state=function(){return g(P,{})}),z?(r[u]=F,$):F})(R,A,"global"in C?C.global:this==r,C.state)}function m(k){var C,T=k.length,E=this,A=0,P=E.i=E.j=0,R=E.S=[];for(T||(k=[T++]);A{var s=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(s=s||__filename),function(r){r=r||{};function a(){return Ce.buffer!=tn&&ns(Ce.buffer),ac}function i(){return Ce.buffer!=tn&&ns(Ce.buffer),ic}function o(){return Ce.buffer!=tn&&ns(Ce.buffer),pu}function u(){return Ce.buffer!=tn&&ns(Ce.buffer),oc}function l(){return Ce.buffer!=tn&&ns(Ce.buffer),uc}function c(){return Ce.buffer!=tn&&ns(Ce.buffer),lc}function p(){return Ce.buffer!=tn&&ns(Ce.buffer),cc}var d=typeof r!="undefined"?r:{},h,f;d.ready=new Promise(function(S,D){h=S,f=D});var m;typeof process!="undefined"&&process.listeners&&(m={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},d),b=[],y="./this.program",v=(S,D)=>{throw D},x=typeof window=="object",k=typeof importScripts=="function",C=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T=d.ENVIRONMENT_IS_PTHREAD||!1,E="";function A(S){return d.locateFile?d.locateFile(S,E):E+S}var P,R,F,$;function z(S){if(S instanceof wu)return;ee("exiting due to exception: "+S)}var W,q,K;if(C){k?E=cd().dirname(E)+"/":E=__dirname+"/",K=()=>{q||(W=Jm(),q=cd())},P=function(B,Q){return K(),B=q.normalize(B),W.readFileSync(B,Q?void 0:"utf8")},F=D=>{var B=P(D,!0);return B.buffer||(B=new Uint8Array(B)),B},R=(D,B,Q)=>{K(),D=q.normalize(D),W.readFile(D,function(ue,pe){ue?Q(ue):B(pe.buffer)})},process.argv.length>1&&(y=process.argv[1].replace(/\\/g,"/")),b=process.argv.slice(2),process.on("uncaughtException",function(D){if(!(D instanceof wu))throw D}),process.on("unhandledRejection",function(D){throw D}),v=(D,B)=>{if(Or())throw process.exitCode=D,B;z(B),process.exit(D)},d.inspect=function(){return"[Emscripten Module object]"};let S;try{S=jT()}catch(D){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),D}global.Worker=S.Worker}else(x||k)&&(k?E=self.location.href:typeof document!="undefined"&&document.currentScript&&(E=document.currentScript.src),typeof s!="undefined"&&s&&(E=s),E.indexOf("blob:")!==0?E=E.substr(0,E.replace(/[?#].*/,"").lastIndexOf("/")+1):E="",C||(P=S=>{var D=new XMLHttpRequest;return D.open("GET",S,!1),D.send(null),D.responseText},k&&(F=S=>{var D=new XMLHttpRequest;return D.open("GET",S,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),R=(S,D,B)=>{var Q=new XMLHttpRequest;Q.open("GET",S,!0),Q.responseType="arraybuffer",Q.onload=()=>{if(Q.status==200||Q.status==0&&Q.response){D(Q.response);return}B()},Q.onerror=B,Q.send(null)}),$=S=>document.title=S);C&&typeof performance=="undefined"&&(global.performance=KT().performance);var Y=console.log.bind(console),Z=console.warn.bind(console);C&&(K(),Y=S=>W.writeSync(1,S+` `),Z=S=>W.writeSync(2,S+` `));var te=d.print||Y,ee=d.printErr||Z;Object.assign(d,g),g=null,d.arguments&&(b=d.arguments),d.thisProgram&&(y=d.thisProgram),d.quit&&(v=d.quit);var se=4;function ne(S){ne.shown||(ne.shown={}),ne.shown[S]||(ne.shown[S]=1,ee(S))}function oe(S,D){if(typeof WebAssembly.Function=="function"){for(var B={i:"i32",j:"i64",f:"f32",d:"f64"},Q={parameters:[],results:D[0]=="v"?[]:[B[D[0]]]},ue=1;ue{Se=S},Pe=Atomics.load,Xe=Atomics.store,Je=Atomics.compareExchange,Ye;d.wasmBinary&&(Ye=d.wasmBinary);var tt=d.noExitRuntime||!0;typeof WebAssembly!="object"&&Ii("no native wasm support detected");var Ce,ut,rt=!1,Zt;function Nt(S,D){S||Ii(D)}function In(S){var D=d["_"+S];return D}function Et(S,D,B,Q,ue){var pe={string:function(Nn){var Di=0;if(Nn!=null&&Nn!==0){var Qv=(Nn.length<<2)+1;Di=Ri(Qv),Ls(Nn,Di,Qv)}return Di},array:function(Nn){var Di=Ri(Nn.length);return Bs(Nn,Di),Di}};function be(Nn){return D==="string"?en(Nn):D==="boolean"?Boolean(Nn):Nn}var Te=In(S),bt=[],is=0;if(Q)for(var os=0;os(B.buffer instanceof SharedArrayBuffer&&(B=new Uint8Array(B)),D.decode.call(D,B))}var Xt=typeof TextDecoder!="undefined"?new Cn("utf8"):void 0;function Rn(S,D,B){for(var Q=D+B,ue=D;S[ue]&&!(ue>=Q);)++ue;if(ue-D>16&&S.subarray&&Xt)return Xt.decode(S.subarray(D,ue));for(var pe="";D>10,56320|is&1023)}}return pe}function en(S,D){return S?Rn(i(),S,D):""}function Ms(S,D,B,Q){if(!(Q>0))return 0;for(var ue=B,pe=B+Q-1,be=0;be=55296&&Te<=57343){var bt=S.charCodeAt(++be);Te=65536+((Te&1023)<<10)|bt&1023}if(Te<=127){if(B>=pe)break;D[B++]=Te}else if(Te<=2047){if(B+1>=pe)break;D[B++]=192|Te>>6,D[B++]=128|Te&63}else if(Te<=65535){if(B+2>=pe)break;D[B++]=224|Te>>12,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}else{if(B+3>=pe)break;D[B++]=240|Te>>18,D[B++]=128|Te>>12&63,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}}return D[B]=0,B-ue}function Ls(S,D,B){return Ms(S,i(),D,B)}function xi(S){for(var D=0,B=0;B=55296&&Q<=57343&&(Q=65536+((Q&1023)<<10)|S.charCodeAt(++B)&1023),Q<=127?++D:Q<=2047?D+=2:Q<=65535?D+=3:D+=4}return D}var Js=typeof TextDecoder!="undefined"?new Cn("utf-16le"):void 0;function Bs(S,D){a().set(S,D)}function du(S,D,B){for(var Q=0;Q>0]=S.charCodeAt(Q);B||(a()[D>>0]=0)}function wi(S,D){return S%D>0&&(S+=D-S%D),S}var tn,ac,ic,pu,oc,uc,Ev,lc,cc;T&&(tn=d.buffer);function ns(S){tn=S,d.HEAP8=ac=new Int8Array(S),d.HEAP16=pu=new Int16Array(S),d.HEAP32=uc=new Int32Array(S),d.HEAPU8=ic=new Uint8Array(S),d.HEAPU16=oc=new Uint16Array(S),d.HEAPU32=Ev=new Uint32Array(S),d.HEAPF32=lc=new Float32Array(S),d.HEAPF64=cc=new Float64Array(S)}var dc=d.INITIAL_MEMORY||16777216;if(T)Ce=d.wasmMemory,tn=d.buffer;else if(d.wasmMemory)Ce=d.wasmMemory;else if(Ce=new WebAssembly.Memory({initial:dc/65536,maximum:32768,shared:!0}),!(Ce.buffer instanceof SharedArrayBuffer))throw ee("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),C&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Ce&&(tn=Ce.buffer),dc=tn.byteLength,ns(tn);var Dn,ki=[],er=[],eh=[],pc=[],Fr=!1,th=!1,hc=0;function Or(){return tt||hc>0}function nn(){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)Rv(d.preRun.shift());yc(ki)}function hu(){Fr=!0,!T&&yc(er)}function nh(){T||($e.terminateAllThreads(),th=!0)}function sh(){if(!T){if(d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;)fu(d.postRun.shift());yc(pc)}}function Rv(S){ki.unshift(S)}function Dv(S){er.unshift(S)}function fu(S){pc.unshift(S)}var tr=0,fc=null,ss=null;function mu(S){tr++,d.monitorRunDependencies&&d.monitorRunDependencies(tr)}function Fv(S){if(tr--,d.monitorRunDependencies&&d.monitorRunDependencies(tr),tr==0&&(fc!==null&&(clearInterval(fc),fc=null),ss)){var D=ss;ss=null,D()}}d.preloadedImages={},d.preloadedAudios={};function Ii(S){T?postMessage({cmd:"onAbort",arg:S}):d.onAbort&&d.onAbort(S),S="Aborted("+S+")",ee(S),rt=!0,Zt=1,S+=". Build with -s ASSERTIONS=1 for more info.";var D=new WebAssembly.RuntimeError(S);throw f(D),D}var rh="data:application/octet-stream;base64,";function mc(S){return S.startsWith(rh)}function gc(S){return S.startsWith("file://")}var sn;sn="tfjs-backend-wasm-threaded-simd.wasm",mc(sn)||(sn=A(sn));function bc(S){try{if(S==sn&&Ye)return new Uint8Array(Ye);if(F)return F(S);throw"both async and sync fetching of the wasm failed"}catch(D){Ii(D)}}function Si(){if(!Ye&&(x||k)){if(typeof fetch=="function"&&!gc(sn))return fetch(sn,{credentials:"same-origin"}).then(function(S){if(!S.ok)throw"failed to load wasm binary file at '"+sn+"'";return S.arrayBuffer()}).catch(function(){return bc(sn)});if(R)return new Promise(function(S,D){R(sn,function(B){S(new Uint8Array(B))},D)})}return Promise.resolve().then(function(){return bc(sn)})}function ah(){var S={env:Ac,wasi_snapshot_preview1:Ac};function D(be,Te){var bt=be.exports;if(d.asm=bt,ph(d.asm.emscripten_tls_init),Dn=d.asm.__indirect_function_table,Dv(d.asm.__wasm_call_ctors),ut=Te,!T){var is=$e.unusedWorkers.length;$e.unusedWorkers.forEach(function(os){$e.loadWasmModuleToWorker(os,function(){--is||Fv("wasm-instantiate")})})}}T||mu("wasm-instantiate");function B(be){D(be.instance,be.module)}function Q(be){return Si().then(function(Te){return WebAssembly.instantiate(Te,S)}).then(function(Te){return Te}).then(be,function(Te){ee("failed to asynchronously prepare wasm: "+Te),Ii(Te)})}function ue(){return!Ye&&typeof WebAssembly.instantiateStreaming=="function"&&!mc(sn)&&!gc(sn)&&typeof fetch=="function"?fetch(sn,{credentials:"same-origin"}).then(function(be){var Te=WebAssembly.instantiateStreaming(be,S);return Te.then(B,function(bt){return ee("wasm streaming compile failed: "+bt),ee("falling back to ArrayBuffer instantiation"),Q(B)})}):Q(B)}if(d.instantiateWasm)try{var pe=d.instantiateWasm(S,D);return pe}catch(be){return ee("Module.instantiateWasm callback failed with error: "+be),!1}return ue().catch(f),{}}var Ov,Pv,ih={};function yc(S){for(;S.length>0;){var D=S.shift();if(typeof D=="function"){D(d);continue}var B=D.func;typeof B=="number"?D.arg===void 0?Ni(B)():Ni(B)(D.arg):B(D.arg===void 0?null:D.arg)}}function Ci(S){var D=_f(),B=S();return Oc(D),B}function zN(S){return S}function zv(S){var D=/\b_Z[\w\d_]+/g;return S.replace(D,function(B){var Q=B;return B===Q?B:Q+" ["+B+"]"})}function oh(S){l()[S>>2]=0;var D=$e.pthreads[S];delete $e.pthreads[S],D.worker.terminate(),$f(S),$e.runningWorkers.splice($e.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function uh(S){var D=$e.pthreads[S];D.worker.postMessage({cmd:"cancel"})}function vc(S){var D=$e.pthreads[S];if(D){l()[S>>2]=0;var B=D.worker;$e.returnWorkerToPool(B)}}function xc(S){NT(S)}function lh(S){if(S instanceof wu||S=="unwind")return Zt;v(1,S)}var $e={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){T?$e.initWorker():$e.initMainThread()},initMainThread:function(){for(var S=8,D=0;D>2]=0;try{S()}finally{l()[Yv>>2]=1}},receiveObjectTransfer:function(S){},threadInit:function(){for(var S in $e.tlsInitFunctions)$e.tlsInitFunctions[S]()},loadWasmModuleToWorker:function(S,D){S.onmessage=B=>{var Q=B.data,ue=Q.cmd;if(S.pthread&&($e.currentProxiedOperationCallerThread=S.pthread.threadInfoStruct),Q.targetThread&&Q.targetThread!=Fc()){var pe=$e.pthreads[Q.targetThread];pe?pe.worker.postMessage(Q,Q.transferList):ee('Internal error! Worker sent a message "'+ue+'" to target pthread '+Q.targetThread+", but that thread no longer exists!"),$e.currentProxiedOperationCallerThread=void 0;return}ue==="processQueuedMainThreadWork"?Hv():ue==="spawnThread"?kc(Q):ue==="cleanupThread"?vc(Q.thread):ue==="killThread"?oh(Q.thread):ue==="cancelThread"?uh(Q.thread):ue==="loaded"?(S.loaded=!0,D&&D(S),S.runPthread&&(S.runPthread(),delete S.runPthread)):ue==="print"?te("Thread "+Q.threadId+": "+Q.text):ue==="printErr"?ee("Thread "+Q.threadId+": "+Q.text):ue==="alert"?alert("Thread "+Q.threadId+": "+Q.text):Q.target==="setimmediate"?S.postMessage(Q):ue==="onAbort"?d.onAbort&&d.onAbort(Q.arg):ee("worker sent an unknown command "+ue),$e.currentProxiedOperationCallerThread=void 0},S.onerror=B=>{var Q="worker sent an error!";throw ee(Q+" "+B.filename+":"+B.lineno+": "+B.message),B},C&&(S.on("message",function(B){S.onmessage({data:B})}),S.on("error",function(B){S.onerror(B)}),S.on("detachedExit",function(){})),S.postMessage({cmd:"load",urlOrBlob:d.mainScriptUrlOrBlob||s,wasmMemory:Ce,wasmModule:ut})},allocateUnusedWorker:function(){var S=A("tfjs-backend-wasm-threaded-simd.worker.js");$e.unusedWorkers.push(new Worker(S))},getNewWorker:function(){return $e.unusedWorkers.length==0&&($e.allocateUnusedWorker(),$e.loadWasmModuleToWorker($e.unusedWorkers[0])),$e.unusedWorkers.pop()}};function ch(){var S=Fc(),D=l()[S+44>>2],B=l()[S+48>>2],Q=D-B;Xv(D,Q),Oc(D)}d.establishStackSpace=ch;function wc(S){if(T)return Mr(1,0,S);try{xc(S)}catch(D){lh(D)}}var Pr=[];function Ni(S){var D=Pr[S];return D||(S>=Pr.length&&(Pr.length=S+1),Pr[S]=D=Dn.get(S)),D}function dh(S,D){return Ni(S)(D)}d.invokeEntryPoint=dh;function Mv(){var S=new Error;if(!S.stack){try{throw new Error}catch(D){S=D}if(!S.stack)return"(no stack trace available)"}return S.stack.toString()}function ph(S,D,B){$e.tlsInitFunctions.push(S)}function Lv(S,D){Dn.set(S,D),Pr[S]=D}var zr;C?zr=()=>{var S=process.hrtime();return S[0]*1e3+S[1]/1e6}:T?zr=()=>performance.now()-d.__performance_now_clock_drift:zr=()=>performance.now();var hh=!0;function fh(S){return l()[Gv()>>2]=S,S}function mh(S,D){var B;if(S===0)B=Date.now();else if((S===1||S===4)&&hh)B=zr();else return fh(28),-1;return l()[D>>2]=B/1e3|0,l()[D+4>>2]=B%1e3*1e3*1e3|0,0}function gh(S,D){return mh(S,D)}function bh(S){qv(S,!k,1,!x),$e.threadInit()}function yh(S){T?postMessage({cmd:"cleanupThread",thread:S}):vc(S)}function kc(S){var D=$e.getNewWorker();if(!D)return 6;$e.runningWorkers.push(D);var B=$e.pthreads[S.pthread_ptr]={worker:D,threadInfoStruct:S.pthread_ptr};D.pthread=B;var Q={cmd:"run",start_routine:S.startRoutine,arg:S.arg,threadInfoStruct:S.pthread_ptr};return D.runPthread=()=>{Q.time=performance.now(),D.postMessage(Q,S.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function vh(S,D,B,Q){if(typeof SharedArrayBuffer=="undefined")return ee("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ue=[],pe=0;if(T&&(ue.length===0||pe))return jv(687865856,S,D,B,Q);if(pe)return pe;var be={startRoutine:B,pthread_ptr:S,arg:Q,transferList:ue};return T?(be.cmd="spawnThread",postMessage(be,ue),0):kc(be)}function xh(){return 2097152}function wh(S,D){if(S==D)postMessage({cmd:"processQueuedMainThreadWork"});else if(T)postMessage({targetThread:S,cmd:"processThreadQueue"});else{var B=$e.pthreads[S],Q=B&&B.worker;if(!Q)return;Q.postMessage({cmd:"processThreadQueue"})}return 1}function kh(){Ii("")}function Ih(){C||k||ne("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Ic(){return 2147483648}function Sh(S,D,B){i().copyWithin(S,D,D+B)}function Ch(){return C?XT().cpus().length:navigator.hardwareConcurrency}function Mr(S,D){var B=arguments.length-2,Q=arguments;return Ci(function(){for(var ue=B,pe=Ri(ue*8),be=pe>>3,Te=0;Te>3,ue=0;ue>>16),ns(Ce.buffer),1}catch(D){}}function $h(S){var D=i().length;if(S=S>>>0,S<=D)return!1;var B=Ic();if(S>B)return!1;for(var Q=1;Q<=4;Q*=2){var ue=D*(1+.2/Q);ue=Math.min(ue,S+100663296);var pe=Math.min(B,wi(Math.max(S,ue),65536)),be=Th(pe);if(be)return!0}return!1}var Le={inEventHandler:0,removeAllEventListeners:function(){for(var S=Le.eventHandlers.length-1;S>=0;--S)Le._removeHandler(S);Le.eventHandlers=[],Le.deferredCalls=[]},registerRemoveEventListeners:function(){Le.removeEventListenersRegistered||(eh.push(Le.removeAllEventListeners),Le.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(S,D,B){function Q(be,Te){if(be.length!=Te.length)return!1;for(var bt in be)if(be[bt]!=Te[bt])return!1;return!0}for(var ue in Le.deferredCalls){var pe=Le.deferredCalls[ue];if(pe.targetFunction==S&&Q(pe.argsList,B))return}Le.deferredCalls.push({targetFunction:S,precedence:D,argsList:B}),Le.deferredCalls.sort(function(be,Te){return be.precedence>2]=B,l()[pe+4>>2]=Q,l()[pe+8>>2]=ue,Tf(S,637534208,D,Q,pe)})},getTargetThreadForEventCallback:function(S){switch(S){case 1:return 0;case 2:return $e.currentProxiedOperationCallerThread;default:return S}},getNodeNameForTarget:function(S){return S?S==window?"#window":S==screen?"#screen":S&&S.nodeName?S.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function _h(S){var D=xi(S)+1,B=Nf(D);return Ls(S,B,D),B}function Ah(S,D,B,Q){Ci(function(){var ue=Ri(12),pe=0;D&&(pe=_h(D)),l()[ue>>2]=pe,l()[ue+4>>2]=B,l()[ue+8>>2]=Q,Tf(S,657457152,0,pe,ue)})}function Eh(S,D,B,Q){D=D?en(D):"",Ah(S,D,B,Q)}function Rh(S){return S>2?en(S):S}var Dh=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Fh(S){S=Rh(S);var D=Dh[S]||(typeof document!="undefined"?document.querySelector(S):void 0);return D}function bu(S){return Fh(S)}function Sc(S,D,B){var Q=bu(S);if(!Q)return-4;if(Q.canvasSharedPtr&&(l()[Q.canvasSharedPtr>>2]=D,l()[Q.canvasSharedPtr+4>>2]=B),Q.offscreenCanvas||!Q.controlTransferredOffscreen){Q.offscreenCanvas&&(Q=Q.offscreenCanvas);var ue=!1;if(Q.GLctxObject&&Q.GLctxObject.GLctx){var pe=Q.GLctxObject.GLctx.getParameter(2978);ue=pe[0]===0&&pe[1]===0&&pe[2]===Q.width&&pe[3]===Q.height}Q.width=D,Q.height=B,ue&&Q.GLctxObject.GLctx.viewport(0,0,D,B)}else if(Q.canvasSharedPtr){var be=l()[Q.canvasSharedPtr+8>>2];return Eh(be,S,D,B),1}else return-4;return 0}function Cc(S,D,B){return T?Mr(2,1,S,D,B):Sc(S,D,B)}function Oh(S,D,B){var Q=bu(S);return Q?Sc(S,D,B):Cc(S,D,B)}function Ph(){throw"unwind"}function zh(S){var D=S.getExtension("ANGLE_instanced_arrays");if(D)return S.vertexAttribDivisor=function(B,Q){D.vertexAttribDivisorANGLE(B,Q)},S.drawArraysInstanced=function(B,Q,ue,pe){D.drawArraysInstancedANGLE(B,Q,ue,pe)},S.drawElementsInstanced=function(B,Q,ue,pe,be){D.drawElementsInstancedANGLE(B,Q,ue,pe,be)},1}function Mh(S){var D=S.getExtension("OES_vertex_array_object");if(D)return S.createVertexArray=function(){return D.createVertexArrayOES()},S.deleteVertexArray=function(B){D.deleteVertexArrayOES(B)},S.bindVertexArray=function(B){D.bindVertexArrayOES(B)},S.isVertexArray=function(B){return D.isVertexArrayOES(B)},1}function Lh(S){var D=S.getExtension("WEBGL_draw_buffers");if(D)return S.drawBuffers=function(B,Q){D.drawBuffersWEBGL(B,Q)},1}function Bh(S){return!!(S.multiDrawWebgl=S.getExtension("WEBGL_multi_draw"))}var gt={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(D){gt.lastError||(gt.lastError=D)},getNewId:function(S){for(var D=gt.counter++,B=S.length;B>2]:-1;ue+=en(l()[B+pe*4>>2],be<0?void 0:be)}return ue},createContext:function(S,D){S.getContextSafariWebGL2Fixed||(S.getContextSafariWebGL2Fixed=S.getContext,S.getContext=function(ue,pe){var be=S.getContextSafariWebGL2Fixed(ue,pe);return ue=="webgl"==be instanceof WebGLRenderingContext?be:null});var B=S.getContext("webgl",D);if(!B)return 0;var Q=gt.registerContext(B,D);return Q},registerContext:function(S,D){var B=Nf(8);l()[B+4>>2]=Fc();var Q={handle:B,attributes:D,version:D.majorVersion,GLctx:S};return S.canvas&&(S.canvas.GLctxObject=Q),gt.contexts[B]=Q,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&>.initExtensions(Q),B},makeContextCurrent:function(S){return gt.currentContext=gt.contexts[S],d.ctx=_c=gt.currentContext&>.currentContext.GLctx,!(S&&!_c)},getContext:function(S){return gt.contexts[S]},deleteContext:function(S){gt.currentContext===gt.contexts[S]&&(gt.currentContext=null),typeof Le=="object"&&Le.removeAllHandlersOnTarget(gt.contexts[S].GLctx.canvas),gt.contexts[S]&>.contexts[S].GLctx.canvas&&(gt.contexts[S].GLctx.canvas.GLctxObject=void 0),Uv(gt.contexts[S].handle),gt.contexts[S]=null},initExtensions:function(S){if(S||(S=gt.currentContext),!S.initExtensionsDone){S.initExtensionsDone=!0;var D=S.GLctx;zh(D),Mh(D),Lh(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),Bh(D);var B=D.getSupportedExtensions()||[];B.forEach(function(Q){!Q.includes("lose_context")&&!Q.includes("debug")&&D.getExtension(Q)})}}},Vh=["default","low-power","high-performance"];function Wh(S,D){var B=D>>2,Q=l()[B+6],ue={alpha:!!l()[B+0],depth:!!l()[B+1],stencil:!!l()[B+2],antialias:!!l()[B+3],premultipliedAlpha:!!l()[B+4],preserveDrawingBuffer:!!l()[B+5],powerPreference:Vh[Q],failIfMajorPerformanceCaveat:!!l()[B+7],majorVersion:l()[B+8],minorVersion:l()[B+9],enableExtensionsByDefault:l()[B+10],explicitSwapControl:l()[B+11],proxyContextToMainThread:l()[B+12],renderViaOffscreenBackBuffer:l()[B+13]},pe=bu(S);if(!pe||ue.explicitSwapControl)return 0;var be=gt.createContext(pe,ue);return be}function Uh(S,D){return Wh(S,D)}var Ti={mappings:{},buffers:[null,[],[]],printChar:function(S,D){var B=Ti.buffers[S];D===0||D===10?((S===1?te:ee)(Rn(B,0)),B.length=0):B.push(D)},varargs:void 0,get:function(){Ti.varargs+=4;var S=l()[Ti.varargs-4>>2];return S},getStr:function(S){var D=en(S);return D},get64:function(S,D){return S}};function Nc(S){return T?Mr(3,1,S):0}function Tc(S,D,B,Q,ue){if(T)return Mr(4,1,S,D,B,Q,ue)}function $c(S,D,B,Q){if(T)return Mr(5,1,S,D,B,Q);for(var ue=0,pe=0;pe>2],Te=l()[D+4>>2];D+=8;for(var bt=0;bt>2]=ue,0}function Gh(S){Ee(S)}$e.init();var _c,Hh=[null,wc,Cc,Nc,Tc,$c],Bv=!1,Ac={__clock_gettime:gh,__emscripten_init_main_thread_js:bh,__emscripten_thread_cleanup:yh,__pthread_create_js:vh,_emscripten_default_pthread_stack_size:xh,_emscripten_notify_thread_queue:wh,abort:kh,emscripten_check_blocking_allowed:Ih,emscripten_get_heap_max:Ic,emscripten_get_now:zr,emscripten_memcpy_big:Sh,emscripten_num_logical_cores:Ch,emscripten_receive_on_main_thread_js:Nh,emscripten_resize_heap:$h,emscripten_set_canvas_element_size:Oh,emscripten_unwind_to_js_event_loop:Ph,emscripten_webgl_create_context:Uh,exit:xc,fd_close:Nc,fd_seek:Tc,fd_write:$c,memory:Ce||d.wasmMemory,setTempRet0:Gh},Vv=ah(),qh=d.___wasm_call_ctors=function(){return(qh=d.___wasm_call_ctors=d.asm.__wasm_call_ctors).apply(null,arguments)},jh=d._init=function(){return(jh=d._init=d.asm.init).apply(null,arguments)},Kh=d._init_with_threads_count=function(){return(Kh=d._init_with_threads_count=d.asm.init_with_threads_count).apply(null,arguments)},Xh=d._get_threads_count=function(){return(Xh=d._get_threads_count=d.asm.get_threads_count).apply(null,arguments)},Yh=d._register_tensor=function(){return(Yh=d._register_tensor=d.asm.register_tensor).apply(null,arguments)},Qh=d._dispose_data=function(){return(Qh=d._dispose_data=d.asm.dispose_data).apply(null,arguments)},Zh=d._dispose=function(){return(Zh=d._dispose=d.asm.dispose).apply(null,arguments)},Jh=d._Abs=function(){return(Jh=d._Abs=d.asm.Abs).apply(null,arguments)},ef=d._Add=function(){return(ef=d._Add=d.asm.Add).apply(null,arguments)},tf=d._AddN=function(){return(tf=d._AddN=d.asm.AddN).apply(null,arguments)},nf=d._All=function(){return(nf=d._All=d.asm.All).apply(null,arguments)},sf=d._Any=function(){return(sf=d._Any=d.asm.Any).apply(null,arguments)},rf=d._ArgMax=function(){return(rf=d._ArgMax=d.asm.ArgMax).apply(null,arguments)},af=d._AvgPool=function(){return(af=d._AvgPool=d.asm.AvgPool).apply(null,arguments)},of=d._BatchMatMul=function(){return(of=d._BatchMatMul=d.asm.BatchMatMul).apply(null,arguments)},uf=d._Ceil=function(){return(uf=d._Ceil=d.asm.Ceil).apply(null,arguments)},lf=d._ClipByValue=function(){return(lf=d._ClipByValue=d.asm.ClipByValue).apply(null,arguments)},cf=d._Conv2D=function(){return(cf=d._Conv2D=d.asm.Conv2D).apply(null,arguments)},df=d._Conv2DBackpropInput=function(){return(df=d._Conv2DBackpropInput=d.asm.Conv2DBackpropInput).apply(null,arguments)},pf=d._Cos=function(){return(pf=d._Cos=d.asm.Cos).apply(null,arguments)},hf=d._Cosh=function(){return(hf=d._Cosh=d.asm.Cosh).apply(null,arguments)},ff=d._CropAndResize=function(){return(ff=d._CropAndResize=d.asm.CropAndResize).apply(null,arguments)},mf=d._Cumsum=function(){return(mf=d._Cumsum=d.asm.Cumsum).apply(null,arguments)},gf=d._DepthToSpace=function(){return(gf=d._DepthToSpace=d.asm.DepthToSpace).apply(null,arguments)},bf=d._DepthwiseConv2dNative=function(){return(bf=d._DepthwiseConv2dNative=d.asm.DepthwiseConv2dNative).apply(null,arguments)},yf=d._Elu=function(){return(yf=d._Elu=d.asm.Elu).apply(null,arguments)},vf=d._Equal=function(){return(vf=d._Equal=d.asm.Equal).apply(null,arguments)},xf=d._Exp=function(){return(xf=d._Exp=d.asm.Exp).apply(null,arguments)},wf=d._FlipLeftRight=function(){return(wf=d._FlipLeftRight=d.asm.FlipLeftRight).apply(null,arguments)},Ec=d._Floor=function(){return(Ec=d._Floor=d.asm.Floor).apply(null,arguments)},Rc=d._FloorDiv=function(){return(Rc=d._FloorDiv=d.asm.FloorDiv).apply(null,arguments)},yu=d._FusedBatchNorm=function(){return(yu=d._FusedBatchNorm=d.asm.FusedBatchNorm).apply(null,arguments)},kf=d._FusedConv2D=function(){return(kf=d._FusedConv2D=d.asm.FusedConv2D).apply(null,arguments)},If=d._FusedDepthwiseConv2D=function(){return(If=d._FusedDepthwiseConv2D=d.asm.FusedDepthwiseConv2D).apply(null,arguments)},$i=d._Gather=function(){return($i=d._Gather=d.asm.Gather).apply(null,arguments)},vu=d._GatherNd=function(){return(vu=d._GatherNd=d.asm.GatherNd).apply(null,arguments)},xu=d._Greater=function(){return(xu=d._Greater=d.asm.Greater).apply(null,arguments)},Wv=d._GreaterEqual=function(){return(Wv=d._GreaterEqual=d.asm.GreaterEqual).apply(null,arguments)},_i=d._LeakyRelu=function(){return(_i=d._LeakyRelu=d.asm.LeakyRelu).apply(null,arguments)},Ai=d._Less=function(){return(Ai=d._Less=d.asm.Less).apply(null,arguments)},Sf=d._LessEqual=function(){return(Sf=d._LessEqual=d.asm.LessEqual).apply(null,arguments)},H=d._Log=function(){return(H=d._Log=d.asm.Log).apply(null,arguments)},J=d._LogicalAnd=function(){return(J=d._LogicalAnd=d.asm.LogicalAnd).apply(null,arguments)},de=d._Max=function(){return(de=d._Max=d.asm.Max).apply(null,arguments)},ke=d._MaxPool=function(){return(ke=d._MaxPool=d.asm.MaxPool).apply(null,arguments)},Qe=d._Maximum=function(){return(Qe=d._Maximum=d.asm.Maximum).apply(null,arguments)},Ze=d._Mean=function(){return(Ze=d._Mean=d.asm.Mean).apply(null,arguments)},Ve=d._Min=function(){return(Ve=d._Min=d.asm.Min).apply(null,arguments)},ze=d._Minimum=function(){return(ze=d._Minimum=d.asm.Minimum).apply(null,arguments)},Tt=d._MirrorPad=function(){return(Tt=d._MirrorPad=d.asm.MirrorPad).apply(null,arguments)},rs=d._Multiply=function(){return(rs=d._Multiply=d.asm.Multiply).apply(null,arguments)},as=d._Neg=function(){return(as=d._Neg=d.asm.Neg).apply(null,arguments)},Ei=d._NonMaxSuppressionV3=function(){return(Ei=d._NonMaxSuppressionV3=d.asm.NonMaxSuppressionV3).apply(null,arguments)},Lr=d._NonMaxSuppressionV4=function(){return(Lr=d._NonMaxSuppressionV4=d.asm.NonMaxSuppressionV4).apply(null,arguments)},Cf=d._NonMaxSuppressionV5=function(){return(Cf=d._NonMaxSuppressionV5=d.asm.NonMaxSuppressionV5).apply(null,arguments)},rn=d._NotEqual=function(){return(rn=d._NotEqual=d.asm.NotEqual).apply(null,arguments)},nr=d._OneHot=function(){return(nr=d._OneHot=d.asm.OneHot).apply(null,arguments)},Dc=d._PadV2=function(){return(Dc=d._PadV2=d.asm.PadV2).apply(null,arguments)},MN=d._Pow=function(){return(MN=d._Pow=d.asm.Pow).apply(null,arguments)},LN=d._Prelu=function(){return(LN=d._Prelu=d.asm.Prelu).apply(null,arguments)},BN=d._Prod=function(){return(BN=d._Prod=d.asm.Prod).apply(null,arguments)},VN=d._RealDiv=function(){return(VN=d._RealDiv=d.asm.RealDiv).apply(null,arguments)},WN=d._Relu=function(){return(WN=d._Relu=d.asm.Relu).apply(null,arguments)},UN=d._Relu6=function(){return(UN=d._Relu6=d.asm.Relu6).apply(null,arguments)},GN=d._ResizeBilinear=function(){return(GN=d._ResizeBilinear=d.asm.ResizeBilinear).apply(null,arguments)},HN=d._Reverse=function(){return(HN=d._Reverse=d.asm.Reverse).apply(null,arguments)},qN=d._RotateWithOffset=function(){return(qN=d._RotateWithOffset=d.asm.RotateWithOffset).apply(null,arguments)},jN=d._Round=function(){return(jN=d._Round=d.asm.Round).apply(null,arguments)},KN=d._Rsqrt=function(){return(KN=d._Rsqrt=d.asm.Rsqrt).apply(null,arguments)},XN=d._ScatterNd=function(){return(XN=d._ScatterNd=d.asm.ScatterNd).apply(null,arguments)},YN=d._SelectV2=function(){return(YN=d._SelectV2=d.asm.SelectV2).apply(null,arguments)},QN=d._Sigmoid=function(){return(QN=d._Sigmoid=d.asm.Sigmoid).apply(null,arguments)},ZN=d._Sin=function(){return(ZN=d._Sin=d.asm.Sin).apply(null,arguments)},JN=d._Softmax=function(){return(JN=d._Softmax=d.asm.Softmax).apply(null,arguments)},eT=d._SparseFillEmptyRows=function(){return(eT=d._SparseFillEmptyRows=d.asm.SparseFillEmptyRows).apply(null,arguments)},tT=d._SparseReshape=function(){return(tT=d._SparseReshape=d.asm.SparseReshape).apply(null,arguments)},nT=d._SparseSegmentReduction=function(){return(nT=d._SparseSegmentReduction=d.asm.SparseSegmentReduction).apply(null,arguments)},sT=d._Sqrt=function(){return(sT=d._Sqrt=d.asm.Sqrt).apply(null,arguments)},rT=d._Square=function(){return(rT=d._Square=d.asm.Square).apply(null,arguments)},aT=d._SquaredDifference=function(){return(aT=d._SquaredDifference=d.asm.SquaredDifference).apply(null,arguments)},iT=d._Step=function(){return(iT=d._Step=d.asm.Step).apply(null,arguments)},oT=d._StridedSlice=function(){return(oT=d._StridedSlice=d.asm.StridedSlice).apply(null,arguments)},uT=d._Sub=function(){return(uT=d._Sub=d.asm.Sub).apply(null,arguments)},lT=d._Sum=function(){return(lT=d._Sum=d.asm.Sum).apply(null,arguments)},cT=d._Tan=function(){return(cT=d._Tan=d.asm.Tan).apply(null,arguments)},dT=d._Tanh=function(){return(dT=d._Tanh=d.asm.Tanh).apply(null,arguments)},pT=d._Tile=function(){return(pT=d._Tile=d.asm.Tile).apply(null,arguments)},hT=d._TopK=function(){return(hT=d._TopK=d.asm.TopK).apply(null,arguments)},fT=d._Transform=function(){return(fT=d._Transform=d.asm.Transform).apply(null,arguments)},mT=d._Transpose=function(){return(mT=d._Transpose=d.asm.Transpose).apply(null,arguments)},gT=d.__FusedMatMul=function(){return(gT=d.__FusedMatMul=d.asm._FusedMatMul).apply(null,arguments)},Nf=d._malloc=function(){return(Nf=d._malloc=d.asm.malloc).apply(null,arguments)},Uv=d._free=function(){return(Uv=d._free=d.asm.free).apply(null,arguments)},bT=d._emscripten_tls_init=function(){return(bT=d._emscripten_tls_init=d.asm.emscripten_tls_init).apply(null,arguments)},Gv=d.___errno_location=function(){return(Gv=d.___errno_location=d.asm.__errno_location).apply(null,arguments)},Fc=d._pthread_self=function(){return(Fc=d._pthread_self=d.asm.pthread_self).apply(null,arguments)},Hv=d._emscripten_main_thread_process_queued_calls=function(){return(Hv=d._emscripten_main_thread_process_queued_calls=d.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},yT=d.__emscripten_thread_crashed=function(){return(yT=d.__emscripten_thread_crashed=d.asm._emscripten_thread_crashed).apply(null,arguments)},qv=d.__emscripten_thread_init=function(){return(qv=d.__emscripten_thread_init=d.asm._emscripten_thread_init).apply(null,arguments)},vT=d._emscripten_current_thread_process_queued_calls=function(){return(vT=d._emscripten_current_thread_process_queued_calls=d.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},xT=d._emscripten_main_browser_thread_id=function(){return(xT=d._emscripten_main_browser_thread_id=d.asm.emscripten_main_browser_thread_id).apply(null,arguments)},wT=d._emscripten_sync_run_in_main_thread_2=function(){return(wT=d._emscripten_sync_run_in_main_thread_2=d.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},jv=d._emscripten_sync_run_in_main_thread_4=function(){return(jv=d._emscripten_sync_run_in_main_thread_4=d.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},Kv=d._emscripten_run_in_main_runtime_thread_js=function(){return(Kv=d._emscripten_run_in_main_runtime_thread_js=d.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},Tf=d._emscripten_dispatch_to_thread_=function(){return(Tf=d._emscripten_dispatch_to_thread_=d.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},$f=d.__emscripten_thread_free_data=function(){return($f=d.__emscripten_thread_free_data=d.asm._emscripten_thread_free_data).apply(null,arguments)},kT=d.__emscripten_thread_exit=function(){return(kT=d.__emscripten_thread_exit=d.asm._emscripten_thread_exit).apply(null,arguments)},IT=d._memalign=function(){return(IT=d._memalign=d.asm.memalign).apply(null,arguments)},Xv=d._emscripten_stack_set_limits=function(){return(Xv=d._emscripten_stack_set_limits=d.asm.emscripten_stack_set_limits).apply(null,arguments)},_f=d.stackSave=function(){return(_f=d.stackSave=d.asm.stackSave).apply(null,arguments)},Oc=d.stackRestore=function(){return(Oc=d.stackRestore=d.asm.stackRestore).apply(null,arguments)},Ri=d.stackAlloc=function(){return(Ri=d.stackAlloc=d.asm.stackAlloc).apply(null,arguments)},ST=d.dynCall_iijjiiii=function(){return(ST=d.dynCall_iijjiiii=d.asm.dynCall_iijjiiii).apply(null,arguments)},CT=d.dynCall_jiji=function(){return(CT=d.dynCall_jiji=d.asm.dynCall_jiji).apply(null,arguments)},Yv=d.__emscripten_allow_main_runtime_queued_calls=21408;d.cwrap=Jt,d.keepRuntimeAlive=Or,d.PThread=$e,d.PThread=$e,d.wasmMemory=Ce,d.ExitStatus=wu;var Pc;function wu(S){this.name="ExitStatus",this.message="Program terminated with exit("+S+")",this.status=S}ss=function S(){Pc||Af(),Pc||(ss=S)};function Af(S){if(S=S||b,tr>0)return;if(T){h(d),hu(),postMessage({cmd:"loaded"});return}if(nn(),tr>0)return;function D(){Pc||(Pc=!0,d.calledRun=!0,!rt&&(hu(),h(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),sh()))}d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1),D()},1)):D()}d.run=Af;function NT(S,D){if(Zt=S,!D&&T)throw wc(S),"unwind";Or()||nh(),TT(S)}function TT(S){Zt=S,Or()||($e.terminateAllThreads(),d.onExit&&d.onExit(S),rt=!0),v(S,new wu(S))}if(d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.pop()();Af();var zc;m&&(zc={uncaughtException:process.listeners("uncaughtException").filter(function(S){return!m.uncaughtException.indexOf(S)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(S){return!m.unhandledRejection.indexOf(S)>-1})});var Mc;if(typeof WasmBackendModule!="undefined")Mc=WasmBackendModule;else if(typeof r!="undefined")Mc=r;else throw new Error("Could not find wasm module in post.js");if(zc){var $T=Mc._dispose;Mc._dispose=function(){$T(),zc.uncaughtException.forEach(function(S){process.removeListener("uncaughtException",S)}),zc.unhandledRejection.forEach(function(S){process.removeListener("unhandledRejection",S)})}}return r.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=n:typeof define=="function"&&define.amd?define([],function(){return n}):typeof e=="object"&&(e.WasmBackendModuleThreadedSimd=n)}}),QT=zt({"src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e,t){var n=(()=>{var s=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(s=s||__filename),function(r){r=r||{};var a=typeof r!="undefined"?r:{},i,o;a.ready=new Promise(function(H,J){i=H,o=J});var u;typeof process!="undefined"&&process.listeners&&(u={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var l=Object.assign({},a),c=[],p="./this.program",d=(H,J)=>{throw J},h=typeof window=="object",f=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function b(H){return a.locateFile?a.locateFile(H,g):g+H}var y,v,x,k;function C(H){if(H instanceof vu)return;R("exiting due to exception: "+H)}var T,E,A;m?(f?g=cd().dirname(g)+"/":g=__dirname+"/",A=()=>{E||(T=Jm(),E=cd())},y=function(J,de){return A(),J=E.normalize(J),T.readFileSync(J,de?void 0:"utf8")},x=H=>{var J=y(H,!0);return J.buffer||(J=new Uint8Array(J)),J},v=(H,J,de)=>{A(),H=E.normalize(H),T.readFile(H,function(ke,Qe){ke?de(ke):J(Qe.buffer)})},process.argv.length>1&&(p=process.argv[1].replace(/\\/g,"/")),c=process.argv.slice(2),process.on("uncaughtException",function(H){if(!(H instanceof vu))throw H}),process.on("unhandledRejection",function(H){throw H}),d=(H,J)=>{if(pu())throw process.exitCode=H,J;C(J),process.exit(H)},a.inspect=function(){return"[Emscripten Module object]"}):(h||f)&&(f?g=self.location.href:typeof document!="undefined"&&document.currentScript&&(g=document.currentScript.src),s&&(g=s),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",y=H=>{var J=new XMLHttpRequest;return J.open("GET",H,!1),J.send(null),J.responseText},f&&(x=H=>{var J=new XMLHttpRequest;return J.open("GET",H,!1),J.responseType="arraybuffer",J.send(null),new Uint8Array(J.response)}),v=(H,J,de)=>{var ke=new XMLHttpRequest;ke.open("GET",H,!0),ke.responseType="arraybuffer",ke.onload=()=>{if(ke.status==200||ke.status==0&&ke.response){J(ke.response);return}de()},ke.onerror=de,ke.send(null)},k=H=>document.title=H);var P=a.print||console.log.bind(console),R=a.printErr||console.warn.bind(console);Object.assign(a,l),l=null,a.arguments&&(c=a.arguments),a.thisProgram&&(p=a.thisProgram),a.quit&&(d=a.quit);var F=4;function $(H){$.shown||($.shown={}),$.shown[H]||($.shown[H]=1,R(H))}function z(H,J){if(typeof WebAssembly.Function=="function"){for(var de={i:"i32",j:"i64",f:"f32",d:"f64"},ke={parameters:[],results:J[0]=="v"?[]:[de[J[0]]]},Qe=1;Qe{Z=H},ee;a.wasmBinary&&(ee=a.wasmBinary);var se=a.noExitRuntime||!0;typeof WebAssembly!="object"&&Fr("no native wasm support detected");var ne,oe=!1,re;function le(H,J){H||Fr(J)}function me(H){var J=a["_"+H];return J}function we(H,J,de,ke,Qe){var Ze={string:function(rn){var nr=0;if(rn!=null&&rn!==0){var Dc=(rn.length<<2)+1;nr=yu(Dc),tt(rn,nr,Dc)}return nr},array:function(rn){var nr=yu(rn.length);return rt(rn,nr),nr}};function Ve(rn){return J==="string"?Je(rn):J==="boolean"?Boolean(rn):rn}var ze=me(H),Tt=[],rs=0;if(ke)for(var as=0;as=ke);)++Qe;if(Qe-J>16&&H.subarray&&Pe)return Pe.decode(H.subarray(J,Qe));for(var Ze="";J>10,56320|rs&1023)}}return Ze}function Je(H,J){return H?Xe(Jt,H,J):""}function Ye(H,J,de,ke){if(!(ke>0))return 0;for(var Qe=de,Ze=de+ke-1,Ve=0;Ve=55296&&ze<=57343){var Tt=H.charCodeAt(++Ve);ze=65536+((ze&1023)<<10)|Tt&1023}if(ze<=127){if(de>=Ze)break;J[de++]=ze}else if(ze<=2047){if(de+1>=Ze)break;J[de++]=192|ze>>6,J[de++]=128|ze&63}else if(ze<=65535){if(de+2>=Ze)break;J[de++]=224|ze>>12,J[de++]=128|ze>>6&63,J[de++]=128|ze&63}else{if(de+3>=Ze)break;J[de++]=240|ze>>18,J[de++]=128|ze>>12&63,J[de++]=128|ze>>6&63,J[de++]=128|ze&63}}return J[de]=0,de-Qe}function tt(H,J,de){return Ye(H,Jt,J,de)}function Ce(H){for(var J=0,de=0;de=55296&&ke<=57343&&(ke=65536+((ke&1023)<<10)|H.charCodeAt(++de)&1023),ke<=127?++J:ke<=2047?J+=2:ke<=65535?J+=3:J+=4}return J}var ut=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function rt(H,J){Et.set(H,J)}function Zt(H,J,de){for(var ke=0;ke>0]=H.charCodeAt(ke);de||(Et[J>>0]=0)}function Nt(H,J){return H%J>0&&(H+=J-H%J),H}var In,Et,Jt,Sn,Cn,Xt,Rn,en,Ms;function Ls(H){In=H,a.HEAP8=Et=new Int8Array(H),a.HEAP16=Sn=new Int16Array(H),a.HEAP32=Xt=new Int32Array(H),a.HEAPU8=Jt=new Uint8Array(H),a.HEAPU16=Cn=new Uint16Array(H),a.HEAPU32=Rn=new Uint32Array(H),a.HEAPF32=en=new Float32Array(H),a.HEAPF64=Ms=new Float64Array(H)}var xi=a.INITIAL_MEMORY||16777216,Js,Bs=[],du=[],wi=[],tn=!1,ac=!1,ic=0;function pu(){return se||ic>0}function oc(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)cc(a.preRun.shift());fu(Bs)}function uc(){tn=!0,fu(du)}function Ev(){ac=!0}function lc(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)dc(a.postRun.shift());fu(wi)}function cc(H){Bs.unshift(H)}function ns(H){du.unshift(H)}function dc(H){wi.unshift(H)}var Dn=0,ki=null,er=null;function eh(H){Dn++,a.monitorRunDependencies&&a.monitorRunDependencies(Dn)}function pc(H){if(Dn--,a.monitorRunDependencies&&a.monitorRunDependencies(Dn),Dn==0&&(ki!==null&&(clearInterval(ki),ki=null),er)){var J=er;er=null,J()}}a.preloadedImages={},a.preloadedAudios={};function Fr(H){a.onAbort&&a.onAbort(H),H="Aborted("+H+")",R(H),oe=!0,re=1,H+=". Build with -s ASSERTIONS=1 for more info.";var J=new WebAssembly.RuntimeError(H);throw o(J),J}var th="data:application/octet-stream;base64,";function hc(H){return H.startsWith(th)}function Or(H){return H.startsWith("file://")}var nn;nn="tfjs-backend-wasm.wasm",hc(nn)||(nn=b(nn));function hu(H){try{if(H==nn&&ee)return new Uint8Array(ee);if(x)return x(H);throw"both async and sync fetching of the wasm failed"}catch(J){Fr(J)}}function nh(){if(!ee&&(h||f)){if(typeof fetch=="function"&&!Or(nn))return fetch(nn,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+nn+"'";return H.arrayBuffer()}).catch(function(){return hu(nn)});if(v)return new Promise(function(H,J){v(nn,function(de){H(new Uint8Array(de))},J)})}return Promise.resolve().then(function(){return hu(nn)})}function sh(){var H={env:Ci,wasi_snapshot_preview1:Ci};function J(Ve,ze){var Tt=Ve.exports;a.asm=Tt,ne=a.asm.memory,Ls(ne.buffer),Js=a.asm.__indirect_function_table,ns(a.asm.__wasm_call_ctors),pc("wasm-instantiate")}eh("wasm-instantiate");function de(Ve){J(Ve.instance)}function ke(Ve){return nh().then(function(ze){return WebAssembly.instantiate(ze,H)}).then(function(ze){return ze}).then(Ve,function(ze){R("failed to asynchronously prepare wasm: "+ze),Fr(ze)})}function Qe(){return!ee&&typeof WebAssembly.instantiateStreaming=="function"&&!hc(nn)&&!Or(nn)&&typeof fetch=="function"?fetch(nn,{credentials:"same-origin"}).then(function(Ve){var ze=WebAssembly.instantiateStreaming(Ve,H);return ze.then(de,function(Tt){return R("wasm streaming compile failed: "+Tt),R("falling back to ArrayBuffer instantiation"),ke(de)})}):ke(de)}if(a.instantiateWasm)try{var Ze=a.instantiateWasm(H,J);return Ze}catch(Ve){return R("Module.instantiateWasm callback failed with error: "+Ve),!1}return Qe().catch(o),{}}var Rv,Dv;function fu(H){for(;H.length>0;){var J=H.shift();if(typeof J=="function"){J(a);continue}var de=J.func;typeof de=="number"?J.arg===void 0?mu(de)():mu(de)(J.arg):de(J.arg===void 0?null:J.arg)}}function tr(H){return H}function fc(H){var J=/\b_Z[\w\d_]+/g;return H.replace(J,function(de){var ke=de;return de===ke?de:ke+" ["+de+"]"})}var ss=[];function mu(H){var J=ss[H];return J||(H>=ss.length&&(ss.length=H+1),ss[H]=J=Js.get(H)),J}function Fv(){var H=new Error;if(!H.stack){try{throw new Error}catch(J){H=J}if(!H.stack)return"(no stack trace available)"}return H.stack.toString()}function Ii(H,J){Js.set(H,J),ss[H]=J}function rh(){Fr("")}function mc(H,J,de){Jt.copyWithin(H,J,J+de)}function gc(){return 2147483648}function sn(H){try{return ne.grow(H-In.byteLength+65535>>>16),Ls(ne.buffer),1}catch(J){}}function bc(H){var J=Jt.length;H=H>>>0;var de=gc();if(H>de)return!1;for(var ke=1;ke<=4;ke*=2){var Qe=J*(1+.2/ke);Qe=Math.min(Qe,H+100663296);var Ze=Math.min(de,Nt(Math.max(H,Qe),65536)),Ve=sn(Ze);if(Ve)return!0}return!1}var Si={mappings:{},buffers:[null,[],[]],printChar:function(H,J){var de=Si.buffers[H];J===0||J===10?((H===1?P:R)(Xe(de,0)),de.length=0):de.push(J)},varargs:void 0,get:function(){Si.varargs+=4;var H=Xt[Si.varargs-4>>2];return H},getStr:function(H){var J=Je(H);return J},get64:function(H,J){return H}};function ah(H){return 0}function Ov(H,J,de,ke,Qe){}function Pv(H,J,de,ke){for(var Qe=0,Ze=0;Ze>2],ze=Xt[J+4>>2];J+=8;for(var Tt=0;Tt>2]=Qe,0}function ih(H){te(H)}var yc=!1,Ci={abort:rh,emscripten_memcpy_big:mc,emscripten_resize_heap:bc,fd_close:ah,fd_seek:Ov,fd_write:Pv,setTempRet0:ih},zN=sh(),zv=a.___wasm_call_ctors=function(){return(zv=a.___wasm_call_ctors=a.asm.__wasm_call_ctors).apply(null,arguments)},oh=a._init=function(){return(oh=a._init=a.asm.init).apply(null,arguments)},uh=a._init_with_threads_count=function(){return(uh=a._init_with_threads_count=a.asm.init_with_threads_count).apply(null,arguments)},vc=a._get_threads_count=function(){return(vc=a._get_threads_count=a.asm.get_threads_count).apply(null,arguments)},xc=a._register_tensor=function(){return(xc=a._register_tensor=a.asm.register_tensor).apply(null,arguments)},lh=a._dispose_data=function(){return(lh=a._dispose_data=a.asm.dispose_data).apply(null,arguments)},$e=a._dispose=function(){return($e=a._dispose=a.asm.dispose).apply(null,arguments)},ch=a._Abs=function(){return(ch=a._Abs=a.asm.Abs).apply(null,arguments)},wc=a._Add=function(){return(wc=a._Add=a.asm.Add).apply(null,arguments)},Pr=a._AddN=function(){return(Pr=a._AddN=a.asm.AddN).apply(null,arguments)},Ni=a._All=function(){return(Ni=a._All=a.asm.All).apply(null,arguments)},dh=a._Any=function(){return(dh=a._Any=a.asm.Any).apply(null,arguments)},Mv=a._ArgMax=function(){return(Mv=a._ArgMax=a.asm.ArgMax).apply(null,arguments)},ph=a._AvgPool=function(){return(ph=a._AvgPool=a.asm.AvgPool).apply(null,arguments)},Lv=a._BatchMatMul=function(){return(Lv=a._BatchMatMul=a.asm.BatchMatMul).apply(null,arguments)},zr=a._Ceil=function(){return(zr=a._Ceil=a.asm.Ceil).apply(null,arguments)},hh=a._ClipByValue=function(){return(hh=a._ClipByValue=a.asm.ClipByValue).apply(null,arguments)},fh=a._Conv2D=function(){return(fh=a._Conv2D=a.asm.Conv2D).apply(null,arguments)},mh=a._Conv2DBackpropInput=function(){return(mh=a._Conv2DBackpropInput=a.asm.Conv2DBackpropInput).apply(null,arguments)},gh=a._Cos=function(){return(gh=a._Cos=a.asm.Cos).apply(null,arguments)},bh=a._Cosh=function(){return(bh=a._Cosh=a.asm.Cosh).apply(null,arguments)},yh=a._CropAndResize=function(){return(yh=a._CropAndResize=a.asm.CropAndResize).apply(null,arguments)},kc=a._Cumsum=function(){return(kc=a._Cumsum=a.asm.Cumsum).apply(null,arguments)},vh=a._DepthToSpace=function(){return(vh=a._DepthToSpace=a.asm.DepthToSpace).apply(null,arguments)},xh=a._DepthwiseConv2dNative=function(){return(xh=a._DepthwiseConv2dNative=a.asm.DepthwiseConv2dNative).apply(null,arguments)},wh=a._Elu=function(){return(wh=a._Elu=a.asm.Elu).apply(null,arguments)},kh=a._Equal=function(){return(kh=a._Equal=a.asm.Equal).apply(null,arguments)},Ih=a._Exp=function(){return(Ih=a._Exp=a.asm.Exp).apply(null,arguments)},Ic=a._FlipLeftRight=function(){return(Ic=a._FlipLeftRight=a.asm.FlipLeftRight).apply(null,arguments)},Sh=a._Floor=function(){return(Sh=a._Floor=a.asm.Floor).apply(null,arguments)},Ch=a._FloorDiv=function(){return(Ch=a._FloorDiv=a.asm.FloorDiv).apply(null,arguments)},Mr=a._FusedBatchNorm=function(){return(Mr=a._FusedBatchNorm=a.asm.FusedBatchNorm).apply(null,arguments)},gu=a._FusedConv2D=function(){return(gu=a._FusedConv2D=a.asm.FusedConv2D).apply(null,arguments)},Nh=a._FusedDepthwiseConv2D=function(){return(Nh=a._FusedDepthwiseConv2D=a.asm.FusedDepthwiseConv2D).apply(null,arguments)},Th=a._Gather=function(){return(Th=a._Gather=a.asm.Gather).apply(null,arguments)},$h=a._GatherNd=function(){return($h=a._GatherNd=a.asm.GatherNd).apply(null,arguments)},Le=a._Greater=function(){return(Le=a._Greater=a.asm.Greater).apply(null,arguments)},_h=a._GreaterEqual=function(){return(_h=a._GreaterEqual=a.asm.GreaterEqual).apply(null,arguments)},Ah=a._LeakyRelu=function(){return(Ah=a._LeakyRelu=a.asm.LeakyRelu).apply(null,arguments)},Eh=a._Less=function(){return(Eh=a._Less=a.asm.Less).apply(null,arguments)},Rh=a._LessEqual=function(){return(Rh=a._LessEqual=a.asm.LessEqual).apply(null,arguments)},Dh=a._Log=function(){return(Dh=a._Log=a.asm.Log).apply(null,arguments)},Fh=a._LogicalAnd=function(){return(Fh=a._LogicalAnd=a.asm.LogicalAnd).apply(null,arguments)},bu=a._Max=function(){return(bu=a._Max=a.asm.Max).apply(null,arguments)},Sc=a._MaxPool=function(){return(Sc=a._MaxPool=a.asm.MaxPool).apply(null,arguments)},Cc=a._Maximum=function(){return(Cc=a._Maximum=a.asm.Maximum).apply(null,arguments)},Oh=a._Mean=function(){return(Oh=a._Mean=a.asm.Mean).apply(null,arguments)},Ph=a._Min=function(){return(Ph=a._Min=a.asm.Min).apply(null,arguments)},zh=a._Minimum=function(){return(zh=a._Minimum=a.asm.Minimum).apply(null,arguments)},Mh=a._MirrorPad=function(){return(Mh=a._MirrorPad=a.asm.MirrorPad).apply(null,arguments)},Lh=a._Multiply=function(){return(Lh=a._Multiply=a.asm.Multiply).apply(null,arguments)},Bh=a._Neg=function(){return(Bh=a._Neg=a.asm.Neg).apply(null,arguments)},gt=a._NonMaxSuppressionV3=function(){return(gt=a._NonMaxSuppressionV3=a.asm.NonMaxSuppressionV3).apply(null,arguments)},Vh=a._NonMaxSuppressionV4=function(){return(Vh=a._NonMaxSuppressionV4=a.asm.NonMaxSuppressionV4).apply(null,arguments)},Wh=a._NonMaxSuppressionV5=function(){return(Wh=a._NonMaxSuppressionV5=a.asm.NonMaxSuppressionV5).apply(null,arguments)},Uh=a._NotEqual=function(){return(Uh=a._NotEqual=a.asm.NotEqual).apply(null,arguments)},Ti=a._OneHot=function(){return(Ti=a._OneHot=a.asm.OneHot).apply(null,arguments)},Nc=a._PadV2=function(){return(Nc=a._PadV2=a.asm.PadV2).apply(null,arguments)},Tc=a._Pow=function(){return(Tc=a._Pow=a.asm.Pow).apply(null,arguments)},$c=a._Prelu=function(){return($c=a._Prelu=a.asm.Prelu).apply(null,arguments)},Gh=a._Prod=function(){return(Gh=a._Prod=a.asm.Prod).apply(null,arguments)},_c=a._RealDiv=function(){return(_c=a._RealDiv=a.asm.RealDiv).apply(null,arguments)},Hh=a._Relu=function(){return(Hh=a._Relu=a.asm.Relu).apply(null,arguments)},Bv=a._Relu6=function(){return(Bv=a._Relu6=a.asm.Relu6).apply(null,arguments)},Ac=a._ResizeBilinear=function(){return(Ac=a._ResizeBilinear=a.asm.ResizeBilinear).apply(null,arguments)},Vv=a._Reverse=function(){return(Vv=a._Reverse=a.asm.Reverse).apply(null,arguments)},qh=a._RotateWithOffset=function(){return(qh=a._RotateWithOffset=a.asm.RotateWithOffset).apply(null,arguments)},jh=a._Round=function(){return(jh=a._Round=a.asm.Round).apply(null,arguments)},Kh=a._Rsqrt=function(){return(Kh=a._Rsqrt=a.asm.Rsqrt).apply(null,arguments)},Xh=a._ScatterNd=function(){return(Xh=a._ScatterNd=a.asm.ScatterNd).apply(null,arguments)},Yh=a._SelectV2=function(){return(Yh=a._SelectV2=a.asm.SelectV2).apply(null,arguments)},Qh=a._Sigmoid=function(){return(Qh=a._Sigmoid=a.asm.Sigmoid).apply(null,arguments)},Zh=a._Sin=function(){return(Zh=a._Sin=a.asm.Sin).apply(null,arguments)},Jh=a._Softmax=function(){return(Jh=a._Softmax=a.asm.Softmax).apply(null,arguments)},ef=a._SparseFillEmptyRows=function(){return(ef=a._SparseFillEmptyRows=a.asm.SparseFillEmptyRows).apply(null,arguments)},tf=a._SparseReshape=function(){return(tf=a._SparseReshape=a.asm.SparseReshape).apply(null,arguments)},nf=a._SparseSegmentReduction=function(){return(nf=a._SparseSegmentReduction=a.asm.SparseSegmentReduction).apply(null,arguments)},sf=a._Sqrt=function(){return(sf=a._Sqrt=a.asm.Sqrt).apply(null,arguments)},rf=a._Square=function(){return(rf=a._Square=a.asm.Square).apply(null,arguments)},af=a._SquaredDifference=function(){return(af=a._SquaredDifference=a.asm.SquaredDifference).apply(null,arguments)},of=a._Step=function(){return(of=a._Step=a.asm.Step).apply(null,arguments)},uf=a._StridedSlice=function(){return(uf=a._StridedSlice=a.asm.StridedSlice).apply(null,arguments)},lf=a._Sub=function(){return(lf=a._Sub=a.asm.Sub).apply(null,arguments)},cf=a._Sum=function(){return(cf=a._Sum=a.asm.Sum).apply(null,arguments)},df=a._Tan=function(){return(df=a._Tan=a.asm.Tan).apply(null,arguments)},pf=a._Tanh=function(){return(pf=a._Tanh=a.asm.Tanh).apply(null,arguments)},hf=a._Tile=function(){return(hf=a._Tile=a.asm.Tile).apply(null,arguments)},ff=a._TopK=function(){return(ff=a._TopK=a.asm.TopK).apply(null,arguments)},mf=a._Transform=function(){return(mf=a._Transform=a.asm.Transform).apply(null,arguments)},gf=a._Transpose=function(){return(gf=a._Transpose=a.asm.Transpose).apply(null,arguments)},bf=a.__FusedMatMul=function(){return(bf=a.__FusedMatMul=a.asm._FusedMatMul).apply(null,arguments)},yf=a._malloc=function(){return(yf=a._malloc=a.asm.malloc).apply(null,arguments)},vf=a._free=function(){return(vf=a._free=a.asm.free).apply(null,arguments)},xf=a.___errno_location=function(){return(xf=a.___errno_location=a.asm.__errno_location).apply(null,arguments)},wf=a._emscripten_main_thread_process_queued_calls=function(){return(wf=a._emscripten_main_thread_process_queued_calls=a.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Ec=a.stackSave=function(){return(Ec=a.stackSave=a.asm.stackSave).apply(null,arguments)},Rc=a.stackRestore=function(){return(Rc=a.stackRestore=a.asm.stackRestore).apply(null,arguments)},yu=a.stackAlloc=function(){return(yu=a.stackAlloc=a.asm.stackAlloc).apply(null,arguments)},kf=a.dynCall_iijjiiii=function(){return(kf=a.dynCall_iijjiiii=a.asm.dynCall_iijjiiii).apply(null,arguments)},If=a.dynCall_jiji=function(){return(If=a.dynCall_jiji=a.asm.dynCall_jiji).apply(null,arguments)};a.cwrap=Se;var $i;function vu(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}er=function H(){$i||xu(),$i||(er=H)};function xu(H){if(H=H||c,Dn>0||(oc(),Dn>0))return;function J(){$i||($i=!0,a.calledRun=!0,!oe&&(uc(),i(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),lc()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),J()},1)):J()}a.run=xu;function Wv(H){re=H,pu()||(a.onExit&&a.onExit(H),oe=!0),d(H,new vu(H))}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();xu();var _i;u&&(_i={uncaughtException:process.listeners("uncaughtException").filter(function(H){return!u.uncaughtException.indexOf(H)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(H){return!u.unhandledRejection.indexOf(H)>-1})});var Ai;if(typeof r!="undefined")Ai=r;else if(typeof WasmBackendModuleThreadedSimd!="undefined")Ai=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(_i){var Sf=Ai._dispose;Ai._dispose=function(){Sf(),_i.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),_i.unhandledRejection.forEach(function(H){process.removeListener("unhandledRejection",H)})}}return r.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=n:typeof define=="function"&&define.amd?define([],function(){return n}):typeof e=="object"&&(e.WasmBackendModule=n)}}),ZT=1e-7,JT=1e-4,Wd=class{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}},tl=class{refCount(e){return Fn("refCount")}incRef(e){return Fn("incRef")}timerAvailable(){return!0}time(e){return Fn("time")}read(e){return Fn("read")}readSync(e){return Fn("readSync")}readToGPU(e,t){return Fn("readToGPU")}numDataIds(){return Fn("numDataIds")}disposeData(e,t){return Fn("disposeData")}write(e,t,n){return Fn("write")}move(e,t,n,s,r){return Fn("move")}memory(){return Fn("memory")}floatPrecision(){return Fn("floatPrecision")}epsilon(){return this.floatPrecision()===32?ZT:JT}dispose(){return Fn("dispose")}};function Fn(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function zw(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,dd(e,t,n)}function e$(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,s=0;for(;n>0;)s=Math.random()*n|0,n--,dd(e,n,s),dd(t,n,s)}function Bu(e,t,n){return Math.max(e,Math.min(t,n))}function t$(e){return e%2===0?e:e+1}function dd(e,t,n){let s=e[t];e[t]=e[n],e[n]=s}function n$(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function va(e){O(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function ta(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||Yt(e)&&!n)for(let s=0;s0,n){return new Promise((s,r)=>{let a=0,i=()=>{if(e()){s();return}a++;let o=t(a);if(n!=null&&a>=n){r();return}setTimeout(i,o)};i()})}function c$(e,t){let n=1,s=-1;for(let a=0;a=0)n*=e[a];else if(e[a]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`);s=a}else if(e[a]<0)throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);if(s===-1){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(n===0)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);let r=e.slice();return r[s]=t/n,r}function Jn(e,t){let n=t.length;return e=e==null?t.map((s,r)=>r):[].concat(e),O(e.every(s=>s>=-n&&s`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),O(e.every(s=>Xi(s)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(s=>s<0?n+s:s)}function Mw(e,t){let n=[],s=[],r=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||r?null:Jn(t,e).sort(),i=0;for(let o=0;oo)&&e[o]===1&&(n.push(e[o]),s.push(o)),a[i]<=o&&i++}e[o]!==1&&(n.push(e[o]),s.push(o))}return{newShape:n,keptDims:s}}function Lw(e,t){let n=null;if(e==null||e==="float32")n=new Float32Array(t);else if(e==="int32")n=new Int32Array(t);else if(e==="bool")n=new Uint8Array(t);else throw new Error(`Unknown data type ${e}`);return n}function Bw(e,t){let n=null;if(e==null||e==="float32")n=new Float32Array(t);else if(e==="int32")n=new Int32Array(t);else if(e==="bool")n=new Uint8Array(t);else if(e==="string")n=new Array(t);else throw new Error(`Unknown data type ${e}`);return n}function Vw(e,t){for(let n=0;nt+=n.length),t}function ir(e){return typeof e=="string"||e instanceof String}function Gw(e){return typeof e=="boolean"}function Hw(e){return typeof e=="number"}function Ud(e){return Array.isArray(e)?Ud(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Hw(e)?"float32":ir(e)?"string":Gw(e)?"bool":"float32"}function hr(e){return!!(e&&e.constructor&&e.call&&e.apply)}function pd(e,t){for(let n=t;n=0;--s)n[s]=n[s+1]*e[s+1];return n}function qw(e,t,n,s=!1){let r=new Array;if(t.length===1){let a=t[0]*(s?2:1);for(let i=0;iu*l)*(s?2:1);for(let u=0;ur*a)*(n?2:1);if(s===0)return[];if(s!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return qw(0,e,t,n)}function eg(e,t){let n=Gd(e,t);for(let s=0;ss*r,1);if(t==null||t==="float32")return Gi(e,new Float32Array(n));if(t==="int32")return Gi(e,new Int32Array(n));if(t==="bool")return Gi(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function tg(e){e.forEach(t=>{O(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function h$(e,t,n){if(t===0)return 0;if(t===1)return e[0];let s=e[e.length-1];for(let r=0;r{let[s,r]=n.split(":");this.urlFlags[s]=y$(s,r)})}};function g$(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(b$(t,s[0],s[1]),s.join("="))),t}function b$(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function y$(e,t){if(t=t.toLowerCase(),t==="true"||t==="false")return t==="true";if(`${+t}`===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}function X(){return jw}var jw=null;function v$(e){jw=e}var Ef;function Kw(){if(Ef==null){let e;if(typeof window!="undefined")e=window;else if(typeof global!="undefined")e=global;else if(typeof process!="undefined")e=process;else if(typeof self!="undefined")e=self;else throw new Error("Could not find a global object");Ef=e}return Ef}function x$(){let e=Kw();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function sg(e,t){let n=x$();if(n.has(e))return n.get(e);{let s=t();return n.set(e,s),n.get(e)}}var ao="Abs",nl="Acos",sl="Acosh",kr="Add",xa="AddN",rl="All",al="Any",wa="ArgMax",il="ArgMin",ol="Asin",ul="Asinh",ll="Atan",cl="Atanh",dl="Atan2",ka="AvgPool",rg="AvgPoolGrad",Hd="AvgPool3D",ag="AvgPool3DGrad",Ia="BatchMatMul",io="BatchToSpaceND",ig="Bincount",w$="BroadcastTo",og="BroadcastArgs",Sa="Cast",Ca="Ceil",Ir="ClipByValue",qd="Complex",jd="ComplexAbs",oo="Concat",Na="Conv2D",ug="Conv2DBackpropFilter",Ta="Conv2DBackpropInput",Kd="Conv3D",lg="Conv3DBackpropFilterV2",cg="Conv3DBackpropInputV2",$a="Cos",_a="Cosh",uo="Cumsum",lo="CropAndResize",dg="DenseBincount",co="DepthToSpace",Aa="DepthwiseConv2dNative",pg="DepthwiseConv2dNativeBackpropFilter",hg="DepthwiseConv2dNativeBackpropInput",fg="Diag",Xd="Dilation2D",Kf="Dilation2DBackpropInput",Xf="Dilation2DBackpropFilter",Ea="RealDiv",Yd="Einsum",Ra="Elu",mg="EluGrad",pl="Erf",po="Equal",Da="Exp",ho="ExpandDims",fo="Expm1",gg="FFT",hl="Fill",mo="FlipLeftRight",Fa="Floor",Oa="FloorDiv",Pa="FusedBatchNorm",go="GatherV2",bo="GatherNd",yo="Greater",za="GreaterEqual",Ma="Identity",bg="IFFT",Qd="Imag",fl="IsFinite",ml="IsInf",gl="IsNan",La="LeakyRelu",vo="Less",xo="LessEqual",yg="LinSpace",Ba="Log",bl="Log1p",wo="LogicalAnd",yl="LogicalNot",Zd="LogicalOr",k$="LogSoftmax",Jd="LRN",vg="LRNGrad",Va="Max",Wa="Maximum",Ua="MaxPool",xg="MaxPoolGrad",ep="MaxPool3D",wg="MaxPool3DGrad",kg="MaxPoolWithArgmax",Ga="Mean",Ha="Min",qa="Minimum",ja="MirrorPad",vl="Mod",Ig="Multinomial",Ka="Multiply",ko="Neg",Io="NotEqual",So="NonMaxSuppressionV3",xl="NonMaxSuppressionV4",Co="NonMaxSuppressionV5",No="OnesLike",To="OneHot",$o="Pack",Xa="PadV2",pde="Pool",Ya="Pow",Qa="Prelu",_o="Prod",wl="Range",tp="Real",kl="Reciprocal",Za="Relu",Ao="Reshape",Il="ResizeNearestNeighbor",Sg="ResizeNearestNeighborGrad",Ja="ResizeBilinear",Cg="ResizeBilinearGrad",ei="Relu6",Eo="Reverse",Ro="Round",ti="Rsqrt",Do="ScatterNd",Fo="Select",Sl="Selu",Oo="Slice",ni="Sin",Po="Sinh",Cl="Sign",si="Sigmoid",Nl="Softplus",ri="Sqrt",ai="Sum",zo="SpaceToBatchND",Mo="SplitV",ii="Softmax",np="SparseFillEmptyRows",Tl="SparseReshape",sp="SparseSegmentMean",rp="SparseSegmentSum",ap="SparseToDense",oi="SquaredDifference",$l="Square",Lo="StridedSlice",ip="StringNGrams",Ng="StringSplit",Tg="StringToHashBucketFast",ui="Sub",Bo="Tan",li="Tanh",Sr="Tile",Vo="TopK",Wo="Transform",ci="Transpose",$g="Unique",Uo="Unpack",op="UnsortedSegmentSum",Go="ZerosLike",di="Step",hd="FromPixels",Ho="RotateWithOffset",na="_FusedMatMul",sa="FusedConv2D",ra="FusedDepthwiseConv2D";function ar(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.warn(...e)}function I$(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.log(...e)}var Yi=sg("kernelRegistry",()=>new Map),Vu=sg("gradRegistry",()=>new Map);function Yf(e,t){let n=_g(e,t);return Yi.get(n)}function Jv(e){return Vu.get(e)}function Qf(e){let t=Yi.entries(),n=[];for(;;){let{done:s,value:r}=t.next();if(s)break;let[a,i]=r,[o]=a.split("_");o===e&&n.push(i)}return n}function _l(e){let{kernelName:t,backendName:n}=e,s=_g(t,n);Yi.has(s)&&ar(`The kernel '${t}' for backend '${n}' is already registered`),Yi.set(s,e)}function S$(e){let{kernelName:t}=e;Vu.has(t)&&X().getBool("DEBUG")&&ar(`Overriding the gradient for '${t}'`),Vu.set(t,e)}function hde(e,t){let n=_g(e,t);if(!Yi.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Yi.delete(n)}function fde(e){if(!Vu.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Vu.delete(e)}function mde(e,t){Qf(e).forEach(s=>{let r=Object.assign({},s,{backendName:t});_l(r)})}function _g(e,t){return`${t}_${e}`}var w={};Ae(w,{arraysEqual:()=>wr,assert:()=>O,assertNonNegativeIntegerDimensions:()=>tg,assertNonNull:()=>va,assertShapesMatch:()=>dn,bytesFromStringArray:()=>Uw,bytesPerElement:()=>jf,checkConversionForErrors:()=>Vw,clamp:()=>Bu,computeStrides:()=>ro,createScalarValue:()=>A$,createShuffledIndices:()=>u$,decodeString:()=>fd,distSquared:()=>r$,encodeString:()=>El,fetch:()=>R$,fingerPrint64:()=>_$,flatten:()=>ta,getArrayFromDType:()=>Bw,getTypedArrayFromDType:()=>Lw,hasEncodingLoss:()=>d$,hexToLong:()=>Al,indexToLoc:()=>f$,inferDtype:()=>Ud,inferFromImplicitShape:()=>c$,isBoolean:()=>Gw,isFunction:()=>hr,isInt:()=>Xi,isNumber:()=>Hw,isPromise:()=>ng,isScalarShape:()=>a$,isString:()=>ir,isTypedArray:()=>Yt,isValidDtype:()=>Ww,locToIndex:()=>h$,makeOnesTypedArray:()=>eg,makeZerosNestedTypedArray:()=>p$,makeZerosTypedArray:()=>Gd,nearestDivisor:()=>pd,nearestLargerEven:()=>t$,now:()=>Wu,parseAxisParam:()=>Jn,randUniform:()=>s$,repeatedTry:()=>l$,rightPad:()=>Pu,shuffle:()=>zw,shuffleCombo:()=>e$,sizeFromShape:()=>pt,sizeToSquarishShape:()=>o$,squeezeShape:()=>Mw,sum:()=>n$,swap:()=>dd,tanh:()=>i$,toNestedArray:()=>Gi,toTypedArray:()=>up});var ex=ya(PT()),Gr=ex.default||ex;function Al(e){return Gr.fromString(e,!0,16)}var Xw=Al("c3a5c85c97cb3127"),Ur=Al("b492b66fbe98f273"),an=Al("9ae16a3b2f90404f");function Zf(e){return e.xor(e.shru(47))}function Yw(e,t,n){let s=e.slice(t,t+n);return Gr.fromBytes(Array.from(s),!0,!0)}function lt(e,t){return Yw(e,t,8)}function tx(e,t){return Yw(e,t,4)}function Lt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function ur(e,t,n=Al("9ddfea08eb382d69")){let s=e.xor(t).mul(n);s=s.xor(s.shru(47));let r=t.xor(s).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function C$(e,t,n,s,r,a){r=r.add(e),a=Lt(a.add(r).add(s),21);let i=r;return r=r.add(t),r=r.add(n),a=a.add(Lt(r,44)),[r.add(s),a.add(i)]}function Bc(e,t,n,s){return C$(lt(e,t),lt(e,t+8),lt(e,t+16),lt(e,t+24),n,s)}function N$(e,t=e.length){if(t>=8){let n=an.add(t*2),s=lt(e,0).add(an),r=lt(e,t-8),a=Lt(r,37).mul(n).add(s),i=Lt(s,25).add(r).mul(n);return ur(a,i,n)}if(t>=4){let n=an.add(t*2),s=tx(e,0);return ur(s.shl(3).add(t),tx(e,t-4),n)}if(t>0){let n=e[0],s=e[t>>1],r=e[t-1],a=n+(s<<8),i=t+(r<<2);return Zf(an.mul(a).xor(Xw.mul(i))).mul(an)}return an}function T$(e,t=e.length){let n=an.add(t*2),s=lt(e,0).mul(Ur),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(an);return ur(Lt(s.add(r),43).add(Lt(a,30)).add(i),s.add(Lt(r.add(an),18)).add(a),n)}function $$(e,t=e.length){let n=an.add(t*2),s=lt(e,0).mul(an),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(an),o=Lt(s.add(r),43).add(Lt(a,30)).add(i),u=ur(o,s.add(Lt(r.add(an),18)).add(a),n),l=lt(e,16).mul(n),c=lt(e,24),p=o.add(lt(e,t-32)).mul(n),d=u.add(lt(e,t-24)).mul(n);return ur(Lt(l.add(c),43).add(Lt(p,30)).add(d),l.add(Lt(c.add(s),18)).add(p),n)}function _$(e,t=e.length){let n=Gr.fromNumber(81,!0);if(t<=32)return t<=16?N$(e,t):T$(e,t);if(t<=64)return $$(e,t);let s=n,r=n.mul(Ur).add(113),a=Zf(r.mul(an).add(113)).mul(an),i=[Gr.UZERO,Gr.UZERO],o=[Gr.UZERO,Gr.UZERO];s=s.mul(an).add(lt(e,0));let u=0,l=(t-1>>6)*64,c=l+(t-1&63)-63;do s=Lt(s.add(r).add(i[0]).add(lt(e,u+8)),37).mul(Ur),r=Lt(r.add(i[1]).add(lt(e,u+48)),42).mul(Ur),s=s.xor(o[1]),r=r.add(i[0]).add(lt(e,u+40)),a=Lt(a.add(o[0]),33).mul(Ur),i=Bc(e,u,i[1].mul(Ur),s.add(o[0])),o=Bc(e,u+32,a.add(o[1]),r.add(lt(e,u+16))),[a,s]=[s,a],u+=64;while(u!==l);let p=Ur.add(a.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),s=Lt(s.add(r).add(i[0]).add(lt(e,u+8)),37).mul(p),r=Lt(r.add(i[1]).add(lt(e,u+48)),42).mul(p),s=s.xor(o[1].mul(9)),r=r.add(i[0].mul(9).add(lt(e,u+40))),a=Lt(a.add(o[0]),33).mul(p),i=Bc(e,u,i[1].mul(p),s.add(o[0])),o=Bc(e,u+32,a.add(o[1]),r.add(lt(e,u+16))),[a,s]=[s,a],ur(ur(i[0],o[0],p).add(Zf(r).mul(Xw)).add(a),ur(i[1],o[1],p).add(s),p)}function A$(e,t){return t==="string"?El(e):up([e],t)}function E$(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function up(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=ta(e)),X().getBool("DEBUG")&&Vw(e,t),E$(e,t))return e;if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool"){let n=new Uint8Array(e.length);for(let s=0;s{s=n()},a,i=Wu();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(r);else{r();for(let u of s)u.dataSync();a=Promise.resolve({kernelMs:Wu()-i})}if(X().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let u=0;u{F$(c,l.dtype,e)})}return{kernelName:e,outputs:s,inputs:t,timeMs:a.then(u=>u.kernelMs),extraInfo:a.then(u=>u.getExtraProfileInfo!=null?u.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:s,inputs:r,extraInfo:a}=e;n.forEach(i=>{Promise.all([i.data(),s,a]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],r,o[2])})})}};function F$(e,t,n){if(t!=="float32")return!1;for(let s=0;s0?f:""} `}}console.log(`%c${o} %c${i} %c${u}D ${c} %c${l} %c${p} %c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function P$(e,t,n){let s={},r={};for(let u=0;us[m.id]=!0),h=!0,r[l.id]=!0;break}if(h)break}}let a={};a[n.id]=!0;let i={};for(let u=e.length-1;u>=0;u--){let l=e[u],c=l.inputs;for(let p=0;p=0;r--){let a=t[r],i=[];if(a.outputs.forEach(u=>{let l=e[u.id];l!=null?i.push(l):i.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let o=a.gradient(i);for(let u in a.inputs){if(!(u in o))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(o)}.`);let l=n(()=>o[u]());if(l.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`);let c=a.inputs[u];if(!wr(l.shape,c.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`);if(e[c.id]==null)e[c.id]=l;else{let p=e[c.id];e[c.id]=s(p,l),p.dispose()}}}}var nx=20,Iu=3,Rf=7;function M$(e,t,n,s){let r=ro(t),a=L$(e,t,n,r),i=t.length,o=Jc(e,t,n,r,a),u=["Tensor"];return s&&(u.push(` dtype: ${n}`),u.push(` rank: ${i}`),u.push(` shape: [${t}]`),u.push(" values:")),u.push(o.map(l=>" "+l).join(` `)),u.join(` `)}function L$(e,t,n,s){let r=pt(t),a=s[s.length-1],i=new Array(a).fill(0),o=t.length,u=n==="complex64"?$u(e):e;if(o>1)for(let l=0;lnx){let g=Iu*i,b=Array.from(e.slice(0,g)),y=Array.from(e.slice((o-Iu)*i,o*i));return n==="complex64"&&(b=$u(b),y=$u(y)),["["+b.map((v,x)=>Tu(v,r[x],n)).join(", ")+", ..., "+y.map((v,x)=>Tu(v,r[o-Iu+x],n)).join(", ")+"]"]}let m=n==="complex64"?$u(e):Array.from(e);return["["+m.map((g,b)=>Tu(g,r[b],n)).join(", ")+"]"]}let l=t.slice(1),c=s.slice(1),p=s[0]*i,d=[];if(o>nx){for(let m=0;m`Length of values '${s}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||Bw(t,this.size),this.strides=ro(e)}set(e,...t){t.length===0&&(t=[0]),O(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let n=this.locToIndex(t);this.values[n]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let s of e){if(s<0||s>=this.shape[t]){let r=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(r)}t++}let n=e[e.length-1];for(let s=0;sfd(n))}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),us().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=us().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>fd(t))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();let e=await us().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(us().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Bi.print(this,e)}clone(){return this.throwIfDisposed(),Bi.clone(this)}toString(e=!1){let t=this.dataSync();return M$(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Bi.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),us().makeVariable(this,e,t,n)}};Object.defineProperty(et,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function G$(){return sg("Tensor",()=>et)}G$();var md=class extends et{constructor(e,t,n,s){super(e.shape,e.dtype,e.dataId,s);this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!wr(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);us().disposeTensor(this),this.dataId=e.dataId,us().incRef(this,null)}dispose(){us().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(md,Symbol.hasInstance,{value:e=>e instanceof et&&e.assign!=null&&e.assign instanceof Function});var _s={};Ae(_s,{assertTypesMatch:()=>nk,getTensorsInContainer:()=>Ag,isTensorInList:()=>j$,makeTypesMatch:()=>vt});var H$=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(H$||{}),Zw=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(Zw||{}),Jw=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(Jw||{}),ek=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(ek||{}),tk=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(tk||{}),q$={float32:ek,int32:Zw,bool:Jw,complex64:tk};function yn(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return q$[e][t]}function lp(e){return yn(e,"int32")}function vt(e,t){if(e.dtype===t.dtype)return[e,t];let n=yn(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function nk(e,t){O(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function j$(e,t){return t.some(n=>n.id===e.id)}function Ag(e){let t=[];return sk(e,t,new Set),t}function sk(e,t,n){if(e==null)return;if(e instanceof et){t.push(e);return}if(!K$(e))return;let s=e;for(let r in s){let a=s[r];n.has(a)||(n.add(a),sk(a,t,n))}}function K$(e){return Array.isArray(e)||typeof e=="object"}function Df(e){return e.kernelName!=null}var sx=class{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(let e in this.registeredVariables)this.registeredVariables[e].dispose()}},Jf=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new sx}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Qf(e).forEach(n=>{n.disposeFunc!=null&&n.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{let n=t.factory();if(n&&!(n instanceof tl)&&typeof n.then=="function"){let s=++this.pendingBackendInitId,r=n.then(a=>s(sthis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.startScope(n),()=>this.endScope(s),()=>(s=t(),s instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),s))}scopedRun(e,t,n){e();try{let s=n();return t(),s}catch(s){throw t(),s}}nextTensorId(){return Jf.nextTensorId++}nextVariableId(){return Jf.nextVariableId++}clone(e){let t=M.runKernel(Ma,{x:e}),n={x:e},s=a=>({x:()=>{let i="float32",o={x:a},u={dtype:i};return M.runKernel(Sa,o,u)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],s,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,!(Yf(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){let s=this.backend.numDataIds(),r=0;n.forEach(o=>{r+=o.dtype==="complex64"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=s-t-r-a;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],s=this.isTapeOn(),r=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,u=Df(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Df(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=Yf(h,this.backendName);O(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),i=()=>{let b=this.backend.numDataIds();o=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let y=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,b,y);let v=y.map(x=>{if(x.rank!=null)return x;let{dataId:k,shape:C,dtype:T}=x;return this.makeTensorFromDataId(k,C,T)});if(s){let x=this.getTensorsForGradient(h,f,v);n=this.saveTensorsForBackwardMode(x)}return v}}else{let{forwardFunc:h}=e,f=m=>{!s||(n=m.map(g=>this.keep(this.clone(g))))};i=()=>{let m=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,f));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,m,g),g}}let{inputs:l,attrs:c}=e,p=Df(e)?null:e.backwardsFunc,d;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(d=this.profiler.profileKernel(u,l,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs)}),s&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map(h=>l[h]!=null?l[h].shape:null),outputShapes:t.map(h=>h.shape),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let s=Jv(e);if(s!=null){let r=s.inputsToSave||[],a=s.outputsToSave||[],i;s.saveAllInputs?(O(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(u=>t[u])):i=r.map(u=>t[u]);let o=n.filter((u,l)=>a[l]);return i.concat(o)}return[]}makeTensor(e,t,n,s){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",s=s||this.backend;let r=e;n==="string"&&ir(e[0])&&(r=e.map(o=>El(o)));let a=s.write(r,t,n),i=new et(t,n,a,this.nextTensorId());if(this.trackTensor(i,s),n==="string"){let o=this.state.tensorInfo.get(a),u=Uw(r);this.state.numBytes+=u-o.bytes,o.bytes=u}return i}makeTensorFromDataId(e,t,n,s){n=n||"float32";let r=new et(t,n,e,this.nextTensorId());return this.trackTensor(r,s),r}makeVariable(e,t=!0,n,s){n=n||this.nextVariableId().toString(),s!=null&&s!==e.dtype&&(e=e.cast(s));let r=new md(e,t,n,this.nextTensorId());if(this.state.registeredVariables[r.name]!=null)throw new Error(`Variable with name ${r.name} was already registered`);return this.state.registeredVariables[r.name]=r,this.incRef(r,this.backend),r}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let n=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(n=e.size*jf(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof md||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;let t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){let n=e.size*jf(e.dtype);this.state.numBytes-=n}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(let e in this.state.registeredVariables){let t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]}memory(){let e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;let t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,s,r,a){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},o=Jv(e);o!=null&&(s=o.gradFunc),s!=null&&(i.gradient=u=>(u=u.map((l,c)=>{if(l==null){let p=n[c],d=Gd(p.size,p.dtype);return this.makeTensor(d,p.shape,p.dtype)}return l}),s(u.length>1?u:u[0],r,a))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=Ag(e),n=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===s.id&&this.track(r)})}gradients(e,t,n,s=!1){if(O(t.length>0,()=>"gradients() received an empty list of xs."),n!=null&&n.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);let r=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));O(r instanceof et,()=>"The result y returned by f() must be a tensor.");let a=P$(this.state.activeTape,t,r);if(!s&&a.length===0&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{let i={};i[r.id]=n==null?X$(r.shape):n,z$(i,a,u=>this.tidy(u),Y$);let o=t.map(u=>i[u.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(u=>{for(let l of u.saved)l.dispose()}),this.state.activeTape=null),{value:r,grads:o}})}customGrad(e){return O(hr(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{O(t.every(i=>i instanceof et),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,s={};t.forEach((i,o)=>{s[o]=i});let r=(i,o)=>(n=e(...t,o),O(n.value instanceof et,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),O(hr(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),a=(i,o)=>{let u=n.gradFunc(i,o),l=Array.isArray(u)?u:[u];O(l.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),O(l.every(p=>p instanceof et),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let c={};return l.forEach((p,d)=>{c[d]=()=>p}),c};return this.runKernelFunc({forwardFunc:r,backwardsFunc:a,inputs:s})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){let t=Wu(),n=await this.backend.time(e);return n.wallMs=Wu()-t,n}track(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new sx;for(let e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}},Eg=Jf;Eg.nextTensorId=0;Eg.nextVariableId=0;function X$(e){let t=eg(pt(e),"float32");return M.makeTensor(t,e,"float32")}function rk(){let e=Kw();if(e._tfengine==null){let t=new m$(e);e._tfengine=new Eg(t)}return v$(e._tfengine.ENV),V$(()=>e._tfengine),e._tfengine}var M=rk();function Y$(e,t){let n={a:e,b:t};return M.runKernel(kr,n)}var cp={};Ae(cp,{isBrowser:()=>ak,isMobile:()=>J$,mockIsMobile:()=>Z$});function Q$(){return typeof navigator!="undefined"&&navigator!=null}var em;function Z$(e){em=e}function J$(e){if(em!==void 0)return em;if(e||Q$()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||(typeof window!="undefined"?window.opera:"");if(!t){let n=e;return n.userAgentData&&n.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function ak(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var gs=X();gs.registerFlag("DEBUG",()=>!1,e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")});gs.registerFlag("IS_BROWSER",()=>ak());gs.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");gs.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));gs.registerFlag("PROD",()=>!1);gs.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>gs.getBool("DEBUG"));gs.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);gs.registerFlag("IS_TEST",()=>!1);gs.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);gs.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);function Rs(e,t){let n=e;if(Yt(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let s=[];for(;Array.isArray(n)||Yt(n)&&t!=="string";)s.push(n.length),n=n[0];return Array.isArray(e)&&X().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&ik(e,s,[]),s}function ik(e,t,n){if(n=n||[],!Array.isArray(e)&&!Yt(e)){O(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}O(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),O(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let s=t.slice(1);for(let r=0;r=0&&(r=s),rx(s,r,t,n),e==null||!Yt(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let u=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${u}'`)}let a=Rs(e,r);!Yt(e)&&!Array.isArray(e)&&(e=[e]);let o=r!=="string"?up(e,r):ta(e,[],!0);return M.makeTensor(o,a,r)}function Uu(e,t,n,s="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,i)=>_(a,`${t}[${i}]`,n,s))}var e_="__op";function L(e){let t=Object.keys(e);if(t.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0],s=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+e_;let r=(...a)=>{M.startScope(n);try{let i=s(...a);return ng(i)&&console.error("Cannot return a Promise inside of tidy."),M.endScope(i),i}catch(i){throw M.endScope(null),i}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}function t_(e,t){let n=_(e,"real","complex"),s=_(t,"imag","complex");dn(n.shape,s.shape,`real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`);let r={real:n,imag:s};return M.runKernel(qd,r)}var aa=L({complex_:t_});function Cr(e,t,n,s){if(s==null&&(s=Ud(e)),s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Yt(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(t!=null){tg(t);let r=pt(t),a=pt(n);O(r===a,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!Yt(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=s!=="string"?up(e,s):ta(e,[],!0),M.makeTensor(e,t,s)}function hs(e,t,n){let s=Rs(e,n);return Cr(e,t,s,n)}var tm={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},gd=4;async function n_(e,t){let n=[],s=[],r=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let d=await u.bytes(),h=d.reduce((g,b)=>g+b.length,0)+gd*d.length,f=new Uint8Array(h),m=0;for(let g=0;g{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let s=new Uint8Array(t),r=0;return n.forEach(a=>{s.set(new Uint8Array(a.buffer),r),r+=a.byteLength}),s.buffer}var Rg=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function ax(e){return Rg?Buffer.byteLength(e):new Blob([e]).size}function r_(e){if(Rg)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let s=0,r=t.length;s{t+=r.byteLength});let n=new Uint8Array(t),s=0;return e.forEach(r=>{n.set(new Uint8Array(r),s),s+=r.byteLength}),n.buffer}function ix(e){let t="/";for(e=e.trim();e.endsWith(t);)e=e.slice(0,e.length-1);let n=e.split(t);return n[n.length-1]}function uk(e,t){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),e.trainingConfig!=null&&(n.trainingConfig=e.trainingConfig),n}async function Fg(e,t){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(e.trainingConfig!=null&&(n.trainingConfig=e.trainingConfig),e.weightsManifest!=null){let[s,r]=await t(e.weightsManifest);n.weightSpecs=s,n.weightData=r}return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),n}function Rl(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:e.modelTopology==null?0:ax(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:ax(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function i_(){let e=n=>{let s=n<<13,r=0;for(;(s&8388608)===0;)r-=8388608,s<<=1;return s&=-8388609,r+=947912704,s|r},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let n=1024;n<2048;n++)t[n]=939524096+(n-1024<<13);return t}function o_(){let e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}function u_(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function l_(){let e=i_(),t=o_(),n=u_();return s=>{let r=new ArrayBuffer(4*s.length),a=new Uint32Array(r);for(let i=0;i>10]+(o&1023)]+t[o>>10];a[i]=u}return new Float32Array(r)}}var xt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return xt.instance==null&&(xt.instance=new xt),xt.instance}static registerSaveRouter(e){xt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){xt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return xt.getHandlers(e,"save")}static getLoadHandlers(e,t){return xt.getHandlers(e,"load",t)}static getHandlers(e,t,n){let s=[];return(t==="load"?xt.getInstance().loadRouters:xt.getInstance().saveRouters).forEach(a=>{let i=a(e,n);i!==null&&s.push(i)}),s}},c_=e=>xt.registerSaveRouter(e),d_=e=>xt.registerLoadRouter(e),p_=e=>xt.getSaveHandlers(e),h_=(e,t)=>xt.getLoadHandlers(e,t),nm="tensorflowjs",sm=1,Kr="models_store",or="model_info_store";function lk(){if(!X().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");let e=typeof window=="undefined"?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(t==null)throw new Error("The current browser does not appear to support IndexedDB.");return t}function rm(e){let t=e.result;t.createObjectStore(Kr,{keyPath:"modelPath"}),t.createObjectStore(or,{keyPath:"modelPath"})}var ia=class{constructor(e){if(this.indexedDB=lk(),e==null||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((n,s)=>{let r=this.indexedDB.open(nm,sm);r.onupgradeneeded=()=>rm(r),r.onsuccess=()=>{let a=r.result;if(t==null){let i=a.transaction(Kr,"readonly"),u=i.objectStore(Kr).get(this.modelPath);u.onsuccess=()=>{if(u.result==null)return a.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(u.result.modelArtifacts)},u.onerror=l=>(a.close(),s(u.error)),i.oncomplete=()=>a.close()}else{let i=Rl(t),o=a.transaction(or,"readwrite"),u=o.objectStore(or),l=u.put({modelPath:this.modelPath,modelArtifactsInfo:i}),c;l.onsuccess=()=>{c=a.transaction(Kr,"readwrite");let d=c.objectStore(Kr).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=h=>{u=o.objectStore(or);let f=u.delete(this.modelPath);f.onsuccess=()=>(a.close(),s(d.error)),f.onerror=m=>(a.close(),s(d.error))}},l.onerror=p=>(a.close(),s(l.error)),o.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},r.onerror=a=>s(r.error)})}};ia.URL_SCHEME="indexeddb://";var ck=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ia.URL_SCHEME)?f_(e.slice(ia.URL_SCHEME.length)):null;xt.registerSaveRouter(ck);xt.registerLoadRouter(ck);function f_(e){return new ia(e)}function m_(e){return e.startsWith(ia.URL_SCHEME)?e.slice(ia.URL_SCHEME.length):e}var g_=class{constructor(){this.indexedDB=lk()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(nm,sm);n.onupgradeneeded=()=>rm(n),n.onsuccess=()=>{let s=n.result,r=s.transaction(or,"readonly"),i=r.objectStore(or).getAll();i.onsuccess=()=>{let o={};for(let u of i.result)o[u.modelPath]=u.modelArtifactsInfo;e(o)},i.onerror=o=>(s.close(),t(i.error)),r.oncomplete=()=>s.close()},n.onerror=s=>t(n.error)})}async removeModel(e){return e=m_(e),new Promise((t,n)=>{let s=this.indexedDB.open(nm,sm);s.onupgradeneeded=()=>rm(s),s.onsuccess=()=>{let r=s.result,a=r.transaction(or,"readwrite"),i=a.objectStore(or),o=i.get(e),u;o.onsuccess=()=>{if(o.result==null)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let l=i.delete(e),c=()=>{u=r.transaction(Kr,"readwrite");let d=u.objectStore(Kr).delete(e);d.onsuccess=()=>t(o.result.modelArtifactsInfo),d.onerror=h=>n(o.error)};l.onsuccess=c,l.onerror=p=>(c(),r.close(),n(o.error))}},o.onerror=l=>(r.close(),n(o.error)),a.oncomplete=()=>{u==null?r.close():u.oncomplete=()=>r.close()}},s.onerror=r=>n(s.error)})}},Gs="/",Vi="tensorflowjs_models",dk="info",b_="model_topology",y_="weight_specs",v_="weight_data",x_="model_metadata";function pk(e){return{info:[Vi,e,dk].join(Gs),topology:[Vi,e,b_].join(Gs),weightSpecs:[Vi,e,y_].join(Gs),weightData:[Vi,e,v_].join(Gs),modelMetadata:[Vi,e,x_].join(Gs)}}function hk(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function w_(e){let t=e.split(Gs);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Gs)}function k_(e){return e.startsWith(oa.URL_SCHEME)?e.slice(oa.URL_SCHEME.length):e}var oa=class{constructor(e){if(!X().getBool("IS_BROWSER")||typeof window=="undefined"||typeof window.localStorage=="undefined")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=pk(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{let t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),s=Rl(e);try{this.LS.setItem(this.keys.info,JSON.stringify(s)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,r_(e.weightData));let r={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(r)),{modelArtifactsInfo:s}}catch(r){throw hk(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");let t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(n==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;let s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;let r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){let i=JSON.parse(r);t.format=i.format,t.generatedBy=i.generatedBy,t.convertedBy=i.convertedBy,i.signature!=null&&(t.signature=i.signature),i.userDefinedMetadata!=null&&(t.userDefinedMetadata=i.userDefinedMetadata),i.modelInitializer!=null&&(t.modelInitializer=i.modelInitializer),i.trainingConfig!=null&&(t.trainingConfig=i.trainingConfig)}let a=this.LS.getItem(this.keys.weightData);if(a==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=a_(a),t}};oa.URL_SCHEME="localstorage://";var fk=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(oa.URL_SCHEME)?I_(e.slice(oa.URL_SCHEME.length)):null;xt.registerSaveRouter(fk);xt.registerLoadRouter(fk);function I_(e){return new oa(e)}var S_=class{constructor(){O(X().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),O(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Vi+Gs,n=Gs+dk;for(let s=0;s"scheme must not be undefined or null."),e.endsWith(Hi)&&(e=e.slice(0,e.indexOf(Hi))),O(e.length>0,()=>"scheme must not be an empty string.");let n=Pn.getInstance();O(n.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),n.managers[e]=t}static getManager(e){let t=this.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}};function ed(e){if(e.indexOf(Hi)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Pn.getSchemes().join(",")}`);return{scheme:e.split(Hi)[0],path:e.split(Hi)[1]}}async function mk(e,t,n=!1){O(e!==t,()=>`Old path and new path are the same: '${e}'`);let s=xt.getLoadHandlers(e);O(s.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),O(s.length<2,()=>`Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`);let r=s[0],a=xt.getSaveHandlers(t);O(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),O(a.length<2,()=>`Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`);let i=a[0],o=ed(e).scheme,u=ed(e).path,l=o===ed(e).scheme,c=await r.load();n&&l&&await Pn.getManager(o).removeModel(u);let p=await i.save(c);return n&&!l&&await Pn.getManager(o).removeModel(u),p.modelArtifactsInfo}async function C_(){let e=Pn.getSchemes(),t={};for(let n of e){let s=await Pn.getManager(n).listModels();for(let r in s){let a=n+Hi+r;t[a]=s[r]}}return t}async function N_(e){let t=ed(e);return Pn.getManager(t.scheme).removeModel(t.path)}async function T_(e,t){return mk(e,t,!1)}async function $_(e,t){return mk(e,t,!0)}var __=class{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}};if(X().get("IS_BROWSER")){X().setPlatform("browser",new __);try{Pn.registerManager(oa.URL_SCHEME,new S_)}catch(e){}try{Pn.registerManager(ia.URL_SCHEME,new g_)}catch(e){}}var A_={importFetch:()=>zT()},Ff,E_=class{constructor(){this.util=MT(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return X().global.fetch!=null?X().global.fetch(e,t):(Ff==null&&(Ff=A_.importFetch()),Ff(e,t))}now(){let e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return e.length===0?"":new this.util.TextDecoder(t).decode(e)}};X().get("IS_NODE")&&!X().get("IS_BROWSER")&&X().setPlatform("node",new E_);function De(e,t="float32",n){return t=t||"float32",tg(e),new Vt(e,t,n)}function R_(e,t){let n=_(e,"x","cast");if(!Ww(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t==="string"&&n.dtype!=="string"||t!=="string"&&n.dtype==="string")throw new Error("Only strings can be casted to strings");let s={x:n},r={dtype:t};return M.runKernel(Sa,s,r)}var ce=L({cast_:R_});function D_(e){let n={x:_(e,"x","clone","string_or_numeric")};return M.runKernel(Ma,n)}var lr=L({clone_:D_});function F_(e,t=!1){console.log(e.toString(t))}rk();var O_={buffer:De,cast:ce,clone:lr,print:F_};W$(O_);var _n={};Ae(_n,{browserFiles:()=>W_,browserHTTPRequest:()=>j_,concatenateArrayBuffers:()=>Dg,copyModel:()=>T_,decodeWeights:()=>ok,encodeWeights:()=>n_,fromMemory:()=>X_,getLoadHandlers:()=>h_,getModelArtifactsForJSON:()=>Fg,getModelArtifactsInfoForJSON:()=>Rl,getSaveHandlers:()=>p_,http:()=>Pg,isHTTPScheme:()=>im,listModels:()=>C_,loadWeights:()=>U_,moveModel:()=>$_,registerLoadRouter:()=>d_,registerSaveRouter:()=>c_,removeModel:()=>N_,weightsLoaderFactory:()=>bk,withSaveHandler:()=>Y_});var P_="model",z_=".json",M_=".weights.bin";function ox(e){return new Promise(t=>setTimeout(t)).then(e)}var am=class{constructor(e){if(!X().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(am.URL_SCHEME)&&(e=e.slice(am.URL_SCHEME.length)),(e==null||e.length===0)&&(e=P_),this.modelJsonFileName=e+z_,this.weightDataFileName=e+M_}async save(e){if(typeof document=="undefined")throw new Error("Browser downloads are not supported in this environment since `document` is not present");let t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{let n=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],s=uk(e,n),r=window.URL.createObjectURL(new Blob([JSON.stringify(s)],{type:"application/json"})),a=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await ox(()=>a.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){let i=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;i.download=this.weightDataFileName,i.href=t,await ox(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Rl(e)}}}},bd=am;bd.URL_SCHEME="downloads://";var L_=class{constructor(e){if(e==null||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{let n=new FileReader;n.onload=s=>{let r=JSON.parse(s.target.result),a=r.modelTopology;if(a==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(r.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:a});return}let o=Fg(r,u=>this.loadWeights(u));e(o)},n.onerror=s=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)})}loadWeights(e){let t=[],n=[];for(let a of e)t.push(...a.weights),n.push(...a.paths);let s=this.checkManifestAndWeightFiles(e),r=n.map(a=>this.loadWeightsFile(a,s[a]));return Promise.all(r).then(a=>[t,Dg(a)])}loadWeightsFile(e,t){return new Promise((n,s)=>{let r=new FileReader;r.onload=a=>{let i=a.target.result;n(i)},r.onerror=a=>s(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>ix(r.name)),s={};for(let r of e)r.paths.forEach(a=>{let i=ix(a);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),n.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);s[a]=this.weightsFiles[n.indexOf(i)]});if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return s}},B_=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(bd.URL_SCHEME)?V_(e.slice(bd.URL_SCHEME.length)):null;xt.registerSaveRouter(B_);function V_(e="model"){return new bd(e)}function W_(e){return new L_(e)}function ux(e,t,n,s){i(e),n=n==null?0:n,s=s==null?1:s,o(n,s);let r=0,a=u=>(u.then(l=>{let c=n+ ++r/e.length*(s-n);return t(c),l}),u);function i(u){O(u!=null&&Array.isArray(u)&&u.length>0,()=>"promises must be a none empty array")}function o(u,l){O(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${u}`),O(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),O(l>=u,()=>`startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`)}return Promise.all(e.map(a))}async function gk(e,t){t==null&&(t={});let n=t.fetchFunc==null?X().platform.fetch:t.fetchFunc,s=e.map(p=>n(p,t.requestInit,{isBinary:!0})),r=0,a=.5,o=(t.onProgress==null?await Promise.all(s):await ux(s,t.onProgress,r,a)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(o):await ux(o,t.onProgress,u,l)}async function U_(e,t="",n,s){return bk(i=>gk(i,{requestInit:s}))(e,t,n)}function bk(e){return async(t,n="",s)=>{let r=t.map(()=>!1),a={},i=s!=null?s.map(()=>!1):[],o=[];if(t.forEach((h,f)=>{let m=0;h.weights.forEach(g=>{let b="quantization"in g?g.quantization.dtype:g.dtype,y=tm[b]*pt(g.shape),v=()=>{r[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:y})};s!=null?s.forEach((x,k)=>{x===g.name&&(v(),i[k]=!0)}):v(),o.push(g.name),m+=y})}),!i.every(h=>h)){let h=s.filter((f,m)=>!i[m]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`)}let u=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),l=[];u.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;l.push(m)})});let c=await e(l),p={},d=0;return u.forEach(h=>{let f=t[h].paths.length,m=0;for(let x=0;x{let k=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),C=ok(k,[x.manifestEntry]);for(let T in C)p[T]=C[T]}),d+=f}),p}}var G_="application/octet-stream",H_="application/json",Og=class{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?(O(typeof t.fetchFunc=="function",()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=X().platform.fetch,O(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&O(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");let t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;let n=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],s=uk(e,n);t.body.append("model.json",new Blob([JSON.stringify(s)],{type:H_}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:G_}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Rl(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){let e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(r){let a=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?a+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":a+=" Please make sure the server is serving valid JSON for this request.",new Error(a)}let n=t.modelTopology,s=t.weightsManifest;if(n==null&&s==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Fg(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,s]=q_(t),r=this.weightPathPrefix||n,a=[];for(let l of e)a.push(...l.weights);let i=[],o=[];for(let l of e)for(let c of l.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(c)):i.push(r+c+s);this.weightUrlConverter&&i.push(...await Promise.all(o));let u=await gk(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,Dg(u)]}};Og.URL_SCHEME_REGEX=/^https?:\/\//;function q_(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),s=e.substring(0,t),r=n>t?e.substring(n):"";return[s+"/",r]}function im(e){return e.match(Og.URL_SCHEME_REGEX)!=null}var yk=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(s=>im(s)):n=im(e),n)return Pg(e,t)}return null};xt.registerSaveRouter(yk);xt.registerLoadRouter(yk);function Pg(e,t){return new Og(e,t)}function j_(e,t){return Pg(e,t)}var Of=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},K_=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function X_(e,t,n,s){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new Of(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Of({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Of({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:s}))}function Y_(e){return new K_(e)}var Q_={};Ae(Q_,{confusionMatrix:()=>nA});function Z_(e,t,n=!1,s=!1){let r=_(e,"a","matMul"),a=_(t,"b","matMul");[r,a]=vt(r,a);let i={a:r,b:a},o={transposeA:n,transposeB:s};return M.runKernel(Ia,i,o)}var We=L({matMul_:Z_});function J_(e,t,n=1,s=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:_(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:s};return M.runKernel(To,a,i)}var yd=L({oneHot_:J_});function eA(e,t){let n=_(e,"x","transpose");if(t==null&&(t=n.shape.map((a,i)=>i).reverse()),O(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(a=>{O(a>=0&&a`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let s={x:n},r={perm:t};return M.runKernel(ci,s,r)}var qe=L({transpose_:eA});function tA(e,t,n){let s=_(e,"labels","confusionMatrix"),r=_(t,"predictions","confusionMatrix");O(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),O(s.rank===1,()=>`Expected the rank of labels to be 1, but got ${s.rank}`),O(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),O(s.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`),O(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=yd(ce(s,"int32"),n),i=yd(ce(r,"int32"),n),o=qe(a),u=We(o,i);return ce(u,"int32")}var nA=L({confusionMatrix_:tA}),qo={};Ae(qo,{assertAndGetBroadcastShape:()=>it,getBroadcastDims:()=>vk,getReductionAxes:()=>_t});function vk(e,t){let n=e.length,s=[];for(let r=0;r1&&i===1&&s.unshift(a)}return s}function _t(e,t){let n=[];for(let s=0;s1)&&n.unshift(a)}return n}function it(e,t){let n=[],s=Math.max(e.length,t.length);for(let r=0;rcA,fromPixelsAsync:()=>uA,toPixels:()=>lA});function sA(e,t,n){if(va(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let s=Rs(e,n);if(s.length!==3&&s.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Cr(e,t,s,n)}var Br;function wk(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(e==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,s=!1,r=!1,a=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)s=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)r=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)a=!0;else if(e.getContext!=null)i=!0;else if(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)o=!0;else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);if(r&&r&&e.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the