/* Human homepage: author: ' */ var Human=(()=>{var Kc=Object.defineProperty;var qE=Object.getOwnPropertyDescriptor;var XE=Object.getOwnPropertyNames;var KE=Object.prototype.hasOwnProperty;var ZE=(e,t,r)=>t in e?Kc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ks=(e,t)=>{for(var r in t)Kc(e,r,{get:t[r],enumerable:!0})},YE=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of XE(t))!KE.call(e,a)&&a!==r&&Kc(e,a,{get:()=>t[a],enumerable:!(n=qE(t,a))||n.enumerable});return e};var JE=e=>YE(Kc({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>(ZE(e,typeof t!="symbol"?t+"":t,r),r),z3=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var xp=(e,t,r)=>(z3(e,t,"read from private field"),r?r.call(e):t.get(e)),bp=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},vp=(e,t,r,n)=>(z3(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var Oxe={};ks(Oxe,{Human:()=>f3,default:()=>f3,defaults:()=>Is,draw:()=>o3,env:()=>he,match:()=>c3,models:()=>w1});function se(...e){let t=new Date,r=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(r,"Human:",...e)}function O3(e,t){let r=e.endsWith("/")?"":"/",a=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${r}${t}`;if(!a.toLocaleLowerCase().includes(".json"))throw new Error(`modelpath error: expecting json file: ${a}`);return a}var oe=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function ag(e,t,r="config",n=[]){for(let a of Object.keys(t))if(typeof t[a]=="object")ag(e[a],t[a],a,n);else{let s=e&&typeof e[a]!="undefined";s||n.push({reason:"unknown property",where:`${r}.${a} = ${t[a]}`});let i=e&&typeof e[a]==typeof t[a];s&&!i&&n.push({reason:"property type mismatch",where:`${r}.${a} = ${t[a]}`,expected:typeof e[a]})}return t.debug&&r==="config"&&n.length>0&&se("invalid configuration",n),n}function Gt(...e){let t=r=>r&&typeof r=="object";return e.reduce((r,n)=>(Object.keys(n||{}).forEach(a=>{let s=r[a],i=n[a];Array.isArray(s)&&Array.isArray(i)?r[a]=s.concat(...i):t(s)&&t(i)?r[a]=Gt(s,i):r[a]=i}),r),{})}var Is={backend:"",modelBasePath:"",cacheModels:!0,wasmPath:"",wasmPlatformFetch:!1,debug:!0,async:!0,warmup:"full",cacheSensitivity:.7,skipAllowed:!1,deallocate:!1,filter:{enabled:!0,equalization:!1,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:1,skipFrames:99,skipTime:2500,minConfidence:.2,iouThreshold:.1,mask:!1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json",keepInvalid:!1},attention:{enabled:!1,modelPath:"facemesh-attention.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:99,skipTime:1500,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:99,skipTime:3e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"antispoof.json"},liveness:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"liveness.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:200},hand:{enabled:!0,rotation:!0,skipFrames:99,skipTime:1e3,minConfidence:.5,iouThreshold:.2,maxDetected:-1,landmarks:!0,detector:{modelPath:"handtrack.json"},skeleton:{modelPath:"handlandmark-full.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:99,skipTime:2e3},segmentation:{enabled:!1,modelPath:"selfie.json",blur:8}};var Ue={};ks(Ue,{Abs:()=>jo,Acos:()=>Uu,Acosh:()=>Gu,AdadeltaOptimizer:()=>Jf,AdagradOptimizer:()=>Qf,AdamOptimizer:()=>em,AdamaxOptimizer:()=>tm,Add:()=>es,AddN:()=>Ys,All:()=>ju,Any:()=>Hu,ArgMax:()=>Js,ArgMin:()=>qu,Asin:()=>Xu,Asinh:()=>Ku,Atan:()=>Zu,Atan2:()=>Ju,Atanh:()=>Yu,AvgPool:()=>Qs,AvgPool3D:()=>th,AvgPool3DGrad:()=>af,AvgPoolGrad:()=>nf,BackendWasm:()=>yC,BatchMatMul:()=>ei,BatchToSpaceND:()=>Ho,Bincount:()=>sf,BroadcastArgs:()=>of,BroadcastTo:()=>Lv,Callback:()=>Ak,CallbackList:()=>A6,Cast:()=>ti,Ceil:()=>ri,ClipByValue:()=>ts,Complex:()=>rh,ComplexAbs:()=>nh,Concat:()=>qo,Conv2D:()=>ni,Conv2DBackpropFilter:()=>lf,Conv2DBackpropInput:()=>ai,Conv3D:()=>ah,Conv3DBackpropFilterV2:()=>uf,Conv3DBackpropInputV2:()=>df,Cos:()=>si,Cosh:()=>ii,CropAndResize:()=>Ko,Cumprod:()=>Xo,Cumsum:()=>oi,CustomCallback:()=>b6,DataStorage:()=>eh,DenseBincount:()=>pf,DepthToSpace:()=>Zo,DepthwiseConv2dNative:()=>li,DepthwiseConv2dNativeBackpropFilter:()=>hf,DepthwiseConv2dNativeBackpropInput:()=>cf,Diag:()=>ff,Dilation2D:()=>sh,Dilation2DBackpropFilter:()=>I0,Dilation2DBackpropInput:()=>k0,ENV:()=>ba,EarlyStopping:()=>xk,Einsum:()=>ih,Elu:()=>di,EluGrad:()=>mf,Environment:()=>Ov,Equal:()=>Yo,Erf:()=>Qu,Exp:()=>pi,ExpandDims:()=>Jo,Expm1:()=>Qo,FFT:()=>gf,Fill:()=>ed,FlipLeftRight:()=>el,Floor:()=>hi,FloorDiv:()=>ci,FromPixels:()=>Vp,FusedBatchNorm:()=>fi,FusedConv2D:()=>Os,FusedDepthwiseConv2D:()=>Ds,GPGPUContext:()=>Iu,GatherNd:()=>rl,GatherV2:()=>tl,GraphModel:()=>Wh,Greater:()=>nl,GreaterEqual:()=>mi,History:()=>x6,IFFT:()=>yf,Identity:()=>gi,Imag:()=>oh,InputSpec:()=>Zt,IsFinite:()=>td,IsInf:()=>rd,IsNan:()=>nd,KernelBackend:()=>Wu,LRN:()=>uh,LRNGrad:()=>xf,LayerVariable:()=>u6,LayersModel:()=>Za,LeakyRelu:()=>yi,Less:()=>al,LessEqual:()=>sl,LinSpace:()=>Af,Log:()=>Ai,Log1p:()=>ad,LogSoftmax:()=>Bv,LogicalAnd:()=>il,LogicalNot:()=>sd,LogicalOr:()=>lh,LowerBound:()=>UR,MathBackendCPU:()=>n5,MathBackendWebGL:()=>jh,Max:()=>xi,MaxPool:()=>vi,MaxPool3D:()=>dh,MaxPool3DGrad:()=>vf,MaxPoolGrad:()=>bf,MaxPoolWithArgmax:()=>wf,Maximum:()=>bi,Mean:()=>wi,Min:()=>ki,Minimum:()=>Ii,MirrorPad:()=>Si,Mod:()=>id,MomentumOptimizer:()=>rm,Multinomial:()=>kf,Multiply:()=>Ci,Neg:()=>ol,NonMaxSuppressionV3:()=>ul,NonMaxSuppressionV4:()=>od,NonMaxSuppressionV5:()=>dl,NotEqual:()=>ll,OP_SCOPE_SUFFIX:()=>t7,OneHot:()=>hl,OnesLike:()=>pl,Optimizer:()=>ss,OptimizerConstructors:()=>Cs,Pack:()=>cl,PadV2:()=>Ti,Pool:()=>GR,Pow:()=>Ni,Prelu:()=>Ei,Prod:()=>Ri,RMSPropOptimizer:()=>nm,RNN:()=>is,Range:()=>ld,Rank:()=>jv,Real:()=>ph,RealDiv:()=>ui,Reciprocal:()=>ud,Reduction:()=>qw,Relu:()=>$i,Relu6:()=>Fi,Reshape:()=>fl,ResizeBilinear:()=>Mi,ResizeBilinearGrad:()=>Sf,ResizeNearestNeighbor:()=>dd,ResizeNearestNeighborGrad:()=>If,Reverse:()=>ml,RotateWithOffset:()=>El,Round:()=>gl,Rsqrt:()=>Pi,SGDOptimizer:()=>$h,ScatterNd:()=>yl,SearchSorted:()=>Cf,Select:()=>Al,Selu:()=>pd,Sequential:()=>ym,Sigmoid:()=>zi,Sign:()=>hd,Sin:()=>_i,Sinh:()=>bl,Slice:()=>xl,Softmax:()=>Li,Softplus:()=>cd,SpaceToBatchND:()=>vl,SparseFillEmptyRows:()=>hh,SparseReshape:()=>fd,SparseSegmentMean:()=>ch,SparseSegmentSum:()=>fh,SparseToDense:()=>mh,SplitV:()=>wl,Sqrt:()=>Oi,Square:()=>md,SquaredDifference:()=>Bi,Step:()=>Ui,StridedSlice:()=>kl,StringNGrams:()=>gh,StringSplit:()=>Tf,StringToHashBucketFast:()=>Nf,Sub:()=>Wi,Sum:()=>Di,SymbolicTensor:()=>pa,Tan:()=>Il,Tanh:()=>Vi,Tensor:()=>nt,TensorBuffer:()=>or,Tile:()=>rs,TopK:()=>Sl,Transform:()=>Cl,Transpose:()=>$a,Unique:()=>Ef,Unpack:()=>Tl,UnsortedSegmentSum:()=>yh,UpperBound:()=>jR,Variable:()=>jp,ZerosLike:()=>Nl,_FusedMatMul:()=>zs,abs:()=>sr,acos:()=>z7,acosh:()=>O7,add:()=>le,addN:()=>$f,all:()=>Uy,any:()=>R0,argMax:()=>Rn,argMin:()=>D7,asin:()=>L7,asinh:()=>B7,atan:()=>W7,atan2:()=>V7,atanh:()=>U7,avgPool:()=>Mf,avgPool3d:()=>jy,backend:()=>On,backend_util:()=>T,basicLSTMCell:()=>zF,batchNorm:()=>Eu,batchNorm2d:()=>q7,batchNorm3d:()=>X7,batchNorm4d:()=>K7,batchToSpaceND:()=>Ff,bincount:()=>Hy,booleanMaskAsync:()=>Kz,broadcastArgs:()=>Z7,broadcastTo:()=>Op,broadcast_util:()=>$l,browser:()=>Dn,buffer:()=>Le,callbacks:()=>Cj,cast:()=>me,ceil:()=>Y7,clipByValue:()=>cn,clone:()=>Wr,complex:()=>Ya,concat:()=>St,concat1d:()=>J7,concat2d:()=>yd,concat3d:()=>Q7,concat4d:()=>ew,constraints:()=>f6,conv1d:()=>qy,conv2d:()=>Bs,conv2dTranspose:()=>Ky,conv3d:()=>Zy,conv3dTranspose:()=>rw,copyRegisteredKernels:()=>KR,cos:()=>Pf,cosh:()=>Yy,cosineWindow:()=>vA,cumprod:()=>M0,cumsum:()=>Jy,customGrad:()=>_a,data:()=>Gk,denseBincount:()=>nw,deprecationWarn:()=>Fy,depthToSpace:()=>aw,depthwiseConv2d:()=>Ch,deregisterOp:()=>Ej,device_util:()=>vh,diag:()=>cP,dilation2d:()=>sw,disableDeprecationWarnings:()=>kM,dispose:()=>te,disposeVariables:()=>IM,div:()=>pe,divNoNan:()=>iw,dot:()=>bP,dropout:()=>Dw,einsum:()=>ow,elu:()=>Th,enableDebugMode:()=>wM,enableProdMode:()=>My,enclosingPowerOfTwo:()=>Lw,engine:()=>Xt,env:()=>Z,equal:()=>$n,erf:()=>lw,euclideanNorm:()=>cw,exp:()=>Mn,expandDims:()=>Kt,expm1:()=>fw,eye:()=>tA,fft:()=>jf,fill:()=>Ad,findBackend:()=>_y,findBackendFactory:()=>NM,floor:()=>Nh,floorDiv:()=>Ih,forceHalfFloat:()=>p9,fused:()=>Us,gather:()=>Ru,gatherND:()=>Ow,gather_util:()=>zy,getBackend:()=>Gr,getGradient:()=>bg,getKernel:()=>S0,getKernelsForBackend:()=>Fa,getThreadsCount:()=>Vye,gpgpu_util:()=>VI,grad:()=>e_,grads:()=>t_,greater:()=>mn,greaterEqual:()=>Ml,ifft:()=>Xp,imag:()=>kh,image:()=>Ie,inTopKAsync:()=>sO,initializers:()=>m6,input:()=>P6,io:()=>Cr,irfft:()=>yA,isFinite:()=>GP,isInf:()=>HP,isNaN:()=>mw,keep:()=>gr,kernel_impls:()=>Kn,layers:()=>g6,leakyRelu:()=>zf,less:()=>rA,lessEqual:()=>Fl,linalg:()=>Xw,linspace:()=>gw,loadGraphModel:()=>MH,loadGraphModelSync:()=>FH,loadLayersModel:()=>OU,localResponseNormalization:()=>yw,log:()=>Fn,log1p:()=>Of,logSigmoid:()=>i_,logSoftmax:()=>nA,logSumExp:()=>xw,logicalAnd:()=>ga,logicalNot:()=>Lf,logicalOr:()=>aA,logicalXor:()=>f_,losses:()=>UD,lowerBound:()=>bw,matMul:()=>Ze,math:()=>y7,max:()=>Ar,maxPool:()=>Bf,maxPool3d:()=>iA,maxPoolWithArgmax:()=>vw,maximum:()=>ns,mean:()=>Vt,memory:()=>E0,meshgrid:()=>v_,metrics:()=>mk,min:()=>Ws,minimum:()=>Eh,mirrorPad:()=>ww,mod:()=>bd,model:()=>_U,models:()=>gk,moments:()=>Wf,movingAverage:()=>Yz,mul:()=>L,multiRNNCell:()=>T_,multinomial:()=>kw,neg:()=>Mt,nextFrame:()=>IA,norm:()=>_f,notEqual:()=>$u,oneHot:()=>qp,ones:()=>hn,onesLike:()=>Pn,op:()=>W,outerProduct:()=>M_,pad:()=>Xn,pad1d:()=>__,pad2d:()=>O_,pad3d:()=>L_,pad4d:()=>W_,pool:()=>H_,pow:()=>Vs,prelu:()=>Uf,print:()=>p7,prod:()=>oA,profile:()=>SM,rand:()=>Z_,randomGamma:()=>ez,randomNormal:()=>Iw,randomUniform:()=>vd,range:()=>Mu,ready:()=>gd,real:()=>Tu,reciprocal:()=>Sw,registerBackend:()=>Rl,registerCallbackConstructor:()=>DU,registerGradient:()=>Wv,registerKernel:()=>qn,registerOp:()=>Nj,regularizers:()=>yk,relu:()=>Da,relu6:()=>dA,removeBackend:()=>TM,reshape:()=>U,reverse:()=>_n,reverse1d:()=>lz,reverse2d:()=>dz,reverse3d:()=>hz,reverse4d:()=>fz,rfft:()=>Hf,round:()=>pA,rsqrt:()=>hA,scalar:()=>Se,scatterND:()=>zw,scatter_util:()=>Oy,searchSorted:()=>sA,selu:()=>cA,separableConv2d:()=>Cw,sequential:()=>zU,serialization:()=>ue,setBackend:()=>Py,setPlatform:()=>EM,setThreadsCount:()=>Wye,setWasmPath:()=>Bye,setWasmPaths:()=>D5,setWebGLContext:()=>Nm,setdiff1dAsync:()=>Tw,shared:()=>Cm,sigmoid:()=>Tr,sign:()=>Nw,signal:()=>VD,sin:()=>fA,sinh:()=>mA,slice:()=>Pe,slice1d:()=>Gf,slice2d:()=>gA,slice3d:()=>Pl,slice4d:()=>zo,slice_util:()=>Dt,softmax:()=>wd,softplus:()=>xd,spaceToBatchND:()=>Vf,sparse:()=>Np,sparseToDense:()=>bA,spectral:()=>WD,split:()=>Yt,sqrt:()=>Er,square:()=>xt,squaredDifference:()=>AA,squeeze:()=>Qe,stack:()=>dr,step:()=>Rh,stridedSlice:()=>Ew,string:()=>d0,sub:()=>ce,sum:()=>ke,sumOutType:()=>bh,tan:()=>Rw,tanh:()=>Nu,tensor:()=>ft,tensor1d:()=>Nt,tensor2d:()=>ca,tensor3d:()=>x7,tensor4d:()=>Lz,tensor5d:()=>Bz,tensor6d:()=>Wz,tensor_util:()=>ha,test_util:()=>F7,tidy:()=>X,tile:()=>Gn,time:()=>CM,topk:()=>$w,train:()=>xo,transpose:()=>tt,truncatedNormal:()=>qf,unique:()=>Fg,unregisterGradient:()=>XR,unregisterKernel:()=>qR,unsortedSegmentSum:()=>Mw,unstack:()=>nn,upcastType:()=>Nr,upperBound:()=>Fw,util:()=>v,valueAndGrad:()=>r_,valueAndGrads:()=>n_,variable:()=>Pw,variableGrads:()=>Aw,version:()=>ec,version_converter:()=>_H,version_core:()=>Vy,version_cpu:()=>vX,version_layers:()=>qA,version_wasm:()=>Uye,version_webgl:()=>Yte,webgl:()=>Jte,webgl_util:()=>hI,webgpu:()=>hS,where:()=>Vr,whereAsync:()=>xA,zeros:()=>zt,zerosLike:()=>at});var QE=Object.create,Q0=Object.defineProperty,eR=Object.getOwnPropertyDescriptor,Sv=Object.getOwnPropertyNames,tR=Object.getPrototypeOf,rR=Object.prototype.hasOwnProperty,nR=e=>Q0(e,"__esModule",{value:!0}),pr=(e,t)=>function(){return t||(0,e[Sv(e)[0]])((t={exports:{}}).exports,t),t.exports},Be=(e,t)=>{for(var r in t)Q0(e,r,{get:t[r],enumerable:!0})},aR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Sv(t))!rR.call(e,a)&&(r||a!=="default")&&Q0(e,a,{get:()=>t[a],enumerable:!(n=eR(t,a))||n.enumerable});return e},Uo=(e,t)=>aR(nR(Q0(e!=null?QE(tR(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),sR=pr({"src/node_modules/long/src/long.js"(e,t){t.exports=n;var r=null;try{r=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(S){}function n(S,P,O){this.low=S|0,this.high=P|0,this.unsigned=!!O}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0});function a(S){return(S&&S.__isLong__)===!0}n.isLong=a;var s={},i={};function o(S,P){var O,j,K;return P?(S>>>=0,(K=0<=S&&S<256)&&(j=i[S],j)?j:(O=u(S,(S|0)<0?-1:0,!0),K&&(i[S]=O),O)):(S|=0,(K=-128<=S&&S<128)&&(j=s[S],j)?j:(O=u(S,S<0?-1:0,!1),K&&(s[S]=O),O))}n.fromInt=o;function l(S,P){if(isNaN(S))return P?b:x;if(P){if(S<0)return b;if(S>=g)return R}else{if(S<=-y)return z;if(S+1>=y)return E}return S<0?l(-S,P).neg():u(S%f|0,S/f|0,P)}n.fromNumber=l;function u(S,P,O){return new n(S,P,O)}n.fromBits=u;var d=Math.pow;function h(S,P,O){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof P=="number"?(O=P,P=!1):P=!!P,O=O||10,O<2||360)throw Error("interior hyphen");if(j===0)return h(S.substring(1),P,O).neg();for(var K=l(d(O,8)),D=x,Q=0;Q>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},$.toString=function(S){if(S=S||10,S<2||36>>0,Y=re.toString(S);if(D=V,D.isZero())return Y+Q;for(;Y.length<6;)Y="0"+Y;Q=""+Y+Q}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(z)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,P=31;P>0&&(S&1<=0},$.isOdd=function(){return(this.low&1)===1},$.isEven=function(){return(this.low&1)===0},$.equals=function(S){return a(S)||(S=p(S)),this.unsigned!==S.unsigned&&this.high>>>31===1&&S.high>>>31===1?!1:this.high===S.high&&this.low===S.low},$.eq=$.equals,$.notEquals=function(S){return!this.eq(S)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(S){return this.comp(S)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(S){return this.comp(S)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(S){return this.comp(S)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(S){return this.comp(S)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(S){if(a(S)||(S=p(S)),this.eq(S))return 0;var P=this.isNegative(),O=S.isNegative();return P&&!O?-1:!P&&O?1:this.unsigned?S.high>>>0>this.high>>>0||S.high===this.high&&S.low>>>0>this.low>>>0?-1:1:this.sub(S).isNegative()?-1:1},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(z)?z:this.not().add(w)},$.neg=$.negate,$.add=function(S){a(S)||(S=p(S));var P=this.high>>>16,O=this.high&65535,j=this.low>>>16,K=this.low&65535,D=S.high>>>16,Q=S.high&65535,V=S.low>>>16,re=S.low&65535,Y=0,ie=0,J=0,ae=0;return ae+=K+re,J+=ae>>>16,ae&=65535,J+=j+V,ie+=J>>>16,J&=65535,ie+=O+Q,Y+=ie>>>16,ie&=65535,Y+=P+D,Y&=65535,u(J<<16|ae,Y<<16|ie,this.unsigned)},$.subtract=function(S){return a(S)||(S=p(S)),this.add(S.neg())},$.sub=$.subtract,$.multiply=function(S){if(this.isZero())return x;if(a(S)||(S=p(S)),r){var P=r.mul(this.low,this.high,S.low,S.high);return u(P,r.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(z))return S.isOdd()?z:x;if(S.eq(z))return this.isOdd()?z:x;if(this.isNegative())return S.isNegative()?this.neg().mul(S.neg()):this.neg().mul(S).neg();if(S.isNegative())return this.mul(S.neg()).neg();if(this.lt(A)&&S.lt(A))return l(this.toNumber()*S.toNumber(),this.unsigned);var O=this.high>>>16,j=this.high&65535,K=this.low>>>16,D=this.low&65535,Q=S.high>>>16,V=S.high&65535,re=S.low>>>16,Y=S.low&65535,ie=0,J=0,ae=0,de=0;return de+=D*Y,ae+=de>>>16,de&=65535,ae+=K*Y,J+=ae>>>16,ae&=65535,ae+=D*re,J+=ae>>>16,ae&=65535,J+=j*Y,ie+=J>>>16,J&=65535,J+=K*re,ie+=J>>>16,J&=65535,J+=D*V,ie+=J>>>16,J&=65535,ie+=O*Y+j*re+K*V+D*Q,ie&=65535,u(ae<<16|de,ie<<16|J,this.unsigned)},$.mul=$.multiply,$.divide=function(S){if(a(S)||(S=p(S)),S.isZero())throw Error("division by zero");if(r){if(!this.unsigned&&this.high===-2147483648&&S.low===-1&&S.high===-1)return this;var P=(this.unsigned?r.div_u:r.div_s)(this.low,this.high,S.low,S.high);return u(P,r.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var O,j,K;if(this.unsigned){if(S.unsigned||(S=S.toUnsigned()),S.gt(this))return b;if(S.gt(this.shru(1)))return I;K=b}else{if(this.eq(z)){if(S.eq(w)||S.eq(C))return z;if(S.eq(z))return w;var D=this.shr(1);return O=D.div(S).shl(1),O.eq(x)?S.isNegative()?w:C:(j=this.sub(S.mul(O)),K=O.add(j.div(S)),K)}else if(S.eq(z))return this.unsigned?b:x;if(this.isNegative())return S.isNegative()?this.neg().div(S.neg()):this.neg().div(S).neg();if(S.isNegative())return this.div(S.neg()).neg();K=x}for(j=this;j.gte(S);){O=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Q=Math.ceil(Math.log(O)/Math.LN2),V=Q<=48?1:d(2,Q-48),re=l(O),Y=re.mul(S);Y.isNegative()||Y.gt(j);)O-=V,re=l(O,this.unsigned),Y=re.mul(S);re.isZero()&&(re=w),K=K.add(re),j=j.sub(Y)}return K},$.div=$.divide,$.modulo=function(S){if(a(S)||(S=p(S)),r){var P=(this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,S.low,S.high);return u(P,r.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return u(~this.low,~this.high,this.unsigned)},$.and=function(S){return a(S)||(S=p(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},$.or=function(S){return a(S)||(S=p(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},$.xor=function(S){return a(S)||(S=p(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},$.shiftLeft=function(S){return a(S)&&(S=S.toInt()),(S&=63)===0?this:S<32?u(this.low<>>32-S,this.unsigned):u(0,this.low<>>S|this.high<<32-S,this.high>>S,this.unsigned):u(this.high>>S-32,this.high>=0?0:-1,this.unsigned)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(S){if(a(S)&&(S=S.toInt()),S&=63,S===0)return this;var P=this.high;if(S<32){var O=this.low;return u(O>>>S|P<<32-S,P>>>S,this.unsigned)}else return S===32?u(P,0,this.unsigned):u(P>>>S-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},$.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},$.toBytesLE=function(){var S=this.high,P=this.low;return[P&255,P>>>8&255,P>>>16&255,P>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},$.toBytesBE=function(){var S=this.high,P=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,P>>>24,P>>>16&255,P>>>8&255,P&255]},n.fromBytes=function(S,P,O){return O?n.fromBytesLE(S,P):n.fromBytesBE(S,P)},n.fromBytesLE=function(S,P){return new n(S[0]|S[1]<<8|S[2]<<16|S[3]<<24,S[4]|S[5]<<8|S[6]<<16|S[7]<<24,P)},n.fromBytesBE=function(S,P){return new n(S[4]<<24|S[5]<<16|S[6]<<8|S[7],S[0]<<24|S[1]<<16|S[2]<<8|S[3],P)}}}),iR=pr({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),oR=pr({"(disabled):util"(){}}),lR=pr({"src/node_modules/seedrandom/lib/alea.js"(e,t){(function(r,n,a){function s(u){var d=this,h=l();d.next=function(){var p=2091639*d.s0+d.c*23283064365386963e-26;return d.s0=d.s1,d.s1=d.s2,d.s2=p-(d.c=p|0)},d.c=1,d.s0=h(" "),d.s1=h(" "),d.s2=h(" "),d.s0-=h(u),d.s0<0&&(d.s0+=1),d.s1-=h(u),d.s1<0&&(d.s1+=1),d.s2-=h(u),d.s2<0&&(d.s2+=1),h=null}function i(u,d){return d.c=u.c,d.s0=u.s0,d.s1=u.s1,d.s2=u.s2,d}function o(u,d){var h=new s(u),p=d&&d.state,c=h.next;return c.int32=function(){return h.next()*4294967296|0},c.double=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.quick=c,p&&(typeof p=="object"&&i(p,h),c.state=function(){return i(h,{})}),c}function l(){var u=4022871197,d=function(h){h=String(h);for(var p=0;p>>0,c-=u,c*=u,u=c>>>0,c-=u,u+=c*4294967296}return(u>>>0)*23283064365386963e-26};return d}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),uR=pr({"src/node_modules/seedrandom/lib/xor128.js"(e,t){(function(r,n,a){function s(l){var u=this,d="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var p=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^p^p>>>8},l===(l|0)?u.x=l:d+=l;for(var h=0;h>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(typeof h=="object"&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),dR=pr({"src/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(r,n,a){function s(l){var u=this,d="";u.next=function(){var p=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(p^p<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:d+=l;for(var h=0;h>>4),u.next()}function i(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function o(l,u){var d=new s(l),h=u&&u.state,p=function(){return(d.next()>>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(typeof h=="object"&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),pR=pr({"src/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(r,n,a){function s(l){var u=this;u.next=function(){var h=u.x,p=u.i,c,m,f;return c=h[p],c^=c>>>7,m=c^c<<24,c=h[p+1&7],m^=c^c>>>10,c=h[p+3&7],m^=c^c>>>3,c=h[p+4&7],m^=c^c<<7,c=h[p+7&7],c=c^c<<13,m^=c^c<<9,h[p]=m,u.i=p+1&7,m};function d(h,p){var c,m,f=[];if(p===(p|0))m=f[0]=p;else for(p=""+p,c=0;c0;--c)h.next()}d(u,l)}function i(l,u){return u.x=l.x.slice(),u.i=l.i,u}function o(l,u){l==null&&(l=+new Date);var d=new s(l),h=u&&u.state,p=function(){return(d.next()>>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(h.x&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),hR=pr({"src/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(r,n,a){function s(l){var u=this;u.next=function(){var h=u.w,p=u.X,c=u.i,m,f;return u.w=h=h+1640531527|0,f=p[c+34&127],m=p[c=c+1&127],f^=f<<13,m^=m<<17,f^=f>>>15,m^=m>>>12,f=p[c]=f^m,u.i=c,f+(h^h>>>16)|0};function d(h,p){var c,m,f,g,y,A=[],x=128;for(p===(p|0)?(m=p,p=null):(p=p+"\0",m=0,x=Math.max(x,p.length)),f=0,g=-32;g>>15,m^=m<<4,m^=m>>>13,g>=0&&(y=y+1640531527|0,c=A[g&127]^=m+y,f=c==0?f+1:0);for(f>=128&&(A[(p&&p.length||0)&127]=-1),f=127,g=4*128;g>0;--g)m=A[f+34&127],c=A[f=f+1&127],m^=m<<13,c^=c<<17,m^=m>>>15,c^=c>>>12,A[f]=m^c;h.w=y,h.X=A,h.i=f}d(u,l)}function i(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function o(l,u){l==null&&(l=+new Date);var d=new s(l),h=u&&u.state,p=function(){return(d.next()>>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(h.X&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),cR=pr({"src/node_modules/seedrandom/lib/tychei.js"(e,t){(function(r,n,a){function s(l){var u=this,d="";u.next=function(){var p=u.b,c=u.c,m=u.d,f=u.a;return p=p<<25^p>>>7^c,c=c-m|0,m=m<<24^m>>>8^f,f=f-p|0,u.b=p=p<<20^p>>>12^c,u.c=c=c-m|0,u.d=m<<16^c>>>16^f,u.a=f-p|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):d+=l;for(var h=0;h>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(typeof h=="object"&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),fR=pr({"(disabled):crypto"(){}}),mR=pr({"src/node_modules/seedrandom/seedrandom.js"(e,t){(function(r,n,a){var s=256,i=6,o=52,l="random",u=a.pow(s,i),d=a.pow(2,o),h=d*2,p=s-1,c;function m(w,I,C){var E=[];I=I==!0?{entropy:!0}:I||{};var R=A(y(I.entropy?[w,b(n)]:w==null?x():w,3),E),z=new f(E),$=function(){for(var S=z.g(i),P=u,O=0;S=h;)S/=2,P/=2,O>>>=1;return(S+O)/P};return $.int32=function(){return z.g(4)|0},$.quick=function(){return z.g(4)/4294967296},$.double=$,A(b(z.S),n),(I.pass||C||function(S,P,O,j){return j&&(j.S&&g(j,z),S.state=function(){return g(z,{})}),O?(a[l]=S,P):S})($,R,"global"in I?I.global:this==a,I.state)}function f(w){var I,C=w.length,E=this,R=0,z=E.i=E.j=0,$=E.S=[];for(C||(w=[C++]);R{var n=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(n=n||__filename),function(a){a=a||{};function s(){return Fe.buffer!=_r&&ra(Fe.buffer),fc}function i(){return Fe.buffer!=_r&&ra(Fe.buffer),mc}function o(){return Fe.buffer!=_r&&ra(Fe.buffer),lp}function l(){return Fe.buffer!=_r&&ra(Fe.buffer),gc}function u(){return Fe.buffer!=_r&&ra(Fe.buffer),yc}function d(){return Fe.buffer!=_r&&ra(Fe.buffer),Ac}function h(){return Fe.buffer!=_r&&ra(Fe.buffer),xc}var p=typeof a!="undefined"?a:{},c,m;p.ready=new Promise(function(N,F){c=N,m=F});var f;typeof process!="undefined"&&process.listeners&&(f={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},p),y=[],A="./this.program",x=(N,F)=>{throw F},b=typeof window=="object",w=typeof importScripts=="function",I=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",C=p.ENVIRONMENT_IS_PTHREAD||!1,E="";function R(N){return p.locateFile?p.locateFile(N,E):E+N}var z,$,S,P;function O(N){N instanceof yp||Y("exiting due to exception: "+N)}var j,K,D;if(I){w?E=b0().dirname(E)+"/":E=__dirname+"/",D=()=>{K||(j=xy(),K=b0())},z=function(F,G){return D(),F=K.normalize(F),j.readFileSync(F,G?void 0:"utf8")},S=F=>{var G=z(F,!0);return G.buffer||(G=new Uint8Array(G)),G},$=(F,G,ee)=>{D(),F=K.normalize(F),j.readFile(F,function(ge,Ae){ge?ee(ge):G(Ae.buffer)})},process.argv.length>1&&(A=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function(F){if(!(F instanceof yp))throw F}),process.on("unhandledRejection",function(F){throw F}),x=(F,G)=>{if(po())throw process.exitCode=F,G;O(G),process.exit(F)},p.inspect=function(){return"[Emscripten Module object]"};let N;try{N=gR()}catch(F){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),F}global.Worker=N.Worker}else(b||w)&&(w?E=self.location.href:typeof document!="undefined"&&document.currentScript&&(E=document.currentScript.src),typeof n!="undefined"&&n&&(E=n),E.indexOf("blob:")!==0?E=E.substr(0,E.replace(/[?#].*/,"").lastIndexOf("/")+1):E="",I||(z=N=>{var F=new XMLHttpRequest;return F.open("GET",N,!1),F.send(null),F.responseText},w&&(S=N=>{var F=new XMLHttpRequest;return F.open("GET",N,!1),F.responseType="arraybuffer",F.send(null),new Uint8Array(F.response)}),$=(N,F,G)=>{var ee=new XMLHttpRequest;ee.open("GET",N,!0),ee.responseType="arraybuffer",ee.onload=()=>{if(ee.status==200||ee.status==0&&ee.response){F(ee.response);return}G()},ee.onerror=G,ee.send(null)}),P=N=>document.title=N);I&&typeof performance=="undefined"&&(global.performance=yR().performance);var Q=console.log.bind(console),V=console.warn.bind(console);I&&(D(),Q=N=>j.writeSync(1,N+` `),V=N=>j.writeSync(2,N+` `));var re=p.print||Q,Y=p.printErr||V;Object.assign(p,g),g=null,p.arguments&&(y=p.arguments),p.thisProgram&&(A=p.thisProgram),p.quit&&(x=p.quit);var ie=4;function J(N){J.shown||(J.shown={}),J.shown[N]||(J.shown[N]=1,Y(N))}function ae(N,F){if(typeof WebAssembly.Function=="function"){for(var G={i:"i32",j:"i64",f:"f32",d:"f64"},ee={parameters:[],results:F[0]=="v"?[]:[G[F[0]]]},ge=1;ge{$e=N},We=Atomics.load,Xe=Atomics.store,ot=Atomics.compareExchange,pt;p.wasmBinary&&(pt=p.wasmBinary);var ht=p.noExitRuntime||!0;typeof WebAssembly!="object"&&eu("no native wasm support detected");var Fe,wt,At=!1,Pr;function cr(N,F){N||eu(F)}function Jr(N){var F=p["_"+N];return F}function nr(N,F,G,ee,ge){var Ae={string:function(Cn){var du=0;if(Cn!=null&&Cn!==0){var _3=(Cn.length<<2)+1;du=uu(_3),lo(Cn,du,_3)}return du},array:function(Cn){var du=uu(Cn.length);return Ga(Cn,du),du}};function Te(Cn){return F==="string"?In(Cn):F==="boolean"?Boolean(Cn):Cn}var _e=Jr(N),_t=[],ia=0;if(ee)for(var oa=0;oa(G.buffer instanceof SharedArrayBuffer&&(G=new Uint8Array(G)),F.decode.call(F,G))}var ar=typeof TextDecoder!="undefined"?new Qr("utf8"):void 0;function kn(N,F,G){for(var ee=F+G,ge=F;N[ge]&&!(ge>=ee);)++ge;if(ge-F>16&&N.subarray&&ar)return ar.decode(N.subarray(F,ge));for(var Ae="";F>10,56320|ia&1023)}}return Ae}function In(N,F){return N?kn(i(),N,F):""}function As(N,F,G,ee){if(!(ee>0))return 0;for(var ge=G,Ae=G+ee-1,Te=0;Te=55296&&_e<=57343){var _t=N.charCodeAt(++Te);_e=65536+((_e&1023)<<10)|_t&1023}if(_e<=127){if(G>=Ae)break;F[G++]=_e}else if(_e<=2047){if(G+1>=Ae)break;F[G++]=192|_e>>6,F[G++]=128|_e&63}else if(_e<=65535){if(G+2>=Ae)break;F[G++]=224|_e>>12,F[G++]=128|_e>>6&63,F[G++]=128|_e&63}else{if(G+3>=Ae)break;F[G++]=240|_e>>18,F[G++]=128|_e>>12&63,F[G++]=128|_e>>6&63,F[G++]=128|_e&63}}return F[G]=0,G-ge}function lo(N,F,G){return As(N,i(),F,G)}function cc(N){for(var F=0,G=0;G=55296&&ee<=57343&&(ee=65536+((ee&1023)<<10)|N.charCodeAt(++G)&1023),ee<=127?++F:ee<=2047?F+=2:ee<=65535?F+=3:F+=4}return F}var xs=typeof TextDecoder!="undefined"?new Qr("utf-16le"):void 0;function Ga(N,F){s().set(N,F)}function op(N,F,G){for(var ee=0;ee>0]=N.charCodeAt(ee);G||(s()[F>>0]=0)}function Jl(N,F){return N%F>0&&(N+=F-N%F),N}var _r,fc,mc,lp,gc,yc,m3,Ac,xc;C&&(_r=p.buffer);function ra(N){_r=N,p.HEAP8=fc=new Int8Array(N),p.HEAP16=lp=new Int16Array(N),p.HEAP32=yc=new Int32Array(N),p.HEAPU8=mc=new Uint8Array(N),p.HEAPU16=gc=new Uint16Array(N),p.HEAPU32=m3=new Uint32Array(N),p.HEAPF32=Ac=new Float32Array(N),p.HEAPF64=xc=new Float64Array(N)}var bc=p.INITIAL_MEMORY||16777216;if(C)Fe=p.wasmMemory,_r=p.buffer;else if(p.wasmMemory)Fe=p.wasmMemory;else if(Fe=new WebAssembly.Memory({initial:bc/65536,maximum:32768,shared:!0}),!(Fe.buffer instanceof SharedArrayBuffer))throw Y("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"),I&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Fe&&(_r=Fe.buffer),bc=_r.byteLength,ra(_r);var Sn,Ql=[],bs=[],T1=[],vc=[],uo=!1,N1=!1,wc=0;function po(){return ht||wc>0}function zr(){if(p.preRun)for(typeof p.preRun=="function"&&(p.preRun=[p.preRun]);p.preRun.length;)g3(p.preRun.shift());Tc(Ql)}function up(){uo=!0,!C&&Tc(bs)}function E1(){C||(ze.terminateAllThreads(),N1=!0)}function R1(){if(!C){if(p.postRun)for(typeof p.postRun=="function"&&(p.postRun=[p.postRun]);p.postRun.length;)dp(p.postRun.shift());Tc(vc)}}function g3(N){Ql.unshift(N)}function y3(N){bs.unshift(N)}function dp(N){vc.unshift(N)}var vs=0,kc=null,na=null;function pp(N){vs++,p.monitorRunDependencies&&p.monitorRunDependencies(vs)}function A3(N){if(vs--,p.monitorRunDependencies&&p.monitorRunDependencies(vs),vs==0&&(kc!==null&&(clearInterval(kc),kc=null),na)){var F=na;na=null,F()}}p.preloadedImages={},p.preloadedAudios={};function eu(N){C?postMessage({cmd:"onAbort",arg:N}):p.onAbort&&p.onAbort(N),N="Aborted("+N+")",Y(N),At=!0,Pr=1,N+=". Build with -s ASSERTIONS=1 for more info.";var F=new WebAssembly.RuntimeError(N);throw m(F),F}var $1="data:application/octet-stream;base64,";function Ic(N){return N.startsWith($1)}function Sc(N){return N.startsWith("file://")}var Or;Or="tfjs-backend-wasm-threaded-simd.wasm",Ic(Or)||(Or=R(Or));function Cc(N){try{if(N==Or&&pt)return new Uint8Array(pt);if(S)return S(N);throw"both async and sync fetching of the wasm failed"}catch(F){eu(F)}}function tu(){if(!pt&&(b||w)){if(typeof fetch=="function"&&!Sc(Or))return fetch(Or,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+Or+"'";return N.arrayBuffer()}).catch(function(){return Cc(Or)});if($)return new Promise(function(N,F){$(Or,function(G){N(new Uint8Array(G))},F)})}return Promise.resolve().then(function(){return Cc(Or)})}function M1(){var N={env:Lc,wasi_snapshot_preview1:Lc};function F(Te,_e){var _t=Te.exports;if(p.asm=_t,L1(p.asm.emscripten_tls_init),Sn=p.asm.__indirect_function_table,y3(p.asm.__wasm_call_ctors),wt=_e,!C){var ia=ze.unusedWorkers.length;ze.unusedWorkers.forEach(function(oa){ze.loadWasmModuleToWorker(oa,function(){--ia||A3("wasm-instantiate")})})}}C||pp("wasm-instantiate");function G(Te){F(Te.instance,Te.module)}function ee(Te){return tu().then(function(_e){return WebAssembly.instantiate(_e,N)}).then(function(_e){return _e}).then(Te,function(_e){Y("failed to asynchronously prepare wasm: "+_e),eu(_e)})}function ge(){return!pt&&typeof WebAssembly.instantiateStreaming=="function"&&!Ic(Or)&&!Sc(Or)&&typeof fetch=="function"?fetch(Or,{credentials:"same-origin"}).then(function(Te){var _e=WebAssembly.instantiateStreaming(Te,N);return _e.then(G,function(_t){return Y("wasm streaming compile failed: "+_t),Y("falling back to ArrayBuffer instantiation"),ee(G)})}):ee(G)}if(p.instantiateWasm)try{var Ae=p.instantiateWasm(N,F);return Ae}catch(Te){return Y("Module.instantiateWasm callback failed with error: "+Te),!1}return ge().catch(m),{}}var x3,b3,F1={};function Tc(N){for(;N.length>0;){var F=N.shift();if(typeof F=="function"){F(p);continue}var G=F.func;typeof G=="number"?F.arg===void 0?nu(G)():nu(G)(F.arg):G(F.arg===void 0?null:F.arg)}}function ru(N){var F=rg(),G=N();return Gc(F),G}function eE(N){return N}function v3(N){var F=/\b_Z[\w\d_]+/g;return N.replace(F,function(G){var ee=G;return G===ee?G:ee+" ["+G+"]"})}function P1(N){u()[N>>2]=0;var F=ze.pthreads[N];delete ze.pthreads[N],F.worker.terminate(),tg(N),ze.runningWorkers.splice(ze.runningWorkers.indexOf(F.worker),1),F.worker.pthread=void 0}function _1(N){var F=ze.pthreads[N];F.worker.postMessage({cmd:"cancel"})}function Nc(N){var F=ze.pthreads[N];if(F){u()[N>>2]=0;var G=F.worker;ze.returnWorkerToPool(G)}}function Ec(N){UE(N)}function z1(N){if(N instanceof yp||N=="unwind")return Pr;x(1,N)}var ze={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){C?ze.initWorker():ze.initMainThread()},initMainThread:function(){for(var N=8,F=0;F>2]=0;try{N()}finally{u()[P3>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in ze.tlsInitFunctions)ze.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,F){N.onmessage=G=>{var ee=G.data,ge=ee.cmd;if(N.pthread&&(ze.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),ee.targetThread&&ee.targetThread!=Uc()){var Ae=ze.pthreads[ee.targetThread];Ae?Ae.worker.postMessage(ee,ee.transferList):Y('Internal error! Worker sent a message "'+ge+'" to target pthread '+ee.targetThread+", but that thread no longer exists!"),ze.currentProxiedOperationCallerThread=void 0;return}ge==="processQueuedMainThreadWork"?E3():ge==="spawnThread"?$c(ee):ge==="cleanupThread"?Nc(ee.thread):ge==="killThread"?P1(ee.thread):ge==="cancelThread"?_1(ee.thread):ge==="loaded"?(N.loaded=!0,F&&F(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):ge==="print"?re("Thread "+ee.threadId+": "+ee.text):ge==="printErr"?Y("Thread "+ee.threadId+": "+ee.text):ge==="alert"?alert("Thread "+ee.threadId+": "+ee.text):ee.target==="setimmediate"?N.postMessage(ee):ge==="onAbort"?p.onAbort&&p.onAbort(ee.arg):Y("worker sent an unknown command "+ge),ze.currentProxiedOperationCallerThread=void 0},N.onerror=G=>{var ee="worker sent an error!";throw Y(ee+" "+G.filename+":"+G.lineno+": "+G.message),G},I&&(N.on("message",function(G){N.onmessage({data:G})}),N.on("error",function(G){N.onerror(G)}),N.on("detachedExit",function(){})),N.postMessage({cmd:"load",urlOrBlob:p.mainScriptUrlOrBlob||n,wasmMemory:Fe,wasmModule:wt})},allocateUnusedWorker:function(){var N=R("tfjs-backend-wasm-threaded-simd.worker.js");ze.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return ze.unusedWorkers.length==0&&(ze.allocateUnusedWorker(),ze.loadWasmModuleToWorker(ze.unusedWorkers[0])),ze.unusedWorkers.pop()}};function O1(){var N=Uc(),F=u()[N+44>>2],G=u()[N+48>>2],ee=F-G;F3(F,ee),Gc(F)}p.establishStackSpace=O1;function Rc(N){if(C)return fo(1,0,N);try{Ec(N)}catch(F){z1(F)}}var ho=[];function nu(N){var F=ho[N];return F||(N>=ho.length&&(ho.length=N+1),ho[N]=F=Sn.get(N)),F}function D1(N,F){return nu(N)(F)}p.invokeEntryPoint=D1;function w3(){var N=new Error;if(!N.stack){try{throw new Error}catch(F){N=F}if(!N.stack)return"(no stack trace available)"}return N.stack.toString()}function L1(N,F,G){ze.tlsInitFunctions.push(N)}function k3(N,F){Sn.set(N,F),ho[N]=F}var co;I?co=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:C?co=()=>performance.now()-p.__performance_now_clock_drift:co=()=>performance.now();var B1=!0;function W1(N){return u()[N3()>>2]=N,N}function V1(N,F){var G;if(N===0)G=Date.now();else if((N===1||N===4)&&B1)G=co();else return W1(28),-1;return u()[F>>2]=G/1e3|0,u()[F+4>>2]=G%1e3*1e3*1e3|0,0}function U1(N,F){return V1(N,F)}function G1(N){R3(N,!w,1,!b),ze.threadInit()}function j1(N){C?postMessage({cmd:"cleanupThread",thread:N}):Nc(N)}function $c(N){var F=ze.getNewWorker();if(!F)return 6;ze.runningWorkers.push(F);var G=ze.pthreads[N.pthread_ptr]={worker:F,threadInfoStruct:N.pthread_ptr};F.pthread=G;var ee={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return F.runPthread=()=>{ee.time=performance.now(),F.postMessage(ee,N.transferList)},F.loaded&&(F.runPthread(),delete F.runPthread),0}function H1(N,F,G,ee){if(typeof SharedArrayBuffer=="undefined")return Y("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ge=[],Ae=0;if(C&&(ge.length===0||Ae))return $3(687865856,N,F,G,ee);if(Ae)return Ae;var Te={startRoutine:G,pthread_ptr:N,arg:ee,transferList:ge};return C?(Te.cmd="spawnThread",postMessage(Te,ge),0):$c(Te)}function q1(){return 2097152}function X1(N,F){if(N==F)postMessage({cmd:"processQueuedMainThreadWork"});else if(C)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var G=ze.pthreads[N],ee=G&&G.worker;if(!ee)return;ee.postMessage({cmd:"processThreadQueue"})}return 1}function K1(){eu("")}function Z1(){I||w||J("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Mc(){return 2147483648}function Y1(N,F,G){i().copyWithin(N,F,F+G)}function J1(){return I?AR().cpus().length:navigator.hardwareConcurrency}function fo(N,F){var G=arguments.length-2,ee=arguments;return ru(function(){for(var ge=G,Ae=uu(ge*8),Te=Ae>>3,_e=0;_e>3,ge=0;ge>>16),ra(Fe.buffer),1}catch(F){}}function t2(N){var F=i().length;if(N=N>>>0,N<=F)return!1;var G=Mc();if(N>G)return!1;for(var ee=1;ee<=4;ee*=2){var ge=F*(1+.2/ee);ge=Math.min(ge,N+100663296);var Ae=Math.min(G,Jl(Math.max(N,ge),65536)),Te=e2(Ae);if(Te)return!0}return!1}var qe={inEventHandler:0,removeAllEventListeners:function(){for(var N=qe.eventHandlers.length-1;N>=0;--N)qe._removeHandler(N);qe.eventHandlers=[],qe.deferredCalls=[]},registerRemoveEventListeners:function(){qe.removeEventListenersRegistered||(T1.push(qe.removeAllEventListeners),qe.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,F,G){function ee(Te,_e){if(Te.length!=_e.length)return!1;for(var _t in Te)if(Te[_t]!=_e[_t])return!1;return!0}for(var ge in qe.deferredCalls){var Ae=qe.deferredCalls[ge];if(Ae.targetFunction==N&&ee(Ae.argsList,G))return}qe.deferredCalls.push({targetFunction:N,precedence:F,argsList:G}),qe.deferredCalls.sort(function(Te,_e){return Te.precedence<_e.precedence})},removeDeferredCalls:function(N){for(var F=0;F>2]=G,u()[Ae+4>>2]=ee,u()[Ae+8>>2]=ge,eg(N,637534208,F,ee,Ae)})},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return ze.currentProxiedOperationCallerThread;default:return N}},getNodeNameForTarget:function(N){return N?N==window?"#window":N==screen?"#screen":N&&N.nodeName?N.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function r2(N){var F=cc(N)+1,G=Q2(F);return lo(N,G,F),G}function n2(N,F,G,ee){ru(function(){var ge=uu(12),Ae=0;F&&(Ae=r2(F)),u()[ge>>2]=Ae,u()[ge+4>>2]=G,u()[ge+8>>2]=ee,eg(N,657457152,0,Ae,ge)})}function a2(N,F,G,ee){F=F?In(F):"",n2(N,F,G,ee)}function s2(N){return N>2?In(N):N}var i2=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function o2(N){N=s2(N);var F=i2[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return F}function cp(N){return o2(N)}function Fc(N,F,G){var ee=cp(N);if(!ee)return-4;if(ee.canvasSharedPtr&&(u()[ee.canvasSharedPtr>>2]=F,u()[ee.canvasSharedPtr+4>>2]=G),ee.offscreenCanvas||!ee.controlTransferredOffscreen){ee.offscreenCanvas&&(ee=ee.offscreenCanvas);var ge=!1;if(ee.GLctxObject&&ee.GLctxObject.GLctx){var Ae=ee.GLctxObject.GLctx.getParameter(2978);ge=Ae[0]===0&&Ae[1]===0&&Ae[2]===ee.width&&Ae[3]===ee.height}ee.width=F,ee.height=G,ge&&ee.GLctxObject.GLctx.viewport(0,0,F,G)}else if(ee.canvasSharedPtr){var Te=u()[ee.canvasSharedPtr+8>>2];return a2(Te,N,F,G),1}else return-4;return 0}function Pc(N,F,G){return C?fo(2,1,N,F,G):Fc(N,F,G)}function l2(N,F,G){var ee=cp(N);return ee?Fc(N,F,G):Pc(N,F,G)}function u2(){throw"unwind"}function d2(N){var F=N.getExtension("ANGLE_instanced_arrays");if(F)return N.vertexAttribDivisor=function(G,ee){F.vertexAttribDivisorANGLE(G,ee)},N.drawArraysInstanced=function(G,ee,ge,Ae){F.drawArraysInstancedANGLE(G,ee,ge,Ae)},N.drawElementsInstanced=function(G,ee,ge,Ae,Te){F.drawElementsInstancedANGLE(G,ee,ge,Ae,Te)},1}function p2(N){var F=N.getExtension("OES_vertex_array_object");if(F)return N.createVertexArray=function(){return F.createVertexArrayOES()},N.deleteVertexArray=function(G){F.deleteVertexArrayOES(G)},N.bindVertexArray=function(G){F.bindVertexArrayOES(G)},N.isVertexArray=function(G){return F.isVertexArrayOES(G)},1}function h2(N){var F=N.getExtension("WEBGL_draw_buffers");if(F)return N.drawBuffers=function(G,ee){F.drawBuffersWEBGL(G,ee)},1}function c2(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var Pt={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(N){Pt.lastError||(Pt.lastError=N)},getNewId:function(N){for(var F=Pt.counter++,G=N.length;G>2]:-1;ge+=In(u()[G+Ae*4>>2],Te<0?void 0:Te)}return ge},createContext:function(N,F){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(ge,Ae){var Te=N.getContextSafariWebGL2Fixed(ge,Ae);return ge=="webgl"==Te instanceof WebGLRenderingContext?Te:null});var G=N.getContext("webgl",F);if(!G)return 0;var ee=Pt.registerContext(G,F);return ee},registerContext:function(N,F){var G=Q2(8);u()[G+4>>2]=Uc();var ee={handle:G,attributes:F,version:F.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=ee),Pt.contexts[G]=ee,(typeof F.enableExtensionsByDefault=="undefined"||F.enableExtensionsByDefault)&&Pt.initExtensions(ee),G},makeContextCurrent:function(N){return Pt.currentContext=Pt.contexts[N],p.ctx=Dc=Pt.currentContext&&Pt.currentContext.GLctx,!(N&&!Dc)},getContext:function(N){return Pt.contexts[N]},deleteContext:function(N){Pt.currentContext===Pt.contexts[N]&&(Pt.currentContext=null),typeof qe=="object"&&qe.removeAllHandlersOnTarget(Pt.contexts[N].GLctx.canvas),Pt.contexts[N]&&Pt.contexts[N].GLctx.canvas&&(Pt.contexts[N].GLctx.canvas.GLctxObject=void 0),T3(Pt.contexts[N].handle),Pt.contexts[N]=null},initExtensions:function(N){if(N||(N=Pt.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var F=N.GLctx;d2(F),p2(F),h2(F),F.disjointTimerQueryExt=F.getExtension("EXT_disjoint_timer_query"),c2(F);var G=F.getSupportedExtensions()||[];G.forEach(function(ee){!ee.includes("lose_context")&&!ee.includes("debug")&&F.getExtension(ee)})}}},f2=["default","low-power","high-performance"];function m2(N,F){var G=F>>2,ee=u()[G+6],ge={alpha:!!u()[G+0],depth:!!u()[G+1],stencil:!!u()[G+2],antialias:!!u()[G+3],premultipliedAlpha:!!u()[G+4],preserveDrawingBuffer:!!u()[G+5],powerPreference:f2[ee],failIfMajorPerformanceCaveat:!!u()[G+7],majorVersion:u()[G+8],minorVersion:u()[G+9],enableExtensionsByDefault:u()[G+10],explicitSwapControl:u()[G+11],proxyContextToMainThread:u()[G+12],renderViaOffscreenBackBuffer:u()[G+13]},Ae=cp(N);if(!Ae||ge.explicitSwapControl)return 0;var Te=Pt.createContext(Ae,ge);return Te}function g2(N,F){return m2(N,F)}var au={mappings:{},buffers:[null,[],[]],printChar:function(N,F){var G=au.buffers[N];F===0||F===10?((N===1?re:Y)(kn(G,0)),G.length=0):G.push(F)},varargs:void 0,get:function(){au.varargs+=4;var N=u()[au.varargs-4>>2];return N},getStr:function(N){var F=In(N);return F},get64:function(N,F){return N}};function _c(N){return C?fo(3,1,N):0}function zc(N,F,G,ee,ge){if(C)return fo(4,1,N,F,G,ee,ge)}function Oc(N,F,G,ee){if(C)return fo(5,1,N,F,G,ee);for(var ge=0,Ae=0;Ae>2],_e=u()[F+4>>2];F+=8;for(var _t=0;_t<_e;_t++)au.printChar(N,i()[Te+_t]);ge+=_e}return u()[ee>>2]=ge,0}function y2(N){De(N)}ze.init();var Dc,A2=[null,Rc,Pc,_c,zc,Oc],I3=!1,Lc={__clock_gettime:U1,__emscripten_init_main_thread_js:G1,__emscripten_thread_cleanup:j1,__pthread_create_js:H1,_emscripten_default_pthread_stack_size:q1,_emscripten_notify_thread_queue:X1,abort:K1,emscripten_check_blocking_allowed:Z1,emscripten_get_heap_max:Mc,emscripten_get_now:co,emscripten_memcpy_big:Y1,emscripten_num_logical_cores:J1,emscripten_receive_on_main_thread_js:Q1,emscripten_resize_heap:t2,emscripten_set_canvas_element_size:l2,emscripten_unwind_to_js_event_loop:u2,emscripten_webgl_create_context:g2,exit:Ec,fd_close:_c,fd_seek:zc,fd_write:Oc,memory:Fe||p.wasmMemory,setTempRet0:y2},S3=M1(),x2=p.___wasm_call_ctors=function(){return(x2=p.___wasm_call_ctors=p.asm.__wasm_call_ctors).apply(null,arguments)},b2=p._init=function(){return(b2=p._init=p.asm.init).apply(null,arguments)},v2=p._init_with_threads_count=function(){return(v2=p._init_with_threads_count=p.asm.init_with_threads_count).apply(null,arguments)},w2=p._get_threads_count=function(){return(w2=p._get_threads_count=p.asm.get_threads_count).apply(null,arguments)},k2=p._register_tensor=function(){return(k2=p._register_tensor=p.asm.register_tensor).apply(null,arguments)},I2=p._dispose_data=function(){return(I2=p._dispose_data=p.asm.dispose_data).apply(null,arguments)},S2=p._dispose=function(){return(S2=p._dispose=p.asm.dispose).apply(null,arguments)},C2=p._Abs=function(){return(C2=p._Abs=p.asm.Abs).apply(null,arguments)},T2=p._Add=function(){return(T2=p._Add=p.asm.Add).apply(null,arguments)},N2=p._AddN=function(){return(N2=p._AddN=p.asm.AddN).apply(null,arguments)},E2=p._All=function(){return(E2=p._All=p.asm.All).apply(null,arguments)},R2=p._Any=function(){return(R2=p._Any=p.asm.Any).apply(null,arguments)},$2=p._ArgMax=function(){return($2=p._ArgMax=p.asm.ArgMax).apply(null,arguments)},M2=p._AvgPool=function(){return(M2=p._AvgPool=p.asm.AvgPool).apply(null,arguments)},F2=p._BatchMatMul=function(){return(F2=p._BatchMatMul=p.asm.BatchMatMul).apply(null,arguments)},P2=p._Ceil=function(){return(P2=p._Ceil=p.asm.Ceil).apply(null,arguments)},_2=p._ClipByValue=function(){return(_2=p._ClipByValue=p.asm.ClipByValue).apply(null,arguments)},z2=p._Conv2D=function(){return(z2=p._Conv2D=p.asm.Conv2D).apply(null,arguments)},O2=p._Conv2DBackpropInput=function(){return(O2=p._Conv2DBackpropInput=p.asm.Conv2DBackpropInput).apply(null,arguments)},D2=p._Cos=function(){return(D2=p._Cos=p.asm.Cos).apply(null,arguments)},L2=p._Cosh=function(){return(L2=p._Cosh=p.asm.Cosh).apply(null,arguments)},B2=p._CropAndResize=function(){return(B2=p._CropAndResize=p.asm.CropAndResize).apply(null,arguments)},W2=p._Cumprod=function(){return(W2=p._Cumprod=p.asm.Cumprod).apply(null,arguments)},V2=p._Cumsum=function(){return(V2=p._Cumsum=p.asm.Cumsum).apply(null,arguments)},U2=p._DepthToSpace=function(){return(U2=p._DepthToSpace=p.asm.DepthToSpace).apply(null,arguments)},G2=p._DepthwiseConv2dNative=function(){return(G2=p._DepthwiseConv2dNative=p.asm.DepthwiseConv2dNative).apply(null,arguments)},j2=p._Elu=function(){return(j2=p._Elu=p.asm.Elu).apply(null,arguments)},H2=p._Equal=function(){return(H2=p._Equal=p.asm.Equal).apply(null,arguments)},q2=p._Exp=function(){return(q2=p._Exp=p.asm.Exp).apply(null,arguments)},X2=p._FlipLeftRight=function(){return(X2=p._FlipLeftRight=p.asm.FlipLeftRight).apply(null,arguments)},Bc=p._Floor=function(){return(Bc=p._Floor=p.asm.Floor).apply(null,arguments)},Wc=p._FloorDiv=function(){return(Wc=p._FloorDiv=p.asm.FloorDiv).apply(null,arguments)},fp=p._FusedBatchNorm=function(){return(fp=p._FusedBatchNorm=p.asm.FusedBatchNorm).apply(null,arguments)},K2=p._FusedConv2D=function(){return(K2=p._FusedConv2D=p.asm.FusedConv2D).apply(null,arguments)},Z2=p._FusedDepthwiseConv2D=function(){return(Z2=p._FusedDepthwiseConv2D=p.asm.FusedDepthwiseConv2D).apply(null,arguments)},su=p._Gather=function(){return(su=p._Gather=p.asm.Gather).apply(null,arguments)},mp=p._GatherNd=function(){return(mp=p._GatherNd=p.asm.GatherNd).apply(null,arguments)},gp=p._Greater=function(){return(gp=p._Greater=p.asm.Greater).apply(null,arguments)},C3=p._GreaterEqual=function(){return(C3=p._GreaterEqual=p.asm.GreaterEqual).apply(null,arguments)},iu=p._LeakyRelu=function(){return(iu=p._LeakyRelu=p.asm.LeakyRelu).apply(null,arguments)},ou=p._Less=function(){return(ou=p._Less=p.asm.Less).apply(null,arguments)},Y2=p._LessEqual=function(){return(Y2=p._LessEqual=p.asm.LessEqual).apply(null,arguments)},H=p._Log=function(){return(H=p._Log=p.asm.Log).apply(null,arguments)},ne=p._LogicalAnd=function(){return(ne=p._LogicalAnd=p.asm.LogicalAnd).apply(null,arguments)},ye=p._Max=function(){return(ye=p._Max=p.asm.Max).apply(null,arguments)},Re=p._MaxPool=function(){return(Re=p._MaxPool=p.asm.MaxPool).apply(null,arguments)},lt=p._Maximum=function(){return(lt=p._Maximum=p.asm.Maximum).apply(null,arguments)},ct=p._Mean=function(){return(ct=p._Mean=p.asm.Mean).apply(null,arguments)},Ke=p._Min=function(){return(Ke=p._Min=p.asm.Min).apply(null,arguments)},He=p._Minimum=function(){return(He=p._Minimum=p.asm.Minimum).apply(null,arguments)},qt=p._MirrorPad=function(){return(qt=p._MirrorPad=p.asm.MirrorPad).apply(null,arguments)},aa=p._Multiply=function(){return(aa=p._Multiply=p.asm.Multiply).apply(null,arguments)},sa=p._Neg=function(){return(sa=p._Neg=p.asm.Neg).apply(null,arguments)},lu=p._NonMaxSuppressionV3=function(){return(lu=p._NonMaxSuppressionV3=p.asm.NonMaxSuppressionV3).apply(null,arguments)},mo=p._NonMaxSuppressionV4=function(){return(mo=p._NonMaxSuppressionV4=p.asm.NonMaxSuppressionV4).apply(null,arguments)},J2=p._NonMaxSuppressionV5=function(){return(J2=p._NonMaxSuppressionV5=p.asm.NonMaxSuppressionV5).apply(null,arguments)},en=p._NotEqual=function(){return(en=p._NotEqual=p.asm.NotEqual).apply(null,arguments)},ws=p._OneHot=function(){return(ws=p._OneHot=p.asm.OneHot).apply(null,arguments)},Vc=p._PadV2=function(){return(Vc=p._PadV2=p.asm.PadV2).apply(null,arguments)},tE=p._Pow=function(){return(tE=p._Pow=p.asm.Pow).apply(null,arguments)},rE=p._Prelu=function(){return(rE=p._Prelu=p.asm.Prelu).apply(null,arguments)},nE=p._Prod=function(){return(nE=p._Prod=p.asm.Prod).apply(null,arguments)},aE=p._RealDiv=function(){return(aE=p._RealDiv=p.asm.RealDiv).apply(null,arguments)},sE=p._Relu=function(){return(sE=p._Relu=p.asm.Relu).apply(null,arguments)},iE=p._Relu6=function(){return(iE=p._Relu6=p.asm.Relu6).apply(null,arguments)},oE=p._ResizeBilinear=function(){return(oE=p._ResizeBilinear=p.asm.ResizeBilinear).apply(null,arguments)},lE=p._Reverse=function(){return(lE=p._Reverse=p.asm.Reverse).apply(null,arguments)},uE=p._RotateWithOffset=function(){return(uE=p._RotateWithOffset=p.asm.RotateWithOffset).apply(null,arguments)},dE=p._Round=function(){return(dE=p._Round=p.asm.Round).apply(null,arguments)},pE=p._Rsqrt=function(){return(pE=p._Rsqrt=p.asm.Rsqrt).apply(null,arguments)},hE=p._ScatterNd=function(){return(hE=p._ScatterNd=p.asm.ScatterNd).apply(null,arguments)},cE=p._SelectV2=function(){return(cE=p._SelectV2=p.asm.SelectV2).apply(null,arguments)},fE=p._Sigmoid=function(){return(fE=p._Sigmoid=p.asm.Sigmoid).apply(null,arguments)},mE=p._Sin=function(){return(mE=p._Sin=p.asm.Sin).apply(null,arguments)},gE=p._Softmax=function(){return(gE=p._Softmax=p.asm.Softmax).apply(null,arguments)},yE=p._SparseFillEmptyRows=function(){return(yE=p._SparseFillEmptyRows=p.asm.SparseFillEmptyRows).apply(null,arguments)},AE=p._SparseReshape=function(){return(AE=p._SparseReshape=p.asm.SparseReshape).apply(null,arguments)},xE=p._SparseSegmentReduction=function(){return(xE=p._SparseSegmentReduction=p.asm.SparseSegmentReduction).apply(null,arguments)},bE=p._Sqrt=function(){return(bE=p._Sqrt=p.asm.Sqrt).apply(null,arguments)},vE=p._Square=function(){return(vE=p._Square=p.asm.Square).apply(null,arguments)},wE=p._SquaredDifference=function(){return(wE=p._SquaredDifference=p.asm.SquaredDifference).apply(null,arguments)},kE=p._Step=function(){return(kE=p._Step=p.asm.Step).apply(null,arguments)},IE=p._StridedSlice=function(){return(IE=p._StridedSlice=p.asm.StridedSlice).apply(null,arguments)},SE=p._Sub=function(){return(SE=p._Sub=p.asm.Sub).apply(null,arguments)},CE=p._Sum=function(){return(CE=p._Sum=p.asm.Sum).apply(null,arguments)},TE=p._Tan=function(){return(TE=p._Tan=p.asm.Tan).apply(null,arguments)},NE=p._Tanh=function(){return(NE=p._Tanh=p.asm.Tanh).apply(null,arguments)},EE=p._Tile=function(){return(EE=p._Tile=p.asm.Tile).apply(null,arguments)},RE=p._TopK=function(){return(RE=p._TopK=p.asm.TopK).apply(null,arguments)},$E=p._Transform=function(){return($E=p._Transform=p.asm.Transform).apply(null,arguments)},ME=p._Transpose=function(){return(ME=p._Transpose=p.asm.Transpose).apply(null,arguments)},FE=p.__FusedMatMul=function(){return(FE=p.__FusedMatMul=p.asm._FusedMatMul).apply(null,arguments)},Q2=p._malloc=function(){return(Q2=p._malloc=p.asm.malloc).apply(null,arguments)},T3=p._free=function(){return(T3=p._free=p.asm.free).apply(null,arguments)},PE=p._emscripten_tls_init=function(){return(PE=p._emscripten_tls_init=p.asm.emscripten_tls_init).apply(null,arguments)},N3=p.___errno_location=function(){return(N3=p.___errno_location=p.asm.__errno_location).apply(null,arguments)},Uc=p._pthread_self=function(){return(Uc=p._pthread_self=p.asm.pthread_self).apply(null,arguments)},E3=p._emscripten_main_thread_process_queued_calls=function(){return(E3=p._emscripten_main_thread_process_queued_calls=p.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},_E=p.__emscripten_thread_crashed=function(){return(_E=p.__emscripten_thread_crashed=p.asm._emscripten_thread_crashed).apply(null,arguments)},R3=p.__emscripten_thread_init=function(){return(R3=p.__emscripten_thread_init=p.asm._emscripten_thread_init).apply(null,arguments)},zE=p._emscripten_current_thread_process_queued_calls=function(){return(zE=p._emscripten_current_thread_process_queued_calls=p.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},OE=p._emscripten_main_browser_thread_id=function(){return(OE=p._emscripten_main_browser_thread_id=p.asm.emscripten_main_browser_thread_id).apply(null,arguments)},DE=p._emscripten_sync_run_in_main_thread_2=function(){return(DE=p._emscripten_sync_run_in_main_thread_2=p.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},$3=p._emscripten_sync_run_in_main_thread_4=function(){return($3=p._emscripten_sync_run_in_main_thread_4=p.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},M3=p._emscripten_run_in_main_runtime_thread_js=function(){return(M3=p._emscripten_run_in_main_runtime_thread_js=p.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},eg=p._emscripten_dispatch_to_thread_=function(){return(eg=p._emscripten_dispatch_to_thread_=p.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},tg=p.__emscripten_thread_free_data=function(){return(tg=p.__emscripten_thread_free_data=p.asm._emscripten_thread_free_data).apply(null,arguments)},LE=p.__emscripten_thread_exit=function(){return(LE=p.__emscripten_thread_exit=p.asm._emscripten_thread_exit).apply(null,arguments)},BE=p._memalign=function(){return(BE=p._memalign=p.asm.memalign).apply(null,arguments)},F3=p._emscripten_stack_set_limits=function(){return(F3=p._emscripten_stack_set_limits=p.asm.emscripten_stack_set_limits).apply(null,arguments)},rg=p.stackSave=function(){return(rg=p.stackSave=p.asm.stackSave).apply(null,arguments)},Gc=p.stackRestore=function(){return(Gc=p.stackRestore=p.asm.stackRestore).apply(null,arguments)},uu=p.stackAlloc=function(){return(uu=p.stackAlloc=p.asm.stackAlloc).apply(null,arguments)},WE=p.dynCall_iijjiiii=function(){return(WE=p.dynCall_iijjiiii=p.asm.dynCall_iijjiiii).apply(null,arguments)},VE=p.dynCall_jiji=function(){return(VE=p.dynCall_jiji=p.asm.dynCall_jiji).apply(null,arguments)},P3=p.__emscripten_allow_main_runtime_queued_calls=21456;p.cwrap=fr,p.keepRuntimeAlive=po,p.PThread=ze,p.PThread=ze,p.wasmMemory=Fe,p.ExitStatus=yp;var jc;function yp(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}na=function N(){jc||ng(),jc||(na=N)};function ng(N){if(N=N||y,vs>0)return;if(C){c(p),up(),postMessage({cmd:"loaded"});return}if(zr(),vs>0)return;function F(){jc||(jc=!0,p.calledRun=!0,!At&&(up(),c(p),p.onRuntimeInitialized&&p.onRuntimeInitialized(),R1()))}p.setStatus?(p.setStatus("Running..."),setTimeout(function(){setTimeout(function(){p.setStatus("")},1),F()},1)):F()}p.run=ng;function UE(N,F){if(Pr=N,!F&&C)throw Rc(N),"unwind";po()||E1(),GE(N)}function GE(N){Pr=N,po()||(ze.terminateAllThreads(),p.onExit&&p.onExit(N),At=!0),x(N,new yp(N))}if(p.preInit)for(typeof p.preInit=="function"&&(p.preInit=[p.preInit]);p.preInit.length>0;)p.preInit.pop()();ng();var Hc;f&&(Hc={uncaughtException:process.listeners("uncaughtException").filter(function(N){return!f.uncaughtException.indexOf(N)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(N){return!f.unhandledRejection.indexOf(N)>-1})});var qc;if(typeof WasmBackendModule!="undefined")qc=WasmBackendModule;else if(typeof a!="undefined")qc=a;else throw new Error("Could not find wasm module in post.js");if(Hc){var jE=qc._dispose;qc._dispose=function(){jE(),Hc.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Hc.unhandledRejection.forEach(function(N){process.removeListener("unhandledRejection",N)})}}return a.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=r:typeof define=="function"&&define.amd?define([],function(){return r}):typeof e=="object"&&(e.WasmBackendModuleThreadedSimd=r)}}),bR=pr({"src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e,t){var r=(()=>{var n=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(n=n||__filename),function(a){a=a||{};var s=typeof a!="undefined"?a:{},i,o;s.ready=new Promise(function(H,ne){i=H,o=ne});var l;typeof process!="undefined"&&process.listeners&&(l={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var u=Object.assign({},s),d=[],h="./this.program",p=(H,ne)=>{throw ne},c=typeof window=="object",m=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function y(H){return s.locateFile?s.locateFile(H,g):g+H}var A,x,b,w;function I(H){H instanceof mp||$("exiting due to exception: "+H)}var C,E,R;f?(m?g=b0().dirname(g)+"/":g=__dirname+"/",R=()=>{E||(C=xy(),E=b0())},A=function(H,ne){return R(),H=E.normalize(H),C.readFileSync(H,ne?void 0:"utf8")},b=H=>{var ne=A(H,!0);return ne.buffer||(ne=new Uint8Array(ne)),ne},x=(H,ne,ye)=>{R(),H=E.normalize(H),C.readFile(H,function(Re,lt){Re?ye(Re):ne(lt.buffer)})},process.argv.length>1&&(h=process.argv[1].replace(/\\/g,"/")),d=process.argv.slice(2),process.on("uncaughtException",function(H){if(!(H instanceof mp))throw H}),process.on("unhandledRejection",function(H){throw H}),p=(H,ne)=>{if(lp())throw process.exitCode=H,ne;I(ne),process.exit(H)},s.inspect=function(){return"[Emscripten Module object]"}):(c||m)&&(m?g=self.location.href:typeof document!="undefined"&&document.currentScript&&(g=document.currentScript.src),n&&(g=n),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",A=H=>{var ne=new XMLHttpRequest;return ne.open("GET",H,!1),ne.send(null),ne.responseText},m&&(b=H=>{var ne=new XMLHttpRequest;return ne.open("GET",H,!1),ne.responseType="arraybuffer",ne.send(null),new Uint8Array(ne.response)}),x=(H,ne,ye)=>{var Re=new XMLHttpRequest;Re.open("GET",H,!0),Re.responseType="arraybuffer",Re.onload=()=>{if(Re.status==200||Re.status==0&&Re.response){ne(Re.response);return}ye()},Re.onerror=ye,Re.send(null)},w=H=>document.title=H);var z=s.print||console.log.bind(console),$=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.arguments&&(d=s.arguments),s.thisProgram&&(h=s.thisProgram),s.quit&&(p=s.quit);var S=4;function P(H){P.shown||(P.shown={}),P.shown[H]||(P.shown[H]=1,$(H))}function O(H,ne){if(typeof WebAssembly.Function=="function"){for(var ye={i:"i32",j:"i64",f:"f32",d:"f64"},Re={parameters:[],results:ne[0]=="v"?[]:[ye[ne[0]]]},lt=1;lt{V=H},Y;s.wasmBinary&&(Y=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&uo("no native wasm support detected");var J,ae=!1,de;function be(H,ne){H||uo(ne)}function ve(H){var ne=s["_"+H];return ne}function Ee(H,ne,ye,Re,lt){var ct={string:function(en){var ws=0;if(en!=null&&en!==0){var Vc=(en.length<<2)+1;ws=fp(Vc),ht(en,ws,Vc)}return ws},array:function(en){var ws=fp(en.length);return At(en,ws),ws}};function Ke(en){return ne==="string"?ot(en):ne==="boolean"?Boolean(en):en}var He=ve(H),qt=[],aa=0;if(Re)for(var sa=0;sa=Re);)++lt;if(lt-ne>16&&H.subarray&&We)return We.decode(H.subarray(ne,lt));for(var ct="";ne>10,56320|aa&1023)}}return ct}function ot(H,ne){return H?Xe(fr,H,ne):""}function pt(H,ne,ye,Re){if(!(Re>0))return 0;for(var lt=ye,ct=ye+Re-1,Ke=0;Ke=55296&&He<=57343){var qt=H.charCodeAt(++Ke);He=65536+((He&1023)<<10)|qt&1023}if(He<=127){if(ye>=ct)break;ne[ye++]=He}else if(He<=2047){if(ye+1>=ct)break;ne[ye++]=192|He>>6,ne[ye++]=128|He&63}else if(He<=65535){if(ye+2>=ct)break;ne[ye++]=224|He>>12,ne[ye++]=128|He>>6&63,ne[ye++]=128|He&63}else{if(ye+3>=ct)break;ne[ye++]=240|He>>18,ne[ye++]=128|He>>12&63,ne[ye++]=128|He>>6&63,ne[ye++]=128|He&63}}return ne[ye]=0,ye-lt}function ht(H,ne,ye){return pt(H,fr,ne,ye)}function Fe(H){for(var ne=0,ye=0;ye=55296&&Re<=57343&&(Re=65536+((Re&1023)<<10)|H.charCodeAt(++ye)&1023),Re<=127?++ne:Re<=2047?ne+=2:Re<=65535?ne+=3:ne+=4}return ne}var wt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function At(H,ne){nr.set(H,ne)}function Pr(H,ne,ye){for(var Re=0;Re>0]=H.charCodeAt(Re);ye||(nr[ne>>0]=0)}function cr(H,ne){return H%ne>0&&(H+=ne-H%ne),H}var Jr,nr,fr,ta,Qr,ar,kn,In,As;function lo(H){Jr=H,s.HEAP8=nr=new Int8Array(H),s.HEAP16=ta=new Int16Array(H),s.HEAP32=ar=new Int32Array(H),s.HEAPU8=fr=new Uint8Array(H),s.HEAPU16=Qr=new Uint16Array(H),s.HEAPU32=kn=new Uint32Array(H),s.HEAPF32=In=new Float32Array(H),s.HEAPF64=As=new Float64Array(H)}var cc=s.INITIAL_MEMORY||16777216,xs,Ga=[],op=[],Jl=[],_r=!1,fc=!1,mc=0;function lp(){return ie||mc>0}function gc(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)xc(s.preRun.shift());dp(Ga)}function yc(){_r=!0,dp(op)}function m3(){fc=!0}function Ac(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)bc(s.postRun.shift());dp(Jl)}function xc(H){Ga.unshift(H)}function ra(H){op.unshift(H)}function bc(H){Jl.unshift(H)}var Sn=0,Ql=null,bs=null;function T1(H){Sn++,s.monitorRunDependencies&&s.monitorRunDependencies(Sn)}function vc(H){if(Sn--,s.monitorRunDependencies&&s.monitorRunDependencies(Sn),Sn==0&&(Ql!==null&&(clearInterval(Ql),Ql=null),bs)){var ne=bs;bs=null,ne()}}s.preloadedImages={},s.preloadedAudios={};function uo(H){s.onAbort&&s.onAbort(H),H="Aborted("+H+")",$(H),ae=!0,de=1,H+=". Build with -s ASSERTIONS=1 for more info.";var ne=new WebAssembly.RuntimeError(H);throw o(ne),ne}var N1="data:application/octet-stream;base64,";function wc(H){return H.startsWith(N1)}function po(H){return H.startsWith("file://")}var zr;zr="tfjs-backend-wasm.wasm",wc(zr)||(zr=y(zr));function up(H){try{if(H==zr&&Y)return new Uint8Array(Y);if(b)return b(H);throw"both async and sync fetching of the wasm failed"}catch(ne){uo(ne)}}function E1(){if(!Y&&(c||m)){if(typeof fetch=="function"&&!po(zr))return fetch(zr,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+zr+"'";return H.arrayBuffer()}).catch(function(){return up(zr)});if(x)return new Promise(function(H,ne){x(zr,function(ye){H(new Uint8Array(ye))},ne)})}return Promise.resolve().then(function(){return up(zr)})}function R1(){var H={env:ru,wasi_snapshot_preview1:ru};function ne(Ke,He){var qt=Ke.exports;s.asm=qt,J=s.asm.memory,lo(J.buffer),xs=s.asm.__indirect_function_table,ra(s.asm.__wasm_call_ctors),vc("wasm-instantiate")}T1("wasm-instantiate");function ye(Ke){ne(Ke.instance)}function Re(Ke){return E1().then(function(He){return WebAssembly.instantiate(He,H)}).then(function(He){return He}).then(Ke,function(He){$("failed to asynchronously prepare wasm: "+He),uo(He)})}function lt(){return!Y&&typeof WebAssembly.instantiateStreaming=="function"&&!wc(zr)&&!po(zr)&&typeof fetch=="function"?fetch(zr,{credentials:"same-origin"}).then(function(Ke){var He=WebAssembly.instantiateStreaming(Ke,H);return He.then(ye,function(qt){return $("wasm streaming compile failed: "+qt),$("falling back to ArrayBuffer instantiation"),Re(ye)})}):Re(ye)}if(s.instantiateWasm)try{var ct=s.instantiateWasm(H,ne);return ct}catch(Ke){return $("Module.instantiateWasm callback failed with error: "+Ke),!1}return lt().catch(o),{}}var g3,y3;function dp(H){for(;H.length>0;){var ne=H.shift();if(typeof ne=="function"){ne(s);continue}var ye=ne.func;typeof ye=="number"?ne.arg===void 0?pp(ye)():pp(ye)(ne.arg):ye(ne.arg===void 0?null:ne.arg)}}function vs(H){return H}function kc(H){var ne=/\b_Z[\w\d_]+/g;return H.replace(ne,function(ye){var Re=ye;return ye===Re?ye:Re+" ["+ye+"]"})}var na=[];function pp(H){var ne=na[H];return ne||(H>=na.length&&(na.length=H+1),na[H]=ne=xs.get(H)),ne}function A3(){var H=new Error;if(!H.stack){try{throw new Error}catch(ne){H=ne}if(!H.stack)return"(no stack trace available)"}return H.stack.toString()}function eu(H,ne){xs.set(H,ne),na[H]=ne}function $1(){uo("")}function Ic(H,ne,ye){fr.copyWithin(H,ne,ne+ye)}function Sc(){return 2147483648}function Or(H){try{return J.grow(H-Jr.byteLength+65535>>>16),lo(J.buffer),1}catch(ne){}}function Cc(H){var ne=fr.length;H=H>>>0;var ye=Sc();if(H>ye)return!1;for(var Re=1;Re<=4;Re*=2){var lt=ne*(1+.2/Re);lt=Math.min(lt,H+100663296);var ct=Math.min(ye,cr(Math.max(H,lt),65536)),Ke=Or(ct);if(Ke)return!0}return!1}var tu={mappings:{},buffers:[null,[],[]],printChar:function(H,ne){var ye=tu.buffers[H];ne===0||ne===10?((H===1?z:$)(Xe(ye,0)),ye.length=0):ye.push(ne)},varargs:void 0,get:function(){tu.varargs+=4;var H=ar[tu.varargs-4>>2];return H},getStr:function(H){var ne=ot(H);return ne},get64:function(H,ne){return H}};function M1(H){return 0}function x3(H,ne,ye,Re,lt){}function b3(H,ne,ye,Re){for(var lt=0,ct=0;ct>2],He=ar[ne+4>>2];ne+=8;for(var qt=0;qt>2]=lt,0}function F1(H){re(H)}var Tc=!1,ru={abort:$1,emscripten_memcpy_big:Ic,emscripten_resize_heap:Cc,fd_close:M1,fd_seek:x3,fd_write:b3,setTempRet0:F1},eE=R1(),v3=s.___wasm_call_ctors=function(){return(v3=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},P1=s._init=function(){return(P1=s._init=s.asm.init).apply(null,arguments)},_1=s._init_with_threads_count=function(){return(_1=s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},Nc=s._get_threads_count=function(){return(Nc=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},Ec=s._register_tensor=function(){return(Ec=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},z1=s._dispose_data=function(){return(z1=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},ze=s._dispose=function(){return(ze=s._dispose=s.asm.dispose).apply(null,arguments)},O1=s._Abs=function(){return(O1=s._Abs=s.asm.Abs).apply(null,arguments)},Rc=s._Add=function(){return(Rc=s._Add=s.asm.Add).apply(null,arguments)},ho=s._AddN=function(){return(ho=s._AddN=s.asm.AddN).apply(null,arguments)},nu=s._All=function(){return(nu=s._All=s.asm.All).apply(null,arguments)},D1=s._Any=function(){return(D1=s._Any=s.asm.Any).apply(null,arguments)},w3=s._ArgMax=function(){return(w3=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},L1=s._AvgPool=function(){return(L1=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},k3=s._BatchMatMul=function(){return(k3=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},co=s._Ceil=function(){return(co=s._Ceil=s.asm.Ceil).apply(null,arguments)},B1=s._ClipByValue=function(){return(B1=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},W1=s._Conv2D=function(){return(W1=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},V1=s._Conv2DBackpropInput=function(){return(V1=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},U1=s._Cos=function(){return(U1=s._Cos=s.asm.Cos).apply(null,arguments)},G1=s._Cosh=function(){return(G1=s._Cosh=s.asm.Cosh).apply(null,arguments)},j1=s._CropAndResize=function(){return(j1=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},$c=s._Cumprod=function(){return($c=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},H1=s._Cumsum=function(){return(H1=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},q1=s._DepthToSpace=function(){return(q1=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},X1=s._DepthwiseConv2dNative=function(){return(X1=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},K1=s._Elu=function(){return(K1=s._Elu=s.asm.Elu).apply(null,arguments)},Z1=s._Equal=function(){return(Z1=s._Equal=s.asm.Equal).apply(null,arguments)},Mc=s._Exp=function(){return(Mc=s._Exp=s.asm.Exp).apply(null,arguments)},Y1=s._FlipLeftRight=function(){return(Y1=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},J1=s._Floor=function(){return(J1=s._Floor=s.asm.Floor).apply(null,arguments)},fo=s._FloorDiv=function(){return(fo=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},hp=s._FusedBatchNorm=function(){return(hp=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},Q1=s._FusedConv2D=function(){return(Q1=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},e2=s._FusedDepthwiseConv2D=function(){return(e2=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},t2=s._Gather=function(){return(t2=s._Gather=s.asm.Gather).apply(null,arguments)},qe=s._GatherNd=function(){return(qe=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},r2=s._Greater=function(){return(r2=s._Greater=s.asm.Greater).apply(null,arguments)},n2=s._GreaterEqual=function(){return(n2=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},a2=s._LeakyRelu=function(){return(a2=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},s2=s._Less=function(){return(s2=s._Less=s.asm.Less).apply(null,arguments)},i2=s._LessEqual=function(){return(i2=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},o2=s._Log=function(){return(o2=s._Log=s.asm.Log).apply(null,arguments)},cp=s._LogicalAnd=function(){return(cp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Fc=s._Max=function(){return(Fc=s._Max=s.asm.Max).apply(null,arguments)},Pc=s._MaxPool=function(){return(Pc=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},l2=s._Maximum=function(){return(l2=s._Maximum=s.asm.Maximum).apply(null,arguments)},u2=s._Mean=function(){return(u2=s._Mean=s.asm.Mean).apply(null,arguments)},d2=s._Min=function(){return(d2=s._Min=s.asm.Min).apply(null,arguments)},p2=s._Minimum=function(){return(p2=s._Minimum=s.asm.Minimum).apply(null,arguments)},h2=s._MirrorPad=function(){return(h2=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},c2=s._Multiply=function(){return(c2=s._Multiply=s.asm.Multiply).apply(null,arguments)},Pt=s._Neg=function(){return(Pt=s._Neg=s.asm.Neg).apply(null,arguments)},f2=s._NonMaxSuppressionV3=function(){return(f2=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},m2=s._NonMaxSuppressionV4=function(){return(m2=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},g2=s._NonMaxSuppressionV5=function(){return(g2=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},au=s._NotEqual=function(){return(au=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},_c=s._OneHot=function(){return(_c=s._OneHot=s.asm.OneHot).apply(null,arguments)},zc=s._PadV2=function(){return(zc=s._PadV2=s.asm.PadV2).apply(null,arguments)},Oc=s._Pow=function(){return(Oc=s._Pow=s.asm.Pow).apply(null,arguments)},y2=s._Prelu=function(){return(y2=s._Prelu=s.asm.Prelu).apply(null,arguments)},Dc=s._Prod=function(){return(Dc=s._Prod=s.asm.Prod).apply(null,arguments)},A2=s._RealDiv=function(){return(A2=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},I3=s._Relu=function(){return(I3=s._Relu=s.asm.Relu).apply(null,arguments)},Lc=s._Relu6=function(){return(Lc=s._Relu6=s.asm.Relu6).apply(null,arguments)},S3=s._ResizeBilinear=function(){return(S3=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},x2=s._Reverse=function(){return(x2=s._Reverse=s.asm.Reverse).apply(null,arguments)},b2=s._RotateWithOffset=function(){return(b2=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},v2=s._Round=function(){return(v2=s._Round=s.asm.Round).apply(null,arguments)},w2=s._Rsqrt=function(){return(w2=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},k2=s._ScatterNd=function(){return(k2=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},I2=s._SelectV2=function(){return(I2=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},S2=s._Sigmoid=function(){return(S2=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},C2=s._Sin=function(){return(C2=s._Sin=s.asm.Sin).apply(null,arguments)},T2=s._Softmax=function(){return(T2=s._Softmax=s.asm.Softmax).apply(null,arguments)},N2=s._SparseFillEmptyRows=function(){return(N2=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},E2=s._SparseReshape=function(){return(E2=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},R2=s._SparseSegmentReduction=function(){return(R2=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},$2=s._Sqrt=function(){return($2=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},M2=s._Square=function(){return(M2=s._Square=s.asm.Square).apply(null,arguments)},F2=s._SquaredDifference=function(){return(F2=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},P2=s._Step=function(){return(P2=s._Step=s.asm.Step).apply(null,arguments)},_2=s._StridedSlice=function(){return(_2=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},z2=s._Sub=function(){return(z2=s._Sub=s.asm.Sub).apply(null,arguments)},O2=s._Sum=function(){return(O2=s._Sum=s.asm.Sum).apply(null,arguments)},D2=s._Tan=function(){return(D2=s._Tan=s.asm.Tan).apply(null,arguments)},L2=s._Tanh=function(){return(L2=s._Tanh=s.asm.Tanh).apply(null,arguments)},B2=s._Tile=function(){return(B2=s._Tile=s.asm.Tile).apply(null,arguments)},W2=s._TopK=function(){return(W2=s._TopK=s.asm.TopK).apply(null,arguments)},V2=s._Transform=function(){return(V2=s._Transform=s.asm.Transform).apply(null,arguments)},U2=s._Transpose=function(){return(U2=s._Transpose=s.asm.Transpose).apply(null,arguments)},G2=s.__FusedMatMul=function(){return(G2=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},j2=s._malloc=function(){return(j2=s._malloc=s.asm.malloc).apply(null,arguments)},H2=s._free=function(){return(H2=s._free=s.asm.free).apply(null,arguments)},q2=s.___errno_location=function(){return(q2=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},X2=s._emscripten_main_thread_process_queued_calls=function(){return(X2=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Bc=s.stackSave=function(){return(Bc=s.stackSave=s.asm.stackSave).apply(null,arguments)},Wc=s.stackRestore=function(){return(Wc=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},fp=s.stackAlloc=function(){return(fp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},K2=s.dynCall_iijjiiii=function(){return(K2=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},Z2=s.dynCall_jiji=function(){return(Z2=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=$e;var su;function mp(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}bs=function H(){su||gp(),su||(bs=H)};function gp(H){if(H=H||d,Sn>0||(gc(),Sn>0))return;function ne(){su||(su=!0,s.calledRun=!0,!ae&&(yc(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),Ac()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),ne()},1)):ne()}s.run=gp;function C3(H){de=H,lp()||(s.onExit&&s.onExit(H),ae=!0),p(H,new mp(H))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();gp();var iu;l&&(iu={uncaughtException:process.listeners("uncaughtException").filter(function(H){return!l.uncaughtException.indexOf(H)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(H){return!l.unhandledRejection.indexOf(H)>-1})});var ou;if(typeof a!="undefined")ou=a;else if(typeof WasmBackendModuleThreadedSimd!="undefined")ou=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(iu){var Y2=ou._dispose;ou._dispose=function(){Y2(),iu.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),iu.unhandledRejection.forEach(function(H){process.removeListener("unhandledRejection",H)})}}return a.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=r:typeof define=="function"&&define.amd?define([],function(){return r}):typeof e=="object"&&(e.WasmBackendModule=r)}}),vR=1e-7,wR=1e-4,eh=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}},Wu=class{refCount(e){return Tn("refCount")}incRef(e){return Tn("incRef")}timerAvailable(){return!0}time(e){return Tn("time")}read(e){return Tn("read")}readSync(e){return Tn("readSync")}readToGPU(e,t){return Tn("readToGPU")}numDataIds(){return Tn("numDataIds")}disposeData(e,t){return Tn("disposeData")}write(e,t,r){return Tn("write")}move(e,t,r,n,a){return Tn("move")}memory(){return Tn("memory")}floatPrecision(){return Tn("floatPrecision")}epsilon(){return this.floatPrecision()===32?vR:wR}dispose(){return Tn("dispose")}};function Tn(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 Tv(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,t--,v0(e,t,r)}function kR(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 r=e.length,n=0;for(;r>0;)n=Math.random()*r|0,r--,v0(e,r,n),v0(t,r,n)}function Wp(e,t,r){return Math.max(e,Math.min(t,r))}function IR(e){return e%2===0?e:e+1}function v0(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function SR(e){let t=0;for(let r=0;rr+` Shapes ${e} and ${t} must match`)}function Go(e){_(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Mo(e,t=[],r=!1){if(t==null&&(t=[]),Array.isArray(e)||Sr(e)&&!r)for(let n=0;n0,r){return new Promise((n,a)=>{let s=0,i=()=>{if(e()){n();return}s++;let o=t(s);if(r!=null&&s>=r){a();return}setTimeout(i,o)};i()})}function FR(e,t){let r=1,n=-1;for(let s=0;s=0)r*=e[s];else if(e[s]===-1){if(n!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${s}`);n=s}else if(e[s]<0)throw Error(`Shapes can not be < 0. Found ${e[s]} at dim ${s}`);if(n===-1){if(t>0&&t!==r)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(r===0)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%r!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${r}`);let a=e.slice();return a[n]=t/r,a}function Hn(e,t){let r=t.length;return e=e==null?t.map((n,a)=>a):[].concat(e),_(e.every(n=>n>=-r&&n`All values in axis param must be in range [-${r}, ${r}) but got axis ${e}`),_(e.every(n=>Su(n)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(n=>n<0?r+n:n)}function Nv(e,t){let r=[],n=[],a=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||a?null:Hn(t,e).sort(),i=0;for(let o=0;oo)&&e[o]===1&&(r.push(e[o]),n.push(o)),s[i]<=o&&i++}e[o]!==1&&(r.push(e[o]),n.push(o))}return{newShape:r,keptDims:n}}function Ev(e,t){let r=null;if(e==null||e==="float32")r=new Float32Array(t);else if(e==="int32")r=new Int32Array(t);else if(e==="bool")r=new Uint8Array(t);else throw new Error(`Unknown data type ${e}`);return r}function Rv(e,t){let r=null;if(e==null||e==="float32")r=new Float32Array(t);else if(e==="int32")r=new Int32Array(t);else if(e==="bool")r=new Uint8Array(t);else if(e==="string")r=new Array(t);else throw new Error(`Unknown data type ${e}`);return r}function $v(e,t){for(let r=0;rt+=r.length),t}function Es(e){return typeof e=="string"||e instanceof String}function Pv(e){return typeof e=="boolean"}function _v(e){return typeof e=="number"}function tf(e){return Array.isArray(e)?tf(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":_v(e)?"float32":Es(e)?"string":Pv(e)?"bool":"float32"}function _s(e){return!!(e&&e.constructor&&e.call&&e.apply)}function w0(e,t){for(let r=t;r=0;--n)r[n]=r[n+1]*e[n+1];return r}function zv(e,t,r,n=!1){let a=new Array;if(t.length===1){let s=t[0]*(n?2:1);for(let i=0;il*u)*(n?2:1);for(let l=0;la*s)*(r?2:1);if(n===0)return[];if(n!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${r?" for a complex tensor":""}.`);return zv(0,e,t,r)}function by(e,t){let r=rf(e,t);for(let n=0;nn*a,1);if(t==null||t==="float32")return bu(e,new Float32Array(r));if(t==="int32")return bu(e,new Int32Array(r));if(t==="bool")return bu(e,new Uint8Array(r));throw new Error(`Unknown data type ${t}`)}function vy(e){e.forEach(t=>{_(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function zR(e,t,r){if(t===0)return 0;if(t===1)return e[0];let n=e[e.length-1];for(let a=0;a{let[r,n]=t.split(":");this.urlFlags[r]=BR(r,n)})}};function DR(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(r,...n)=>(LR(t,n[0],n[1]),n.join("="))),t}function LR(e,t,r){e[decodeURIComponent(t)]=decodeURIComponent(r||"")}function BR(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 Z(){return ba}var ba=null;function WR(e){ba=e}var sg;function Dv(){if(sg==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");sg=e}return sg}function VR(){let e=Dv();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function ky(e,t){let r=VR();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}var jo="Abs",Uu="Acos",Gu="Acosh",es="Add",Ys="AddN",ju="All",Hu="Any",Js="ArgMax",qu="ArgMin",Xu="Asin",Ku="Asinh",Zu="Atan",Yu="Atanh",Ju="Atan2",Qs="AvgPool",nf="AvgPoolGrad",th="AvgPool3D",af="AvgPool3DGrad",ei="BatchMatMul",Ho="BatchToSpaceND",sf="Bincount",Lv="BroadcastTo",of="BroadcastArgs",ti="Cast",ri="Ceil",ts="ClipByValue",rh="Complex",nh="ComplexAbs",qo="Concat",ni="Conv2D",lf="Conv2DBackpropFilter",ai="Conv2DBackpropInput",ah="Conv3D",uf="Conv3DBackpropFilterV2",df="Conv3DBackpropInputV2",si="Cos",ii="Cosh",Xo="Cumprod",oi="Cumsum",Ko="CropAndResize",pf="DenseBincount",Zo="DepthToSpace",li="DepthwiseConv2dNative",hf="DepthwiseConv2dNativeBackpropFilter",cf="DepthwiseConv2dNativeBackpropInput",ff="Diag",sh="Dilation2D",k0="Dilation2DBackpropInput",I0="Dilation2DBackpropFilter",ui="RealDiv",ih="Einsum",di="Elu",mf="EluGrad",Qu="Erf",Yo="Equal",pi="Exp",Jo="ExpandDims",Qo="Expm1",gf="FFT",ed="Fill",el="FlipLeftRight",hi="Floor",ci="FloorDiv",fi="FusedBatchNorm",tl="GatherV2",rl="GatherNd",nl="Greater",mi="GreaterEqual",gi="Identity",yf="IFFT",oh="Imag",td="IsFinite",rd="IsInf",nd="IsNan",yi="LeakyRelu",al="Less",sl="LessEqual",Af="LinSpace",Ai="Log",ad="Log1p",il="LogicalAnd",sd="LogicalNot",lh="LogicalOr",Bv="LogSoftmax",UR="LowerBound",uh="LRN",xf="LRNGrad",xi="Max",bi="Maximum",vi="MaxPool",bf="MaxPoolGrad",dh="MaxPool3D",vf="MaxPool3DGrad",wf="MaxPoolWithArgmax",wi="Mean",ki="Min",Ii="Minimum",Si="MirrorPad",id="Mod",kf="Multinomial",Ci="Multiply",ol="Neg",ll="NotEqual",ul="NonMaxSuppressionV3",od="NonMaxSuppressionV4",dl="NonMaxSuppressionV5",pl="OnesLike",hl="OneHot",cl="Pack",Ti="PadV2",GR="Pool",Ni="Pow",Ei="Prelu",Ri="Prod",ld="Range",ph="Real",ud="Reciprocal",$i="Relu",fl="Reshape",dd="ResizeNearestNeighbor",If="ResizeNearestNeighborGrad",Mi="ResizeBilinear",Sf="ResizeBilinearGrad",Fi="Relu6",ml="Reverse",gl="Round",Pi="Rsqrt",yl="ScatterNd",Cf="SearchSorted",Al="Select",pd="Selu",xl="Slice",_i="Sin",bl="Sinh",hd="Sign",zi="Sigmoid",cd="Softplus",Oi="Sqrt",Di="Sum",vl="SpaceToBatchND",wl="SplitV",Li="Softmax",hh="SparseFillEmptyRows",fd="SparseReshape",ch="SparseSegmentMean",fh="SparseSegmentSum",mh="SparseToDense",Bi="SquaredDifference",md="Square",kl="StridedSlice",gh="StringNGrams",Tf="StringSplit",Nf="StringToHashBucketFast",Wi="Sub",Il="Tan",Vi="Tanh",rs="Tile",Sl="TopK",Cl="Transform",$a="Transpose",Ef="Unique",Tl="Unpack",yh="UnsortedSegmentSum",jR="UpperBound",Nl="ZerosLike",Ui="Step",Vp="FromPixels",El="RotateWithOffset",zs="_FusedMatMul",Os="FusedConv2D",Ds="FusedDepthwiseConv2D";function Ns(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.warn(...e)}function HR(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.log(...e)}var Cu=ky("kernelRegistry",()=>new Map),Up=ky("gradRegistry",()=>new Map);function S0(e,t){let r=Iy(e,t);return Cu.get(r)}function bg(e){return Up.get(e)}function Fa(e){let t=Cu.entries(),r=[];for(;;){let{done:n,value:a}=t.next();if(n)break;let[s,i]=a,[o]=s.split("_");o===e&&r.push(i)}return r}function qn(e){let{kernelName:t,backendName:r}=e,n=Iy(t,r);Cu.has(n)&&Ns(`The kernel '${t}' for backend '${r}' is already registered`),Cu.set(n,e)}function Wv(e){let{kernelName:t}=e;Up.has(t)&&Z().getBool("DEBUG")&&Ns(`Overriding the gradient for '${t}'`),Up.set(t,e)}function qR(e,t){let r=Iy(e,t);if(!Cu.has(r))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Cu.delete(r)}function XR(e){if(!Up.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Up.delete(e)}function KR(e,t){Fa(e).forEach(r=>{let n=Object.assign({},r,{backendName:t});qn(n)})}function Iy(e,t){return`${t}_${e}`}var v={};Be(v,{arraysEqual:()=>Zs,assert:()=>_,assertNonNegativeIntegerDimensions:()=>vy,assertNonNull:()=>Go,assertShapesMatch:()=>Ur,bytesFromStringArray:()=>Fv,bytesPerElement:()=>xg,checkConversionForErrors:()=>$v,clamp:()=>Wp,computeStrides:()=>Vu,createScalarValue:()=>t$,createShuffledIndices:()=>$R,decodeString:()=>C0,distSquared:()=>TR,encodeString:()=>xh,fetch:()=>n$,fingerPrint64:()=>e$,flatten:()=>Mo,getArrayFromDType:()=>Rv,getTypedArrayFromDType:()=>Ev,hasEncodingLoss:()=>PR,hexToLong:()=>Ah,indexToLoc:()=>OR,inferDtype:()=>tf,inferFromImplicitShape:()=>FR,isBoolean:()=>Pv,isFunction:()=>_s,isInt:()=>Su,isNumber:()=>_v,isPromise:()=>wy,isScalarShape:()=>NR,isString:()=>Es,isTypedArray:()=>Sr,isValidDtype:()=>Mv,locToIndex:()=>zR,makeOnesTypedArray:()=>by,makeZerosNestedTypedArray:()=>_R,makeZerosTypedArray:()=>rf,nearestDivisor:()=>w0,nearestLargerEven:()=>IR,now:()=>Gp,parseAxisParam:()=>Hn,randUniform:()=>CR,repeatedTry:()=>MR,rightPad:()=>zp,shuffle:()=>Tv,shuffleCombo:()=>kR,sizeFromShape:()=>It,sizeToSquarishShape:()=>RR,squeezeShape:()=>Nv,sum:()=>SR,swap:()=>v0,tanh:()=>ER,toNestedArray:()=>bu,toTypedArray:()=>Rf});var L3=Uo(sR()),vo=L3.default||L3;function Ah(e){return vo.fromString(e,!0,16)}var Vv=Ah("c3a5c85c97cb3127"),Ao=Ah("b492b66fbe98f273"),Dr=Ah("9ae16a3b2f90404f");function vg(e){return e.xor(e.shru(47))}function Uv(e,t,r){let n=e.slice(t,t+r);return vo.fromBytes(Array.from(n),!0,!0)}function kt(e,t){return Uv(e,t,8)}function B3(e,t){return Uv(e,t,4)}function mr(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function $s(e,t,r=Ah("9ddfea08eb382d69")){let n=e.xor(t).mul(r);n=n.xor(n.shru(47));let a=t.xor(n).mul(r);return a=a.xor(a.shru(47)),a=a.mul(r),a}function ZR(e,t,r,n,a,s){a=a.add(e),s=mr(s.add(a).add(n),21);let i=a;return a=a.add(t),a=a.add(r),s=s.add(mr(a,44)),[a.add(n),s.add(i)]}function Zc(e,t,r,n){return ZR(kt(e,t),kt(e,t+8),kt(e,t+16),kt(e,t+24),r,n)}function YR(e,t=e.length){if(t>=8){let r=Dr.add(t*2),n=kt(e,0).add(Dr),a=kt(e,t-8),s=mr(a,37).mul(r).add(n),i=mr(n,25).add(a).mul(r);return $s(s,i,r)}if(t>=4){let r=Dr.add(t*2),n=B3(e,0);return $s(n.shl(3).add(t),B3(e,t-4),r)}if(t>0){let r=e[0],n=e[t>>1],a=e[t-1],s=r+(n<<8),i=t+(a<<2);return vg(Dr.mul(s).xor(Vv.mul(i))).mul(Dr)}return Dr}function JR(e,t=e.length){let r=Dr.add(t*2),n=kt(e,0).mul(Ao),a=kt(e,8),s=kt(e,t-8).mul(r),i=kt(e,t-16).mul(Dr);return $s(mr(n.add(a),43).add(mr(s,30)).add(i),n.add(mr(a.add(Dr),18)).add(s),r)}function QR(e,t=e.length){let r=Dr.add(t*2),n=kt(e,0).mul(Dr),a=kt(e,8),s=kt(e,t-8).mul(r),i=kt(e,t-16).mul(Dr),o=mr(n.add(a),43).add(mr(s,30)).add(i),l=$s(o,n.add(mr(a.add(Dr),18)).add(s),r),u=kt(e,16).mul(r),d=kt(e,24),h=o.add(kt(e,t-32)).mul(r),p=l.add(kt(e,t-24)).mul(r);return $s(mr(u.add(d),43).add(mr(h,30)).add(p),u.add(mr(d.add(n),18)).add(h),r)}function e$(e,t=e.length){let r=vo.fromNumber(81,!0);if(t<=32)return t<=16?YR(e,t):JR(e,t);if(t<=64)return QR(e,t);let n=r,a=r.mul(Ao).add(113),s=vg(a.mul(Dr).add(113)).mul(Dr),i=[vo.UZERO,vo.UZERO],o=[vo.UZERO,vo.UZERO];n=n.mul(Dr).add(kt(e,0));let l=0,u=(t-1>>6)*64,d=u+(t-1&63)-63;do n=mr(n.add(a).add(i[0]).add(kt(e,l+8)),37).mul(Ao),a=mr(a.add(i[1]).add(kt(e,l+48)),42).mul(Ao),n=n.xor(o[1]),a=a.add(i[0]).add(kt(e,l+40)),s=mr(s.add(o[0]),33).mul(Ao),i=Zc(e,l,i[1].mul(Ao),n.add(o[0])),o=Zc(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],l+=64;while(l!==u);let h=Ao.add(s.and(255).shl(1));return l=d,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),n=mr(n.add(a).add(i[0]).add(kt(e,l+8)),37).mul(h),a=mr(a.add(i[1]).add(kt(e,l+48)),42).mul(h),n=n.xor(o[1].mul(9)),a=a.add(i[0].mul(9).add(kt(e,l+40))),s=mr(s.add(o[0]),33).mul(h),i=Zc(e,l,i[1].mul(h),n.add(o[0])),o=Zc(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],$s($s(i[0],o[0],h).add(vg(a).mul(Vv)).add(s),$s(i[1],o[1],h).add(n),h)}function t$(e,t){return t==="string"?xh(e):Rf([e],t)}function r$(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Rf(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Mo(e)),Z().getBool("DEBUG")&&$v(e,t),r$(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 r=new Uint8Array(e.length);for(let n=0;n{n=r()},s,i=Gp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(a);else{a();for(let o of n)o.dataSync();s=Promise.resolve({kernelMs:Gp()-i})}if(Z().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{s$(u,l.dtype,e)})}return{kernelName:e,outputs:n,inputs:t,timeMs:s.then(o=>o.kernelMs),extraInfo:s.then(o=>o.getExtraProfileInfo!=null?o.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:r,timeMs:n,inputs:a,extraInfo:s}=e;r.forEach(i=>{Promise.all([i.data(),n,s]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],a,o[2])})})}};function s$(e,t,r){if(t!=="float32")return!1;for(let n=0;n0?m:""} `}}console.log(`%c${o} %c${i} %c${l}D ${d} %c${u} %c${h} %c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function o$(e,t,r){let n={},a={};for(let l=0;ln[f.id]=!0),c=!0,a[u.id]=!0;break}if(c)break}}let s={};s[r.id]=!0;let i={};for(let l=e.length-1;l>=0;l--){let u=e[l],d=u.inputs;for(let h=0;h=0;a--){let s=t[a],i=[];if(s.outputs.forEach(l=>{let u=e[l.id];u!=null?i.push(u):i.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let o=s.gradient(i);for(let l in s.inputs){if(!(l in o))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(o)}.`);let u=r(()=>o[l]());if(u.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`);let d=s.inputs[l];if(!Zs(u.shape,d.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${d.shape}'`);if(e[d.id]==null)e[d.id]=u;else{let h=e[d.id];e[d.id]=n(h,u),h.dispose()}}}}var W3=20,wp=3,ig=7;function u$(e,t,r,n){let a=Vu(t),s=d$(e,t,r,a),i=t.length,o=l0(e,t,r,a,s),l=["Tensor"];return n&&(l.push(` dtype: ${r}`),l.push(` rank: ${i}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(o.map(u=>" "+u).join(` `)),l.join(` `)}function d$(e,t,r,n){let a=It(t),s=n[n.length-1],i=new Array(s).fill(0),o=t.length,l=r==="complex64"?Tp(e):e;if(o>1)for(let u=0;uW3){let g=wp*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-wp)*i,o*i));return r==="complex64"&&(y=Tp(y),A=Tp(A)),["["+y.map((x,b)=>Cp(x,a[b],r)).join(", ")+", ..., "+A.map((x,b)=>Cp(x,a[o-wp+b],r)).join(", ")+"]"]}let f=r==="complex64"?Tp(e):Array.from(e);return["["+f.map((g,y)=>Cp(g,a[y],r)).join(", ")+"]"]}let u=t.slice(1),d=n.slice(1),h=n[0]*i,p=[];if(o>W3){for(let f=0;f`Length of values '${n}' 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=r||Rv(t,this.size),this.strides=Vu(e)}set(e,...t){t.length===0&&(t=[0]),_(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let r=this.locToIndex(t);this.values[r]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let n of e){if(n<0||n>=this.shape[t]){let a=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(a)}t++}let r=e[e.length-1];for(let n=0;nC0(r))}catch(r){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(),la().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=la().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>C0(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 la().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(la().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return gu.print(this,e)}clone(){return this.throwIfDisposed(),gu.clone(this)}toString(e=!1){let t=this.dataSync();return u$(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),gu.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),la().makeVariable(this,e,t,r)}};Object.defineProperty(nt,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function m$(){return ky("Tensor",()=>nt)}m$();var jp=class extends nt{constructor(e,t,r,n){super(e.shape,e.dtype,e.dataId,n),this.trainable=t,this.name=r}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(!Zs(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);la().disposeTensor(this),this.dataId=e.dataId,la().incRef(this,null)}dispose(){la().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(jp,Symbol.hasInstance,{value:e=>e instanceof nt&&e.assign!=null&&e.assign instanceof Function});var ha={};Be(ha,{assertTypesMatch:()=>Zv,getTensorsInContainer:()=>Sy,isTensorInList:()=>y$,makeTypesMatch:()=>Lt});var jv=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(jv||{}),Hv=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(Hv||{}),qv=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(qv||{}),Xv=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(Xv||{}),Kv=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(Kv||{}),g$={float32:Xv,int32:Hv,bool:qv,complex64:Kv};function Nr(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return g$[e][t]}function bh(e){return Nr(e,"int32")}function Lt(e,t){if(e.dtype===t.dtype)return[e,t];let r=Nr(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function Zv(e,t){_(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function y$(e,t){return t.some(r=>r.id===e.id)}function Sy(e){let t=[];return Yv(e,t,new Set),t}function Yv(e,t,r){if(e==null)return;if(e instanceof nt){t.push(e);return}if(!A$(e))return;let n=e;for(let a in n){let s=n[a];r.has(s)||(r.add(s),Yv(s,t,r))}}function A$(e){return Array.isArray(e)||typeof e=="object"}function og(e){return e.kernelName!=null}var V3=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()}},wg=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new V3}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t{e.setupFunc!=null&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Fa(e).forEach(t=>{t.disposeFunc!=null&&t.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 r=t.factory();if(r&&!(r instanceof Wu)&&typeof r.then=="function"){let n=++this.pendingBackendInitId,a=r.then(s=>n(nthis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.startScope(r),()=>this.endScope(n),()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n))}scopedRun(e,t,r){e();try{let n=r();return t(),n}catch(n){throw t(),n}}nextTensorId(){return wg.nextTensorId++}nextVariableId(){return wg.nextVariableId++}clone(e){let t=B.runKernel(gi,{x:e}),r={x:e},n=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return B.runKernel(ti,o,l)}}),a=[];return this.addTapeNode(this.state.activeScope.name,r,[t],n,a,{}),t}runKernel(e,t,r){if(this.backendName==null&&this.backend,S0(e,this.backendName)==null)throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:r})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,r){let n=this.backend.numDataIds(),a=0;r.forEach(o=>{a+=o.dtype==="complex64"?3:1});let s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=n-t-a-s;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,r=[],n=this.isTapeOn(),a=this.state.numBytes,s=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,l=og(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(og(e)){let{kernelName:c,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=S0(c,this.backendName);_(g!=null,()=>`Cannot find registered kernel '${c}' for backend '${this.backendName}'`),i=()=>{let y=this.backend.numDataIds();o=g.kernelFunc({inputs:m,attrs:f,backend:this.backend});let A=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,y,A);let x=A.map(b=>b.rank!=null?b:this.makeTensorFromTensorInfo(b));if(n){let b=this.getTensorsForGradient(c,m,x);r=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:c}=e,m=f=>{!n||(r=f.map(g=>this.keep(this.clone(g))))};i=()=>{let f=this.backend.numDataIds();o=this.tidy(()=>c(this.backend,m));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,f,g),g}}let{inputs:u,attrs:d}=e,h=og(e)?null:e.backwardsFunc,p;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(p=this.profiler.profileKernel(l,u,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs)}),n&&this.addTapeNode(l,u,t,h,r,d),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(c=>u[c]!=null?u[c].shape:null),outputShapes:t.map(c=>c.shape),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(t=>this.keep(this.clone(t)))}getTensorsForGradient(e,t,r){let n=bg(e);if(n!=null){let a=n.inputsToSave||[],s=n.outputsToSave||[],i;n.saveAllInputs?(_(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(l=>t[l])):i=a.map(l=>t[l]);let o=r.filter((l,u)=>s[u]);return i.concat(o)}return[]}makeTensor(e,t,r,n){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");r=r||"float32",n=n||this.backend;let a=e;r==="string"&&Es(e[0])&&(a=e.map(o=>xh(o)));let s=n.write(a,t,r),i=new nt(t,r,s,this.nextTensorId());if(this.trackTensor(i,n),r==="string"){let o=this.state.tensorInfo.get(s),l=Fv(a);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,r,n){r=r||"float32";let a={dataId:e,shape:t,dtype:r};return this.makeTensorFromTensorInfo(a,n)}makeTensorFromTensorInfo(e,t){let{dataId:r,shape:n,dtype:a}=e,s=new nt(n,a,r,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,r,n){r=r||this.nextVariableId().toString(),n!=null&&n!==e.dtype&&(e=e.cast(n));let a=new jp(e,t,r,this.nextTensorId());if(this.state.registeredVariables[a.name]!=null)throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let r=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(r=e.size*xg(e.dtype)),this.state.numBytes+=r,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:r})),e instanceof jp||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 r=e.size*xg(e.dtype);this.state.numBytes-=r}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,r=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(n=>n.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r;for(let n of this.state.activeProfile.kernels)n.kernelTimeMs=await n.kernelTimeMs,n.extraInfo=await n.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,r,n,a,s){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:a},o=bg(e);o!=null&&(n=o.gradFunc),n!=null&&(i.gradient=l=>(l=l.map((u,d)=>{if(u==null){let h=r[d],p=rf(h.size,h.dtype);return this.makeTensor(p,h.shape,h.dtype)}return u}),n(l.length>1?l:l[0],a,s))),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=Sy(e),r=new Set(t.map(a=>a.id));for(let a=0;a{!a.kept&&a.scopeId===n.id&&this.track(a)})}gradients(e,t,r,n=!1){if(_(t.length>0,()=>"gradients() received an empty list of xs."),r!=null&&r.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${r.dtype}'`);let a=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));_(a instanceof nt,()=>"The result y returned by f() must be a tensor.");let s=o$(this.state.activeTape,t,a);if(!n&&s.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[a.id]=r==null?x$(a.shape):r,l$(i,s,l=>this.tidy(l),b$);let o=t.map(l=>i[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let u of l.saved)u.dispose()}),this.state.activeTape=null),{value:a,grads:o}})}customGrad(e){return _(_s(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{_(t.every(i=>i instanceof nt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let r,n={};t.forEach((i,o)=>{n[o]=i});let a=(i,o)=>(r=e(...t,o),_(r.value instanceof nt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),_(_s(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),s=(i,o)=>{let l=r.gradFunc(i,o),u=Array.isArray(l)?l:[l];_(u.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(...)."),_(u.every(h=>h instanceof nt),()=>"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 d={};return u.forEach((h,p)=>{d[p]=()=>h}),d};return this.runKernelFunc({forwardFunc:a,backwardsFunc:s,inputs:n})}}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=Gp(),r=await this.backend.time(e);return r.wallMs=Gp()-t,r}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 V3;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}},Cy=wg;Cy.nextTensorId=0;Cy.nextVariableId=0;function x$(e){let t=by(It(e),"float32");return B.makeTensor(t,e,"float32")}function Jv(){let e=Dv();if(e._tfengine==null){let t=new Ov(e);e._tfengine=new Cy(t)}return WR(e._tfengine.ENV),h$(()=>e._tfengine),e._tfengine}var B=Jv();function b$(e,t){let r={a:e,b:t};return B.runKernel(es,r)}var vh={};Be(vh,{isBrowser:()=>Qv,isMobile:()=>k$,mockIsMobile:()=>w$});function v$(){return typeof navigator!="undefined"&&navigator!=null}var kg;function w$(e){kg=e}function k$(e){if(kg!==void 0)return kg;if(e||v$()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||(typeof window!="undefined"?window.opera:"");if(!t){let r=e;return r.userAgentData&&r.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 Qv(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var jn=Z();jn.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.")});jn.registerFlag("IS_BROWSER",()=>Qv());jn.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");jn.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));jn.registerFlag("PROD",()=>!1);jn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>jn.getBool("DEBUG"));jn.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);jn.registerFlag("IS_TEST",()=>!1);jn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);jn.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);jn.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function Pa(e,t){let r=e;if(Sr(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let n=[];for(;Array.isArray(r)||Sr(r)&&t!=="string";)n.push(r.length),r=r[0];return Array.isArray(e)&&Z().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&e7(e,n,[]),n}function e7(e,t,r){if(r=r||[],!Array.isArray(e)&&!Sr(e)){_(t.length===0,()=>`Element arr[${r.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}_(t.length>0,()=>`Element arr[${r.join("][")}] should be a primitive, but is an array of ${e.length} elements`),_(e.length===t[0],()=>`Element arr[${r.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let n=t.slice(1);for(let a=0;a=0&&(a=n),U3(n,a,t,r),e==null||!Sr(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let o=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${r}' must be a Tensor or TensorLike, but got '${o}'`)}let s=Pa(e,a);!Sr(e)&&!Array.isArray(e)&&(e=[e]);let i=a!=="string"?Rf(e,a):Mo(e,[],!0);return B.makeTensor(i,s,a)}function Hp(e,t,r,n="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${r} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,s)=>M(a,`${t}[${s}]`,r,n))}var t7="__op";function W(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 r=t[0],n=e[r];r.endsWith("_")&&(r=r.substring(0,r.length-1)),r=r+t7;let a=(...s)=>{B.startScope(r);try{let i=n(...s);return wy(i)&&console.error("Cannot return a Promise inside of tidy."),B.endScope(i),i}catch(i){throw B.endScope(null),i}};return Object.defineProperty(a,"name",{value:r,configurable:!0}),a}function I$(e,t){let r=M(e,"real","complex"),n=M(t,"imag","complex");Ur(r.shape,n.shape,`real and imag shapes, ${r.shape} and ${n.shape}, must match in call to tf.complex().`);let a={real:r,imag:n};return B.runKernel(rh,a)}var Ya=W({complex_:I$});function Gi(e,t,r,n){if(n==null&&(n=tf(e)),n==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Sr(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){vy(t);let a=It(t),s=It(r);_(a===s,()=>`Based on the provided shape, [${t}], the tensor should have ${a} values but has ${s}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${r}) does not match the provided shape (${t}). `)}}return!Sr(e)&&!Array.isArray(e)&&(e=[e]),t=t||r,e=n!=="string"?Rf(e,n):Mo(e,[],!0),B.makeTensor(e,t,n)}function ft(e,t,r){let n=Pa(e,r);return Gi(e,t,n,r)}var Ig={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},T0=4;async function S$(e,t){let r=[],n=[],a=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let p=await l.bytes(),c=p.reduce((g,y)=>g+y.length,0)+T0*p.length,m=new Uint8Array(c),f=0;for(let g=0;g{if(t+=s.byteLength,r.push(s.byteLength===s.buffer.byteLength?s:new s.constructor(s)),!(s instanceof Float32Array||s instanceof Int32Array||s instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`)});let n=new Uint8Array(t),a=0;return r.forEach(s=>{n.set(new Uint8Array(s.buffer),a),a+=s.byteLength}),n.buffer}var Ty=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function G3(e){return Ty?Buffer.byteLength(e):new Blob([e]).size}function T$(e){if(Ty)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),r="";for(let n=0,a=t.length;n{t+=a.byteLength});let r=new Uint8Array(t),n=0;return e.forEach(a=>{r.set(new Uint8Array(a),n),n+=a.byteLength}),r.buffer}function j3(e){let t="/";for(e=e.trim();e.endsWith(t);)e=e.slice(0,e.length-1);let r=e.split(t);return r[r.length-1]}function n7(e,t){let r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),e.trainingConfig!=null&&(r.trainingConfig=e.trainingConfig),r}async function Ey(e,t){let r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(e.trainingConfig!=null&&(r.trainingConfig=e.trainingConfig),e.weightsManifest!=null){let[n,a]=await t(e.weightsManifest);r.weightSpecs=n,r.weightData=a}return e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),r}function wh(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:G3(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:G3(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function E$(){let e=r=>{let n=r<<13,a=0;for(;(n&8388608)===0;)a-=8388608,n<<=1;return n&=-8388609,a+=947912704,n|a},t=new Uint32Array(2048);t[0]=0;for(let r=1;r<1024;r++)t[r]=e(r);for(let r=1024;r<2048;r++)t[r]=939524096+(r-1024<<13);return t}function R$(){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 $$(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function M$(){let e=E$(),t=R$(),r=$$();return n=>{let a=new ArrayBuffer(4*n.length),s=new Uint32Array(a);for(let i=0;i>10]+(o&1023)]+t[o>>10];s[i]=l}return new Float32Array(a)}}var Wt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Wt.instance==null&&(Wt.instance=new Wt),Wt.instance}static registerSaveRouter(e){Wt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Wt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Wt.getHandlers(e,"save")}static getLoadHandlers(e,t){return Wt.getHandlers(e,"load",t)}static getHandlers(e,t,r){let n=[];return(t==="load"?Wt.getInstance().loadRouters:Wt.getInstance().saveRouters).forEach(a=>{let s=a(e,r);s!==null&&n.push(s)}),n}},F$=e=>Wt.registerSaveRouter(e),P$=e=>Wt.registerLoadRouter(e),_$=e=>Wt.getSaveHandlers(e),z$=(e,t)=>Wt.getLoadHandlers(e,t),Sg="tensorflowjs",Cg=1,So="models_store",Rs="model_info_store";function a7(){if(!Z().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 Tg(e){let t=e.result;t.createObjectStore(So,{keyPath:"modelPath"}),t.createObjectStore(Rs,{keyPath:"modelPath"})}var Fo=class{constructor(e){if(this.indexedDB=a7(),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((r,n)=>{let a=this.indexedDB.open(Sg,Cg);a.onupgradeneeded=()=>Tg(a),a.onsuccess=()=>{let s=a.result;if(t==null){let i=s.transaction(So,"readonly"),o=i.objectStore(So).get(this.modelPath);o.onsuccess=()=>{if(o.result==null)return s.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));r(o.result.modelArtifacts)},o.onerror=l=>(s.close(),n(o.error)),i.oncomplete=()=>s.close()}else{let i=wh(t),o=s.transaction(Rs,"readwrite"),l=o.objectStore(Rs),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),d;u.onsuccess=()=>{d=s.transaction(So,"readwrite");let h=d.objectStore(So).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});h.onsuccess=()=>r({modelArtifactsInfo:i}),h.onerror=p=>{l=o.objectStore(Rs);let c=l.delete(this.modelPath);c.onsuccess=()=>(s.close(),n(h.error)),c.onerror=m=>(s.close(),n(h.error))}},u.onerror=h=>(s.close(),n(u.error)),o.oncomplete=()=>{d==null?s.close():d.oncomplete=()=>s.close()}}},a.onerror=s=>n(a.error)})}};Fo.URL_SCHEME="indexeddb://";var s7=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Fo.URL_SCHEME)?O$(e.slice(Fo.URL_SCHEME.length)):null;Wt.registerSaveRouter(s7);Wt.registerLoadRouter(s7);function O$(e){return new Fo(e)}function D$(e){return e.startsWith(Fo.URL_SCHEME)?e.slice(Fo.URL_SCHEME.length):e}var L$=class{constructor(){this.indexedDB=a7()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(Sg,Cg);r.onupgradeneeded=()=>Tg(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(Rs,"readonly"),s=a.objectStore(Rs).getAll();s.onsuccess=()=>{let i={};for(let o of s.result)i[o.modelPath]=o.modelArtifactsInfo;e(i)},s.onerror=i=>(n.close(),t(s.error)),a.oncomplete=()=>n.close()},r.onerror=n=>t(r.error)})}async removeModel(e){return e=D$(e),new Promise((t,r)=>{let n=this.indexedDB.open(Sg,Cg);n.onupgradeneeded=()=>Tg(n),n.onsuccess=()=>{let a=n.result,s=a.transaction(Rs,"readwrite"),i=s.objectStore(Rs),o=i.get(e),l;o.onsuccess=()=>{if(o.result==null)return a.close(),r(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=i.delete(e),d=()=>{l=a.transaction(So,"readwrite");let h=l.objectStore(So).delete(e);h.onsuccess=()=>t(o.result.modelArtifactsInfo),h.onerror=p=>r(o.error)};u.onsuccess=d,u.onerror=h=>(d(),a.close(),r(o.error))}},o.onerror=u=>(a.close(),r(o.error)),s.oncomplete=()=>{l==null?a.close():l.oncomplete=()=>a.close()}},n.onerror=a=>r(n.error)})}},Xa="/",yu="tensorflowjs_models",i7="info",B$="model_topology",W$="weight_specs",V$="weight_data",U$="model_metadata";function o7(e){return{info:[yu,e,i7].join(Xa),topology:[yu,e,B$].join(Xa),weightSpecs:[yu,e,W$].join(Xa),weightData:[yu,e,V$].join(Xa),modelMetadata:[yu,e,U$].join(Xa)}}function l7(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function G$(e){let t=e.split(Xa);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Xa)}function j$(e){return e.startsWith(Po.URL_SCHEME)?e.slice(Po.URL_SCHEME.length):e}var Po=class{constructor(e){if(!Z().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=o7(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),r=JSON.stringify(e.weightSpecs),n=wh(e);try{this.LS.setItem(this.keys.info,JSON.stringify(n)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,T$(e.weightData));let a={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(a)),{modelArtifactsInfo:n}}catch(a){throw l7(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=${n.modelTopologyBytes}, weightSpecsBytes=${n.weightSpecsBytes}, weightDataBytes=${n.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={},r=JSON.parse(this.LS.getItem(this.keys.topology));if(r==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=r;let n=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(n==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=n;let a=this.LS.getItem(this.keys.modelMetadata);if(a!=null){let i=JSON.parse(a);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 s=this.LS.getItem(this.keys.weightData);if(s==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=N$(s),t}};Po.URL_SCHEME="localstorage://";var u7=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Po.URL_SCHEME)?H$(e.slice(Po.URL_SCHEME.length)):null;Wt.registerSaveRouter(u7);Wt.registerLoadRouter(u7);function H$(e){return new Po(e)}var q$=class{constructor(){_(Z().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),_(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=yu+Xa,r=Xa+i7;for(let n=0;n"scheme must not be undefined or null."),e.endsWith(vu)&&(e=e.slice(0,e.indexOf(vu))),_(e.length>0,()=>"scheme must not be an empty string.");let r=Nn.getInstance();_(r.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),r.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 u0(e){if(e.indexOf(vu)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Nn.getSchemes().join(",")}`);return{scheme:e.split(vu)[0],path:e.split(vu)[1]}}async function d7(e,t,r=!1){_(e!==t,()=>`Old path and new path are the same: '${e}'`);let n=Wt.getLoadHandlers(e);_(n.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),_(n.length<2,()=>`Copying failed because more than one (${n.length}) load handlers for source URL ${e}.`);let a=n[0],s=Wt.getSaveHandlers(t);_(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),_(s.length<2,()=>`Copying failed because more than one (${n.length}) save handlers for destination URL ${t}.`);let i=s[0],o=u0(e).scheme,l=u0(e).path,u=o===u0(e).scheme,d=await a.load();r&&u&&await Nn.getManager(o).removeModel(l);let h=await i.save(d);return r&&!u&&await Nn.getManager(o).removeModel(l),h.modelArtifactsInfo}async function X$(){let e=Nn.getSchemes(),t={};for(let r of e){let n=await Nn.getManager(r).listModels();for(let a in n){let s=r+vu+a;t[s]=n[a]}}return t}async function K$(e){let t=u0(e);return Nn.getManager(t.scheme).removeModel(t.path)}async function Z$(e,t){return d7(e,t,!1)}async function Y$(e,t){return d7(e,t,!0)}var J$=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(Z().get("IS_BROWSER")){Z().setPlatform("browser",new J$);try{Nn.registerManager(Po.URL_SCHEME,new q$)}catch(e){}try{Nn.registerManager(Fo.URL_SCHEME,new L$)}catch(e){}}var Q$={importFetch:()=>iR()},lg,eM=class{constructor(){this.util=oR(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Z().global.fetch!=null?Z().global.fetch(e,t):(lg==null&&(lg=Q$.importFetch()),lg(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)}};Z().get("IS_NODE")&&!Z().get("IS_BROWSER")&&Z().setPlatform("node",new eM);function Le(e,t="float32",r){return t=t||"float32",vy(e),new or(e,t,r)}function tM(e,t){let r=M(e,"x","cast");if(!Mv(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t==="string"&&r.dtype!=="string"||t!=="string"&&r.dtype==="string")throw new Error("Only strings can be casted to strings");let n={x:r},a={dtype:t};return B.runKernel(ti,n,a)}var me=W({cast_:tM});function rM(e){let t={x:M(e,"x","clone","string_or_numeric")};return B.runKernel(gi,t)}var Wr=W({clone_:rM});function p7(e,t=!1){console.log(e.toString(t))}Jv();var nM={buffer:Le,cast:me,clone:Wr,print:p7};c$(nM);var Cr={};Be(Cr,{browserFiles:()=>dM,browserHTTPRequest:()=>mM,concatenateArrayBuffers:()=>Ny,copyModel:()=>Z$,decodeWeights:()=>r7,encodeWeights:()=>S$,fromMemory:()=>yM,fromMemorySync:()=>g7,getLoadHandlers:()=>z$,getModelArtifactsForJSON:()=>Ey,getModelArtifactsInfoForJSON:()=>wh,getSaveHandlers:()=>_$,http:()=>$y,isHTTPScheme:()=>Eg,listModels:()=>X$,loadWeights:()=>pM,moveModel:()=>Y$,registerLoadRouter:()=>P$,registerSaveRouter:()=>F$,removeModel:()=>K$,weightsLoaderFactory:()=>c7,withSaveHandler:()=>AM,withSaveHandlerSync:()=>xM});var aM="model",sM=".json",iM=".weights.bin";function H3(e){return new Promise(t=>setTimeout(t)).then(e)}var Ng=class{constructor(e){if(!Z().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Ng.URL_SCHEME)&&(e=e.slice(Ng.URL_SCHEME.length)),(e==null||e.length===0)&&(e=aM),this.modelJsonFileName=e+sM,this.weightDataFileName=e+iM}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 r=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],n=n7(e,r),a=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),s=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=a,await H3(()=>s.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 H3(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:wh(e)}}}},N0=Ng;N0.URL_SCHEME="downloads://";var oM=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 r=new FileReader;r.onload=n=>{let a=JSON.parse(n.target.result),s=a.modelTopology;if(s==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(a.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:s});return}let i=Ey(a,o=>this.loadWeights(o));e(i)},r.onerror=n=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),r.readAsText(this.jsonFile)})}loadWeights(e){let t=[],r=[];for(let s of e)t.push(...s.weights),r.push(...s.paths);let n=this.checkManifestAndWeightFiles(e),a=r.map(s=>this.loadWeightsFile(s,n[s]));return Promise.all(a).then(s=>[t,Ny(s)])}loadWeightsFile(e,t){return new Promise((r,n)=>{let a=new FileReader;a.onload=s=>{let i=s.target.result;r(i)},a.onerror=s=>n(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],r=this.weightsFiles.map(a=>j3(a.name)),n={};for(let a of e)a.paths.forEach(s=>{let i=j3(s);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),r.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);n[s]=this.weightsFiles[r.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 n}},lM=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(N0.URL_SCHEME)?uM(e.slice(N0.URL_SCHEME.length)):null;Wt.registerSaveRouter(lM);function uM(e="model"){return new N0(e)}function dM(e){return new oM(e)}function q3(e,t,r,n){i(e),r=r==null?0:r,n=n==null?1:n,o(r,n);let a=0,s=l=>(l.then(u=>{let d=r+ ++a/e.length*(n-r);return t(d),u}),l);function i(l){_(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function o(l,u){_(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),_(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),_(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(s))}async function h7(e,t){t==null&&(t={});let r=t.fetchFunc==null?Z().platform.fetch:t.fetchFunc,n=e.map(u=>r(u,t.requestInit,{isBinary:!0})),a=0,s=.5,i=(t.onProgress==null?await Promise.all(n):await q3(n,t.onProgress,a,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await q3(i,t.onProgress,o,l)}async function pM(e,t="",r,n){return c7(a=>h7(a,{requestInit:n}))(e,t,r)}function c7(e){return async(t,r="",n)=>{let a=t.map(()=>!1),s={},i=n!=null?n.map(()=>!1):[],o=[];if(t.forEach((c,m)=>{let f=0;c.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,A=Ig[y]*It(g.shape),x=()=>{a[m]=!0,s[m]==null&&(s[m]=[]),s[m].push({manifestEntry:g,groupOffset:f,sizeBytes:A})};n!=null?n.forEach((b,w)=>{b===g.name&&(x(),i[w]=!0)}):x(),o.push(g.name),f+=A})}),!i.every(c=>c)){let c=n.filter((m,f)=>!i[f]);throw new Error(`Could not find weights in manifest with names: ${c.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=a.reduce((c,m,f)=>(m&&c.push(f),c),[]),u=[];l.forEach(c=>{t[c].paths.forEach(m=>{let f=r+(r.endsWith("/")?"":"/")+m;u.push(f)})});let d=await e(u),h={},p=0;return l.forEach(c=>{let m=t[c].paths.length,f=0;for(let x=0;x{let b=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),w=r7(b,[x.manifestEntry]);for(let I in w)h[I]=w[I]}),p+=m}),h}}var hM="application/octet-stream",cM="application/json",Ry=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?(_(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=Z().platform.fetch,_(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&_(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 r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],n=n7(e,r);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:cM}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:hM}),"model.weights.bin");let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:wh(e),responses:[a]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${a.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(a){let s=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?s+=" 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.":s+=" Please make sure the server is serving valid JSON for this request.",new Error(s)}let r=t.modelTopology,n=t.weightsManifest;if(r==null&&n==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Ey(t,a=>this.loadWeights(a))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[r,n]=fM(t),a=this.weightPathPrefix||r,s=[];for(let u of e)s.push(...u.weights);let i=[],o=[];for(let u of e)for(let d of u.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(d)):i.push(a+d+n);this.weightUrlConverter&&i.push(...await Promise.all(o));let l=await h7(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,Ny(l)]}};Ry.URL_SCHEME_REGEX=/^https?:\/\//;function fM(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?"),n=e.substring(0,t),a=r>t?e.substring(r):"";return[n+"/",a]}function Eg(e){return e.match(Ry.URL_SCHEME_REGEX)!=null}var f7=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let r=!0;if(Array.isArray(e)?r=e.every(n=>Eg(n)):r=Eg(e),r)return $y(e,t)}return null};Wt.registerSaveRouter(f7);Wt.registerLoadRouter(f7);function $y(e,t){return new Ry(e,t)}function mM(e,t){return $y(e,t)}var ug=class{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}},m7=class{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}},gM=class{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}};function yM(e,t,r,n){let a=arguments;return new gM(g7(...a))}function g7(e,t,r,n){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new ug(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 ug({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 ug({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n}))}function AM(e){return new m7(e)}function xM(e){return new m7(e)}var y7={};Be(y7,{confusionMatrix:()=>_M});function bM(e,t,r=!1,n=!1){let a=M(e,"a","matMul"),s=M(t,"b","matMul");[a,s]=Lt(a,s);let i={a,b:s},o={transposeA:r,transposeB:n};return B.runKernel(ei,i,o)}var Ze=W({matMul_:bM});function vM(e,t,r=1,n=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:M(e,"indices","oneHot","int32")},s={depth:t,onValue:r,offValue:n};return B.runKernel(hl,a,s)}var qp=W({oneHot_:vM});function My(){Z().set("PROD",!0)}function wM(){Z().set("DEBUG",!0)}function kM(){Z().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Fy(e){Z().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}f$(Fy);function IM(){B.disposeVariables()}function Xt(){return B}function E0(){return B.memory()}function SM(e){return B.profile(e)}function X(e,t){return B.tidy(e,t)}function te(e){Sy(e).forEach(t=>t.dispose())}function gr(e){return B.keep(e)}function CM(e){return B.time(e)}function Py(e){return B.setBackend(e)}function gd(){return B.ready()}function Gr(){return B.backendName}function TM(e){B.removeBackend(e)}function _y(e){return B.findBackend(e)}function NM(e){return B.findBackendFactory(e)}function Rl(e,t,r=1){return B.registerBackend(e,t,r)}function On(){return B.backend}function EM(e,t){Z().setPlatform(e,t)}function RM(e){let t={input:M(e,"input","imag")};return B.runKernel(oh,t)}var kh=W({imag_:RM});function $M(e){let t={x:M(e,"x","neg")};return B.runKernel(ol,t)}var Mt=W({neg_:$M});function MM(e){let t={input:M(e,"input","real")};return B.runKernel(ph,t)}var Tu=W({real_:MM});function FM(e,t,r){let n=M(e,"x","transpose");if(t==null&&(t=n.shape.map((i,o)=>o).reverse()),_(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(i=>{_(i>=0&&i`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let a={x:n},s={perm:t};return n.dtype==="complex64"?X(()=>{let i=Tu(n),o=kh(n);return i=B.runKernel($a,{x:i},s),o=B.runKernel($a,{x:o},s),r&&(o=Mt(o)),Ya(i,o)}):B.runKernel($a,a,s)}var tt=W({transpose_:FM});function PM(e,t,r){let n=M(e,"labels","confusionMatrix"),a=M(t,"predictions","confusionMatrix");_(r==null||r>0&&Number.isInteger(r),()=>`If provided, numClasses must be a positive integer, but got ${r}`),_(n.rank===1,()=>`Expected the rank of labels to be 1, but got ${n.rank}`),_(a.rank===1,()=>`Expected the rank of predictions to be 1, but got ${a.rank}`),_(n.shape[0]===a.shape[0],()=>`Mismatch in the number of examples: ${n.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`),_(r>0&&Number.isInteger(r),()=>`numClasses is required to be a positive integer, but got ${r}`);let s=qp(me(n,"int32"),r),i=qp(me(a,"int32"),r),o=tt(s),l=Ze(o,i);return me(l,"int32")}var _M=W({confusionMatrix_:PM}),$l={};Be($l,{assertAndGetBroadcastShape:()=>yt,getBroadcastDims:()=>A7,getReductionAxes:()=>Qt});function A7(e,t){let r=e.length,n=[];for(let a=0;a1&&i===1&&n.unshift(s)}return n}function Qt(e,t){let r=[];for(let n=0;n1)&&r.unshift(s)}return r}function yt(e,t){let r=[],n=Math.max(e.length,t.length);for(let a=0;aVM,fromPixelsAsync:()=>BM,toPixels:()=>WM});function x7(e,t,r){if(Go(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=Pa(e,r);if(n.length!==3&&n.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(n.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Gi(e,t,n,r)}var go;function b7(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 r=!1,n=!1,a=!1,s=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)r=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)n=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)a=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)s=!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(a&&a&&e.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the