"use strict";/* Human homepage: author: ' */ var Human=(()=>{var Qc=Object.defineProperty;var iR=Object.getOwnPropertyDescriptor;var oR=Object.getOwnPropertyNames;var lR=Object.prototype.hasOwnProperty;var uR=(e,t,r)=>t in e?Qc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ws=(e,t)=>{for(var r in t)Qc(e,r,{get:t[r],enumerable:!0})},dR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of oR(t))!lR.call(e,a)&&a!==r&&Qc(e,a,{get:()=>t[a],enumerable:!(n=iR(t,a))||n.enumerable});return e};var pR=e=>dR(Qc({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>(uR(e,typeof t!="symbol"?t+"":t,r),r),jb=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var wp=(e,t,r)=>(jb(e,t,"read from private field"),r?r.call(e):t.get(e)),kp=(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)},Ip=(e,t,r,n)=>(jb(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var gAe={};ws(gAe,{Human:()=>kb,default:()=>kb,defaults:()=>ks,draw:()=>gb,env:()=>he,match:()=>wb,models:()=>T1});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 Hb(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 hg(e,t,r="config",n=[]){for(let a of Object.keys(t))if(typeof t[a]=="object")hg(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 ks={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={};ws(Ue,{Abs:()=>Go,Acos:()=>Hu,Acosh:()=>qu,AdadeltaOptimizer:()=>nm,AdagradOptimizer:()=>am,AdamOptimizer:()=>sm,AdamaxOptimizer:()=>im,Add:()=>Qa,AddN:()=>Zs,All:()=>Xu,Any:()=>Ku,ArgMax:()=>Ys,ArgMin:()=>Zu,Asin:()=>Yu,Asinh:()=>Ju,Atan:()=>Qu,Atan2:()=>td,Atanh:()=>ed,AvgPool:()=>Js,AvgPool3D:()=>ah,AvgPool3DGrad:()=>df,AvgPoolGrad:()=>uf,BackendWasm:()=>EC,BatchMatMul:()=>Qs,BatchToSpaceND:()=>jo,Bincount:()=>pf,BroadcastArgs:()=>hf,BroadcastTo:()=>K7,Callback:()=>E8,CallbackList:()=>Ew,Cast:()=>ei,Ceil:()=>ti,ClipByValue:()=>es,Complex:()=>sh,ComplexAbs:()=>ih,Concat:()=>Ho,Conv2D:()=>ri,Conv2DBackpropFilter:()=>cf,Conv2DBackpropInput:()=>ni,Conv3D:()=>oh,Conv3DBackpropFilterV2:()=>ff,Conv3DBackpropInputV2:()=>mf,Cos:()=>ai,Cosh:()=>si,CropAndResize:()=>Xo,Cumprod:()=>qo,Cumsum:()=>ii,CustomCallback:()=>$w,DataStorage:()=>nh,DenseBincount:()=>gf,DepthToSpace:()=>Ko,DepthwiseConv2dNative:()=>oi,DepthwiseConv2dNativeBackpropFilter:()=>yf,DepthwiseConv2dNativeBackpropInput:()=>Af,Diag:()=>xf,Dilation2D:()=>lh,Dilation2DBackpropFilter:()=>N0,Dilation2DBackpropInput:()=>T0,ENV:()=>ba,EarlyStopping:()=>R8,Einsum:()=>uh,Elu:()=>ui,EluGrad:()=>bf,Environment:()=>q7,Equal:()=>Zo,Erf:()=>rd,Exp:()=>di,ExpandDims:()=>Yo,Expm1:()=>Jo,FFT:()=>vf,Fill:()=>nd,FlipLeftRight:()=>Qo,Floor:()=>pi,FloorDiv:()=>hi,FromPixels:()=>jp,FusedBatchNorm:()=>ci,FusedConv2D:()=>Os,FusedDepthwiseConv2D:()=>zs,GPGPUContext:()=>Tu,GatherNd:()=>tl,GatherV2:()=>el,GraphModel:()=>Uh,Greater:()=>rl,GreaterEqual:()=>fi,History:()=>Rw,IFFT:()=>wf,Identity:()=>mi,Imag:()=>dh,InputSpec:()=>Zt,IsFinite:()=>ad,IsInf:()=>sd,IsNan:()=>id,KernelBackend:()=>Gu,LRN:()=>ph,LRNGrad:()=>If,LayerVariable:()=>bw,LayersModel:()=>Za,LeakyRelu:()=>gi,Less:()=>nl,LessEqual:()=>al,LinSpace:()=>kf,Log:()=>yi,Log1p:()=>od,LogSoftmax:()=>Y7,LogicalAnd:()=>sl,LogicalNot:()=>il,LogicalOr:()=>ld,LogicalXor:()=>Z7,LowerBound:()=>r$,MathBackendCPU:()=>pA,MathBackendWebGL:()=>qh,Max:()=>Ai,MaxPool:()=>bi,MaxPool3D:()=>hh,MaxPool3DGrad:()=>Cf,MaxPoolGrad:()=>Sf,MaxPoolWithArgmax:()=>Tf,Maximum:()=>xi,Mean:()=>vi,Min:()=>wi,Minimum:()=>ki,MirrorPad:()=>Ii,Mod:()=>ud,MomentumOptimizer:()=>om,Multinomial:()=>Nf,Multiply:()=>Si,Neg:()=>ol,NonMaxSuppressionV3:()=>ul,NonMaxSuppressionV4:()=>dd,NonMaxSuppressionV5:()=>dl,NotEqual:()=>ll,OP_SCOPE_SUFFIX:()=>h6,OneHot:()=>hl,OnesLike:()=>pl,Optimizer:()=>as,OptimizerConstructors:()=>Ss,Pack:()=>cl,PadV2:()=>Ci,Pool:()=>n$,Pow:()=>Ti,Prelu:()=>Ni,Prod:()=>Ei,RMSPropOptimizer:()=>lm,RNN:()=>ss,Range:()=>pd,Rank:()=>r6,Real:()=>ch,RealDiv:()=>li,Reciprocal:()=>hd,Reduction:()=>aw,Relu:()=>Ri,Relu6:()=>Mi,Reshape:()=>fl,ResizeBilinear:()=>$i,ResizeBilinearGrad:()=>Rf,ResizeNearestNeighbor:()=>cd,ResizeNearestNeighborGrad:()=>Ef,Reverse:()=>ml,RotateWithOffset:()=>El,Round:()=>gl,Rsqrt:()=>Fi,SGDOptimizer:()=>Fh,ScatterNd:()=>yl,SearchSorted:()=>$f,Select:()=>Al,Selu:()=>fd,Sequential:()=>wm,Sigmoid:()=>Pi,Sign:()=>md,Sin:()=>_i,Sinh:()=>bl,Slice:()=>xl,Softmax:()=>Di,Softplus:()=>gd,SpaceToBatchND:()=>vl,SparseFillEmptyRows:()=>fh,SparseReshape:()=>yd,SparseSegmentMean:()=>mh,SparseSegmentSum:()=>gh,SparseToDense:()=>yh,SplitV:()=>wl,Sqrt:()=>Oi,Square:()=>Ad,SquaredDifference:()=>Li,Step:()=>Vi,StridedSlice:()=>kl,StringNGrams:()=>Ah,StringSplit:()=>Mf,StringToHashBucketFast:()=>Ff,Sub:()=>Bi,Sum:()=>zi,SymbolicTensor:()=>pa,Tan:()=>Il,Tanh:()=>Wi,Tensor:()=>nt,TensorBuffer:()=>ir,Tile:()=>ts,TopK:()=>Sl,Transform:()=>Cl,Transpose:()=>$a,Unique:()=>_f,Unpack:()=>Tl,UnsortedSegmentSum:()=>xh,UpperBound:()=>a$,Variable:()=>Xp,ZerosLike:()=>Nl,_FusedMatMul:()=>Ps,abs:()=>ar,acos:()=>q6,acosh:()=>X6,add:()=>le,addN:()=>Of,all:()=>Yy,any:()=>_0,argMax:()=>$n,argMin:()=>K6,asin:()=>Z6,asinh:()=>Y6,atan:()=>J6,atan2:()=>Q6,atanh:()=>ev,avgPool:()=>zf,avgPool3d:()=>Qy,backend:()=>Dn,backend_util:()=>C,basicLSTMCell:()=>KF,batchNorm:()=>Mu,batchNorm2d:()=>av,batchNorm3d:()=>sv,batchNorm4d:()=>iv,batchToSpaceND:()=>Df,bincount:()=>e3,booleanMaskAsync:()=>lz,broadcastArgs:()=>ov,broadcastTo:()=>Bp,broadcast_util:()=>$l,browser:()=>Ln,buffer:()=>De,callbacks:()=>Lj,cast:()=>me,ceil:()=>lv,clipByValue:()=>fn,clone:()=>Vr,complex:()=>Ya,concat:()=>St,concat1d:()=>uv,concat2d:()=>bd,concat3d:()=>dv,concat4d:()=>pv,constraints:()=>Sw,conv1d:()=>t3,conv2d:()=>Ls,conv2dTranspose:()=>n3,conv3d:()=>a3,conv3dTranspose:()=>cv,copyRegisteredKernels:()=>l$,cos:()=>Lf,cosh:()=>s3,cosineWindow:()=>E3,cumprod:()=>O0,cumsum:()=>i3,customGrad:()=>Pa,data:()=>tk,denseBincount:()=>fv,deprecationWarn:()=>Wy,depthToSpace:()=>mv,depthwiseConv2d:()=>Nh,deregisterOp:()=>Vj,device_util:()=>kh,diag:()=>C_,dilation2d:()=>gv,disableDeprecationWarnings:()=>OM,dispose:()=>ee,disposeVariables:()=>zM,div:()=>pe,divNoNan:()=>yv,dot:()=>F_,dropout:()=>Kv,einsum:()=>Av,elu:()=>Eh,enableDebugMode:()=>PM,enableProdMode:()=>By,enclosingPowerOfTwo:()=>Zv,engine:()=>Xt,env:()=>Z,equal:()=>Mn,erf:()=>xv,euclideanNorm:()=>Iv,exp:()=>Fn,expandDims:()=>Kt,expm1:()=>Sv,eye:()=>u3,fft:()=>Zf,fill:()=>vd,findBackend:()=>Uy,findBackendFactory:()=>WM,floor:()=>Rh,floorDiv:()=>Ch,forceHalfFloat:()=>wI,fused:()=>Vs,gather:()=>Fu,gatherND:()=>Xv,gather_util:()=>Gy,getBackend:()=>Hr,getGradient:()=>Ng,getKernel:()=>E0,getKernelsForBackend:()=>Fa,getThreadsCount:()=>p3e,gpgpu_util:()=>Q9,grad:()=>cP,grads:()=>fP,greater:()=>gn,greaterEqual:()=>Ml,ifft:()=>Yp,imag:()=>Sh,image:()=>Ie,inTopKAsync:()=>Az,initializers:()=>Cw,input:()=>jw,io:()=>Cr,irfft:()=>S3,isFinite:()=>nP,isInf:()=>sP,isNaN:()=>Cv,keep:()=>mr,kernel_impls:()=>Kn,layers:()=>Tw,leakyRelu:()=>Wf,less:()=>d3,lessEqual:()=>Fl,linalg:()=>sw,linspace:()=>Tv,loadGraphModel:()=>jH,loadGraphModelSync:()=>HH,loadLayersModel:()=>ZU,localResponseNormalization:()=>Nv,log:()=>_n,log1p:()=>Vf,logSigmoid:()=>xP,logSoftmax:()=>p3,logSumExp:()=>Rv,logicalAnd:()=>ga,logicalNot:()=>Gf,logicalOr:()=>h3,logicalXor:()=>TP,losses:()=>rL,lowerBound:()=>$v,matMul:()=>Ye,math:()=>N6,max:()=>yr,maxPool:()=>jf,maxPool3d:()=>f3,maxPoolWithArgmax:()=>Mv,maximum:()=>rs,mean:()=>Vt,memory:()=>F0,meshgrid:()=>_P,metrics:()=>C8,min:()=>Bs,minimum:()=>$h,mirrorPad:()=>Fv,mod:()=>kd,model:()=>XU,models:()=>T8,moments:()=>Hf,movingAverage:()=>dz,mul:()=>L,multiRNNCell:()=>BP,multinomial:()=>_v,neg:()=>Mt,nextFrame:()=>M3,norm:()=>Bf,notEqual:()=>_u,oneHot:()=>Zp,ones:()=>cn,onesLike:()=>Pn,op:()=>W,outerProduct:()=>jP,pad:()=>Xn,pad1d:()=>XP,pad2d:()=>ZP,pad3d:()=>JP,pad4d:()=>eO,pool:()=>sO,pow:()=>Ws,prelu:()=>Xf,print:()=>w6,prod:()=>m3,profile:()=>DM,rand:()=>uO,randomGamma:()=>cO,randomNormal:()=>Pv,randomUniform:()=>Id,range:()=>Pu,ready:()=>xd,real:()=>Ru,reciprocal:()=>Ov,registerBackend:()=>Rl,registerCallbackConstructor:()=>YU,registerGradient:()=>J7,registerKernel:()=>qn,registerOp:()=>Wj,regularizers:()=>N8,relu:()=>Da,relu6:()=>A3,removeBackend:()=>BM,reshape:()=>U,reverse:()=>On,reverse1d:()=>vO,reverse2d:()=>kO,reverse3d:()=>SO,reverse4d:()=>TO,rfft:()=>Yf,round:()=>x3,rsqrt:()=>b3,scalar:()=>Se,scatterND:()=>qv,scatter_util:()=>jy,searchSorted:()=>c3,selu:()=>v3,separableConv2d:()=>zv,sequential:()=>KU,serialization:()=>ue,setBackend:()=>Vy,setPlatform:()=>VM,setThreadsCount:()=>d3e,setWasmPath:()=>u3e,setWasmPaths:()=>HA,setWebGLContext:()=>Fm,setdiff1dAsync:()=>Dv,shared:()=>$m,sigmoid:()=>Tr,sign:()=>Lv,signal:()=>tL,sin:()=>w3,sinh:()=>k3,slice:()=>_e,slice1d:()=>Kf,slice2d:()=>I3,slice3d:()=>_l,slice4d:()=>Po,slice_util:()=>Dt,softmax:()=>Sd,softplus:()=>wd,spaceToBatchND:()=>qf,sparse:()=>$p,sparseToDense:()=>N3,spectral:()=>eL,split:()=>Yt,sqrt:()=>Er,square:()=>bt,squaredDifference:()=>C3,squeeze:()=>et,stack:()=>ur,step:()=>Mh,stridedSlice:()=>Bv,string:()=>f0,sub:()=>ce,sum:()=>ke,sumOutType:()=>wh,tan:()=>Wv,tanh:()=>$u,tensor:()=>ft,tensor1d:()=>Nt,tensor2d:()=>ca,tensor3d:()=>R6,tensor4d:()=>JO,tensor5d:()=>QO,tensor6d:()=>ez,tensor_util:()=>ha,test_util:()=>G6,tidy:()=>X,tile:()=>jn,time:()=>LM,topk:()=>Vv,train:()=>Ao,transpose:()=>tt,truncatedNormal:()=>Jf,unique:()=>Wg,unregisterGradient:()=>o$,unregisterKernel:()=>i$,unsortedSegmentSum:()=>Uv,unstack:()=>an,upcastType:()=>Nr,upperBound:()=>Gv,util:()=>v,valueAndGrad:()=>mP,valueAndGrads:()=>gP,variable:()=>jv,variableGrads:()=>Ev,version:()=>nc,version_converter:()=>XH,version_core:()=>Zy,version_cpu:()=>_X,version_layers:()=>t5,version_wasm:()=>h3e,version_webgl:()=>dre,webgl:()=>pre,webgl_util:()=>k9,webgpu:()=>IS,where:()=>Ur,whereAsync:()=>T3,zeros:()=>Ot,zerosLike:()=>at});var hR=Object.create,af=Object.defineProperty,cR=Object.getOwnPropertyDescriptor,P7=Object.getOwnPropertyNames,fR=Object.getPrototypeOf,mR=Object.prototype.hasOwnProperty,gR=e=>af(e,"__esModule",{value:!0}),dr=(e,t)=>function(){return t||(0,e[P7(e)[0]])((t={exports:{}}).exports,t),t.exports},Be=(e,t)=>{for(var r in t)af(e,r,{get:t[r],enumerable:!0})},yR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of P7(t))!mR.call(e,a)&&(r||a!=="default")&&af(e,a,{get:()=>t[a],enumerable:!(n=cR(t,a))||n.enumerable});return e},Vo=(e,t)=>yR(gR(af(e!=null?hR(fR(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),AR=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,z,O){this.low=S|0,this.high=z|0,this.unsigned=!!O}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0});function a(S){return(S&&S.__isLong__)===!0}n.isLong=a;var s={},i={};function o(S,z){var O,j,K;return z?(S>>>=0,(K=0<=S&&S<256)&&(j=i[S],j)?j:(O=u(S,(S|0)<0?-1:0,!0),K&&(i[S]=O),O)):(S|=0,(K=-128<=S&&S<128)&&(j=s[S],j)?j:(O=u(S,S<0?-1:0,!1),K&&(s[S]=O),O))}n.fromInt=o;function l(S,z){if(isNaN(S))return z?b:x;if(z){if(S<0)return b;if(S>=g)return R}else{if(S<=-y)return F;if(S+1>=y)return E}return S<0?l(-S,z).neg():u(S%f|0,S/f|0,z)}n.fromNumber=l;function u(S,z,O){return new n(S,z,O)}n.fromBits=u;var d=Math.pow;function h(S,z,O){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof z=="number"?(O=z,z=!1):z=!!z,O=O||10,O<2||360)throw Error("interior hyphen");if(j===0)return h(S.substring(1),z,O).neg();for(var K=l(d(O,8)),D=x,Y=0;Y>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},$.toString=function(S){if(S=S||10,S<2||36>>0,Q=re.toString(S);if(D=V,D.isZero())return Q+Y;for(;Q.length<6;)Q="0"+Q;Y=""+Q+Y}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(F)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,z=31;z>0&&(S&1<=0},$.isOdd=function(){return(this.low&1)===1},$.isEven=function(){return(this.low&1)===0},$.equals=function(S){return a(S)||(S=p(S)),this.unsigned!==S.unsigned&&this.high>>>31===1&&S.high>>>31===1?!1:this.high===S.high&&this.low===S.low},$.eq=$.equals,$.notEquals=function(S){return!this.eq(S)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(S){return this.comp(S)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(S){return this.comp(S)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(S){return this.comp(S)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(S){return this.comp(S)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(S){if(a(S)||(S=p(S)),this.eq(S))return 0;var z=this.isNegative(),O=S.isNegative();return z&&!O?-1:!z&&O?1:this.unsigned?S.high>>>0>this.high>>>0||S.high===this.high&&S.low>>>0>this.low>>>0?-1:1:this.sub(S).isNegative()?-1:1},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(F)?F:this.not().add(w)},$.neg=$.negate,$.add=function(S){a(S)||(S=p(S));var z=this.high>>>16,O=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+=O+Y,Q+=ie>>>16,ie&=65535,Q+=z+D,Q&=65535,u(J<<16|ae,Q<<16|ie,this.unsigned)},$.subtract=function(S){return a(S)||(S=p(S)),this.add(S.neg())},$.sub=$.subtract,$.multiply=function(S){if(this.isZero())return x;if(a(S)||(S=p(S)),r){var z=r.mul(this.low,this.high,S.low,S.high);return u(z,r.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(F))return S.isOdd()?F:x;if(S.eq(F))return this.isOdd()?F:x;if(this.isNegative())return S.isNegative()?this.neg().mul(S.neg()):this.neg().mul(S).neg();if(S.isNegative())return this.mul(S.neg()).neg();if(this.lt(A)&&S.lt(A))return l(this.toNumber()*S.toNumber(),this.unsigned);var O=this.high>>>16,j=this.high&65535,K=this.low>>>16,D=this.low&65535,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+=O*Q+j*re+K*V+D*Y,ie&=65535,u(ae<<16|de,ie<<16|J,this.unsigned)},$.mul=$.multiply,$.divide=function(S){if(a(S)||(S=p(S)),S.isZero())throw Error("division by zero");if(r){if(!this.unsigned&&this.high===-2147483648&&S.low===-1&&S.high===-1)return this;var z=(this.unsigned?r.div_u:r.div_s)(this.low,this.high,S.low,S.high);return u(z,r.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var O,j,K;if(this.unsigned){if(S.unsigned||(S=S.toUnsigned()),S.gt(this))return b;if(S.gt(this.shru(1)))return I;K=b}else{if(this.eq(F)){if(S.eq(w)||S.eq(T))return F;if(S.eq(F))return w;var D=this.shr(1);return O=D.div(S).shl(1),O.eq(x)?S.isNegative()?w:T:(j=this.sub(S.mul(O)),K=O.add(j.div(S)),K)}else if(S.eq(F))return this.unsigned?b:x;if(this.isNegative())return S.isNegative()?this.neg().div(S.neg()):this.neg().div(S).neg();if(S.isNegative())return this.div(S.neg()).neg();K=x}for(j=this;j.gte(S);){O=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Y=Math.ceil(Math.log(O)/Math.LN2),V=Y<=48?1:d(2,Y-48),re=l(O),Q=re.mul(S);Q.isNegative()||Q.gt(j);)O-=V,re=l(O,this.unsigned),Q=re.mul(S);re.isZero()&&(re=w),K=K.add(re),j=j.sub(Q)}return K},$.div=$.divide,$.modulo=function(S){if(a(S)||(S=p(S)),r){var z=(this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,S.low,S.high);return u(z,r.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return u(~this.low,~this.high,this.unsigned)},$.and=function(S){return a(S)||(S=p(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},$.or=function(S){return a(S)||(S=p(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},$.xor=function(S){return a(S)||(S=p(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},$.shiftLeft=function(S){return a(S)&&(S=S.toInt()),(S&=63)===0?this:S<32?u(this.low<>>32-S,this.unsigned):u(0,this.low<>>S|this.high<<32-S,this.high>>S,this.unsigned):u(this.high>>S-32,this.high>=0?0:-1,this.unsigned)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(S){if(a(S)&&(S=S.toInt()),S&=63,S===0)return this;var z=this.high;if(S<32){var O=this.low;return u(O>>>S|z<<32-S,z>>>S,this.unsigned)}else return S===32?u(z,0,this.unsigned):u(z>>>S-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},$.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},$.toBytesLE=function(){var S=this.high,z=this.low;return[z&255,z>>>8&255,z>>>16&255,z>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},$.toBytesBE=function(){var S=this.high,z=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,z>>>24,z>>>16&255,z>>>8&255,z&255]},n.fromBytes=function(S,z,O){return O?n.fromBytesLE(S,z):n.fromBytesBE(S,z)},n.fromBytesLE=function(S,z){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,z)},n.fromBytesBE=function(S,z){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],z)}}}),xR=dr({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),bR=dr({"(disabled):util"(){}}),vR=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)}}),wR=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)}}),kR=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)}}),IR=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)}}),SR=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)}}),CR=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)}}),TR=dr({"(disabled):crypto"(){}}),NR=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),F=new f(E),$=function(){for(var S=F.g(i),z=u,O=0;S=h;)S/=2,z/=2,O>>>=1;return(S+O)/z};return $.int32=function(){return F.g(4)|0},$.quick=function(){return F.g(4)/4294967296},$.double=$,A(b(F.S),n),(I.pass||T||function(S,z,O,j){return j&&(j.S&&g(j,F),S.state=function(){return g(F,{})}),O?(a[l]=S,z):S})($,R,"global"in I?I.global:this==a,I.state)}function f(w){var I,T=w.length,E=this,R=0,F=E.i=E.j=0,$=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!=Or&&ra(Fe.buffer),Ac}function i(){return Fe.buffer!=Or&&ra(Fe.buffer),xc}function o(){return Fe.buffer!=Or&&ra(Fe.buffer),pp}function l(){return Fe.buffer!=Or&&ra(Fe.buffer),bc}function u(){return Fe.buffer!=Or&&ra(Fe.buffer),vc}function d(){return Fe.buffer!=Or&&ra(Fe.buffer),wc}function h(){return Fe.buffer!=Or&&ra(Fe.buffer),kc}var p=typeof a!="undefined"?a:{},c,m;p.ready=new Promise(function(N,_){c=N,m=_});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,_)=>{throw _},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 F,$,S,z;function O(N){N instanceof bp||Q("exiting due to exception: "+N)}var j,K,D;if(I){w?E=I0().dirname(E)+"/":E=__dirname+"/",D=()=>{K||(j=Ty(),K=I0())},F=function(_,G){return D(),_=K.normalize(_),j.readFileSync(_,G?void 0:"utf8")},S=_=>{var G=F(_,!0);return G.buffer||(G=new Uint8Array(G)),G},$=(_,G,te)=>{D(),_=K.normalize(_),j.readFile(_,function(ge,xe){ge?te(ge):G(xe.buffer)})},process.argv.length>1&&(A=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function(_){if(!(_ instanceof bp))throw _}),process.on("unhandledRejection",function(_){throw _}),x=(_,G)=>{if(uo())throw process.exitCode=_,G;O(G),process.exit(_)},p.inspect=function(){return"[Emscripten Module object]"};let N;try{N=ER()}catch(_){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),_}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||(F=N=>{var _=new XMLHttpRequest;return _.open("GET",N,!1),_.send(null),_.responseText},w&&(S=N=>{var _=new XMLHttpRequest;return _.open("GET",N,!1),_.responseType="arraybuffer",_.send(null),new Uint8Array(_.response)}),$=(N,_,G)=>{var te=new XMLHttpRequest;te.open("GET",N,!0),te.responseType="arraybuffer",te.onload=()=>{if(te.status==200||te.status==0&&te.response){_(te.response);return}G()},te.onerror=G,te.send(null)}),z=N=>document.title=N);I&&typeof performance=="undefined"&&(global.performance=RR().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,_){if(typeof WebAssembly.Function=="function"){for(var G={i:"i32",j:"i64",f:"f32",d:"f64"},te={parameters:[],results:_[0]=="v"?[]:[G[_[0]]]},ge=1;ge<_.length;++ge)te.parameters.push(G[_[ge]]);return new WebAssembly.Function(te,N)}var xe=[1,0,1,96],Te=_.slice(0,1),Pe=_.slice(1),Pt={i:127,j:126,f:125,d:124};xe.push(Pe.length);for(var ge=0;ge{$e=N},We=Atomics.load,Ke=Atomics.store,ot=Atomics.compareExchange,pt;p.wasmBinary&&(pt=p.wasmBinary);var ht=p.noExitRuntime||!0;typeof WebAssembly!="object"&&ru("no native wasm support detected");var Fe,wt,xt=!1,Pr;function hr(N,_){N||ru(_)}function Qr(N){var _=p["_"+N];return _}function rr(N,_,G,te,ge){var xe={string:function(Cn){var hu=0;if(Cn!=null&&Cn!==0){var Gb=(Cn.length<<2)+1;hu=pu(Gb),oo(Cn,hu,Gb)}return hu},array:function(Cn){var hu=pu(Cn.length);return Ga(Cn,hu),hu}};function Te(Cn){return _==="string"?In(Cn):_==="boolean"?Boolean(Cn):Cn}var Pe=Qr(N),Pt=[],ia=0;if(te)for(var oa=0;oa(G.buffer instanceof SharedArrayBuffer&&(G=new Uint8Array(G)),_.decode.call(_,G))}var nr=typeof TextDecoder!="undefined"?new en("utf8"):void 0;function kn(N,_,G){for(var te=_+G,ge=_;N[ge]&&!(ge>=te);)++ge;if(ge-_>16&&N.subarray&&nr)return nr.decode(N.subarray(_,ge));for(var xe="";_>10,56320|ia&1023)}}return xe}function In(N,_){return N?kn(i(),N,_):""}function ys(N,_,G,te){if(!(te>0))return 0;for(var ge=G,xe=G+te-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;_[G++]=Pe}else if(Pe<=2047){if(G+1>=xe)break;_[G++]=192|Pe>>6,_[G++]=128|Pe&63}else if(Pe<=65535){if(G+2>=xe)break;_[G++]=224|Pe>>12,_[G++]=128|Pe>>6&63,_[G++]=128|Pe&63}else{if(G+3>=xe)break;_[G++]=240|Pe>>18,_[G++]=128|Pe>>12&63,_[G++]=128|Pe>>6&63,_[G++]=128|Pe&63}}return _[G]=0,G-ge}function oo(N,_,G){return ys(N,i(),_,G)}function yc(N){for(var _=0,G=0;G=55296&&te<=57343&&(te=65536+((te&1023)<<10)|N.charCodeAt(++G)&1023),te<=127?++_:te<=2047?_+=2:te<=65535?_+=3:_+=4}return _}var As=typeof TextDecoder!="undefined"?new en("utf-16le"):void 0;function Ga(N,_){s().set(N,_)}function dp(N,_,G){for(var te=0;te>0]=N.charCodeAt(te);G||(s()[_>>0]=0)}function eu(N,_){return N%_>0&&(N+=_-N%_),N}var Or,Ac,xc,pp,bc,vc,Ib,wc,kc;T&&(Or=p.buffer);function ra(N){Or=N,p.HEAP8=Ac=new Int8Array(N),p.HEAP16=pp=new Int16Array(N),p.HEAP32=vc=new Int32Array(N),p.HEAPU8=xc=new Uint8Array(N),p.HEAPU16=bc=new Uint16Array(N),p.HEAPU32=Ib=new Uint32Array(N),p.HEAPF32=wc=new Float32Array(N),p.HEAPF64=kc=new Float64Array(N)}var Ic=p.INITIAL_MEMORY||16777216;if(T)Fe=p.wasmMemory,Or=p.buffer;else if(p.wasmMemory)Fe=p.wasmMemory;else if(Fe=new WebAssembly.Memory({initial:Ic/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&&(Or=Fe.buffer),Ic=Or.byteLength,ra(Or);var Sn,tu=[],xs=[],M1=[],Sc=[],lo=!1,F1=!1,Cc=0;function uo(){return ht||Cc>0}function zr(){if(p.preRun)for(typeof p.preRun=="function"&&(p.preRun=[p.preRun]);p.preRun.length;)Sb(p.preRun.shift());$c(tu)}function hp(){lo=!0,!T&&$c(xs)}function _1(){T||(Oe.terminateAllThreads(),F1=!0)}function P1(){if(!T){if(p.postRun)for(typeof p.postRun=="function"&&(p.postRun=[p.postRun]);p.postRun.length;)cp(p.postRun.shift());$c(Sc)}}function Sb(N){tu.unshift(N)}function Cb(N){xs.unshift(N)}function cp(N){Sc.unshift(N)}var bs=0,Tc=null,na=null;function fp(N){bs++,p.monitorRunDependencies&&p.monitorRunDependencies(bs)}function Tb(N){if(bs--,p.monitorRunDependencies&&p.monitorRunDependencies(bs),bs==0&&(Tc!==null&&(clearInterval(Tc),Tc=null),na)){var _=na;na=null,_()}}p.preloadedImages={},p.preloadedAudios={};function ru(N){T?postMessage({cmd:"onAbort",arg:N}):p.onAbort&&p.onAbort(N),N="Aborted("+N+")",Q(N),xt=!0,Pr=1,N+=". Build with -s ASSERTIONS=1 for more info.";var _=new WebAssembly.RuntimeError(N);throw m(_),_}var O1="data:application/octet-stream;base64,";function Nc(N){return N.startsWith(O1)}function Ec(N){return N.startsWith("file://")}var Dr;Dr="tfjs-backend-wasm-threaded-simd.wasm",Nc(Dr)||(Dr=R(Dr));function Rc(N){try{if(N==Dr&&pt)return new Uint8Array(pt);if(S)return S(N);throw"both async and sync fetching of the wasm failed"}catch(_){ru(_)}}function nu(){if(!pt&&(b||w)){if(typeof fetch=="function"&&!Ec(Dr))return fetch(Dr,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+Dr+"'";return N.arrayBuffer()}).catch(function(){return Rc(Dr)});if($)return new Promise(function(N,_){$(Dr,function(G){N(new Uint8Array(G))},_)})}return Promise.resolve().then(function(){return Rc(Dr)})}function z1(){var N={env:Uc,wasi_snapshot_preview1:Uc};function _(Te,Pe){var Pt=Te.exports;if(p.asm=Pt,G1(p.asm.emscripten_tls_init),Sn=p.asm.__indirect_function_table,Cb(p.asm.__wasm_call_ctors),wt=Pe,!T){var ia=Oe.unusedWorkers.length;Oe.unusedWorkers.forEach(function(oa){Oe.loadWasmModuleToWorker(oa,function(){--ia||Tb("wasm-instantiate")})})}}T||fp("wasm-instantiate");function G(Te){_(Te.instance,Te.module)}function te(Te){return nu().then(function(Pe){return WebAssembly.instantiate(Pe,N)}).then(function(Pe){return Pe}).then(Te,function(Pe){Q("failed to asynchronously prepare wasm: "+Pe),ru(Pe)})}function ge(){return!pt&&typeof WebAssembly.instantiateStreaming=="function"&&!Nc(Dr)&&!Ec(Dr)&&typeof fetch=="function"?fetch(Dr,{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"),te(G)})}):te(G)}if(p.instantiateWasm)try{var xe=p.instantiateWasm(N,_);return xe}catch(Te){return Q("Module.instantiateWasm callback failed with error: "+Te),!1}return ge().catch(m),{}}var Nb,Eb,D1={};function $c(N){for(;N.length>0;){var _=N.shift();if(typeof _=="function"){_(p);continue}var G=_.func;typeof G=="number"?_.arg===void 0?su(G)():su(G)(_.arg):G(_.arg===void 0?null:_.arg)}}function au(N){var _=dg(),G=N();return Xc(_),G}function cE(N){return N}function Rb(N){var _=/\b_Z[\w\d_]+/g;return N.replace(_,function(G){var te=G;return G===te?G:te+" ["+G+"]"})}function L1(N){u()[N>>2]=0;var _=Oe.pthreads[N];delete Oe.pthreads[N],_.worker.terminate(),ug(N),Oe.runningWorkers.splice(Oe.runningWorkers.indexOf(_.worker),1),_.worker.pthread=void 0}function B1(N){var _=Oe.pthreads[N];_.worker.postMessage({cmd:"cancel"})}function Mc(N){var _=Oe.pthreads[N];if(_){u()[N>>2]=0;var G=_.worker;Oe.returnWorkerToPool(G)}}function Fc(N){rR(N)}function W1(N){if(N instanceof bp||N=="unwind")return Pr;x(1,N)}var Oe={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){T?Oe.initWorker():Oe.initMainThread()},initMainThread:function(){for(var N=8,_=0;_>2]=0;try{N()}finally{u()[Ub>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in Oe.tlsInitFunctions)Oe.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,_){N.onmessage=G=>{var te=G.data,ge=te.cmd;if(N.pthread&&(Oe.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),te.targetThread&&te.targetThread!=qc()){var xe=Oe.pthreads[te.targetThread];xe?xe.worker.postMessage(te,te.transferList):Q('Internal error! Worker sent a message "'+ge+'" to target pthread '+te.targetThread+", but that thread no longer exists!"),Oe.currentProxiedOperationCallerThread=void 0;return}ge==="processQueuedMainThreadWork"?Db():ge==="spawnThread"?Pc(te):ge==="cleanupThread"?Mc(te.thread):ge==="killThread"?L1(te.thread):ge==="cancelThread"?B1(te.thread):ge==="loaded"?(N.loaded=!0,_&&_(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):ge==="print"?re("Thread "+te.threadId+": "+te.text):ge==="printErr"?Q("Thread "+te.threadId+": "+te.text):ge==="alert"?alert("Thread "+te.threadId+": "+te.text):te.target==="setimmediate"?N.postMessage(te):ge==="onAbort"?p.onAbort&&p.onAbort(te.arg):Q("worker sent an unknown command "+ge),Oe.currentProxiedOperationCallerThread=void 0},N.onerror=G=>{var te="worker sent an error!";throw Q(te+" "+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 V1(){var N=qc(),_=u()[N+44>>2],G=u()[N+48>>2],te=_-G;Vb(_,te),Xc(_)}p.establishStackSpace=V1;function _c(N){if(T)return co(1,0,N);try{Fc(N)}catch(_){W1(_)}}var po=[];function su(N){var _=po[N];return _||(N>=po.length&&(po.length=N+1),po[N]=_=Sn.get(N)),_}function U1(N,_){return su(N)(_)}p.invokeEntryPoint=U1;function $b(){var N=new Error;if(!N.stack){try{throw new Error}catch(_){N=_}if(!N.stack)return"(no stack trace available)"}return N.stack.toString()}function G1(N,_,G){Oe.tlsInitFunctions.push(N)}function Mb(N,_){Sn.set(N,_),po[N]=_}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 j1=!0;function H1(N){return u()[zb()>>2]=N,N}function q1(N,_){var G;if(N===0)G=Date.now();else if((N===1||N===4)&&j1)G=ho();else return H1(28),-1;return u()[_>>2]=G/1e3|0,u()[_+4>>2]=G%1e3*1e3*1e3|0,0}function X1(N,_){return q1(N,_)}function K1(N){Lb(N,!w,1,!b),Oe.threadInit()}function Z1(N){T?postMessage({cmd:"cleanupThread",thread:N}):Mc(N)}function Pc(N){var _=Oe.getNewWorker();if(!_)return 6;Oe.runningWorkers.push(_);var G=Oe.pthreads[N.pthread_ptr]={worker:_,threadInfoStruct:N.pthread_ptr};_.pthread=G;var te={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return _.runPthread=()=>{te.time=performance.now(),_.postMessage(te,N.transferList)},_.loaded&&(_.runPthread(),delete _.runPthread),0}function Y1(N,_,G,te){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 Bb(687865856,N,_,G,te);if(xe)return xe;var Te={startRoutine:G,pthread_ptr:N,arg:te,transferList:ge};return T?(Te.cmd="spawnThread",postMessage(Te,ge),0):Pc(Te)}function J1(){return 2097152}function Q1(N,_){if(N==_)postMessage({cmd:"processQueuedMainThreadWork"});else if(T)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var G=Oe.pthreads[N],te=G&&G.worker;if(!te)return;te.postMessage({cmd:"processThreadQueue"})}return 1}function e2(){ru("")}function t2(){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 Oc(){return 2147483648}function r2(N,_,G){i().copyWithin(N,_,_+G)}function n2(){return I?$R().cpus().length:navigator.hardwareConcurrency}function co(N,_){var G=arguments.length-2,te=arguments;return au(function(){for(var ge=G,xe=pu(ge*8),Te=xe>>3,Pe=0;Pe>3,ge=0;ge<_;ge++)mp[ge]=h()[te+ge];var xe=N<0,Te=xe?D1[-N-1]:k2[N];return Te.apply(null,mp)}function s2(N){try{return Fe.grow(N-Or.byteLength+65535>>>16),ra(Fe.buffer),1}catch(_){}}function i2(N){var _=i().length;if(N=N>>>0,N<=_)return!1;var G=Oc();if(N>G)return!1;for(var te=1;te<=4;te*=2){var ge=_*(1+.2/te);ge=Math.min(ge,N+100663296);var xe=Math.min(G,eu(Math.max(N,ge),65536)),Te=s2(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,_,G){function te(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&&te(xe.argsList,G))return}Xe.deferredCalls.push({targetFunction:N,precedence:_,argsList:G}),Xe.deferredCalls.sort(function(Te,Pe){return Te.precedence>2]=G,u()[xe+4>>2]=te,u()[xe+8>>2]=ge,lg(N,637534208,_,te,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 o2(N){var _=yc(N)+1,G=og(_);return oo(N,G,_),G}function l2(N,_,G,te){au(function(){var ge=pu(12),xe=0;_&&(xe=o2(_)),u()[ge>>2]=xe,u()[ge+4>>2]=G,u()[ge+8>>2]=te,lg(N,657457152,0,xe,ge)})}function u2(N,_,G,te){_=_?In(_):"",l2(N,_,G,te)}function d2(N){return N>2?In(N):N}var p2=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function h2(N){N=d2(N);var _=p2[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return _}function gp(N){return h2(N)}function zc(N,_,G){var te=gp(N);if(!te)return-4;if(te.canvasSharedPtr&&(u()[te.canvasSharedPtr>>2]=_,u()[te.canvasSharedPtr+4>>2]=G),te.offscreenCanvas||!te.controlTransferredOffscreen){te.offscreenCanvas&&(te=te.offscreenCanvas);var ge=!1;if(te.GLctxObject&&te.GLctxObject.GLctx){var xe=te.GLctxObject.GLctx.getParameter(2978);ge=xe[0]===0&&xe[1]===0&&xe[2]===te.width&&xe[3]===te.height}te.width=_,te.height=G,ge&&te.GLctxObject.GLctx.viewport(0,0,_,G)}else if(te.canvasSharedPtr){var Te=u()[te.canvasSharedPtr+8>>2];return u2(Te,N,_,G),1}else return-4;return 0}function Dc(N,_,G){return T?co(2,1,N,_,G):zc(N,_,G)}function c2(N,_,G){var te=gp(N);return te?zc(N,_,G):Dc(N,_,G)}function f2(){throw"unwind"}function m2(N){var _=N.getExtension("ANGLE_instanced_arrays");if(_)return N.vertexAttribDivisor=function(G,te){_.vertexAttribDivisorANGLE(G,te)},N.drawArraysInstanced=function(G,te,ge,xe){_.drawArraysInstancedANGLE(G,te,ge,xe)},N.drawElementsInstanced=function(G,te,ge,xe,Te){_.drawElementsInstancedANGLE(G,te,ge,xe,Te)},1}function g2(N){var _=N.getExtension("OES_vertex_array_object");if(_)return N.createVertexArray=function(){return _.createVertexArrayOES()},N.deleteVertexArray=function(G){_.deleteVertexArrayOES(G)},N.bindVertexArray=function(G){_.bindVertexArrayOES(G)},N.isVertexArray=function(G){return _.isVertexArrayOES(G)},1}function y2(N){var _=N.getExtension("WEBGL_draw_buffers");if(_)return N.drawBuffers=function(G,te){_.drawBuffersWEBGL(G,te)},1}function A2(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 _=_t.counter++,G=N.length;G<_;G++)N[G]=null;return _},getSource:function(N,_,G,te){for(var ge="",xe=0;xe<_;++xe){var Te=te?u()[te+xe*4>>2]:-1;ge+=In(u()[G+xe*4>>2],Te<0?void 0:Te)}return ge},createContext:function(N,_){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",_);if(!G)return 0;var te=_t.registerContext(G,_);return te},registerContext:function(N,_){var G=og(8);u()[G+4>>2]=qc();var te={handle:G,attributes:_,version:_.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=te),_t.contexts[G]=te,(typeof _.enableExtensionsByDefault=="undefined"||_.enableExtensionsByDefault)&&_t.initExtensions(te),G},makeContextCurrent:function(N){return _t.currentContext=_t.contexts[N],p.ctx=Vc=_t.currentContext&&_t.currentContext.GLctx,!(N&&!Vc)},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),Ob(_t.contexts[N].handle),_t.contexts[N]=null},initExtensions:function(N){if(N||(N=_t.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var _=N.GLctx;m2(_),g2(_),y2(_),_.disjointTimerQueryExt=_.getExtension("EXT_disjoint_timer_query"),A2(_);var G=_.getSupportedExtensions()||[];G.forEach(function(te){!te.includes("lose_context")&&!te.includes("debug")&&_.getExtension(te)})}}},x2=["default","low-power","high-performance"];function b2(N,_){var G=_>>2,te=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:x2[te],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=gp(N);if(!xe||ge.explicitSwapControl)return 0;var Te=_t.createContext(xe,ge);return Te}function v2(N,_){return b2(N,_)}var iu={mappings:{},buffers:[null,[],[]],printChar:function(N,_){var G=iu.buffers[N];_===0||_===10?((N===1?re:Q)(kn(G,0)),G.length=0):G.push(_)},varargs:void 0,get:function(){iu.varargs+=4;var N=u()[iu.varargs-4>>2];return N},getStr:function(N){var _=In(N);return _},get64:function(N,_){return N}};function Lc(N){return T?co(3,1,N):0}function Bc(N,_,G,te,ge){if(T)return co(4,1,N,_,G,te,ge)}function Wc(N,_,G,te){if(T)return co(5,1,N,_,G,te);for(var ge=0,xe=0;xe>2],Pe=u()[_+4>>2];_+=8;for(var Pt=0;Pt>2]=ge,0}function w2(N){ze(N)}Oe.init();var Vc,k2=[null,_c,Dc,Lc,Bc,Wc],Fb=!1,Uc={__clock_gettime:X1,__emscripten_init_main_thread_js:K1,__emscripten_thread_cleanup:Z1,__pthread_create_js:Y1,_emscripten_default_pthread_stack_size:J1,_emscripten_notify_thread_queue:Q1,abort:e2,emscripten_check_blocking_allowed:t2,emscripten_get_heap_max:Oc,emscripten_get_now:ho,emscripten_memcpy_big:r2,emscripten_num_logical_cores:n2,emscripten_receive_on_main_thread_js:a2,emscripten_resize_heap:i2,emscripten_set_canvas_element_size:c2,emscripten_unwind_to_js_event_loop:f2,emscripten_webgl_create_context:v2,exit:Fc,fd_close:Lc,fd_seek:Bc,fd_write:Wc,memory:Fe||p.wasmMemory,setTempRet0:w2},_b=z1(),I2=p.___wasm_call_ctors=function(){return(I2=p.___wasm_call_ctors=p.asm.__wasm_call_ctors).apply(null,arguments)},S2=p._init=function(){return(S2=p._init=p.asm.init).apply(null,arguments)},C2=p._init_with_threads_count=function(){return(C2=p._init_with_threads_count=p.asm.init_with_threads_count).apply(null,arguments)},T2=p._get_threads_count=function(){return(T2=p._get_threads_count=p.asm.get_threads_count).apply(null,arguments)},N2=p._register_tensor=function(){return(N2=p._register_tensor=p.asm.register_tensor).apply(null,arguments)},E2=p._dispose_data=function(){return(E2=p._dispose_data=p.asm.dispose_data).apply(null,arguments)},R2=p._dispose=function(){return(R2=p._dispose=p.asm.dispose).apply(null,arguments)},$2=p._Abs=function(){return($2=p._Abs=p.asm.Abs).apply(null,arguments)},M2=p._Add=function(){return(M2=p._Add=p.asm.Add).apply(null,arguments)},F2=p._AddN=function(){return(F2=p._AddN=p.asm.AddN).apply(null,arguments)},_2=p._All=function(){return(_2=p._All=p.asm.All).apply(null,arguments)},P2=p._Any=function(){return(P2=p._Any=p.asm.Any).apply(null,arguments)},O2=p._ArgMax=function(){return(O2=p._ArgMax=p.asm.ArgMax).apply(null,arguments)},z2=p._AvgPool=function(){return(z2=p._AvgPool=p.asm.AvgPool).apply(null,arguments)},D2=p._BatchMatMul=function(){return(D2=p._BatchMatMul=p.asm.BatchMatMul).apply(null,arguments)},L2=p._Ceil=function(){return(L2=p._Ceil=p.asm.Ceil).apply(null,arguments)},B2=p._ClipByValue=function(){return(B2=p._ClipByValue=p.asm.ClipByValue).apply(null,arguments)},W2=p._Conv2D=function(){return(W2=p._Conv2D=p.asm.Conv2D).apply(null,arguments)},V2=p._Conv2DBackpropInput=function(){return(V2=p._Conv2DBackpropInput=p.asm.Conv2DBackpropInput).apply(null,arguments)},U2=p._Cos=function(){return(U2=p._Cos=p.asm.Cos).apply(null,arguments)},G2=p._Cosh=function(){return(G2=p._Cosh=p.asm.Cosh).apply(null,arguments)},j2=p._CropAndResize=function(){return(j2=p._CropAndResize=p.asm.CropAndResize).apply(null,arguments)},H2=p._Cumprod=function(){return(H2=p._Cumprod=p.asm.Cumprod).apply(null,arguments)},q2=p._Cumsum=function(){return(q2=p._Cumsum=p.asm.Cumsum).apply(null,arguments)},X2=p._DepthToSpace=function(){return(X2=p._DepthToSpace=p.asm.DepthToSpace).apply(null,arguments)},K2=p._DepthwiseConv2dNative=function(){return(K2=p._DepthwiseConv2dNative=p.asm.DepthwiseConv2dNative).apply(null,arguments)},Z2=p._Elu=function(){return(Z2=p._Elu=p.asm.Elu).apply(null,arguments)},Y2=p._Equal=function(){return(Y2=p._Equal=p.asm.Equal).apply(null,arguments)},J2=p._Exp=function(){return(J2=p._Exp=p.asm.Exp).apply(null,arguments)},Q2=p._FlipLeftRight=function(){return(Q2=p._FlipLeftRight=p.asm.FlipLeftRight).apply(null,arguments)},eg=p._Floor=function(){return(eg=p._Floor=p.asm.Floor).apply(null,arguments)},tg=p._FloorDiv=function(){return(tg=p._FloorDiv=p.asm.FloorDiv).apply(null,arguments)},rg=p._FusedBatchNorm=function(){return(rg=p._FusedBatchNorm=p.asm.FusedBatchNorm).apply(null,arguments)},Gc=p._FusedConv2D=function(){return(Gc=p._FusedConv2D=p.asm.FusedConv2D).apply(null,arguments)},jc=p._FusedDepthwiseConv2D=function(){return(jc=p._FusedDepthwiseConv2D=p.asm.FusedDepthwiseConv2D).apply(null,arguments)},yp=p._Gather=function(){return(yp=p._Gather=p.asm.Gather).apply(null,arguments)},ng=p._GatherNd=function(){return(ng=p._GatherNd=p.asm.GatherNd).apply(null,arguments)},ag=p._Greater=function(){return(ag=p._Greater=p.asm.Greater).apply(null,arguments)},ou=p._GreaterEqual=function(){return(ou=p._GreaterEqual=p.asm.GreaterEqual).apply(null,arguments)},Ap=p._LeakyRelu=function(){return(Ap=p._LeakyRelu=p.asm.LeakyRelu).apply(null,arguments)},xp=p._Less=function(){return(xp=p._Less=p.asm.Less).apply(null,arguments)},Pb=p._LessEqual=function(){return(Pb=p._LessEqual=p.asm.LessEqual).apply(null,arguments)},lu=p._Log=function(){return(lu=p._Log=p.asm.Log).apply(null,arguments)},uu=p._LogicalAnd=function(){return(uu=p._LogicalAnd=p.asm.LogicalAnd).apply(null,arguments)},sg=p._LogicalNot=function(){return(sg=p._LogicalNot=p.asm.LogicalNot).apply(null,arguments)},H=p._LogicalOr=function(){return(H=p._LogicalOr=p.asm.LogicalOr).apply(null,arguments)},ne=p._LogicalXor=function(){return(ne=p._LogicalXor=p.asm.LogicalXor).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)},du=p._NonMaxSuppressionV3=function(){return(du=p._NonMaxSuppressionV3=p.asm.NonMaxSuppressionV3).apply(null,arguments)},fo=p._NonMaxSuppressionV4=function(){return(fo=p._NonMaxSuppressionV4=p.asm.NonMaxSuppressionV4).apply(null,arguments)},ig=p._NonMaxSuppressionV5=function(){return(ig=p._NonMaxSuppressionV5=p.asm.NonMaxSuppressionV5).apply(null,arguments)},tn=p._NotEqual=function(){return(tn=p._NotEqual=p.asm.NotEqual).apply(null,arguments)},vs=p._OneHot=function(){return(vs=p._OneHot=p.asm.OneHot).apply(null,arguments)},Hc=p._PadV2=function(){return(Hc=p._PadV2=p.asm.PadV2).apply(null,arguments)},fE=p._Pow=function(){return(fE=p._Pow=p.asm.Pow).apply(null,arguments)},mE=p._Prelu=function(){return(mE=p._Prelu=p.asm.Prelu).apply(null,arguments)},gE=p._Prod=function(){return(gE=p._Prod=p.asm.Prod).apply(null,arguments)},yE=p._RealDiv=function(){return(yE=p._RealDiv=p.asm.RealDiv).apply(null,arguments)},AE=p._Relu=function(){return(AE=p._Relu=p.asm.Relu).apply(null,arguments)},xE=p._Relu6=function(){return(xE=p._Relu6=p.asm.Relu6).apply(null,arguments)},bE=p._ResizeBilinear=function(){return(bE=p._ResizeBilinear=p.asm.ResizeBilinear).apply(null,arguments)},vE=p._Reverse=function(){return(vE=p._Reverse=p.asm.Reverse).apply(null,arguments)},wE=p._RotateWithOffset=function(){return(wE=p._RotateWithOffset=p.asm.RotateWithOffset).apply(null,arguments)},kE=p._Round=function(){return(kE=p._Round=p.asm.Round).apply(null,arguments)},IE=p._Rsqrt=function(){return(IE=p._Rsqrt=p.asm.Rsqrt).apply(null,arguments)},SE=p._ScatterNd=function(){return(SE=p._ScatterNd=p.asm.ScatterNd).apply(null,arguments)},CE=p._SelectV2=function(){return(CE=p._SelectV2=p.asm.SelectV2).apply(null,arguments)},TE=p._Sigmoid=function(){return(TE=p._Sigmoid=p.asm.Sigmoid).apply(null,arguments)},NE=p._Sin=function(){return(NE=p._Sin=p.asm.Sin).apply(null,arguments)},EE=p._Softmax=function(){return(EE=p._Softmax=p.asm.Softmax).apply(null,arguments)},RE=p._SparseFillEmptyRows=function(){return(RE=p._SparseFillEmptyRows=p.asm.SparseFillEmptyRows).apply(null,arguments)},$E=p._SparseReshape=function(){return($E=p._SparseReshape=p.asm.SparseReshape).apply(null,arguments)},ME=p._SparseSegmentReduction=function(){return(ME=p._SparseSegmentReduction=p.asm.SparseSegmentReduction).apply(null,arguments)},FE=p._Sqrt=function(){return(FE=p._Sqrt=p.asm.Sqrt).apply(null,arguments)},_E=p._Square=function(){return(_E=p._Square=p.asm.Square).apply(null,arguments)},PE=p._SquaredDifference=function(){return(PE=p._SquaredDifference=p.asm.SquaredDifference).apply(null,arguments)},OE=p._Step=function(){return(OE=p._Step=p.asm.Step).apply(null,arguments)},zE=p._StridedSlice=function(){return(zE=p._StridedSlice=p.asm.StridedSlice).apply(null,arguments)},DE=p._Sub=function(){return(DE=p._Sub=p.asm.Sub).apply(null,arguments)},LE=p._Sum=function(){return(LE=p._Sum=p.asm.Sum).apply(null,arguments)},BE=p._Tan=function(){return(BE=p._Tan=p.asm.Tan).apply(null,arguments)},WE=p._Tanh=function(){return(WE=p._Tanh=p.asm.Tanh).apply(null,arguments)},VE=p._Tile=function(){return(VE=p._Tile=p.asm.Tile).apply(null,arguments)},UE=p._TopK=function(){return(UE=p._TopK=p.asm.TopK).apply(null,arguments)},GE=p._Transform=function(){return(GE=p._Transform=p.asm.Transform).apply(null,arguments)},jE=p._Transpose=function(){return(jE=p._Transpose=p.asm.Transpose).apply(null,arguments)},HE=p.__FusedMatMul=function(){return(HE=p.__FusedMatMul=p.asm._FusedMatMul).apply(null,arguments)},og=p._malloc=function(){return(og=p._malloc=p.asm.malloc).apply(null,arguments)},Ob=p._free=function(){return(Ob=p._free=p.asm.free).apply(null,arguments)},qE=p._emscripten_tls_init=function(){return(qE=p._emscripten_tls_init=p.asm.emscripten_tls_init).apply(null,arguments)},zb=p.___errno_location=function(){return(zb=p.___errno_location=p.asm.__errno_location).apply(null,arguments)},qc=p._pthread_self=function(){return(qc=p._pthread_self=p.asm.pthread_self).apply(null,arguments)},Db=p._emscripten_main_thread_process_queued_calls=function(){return(Db=p._emscripten_main_thread_process_queued_calls=p.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},XE=p.__emscripten_thread_crashed=function(){return(XE=p.__emscripten_thread_crashed=p.asm._emscripten_thread_crashed).apply(null,arguments)},Lb=p.__emscripten_thread_init=function(){return(Lb=p.__emscripten_thread_init=p.asm._emscripten_thread_init).apply(null,arguments)},KE=p._emscripten_current_thread_process_queued_calls=function(){return(KE=p._emscripten_current_thread_process_queued_calls=p.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},ZE=p._emscripten_main_browser_thread_id=function(){return(ZE=p._emscripten_main_browser_thread_id=p.asm.emscripten_main_browser_thread_id).apply(null,arguments)},YE=p._emscripten_sync_run_in_main_thread_2=function(){return(YE=p._emscripten_sync_run_in_main_thread_2=p.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},Bb=p._emscripten_sync_run_in_main_thread_4=function(){return(Bb=p._emscripten_sync_run_in_main_thread_4=p.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},Wb=p._emscripten_run_in_main_runtime_thread_js=function(){return(Wb=p._emscripten_run_in_main_runtime_thread_js=p.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},lg=p._emscripten_dispatch_to_thread_=function(){return(lg=p._emscripten_dispatch_to_thread_=p.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},ug=p.__emscripten_thread_free_data=function(){return(ug=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)},QE=p._memalign=function(){return(QE=p._memalign=p.asm.memalign).apply(null,arguments)},Vb=p._emscripten_stack_set_limits=function(){return(Vb=p._emscripten_stack_set_limits=p.asm.emscripten_stack_set_limits).apply(null,arguments)},dg=p.stackSave=function(){return(dg=p.stackSave=p.asm.stackSave).apply(null,arguments)},Xc=p.stackRestore=function(){return(Xc=p.stackRestore=p.asm.stackRestore).apply(null,arguments)},pu=p.stackAlloc=function(){return(pu=p.stackAlloc=p.asm.stackAlloc).apply(null,arguments)},eR=p.dynCall_iijjiiii=function(){return(eR=p.dynCall_iijjiiii=p.asm.dynCall_iijjiiii).apply(null,arguments)},tR=p.dynCall_jiji=function(){return(tR=p.dynCall_jiji=p.asm.dynCall_jiji).apply(null,arguments)},Ub=p.__emscripten_allow_main_runtime_queued_calls=21664;p.cwrap=cr,p.keepRuntimeAlive=uo,p.PThread=Oe,p.PThread=Oe,p.wasmMemory=Fe,p.ExitStatus=bp;var Kc;function bp(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}na=function N(){Kc||pg(),Kc||(na=N)};function pg(N){if(N=N||y,bs>0)return;if(T){c(p),hp(),postMessage({cmd:"loaded"});return}if(zr(),bs>0)return;function _(){Kc||(Kc=!0,p.calledRun=!0,!xt&&(hp(),c(p),p.onRuntimeInitialized&&p.onRuntimeInitialized(),P1()))}p.setStatus?(p.setStatus("Running..."),setTimeout(function(){setTimeout(function(){p.setStatus("")},1),_()},1)):_()}p.run=pg;function rR(N,_){if(Pr=N,!_&&T)throw _c(N),"unwind";uo()||_1(),nR(N)}function nR(N){Pr=N,uo()||(Oe.terminateAllThreads(),p.onExit&&p.onExit(N),xt=!0),x(N,new bp(N))}if(p.preInit)for(typeof p.preInit=="function"&&(p.preInit=[p.preInit]);p.preInit.length>0;)p.preInit.pop()();pg();var Zc;f&&(Zc={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 Yc;if(typeof WasmBackendModule!="undefined")Yc=WasmBackendModule;else if(typeof a!="undefined")Yc=a;else throw new Error("Could not find wasm module in post.js");if(Zc){var aR=Yc._dispose;Yc._dispose=function(){aR(),Zc.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Zc.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)}}),FR=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 Ap||$("exiting due to exception: "+H)}var T,E,R;f?(m?g=I0().dirname(g)+"/":g=__dirname+"/",R=()=>{E||(T=Ty(),E=I0())},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 Ap))throw H}),process.on("unhandledRejection",function(H){throw H}),p=(H,ne)=>{if(pp())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 F=s.print||console.log.bind(console),$=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.arguments&&(d=s.arguments),s.thisProgram&&(h=s.thisProgram),s.quit&&(p=s.quit);var S=4;function z(H){z.shown||(z.shown={}),z.shown[H]||(z.shown[H]=1,$(H))}function O(H,ne){if(typeof WebAssembly.Function=="function"){for(var ye={i:"i32",j:"i64",f:"f32",d:"f64"},Re={parameters:[],results:ne[0]=="v"?[]:[ye[ne[0]]]},lt=1;lt{V=H},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 vs=0;if(tn!=null&&tn!==0){var Hc=(tn.length<<2)+1;vs=yp(Hc),ht(tn,vs,Hc)}return vs},array:function(tn){var vs=yp(tn.length);return xt(tn,vs),vs}};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 xt(H,ne){rr.set(H,ne)}function Pr(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,ys;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=ys=new Float64Array(H)}var yc=s.INITIAL_MEMORY||16777216,As,Ga=[],dp=[],eu=[],Or=!1,Ac=!1,xc=0;function pp(){return ie||xc>0}function bc(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)kc(s.preRun.shift());cp(Ga)}function vc(){Or=!0,cp(dp)}function Ib(){Ac=!0}function wc(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Ic(s.postRun.shift());cp(eu)}function kc(H){Ga.unshift(H)}function ra(H){dp.unshift(H)}function Ic(H){eu.unshift(H)}var Sn=0,tu=null,xs=null;function M1(H){Sn++,s.monitorRunDependencies&&s.monitorRunDependencies(Sn)}function Sc(H){if(Sn--,s.monitorRunDependencies&&s.monitorRunDependencies(Sn),Sn==0&&(tu!==null&&(clearInterval(tu),tu=null),xs)){var ne=xs;xs=null,ne()}}s.preloadedImages={},s.preloadedAudios={};function lo(H){s.onAbort&&s.onAbort(H),H="Aborted("+H+")",$(H),ae=!0,de=1,H+=". Build with -s ASSERTIONS=1 for more info.";var ne=new WebAssembly.RuntimeError(H);throw o(ne),ne}var F1="data:application/octet-stream;base64,";function Cc(H){return H.startsWith(F1)}function uo(H){return H.startsWith("file://")}var zr;zr="tfjs-backend-wasm.wasm",Cc(zr)||(zr=y(zr));function hp(H){try{if(H==zr&&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 _1(){if(!Q&&(c||m)){if(typeof fetch=="function"&&!uo(zr))return fetch(zr,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+zr+"'";return H.arrayBuffer()}).catch(function(){return hp(zr)});if(x)return new Promise(function(H,ne){x(zr,function(ye){H(new Uint8Array(ye))},ne)})}return Promise.resolve().then(function(){return hp(zr)})}function P1(){var H={env:au,wasi_snapshot_preview1:au};function ne(Ze,He){var qt=Ze.exports;s.asm=qt,J=s.asm.memory,oo(J.buffer),As=s.asm.__indirect_function_table,ra(s.asm.__wasm_call_ctors),Sc("wasm-instantiate")}M1("wasm-instantiate");function ye(Ze){ne(Ze.instance)}function Re(Ze){return _1().then(function(He){return WebAssembly.instantiate(He,H)}).then(function(He){return He}).then(Ze,function(He){$("failed to asynchronously prepare wasm: "+He),lo(He)})}function lt(){return!Q&&typeof WebAssembly.instantiateStreaming=="function"&&!Cc(zr)&&!uo(zr)&&typeof fetch=="function"?fetch(zr,{credentials:"same-origin"}).then(function(Ze){var He=WebAssembly.instantiateStreaming(Ze,H);return He.then(ye,function(qt){return $("wasm streaming compile failed: "+qt),$("falling back to ArrayBuffer instantiation"),Re(ye)})}):Re(ye)}if(s.instantiateWasm)try{var ct=s.instantiateWasm(H,ne);return ct}catch(Ze){return $("Module.instantiateWasm callback failed with error: "+Ze),!1}return lt().catch(o),{}}var Sb,Cb;function cp(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?fp(ye)():fp(ye)(ne.arg):ye(ne.arg===void 0?null:ne.arg)}}function bs(H){return H}function Tc(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 fp(H){var ne=na[H];return ne||(H>=na.length&&(na.length=H+1),na[H]=ne=As.get(H)),ne}function Tb(){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 ru(H,ne){As.set(H,ne),na[H]=ne}function O1(){lo("")}function Nc(H,ne,ye){cr.copyWithin(H,ne,ne+ye)}function Ec(){return 2147483648}function Dr(H){try{return J.grow(H-Qr.byteLength+65535>>>16),oo(J.buffer),1}catch(ne){}}function Rc(H){var ne=cr.length;H=H>>>0;var ye=Ec();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=Dr(ct);if(Ze)return!0}return!1}var nu={mappings:{},buffers:[null,[],[]],printChar:function(H,ne){var ye=nu.buffers[H];ne===0||ne===10?((H===1?F:$)(Ke(ye,0)),ye.length=0):ye.push(ne)},varargs:void 0,get:function(){nu.varargs+=4;var H=nr[nu.varargs-4>>2];return H},getStr:function(H){var ne=ot(H);return ne},get64:function(H,ne){return H}};function z1(H){return 0}function Nb(H,ne,ye,Re,lt){}function Eb(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 D1(H){re(H)}var $c=!1,au={abort:O1,emscripten_memcpy_big:Nc,emscripten_resize_heap:Rc,fd_close:z1,fd_seek:Nb,fd_write:Eb,setTempRet0:D1},cE=P1(),Rb=s.___wasm_call_ctors=function(){return(Rb=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},L1=s._init=function(){return(L1=s._init=s.asm.init).apply(null,arguments)},B1=s._init_with_threads_count=function(){return(B1=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)},Fc=s._register_tensor=function(){return(Fc=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},W1=s._dispose_data=function(){return(W1=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},Oe=s._dispose=function(){return(Oe=s._dispose=s.asm.dispose).apply(null,arguments)},V1=s._Abs=function(){return(V1=s._Abs=s.asm.Abs).apply(null,arguments)},_c=s._Add=function(){return(_c=s._Add=s.asm.Add).apply(null,arguments)},po=s._AddN=function(){return(po=s._AddN=s.asm.AddN).apply(null,arguments)},su=s._All=function(){return(su=s._All=s.asm.All).apply(null,arguments)},U1=s._Any=function(){return(U1=s._Any=s.asm.Any).apply(null,arguments)},$b=s._ArgMax=function(){return($b=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},G1=s._AvgPool=function(){return(G1=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},Mb=s._BatchMatMul=function(){return(Mb=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},ho=s._Ceil=function(){return(ho=s._Ceil=s.asm.Ceil).apply(null,arguments)},j1=s._ClipByValue=function(){return(j1=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},H1=s._Conv2D=function(){return(H1=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},q1=s._Conv2DBackpropInput=function(){return(q1=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},X1=s._Cos=function(){return(X1=s._Cos=s.asm.Cos).apply(null,arguments)},K1=s._Cosh=function(){return(K1=s._Cosh=s.asm.Cosh).apply(null,arguments)},Z1=s._CropAndResize=function(){return(Z1=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},Pc=s._Cumprod=function(){return(Pc=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},Y1=s._Cumsum=function(){return(Y1=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},J1=s._DepthToSpace=function(){return(J1=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},Q1=s._DepthwiseConv2dNative=function(){return(Q1=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},e2=s._Elu=function(){return(e2=s._Elu=s.asm.Elu).apply(null,arguments)},t2=s._Equal=function(){return(t2=s._Equal=s.asm.Equal).apply(null,arguments)},Oc=s._Exp=function(){return(Oc=s._Exp=s.asm.Exp).apply(null,arguments)},r2=s._FlipLeftRight=function(){return(r2=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},n2=s._Floor=function(){return(n2=s._Floor=s.asm.Floor).apply(null,arguments)},co=s._FloorDiv=function(){return(co=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},mp=s._FusedBatchNorm=function(){return(mp=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},a2=s._FusedConv2D=function(){return(a2=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},s2=s._FusedDepthwiseConv2D=function(){return(s2=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},i2=s._Gather=function(){return(i2=s._Gather=s.asm.Gather).apply(null,arguments)},Xe=s._GatherNd=function(){return(Xe=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},o2=s._Greater=function(){return(o2=s._Greater=s.asm.Greater).apply(null,arguments)},l2=s._GreaterEqual=function(){return(l2=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},u2=s._LeakyRelu=function(){return(u2=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},d2=s._Less=function(){return(d2=s._Less=s.asm.Less).apply(null,arguments)},p2=s._LessEqual=function(){return(p2=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},h2=s._Log=function(){return(h2=s._Log=s.asm.Log).apply(null,arguments)},gp=s._LogicalAnd=function(){return(gp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},zc=s._LogicalNot=function(){return(zc=s._LogicalNot=s.asm.LogicalNot).apply(null,arguments)},Dc=s._LogicalOr=function(){return(Dc=s._LogicalOr=s.asm.LogicalOr).apply(null,arguments)},c2=s._LogicalXor=function(){return(c2=s._LogicalXor=s.asm.LogicalXor).apply(null,arguments)},f2=s._Max=function(){return(f2=s._Max=s.asm.Max).apply(null,arguments)},m2=s._MaxPool=function(){return(m2=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},g2=s._Maximum=function(){return(g2=s._Maximum=s.asm.Maximum).apply(null,arguments)},y2=s._Mean=function(){return(y2=s._Mean=s.asm.Mean).apply(null,arguments)},A2=s._Min=function(){return(A2=s._Min=s.asm.Min).apply(null,arguments)},_t=s._Minimum=function(){return(_t=s._Minimum=s.asm.Minimum).apply(null,arguments)},x2=s._MirrorPad=function(){return(x2=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},b2=s._Multiply=function(){return(b2=s._Multiply=s.asm.Multiply).apply(null,arguments)},v2=s._Neg=function(){return(v2=s._Neg=s.asm.Neg).apply(null,arguments)},iu=s._NonMaxSuppressionV3=function(){return(iu=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},Lc=s._NonMaxSuppressionV4=function(){return(Lc=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},Bc=s._NonMaxSuppressionV5=function(){return(Bc=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},Wc=s._NotEqual=function(){return(Wc=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},w2=s._OneHot=function(){return(w2=s._OneHot=s.asm.OneHot).apply(null,arguments)},Vc=s._PadV2=function(){return(Vc=s._PadV2=s.asm.PadV2).apply(null,arguments)},k2=s._Pow=function(){return(k2=s._Pow=s.asm.Pow).apply(null,arguments)},Fb=s._Prelu=function(){return(Fb=s._Prelu=s.asm.Prelu).apply(null,arguments)},Uc=s._Prod=function(){return(Uc=s._Prod=s.asm.Prod).apply(null,arguments)},_b=s._RealDiv=function(){return(_b=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},I2=s._Relu=function(){return(I2=s._Relu=s.asm.Relu).apply(null,arguments)},S2=s._Relu6=function(){return(S2=s._Relu6=s.asm.Relu6).apply(null,arguments)},C2=s._ResizeBilinear=function(){return(C2=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},T2=s._Reverse=function(){return(T2=s._Reverse=s.asm.Reverse).apply(null,arguments)},N2=s._RotateWithOffset=function(){return(N2=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},E2=s._Round=function(){return(E2=s._Round=s.asm.Round).apply(null,arguments)},R2=s._Rsqrt=function(){return(R2=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},$2=s._ScatterNd=function(){return($2=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},M2=s._SelectV2=function(){return(M2=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},F2=s._Sigmoid=function(){return(F2=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},_2=s._Sin=function(){return(_2=s._Sin=s.asm.Sin).apply(null,arguments)},P2=s._Softmax=function(){return(P2=s._Softmax=s.asm.Softmax).apply(null,arguments)},O2=s._SparseFillEmptyRows=function(){return(O2=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},z2=s._SparseReshape=function(){return(z2=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},D2=s._SparseSegmentReduction=function(){return(D2=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},L2=s._Sqrt=function(){return(L2=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},B2=s._Square=function(){return(B2=s._Square=s.asm.Square).apply(null,arguments)},W2=s._SquaredDifference=function(){return(W2=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},V2=s._Step=function(){return(V2=s._Step=s.asm.Step).apply(null,arguments)},U2=s._StridedSlice=function(){return(U2=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},G2=s._Sub=function(){return(G2=s._Sub=s.asm.Sub).apply(null,arguments)},j2=s._Sum=function(){return(j2=s._Sum=s.asm.Sum).apply(null,arguments)},H2=s._Tan=function(){return(H2=s._Tan=s.asm.Tan).apply(null,arguments)},q2=s._Tanh=function(){return(q2=s._Tanh=s.asm.Tanh).apply(null,arguments)},X2=s._Tile=function(){return(X2=s._Tile=s.asm.Tile).apply(null,arguments)},K2=s._TopK=function(){return(K2=s._TopK=s.asm.TopK).apply(null,arguments)},Z2=s._Transform=function(){return(Z2=s._Transform=s.asm.Transform).apply(null,arguments)},Y2=s._Transpose=function(){return(Y2=s._Transpose=s.asm.Transpose).apply(null,arguments)},J2=s.__FusedMatMul=function(){return(J2=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},Q2=s._malloc=function(){return(Q2=s._malloc=s.asm.malloc).apply(null,arguments)},eg=s._free=function(){return(eg=s._free=s.asm.free).apply(null,arguments)},tg=s.___errno_location=function(){return(tg=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},rg=s._emscripten_main_thread_process_queued_calls=function(){return(rg=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Gc=s.stackSave=function(){return(Gc=s.stackSave=s.asm.stackSave).apply(null,arguments)},jc=s.stackRestore=function(){return(jc=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},yp=s.stackAlloc=function(){return(yp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},ng=s.dynCall_iijjiiii=function(){return(ng=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},ag=s.dynCall_jiji=function(){return(ag=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=$e;var ou;function Ap(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}xs=function H(){ou||xp(),ou||(xs=H)};function xp(H){if(H=H||d,Sn>0||(bc(),Sn>0))return;function ne(){ou||(ou=!0,s.calledRun=!0,!ae&&(vc(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),wc()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),ne()},1)):ne()}s.run=xp;function Pb(H){de=H,pp()||(s.onExit&&s.onExit(H),ae=!0),p(H,new Ap(H))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();xp();var lu;l&&(lu={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 uu;if(typeof a!="undefined")uu=a;else if(typeof WasmBackendModuleThreadedSimd!="undefined")uu=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(lu){var sg=uu._dispose;uu._dispose=function(){sg(),lu.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),lu.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)}}),_R=1e-7,PR=1e-4,nh=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}},Gu=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?_R:PR}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 z7(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,t--,S0(e,t,r)}function OR(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--,S0(e,r,n),S0(t,r,n)}function Gp(e,t,r){return Math.max(e,Math.min(t,r))}function zR(e){return e%2===0?e:e+1}function S0(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function DR(e){let t=0;for(let r=0;rr+` Shapes ${e} and ${t} must match`)}function Uo(e){P(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function $o(e,t=[],r=!1){if(t==null&&(t=[]),Array.isArray(e)||Sr(e)&&!r)for(let n=0;n0,r){return new Promise((n,a)=>{let s=0,i=()=>{if(e()){n();return}s++;let o=t(s);if(r!=null&&s>=r){a();return}setTimeout(i,o)};i()})}function HR(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),P(e.every(n=>n>=-r&&n`All values in axis param must be in range [-${r}, ${r}) but got axis ${e}`),P(e.every(n=>Nu(n)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(n=>n<0?r+n:n)}function D7(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 L7(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 B7(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 W7(e,t){for(let r=0;rt+=r.length),t}function Ns(e){return typeof e=="string"||e instanceof String}function G7(e){return typeof e=="boolean"}function j7(e){return typeof e=="number"}function of(e){return Array.isArray(e)?of(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":j7(e)?"float32":Ns(e)?"string":G7(e)?"bool":"float32"}function _s(e){return!!(e&&e.constructor&&e.call&&e.apply)}function C0(e,t){for(let r=t;r=0;--n)r[n]=r[n+1]*e[n+1];return r}function H7(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 H7(0,e,t,r)}function Ny(e,t){let r=lf(e,t);for(let n=0;nn*a,1);if(t==null||t==="float32")return ku(e,new Float32Array(r));if(t==="int32")return ku(e,new Int32Array(r));if(t==="bool")return ku(e,new Uint8Array(r));throw new Error(`Unknown data type ${t}`)}function Ey(e){e.forEach(t=>{P(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function KR(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]=QR(r,n)})}};function YR(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 QR(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 e$(e){ba=e}var cg;function X7(){if(cg==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");cg=e}return cg}function t$(){let e=X7();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function $y(e,t){let r=t$();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}var Go="Abs",Hu="Acos",qu="Acosh",Qa="Add",Zs="AddN",Xu="All",Ku="Any",Ys="ArgMax",Zu="ArgMin",Yu="Asin",Ju="Asinh",Qu="Atan",ed="Atanh",td="Atan2",Js="AvgPool",uf="AvgPoolGrad",ah="AvgPool3D",df="AvgPool3DGrad",Qs="BatchMatMul",jo="BatchToSpaceND",pf="Bincount",K7="BroadcastTo",hf="BroadcastArgs",ei="Cast",ti="Ceil",es="ClipByValue",sh="Complex",ih="ComplexAbs",Ho="Concat",ri="Conv2D",cf="Conv2DBackpropFilter",ni="Conv2DBackpropInput",oh="Conv3D",ff="Conv3DBackpropFilterV2",mf="Conv3DBackpropInputV2",ai="Cos",si="Cosh",qo="Cumprod",ii="Cumsum",Xo="CropAndResize",gf="DenseBincount",Ko="DepthToSpace",oi="DepthwiseConv2dNative",yf="DepthwiseConv2dNativeBackpropFilter",Af="DepthwiseConv2dNativeBackpropInput",xf="Diag",lh="Dilation2D",T0="Dilation2DBackpropInput",N0="Dilation2DBackpropFilter",li="RealDiv",uh="Einsum",ui="Elu",bf="EluGrad",rd="Erf",Zo="Equal",di="Exp",Yo="ExpandDims",Jo="Expm1",vf="FFT",nd="Fill",Qo="FlipLeftRight",pi="Floor",hi="FloorDiv",ci="FusedBatchNorm",el="GatherV2",tl="GatherNd",rl="Greater",fi="GreaterEqual",mi="Identity",wf="IFFT",dh="Imag",ad="IsFinite",sd="IsInf",id="IsNan",gi="LeakyRelu",nl="Less",al="LessEqual",kf="LinSpace",yi="Log",od="Log1p",sl="LogicalAnd",il="LogicalNot",ld="LogicalOr",Z7="LogicalXor",Y7="LogSoftmax",r$="LowerBound",ph="LRN",If="LRNGrad",Ai="Max",xi="Maximum",bi="MaxPool",Sf="MaxPoolGrad",hh="MaxPool3D",Cf="MaxPool3DGrad",Tf="MaxPoolWithArgmax",vi="Mean",wi="Min",ki="Minimum",Ii="MirrorPad",ud="Mod",Nf="Multinomial",Si="Multiply",ol="Neg",ll="NotEqual",ul="NonMaxSuppressionV3",dd="NonMaxSuppressionV4",dl="NonMaxSuppressionV5",pl="OnesLike",hl="OneHot",cl="Pack",Ci="PadV2",n$="Pool",Ti="Pow",Ni="Prelu",Ei="Prod",pd="Range",ch="Real",hd="Reciprocal",Ri="Relu",fl="Reshape",cd="ResizeNearestNeighbor",Ef="ResizeNearestNeighborGrad",$i="ResizeBilinear",Rf="ResizeBilinearGrad",Mi="Relu6",ml="Reverse",gl="Round",Fi="Rsqrt",yl="ScatterNd",$f="SearchSorted",Al="Select",fd="Selu",xl="Slice",_i="Sin",bl="Sinh",md="Sign",Pi="Sigmoid",gd="Softplus",Oi="Sqrt",zi="Sum",vl="SpaceToBatchND",wl="SplitV",Di="Softmax",fh="SparseFillEmptyRows",yd="SparseReshape",mh="SparseSegmentMean",gh="SparseSegmentSum",yh="SparseToDense",Li="SquaredDifference",Ad="Square",kl="StridedSlice",Ah="StringNGrams",Mf="StringSplit",Ff="StringToHashBucketFast",Bi="Sub",Il="Tan",Wi="Tanh",ts="Tile",Sl="TopK",Cl="Transform",$a="Transpose",_f="Unique",Tl="Unpack",xh="UnsortedSegmentSum",a$="UpperBound",Nl="ZerosLike",Vi="Step",jp="FromPixels",El="RotateWithOffset",Ps="_FusedMatMul",Os="FusedConv2D",zs="FusedDepthwiseConv2D";function Ts(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.warn(...e)}function s$(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.log(...e)}var Eu=$y("kernelRegistry",()=>new Map),Hp=$y("gradRegistry",()=>new Map);function E0(e,t){let r=My(e,t);return Eu.get(r)}function Ng(e){return Hp.get(e)}function Fa(e){let t=Eu.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=My(t,r);Eu.has(n)&&Ts(`The kernel '${t}' for backend '${r}' is already registered`),Eu.set(n,e)}function J7(e){let{kernelName:t}=e;Hp.has(t)&&Z().getBool("DEBUG")&&Ts(`Overriding the gradient for '${t}'`),Hp.set(t,e)}function i$(e,t){let r=My(e,t);if(!Eu.has(r))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Eu.delete(r)}function o$(e){if(!Hp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Hp.delete(e)}function l$(e,t){Fa(e).forEach(r=>{let n=Object.assign({},r,{backendName:t});qn(n)})}function My(e,t){return`${t}_${e}`}var v={};Be(v,{arraysEqual:()=>Ks,assert:()=>P,assertNonNegativeIntegerDimensions:()=>Ey,assertNonNull:()=>Uo,assertShapesMatch:()=>jr,bytesFromStringArray:()=>U7,bytesPerElement:()=>Tg,checkConversionForErrors:()=>W7,clamp:()=>Gp,computeStrides:()=>ju,createScalarValue:()=>f$,createShuffledIndices:()=>GR,decodeString:()=>R0,distSquared:()=>BR,encodeString:()=>vh,fetch:()=>g$,fingerPrint64:()=>c$,flatten:()=>$o,getArrayFromDType:()=>B7,getTypedArrayFromDType:()=>L7,hasEncodingLoss:()=>qR,hexToLong:()=>bh,indexToLoc:()=>ZR,inferDtype:()=>of,inferFromImplicitShape:()=>HR,isBoolean:()=>G7,isFunction:()=>_s,isInt:()=>Nu,isNumber:()=>j7,isPromise:()=>Ry,isScalarShape:()=>WR,isString:()=>Ns,isTypedArray:()=>Sr,isValidDtype:()=>V7,locToIndex:()=>KR,makeOnesTypedArray:()=>Ny,makeZerosNestedTypedArray:()=>XR,makeZerosTypedArray:()=>lf,nearestDivisor:()=>C0,nearestLargerEven:()=>zR,now:()=>qp,parseAxisParam:()=>Hn,randUniform:()=>LR,repeatedTry:()=>jR,rightPad:()=>Lp,shuffle:()=>z7,shuffleCombo:()=>OR,sizeFromShape:()=>It,sizeToSquarishShape:()=>UR,squeezeShape:()=>D7,sum:()=>DR,swap:()=>S0,tanh:()=>VR,toNestedArray:()=>ku,toTypedArray:()=>Pf});var Xb=Vo(AR()),bo=Xb.default||Xb;function bh(e){return bo.fromString(e,!0,16)}var Q7=bh("c3a5c85c97cb3127"),yo=bh("b492b66fbe98f273"),Lr=bh("9ae16a3b2f90404f");function Eg(e){return e.xor(e.shru(47))}function e6(e,t,r){let n=e.slice(t,t+r);return bo.fromBytes(Array.from(n),!0,!0)}function kt(e,t){return e6(e,t,8)}function Kb(e,t){return e6(e,t,4)}function fr(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Rs(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 u$(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 e0(e,t,r,n){return u$(kt(e,t),kt(e,t+8),kt(e,t+16),kt(e,t+24),r,n)}function d$(e,t=e.length){if(t>=8){let r=Lr.add(t*2),n=kt(e,0).add(Lr),a=kt(e,t-8),s=fr(a,37).mul(r).add(n),i=fr(n,25).add(a).mul(r);return Rs(s,i,r)}if(t>=4){let r=Lr.add(t*2),n=Kb(e,0);return Rs(n.shl(3).add(t),Kb(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 Eg(Lr.mul(s).xor(Q7.mul(i))).mul(Lr)}return Lr}function p$(e,t=e.length){let r=Lr.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(Lr);return Rs(fr(n.add(a),43).add(fr(s,30)).add(i),n.add(fr(a.add(Lr),18)).add(s),r)}function h$(e,t=e.length){let r=Lr.add(t*2),n=kt(e,0).mul(Lr),a=kt(e,8),s=kt(e,t-8).mul(r),i=kt(e,t-16).mul(Lr),o=fr(n.add(a),43).add(fr(s,30)).add(i),l=Rs(o,n.add(fr(a.add(Lr),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 Rs(fr(u.add(d),43).add(fr(h,30)).add(p),u.add(fr(d.add(n),18)).add(h),r)}function c$(e,t=e.length){let r=bo.fromNumber(81,!0);if(t<=32)return t<=16?d$(e,t):p$(e,t);if(t<=64)return h$(e,t);let n=r,a=r.mul(yo).add(113),s=Eg(a.mul(Lr).add(113)).mul(Lr),i=[bo.UZERO,bo.UZERO],o=[bo.UZERO,bo.UZERO];n=n.mul(Lr).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=e0(e,l,i[1].mul(yo),n.add(o[0])),o=e0(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=e0(e,l,i[1].mul(h),n.add(o[0])),o=e0(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],Rs(Rs(i[0],o[0],h).add(Eg(a).mul(Q7)).add(s),Rs(i[1],o[1],h).add(n),h)}function f$(e,t){return t==="string"?vh(e):Pf([e],t)}function m$(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Pf(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=$o(e)),Z().getBool("DEBUG")&&W7(e,t),m$(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=qp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(a);else{a();for(let o of n)o.dataSync();s=Promise.resolve({kernelMs:qp()-i})}if(Z().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{A$(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 A$(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 b$(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(!Ks(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 Zb=20,Sp=3,fg=7;function w$(e,t,r,n){let a=ju(t),s=k$(e,t,r,a),i=t.length,o=h0(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 k$(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"?Rp(e):e;if(o>1)for(let u=0;uZb){let g=Sp*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-Sp)*i,o*i));return r==="complex64"&&(y=Rp(y),A=Rp(A)),["["+y.map((x,b)=>Ep(x,a[b],r)).join(", ")+", ..., "+A.map((x,b)=>Ep(x,a[o-Sp+b],r)).join(", ")+"]"]}let f=r==="complex64"?Rp(e):Array.from(e);return["["+f.map((g,y)=>Ep(g,a[y],r)).join(", ")+"]"]}let u=t.slice(1),d=n.slice(1),h=n[0]*i,p=[];if(o>Zb){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||B7(t,this.size),this.strides=ju(e)}set(e,...t){t.length===0&&(t=[0]),P(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;nR0(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=>R0(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 xu.print(this,e)}clone(){return this.throwIfDisposed(),xu.clone(this)}toString(e=!1){let t=this.dataSync();return w$(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),xu.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 N$(){return $y("Tensor",()=>nt)}N$();var Xp=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(!Ks(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(Xp,Symbol.hasInstance,{value:e=>e instanceof nt&&e.assign!=null&&e.assign instanceof Function});var ha={};Be(ha,{assertTypesMatch:()=>o6,getTensorsInContainer:()=>Fy,isTensorInList:()=>R$,makeTypesMatch:()=>Lt});var r6=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(r6||{}),n6=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(n6||{}),a6=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(a6||{}),s6=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(s6||{}),i6=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(i6||{}),E$={float32:s6,int32:n6,bool:a6,complex64:i6};function Nr(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return E$[e][t]}function wh(e){return Nr(e,"int32")}function Lt(e,t){if(e.dtype===t.dtype)return[e,t];let r=Nr(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function o6(e,t){P(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function R$(e,t){return t.some(r=>r.id===e.id)}function Fy(e){let t=[];return l6(e,t,new Set),t}function l6(e,t,r){if(e==null)return;if(e instanceof nt){t.push(e);return}if(!$$(e))return;let n=e;for(let a in n){let s=n[a];r.has(s)||(r.add(s),l6(s,t,r))}}function $$(e){return Array.isArray(e)||typeof e=="object"}function mg(e){return e.kernelName!=null}var Yb=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()}},Rg=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Yb}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 Gu)&&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 Rg.nextTensorId++}nextVariableId(){return Rg.nextVariableId++}clone(e){let t=B.runKernel(mi,{x:e}),r={x:e},n=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return B.runKernel(ei,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,E0(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=mg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(mg(e)){let{kernelName:c,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=E0(c,this.backendName);P(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=mg(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=Ng(e);if(n!=null){let a=n.inputsToSave||[],s=n.outputsToSave||[],i;n.saveAllInputs?(P(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"&&Ns(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=U7(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 Xp(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*Tg(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 Xp||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*Tg(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=Ng(e);o!=null&&(n=o.gradFunc),n!=null&&(i.gradient=l=>(l=l.map((u,d)=>{if(u==null){let h=r[d],p=lf(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=Fy(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(P(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));P(a instanceof nt,()=>"The result y returned by f() must be a tensor.");let s=b$(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?M$(a.shape):r,v$(i,s,l=>this.tidy(l),F$);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 P(_s(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{P(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),P(r.value instanceof nt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),P(_s(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),s=(i,o)=>{let l=r.gradFunc(i,o),u=Array.isArray(l)?l:[l];P(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(...)."),P(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=qp(),r=await this.backend.time(e);return r.wallMs=qp()-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 Yb;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}},_y=Rg;_y.nextTensorId=0;_y.nextVariableId=0;function M$(e){let t=Ny(It(e),"float32");return B.makeTensor(t,e,"float32")}function u6(){let e=X7();if(e._tfengine==null){let t=new q7(e);e._tfengine=new _y(t)}return e$(e._tfengine.ENV),S$(()=>e._tfengine),e._tfengine}var B=u6();function F$(e,t){let r={a:e,b:t};return B.runKernel(Qa,r)}var kh={};Be(kh,{isBrowser:()=>d6,isMobile:()=>O$,mockIsMobile:()=>P$});function _$(){return typeof navigator!="undefined"&&navigator!=null}var $g;function P$(e){$g=e}function O$(e){if($g!==void 0)return $g;if(e||_$()){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 d6(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Rn=Z();Rn.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.")});Rn.registerFlag("IS_BROWSER",()=>d6());Rn.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Rn.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Rn.registerFlag("PROD",()=>!1);Rn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Rn.getBool("DEBUG"));Rn.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Rn.registerFlag("IS_TEST",()=>!1);Rn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Rn.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Rn.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);Rn.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY",()=>!1);function _a(e,t){let r=e;if(Sr(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let n=[];for(;Array.isArray(r)||Sr(r)&&t!=="string";)n.push(r.length),r=r[0];return Array.isArray(e)&&Z().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&p6(e,n,[]),n}function p6(e,t,r){if(r=r||[],!Array.isArray(e)&&!Sr(e)){P(t.length===0,()=>`Element arr[${r.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}P(t.length>0,()=>`Element arr[${r.join("][")}] should be a primitive, but is an array of ${e.length} elements`),P(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),Jb(n,a,t,r),e==null||!Sr(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let o=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${r}' must be a Tensor or TensorLike, but got '${o}'`)}let s=_a(e,a);!Sr(e)&&!Array.isArray(e)&&(e=[e]);let i=a!=="string"?Pf(e,a):$o(e,[],!0);return B.makeTensor(i,s,a)}function Kp(e,t,r,n="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${r} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,s)=>M(a,`${t}[${s}]`,r,n))}var h6="__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+h6;let a=(...s)=>{B.startScope(r);try{let i=n(...s);return Ry(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 z$(e,t){let r=M(e,"real","complex"),n=M(t,"imag","complex");jr(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(sh,a)}var Ya=W({complex_:z$});function Ui(e,t,r,n){if(n==null&&(n=of(e)),n==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Sr(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(t!=null){Ey(t);let a=It(t),s=It(r);P(a===s,()=>`Based on the provided shape, [${t}], the tensor should have ${a} values but has ${s}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${r}) does not match the provided shape (${t}). `)}}return!Sr(e)&&!Array.isArray(e)&&(e=[e]),t=t||r,e=n!=="string"?Pf(e,n):$o(e,[],!0),B.makeTensor(e,t,n)}function ft(e,t,r){let n=_a(e,r);return Ui(e,t,n,r)}var Mg={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},$0=4;async function D$(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)+$0*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 Py=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function Qb(e){return Py?Buffer.byteLength(e):new Blob([e]).size}function B$(e){if(Py)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 e4(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 f6(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 zy(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:Qb(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:Qb(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function V$(){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 U$(){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 G$(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function j$(){let e=V$(),t=U$(),r=G$();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}},H$=e=>Wt.registerSaveRouter(e),q$=e=>Wt.registerLoadRouter(e),X$=e=>Wt.getSaveHandlers(e),K$=(e,t)=>Wt.getLoadHandlers(e,t),Fg="tensorflowjs",_g=1,Io="models_store",Es="model_info_store";function m6(){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 Pg(e){let t=e.result;t.createObjectStore(Io,{keyPath:"modelPath"}),t.createObjectStore(Es,{keyPath:"modelPath"})}var Mo=class{constructor(e){if(this.indexedDB=m6(),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(Fg,_g);a.onupgradeneeded=()=>Pg(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(Es,"readwrite"),l=o.objectStore(Es),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(Es);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)})}};Mo.URL_SCHEME="indexeddb://";var g6=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Mo.URL_SCHEME)?Z$(e.slice(Mo.URL_SCHEME.length)):null;Wt.registerSaveRouter(g6);Wt.registerLoadRouter(g6);function Z$(e){return new Mo(e)}function Y$(e){return e.startsWith(Mo.URL_SCHEME)?e.slice(Mo.URL_SCHEME.length):e}var J$=class{constructor(){this.indexedDB=m6()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(Fg,_g);r.onupgradeneeded=()=>Pg(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(Es,"readonly"),s=a.objectStore(Es).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=Y$(e),new Promise((t,r)=>{let n=this.indexedDB.open(Fg,_g);n.onupgradeneeded=()=>Pg(n),n.onsuccess=()=>{let a=n.result,s=a.transaction(Es,"readwrite"),i=s.objectStore(Es),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)})}},Xa="/",bu="tensorflowjs_models",y6="info",Q$="model_topology",eM="weight_specs",tM="weight_data",rM="model_metadata";function A6(e){return{info:[bu,e,y6].join(Xa),topology:[bu,e,Q$].join(Xa),weightSpecs:[bu,e,eM].join(Xa),weightData:[bu,e,tM].join(Xa),modelMetadata:[bu,e,rM].join(Xa)}}function x6(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function nM(e){let t=e.split(Xa);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Xa)}function aM(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=A6(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,B$(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 x6(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=W$(s),t}};Fo.URL_SCHEME="localstorage://";var b6=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Fo.URL_SCHEME)?sM(e.slice(Fo.URL_SCHEME.length)):null;Wt.registerSaveRouter(b6);Wt.registerLoadRouter(b6);function sM(e){return new Fo(e)}var iM=class{constructor(){P(Z().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),P(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=bu+Xa,r=Xa+y6;for(let n=0;n"scheme must not be undefined or null."),e.endsWith(Iu)&&(e=e.slice(0,e.indexOf(Iu))),P(e.length>0,()=>"scheme must not be an empty string.");let r=Nn.getInstance();P(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 c0(e){if(e.indexOf(Iu)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Nn.getSchemes().join(",")}`);return{scheme:e.split(Iu)[0],path:e.split(Iu)[1]}}async function v6(e,t,r=!1){P(e!==t,()=>`Old path and new path are the same: '${e}'`);let n=Wt.getLoadHandlers(e);P(n.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),P(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);P(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),P(s.length<2,()=>`Copying failed because more than one (${n.length}) save handlers for destination URL ${t}.`);let i=s[0],o=c0(e).scheme,l=c0(e).path,u=o===c0(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 oM(){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+Iu+a;t[s]=n[a]}}return t}async function lM(e){let t=c0(e);return Nn.getManager(t.scheme).removeModel(t.path)}async function uM(e,t){return v6(e,t,!1)}async function dM(e,t){return v6(e,t,!0)}var pM=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 pM);try{Nn.registerManager(Fo.URL_SCHEME,new iM)}catch(e){}try{Nn.registerManager(Mo.URL_SCHEME,new J$)}catch(e){}}var hM={importFetch:()=>xR()},gg,cM=class{constructor(){this.util=bR(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Z().global.fetch!=null?Z().global.fetch(e,t):(gg==null&&(gg=hM.importFetch()),gg(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 cM);function De(e,t="float32",r){return t=t||"float32",Ey(e),new ir(e,t,r)}function fM(e,t){let r=M(e,"x","cast");if(!V7(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(ei,n,a)}var me=W({cast_:fM});function mM(e){let t={x:M(e,"x","clone","string_or_numeric")};return B.runKernel(mi,t)}var Vr=W({clone_:mM});function w6(e,t=!1){console.log(e.toString(t))}u6();var gM={buffer:De,cast:me,clone:Vr,print:w6};C$(gM);var Cr={};Be(Cr,{browserFiles:()=>kM,browserHTTPRequest:()=>NM,concatenateArrayBuffers:()=>Oy,copyModel:()=>uM,decodeWeights:()=>c6,encodeWeights:()=>D$,fromMemory:()=>RM,fromMemorySync:()=>T6,getLoadHandlers:()=>K$,getModelArtifactsForJSON:()=>zy,getModelArtifactsInfoForJSON:()=>Ih,getSaveHandlers:()=>X$,http:()=>Ly,isHTTPScheme:()=>zg,listModels:()=>oM,loadWeights:()=>IM,moveModel:()=>dM,registerLoadRouter:()=>q$,registerSaveRouter:()=>H$,removeModel:()=>lM,weightsLoaderFactory:()=>I6,withSaveHandler:()=>$M,withSaveHandlerSync:()=>MM});var yM="model",AM=".json",xM=".weights.bin";function t4(e){return new Promise(t=>setTimeout(t)).then(e)}var Og=class{constructor(e){if(!Z().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Og.URL_SCHEME)&&(e=e.slice(Og.URL_SCHEME.length)),(e==null||e.length===0)&&(e=yM),this.modelJsonFileName=e+AM,this.weightDataFileName=e+xM}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=f6(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 t4(()=>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 t4(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Ih(e)}}}},M0=Og;M0.URL_SCHEME="downloads://";var bM=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=zy(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,Oy(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=>e4(a.name)),n={};for(let a of e)a.paths.forEach(s=>{let i=e4(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}},vM=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(M0.URL_SCHEME)?wM(e.slice(M0.URL_SCHEME.length)):null;Wt.registerSaveRouter(vM);function wM(e="model"){return new M0(e)}function kM(e){return new bM(e)}function r4(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){P(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function o(l,u){P(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),P(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),P(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(s))}async function k6(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 r4(n,t.onProgress,a,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await r4(i,t.onProgress,o,l)}async function IM(e,t="",r,n){return I6(a=>k6(a,{requestInit:n}))(e,t,r)}function I6(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=Mg[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=c6(b,[x.manifestEntry]);for(let I in w)h[I]=w[I]}),p+=m}),h}}var SM="application/octet-stream",CM="application/json",Dy=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?(P(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,P(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&P(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=f6(e,r);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:CM}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:SM}),"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 zy(t,a=>this.loadWeights(a))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[r,n]=TM(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 k6(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,Oy(l)]}};Dy.URL_SCHEME_REGEX=/^https?:\/\//;function TM(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?"),n=e.substring(0,t),a=r>t?e.substring(r):"";return[n+"/",a]}function zg(e){return e.match(Dy.URL_SCHEME_REGEX)!=null}var S6=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let r=!0;if(Array.isArray(e)?r=e.every(n=>zg(n)):r=zg(e),r)return Ly(e,t)}return null};Wt.registerSaveRouter(S6);Wt.registerLoadRouter(S6);function Ly(e,t){return new Dy(e,t)}function NM(e,t){return Ly(e,t)}var yg=class{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}},C6=class{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}},EM=class{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}};function RM(e,t,r,n){let a=arguments;return new EM(T6(...a))}function T6(e,t,r,n){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new yg(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 yg({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 yg({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n}))}function $M(e){return new C6(e)}function MM(e){return new C6(e)}var N6={};Be(N6,{confusionMatrix:()=>XM});function FM(e,t,r=!1,n=!1){let a=M(e,"a","matMul"),s=M(t,"b","matMul");[a,s]=Lt(a,s);let i={a,b:s},o={transposeA:r,transposeB:n};return B.runKernel(Qs,i,o)}var Ye=W({matMul_:FM});function _M(e,t,r=1,n=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:M(e,"indices","oneHot","int32")},s={depth:t,onValue:r,offValue:n};return B.runKernel(hl,a,s)}var Zp=W({oneHot_:_M});function By(){Z().set("PROD",!0)}function PM(){Z().set("DEBUG",!0)}function OM(){Z().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Wy(e){Z().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}T$(Wy);function zM(){B.disposeVariables()}function Xt(){return B}function F0(){return B.memory()}function DM(e){return B.profile(e)}function X(e,t){return B.tidy(e,t)}function ee(e){Fy(e).forEach(t=>t.dispose())}function mr(e){return B.keep(e)}function LM(e){return B.time(e)}function Vy(e){return B.setBackend(e)}function xd(){return B.ready()}function Hr(){return B.backendName}function BM(e){B.removeBackend(e)}function Uy(e){return B.findBackend(e)}function WM(e){return B.findBackendFactory(e)}function Rl(e,t,r=1){return B.registerBackend(e,t,r)}function Dn(){return B.backend}function VM(e,t){Z().setPlatform(e,t)}function UM(e){let t={input:M(e,"input","imag")};return B.runKernel(dh,t)}var Sh=W({imag_:UM});function GM(e){let t={x:M(e,"x","neg")};return B.runKernel(ol,t)}var Mt=W({neg_:GM});function jM(e){let t={input:M(e,"input","real")};return B.runKernel(ch,t)}var Ru=W({real_:jM});function HM(e,t,r){let n=M(e,"x","transpose");if(t==null&&(t=n.shape.map((i,o)=>o).reverse()),P(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(i=>{P(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=Ru(n),o=Sh(n);return i=B.runKernel($a,{x:i},s),o=B.runKernel($a,{x:o},s),r&&(o=Mt(o)),Ya(i,o)}):B.runKernel($a,a,s)}var tt=W({transpose_:HM});function qM(e,t,r){let n=M(e,"labels","confusionMatrix"),a=M(t,"predictions","confusionMatrix");P(r==null||r>0&&Number.isInteger(r),()=>`If provided, numClasses must be a positive integer, but got ${r}`),P(n.rank===1,()=>`Expected the rank of labels to be 1, but got ${n.rank}`),P(a.rank===1,()=>`Expected the rank of predictions to be 1, but got ${a.rank}`),P(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.`),P(r>0&&Number.isInteger(r),()=>`numClasses is required to be a positive integer, but got ${r}`);let s=Zp(me(n,"int32"),r),i=Zp(me(a,"int32"),r),o=tt(s),l=Ye(o,i);return me(l,"int32")}var XM=W({confusionMatrix_:qM}),$l={};Be($l,{assertAndGetBroadcastShape:()=>At,getBroadcastDims:()=>E6,getReductionAxes:()=>Jt});function E6(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 At(e,t){let r=[],n=Math.max(e.length,t.length);for(let a=0;atF,fromPixelsAsync:()=>QM,toPixels:()=>eF});function R6(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 Ui(e,t,n,r)}var mo;function $6(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