/* Human homepage: author: ' */ var Human=(()=>{var Jc=Object.defineProperty;var QE=Object.getOwnPropertyDescriptor;var eR=Object.getOwnPropertyNames;var tR=Object.prototype.hasOwnProperty;var rR=(e,t,r)=>t in e?Jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var vs=(e,t)=>{for(var r in t)Jc(e,r,{get:t[r],enumerable:!0})},nR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of eR(t))!tR.call(e,a)&&a!==r&&Jc(e,a,{get:()=>t[a],enumerable:!(n=QE(t,a))||n.enumerable});return e};var aR=e=>nR(Jc({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>(rR(e,typeof t!="symbol"?t+"":t,r),r),Bb=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var bp=(e,t,r)=>(Bb(e,t,"read from private field"),r?r.call(e):t.get(e)),vp=(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)},wp=(e,t,r,n)=>(Bb(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var rAe={};vs(rAe,{Human:()=>Ab,default:()=>Ab,defaults:()=>ws,draw:()=>pb,env:()=>he,match:()=>yb,models:()=>C1});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 Wb(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 lg(e,t,r="config",n=[]){for(let a of Object.keys(t))if(typeof t[a]=="object")lg(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 ws={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={};vs(Ue,{Abs:()=>Go,Acos:()=>Uu,Acosh:()=>Gu,AdadeltaOptimizer:()=>rm,AdagradOptimizer:()=>nm,AdamOptimizer:()=>am,AdamaxOptimizer:()=>sm,Add:()=>Ja,AddN:()=>Ks,All:()=>ju,Any:()=>Hu,ArgMax:()=>Zs,ArgMin:()=>qu,Asin:()=>Xu,Asinh:()=>Ku,Atan:()=>Zu,Atan2:()=>Ju,Atanh:()=>Yu,AvgPool:()=>Ys,AvgPool3D:()=>nh,AvgPool3DGrad:()=>uf,AvgPoolGrad:()=>lf,BackendWasm:()=>wC,BatchMatMul:()=>Js,BatchToSpaceND:()=>jo,Bincount:()=>df,BroadcastArgs:()=>pf,BroadcastTo:()=>G7,Callback:()=>k8,CallbackList:()=>kw,Cast:()=>Qs,Ceil:()=>ei,ClipByValue:()=>Qa,Complex:()=>ah,ComplexAbs:()=>sh,Concat:()=>Ho,Conv2D:()=>ti,Conv2DBackpropFilter:()=>hf,Conv2DBackpropInput:()=>ri,Conv3D:()=>ih,Conv3DBackpropFilterV2:()=>cf,Conv3DBackpropInputV2:()=>ff,Cos:()=>ni,Cosh:()=>ai,CropAndResize:()=>Xo,Cumprod:()=>qo,Cumsum:()=>si,CustomCallback:()=>Sw,DataStorage:()=>rh,DenseBincount:()=>mf,DepthToSpace:()=>Ko,DepthwiseConv2dNative:()=>ii,DepthwiseConv2dNativeBackpropFilter:()=>gf,DepthwiseConv2dNativeBackpropInput:()=>yf,Diag:()=>Af,Dilation2D:()=>oh,Dilation2DBackpropFilter:()=>T0,Dilation2DBackpropInput:()=>C0,ENV:()=>ba,EarlyStopping:()=>I8,Einsum:()=>lh,Elu:()=>li,EluGrad:()=>xf,Environment:()=>V7,Equal:()=>Zo,Erf:()=>Qu,Exp:()=>ui,ExpandDims:()=>Yo,Expm1:()=>Jo,FFT:()=>bf,Fill:()=>ed,FlipLeftRight:()=>Qo,Floor:()=>di,FloorDiv:()=>pi,FromPixels:()=>Up,FusedBatchNorm:()=>hi,FusedConv2D:()=>Ps,FusedDepthwiseConv2D:()=>Os,GPGPUContext:()=>Iu,GatherNd:()=>tl,GatherV2:()=>el,GraphModel:()=>Uh,Greater:()=>rl,GreaterEqual:()=>ci,History:()=>Iw,IFFT:()=>vf,Identity:()=>fi,Imag:()=>uh,InputSpec:()=>Zt,IsFinite:()=>td,IsInf:()=>rd,IsNan:()=>nd,KernelBackend:()=>Wu,LRN:()=>ph,LRNGrad:()=>kf,LayerVariable:()=>fw,LayersModel:()=>Ka,LeakyRelu:()=>mi,Less:()=>nl,LessEqual:()=>al,LinSpace:()=>wf,Log:()=>gi,Log1p:()=>ad,LogSoftmax:()=>j7,LogicalAnd:()=>sl,LogicalNot:()=>sd,LogicalOr:()=>dh,LowerBound:()=>KR,MathBackendCPU:()=>oA,MathBackendWebGL:()=>qh,Max:()=>yi,MaxPool:()=>xi,MaxPool3D:()=>hh,MaxPool3DGrad:()=>Sf,MaxPoolGrad:()=>If,MaxPoolWithArgmax:()=>Cf,Maximum:()=>Ai,Mean:()=>bi,Min:()=>vi,Minimum:()=>wi,MirrorPad:()=>ki,Mod:()=>id,MomentumOptimizer:()=>im,Multinomial:()=>Tf,Multiply:()=>Ii,Neg:()=>il,NonMaxSuppressionV3:()=>ll,NonMaxSuppressionV4:()=>od,NonMaxSuppressionV5:()=>ul,NotEqual:()=>ol,OP_SCOPE_SUFFIX:()=>i6,OneHot:()=>pl,OnesLike:()=>dl,Optimizer:()=>ns,OptimizerConstructors:()=>Is,Pack:()=>hl,PadV2:()=>Si,Pool:()=>ZR,Pow:()=>Ci,Prelu:()=>Ti,Prod:()=>Ni,RMSPropOptimizer:()=>om,RNN:()=>as,Range:()=>ld,Rank:()=>Z7,Real:()=>ch,RealDiv:()=>oi,Reciprocal:()=>ud,Reduction:()=>Jv,Relu:()=>Ei,Relu6:()=>Mi,Reshape:()=>cl,ResizeBilinear:()=>Ri,ResizeBilinearGrad:()=>Ef,ResizeNearestNeighbor:()=>dd,ResizeNearestNeighborGrad:()=>Nf,Reverse:()=>fl,RotateWithOffset:()=>Nl,Round:()=>ml,Rsqrt:()=>$i,SGDOptimizer:()=>Fh,ScatterNd:()=>gl,SearchSorted:()=>Rf,Select:()=>yl,Selu:()=>pd,Sequential:()=>vm,Sigmoid:()=>_i,Sign:()=>hd,Sin:()=>Fi,Sinh:()=>xl,Slice:()=>Al,Softmax:()=>zi,Softplus:()=>cd,SpaceToBatchND:()=>bl,SparseFillEmptyRows:()=>fh,SparseReshape:()=>fd,SparseSegmentMean:()=>mh,SparseSegmentSum:()=>gh,SparseToDense:()=>yh,SplitV:()=>vl,Sqrt:()=>Pi,Square:()=>md,SquaredDifference:()=>Di,Step:()=>Wi,StridedSlice:()=>wl,StringNGrams:()=>Ah,StringSplit:()=>Mf,StringToHashBucketFast:()=>$f,Sub:()=>Li,Sum:()=>Oi,SymbolicTensor:()=>pa,Tan:()=>kl,Tanh:()=>Bi,Tensor:()=>nt,TensorBuffer:()=>ir,Tile:()=>es,TopK:()=>Il,Transform:()=>Sl,Transpose:()=>Ma,Unique:()=>Ff,Unpack:()=>Cl,UnsortedSegmentSum:()=>xh,UpperBound:()=>YR,Variable:()=>Hp,ZerosLike:()=>Tl,_FusedMatMul:()=>_s,abs:()=>ar,acos:()=>W6,acosh:()=>V6,add:()=>le,addN:()=>Pf,all:()=>qy,any:()=>F0,argMax:()=>Rn,argMin:()=>U6,asin:()=>G6,asinh:()=>j6,atan:()=>H6,atan2:()=>q6,atanh:()=>X6,avgPool:()=>Of,avgPool3d:()=>Ky,backend:()=>zn,backend_util:()=>C,basicLSTMCell:()=>VF,batchNorm:()=>Eu,batchNorm2d:()=>J6,batchNorm3d:()=>Q6,batchNorm4d:()=>ev,batchToSpaceND:()=>zf,bincount:()=>Zy,booleanMaskAsync:()=>tz,broadcastArgs:()=>tv,broadcastTo:()=>Dp,broadcast_util:()=>Rl,browser:()=>Dn,buffer:()=>Le,callbacks:()=>$j,cast:()=>me,ceil:()=>rv,clipByValue:()=>fn,clone:()=>Wr,complex:()=>Za,concat:()=>St,concat1d:()=>nv,concat2d:()=>yd,concat3d:()=>av,concat4d:()=>sv,constraints:()=>xw,conv1d:()=>Yy,conv2d:()=>Ds,conv2dTranspose:()=>Qy,conv3d:()=>e3,conv3dTranspose:()=>ov,copyRegisteredKernels:()=>tM,cos:()=>Df,cosh:()=>t3,cosineWindow:()=>S3,cumprod:()=>P0,cumsum:()=>r3,customGrad:()=>Pa,data:()=>K8,denseBincount:()=>lv,deprecationWarn:()=>zy,depthToSpace:()=>uv,depthwiseConv2d:()=>Nh,deregisterOp:()=>Pj,device_util:()=>kh,diag:()=>x_,dilation2d:()=>dv,disableDeprecationWarnings:()=>E$,dispose:()=>te,disposeVariables:()=>R$,div:()=>pe,divNoNan:()=>pv,dot:()=>C_,dropout:()=>Uv,einsum:()=>hv,elu:()=>Eh,enableDebugMode:()=>N$,enableProdMode:()=>Oy,enclosingPowerOfTwo:()=>Gv,engine:()=>Xt,env:()=>Z,equal:()=>Mn,erf:()=>cv,euclideanNorm:()=>Av,exp:()=>$n,expandDims:()=>Kt,expm1:()=>xv,eye:()=>s3,fft:()=>Kf,fill:()=>Ad,findBackend:()=>Ly,findBackendFactory:()=>_$,floor:()=>Rh,floorDiv:()=>Ch,forceHalfFloat:()=>gI,fused:()=>Ws,gather:()=>Ru,gatherND:()=>Vv,gather_util:()=>By,getBackend:()=>jr,getGradient:()=>Ig,getKernel:()=>N0,getKernelsForBackend:()=>Fa,getThreadsCount:()=>Yye,gpgpu_util:()=>q9,grad:()=>iP,grads:()=>oP,greater:()=>gn,greaterEqual:()=>Ml,ifft:()=>Kp,imag:()=>Sh,image:()=>Ie,inTopKAsync:()=>pz,initializers:()=>bw,input:()=>Lw,io:()=>Sr,irfft:()=>v3,isFinite:()=>Z_,isInf:()=>J_,isNaN:()=>bv,keep:()=>mr,kernel_impls:()=>Kn,layers:()=>vw,leakyRelu:()=>Bf,less:()=>i3,lessEqual:()=>$l,linalg:()=>Qv,linspace:()=>vv,loadGraphModel:()=>DH,loadGraphModelSync:()=>LH,loadLayersModel:()=>UU,localResponseNormalization:()=>wv,log:()=>Fn,log1p:()=>Wf,logSigmoid:()=>hP,logSoftmax:()=>o3,logSumExp:()=>Iv,logicalAnd:()=>ga,logicalNot:()=>Uf,logicalOr:()=>l3,logicalXor:()=>bP,losses:()=>KD,lowerBound:()=>Sv,matMul:()=>Ye,math:()=>w6,max:()=>yr,maxPool:()=>Gf,maxPool3d:()=>d3,maxPoolWithArgmax:()=>Cv,maximum:()=>ts,mean:()=>Vt,memory:()=>$0,meshgrid:()=>TP,metrics:()=>b8,min:()=>Ls,minimum:()=>Mh,mirrorPad:()=>Tv,mod:()=>bd,model:()=>WU,models:()=>v8,moments:()=>jf,movingAverage:()=>nz,mul:()=>L,multiRNNCell:()=>FP,multinomial:()=>Nv,neg:()=>$t,nextFrame:()=>N3,norm:()=>Lf,notEqual:()=>Mu,oneHot:()=>Xp,ones:()=>cn,onesLike:()=>_n,op:()=>W,outerProduct:()=>DP,pad:()=>Xn,pad1d:()=>WP,pad2d:()=>UP,pad3d:()=>jP,pad4d:()=>qP,pool:()=>JP,pow:()=>Bs,prelu:()=>qf,print:()=>g6,prod:()=>p3,profile:()=>M$,rand:()=>rO,randomGamma:()=>iO,randomNormal:()=>Ev,randomUniform:()=>vd,range:()=>$u,ready:()=>gd,real:()=>Tu,reciprocal:()=>Rv,registerBackend:()=>El,registerCallbackConstructor:()=>GU,registerGradient:()=>H7,registerKernel:()=>qn,registerOp:()=>_j,regularizers:()=>w8,relu:()=>Da,relu6:()=>f3,removeBackend:()=>F$,reshape:()=>U,reverse:()=>Pn,reverse1d:()=>fO,reverse2d:()=>gO,reverse3d:()=>AO,reverse4d:()=>bO,rfft:()=>Zf,round:()=>m3,rsqrt:()=>g3,scalar:()=>Se,scatterND:()=>Wv,scatter_util:()=>Wy,searchSorted:()=>u3,selu:()=>y3,separableConv2d:()=>Mv,sequential:()=>VU,serialization:()=>ue,setBackend:()=>Dy,setPlatform:()=>P$,setThreadsCount:()=>Zye,setWasmPath:()=>Kye,setWasmPaths:()=>VA,setWebGLContext:()=>$m,setdiff1dAsync:()=>$v,shared:()=>Rm,sigmoid:()=>Cr,sign:()=>Fv,signal:()=>XD,sin:()=>A3,sinh:()=>x3,slice:()=>_e,slice1d:()=>Xf,slice2d:()=>b3,slice3d:()=>Fl,slice4d:()=>Po,slice_util:()=>Dt,softmax:()=>wd,softplus:()=>xd,spaceToBatchND:()=>Hf,sparse:()=>Ep,sparseToDense:()=>I3,spectral:()=>qD,split:()=>Yt,sqrt:()=>Nr,square:()=>xt,squaredDifference:()=>w3,squeeze:()=>et,stack:()=>ur,step:()=>$h,stridedSlice:()=>_v,string:()=>c0,sub:()=>ce,sum:()=>ke,sumOutType:()=>wh,tan:()=>Pv,tanh:()=>Nu,tensor:()=>ft,tensor1d:()=>Nt,tensor2d:()=>ca,tensor3d:()=>I6,tensor4d:()=>jO,tensor5d:()=>HO,tensor6d:()=>qO,tensor_util:()=>ha,test_util:()=>D6,tidy:()=>X,tile:()=>Gn,time:()=>$$,topk:()=>Ov,train:()=>Ao,transpose:()=>tt,truncatedNormal:()=>Yf,unique:()=>zg,unregisterGradient:()=>eM,unregisterKernel:()=>QR,unsortedSegmentSum:()=>zv,unstack:()=>an,upcastType:()=>Tr,upperBound:()=>Dv,util:()=>v,valueAndGrad:()=>lP,valueAndGrads:()=>uP,variable:()=>Lv,variableGrads:()=>kv,version:()=>rc,version_converter:()=>WH,version_core:()=>Hy,version_cpu:()=>TX,version_layers:()=>Y3,version_wasm:()=>Jye,version_webgl:()=>nre,webgl:()=>are,webgl_util:()=>y9,webgpu:()=>yS,where:()=>Vr,whereAsync:()=>k3,zeros:()=>Ot,zerosLike:()=>at});var sR=Object.create,nf=Object.defineProperty,iR=Object.getOwnPropertyDescriptor,R7=Object.getOwnPropertyNames,oR=Object.getPrototypeOf,lR=Object.prototype.hasOwnProperty,uR=e=>nf(e,"__esModule",{value:!0}),dr=(e,t)=>function(){return t||(0,e[R7(e)[0]])((t={exports:{}}).exports,t),t.exports},Be=(e,t)=>{for(var r in t)nf(e,r,{get:t[r],enumerable:!0})},dR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of R7(t))!lR.call(e,a)&&(r||a!=="default")&&nf(e,a,{get:()=>t[a],enumerable:!(n=iR(t,a))||n.enumerable});return e},Vo=(e,t)=>dR(uR(nf(e!=null?sR(oR(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),pR=dr({"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,z){this.low=S|0,this.high=P|0,this.unsigned=!!z}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 z,j,K;return P?(S>>>=0,(K=0<=S&&S<256)&&(j=i[S],j)?j:(z=u(S,(S|0)<0?-1:0,!0),K&&(i[S]=z),z)):(S|=0,(K=-128<=S&&S<128)&&(j=s[S],j)?j:(z=u(S,S<0?-1:0,!1),K&&(s[S]=z),z))}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 O;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,z){return new n(S,P,z)}n.fromBits=u;var d=Math.pow;function h(S,P,z){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof P=="number"?(z=P,P=!1):P=!!P,z=z||10,z<2||360)throw Error("interior hyphen");if(j===0)return h(S.substring(1),P,z).neg();for(var K=l(d(z,8)),D=x,Y=0;Y>>0:this.low},M.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},M.toString=function(S){if(S=S||10,S<2||36>>0,Q=re.toString(S);if(D=V,D.isZero())return Q+Y;for(;Q.length<6;)Q="0"+Q;Y=""+Q+Y}},M.getHighBits=function(){return this.high},M.getHighBitsUnsigned=function(){return this.high>>>0},M.getLowBits=function(){return this.low},M.getLowBitsUnsigned=function(){return this.low>>>0},M.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,P=31;P>0&&(S&1<=0},M.isOdd=function(){return(this.low&1)===1},M.isEven=function(){return(this.low&1)===0},M.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},M.eq=M.equals,M.notEquals=function(S){return!this.eq(S)},M.neq=M.notEquals,M.ne=M.notEquals,M.lessThan=function(S){return this.comp(S)<0},M.lt=M.lessThan,M.lessThanOrEqual=function(S){return this.comp(S)<=0},M.lte=M.lessThanOrEqual,M.le=M.lessThanOrEqual,M.greaterThan=function(S){return this.comp(S)>0},M.gt=M.greaterThan,M.greaterThanOrEqual=function(S){return this.comp(S)>=0},M.gte=M.greaterThanOrEqual,M.ge=M.greaterThanOrEqual,M.compare=function(S){if(a(S)||(S=p(S)),this.eq(S))return 0;var P=this.isNegative(),z=S.isNegative();return P&&!z?-1:!P&&z?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},M.comp=M.compare,M.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(w)},M.neg=M.negate,M.add=function(S){a(S)||(S=p(S));var P=this.high>>>16,z=this.high&65535,j=this.low>>>16,K=this.low&65535,D=S.high>>>16,Y=S.high&65535,V=S.low>>>16,re=S.low&65535,Q=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+=z+Y,Q+=ie>>>16,ie&=65535,Q+=P+D,Q&=65535,u(J<<16|ae,Q<<16|ie,this.unsigned)},M.subtract=function(S){return a(S)||(S=p(S)),this.add(S.neg())},M.sub=M.subtract,M.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(O))return S.isOdd()?O:x;if(S.eq(O))return this.isOdd()?O: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 z=this.high>>>16,j=this.high&65535,K=this.low>>>16,D=this.low&65535,Y=S.high>>>16,V=S.high&65535,re=S.low>>>16,Q=S.low&65535,ie=0,J=0,ae=0,de=0;return de+=D*Q,ae+=de>>>16,de&=65535,ae+=K*Q,J+=ae>>>16,ae&=65535,ae+=D*re,J+=ae>>>16,ae&=65535,J+=j*Q,ie+=J>>>16,J&=65535,J+=K*re,ie+=J>>>16,J&=65535,J+=D*V,ie+=J>>>16,J&=65535,ie+=z*Q+j*re+K*V+D*Y,ie&=65535,u(ae<<16|de,ie<<16|J,this.unsigned)},M.mul=M.multiply,M.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 z,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(O)){if(S.eq(w)||S.eq(T))return O;if(S.eq(O))return w;var D=this.shr(1);return z=D.div(S).shl(1),z.eq(x)?S.isNegative()?w:T:(j=this.sub(S.mul(z)),K=z.add(j.div(S)),K)}else if(S.eq(O))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);){z=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Y=Math.ceil(Math.log(z)/Math.LN2),V=Y<=48?1:d(2,Y-48),re=l(z),Q=re.mul(S);Q.isNegative()||Q.gt(j);)z-=V,re=l(z,this.unsigned),Q=re.mul(S);re.isZero()&&(re=w),K=K.add(re),j=j.sub(Q)}return K},M.div=M.divide,M.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))},M.mod=M.modulo,M.rem=M.modulo,M.not=function(){return u(~this.low,~this.high,this.unsigned)},M.and=function(S){return a(S)||(S=p(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},M.or=function(S){return a(S)||(S=p(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},M.xor=function(S){return a(S)||(S=p(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},M.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)},M.shr=M.shiftRight,M.shiftRightUnsigned=function(S){if(a(S)&&(S=S.toInt()),S&=63,S===0)return this;var P=this.high;if(S<32){var z=this.low;return u(z>>>S|P<<32-S,P>>>S,this.unsigned)}else return S===32?u(P,0,this.unsigned):u(P>>>S-32,0,this.unsigned)},M.shru=M.shiftRightUnsigned,M.shr_u=M.shiftRightUnsigned,M.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},M.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},M.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},M.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]},M.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,z){return z?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)}}}),hR=dr({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),cR=dr({"(disabled):util"(){}}),fR=dr({"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)}}),mR=dr({"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)}}),gR=dr({"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)}}),yR=dr({"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)}}),AR=dr({"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)}}),xR=dr({"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)}}),bR=dr({"(disabled):crypto"(){}}),vR=dr({"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,T){var E=[];I=I==!0?{entropy:!0}:I||{};var R=A(y(I.entropy?[w,b(n)]:w==null?x():w,3),E),O=new f(E),M=function(){for(var S=O.g(i),P=u,z=0;S=h;)S/=2,P/=2,z>>>=1;return(S+z)/P};return M.int32=function(){return O.g(4)|0},M.quick=function(){return O.g(4)/4294967296},M.double=M,A(b(O.S),n),(I.pass||T||function(S,P,z,j){return j&&(j.S&&g(j,O),S.state=function(){return g(O,{})}),z?(a[l]=S,P):S})(M,R,"global"in I?I.global:this==a,I.state)}function f(w){var I,T=w.length,E=this,R=0,O=E.i=E.j=0,M=E.S=[];for(T||(w=[T++]);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!=Pr&&ra(Fe.buffer),yc}function i(){return Fe.buffer!=Pr&&ra(Fe.buffer),Ac}function o(){return Fe.buffer!=Pr&&ra(Fe.buffer),up}function l(){return Fe.buffer!=Pr&&ra(Fe.buffer),xc}function u(){return Fe.buffer!=Pr&&ra(Fe.buffer),bc}function d(){return Fe.buffer!=Pr&&ra(Fe.buffer),vc}function h(){return Fe.buffer!=Pr&&ra(Fe.buffer),wc}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",T=p.ENVIRONMENT_IS_PTHREAD||!1,E="";function R(N){return p.locateFile?p.locateFile(N,E):E+N}var O,M,S,P;function z(N){N instanceof Ap||Q("exiting due to exception: "+N)}var j,K,D;if(I){w?E=k0().dirname(E)+"/":E=__dirname+"/",D=()=>{K||(j=ky(),K=k0())},O=function(F,G){return D(),F=K.normalize(F),j.readFileSync(F,G?void 0:"utf8")},S=F=>{var G=O(F,!0);return G.buffer||(G=new Uint8Array(G)),G},M=(F,G,ee)=>{D(),F=K.normalize(F),j.readFile(F,function(ge,xe){ge?ee(ge):G(xe.buffer)})},process.argv.length>1&&(A=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function(F){if(!(F instanceof Ap))throw F}),process.on("unhandledRejection",function(F){throw F}),x=(F,G)=>{if(uo())throw process.exitCode=F,G;z(G),process.exit(F)},p.inspect=function(){return"[Emscripten Module object]"};let N;try{N=wR()}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||(O=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)}),M=(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=kR().performance);var Y=console.log.bind(console),V=console.warn.bind(console);I&&(D(),Y=N=>j.writeSync(1,N+` `),V=N=>j.writeSync(2,N+` `));var re=p.print||Y,Q=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,Q(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{Me=N},We=Atomics.load,Ke=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,_r;function hr(N,F){N||eu(F)}function Qr(N){var F=p["_"+N];return F}function rr(N,F,G,ee,ge){var xe={string:function(Cn){var du=0;if(Cn!=null&&Cn!==0){var Lb=(Cn.length<<2)+1;du=uu(Lb),oo(Cn,du,Lb)}return du},array:function(Cn){var du=uu(Cn.length);return Ua(Cn,du),du}};function Te(Cn){return F==="string"?In(Cn):F==="boolean"?Boolean(Cn):Cn}var Pe=Qr(N),Pt=[],ia=0;if(ee)for(var oa=0;oa(G.buffer instanceof SharedArrayBuffer&&(G=new Uint8Array(G)),F.decode.call(F,G))}var nr=typeof TextDecoder!="undefined"?new en("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&&nr)return nr.decode(N.subarray(F,ge));for(var xe="";F>10,56320|ia&1023)}}return xe}function In(N,F){return N?kn(i(),N,F):""}function gs(N,F,G,ee){if(!(ee>0))return 0;for(var ge=G,xe=G+ee-1,Te=0;Te=55296&&Pe<=57343){var Pt=N.charCodeAt(++Te);Pe=65536+((Pe&1023)<<10)|Pt&1023}if(Pe<=127){if(G>=xe)break;F[G++]=Pe}else if(Pe<=2047){if(G+1>=xe)break;F[G++]=192|Pe>>6,F[G++]=128|Pe&63}else if(Pe<=65535){if(G+2>=xe)break;F[G++]=224|Pe>>12,F[G++]=128|Pe>>6&63,F[G++]=128|Pe&63}else{if(G+3>=xe)break;F[G++]=240|Pe>>18,F[G++]=128|Pe>>12&63,F[G++]=128|Pe>>6&63,F[G++]=128|Pe&63}}return F[G]=0,G-ge}function oo(N,F,G){return gs(N,i(),F,G)}function gc(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 ys=typeof TextDecoder!="undefined"?new en("utf-16le"):void 0;function Ua(N,F){s().set(N,F)}function lp(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 Pr,yc,Ac,up,xc,bc,xb,vc,wc;T&&(Pr=p.buffer);function ra(N){Pr=N,p.HEAP8=yc=new Int8Array(N),p.HEAP16=up=new Int16Array(N),p.HEAP32=bc=new Int32Array(N),p.HEAPU8=Ac=new Uint8Array(N),p.HEAPU16=xc=new Uint16Array(N),p.HEAPU32=xb=new Uint32Array(N),p.HEAPF32=vc=new Float32Array(N),p.HEAPF64=wc=new Float64Array(N)}var kc=p.INITIAL_MEMORY||16777216;if(T)Fe=p.wasmMemory,Pr=p.buffer;else if(p.wasmMemory)Fe=p.wasmMemory;else if(Fe=new WebAssembly.Memory({initial:kc/65536,maximum:32768,shared:!0}),!(Fe.buffer instanceof SharedArrayBuffer))throw Q("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),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&&(Pr=Fe.buffer),kc=Pr.byteLength,ra(Pr);var Sn,Ql=[],As=[],M1=[],Ic=[],lo=!1,$1=!1,Sc=0;function uo(){return ht||Sc>0}function Or(){if(p.preRun)for(typeof p.preRun=="function"&&(p.preRun=[p.preRun]);p.preRun.length;)bb(p.preRun.shift());Rc(Ql)}function dp(){lo=!0,!T&&Rc(As)}function F1(){T||(Oe.terminateAllThreads(),$1=!0)}function _1(){if(!T){if(p.postRun)for(typeof p.postRun=="function"&&(p.postRun=[p.postRun]);p.postRun.length;)pp(p.postRun.shift());Rc(Ic)}}function bb(N){Ql.unshift(N)}function vb(N){As.unshift(N)}function pp(N){Ic.unshift(N)}var xs=0,Cc=null,na=null;function hp(N){xs++,p.monitorRunDependencies&&p.monitorRunDependencies(xs)}function wb(N){if(xs--,p.monitorRunDependencies&&p.monitorRunDependencies(xs),xs==0&&(Cc!==null&&(clearInterval(Cc),Cc=null),na)){var F=na;na=null,F()}}p.preloadedImages={},p.preloadedAudios={};function eu(N){T?postMessage({cmd:"onAbort",arg:N}):p.onAbort&&p.onAbort(N),N="Aborted("+N+")",Q(N),At=!0,_r=1,N+=". Build with -s ASSERTIONS=1 for more info.";var F=new WebAssembly.RuntimeError(N);throw m(F),F}var P1="data:application/octet-stream;base64,";function Tc(N){return N.startsWith(P1)}function Nc(N){return N.startsWith("file://")}var zr;zr="tfjs-backend-wasm-threaded-simd.wasm",Tc(zr)||(zr=R(zr));function Ec(N){try{if(N==zr&&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"&&!Nc(zr))return fetch(zr,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+zr+"'";return N.arrayBuffer()}).catch(function(){return Ec(zr)});if(M)return new Promise(function(N,F){M(zr,function(G){N(new Uint8Array(G))},F)})}return Promise.resolve().then(function(){return Ec(zr)})}function O1(){var N={env:Vc,wasi_snapshot_preview1:Vc};function F(Te,Pe){var Pt=Te.exports;if(p.asm=Pt,U1(p.asm.emscripten_tls_init),Sn=p.asm.__indirect_function_table,vb(p.asm.__wasm_call_ctors),wt=Pe,!T){var ia=Oe.unusedWorkers.length;Oe.unusedWorkers.forEach(function(oa){Oe.loadWasmModuleToWorker(oa,function(){--ia||wb("wasm-instantiate")})})}}T||hp("wasm-instantiate");function G(Te){F(Te.instance,Te.module)}function ee(Te){return tu().then(function(Pe){return WebAssembly.instantiate(Pe,N)}).then(function(Pe){return Pe}).then(Te,function(Pe){Q("failed to asynchronously prepare wasm: "+Pe),eu(Pe)})}function ge(){return!pt&&typeof WebAssembly.instantiateStreaming=="function"&&!Tc(zr)&&!Nc(zr)&&typeof fetch=="function"?fetch(zr,{credentials:"same-origin"}).then(function(Te){var Pe=WebAssembly.instantiateStreaming(Te,N);return Pe.then(G,function(Pt){return Q("wasm streaming compile failed: "+Pt),Q("falling back to ArrayBuffer instantiation"),ee(G)})}):ee(G)}if(p.instantiateWasm)try{var xe=p.instantiateWasm(N,F);return xe}catch(Te){return Q("Module.instantiateWasm callback failed with error: "+Te),!1}return ge().catch(m),{}}var kb,Ib,z1={};function Rc(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=ig(),G=N();return qc(F),G}function iE(N){return N}function Sb(N){var F=/\b_Z[\w\d_]+/g;return N.replace(F,function(G){var ee=G;return G===ee?G:ee+" ["+G+"]"})}function D1(N){u()[N>>2]=0;var F=Oe.pthreads[N];delete Oe.pthreads[N],F.worker.terminate(),sg(N),Oe.runningWorkers.splice(Oe.runningWorkers.indexOf(F.worker),1),F.worker.pthread=void 0}function L1(N){var F=Oe.pthreads[N];F.worker.postMessage({cmd:"cancel"})}function Mc(N){var F=Oe.pthreads[N];if(F){u()[N>>2]=0;var G=F.worker;Oe.returnWorkerToPool(G)}}function $c(N){KE(N)}function B1(N){if(N instanceof Ap||N=="unwind")return _r;x(1,N)}var Oe={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){T?Oe.initWorker():Oe.initMainThread()},initMainThread:function(){for(var N=8,F=0;F>2]=0;try{N()}finally{u()[Db>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in Oe.tlsInitFunctions)Oe.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,F){N.onmessage=G=>{var ee=G.data,ge=ee.cmd;if(N.pthread&&(Oe.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),ee.targetThread&&ee.targetThread!=Hc()){var xe=Oe.pthreads[ee.targetThread];xe?xe.worker.postMessage(ee,ee.transferList):Q('Internal error! Worker sent a message "'+ge+'" to target pthread '+ee.targetThread+", but that thread no longer exists!"),Oe.currentProxiedOperationCallerThread=void 0;return}ge==="processQueuedMainThreadWork"?Fb():ge==="spawnThread"?_c(ee):ge==="cleanupThread"?Mc(ee.thread):ge==="killThread"?D1(ee.thread):ge==="cancelThread"?L1(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"?Q("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):Q("worker sent an unknown command "+ge),Oe.currentProxiedOperationCallerThread=void 0},N.onerror=G=>{var ee="worker sent an error!";throw Q(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");Oe.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return Oe.unusedWorkers.length==0&&(Oe.allocateUnusedWorker(),Oe.loadWasmModuleToWorker(Oe.unusedWorkers[0])),Oe.unusedWorkers.pop()}};function W1(){var N=Hc(),F=u()[N+44>>2],G=u()[N+48>>2],ee=F-G;zb(F,ee),qc(F)}p.establishStackSpace=W1;function Fc(N){if(T)return co(1,0,N);try{$c(N)}catch(F){B1(F)}}var po=[];function nu(N){var F=po[N];return F||(N>=po.length&&(po.length=N+1),po[N]=F=Sn.get(N)),F}function V1(N,F){return nu(N)(F)}p.invokeEntryPoint=V1;function Cb(){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 U1(N,F,G){Oe.tlsInitFunctions.push(N)}function Tb(N,F){Sn.set(N,F),po[N]=F}var ho;I?ho=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:T?ho=()=>performance.now()-p.__performance_now_clock_drift:ho=()=>performance.now();var G1=!0;function j1(N){return u()[$b()>>2]=N,N}function H1(N,F){var G;if(N===0)G=Date.now();else if((N===1||N===4)&&G1)G=ho();else return j1(28),-1;return u()[F>>2]=G/1e3|0,u()[F+4>>2]=G%1e3*1e3*1e3|0,0}function q1(N,F){return H1(N,F)}function X1(N){_b(N,!w,1,!b),Oe.threadInit()}function K1(N){T?postMessage({cmd:"cleanupThread",thread:N}):Mc(N)}function _c(N){var F=Oe.getNewWorker();if(!F)return 6;Oe.runningWorkers.push(F);var G=Oe.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 Z1(N,F,G,ee){if(typeof SharedArrayBuffer=="undefined")return Q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ge=[],xe=0;if(T&&(ge.length===0||xe))return Pb(687865856,N,F,G,ee);if(xe)return xe;var Te={startRoutine:G,pthread_ptr:N,arg:ee,transferList:ge};return T?(Te.cmd="spawnThread",postMessage(Te,ge),0):_c(Te)}function Y1(){return 2097152}function J1(N,F){if(N==F)postMessage({cmd:"processQueuedMainThreadWork"});else if(T)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var G=Oe.pthreads[N],ee=G&&G.worker;if(!ee)return;ee.postMessage({cmd:"processThreadQueue"})}return 1}function Q1(){eu("")}function e2(){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 Pc(){return 2147483648}function t2(N,F,G){i().copyWithin(N,F,F+G)}function r2(){return I?IR().cpus().length:navigator.hardwareConcurrency}function co(N,F){var G=arguments.length-2,ee=arguments;return ru(function(){for(var ge=G,xe=uu(ge*8),Te=xe>>3,Pe=0;Pe>3,ge=0;ge>>16),ra(Fe.buffer),1}catch(F){}}function s2(N){var F=i().length;if(N=N>>>0,N<=F)return!1;var G=Pc();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 xe=Math.min(G,Jl(Math.max(N,ge),65536)),Te=a2(xe);if(Te)return!0}return!1}var Xe={inEventHandler:0,removeAllEventListeners:function(){for(var N=Xe.eventHandlers.length-1;N>=0;--N)Xe._removeHandler(N);Xe.eventHandlers=[],Xe.deferredCalls=[]},registerRemoveEventListeners:function(){Xe.removeEventListenersRegistered||(M1.push(Xe.removeAllEventListeners),Xe.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,F,G){function ee(Te,Pe){if(Te.length!=Pe.length)return!1;for(var Pt in Te)if(Te[Pt]!=Pe[Pt])return!1;return!0}for(var ge in Xe.deferredCalls){var xe=Xe.deferredCalls[ge];if(xe.targetFunction==N&&ee(xe.argsList,G))return}Xe.deferredCalls.push({targetFunction:N,precedence:F,argsList:G}),Xe.deferredCalls.sort(function(Te,Pe){return Te.precedence>2]=G,u()[xe+4>>2]=ee,u()[xe+8>>2]=ge,ag(N,637534208,F,ee,xe)})},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return Oe.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 i2(N){var F=gc(N)+1,G=ng(F);return oo(N,G,F),G}function o2(N,F,G,ee){ru(function(){var ge=uu(12),xe=0;F&&(xe=i2(F)),u()[ge>>2]=xe,u()[ge+4>>2]=G,u()[ge+8>>2]=ee,ag(N,657457152,0,xe,ge)})}function l2(N,F,G,ee){F=F?In(F):"",o2(N,F,G,ee)}function u2(N){return N>2?In(N):N}var d2=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function p2(N){N=u2(N);var F=d2[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return F}function fp(N){return p2(N)}function Oc(N,F,G){var ee=fp(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 xe=ee.GLctxObject.GLctx.getParameter(2978);ge=xe[0]===0&&xe[1]===0&&xe[2]===ee.width&&xe[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 l2(Te,N,F,G),1}else return-4;return 0}function zc(N,F,G){return T?co(2,1,N,F,G):Oc(N,F,G)}function h2(N,F,G){var ee=fp(N);return ee?Oc(N,F,G):zc(N,F,G)}function c2(){throw"unwind"}function f2(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,xe){F.drawArraysInstancedANGLE(G,ee,ge,xe)},N.drawElementsInstanced=function(G,ee,ge,xe,Te){F.drawElementsInstancedANGLE(G,ee,ge,xe,Te)},1}function m2(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 g2(N){var F=N.getExtension("WEBGL_draw_buffers");if(F)return N.drawBuffers=function(G,ee){F.drawBuffersWEBGL(G,ee)},1}function y2(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var _t={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(N){_t.lastError||(_t.lastError=N)},getNewId:function(N){for(var F=_t.counter++,G=N.length;G>2]:-1;ge+=In(u()[G+xe*4>>2],Te<0?void 0:Te)}return ge},createContext:function(N,F){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(ge,xe){var Te=N.getContextSafariWebGL2Fixed(ge,xe);return ge=="webgl"==Te instanceof WebGLRenderingContext?Te:null});var G=N.getContext("webgl",F);if(!G)return 0;var ee=_t.registerContext(G,F);return ee},registerContext:function(N,F){var G=ng(8);u()[G+4>>2]=Hc();var ee={handle:G,attributes:F,version:F.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=ee),_t.contexts[G]=ee,(typeof F.enableExtensionsByDefault=="undefined"||F.enableExtensionsByDefault)&&_t.initExtensions(ee),G},makeContextCurrent:function(N){return _t.currentContext=_t.contexts[N],p.ctx=Wc=_t.currentContext&&_t.currentContext.GLctx,!(N&&!Wc)},getContext:function(N){return _t.contexts[N]},deleteContext:function(N){_t.currentContext===_t.contexts[N]&&(_t.currentContext=null),typeof Xe=="object"&&Xe.removeAllHandlersOnTarget(_t.contexts[N].GLctx.canvas),_t.contexts[N]&&_t.contexts[N].GLctx.canvas&&(_t.contexts[N].GLctx.canvas.GLctxObject=void 0),Mb(_t.contexts[N].handle),_t.contexts[N]=null},initExtensions:function(N){if(N||(N=_t.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var F=N.GLctx;f2(F),m2(F),g2(F),F.disjointTimerQueryExt=F.getExtension("EXT_disjoint_timer_query"),y2(F);var G=F.getSupportedExtensions()||[];G.forEach(function(ee){!ee.includes("lose_context")&&!ee.includes("debug")&&F.getExtension(ee)})}}},A2=["default","low-power","high-performance"];function x2(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:A2[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]},xe=fp(N);if(!xe||ge.explicitSwapControl)return 0;var Te=_t.createContext(xe,ge);return Te}function b2(N,F){return x2(N,F)}var au={mappings:{},buffers:[null,[],[]],printChar:function(N,F){var G=au.buffers[N];F===0||F===10?((N===1?re:Q)(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 Dc(N){return T?co(3,1,N):0}function Lc(N,F,G,ee,ge){if(T)return co(4,1,N,F,G,ee,ge)}function Bc(N,F,G,ee){if(T)return co(5,1,N,F,G,ee);for(var ge=0,xe=0;xe>2],Pe=u()[F+4>>2];F+=8;for(var Pt=0;Pt>2]=ge,0}function v2(N){De(N)}Oe.init();var Wc,w2=[null,Fc,zc,Dc,Lc,Bc],Nb=!1,Vc={__clock_gettime:q1,__emscripten_init_main_thread_js:X1,__emscripten_thread_cleanup:K1,__pthread_create_js:Z1,_emscripten_default_pthread_stack_size:Y1,_emscripten_notify_thread_queue:J1,abort:Q1,emscripten_check_blocking_allowed:e2,emscripten_get_heap_max:Pc,emscripten_get_now:ho,emscripten_memcpy_big:t2,emscripten_num_logical_cores:r2,emscripten_receive_on_main_thread_js:n2,emscripten_resize_heap:s2,emscripten_set_canvas_element_size:h2,emscripten_unwind_to_js_event_loop:c2,emscripten_webgl_create_context:b2,exit:$c,fd_close:Dc,fd_seek:Lc,fd_write:Bc,memory:Fe||p.wasmMemory,setTempRet0:v2},Eb=O1(),k2=p.___wasm_call_ctors=function(){return(k2=p.___wasm_call_ctors=p.asm.__wasm_call_ctors).apply(null,arguments)},I2=p._init=function(){return(I2=p._init=p.asm.init).apply(null,arguments)},S2=p._init_with_threads_count=function(){return(S2=p._init_with_threads_count=p.asm.init_with_threads_count).apply(null,arguments)},C2=p._get_threads_count=function(){return(C2=p._get_threads_count=p.asm.get_threads_count).apply(null,arguments)},T2=p._register_tensor=function(){return(T2=p._register_tensor=p.asm.register_tensor).apply(null,arguments)},N2=p._dispose_data=function(){return(N2=p._dispose_data=p.asm.dispose_data).apply(null,arguments)},E2=p._dispose=function(){return(E2=p._dispose=p.asm.dispose).apply(null,arguments)},R2=p._Abs=function(){return(R2=p._Abs=p.asm.Abs).apply(null,arguments)},M2=p._Add=function(){return(M2=p._Add=p.asm.Add).apply(null,arguments)},$2=p._AddN=function(){return($2=p._AddN=p.asm.AddN).apply(null,arguments)},F2=p._All=function(){return(F2=p._All=p.asm.All).apply(null,arguments)},_2=p._Any=function(){return(_2=p._Any=p.asm.Any).apply(null,arguments)},P2=p._ArgMax=function(){return(P2=p._ArgMax=p.asm.ArgMax).apply(null,arguments)},O2=p._AvgPool=function(){return(O2=p._AvgPool=p.asm.AvgPool).apply(null,arguments)},z2=p._BatchMatMul=function(){return(z2=p._BatchMatMul=p.asm.BatchMatMul).apply(null,arguments)},D2=p._Ceil=function(){return(D2=p._Ceil=p.asm.Ceil).apply(null,arguments)},L2=p._ClipByValue=function(){return(L2=p._ClipByValue=p.asm.ClipByValue).apply(null,arguments)},B2=p._Conv2D=function(){return(B2=p._Conv2D=p.asm.Conv2D).apply(null,arguments)},W2=p._Conv2DBackpropInput=function(){return(W2=p._Conv2DBackpropInput=p.asm.Conv2DBackpropInput).apply(null,arguments)},V2=p._Cos=function(){return(V2=p._Cos=p.asm.Cos).apply(null,arguments)},U2=p._Cosh=function(){return(U2=p._Cosh=p.asm.Cosh).apply(null,arguments)},G2=p._CropAndResize=function(){return(G2=p._CropAndResize=p.asm.CropAndResize).apply(null,arguments)},j2=p._Cumprod=function(){return(j2=p._Cumprod=p.asm.Cumprod).apply(null,arguments)},H2=p._Cumsum=function(){return(H2=p._Cumsum=p.asm.Cumsum).apply(null,arguments)},q2=p._DepthToSpace=function(){return(q2=p._DepthToSpace=p.asm.DepthToSpace).apply(null,arguments)},X2=p._DepthwiseConv2dNative=function(){return(X2=p._DepthwiseConv2dNative=p.asm.DepthwiseConv2dNative).apply(null,arguments)},K2=p._Elu=function(){return(K2=p._Elu=p.asm.Elu).apply(null,arguments)},Z2=p._Equal=function(){return(Z2=p._Equal=p.asm.Equal).apply(null,arguments)},Y2=p._Exp=function(){return(Y2=p._Exp=p.asm.Exp).apply(null,arguments)},J2=p._FlipLeftRight=function(){return(J2=p._FlipLeftRight=p.asm.FlipLeftRight).apply(null,arguments)},Uc=p._Floor=function(){return(Uc=p._Floor=p.asm.Floor).apply(null,arguments)},Gc=p._FloorDiv=function(){return(Gc=p._FloorDiv=p.asm.FloorDiv).apply(null,arguments)},mp=p._FusedBatchNorm=function(){return(mp=p._FusedBatchNorm=p.asm.FusedBatchNorm).apply(null,arguments)},Q2=p._FusedConv2D=function(){return(Q2=p._FusedConv2D=p.asm.FusedConv2D).apply(null,arguments)},eg=p._FusedDepthwiseConv2D=function(){return(eg=p._FusedDepthwiseConv2D=p.asm.FusedDepthwiseConv2D).apply(null,arguments)},su=p._Gather=function(){return(su=p._Gather=p.asm.Gather).apply(null,arguments)},gp=p._GatherNd=function(){return(gp=p._GatherNd=p.asm.GatherNd).apply(null,arguments)},yp=p._Greater=function(){return(yp=p._Greater=p.asm.Greater).apply(null,arguments)},Rb=p._GreaterEqual=function(){return(Rb=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)},tg=p._LessEqual=function(){return(tg=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)},Ze=p._Min=function(){return(Ze=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)},fo=p._NonMaxSuppressionV4=function(){return(fo=p._NonMaxSuppressionV4=p.asm.NonMaxSuppressionV4).apply(null,arguments)},rg=p._NonMaxSuppressionV5=function(){return(rg=p._NonMaxSuppressionV5=p.asm.NonMaxSuppressionV5).apply(null,arguments)},tn=p._NotEqual=function(){return(tn=p._NotEqual=p.asm.NotEqual).apply(null,arguments)},bs=p._OneHot=function(){return(bs=p._OneHot=p.asm.OneHot).apply(null,arguments)},jc=p._PadV2=function(){return(jc=p._PadV2=p.asm.PadV2).apply(null,arguments)},oE=p._Pow=function(){return(oE=p._Pow=p.asm.Pow).apply(null,arguments)},lE=p._Prelu=function(){return(lE=p._Prelu=p.asm.Prelu).apply(null,arguments)},uE=p._Prod=function(){return(uE=p._Prod=p.asm.Prod).apply(null,arguments)},dE=p._RealDiv=function(){return(dE=p._RealDiv=p.asm.RealDiv).apply(null,arguments)},pE=p._Relu=function(){return(pE=p._Relu=p.asm.Relu).apply(null,arguments)},hE=p._Relu6=function(){return(hE=p._Relu6=p.asm.Relu6).apply(null,arguments)},cE=p._ResizeBilinear=function(){return(cE=p._ResizeBilinear=p.asm.ResizeBilinear).apply(null,arguments)},fE=p._Reverse=function(){return(fE=p._Reverse=p.asm.Reverse).apply(null,arguments)},mE=p._RotateWithOffset=function(){return(mE=p._RotateWithOffset=p.asm.RotateWithOffset).apply(null,arguments)},gE=p._Round=function(){return(gE=p._Round=p.asm.Round).apply(null,arguments)},yE=p._Rsqrt=function(){return(yE=p._Rsqrt=p.asm.Rsqrt).apply(null,arguments)},AE=p._ScatterNd=function(){return(AE=p._ScatterNd=p.asm.ScatterNd).apply(null,arguments)},xE=p._SelectV2=function(){return(xE=p._SelectV2=p.asm.SelectV2).apply(null,arguments)},bE=p._Sigmoid=function(){return(bE=p._Sigmoid=p.asm.Sigmoid).apply(null,arguments)},vE=p._Sin=function(){return(vE=p._Sin=p.asm.Sin).apply(null,arguments)},wE=p._Softmax=function(){return(wE=p._Softmax=p.asm.Softmax).apply(null,arguments)},kE=p._SparseFillEmptyRows=function(){return(kE=p._SparseFillEmptyRows=p.asm.SparseFillEmptyRows).apply(null,arguments)},IE=p._SparseReshape=function(){return(IE=p._SparseReshape=p.asm.SparseReshape).apply(null,arguments)},SE=p._SparseSegmentReduction=function(){return(SE=p._SparseSegmentReduction=p.asm.SparseSegmentReduction).apply(null,arguments)},CE=p._Sqrt=function(){return(CE=p._Sqrt=p.asm.Sqrt).apply(null,arguments)},TE=p._Square=function(){return(TE=p._Square=p.asm.Square).apply(null,arguments)},NE=p._SquaredDifference=function(){return(NE=p._SquaredDifference=p.asm.SquaredDifference).apply(null,arguments)},EE=p._Step=function(){return(EE=p._Step=p.asm.Step).apply(null,arguments)},RE=p._StridedSlice=function(){return(RE=p._StridedSlice=p.asm.StridedSlice).apply(null,arguments)},ME=p._Sub=function(){return(ME=p._Sub=p.asm.Sub).apply(null,arguments)},$E=p._Sum=function(){return($E=p._Sum=p.asm.Sum).apply(null,arguments)},FE=p._Tan=function(){return(FE=p._Tan=p.asm.Tan).apply(null,arguments)},_E=p._Tanh=function(){return(_E=p._Tanh=p.asm.Tanh).apply(null,arguments)},PE=p._Tile=function(){return(PE=p._Tile=p.asm.Tile).apply(null,arguments)},OE=p._TopK=function(){return(OE=p._TopK=p.asm.TopK).apply(null,arguments)},zE=p._Transform=function(){return(zE=p._Transform=p.asm.Transform).apply(null,arguments)},DE=p._Transpose=function(){return(DE=p._Transpose=p.asm.Transpose).apply(null,arguments)},LE=p.__FusedMatMul=function(){return(LE=p.__FusedMatMul=p.asm._FusedMatMul).apply(null,arguments)},ng=p._malloc=function(){return(ng=p._malloc=p.asm.malloc).apply(null,arguments)},Mb=p._free=function(){return(Mb=p._free=p.asm.free).apply(null,arguments)},BE=p._emscripten_tls_init=function(){return(BE=p._emscripten_tls_init=p.asm.emscripten_tls_init).apply(null,arguments)},$b=p.___errno_location=function(){return($b=p.___errno_location=p.asm.__errno_location).apply(null,arguments)},Hc=p._pthread_self=function(){return(Hc=p._pthread_self=p.asm.pthread_self).apply(null,arguments)},Fb=p._emscripten_main_thread_process_queued_calls=function(){return(Fb=p._emscripten_main_thread_process_queued_calls=p.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},WE=p.__emscripten_thread_crashed=function(){return(WE=p.__emscripten_thread_crashed=p.asm._emscripten_thread_crashed).apply(null,arguments)},_b=p.__emscripten_thread_init=function(){return(_b=p.__emscripten_thread_init=p.asm._emscripten_thread_init).apply(null,arguments)},VE=p._emscripten_current_thread_process_queued_calls=function(){return(VE=p._emscripten_current_thread_process_queued_calls=p.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},UE=p._emscripten_main_browser_thread_id=function(){return(UE=p._emscripten_main_browser_thread_id=p.asm.emscripten_main_browser_thread_id).apply(null,arguments)},GE=p._emscripten_sync_run_in_main_thread_2=function(){return(GE=p._emscripten_sync_run_in_main_thread_2=p.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},Pb=p._emscripten_sync_run_in_main_thread_4=function(){return(Pb=p._emscripten_sync_run_in_main_thread_4=p.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},Ob=p._emscripten_run_in_main_runtime_thread_js=function(){return(Ob=p._emscripten_run_in_main_runtime_thread_js=p.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},ag=p._emscripten_dispatch_to_thread_=function(){return(ag=p._emscripten_dispatch_to_thread_=p.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},sg=p.__emscripten_thread_free_data=function(){return(sg=p.__emscripten_thread_free_data=p.asm._emscripten_thread_free_data).apply(null,arguments)},jE=p.__emscripten_thread_exit=function(){return(jE=p.__emscripten_thread_exit=p.asm._emscripten_thread_exit).apply(null,arguments)},HE=p._memalign=function(){return(HE=p._memalign=p.asm.memalign).apply(null,arguments)},zb=p._emscripten_stack_set_limits=function(){return(zb=p._emscripten_stack_set_limits=p.asm.emscripten_stack_set_limits).apply(null,arguments)},ig=p.stackSave=function(){return(ig=p.stackSave=p.asm.stackSave).apply(null,arguments)},qc=p.stackRestore=function(){return(qc=p.stackRestore=p.asm.stackRestore).apply(null,arguments)},uu=p.stackAlloc=function(){return(uu=p.stackAlloc=p.asm.stackAlloc).apply(null,arguments)},qE=p.dynCall_iijjiiii=function(){return(qE=p.dynCall_iijjiiii=p.asm.dynCall_iijjiiii).apply(null,arguments)},XE=p.dynCall_jiji=function(){return(XE=p.dynCall_jiji=p.asm.dynCall_jiji).apply(null,arguments)},Db=p.__emscripten_allow_main_runtime_queued_calls=21456;p.cwrap=cr,p.keepRuntimeAlive=uo,p.PThread=Oe,p.PThread=Oe,p.wasmMemory=Fe,p.ExitStatus=Ap;var Xc;function Ap(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}na=function N(){Xc||og(),Xc||(na=N)};function og(N){if(N=N||y,xs>0)return;if(T){c(p),dp(),postMessage({cmd:"loaded"});return}if(Or(),xs>0)return;function F(){Xc||(Xc=!0,p.calledRun=!0,!At&&(dp(),c(p),p.onRuntimeInitialized&&p.onRuntimeInitialized(),_1()))}p.setStatus?(p.setStatus("Running..."),setTimeout(function(){setTimeout(function(){p.setStatus("")},1),F()},1)):F()}p.run=og;function KE(N,F){if(_r=N,!F&&T)throw Fc(N),"unwind";uo()||F1(),ZE(N)}function ZE(N){_r=N,uo()||(Oe.terminateAllThreads(),p.onExit&&p.onExit(N),At=!0),x(N,new Ap(N))}if(p.preInit)for(typeof p.preInit=="function"&&(p.preInit=[p.preInit]);p.preInit.length>0;)p.preInit.pop()();og();var Kc;f&&(Kc={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 Zc;if(typeof WasmBackendModule!="undefined")Zc=WasmBackendModule;else if(typeof a!="undefined")Zc=a;else throw new Error("Could not find wasm module in post.js");if(Kc){var YE=Zc._dispose;Zc._dispose=function(){YE(),Kc.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Kc.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)}}),CR=dr({"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 gp||M("exiting due to exception: "+H)}var T,E,R;f?(m?g=k0().dirname(g)+"/":g=__dirname+"/",R=()=>{E||(T=ky(),E=k0())},A=function(H,ne){return R(),H=E.normalize(H),T.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),T.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 gp))throw H}),process.on("unhandledRejection",function(H){throw H}),p=(H,ne)=>{if(up())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 O=s.print||console.log.bind(console),M=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,M(H))}function z(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},Q;s.wasmBinary&&(Q=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&lo("no native wasm support detected");var J,ae=!1,de;function be(H,ne){H||lo(ne)}function ve(H){var ne=s["_"+H];return ne}function Ee(H,ne,ye,Re,lt){var ct={string:function(tn){var bs=0;if(tn!=null&&tn!==0){var jc=(tn.length<<2)+1;bs=mp(jc),ht(tn,bs,jc)}return bs},array:function(tn){var bs=mp(tn.length);return At(tn,bs),bs}};function Ze(tn){return ne==="string"?ot(tn):ne==="boolean"?Boolean(tn):tn}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?Ke(cr,H,ne):""}function pt(H,ne,ye,Re){if(!(Re>0))return 0;for(var lt=ye,ct=ye+Re-1,Ze=0;Ze=55296&&He<=57343){var qt=H.charCodeAt(++Ze);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,cr,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){rr.set(H,ne)}function _r(H,ne,ye){for(var Re=0;Re>0]=H.charCodeAt(Re);ye||(rr[ne>>0]=0)}function hr(H,ne){return H%ne>0&&(H+=ne-H%ne),H}var Qr,rr,cr,ta,en,nr,kn,In,gs;function oo(H){Qr=H,s.HEAP8=rr=new Int8Array(H),s.HEAP16=ta=new Int16Array(H),s.HEAP32=nr=new Int32Array(H),s.HEAPU8=cr=new Uint8Array(H),s.HEAPU16=en=new Uint16Array(H),s.HEAPU32=kn=new Uint32Array(H),s.HEAPF32=In=new Float32Array(H),s.HEAPF64=gs=new Float64Array(H)}var gc=s.INITIAL_MEMORY||16777216,ys,Ua=[],lp=[],Jl=[],Pr=!1,yc=!1,Ac=0;function up(){return ie||Ac>0}function xc(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)wc(s.preRun.shift());pp(Ua)}function bc(){Pr=!0,pp(lp)}function xb(){yc=!0}function vc(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)kc(s.postRun.shift());pp(Jl)}function wc(H){Ua.unshift(H)}function ra(H){lp.unshift(H)}function kc(H){Jl.unshift(H)}var Sn=0,Ql=null,As=null;function M1(H){Sn++,s.monitorRunDependencies&&s.monitorRunDependencies(Sn)}function Ic(H){if(Sn--,s.monitorRunDependencies&&s.monitorRunDependencies(Sn),Sn==0&&(Ql!==null&&(clearInterval(Ql),Ql=null),As)){var ne=As;As=null,ne()}}s.preloadedImages={},s.preloadedAudios={};function lo(H){s.onAbort&&s.onAbort(H),H="Aborted("+H+")",M(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 $1="data:application/octet-stream;base64,";function Sc(H){return H.startsWith($1)}function uo(H){return H.startsWith("file://")}var Or;Or="tfjs-backend-wasm.wasm",Sc(Or)||(Or=y(Or));function dp(H){try{if(H==Or&&Q)return new Uint8Array(Q);if(b)return b(H);throw"both async and sync fetching of the wasm failed"}catch(ne){lo(ne)}}function F1(){if(!Q&&(c||m)){if(typeof fetch=="function"&&!uo(Or))return fetch(Or,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+Or+"'";return H.arrayBuffer()}).catch(function(){return dp(Or)});if(x)return new Promise(function(H,ne){x(Or,function(ye){H(new Uint8Array(ye))},ne)})}return Promise.resolve().then(function(){return dp(Or)})}function _1(){var H={env:ru,wasi_snapshot_preview1:ru};function ne(Ze,He){var qt=Ze.exports;s.asm=qt,J=s.asm.memory,oo(J.buffer),ys=s.asm.__indirect_function_table,ra(s.asm.__wasm_call_ctors),Ic("wasm-instantiate")}M1("wasm-instantiate");function ye(Ze){ne(Ze.instance)}function Re(Ze){return F1().then(function(He){return WebAssembly.instantiate(He,H)}).then(function(He){return He}).then(Ze,function(He){M("failed to asynchronously prepare wasm: "+He),lo(He)})}function lt(){return!Q&&typeof WebAssembly.instantiateStreaming=="function"&&!Sc(Or)&&!uo(Or)&&typeof fetch=="function"?fetch(Or,{credentials:"same-origin"}).then(function(Ze){var He=WebAssembly.instantiateStreaming(Ze,H);return He.then(ye,function(qt){return M("wasm streaming compile failed: "+qt),M("falling back to ArrayBuffer instantiation"),Re(ye)})}):Re(ye)}if(s.instantiateWasm)try{var ct=s.instantiateWasm(H,ne);return ct}catch(Ze){return M("Module.instantiateWasm callback failed with error: "+Ze),!1}return lt().catch(o),{}}var bb,vb;function pp(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?hp(ye)():hp(ye)(ne.arg):ye(ne.arg===void 0?null:ne.arg)}}function xs(H){return H}function Cc(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 hp(H){var ne=na[H];return ne||(H>=na.length&&(na.length=H+1),na[H]=ne=ys.get(H)),ne}function wb(){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){ys.set(H,ne),na[H]=ne}function P1(){lo("")}function Tc(H,ne,ye){cr.copyWithin(H,ne,ne+ye)}function Nc(){return 2147483648}function zr(H){try{return J.grow(H-Qr.byteLength+65535>>>16),oo(J.buffer),1}catch(ne){}}function Ec(H){var ne=cr.length;H=H>>>0;var ye=Nc();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,hr(Math.max(H,lt),65536)),Ze=zr(ct);if(Ze)return!0}return!1}var tu={mappings:{},buffers:[null,[],[]],printChar:function(H,ne){var ye=tu.buffers[H];ne===0||ne===10?((H===1?O:M)(Ke(ye,0)),ye.length=0):ye.push(ne)},varargs:void 0,get:function(){tu.varargs+=4;var H=nr[tu.varargs-4>>2];return H},getStr:function(H){var ne=ot(H);return ne},get64:function(H,ne){return H}};function O1(H){return 0}function kb(H,ne,ye,Re,lt){}function Ib(H,ne,ye,Re){for(var lt=0,ct=0;ct>2],He=nr[ne+4>>2];ne+=8;for(var qt=0;qt>2]=lt,0}function z1(H){re(H)}var Rc=!1,ru={abort:P1,emscripten_memcpy_big:Tc,emscripten_resize_heap:Ec,fd_close:O1,fd_seek:kb,fd_write:Ib,setTempRet0:z1},iE=_1(),Sb=s.___wasm_call_ctors=function(){return(Sb=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},D1=s._init=function(){return(D1=s._init=s.asm.init).apply(null,arguments)},L1=s._init_with_threads_count=function(){return(L1=s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},Mc=s._get_threads_count=function(){return(Mc=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},$c=s._register_tensor=function(){return($c=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},B1=s._dispose_data=function(){return(B1=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},Oe=s._dispose=function(){return(Oe=s._dispose=s.asm.dispose).apply(null,arguments)},W1=s._Abs=function(){return(W1=s._Abs=s.asm.Abs).apply(null,arguments)},Fc=s._Add=function(){return(Fc=s._Add=s.asm.Add).apply(null,arguments)},po=s._AddN=function(){return(po=s._AddN=s.asm.AddN).apply(null,arguments)},nu=s._All=function(){return(nu=s._All=s.asm.All).apply(null,arguments)},V1=s._Any=function(){return(V1=s._Any=s.asm.Any).apply(null,arguments)},Cb=s._ArgMax=function(){return(Cb=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},U1=s._AvgPool=function(){return(U1=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},Tb=s._BatchMatMul=function(){return(Tb=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},ho=s._Ceil=function(){return(ho=s._Ceil=s.asm.Ceil).apply(null,arguments)},G1=s._ClipByValue=function(){return(G1=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},j1=s._Conv2D=function(){return(j1=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},H1=s._Conv2DBackpropInput=function(){return(H1=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},q1=s._Cos=function(){return(q1=s._Cos=s.asm.Cos).apply(null,arguments)},X1=s._Cosh=function(){return(X1=s._Cosh=s.asm.Cosh).apply(null,arguments)},K1=s._CropAndResize=function(){return(K1=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},_c=s._Cumprod=function(){return(_c=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},Z1=s._Cumsum=function(){return(Z1=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},Y1=s._DepthToSpace=function(){return(Y1=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},J1=s._DepthwiseConv2dNative=function(){return(J1=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},Q1=s._Elu=function(){return(Q1=s._Elu=s.asm.Elu).apply(null,arguments)},e2=s._Equal=function(){return(e2=s._Equal=s.asm.Equal).apply(null,arguments)},Pc=s._Exp=function(){return(Pc=s._Exp=s.asm.Exp).apply(null,arguments)},t2=s._FlipLeftRight=function(){return(t2=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},r2=s._Floor=function(){return(r2=s._Floor=s.asm.Floor).apply(null,arguments)},co=s._FloorDiv=function(){return(co=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},cp=s._FusedBatchNorm=function(){return(cp=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},n2=s._FusedConv2D=function(){return(n2=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},a2=s._FusedDepthwiseConv2D=function(){return(a2=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},s2=s._Gather=function(){return(s2=s._Gather=s.asm.Gather).apply(null,arguments)},Xe=s._GatherNd=function(){return(Xe=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},i2=s._Greater=function(){return(i2=s._Greater=s.asm.Greater).apply(null,arguments)},o2=s._GreaterEqual=function(){return(o2=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},l2=s._LeakyRelu=function(){return(l2=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},u2=s._Less=function(){return(u2=s._Less=s.asm.Less).apply(null,arguments)},d2=s._LessEqual=function(){return(d2=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},p2=s._Log=function(){return(p2=s._Log=s.asm.Log).apply(null,arguments)},fp=s._LogicalAnd=function(){return(fp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Oc=s._Max=function(){return(Oc=s._Max=s.asm.Max).apply(null,arguments)},zc=s._MaxPool=function(){return(zc=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},h2=s._Maximum=function(){return(h2=s._Maximum=s.asm.Maximum).apply(null,arguments)},c2=s._Mean=function(){return(c2=s._Mean=s.asm.Mean).apply(null,arguments)},f2=s._Min=function(){return(f2=s._Min=s.asm.Min).apply(null,arguments)},m2=s._Minimum=function(){return(m2=s._Minimum=s.asm.Minimum).apply(null,arguments)},g2=s._MirrorPad=function(){return(g2=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},y2=s._Multiply=function(){return(y2=s._Multiply=s.asm.Multiply).apply(null,arguments)},_t=s._Neg=function(){return(_t=s._Neg=s.asm.Neg).apply(null,arguments)},A2=s._NonMaxSuppressionV3=function(){return(A2=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},x2=s._NonMaxSuppressionV4=function(){return(x2=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},b2=s._NonMaxSuppressionV5=function(){return(b2=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},au=s._NotEqual=function(){return(au=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},Dc=s._OneHot=function(){return(Dc=s._OneHot=s.asm.OneHot).apply(null,arguments)},Lc=s._PadV2=function(){return(Lc=s._PadV2=s.asm.PadV2).apply(null,arguments)},Bc=s._Pow=function(){return(Bc=s._Pow=s.asm.Pow).apply(null,arguments)},v2=s._Prelu=function(){return(v2=s._Prelu=s.asm.Prelu).apply(null,arguments)},Wc=s._Prod=function(){return(Wc=s._Prod=s.asm.Prod).apply(null,arguments)},w2=s._RealDiv=function(){return(w2=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},Nb=s._Relu=function(){return(Nb=s._Relu=s.asm.Relu).apply(null,arguments)},Vc=s._Relu6=function(){return(Vc=s._Relu6=s.asm.Relu6).apply(null,arguments)},Eb=s._ResizeBilinear=function(){return(Eb=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},k2=s._Reverse=function(){return(k2=s._Reverse=s.asm.Reverse).apply(null,arguments)},I2=s._RotateWithOffset=function(){return(I2=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},S2=s._Round=function(){return(S2=s._Round=s.asm.Round).apply(null,arguments)},C2=s._Rsqrt=function(){return(C2=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},T2=s._ScatterNd=function(){return(T2=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},N2=s._SelectV2=function(){return(N2=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},E2=s._Sigmoid=function(){return(E2=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},R2=s._Sin=function(){return(R2=s._Sin=s.asm.Sin).apply(null,arguments)},M2=s._Softmax=function(){return(M2=s._Softmax=s.asm.Softmax).apply(null,arguments)},$2=s._SparseFillEmptyRows=function(){return($2=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},F2=s._SparseReshape=function(){return(F2=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},_2=s._SparseSegmentReduction=function(){return(_2=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},P2=s._Sqrt=function(){return(P2=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},O2=s._Square=function(){return(O2=s._Square=s.asm.Square).apply(null,arguments)},z2=s._SquaredDifference=function(){return(z2=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},D2=s._Step=function(){return(D2=s._Step=s.asm.Step).apply(null,arguments)},L2=s._StridedSlice=function(){return(L2=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},B2=s._Sub=function(){return(B2=s._Sub=s.asm.Sub).apply(null,arguments)},W2=s._Sum=function(){return(W2=s._Sum=s.asm.Sum).apply(null,arguments)},V2=s._Tan=function(){return(V2=s._Tan=s.asm.Tan).apply(null,arguments)},U2=s._Tanh=function(){return(U2=s._Tanh=s.asm.Tanh).apply(null,arguments)},G2=s._Tile=function(){return(G2=s._Tile=s.asm.Tile).apply(null,arguments)},j2=s._TopK=function(){return(j2=s._TopK=s.asm.TopK).apply(null,arguments)},H2=s._Transform=function(){return(H2=s._Transform=s.asm.Transform).apply(null,arguments)},q2=s._Transpose=function(){return(q2=s._Transpose=s.asm.Transpose).apply(null,arguments)},X2=s.__FusedMatMul=function(){return(X2=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},K2=s._malloc=function(){return(K2=s._malloc=s.asm.malloc).apply(null,arguments)},Z2=s._free=function(){return(Z2=s._free=s.asm.free).apply(null,arguments)},Y2=s.___errno_location=function(){return(Y2=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},J2=s._emscripten_main_thread_process_queued_calls=function(){return(J2=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Uc=s.stackSave=function(){return(Uc=s.stackSave=s.asm.stackSave).apply(null,arguments)},Gc=s.stackRestore=function(){return(Gc=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},mp=s.stackAlloc=function(){return(mp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},Q2=s.dynCall_iijjiiii=function(){return(Q2=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},eg=s.dynCall_jiji=function(){return(eg=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=Me;var su;function gp(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}As=function H(){su||yp(),su||(As=H)};function yp(H){if(H=H||d,Sn>0||(xc(),Sn>0))return;function ne(){su||(su=!0,s.calledRun=!0,!ae&&(bc(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),vc()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),ne()},1)):ne()}s.run=yp;function Rb(H){de=H,up()||(s.onExit&&s.onExit(H),ae=!0),p(H,new gp(H))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();yp();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 tg=ou._dispose;ou._dispose=function(){tg(),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)}}),TR=1e-7,NR=1e-4,rh=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?TR:NR}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 $7(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,t--,I0(e,t,r)}function ER(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--,I0(e,r,n),I0(t,r,n)}function Vp(e,t,r){return Math.max(e,Math.min(t,r))}function RR(e){return e%2===0?e:e+1}function I0(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function MR(e){let t=0;for(let r=0;rr+` Shapes ${e} and ${t} must match`)}function Uo(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)||Ir(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 LR(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 F7(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 _7(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 P7(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 O7(e,t){for(let r=0;rt+=r.length),t}function Ts(e){return typeof e=="string"||e instanceof String}function L7(e){return typeof e=="boolean"}function B7(e){return typeof e=="number"}function sf(e){return Array.isArray(e)?sf(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":B7(e)?"float32":Ts(e)?"string":L7(e)?"bool":"float32"}function Fs(e){return!!(e&&e.constructor&&e.call&&e.apply)}function S0(e,t){for(let r=t;r=0;--n)r[n]=r[n+1]*e[n+1];return r}function W7(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 W7(0,e,t,r)}function Iy(e,t){let r=of(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 Sy(e){e.forEach(t=>{_(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function VR(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]=HR(r,n)})}};function GR(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(r,...n)=>(jR(t,n[0],n[1]),n.join("="))),t}function jR(e,t,r){e[decodeURIComponent(t)]=decodeURIComponent(r||"")}function HR(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 qR(e){ba=e}var ug;function U7(){if(ug==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");ug=e}return ug}function XR(){let e=U7();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function Ty(e,t){let r=XR();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}var Go="Abs",Uu="Acos",Gu="Acosh",Ja="Add",Ks="AddN",ju="All",Hu="Any",Zs="ArgMax",qu="ArgMin",Xu="Asin",Ku="Asinh",Zu="Atan",Yu="Atanh",Ju="Atan2",Ys="AvgPool",lf="AvgPoolGrad",nh="AvgPool3D",uf="AvgPool3DGrad",Js="BatchMatMul",jo="BatchToSpaceND",df="Bincount",G7="BroadcastTo",pf="BroadcastArgs",Qs="Cast",ei="Ceil",Qa="ClipByValue",ah="Complex",sh="ComplexAbs",Ho="Concat",ti="Conv2D",hf="Conv2DBackpropFilter",ri="Conv2DBackpropInput",ih="Conv3D",cf="Conv3DBackpropFilterV2",ff="Conv3DBackpropInputV2",ni="Cos",ai="Cosh",qo="Cumprod",si="Cumsum",Xo="CropAndResize",mf="DenseBincount",Ko="DepthToSpace",ii="DepthwiseConv2dNative",gf="DepthwiseConv2dNativeBackpropFilter",yf="DepthwiseConv2dNativeBackpropInput",Af="Diag",oh="Dilation2D",C0="Dilation2DBackpropInput",T0="Dilation2DBackpropFilter",oi="RealDiv",lh="Einsum",li="Elu",xf="EluGrad",Qu="Erf",Zo="Equal",ui="Exp",Yo="ExpandDims",Jo="Expm1",bf="FFT",ed="Fill",Qo="FlipLeftRight",di="Floor",pi="FloorDiv",hi="FusedBatchNorm",el="GatherV2",tl="GatherNd",rl="Greater",ci="GreaterEqual",fi="Identity",vf="IFFT",uh="Imag",td="IsFinite",rd="IsInf",nd="IsNan",mi="LeakyRelu",nl="Less",al="LessEqual",wf="LinSpace",gi="Log",ad="Log1p",sl="LogicalAnd",sd="LogicalNot",dh="LogicalOr",j7="LogSoftmax",KR="LowerBound",ph="LRN",kf="LRNGrad",yi="Max",Ai="Maximum",xi="MaxPool",If="MaxPoolGrad",hh="MaxPool3D",Sf="MaxPool3DGrad",Cf="MaxPoolWithArgmax",bi="Mean",vi="Min",wi="Minimum",ki="MirrorPad",id="Mod",Tf="Multinomial",Ii="Multiply",il="Neg",ol="NotEqual",ll="NonMaxSuppressionV3",od="NonMaxSuppressionV4",ul="NonMaxSuppressionV5",dl="OnesLike",pl="OneHot",hl="Pack",Si="PadV2",ZR="Pool",Ci="Pow",Ti="Prelu",Ni="Prod",ld="Range",ch="Real",ud="Reciprocal",Ei="Relu",cl="Reshape",dd="ResizeNearestNeighbor",Nf="ResizeNearestNeighborGrad",Ri="ResizeBilinear",Ef="ResizeBilinearGrad",Mi="Relu6",fl="Reverse",ml="Round",$i="Rsqrt",gl="ScatterNd",Rf="SearchSorted",yl="Select",pd="Selu",Al="Slice",Fi="Sin",xl="Sinh",hd="Sign",_i="Sigmoid",cd="Softplus",Pi="Sqrt",Oi="Sum",bl="SpaceToBatchND",vl="SplitV",zi="Softmax",fh="SparseFillEmptyRows",fd="SparseReshape",mh="SparseSegmentMean",gh="SparseSegmentSum",yh="SparseToDense",Di="SquaredDifference",md="Square",wl="StridedSlice",Ah="StringNGrams",Mf="StringSplit",$f="StringToHashBucketFast",Li="Sub",kl="Tan",Bi="Tanh",es="Tile",Il="TopK",Sl="Transform",Ma="Transpose",Ff="Unique",Cl="Unpack",xh="UnsortedSegmentSum",YR="UpperBound",Tl="ZerosLike",Wi="Step",Up="FromPixels",Nl="RotateWithOffset",_s="_FusedMatMul",Ps="FusedConv2D",Os="FusedDepthwiseConv2D";function Cs(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.warn(...e)}function JR(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.log(...e)}var Cu=Ty("kernelRegistry",()=>new Map),Gp=Ty("gradRegistry",()=>new Map);function N0(e,t){let r=Ny(e,t);return Cu.get(r)}function Ig(e){return Gp.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=Ny(t,r);Cu.has(n)&&Cs(`The kernel '${t}' for backend '${r}' is already registered`),Cu.set(n,e)}function H7(e){let{kernelName:t}=e;Gp.has(t)&&Z().getBool("DEBUG")&&Cs(`Overriding the gradient for '${t}'`),Gp.set(t,e)}function QR(e,t){let r=Ny(e,t);if(!Cu.has(r))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Cu.delete(r)}function eM(e){if(!Gp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Gp.delete(e)}function tM(e,t){Fa(e).forEach(r=>{let n=Object.assign({},r,{backendName:t});qn(n)})}function Ny(e,t){return`${t}_${e}`}var v={};Be(v,{arraysEqual:()=>Xs,assert:()=>_,assertNonNegativeIntegerDimensions:()=>Sy,assertNonNull:()=>Uo,assertShapesMatch:()=>Gr,bytesFromStringArray:()=>D7,bytesPerElement:()=>kg,checkConversionForErrors:()=>O7,clamp:()=>Vp,computeStrides:()=>Vu,createScalarValue:()=>oM,createShuffledIndices:()=>zR,decodeString:()=>E0,distSquared:()=>FR,encodeString:()=>vh,fetch:()=>uM,fingerPrint64:()=>iM,flatten:()=>Mo,getArrayFromDType:()=>P7,getTypedArrayFromDType:()=>_7,hasEncodingLoss:()=>BR,hexToLong:()=>bh,indexToLoc:()=>UR,inferDtype:()=>sf,inferFromImplicitShape:()=>LR,isBoolean:()=>L7,isFunction:()=>Fs,isInt:()=>Su,isNumber:()=>B7,isPromise:()=>Cy,isScalarShape:()=>_R,isString:()=>Ts,isTypedArray:()=>Ir,isValidDtype:()=>z7,locToIndex:()=>VR,makeOnesTypedArray:()=>Iy,makeZerosNestedTypedArray:()=>WR,makeZerosTypedArray:()=>of,nearestDivisor:()=>S0,nearestLargerEven:()=>RR,now:()=>jp,parseAxisParam:()=>Hn,randUniform:()=>$R,repeatedTry:()=>DR,rightPad:()=>zp,shuffle:()=>$7,shuffleCombo:()=>ER,sizeFromShape:()=>It,sizeToSquarishShape:()=>OR,squeezeShape:()=>F7,sum:()=>MR,swap:()=>I0,tanh:()=>PR,toNestedArray:()=>bu,toTypedArray:()=>_f});var Ub=Vo(pR()),bo=Ub.default||Ub;function bh(e){return bo.fromString(e,!0,16)}var q7=bh("c3a5c85c97cb3127"),yo=bh("b492b66fbe98f273"),Dr=bh("9ae16a3b2f90404f");function Sg(e){return e.xor(e.shru(47))}function X7(e,t,r){let n=e.slice(t,t+r);return bo.fromBytes(Array.from(n),!0,!0)}function kt(e,t){return X7(e,t,8)}function Gb(e,t){return X7(e,t,4)}function fr(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Es(e,t,r=bh("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 rM(e,t,r,n,a,s){a=a.add(e),s=fr(s.add(a).add(n),21);let i=a;return a=a.add(t),a=a.add(r),s=s.add(fr(a,44)),[a.add(n),s.add(i)]}function Qc(e,t,r,n){return rM(kt(e,t),kt(e,t+8),kt(e,t+16),kt(e,t+24),r,n)}function nM(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=fr(a,37).mul(r).add(n),i=fr(n,25).add(a).mul(r);return Es(s,i,r)}if(t>=4){let r=Dr.add(t*2),n=Gb(e,0);return Es(n.shl(3).add(t),Gb(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 Sg(Dr.mul(s).xor(q7.mul(i))).mul(Dr)}return Dr}function aM(e,t=e.length){let r=Dr.add(t*2),n=kt(e,0).mul(yo),a=kt(e,8),s=kt(e,t-8).mul(r),i=kt(e,t-16).mul(Dr);return Es(fr(n.add(a),43).add(fr(s,30)).add(i),n.add(fr(a.add(Dr),18)).add(s),r)}function sM(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=fr(n.add(a),43).add(fr(s,30)).add(i),l=Es(o,n.add(fr(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 Es(fr(u.add(d),43).add(fr(h,30)).add(p),u.add(fr(d.add(n),18)).add(h),r)}function iM(e,t=e.length){let r=bo.fromNumber(81,!0);if(t<=32)return t<=16?nM(e,t):aM(e,t);if(t<=64)return sM(e,t);let n=r,a=r.mul(yo).add(113),s=Sg(a.mul(Dr).add(113)).mul(Dr),i=[bo.UZERO,bo.UZERO],o=[bo.UZERO,bo.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=fr(n.add(a).add(i[0]).add(kt(e,l+8)),37).mul(yo),a=fr(a.add(i[1]).add(kt(e,l+48)),42).mul(yo),n=n.xor(o[1]),a=a.add(i[0]).add(kt(e,l+40)),s=fr(s.add(o[0]),33).mul(yo),i=Qc(e,l,i[1].mul(yo),n.add(o[0])),o=Qc(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],l+=64;while(l!==u);let h=yo.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=fr(n.add(a).add(i[0]).add(kt(e,l+8)),37).mul(h),a=fr(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=fr(s.add(o[0]),33).mul(h),i=Qc(e,l,i[1].mul(h),n.add(o[0])),o=Qc(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],Es(Es(i[0],o[0],h).add(Sg(a).mul(q7)).add(s),Es(i[1],o[1],h).add(n),h)}function oM(e,t){return t==="string"?vh(e):_f([e],t)}function lM(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function _f(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")&&O7(e,t),lM(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=jp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(a);else{a();for(let o of n)o.dataSync();s=Promise.resolve({kernelMs:jp()-i})}if(Z().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{pM(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 pM(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 cM(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(!Xs(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 jb=20,kp=3,dg=7;function mM(e,t,r,n){let a=Vu(t),s=gM(e,t,r,a),i=t.length,o=p0(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 gM(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"?Np(e):e;if(o>1)for(let u=0;ujb){let g=kp*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-kp)*i,o*i));return r==="complex64"&&(y=Np(y),A=Np(A)),["["+y.map((x,b)=>Tp(x,a[b],r)).join(", ")+", ..., "+A.map((x,b)=>Tp(x,a[o-kp+b],r)).join(", ")+"]"]}let f=r==="complex64"?Np(e):Array.from(e);return["["+f.map((g,y)=>Tp(g,a[y],r)).join(", ")+"]"]}let u=t.slice(1),d=n.slice(1),h=n[0]*i,p=[];if(o>jb){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||P7(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;nE0(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=>E0(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 mM(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 vM(){return Ty("Tensor",()=>nt)}vM();var Hp=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(!Xs(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(Hp,Symbol.hasInstance,{value:e=>e instanceof nt&&e.assign!=null&&e.assign instanceof Function});var ha={};Be(ha,{assertTypesMatch:()=>t6,getTensorsInContainer:()=>Ey,isTensorInList:()=>kM,makeTypesMatch:()=>Lt});var Z7=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(Z7||{}),Y7=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(Y7||{}),J7=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(J7||{}),Q7=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(Q7||{}),e6=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(e6||{}),wM={float32:Q7,int32:Y7,bool:J7,complex64:e6};function Tr(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return wM[e][t]}function wh(e){return Tr(e,"int32")}function Lt(e,t){if(e.dtype===t.dtype)return[e,t];let r=Tr(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function t6(e,t){_(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function kM(e,t){return t.some(r=>r.id===e.id)}function Ey(e){let t=[];return r6(e,t,new Set),t}function r6(e,t,r){if(e==null)return;if(e instanceof nt){t.push(e);return}if(!IM(e))return;let n=e;for(let a in n){let s=n[a];r.has(s)||(r.add(s),r6(s,t,r))}}function IM(e){return Array.isArray(e)||typeof e=="object"}function pg(e){return e.kernelName!=null}var Hb=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()}},Cg=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Hb}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 Cg.nextTensorId++}nextVariableId(){return Cg.nextVariableId++}clone(e){let t=B.runKernel(fi,{x:e}),r={x:e},n=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return B.runKernel(Qs,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,N0(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=pg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(pg(e)){let{kernelName:c,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=N0(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=pg(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=Ig(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"&&Ts(e[0])&&(a=e.map(o=>vh(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=D7(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 Hp(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*kg(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 Hp||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*kg(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=Ig(e);o!=null&&(n=o.gradFunc),n!=null&&(i.gradient=l=>(l=l.map((u,d)=>{if(u==null){let h=r[d],p=of(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=Ey(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=cM(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?SM(a.shape):r,fM(i,s,l=>this.tidy(l),CM);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 _(Fs(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"),_(Fs(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=jp(),r=await this.backend.time(e);return r.wallMs=jp()-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 Hb;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}},Ry=Cg;Ry.nextTensorId=0;Ry.nextVariableId=0;function SM(e){let t=Iy(It(e),"float32");return B.makeTensor(t,e,"float32")}function n6(){let e=U7();if(e._tfengine==null){let t=new V7(e);e._tfengine=new Ry(t)}return qR(e._tfengine.ENV),AM(()=>e._tfengine),e._tfengine}var B=n6();function CM(e,t){let r={a:e,b:t};return B.runKernel(Ja,r)}var kh={};Be(kh,{isBrowser:()=>a6,isMobile:()=>EM,mockIsMobile:()=>NM});function TM(){return typeof navigator!="undefined"&&navigator!=null}var Tg;function NM(e){Tg=e}function EM(e){if(Tg!==void 0)return Tg;if(e||TM()){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 a6(){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",()=>a6());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 _a(e,t){let r=e;if(Ir(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let n=[];for(;Array.isArray(r)||Ir(r)&&t!=="string";)n.push(r.length),r=r[0];return Array.isArray(e)&&Z().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&s6(e,n,[]),n}function s6(e,t,r){if(r=r||[],!Array.isArray(e)&&!Ir(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),qb(n,a,t,r),e==null||!Ir(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=_a(e,a);!Ir(e)&&!Array.isArray(e)&&(e=[e]);let i=a!=="string"?_f(e,a):Mo(e,[],!0);return B.makeTensor(i,s,a)}function qp(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)=>$(a,`${t}[${s}]`,r,n))}var i6="__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+i6;let a=(...s)=>{B.startScope(r);try{let i=n(...s);return Cy(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 RM(e,t){let r=$(e,"real","complex"),n=$(t,"imag","complex");Gr(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(ah,a)}var Za=W({complex_:RM});function Vi(e,t,r,n){if(n==null&&(n=sf(e)),n==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Ir(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){Sy(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!Ir(e)&&!Array.isArray(e)&&(e=[e]),t=t||r,e=n!=="string"?_f(e,n):Mo(e,[],!0),B.makeTensor(e,t,n)}function ft(e,t,r){let n=_a(e,r);return Vi(e,t,n,r)}var Ng={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},R0=4;async function MM(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)+R0*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 My=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function Xb(e){return My?Buffer.byteLength(e):new Blob([e]).size}function FM(e){if(My)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 Kb(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 l6(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 Fy(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 Ih(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:Xb(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:Xb(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function PM(){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 OM(){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 zM(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function DM(){let e=PM(),t=OM(),r=zM();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}},LM=e=>Wt.registerSaveRouter(e),BM=e=>Wt.registerLoadRouter(e),WM=e=>Wt.getSaveHandlers(e),VM=(e,t)=>Wt.getLoadHandlers(e,t),Eg="tensorflowjs",Rg=1,Io="models_store",Ns="model_info_store";function u6(){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 Mg(e){let t=e.result;t.createObjectStore(Io,{keyPath:"modelPath"}),t.createObjectStore(Ns,{keyPath:"modelPath"})}var $o=class{constructor(e){if(this.indexedDB=u6(),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(Eg,Rg);a.onupgradeneeded=()=>Mg(a),a.onsuccess=()=>{let s=a.result;if(t==null){let i=s.transaction(Io,"readonly"),o=i.objectStore(Io).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=Ih(t),o=s.transaction(Ns,"readwrite"),l=o.objectStore(Ns),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),d;u.onsuccess=()=>{d=s.transaction(Io,"readwrite");let h=d.objectStore(Io).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});h.onsuccess=()=>r({modelArtifactsInfo:i}),h.onerror=p=>{l=o.objectStore(Ns);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)})}};$o.URL_SCHEME="indexeddb://";var d6=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith($o.URL_SCHEME)?UM(e.slice($o.URL_SCHEME.length)):null;Wt.registerSaveRouter(d6);Wt.registerLoadRouter(d6);function UM(e){return new $o(e)}function GM(e){return e.startsWith($o.URL_SCHEME)?e.slice($o.URL_SCHEME.length):e}var jM=class{constructor(){this.indexedDB=u6()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(Eg,Rg);r.onupgradeneeded=()=>Mg(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(Ns,"readonly"),s=a.objectStore(Ns).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=GM(e),new Promise((t,r)=>{let n=this.indexedDB.open(Eg,Rg);n.onupgradeneeded=()=>Mg(n),n.onsuccess=()=>{let a=n.result,s=a.transaction(Ns,"readwrite"),i=s.objectStore(Ns),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(Io,"readwrite");let h=l.objectStore(Io).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)})}},qa="/",yu="tensorflowjs_models",p6="info",HM="model_topology",qM="weight_specs",XM="weight_data",KM="model_metadata";function h6(e){return{info:[yu,e,p6].join(qa),topology:[yu,e,HM].join(qa),weightSpecs:[yu,e,qM].join(qa),weightData:[yu,e,XM].join(qa),modelMetadata:[yu,e,KM].join(qa)}}function c6(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function ZM(e){let t=e.split(qa);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(qa)}function YM(e){return e.startsWith(Fo.URL_SCHEME)?e.slice(Fo.URL_SCHEME.length):e}var Fo=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=h6(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=Ih(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,FM(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 c6(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=_M(s),t}};Fo.URL_SCHEME="localstorage://";var f6=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Fo.URL_SCHEME)?JM(e.slice(Fo.URL_SCHEME.length)):null;Wt.registerSaveRouter(f6);Wt.registerLoadRouter(f6);function JM(e){return new Fo(e)}var QM=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+qa,r=qa+p6;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 h0(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 m6(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=h0(e).scheme,l=h0(e).path,u=o===h0(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 e$(){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 t$(e){let t=h0(e);return Nn.getManager(t.scheme).removeModel(t.path)}async function r$(e,t){return m6(e,t,!1)}async function n$(e,t){return m6(e,t,!0)}var a$=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 a$);try{Nn.registerManager(Fo.URL_SCHEME,new QM)}catch(e){}try{Nn.registerManager($o.URL_SCHEME,new jM)}catch(e){}}var s$={importFetch:()=>hR()},hg,i$=class{constructor(){this.util=cR(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Z().global.fetch!=null?Z().global.fetch(e,t):(hg==null&&(hg=s$.importFetch()),hg(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 i$);function Le(e,t="float32",r){return t=t||"float32",Sy(e),new ir(e,t,r)}function o$(e,t){let r=$(e,"x","cast");if(!z7(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(Qs,n,a)}var me=W({cast_:o$});function l$(e){let t={x:$(e,"x","clone","string_or_numeric")};return B.runKernel(fi,t)}var Wr=W({clone_:l$});function g6(e,t=!1){console.log(e.toString(t))}n6();var u$={buffer:Le,cast:me,clone:Wr,print:g6};xM(u$);var Sr={};Be(Sr,{browserFiles:()=>g$,browserHTTPRequest:()=>v$,concatenateArrayBuffers:()=>$y,copyModel:()=>r$,decodeWeights:()=>o6,encodeWeights:()=>MM,fromMemory:()=>k$,fromMemorySync:()=>v6,getLoadHandlers:()=>VM,getModelArtifactsForJSON:()=>Fy,getModelArtifactsInfoForJSON:()=>Ih,getSaveHandlers:()=>WM,http:()=>Py,isHTTPScheme:()=>Fg,listModels:()=>e$,loadWeights:()=>y$,moveModel:()=>n$,registerLoadRouter:()=>BM,registerSaveRouter:()=>LM,removeModel:()=>t$,weightsLoaderFactory:()=>A6,withSaveHandler:()=>I$,withSaveHandlerSync:()=>S$});var d$="model",p$=".json",h$=".weights.bin";function Zb(e){return new Promise(t=>setTimeout(t)).then(e)}var $g=class{constructor(e){if(!Z().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith($g.URL_SCHEME)&&(e=e.slice($g.URL_SCHEME.length)),(e==null||e.length===0)&&(e=d$),this.modelJsonFileName=e+p$,this.weightDataFileName=e+h$}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=l6(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 Zb(()=>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 Zb(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Ih(e)}}}},M0=$g;M0.URL_SCHEME="downloads://";var c$=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=Fy(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,$y(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=>Kb(a.name)),n={};for(let a of e)a.paths.forEach(s=>{let i=Kb(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}},f$=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(M0.URL_SCHEME)?m$(e.slice(M0.URL_SCHEME.length)):null;Wt.registerSaveRouter(f$);function m$(e="model"){return new M0(e)}function g$(e){return new c$(e)}function Yb(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 y6(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 Yb(n,t.onProgress,a,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await Yb(i,t.onProgress,o,l)}async function y$(e,t="",r,n){return A6(a=>y6(a,{requestInit:n}))(e,t,r)}function A6(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=Ng[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=o6(b,[x.manifestEntry]);for(let I in w)h[I]=w[I]}),p+=m}),h}}var A$="application/octet-stream",x$="application/json",_y=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=l6(e,r);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:x$}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:A$}),"model.weights.bin");let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:Ih(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 Fy(t,a=>this.loadWeights(a))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[r,n]=b$(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 y6(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,$y(l)]}};_y.URL_SCHEME_REGEX=/^https?:\/\//;function b$(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?"),n=e.substring(0,t),a=r>t?e.substring(r):"";return[n+"/",a]}function Fg(e){return e.match(_y.URL_SCHEME_REGEX)!=null}var x6=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let r=!0;if(Array.isArray(e)?r=e.every(n=>Fg(n)):r=Fg(e),r)return Py(e,t)}return null};Wt.registerSaveRouter(x6);Wt.registerLoadRouter(x6);function Py(e,t){return new _y(e,t)}function v$(e,t){return Py(e,t)}var cg=class{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}},b6=class{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}},w$=class{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}};function k$(e,t,r,n){let a=arguments;return new w$(v6(...a))}function v6(e,t,r,n){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new cg(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 cg({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 cg({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n}))}function I$(e){return new b6(e)}function S$(e){return new b6(e)}var w6={};Be(w6,{confusionMatrix:()=>W$});function C$(e,t,r=!1,n=!1){let a=$(e,"a","matMul"),s=$(t,"b","matMul");[a,s]=Lt(a,s);let i={a,b:s},o={transposeA:r,transposeB:n};return B.runKernel(Js,i,o)}var Ye=W({matMul_:C$});function T$(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:$(e,"indices","oneHot","int32")},s={depth:t,onValue:r,offValue:n};return B.runKernel(pl,a,s)}var Xp=W({oneHot_:T$});function Oy(){Z().set("PROD",!0)}function N$(){Z().set("DEBUG",!0)}function E$(){Z().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function zy(e){Z().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}bM(zy);function R$(){B.disposeVariables()}function Xt(){return B}function $0(){return B.memory()}function M$(e){return B.profile(e)}function X(e,t){return B.tidy(e,t)}function te(e){Ey(e).forEach(t=>t.dispose())}function mr(e){return B.keep(e)}function $$(e){return B.time(e)}function Dy(e){return B.setBackend(e)}function gd(){return B.ready()}function jr(){return B.backendName}function F$(e){B.removeBackend(e)}function Ly(e){return B.findBackend(e)}function _$(e){return B.findBackendFactory(e)}function El(e,t,r=1){return B.registerBackend(e,t,r)}function zn(){return B.backend}function P$(e,t){Z().setPlatform(e,t)}function O$(e){let t={input:$(e,"input","imag")};return B.runKernel(uh,t)}var Sh=W({imag_:O$});function z$(e){let t={x:$(e,"x","neg")};return B.runKernel(il,t)}var $t=W({neg_:z$});function D$(e){let t={input:$(e,"input","real")};return B.runKernel(ch,t)}var Tu=W({real_:D$});function L$(e,t,r){let n=$(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=Sh(n);return i=B.runKernel(Ma,{x:i},s),o=B.runKernel(Ma,{x:o},s),r&&(o=$t(o)),Za(i,o)}):B.runKernel(Ma,a,s)}var tt=W({transpose_:L$});function B$(e,t,r){let n=$(e,"labels","confusionMatrix"),a=$(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=Xp(me(n,"int32"),r),i=Xp(me(a,"int32"),r),o=tt(s),l=Ye(o,i);return me(l,"int32")}var W$=W({confusionMatrix_:B$}),Rl={};Be(Rl,{assertAndGetBroadcastShape:()=>yt,getBroadcastDims:()=>k6,getReductionAxes:()=>Jt});function k6(e,t){let r=e.length,n=[];for(let a=0;a1&&i===1&&n.unshift(s)}return n}function Jt(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;aX$,fromPixelsAsync:()=>H$,toPixels:()=>q$});function I6(e,t,r){if(Uo(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=_a(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 Vi(e,t,n,r)}var mo;function S6(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