/* Human homepage: author: ' */ var Human=(()=>{var Vc=Object.defineProperty;var DE=Object.getOwnPropertyDescriptor;var LE=Object.getOwnPropertyNames;var BE=Object.prototype.hasOwnProperty;var WE=(e,t,r)=>t in e?Vc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var bs=(e,t)=>{for(var r in t)Vc(e,r,{get:t[r],enumerable:!0})},VE=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of LE(t))!BE.call(e,a)&&a!==r&&Vc(e,a,{get:()=>t[a],enumerable:!(n=DE(t,a))||n.enumerable});return e};var UE=e=>VE(Vc({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>(WE(e,typeof t!="symbol"?t+"":t,r),r),E3=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var pp=(e,t,r)=>(E3(e,t,"read from private field"),r?r.call(e):t.get(e)),hp=(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)},cp=(e,t,r,n)=>(E3(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var YAe={};bs(YAe,{Human:()=>o3,default:()=>o3,defaults:()=>vs,draw:()=>e3,env:()=>he,match:()=>i3,models:()=>pg});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 R3(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 q1(e,t,r="config",n=[]){for(let a of Object.keys(t))if(typeof t[a]=="object")q1(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 Ut(...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]=Ut(s,i):r[a]=i}),r),{})}var vs={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"},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={};bs(Ue,{Abs:()=>Vo,Acos:()=>_u,Acosh:()=>zu,AdadeltaOptimizer:()=>Wm,AdagradOptimizer:()=>Vm,AdamOptimizer:()=>Um,AdamaxOptimizer:()=>Gm,Add:()=>Ja,AddN:()=>Ks,All:()=>Ou,Any:()=>Du,ArgMax:()=>Xs,ArgMin:()=>Lu,Asin:()=>Bu,Asinh:()=>Wu,Atan:()=>Vu,Atan2:()=>Gu,Atanh:()=>Uu,AvgPool:()=>Zs,AvgPool3D:()=>Kp,AvgPool3DGrad:()=>Xf,AvgPoolGrad:()=>Kf,BackendWasm:()=>lN,BatchMatMul:()=>Ys,BatchToSpaceND:()=>Uo,Bincount:()=>Zf,BroadcastArgs:()=>Yf,BroadcastTo:()=>Mw,Callback:()=>s6,CallbackList:()=>s4,Cast:()=>Js,Ceil:()=>Qs,ClipByValue:()=>Qa,Complex:()=>Xp,ComplexAbs:()=>Zp,Concat:()=>Go,Conv2D:()=>ei,Conv2DBackpropFilter:()=>Jf,Conv2DBackpropInput:()=>ti,Conv3D:()=>Yp,Conv3DBackpropFilterV2:()=>Qf,Conv3DBackpropInputV2:()=>em,Cos:()=>ri,Cosh:()=>ni,CropAndResize:()=>Ho,Cumprod:()=>jo,Cumsum:()=>ai,CustomCallback:()=>o4,DataStorage:()=>qp,DenseBincount:()=>tm,DepthToSpace:()=>qo,DepthwiseConv2dNative:()=>si,DepthwiseConv2dNativeBackpropFilter:()=>rm,DepthwiseConv2dNativeBackpropInput:()=>nm,Diag:()=>am,Dilation2D:()=>Jp,Dilation2DBackpropFilter:()=>gf,Dilation2DBackpropInput:()=>mf,ENV:()=>Aa,EarlyStopping:()=>i6,Einsum:()=>Qp,Elu:()=>oi,EluGrad:()=>sm,Environment:()=>Ew,Equal:()=>Ko,Erf:()=>ju,Exp:()=>li,ExpandDims:()=>Xo,Expm1:()=>Zo,FFT:()=>im,Fill:()=>Hu,FlipLeftRight:()=>Yo,Floor:()=>ui,FloorDiv:()=>di,FromPixels:()=>Pp,FusedBatchNorm:()=>pi,FusedConv2D:()=>$s,FusedDepthwiseConv2D:()=>Ps,GPGPUContext:()=>Au,GatherNd:()=>Qo,GatherV2:()=>Jo,GraphModel:()=>m0,Greater:()=>el,GreaterEqual:()=>hi,History:()=>i4,IFFT:()=>om,Identity:()=>ci,Imag:()=>eh,InputSpec:()=>Kt,IsFinite:()=>qu,IsInf:()=>Ku,IsNan:()=>Xu,KernelBackend:()=>$u,LRN:()=>rh,LRNGrad:()=>um,LayerVariable:()=>Z7,LayersModel:()=>Xa,LeakyRelu:()=>fi,Less:()=>tl,LessEqual:()=>rl,LinSpace:()=>lm,Log:()=>mi,Log1p:()=>Zu,LogSoftmax:()=>Fw,LogicalAnd:()=>nl,LogicalNot:()=>Yu,LogicalOr:()=>th,MathBackendCPU:()=>qx,MathBackendWebGL:()=>Oh,Max:()=>gi,MaxPool:()=>Ai,MaxPool3D:()=>nh,MaxPool3DGrad:()=>pm,MaxPoolGrad:()=>dm,MaxPoolWithArgmax:()=>hm,Maximum:()=>yi,Mean:()=>xi,Min:()=>bi,Minimum:()=>vi,MirrorPad:()=>wi,Mod:()=>Ju,MomentumOptimizer:()=>jm,Multinomial:()=>cm,Multiply:()=>ki,Neg:()=>al,NonMaxSuppressionV3:()=>il,NonMaxSuppressionV4:()=>Qu,NonMaxSuppressionV5:()=>ol,NotEqual:()=>sl,OP_SCOPE_SUFFIX:()=>qw,OneHot:()=>ul,OnesLike:()=>ll,Optimizer:()=>ns,OptimizerConstructors:()=>ks,Pack:()=>dl,PadV2:()=>Ii,Pool:()=>PR,Pow:()=>Si,Prelu:()=>Ti,Prod:()=>Ni,RMSPropOptimizer:()=>Hm,RNN:()=>as,Range:()=>ed,Rank:()=>Ow,Real:()=>ah,RealDiv:()=>ii,Reciprocal:()=>td,Reduction:()=>P7,Relu:()=>Ci,Relu6:()=>Ri,Reshape:()=>pl,ResizeBilinear:()=>Ei,ResizeBilinearGrad:()=>mm,ResizeNearestNeighbor:()=>rd,ResizeNearestNeighborGrad:()=>fm,Reverse:()=>hl,RotateWithOffset:()=>Tl,Round:()=>cl,Rsqrt:()=>Mi,SGDOptimizer:()=>kh,ScatterNd:()=>fl,Select:()=>ml,Selu:()=>nd,Sequential:()=>i0,Sigmoid:()=>$i,Sign:()=>ad,Sin:()=>Fi,Sinh:()=>yl,Slice:()=>gl,Softmax:()=>zi,Softplus:()=>sd,SpaceToBatchND:()=>Al,SparseFillEmptyRows:()=>sh,SparseReshape:()=>id,SparseSegmentMean:()=>ih,SparseSegmentSum:()=>oh,SparseToDense:()=>lh,SplitV:()=>xl,Sqrt:()=>Pi,Square:()=>od,SquaredDifference:()=>Oi,Step:()=>Wi,StridedSlice:()=>bl,StringNGrams:()=>uh,StringSplit:()=>gm,StringToHashBucketFast:()=>ym,Sub:()=>Di,Sum:()=>_i,SymbolicTensor:()=>ua,Tan:()=>vl,Tanh:()=>Li,Tensor:()=>nt,TensorBuffer:()=>sr,Tile:()=>es,TopK:()=>wl,Transform:()=>kl,Transpose:()=>Bi,Unique:()=>Am,Unpack:()=>Il,UnsortedSegmentSum:()=>dh,Variable:()=>Op,ZerosLike:()=>Sl,_FusedMatMul:()=>Fs,abs:()=>rr,acos:()=>Tk,acosh:()=>Nk,add:()=>le,addN:()=>bm,all:()=>$2,any:()=>wf,argMax:()=>Cn,argMin:()=>Ck,asin:()=>Ek,asinh:()=>Rk,atan:()=>Mk,atan2:()=>Fk,atanh:()=>$k,avgPool:()=>vm,avgPool3d:()=>_2,backend:()=>zn,backend_util:()=>N,basicLSTMCell:()=>v$,batchNorm:()=>wu,batchNorm2d:()=>Ok,batchNorm3d:()=>Dk,batchNorm4d:()=>Lk,batchToSpaceND:()=>wm,bincount:()=>z2,booleanMaskAsync:()=>Pz,broadcastArgs:()=>Bk,broadcastTo:()=>Ep,broadcast_util:()=>Nl,browser:()=>_n,buffer:()=>We,callbacks:()=>hj,cast:()=>me,ceil:()=>Wk,clipByValue:()=>cn,clone:()=>Br,complex:()=>_s,concat:()=>kt,concat1d:()=>Vk,concat2d:()=>ud,concat3d:()=>Uk,concat4d:()=>Gk,constraints:()=>t4,conv1d:()=>O2,conv2d:()=>Os,conv2dTranspose:()=>L2,conv3d:()=>B2,conv3dTranspose:()=>Hk,copyRegisteredKernels:()=>DR,cos:()=>km,cosh:()=>W2,cosineWindow:()=>pA,cumprod:()=>If,cumsum:()=>V2,customGrad:()=>Fa,data:()=>M6,denseBincount:()=>qk,deprecationWarn:()=>R2,depthToSpace:()=>Kk,depthwiseConv2d:()=>Ah,deregisterOp:()=>mj,device_util:()=>fh,diag:()=>J$,dilation2d:()=>Xk,disableDeprecationWarnings:()=>OF,dispose:()=>re,disposeVariables:()=>DF,div:()=>pe,divNoNan:()=>Zk,dot:()=>sP,dropout:()=>S7,einsum:()=>Yk,elu:()=>xh,enableDebugMode:()=>zF,enableProdMode:()=>E2,enclosingPowerOfTwo:()=>T7,engine:()=>nr,env:()=>Y,equal:()=>En,erf:()=>Jk,exp:()=>Rn,expandDims:()=>qt,expm1:()=>Qk,eye:()=>U2,fft:()=>Pm,fill:()=>dd,findBackend:()=>F2,findBackendFactory:()=>VF,floor:()=>bh,floorDiv:()=>gh,forceHalfFloat:()=>QS,fused:()=>Bs,gather:()=>ku,gatherND:()=>I7,gather_util:()=>w2,getBackend:()=>Ur,getGradient:()=>uy,getKernel:()=>yf,getKernelsForBackend:()=>Ra,getThreadsCount:()=>y2e,gpgpu_util:()=>RS,grad:()=>RP,grads:()=>MP,greater:()=>fn,greaterEqual:()=>El,ifft:()=>Wp,imag:()=>Im,image:()=>Ie,inTopKAsync:()=>jz,initializers:()=>r4,input:()=>v4,io:()=>Tr,irfft:()=>iA,isFinite:()=>bP,isInf:()=>wP,isNaN:()=>e7,keep:()=>fr,kernel_impls:()=>qn,layers:()=>n4,leakyRelu:()=>Sm,less:()=>G2,lessEqual:()=>Rl,linalg:()=>_7,linspace:()=>t7,loadGraphModel:()=>AH,loadLayersModel:()=>kU,localResponseNormalization:()=>r7,log:()=>Mn,log1p:()=>Tm,logSigmoid:()=>OP,logSoftmax:()=>j2,logSumExp:()=>o7,logicalAnd:()=>fa,logicalNot:()=>Cm,logicalOr:()=>K2,logicalXor:()=>XP,losses:()=>ED,matMul:()=>Je,math:()=>ok,max:()=>gr,maxPool:()=>Em,maxPool3d:()=>X2,maxPoolWithArgmax:()=>l7,maximum:()=>ts,mean:()=>Wt,memory:()=>vf,meshgrid:()=>t_,metrics:()=>r6,min:()=>Ds,minimum:()=>vh,mirrorPad:()=>u7,mod:()=>hd,model:()=>vU,models:()=>n6,moments:()=>Rm,movingAverage:()=>Oz,mul:()=>L,multiRNNCell:()=>u_,multinomial:()=>d7,neg:()=>Ot,nextFrame:()=>fA,norm:()=>uA,notEqual:()=>Iu,oneHot:()=>Lp,ones:()=>hn,onesLike:()=>Fn,op:()=>W,outerProduct:()=>f_,pad:()=>Hn,pad1d:()=>y_,pad2d:()=>x_,pad3d:()=>v_,pad4d:()=>k_,pool:()=>C_,pow:()=>Ls,prelu:()=>Fm,print:()=>nk,prod:()=>Z2,profile:()=>LF,rand:()=>$_,randomGamma:()=>O_,randomNormal:()=>p7,randomUniform:()=>cd,range:()=>Su,ready:()=>ld,real:()=>Bp,reciprocal:()=>h7,registerBackend:()=>Cl,registerCallbackConstructor:()=>IU,registerGradient:()=>$w,registerKernel:()=>jn,registerOp:()=>fj,regularizers:()=>a6,relu:()=>_a,relu6:()=>Q2,removeBackend:()=>WF,reshape:()=>G,reverse:()=>$n,reverse1d:()=>H_,reverse2d:()=>K_,reverse3d:()=>Z_,reverse4d:()=>J_,rfft:()=>_m,round:()=>eA,rsqrt:()=>tA,scalar:()=>Se,scatterND:()=>k7,scatter_util:()=>k2,selu:()=>rA,separableConv2d:()=>c7,sequential:()=>wU,serialization:()=>ue,setBackend:()=>M2,setPlatform:()=>UF,setThreadsCount:()=>g2e,setWasmPath:()=>m2e,setWasmPaths:()=>Eb,setWebGLContext:()=>A0,setdiff1dAsync:()=>f7,shared:()=>g0,sigmoid:()=>Nr,sign:()=>m7,signal:()=>CD,sin:()=>nA,sinh:()=>aA,slice:()=>Pe,slice1d:()=>$m,slice2d:()=>sA,slice3d:()=>Ml,slice4d:()=>$o,slice_util:()=>zt,softmax:()=>fd,softplus:()=>pd,spaceToBatchND:()=>Mm,sparse:()=>bp,sparseToDense:()=>dA,spectral:()=>ND,split:()=>Xt,sqrt:()=>Er,square:()=>At,squaredDifference:()=>oA,squeeze:()=>rt,stack:()=>lr,step:()=>wh,stridedSlice:()=>g7,string:()=>rf,sub:()=>ce,sum:()=>ke,sumOutType:()=>ch,tan:()=>y7,tanh:()=>vu,tensor:()=>ct,tensor1d:()=>St,tensor2d:()=>pa,tensor3d:()=>uk,tensor4d:()=>Iz,tensor5d:()=>Sz,tensor6d:()=>Tz,tensor_util:()=>da,test_util:()=>kk,tidy:()=>K,tile:()=>Vn,time:()=>BF,topk:()=>A7,train:()=>go,transpose:()=>tt,truncatedNormal:()=>zm,unique:()=>wy,unregisterGradient:()=>OR,unregisterKernel:()=>zR,unsortedSegmentSum:()=>x7,unstack:()=>rn,upcastType:()=>Cr,util:()=>w,valueAndGrad:()=>FP,valueAndGrads:()=>$P,variable:()=>b7,variableGrads:()=>n7,version:()=>Hh,version_converter:()=>xH,version_core:()=>C2,version_cpu:()=>sK,version_layers:()=>OA,version_wasm:()=>A2e,version_webgl:()=>Ete,webgl:()=>Rte,webgl_util:()=>eS,webgpu:()=>nT,where:()=>Wr,whereAsync:()=>lA,zeros:()=>Pt,zerosLike:()=>at});var GE=Object.create,Gf=Object.defineProperty,jE=Object.getOwnPropertyDescriptor,yw=Object.getOwnPropertyNames,HE=Object.getPrototypeOf,qE=Object.prototype.hasOwnProperty,KE=e=>Gf(e,"__esModule",{value:!0}),ur=(e,t)=>function(){return t||(0,e[yw(e)[0]])((t={exports:{}}).exports,t),t.exports},Le=(e,t)=>{for(var r in t)Gf(e,r,{get:t[r],enumerable:!0})},XE=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of yw(t))!qE.call(e,a)&&(r||a!=="default")&&Gf(e,a,{get:()=>t[a],enumerable:!(n=jE(t,a))||n.enumerable});return e},Bo=(e,t)=>XE(KE(Gf(e!=null?GE(HE(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),ZE=ur({"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(I){}function n(I,z,O){this.low=I|0,this.high=z|0,this.unsigned=!!O}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0});function a(I){return(I&&I.__isLong__)===!0}n.isLong=a;var s={},i={};function o(I,z){var O,j,X;return z?(I>>>=0,(X=0<=I&&I<256)&&(j=i[I],j)?j:(O=u(I,(I|0)<0?-1:0,!0),X&&(i[I]=O),O)):(I|=0,(X=-128<=I&&I<128)&&(j=s[I],j)?j:(O=u(I,I<0?-1:0,!1),X&&(s[I]=O),O))}n.fromInt=o;function l(I,z){if(isNaN(I))return z?b:x;if(z){if(I<0)return b;if(I>=g)return R}else{if(I<=-y)return _;if(I+1>=y)return E}return I<0?l(-I,z).neg():u(I%m|0,I/m|0,z)}n.fromNumber=l;function u(I,z,O){return new n(I,z,O)}n.fromBits=u;var d=Math.pow;function h(I,z,O){if(I.length===0)throw Error("empty string");if(I==="NaN"||I==="Infinity"||I==="+Infinity"||I==="-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(I.substring(1),z,O).neg();for(var X=l(d(O,8)),D=x,Q=0;Q>>0:this.low},M.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},M.toString=function(I){if(I=I||10,I<2||36>>0,J=ee.toString(I);if(D=V,D.isZero())return J+Q;for(;J.length<6;)J="0"+J;Q=""+J+Q}},M.getHighBits=function(){return this.high},M.getHighBitsUnsigned=function(){return this.high>>>0},M.getLowBits=function(){return this.low},M.getLowBitsUnsigned=function(){return this.low>>>0},M.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_)?64:this.neg().getNumBitsAbs();for(var I=this.high!=0?this.high:this.low,z=31;z>0&&(I&1<=0},M.isOdd=function(){return(this.low&1)===1},M.isEven=function(){return(this.low&1)===0},M.equals=function(I){return a(I)||(I=p(I)),this.unsigned!==I.unsigned&&this.high>>>31===1&&I.high>>>31===1?!1:this.high===I.high&&this.low===I.low},M.eq=M.equals,M.notEquals=function(I){return!this.eq(I)},M.neq=M.notEquals,M.ne=M.notEquals,M.lessThan=function(I){return this.comp(I)<0},M.lt=M.lessThan,M.lessThanOrEqual=function(I){return this.comp(I)<=0},M.lte=M.lessThanOrEqual,M.le=M.lessThanOrEqual,M.greaterThan=function(I){return this.comp(I)>0},M.gt=M.greaterThan,M.greaterThanOrEqual=function(I){return this.comp(I)>=0},M.gte=M.greaterThanOrEqual,M.ge=M.greaterThanOrEqual,M.compare=function(I){if(a(I)||(I=p(I)),this.eq(I))return 0;var z=this.isNegative(),O=I.isNegative();return z&&!O?-1:!z&&O?1:this.unsigned?I.high>>>0>this.high>>>0||I.high===this.high&&I.low>>>0>this.low>>>0?-1:1:this.sub(I).isNegative()?-1:1},M.comp=M.compare,M.negate=function(){return!this.unsigned&&this.eq(_)?_:this.not().add(v)},M.neg=M.negate,M.add=function(I){a(I)||(I=p(I));var z=this.high>>>16,O=this.high&65535,j=this.low>>>16,X=this.low&65535,D=I.high>>>16,Q=I.high&65535,V=I.low>>>16,ee=I.low&65535,J=0,ie=0,Z=0,ae=0;return ae+=X+ee,Z+=ae>>>16,ae&=65535,Z+=j+V,ie+=Z>>>16,Z&=65535,ie+=O+Q,J+=ie>>>16,ie&=65535,J+=z+D,J&=65535,u(Z<<16|ae,J<<16|ie,this.unsigned)},M.subtract=function(I){return a(I)||(I=p(I)),this.add(I.neg())},M.sub=M.subtract,M.multiply=function(I){if(this.isZero())return x;if(a(I)||(I=p(I)),r){var z=r.mul(this.low,this.high,I.low,I.high);return u(z,r.get_high(),this.unsigned)}if(I.isZero())return x;if(this.eq(_))return I.isOdd()?_:x;if(I.eq(_))return this.isOdd()?_:x;if(this.isNegative())return I.isNegative()?this.neg().mul(I.neg()):this.neg().mul(I).neg();if(I.isNegative())return this.mul(I.neg()).neg();if(this.lt(A)&&I.lt(A))return l(this.toNumber()*I.toNumber(),this.unsigned);var O=this.high>>>16,j=this.high&65535,X=this.low>>>16,D=this.low&65535,Q=I.high>>>16,V=I.high&65535,ee=I.low>>>16,J=I.low&65535,ie=0,Z=0,ae=0,de=0;return de+=D*J,ae+=de>>>16,de&=65535,ae+=X*J,Z+=ae>>>16,ae&=65535,ae+=D*ee,Z+=ae>>>16,ae&=65535,Z+=j*J,ie+=Z>>>16,Z&=65535,Z+=X*ee,ie+=Z>>>16,Z&=65535,Z+=D*V,ie+=Z>>>16,Z&=65535,ie+=O*J+j*ee+X*V+D*Q,ie&=65535,u(ae<<16|de,ie<<16|Z,this.unsigned)},M.mul=M.multiply,M.divide=function(I){if(a(I)||(I=p(I)),I.isZero())throw Error("division by zero");if(r){if(!this.unsigned&&this.high===-2147483648&&I.low===-1&&I.high===-1)return this;var z=(this.unsigned?r.div_u:r.div_s)(this.low,this.high,I.low,I.high);return u(z,r.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var O,j,X;if(this.unsigned){if(I.unsigned||(I=I.toUnsigned()),I.gt(this))return b;if(I.gt(this.shru(1)))return S;X=b}else{if(this.eq(_)){if(I.eq(v)||I.eq(T))return _;if(I.eq(_))return v;var D=this.shr(1);return O=D.div(I).shl(1),O.eq(x)?I.isNegative()?v:T:(j=this.sub(I.mul(O)),X=O.add(j.div(I)),X)}else if(I.eq(_))return this.unsigned?b:x;if(this.isNegative())return I.isNegative()?this.neg().div(I.neg()):this.neg().div(I).neg();if(I.isNegative())return this.div(I.neg()).neg();X=x}for(j=this;j.gte(I);){O=Math.max(1,Math.floor(j.toNumber()/I.toNumber()));for(var Q=Math.ceil(Math.log(O)/Math.LN2),V=Q<=48?1:d(2,Q-48),ee=l(O),J=ee.mul(I);J.isNegative()||J.gt(j);)O-=V,ee=l(O,this.unsigned),J=ee.mul(I);ee.isZero()&&(ee=v),X=X.add(ee),j=j.sub(J)}return X},M.div=M.divide,M.modulo=function(I){if(a(I)||(I=p(I)),r){var z=(this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,I.low,I.high);return u(z,r.get_high(),this.unsigned)}return this.sub(this.div(I).mul(I))},M.mod=M.modulo,M.rem=M.modulo,M.not=function(){return u(~this.low,~this.high,this.unsigned)},M.and=function(I){return a(I)||(I=p(I)),u(this.low&I.low,this.high&I.high,this.unsigned)},M.or=function(I){return a(I)||(I=p(I)),u(this.low|I.low,this.high|I.high,this.unsigned)},M.xor=function(I){return a(I)||(I=p(I)),u(this.low^I.low,this.high^I.high,this.unsigned)},M.shiftLeft=function(I){return a(I)&&(I=I.toInt()),(I&=63)===0?this:I<32?u(this.low<>>32-I,this.unsigned):u(0,this.low<>>I|this.high<<32-I,this.high>>I,this.unsigned):u(this.high>>I-32,this.high>=0?0:-1,this.unsigned)},M.shr=M.shiftRight,M.shiftRightUnsigned=function(I){if(a(I)&&(I=I.toInt()),I&=63,I===0)return this;var z=this.high;if(I<32){var O=this.low;return u(O>>>I|z<<32-I,z>>>I,this.unsigned)}else return I===32?u(z,0,this.unsigned):u(z>>>I-32,0,this.unsigned)},M.shru=M.shiftRightUnsigned,M.shr_u=M.shiftRightUnsigned,M.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},M.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},M.toBytes=function(I){return I?this.toBytesLE():this.toBytesBE()},M.toBytesLE=function(){var I=this.high,z=this.low;return[z&255,z>>>8&255,z>>>16&255,z>>>24,I&255,I>>>8&255,I>>>16&255,I>>>24]},M.toBytesBE=function(){var I=this.high,z=this.low;return[I>>>24,I>>>16&255,I>>>8&255,I&255,z>>>24,z>>>16&255,z>>>8&255,z&255]},n.fromBytes=function(I,z,O){return O?n.fromBytesLE(I,z):n.fromBytesBE(I,z)},n.fromBytesLE=function(I,z){return new n(I[0]|I[1]<<8|I[2]<<16|I[3]<<24,I[4]|I[5]<<8|I[6]<<16|I[7]<<24,z)},n.fromBytesBE=function(I,z){return new n(I[4]<<24|I[5]<<16|I[6]<<8|I[7],I[0]<<24|I[1]<<16|I[2]<<8|I[3],z)}}}),YE=ur({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),JE=ur({"(disabled):util"(){}}),QE=ur({"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)}}),eR=ur({"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,f=(d.next()>>>0)/4294967296,m=(c+f)/(1<<21);while(m===0);return m},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)}}),tR=ur({"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,f=(d.next()>>>0)/4294967296,m=(c+f)/(1<<21);while(m===0);return m},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)}}),rR=ur({"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,f,m;return c=h[p],c^=c>>>7,f=c^c<<24,c=h[p+1&7],f^=c^c>>>10,c=h[p+3&7],f^=c^c>>>3,c=h[p+4&7],f^=c^c<<7,c=h[p+7&7],c=c^c<<13,f^=c^c<<9,h[p]=f,u.i=p+1&7,f};function d(h,p){var c,f,m=[];if(p===(p|0))f=m[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,f=(d.next()>>>0)/4294967296,m=(c+f)/(1<<21);while(m===0);return m},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)}}),nR=ur({"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,f,m;return u.w=h=h+1640531527|0,m=p[c+34&127],f=p[c=c+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=p[c]=m^f,u.i=c,m+(h^h>>>16)|0};function d(h,p){var c,f,m,g,y,A=[],x=128;for(p===(p|0)?(f=p,p=null):(p=p+"\0",f=0,x=Math.max(x,p.length)),m=0,g=-32;g>>15,f^=f<<4,f^=f>>>13,g>=0&&(y=y+1640531527|0,c=A[g&127]^=f+y,m=c==0?m+1:0);for(m>=128&&(A[(p&&p.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=A[m+34&127],c=A[m=m+1&127],f^=f<<13,c^=c<<17,f^=f>>>15,c^=c>>>12,A[m]=f^c;h.w=y,h.X=A,h.i=m}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,f=(d.next()>>>0)/4294967296,m=(c+f)/(1<<21);while(m===0);return m},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)}}),aR=ur({"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,f=u.d,m=u.a;return p=p<<25^p>>>7^c,c=c-f|0,f=f<<24^f>>>8^m,m=m-p|0,u.b=p=p<<20^p>>>12^c,u.c=c=c-f|0,u.d=f<<16^c>>>16^m,u.a=m-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,f=(d.next()>>>0)/4294967296,m=(c+f)/(1<<21);while(m===0);return m},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)}}),sR=ur({"(disabled):crypto"(){}}),iR=ur({"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 f(v,S,T){var E=[];S=S==!0?{entropy:!0}:S||{};var R=A(y(S.entropy?[v,b(n)]:v==null?x():v,3),E),_=new m(E),M=function(){for(var I=_.g(i),z=u,O=0;I=h;)I/=2,z/=2,O>>>=1;return(I+O)/z};return M.int32=function(){return _.g(4)|0},M.quick=function(){return _.g(4)/4294967296},M.double=M,A(b(_.S),n),(S.pass||T||function(I,z,O,j){return j&&(j.S&&g(j,_),I.state=function(){return g(_,{})}),O?(a[l]=I,z):I})(M,R,"global"in S?S.global:this==a,S.state)}function m(v){var S,T=v.length,E=this,R=0,_=E.i=E.j=0,M=E.S=[];for(T||(v=[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 $e.buffer!=Pr&&ea($e.buffer),oc}function i(){return $e.buffer!=Pr&&ea($e.buffer),lc}function o(){return $e.buffer!=Pr&&ea($e.buffer),ep}function l(){return $e.buffer!=Pr&&ea($e.buffer),uc}function u(){return $e.buffer!=Pr&&ea($e.buffer),dc}function d(){return $e.buffer!=Pr&&ea($e.buffer),pc}function h(){return $e.buffer!=Pr&&ea($e.buffer),hc}var p=typeof a!="undefined"?a:{},c,f;p.ready=new Promise(function(C,$){c=C,f=$});var m;typeof process!="undefined"&&process.listeners&&(m={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},p),y=[],A="./this.program",x=(C,$)=>{throw $},b=typeof window=="object",v=typeof importScripts=="function",S=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T=p.ENVIRONMENT_IS_PTHREAD||!1,E="";function R(C){return p.locateFile?p.locateFile(C,E):E+C}var _,M,I,z;function O(C){C instanceof up||J("exiting due to exception: "+C)}var j,X,D;if(S){v?E=hf().dirname(E)+"/":E=__dirname+"/",D=()=>{X||(j=u2(),X=hf())},_=function($,U){return D(),$=X.normalize($),j.readFileSync($,U?void 0:"utf8")},I=$=>{var U=_($,!0);return U.buffer||(U=new Uint8Array(U)),U},M=($,U,te)=>{D(),$=X.normalize($),j.readFile($,function(ge,xe){ge?te(ge):U(xe.buffer)})},process.argv.length>1&&(A=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function($){if(!($ instanceof up))throw $}),process.on("unhandledRejection",function($){throw $}),x=($,U)=>{if(oo())throw process.exitCode=$,U;O(U),process.exit($)},p.inspect=function(){return"[Emscripten Module object]"};let C;try{C=oR()}catch($){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),$}global.Worker=C.Worker}else(b||v)&&(v?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="",S||(_=C=>{var $=new XMLHttpRequest;return $.open("GET",C,!1),$.send(null),$.responseText},v&&(I=C=>{var $=new XMLHttpRequest;return $.open("GET",C,!1),$.responseType="arraybuffer",$.send(null),new Uint8Array($.response)}),M=(C,$,U)=>{var te=new XMLHttpRequest;te.open("GET",C,!0),te.responseType="arraybuffer",te.onload=()=>{if(te.status==200||te.status==0&&te.response){$(te.response);return}U()},te.onerror=U,te.send(null)}),z=C=>document.title=C);S&&typeof performance=="undefined"&&(global.performance=lR().performance);var Q=console.log.bind(console),V=console.warn.bind(console);S&&(D(),Q=C=>j.writeSync(1,C+` `),V=C=>j.writeSync(2,C+` `));var ee=p.print||Q,J=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 Z(C){Z.shown||(Z.shown={}),Z.shown[C]||(Z.shown[C]=1,J(C))}function ae(C,$){if(typeof WebAssembly.Function=="function"){for(var U={i:"i32",j:"i64",f:"f32",d:"f64"},te={parameters:[],results:$[0]=="v"?[]:[U[$[0]]]},ge=1;ge<$.length;++ge)te.parameters.push(U[$[ge]]);return new WebAssembly.Function(te,C)}var xe=[1,0,1,96],Ne=$.slice(0,1),_e=$.slice(1),$t={i:127,j:126,f:125,d:124};xe.push(_e.length);for(var ge=0;ge<_e.length;++ge)xe.push($t[_e[ge]]);Ne=="v"?xe.push(0):xe=xe.concat([1,$t[Ne]]),xe[1]=xe.length-2;var aa=new Uint8Array([0,97,115,109,1,0,0,0].concat(xe,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),sa=new WebAssembly.Module(aa),Wc=new WebAssembly.Instance(sa,{e:{f:C}}),dp=Wc.exports.f;return dp}var de=[],Ae;function be(){if(de.length)return de.pop();try{kn.grow(1)}catch(C){throw C instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":C}return kn.length-1}function Ee(C,$){for(var U=C;U{Me=C},Be=Atomics.load,Ze=Atomics.store,ot=Atomics.compareExchange,dt;p.wasmBinary&&(dt=p.wasmBinary);var pt=p.noExitRuntime||!0;typeof WebAssembly!="object"&&Xl("no native wasm support detected");var $e,vt,yt=!1,$r;function pr(C,$){C||Xl($)}function Yr(C){var $=p["_"+C];return $}function er(C,$,U,te,ge){var xe={string:function(In){var su=0;if(In!=null&&In!==0){var C3=(In.length<<2)+1;su=au(C3),so(In,su,C3)}return su},array:function(In){var su=au(In.length);return Ua(In,su),su}};function Ne(In){return $==="string"?wn(In):$==="boolean"?Boolean(In):In}var _e=Yr(C),$t=[],aa=0;if(te)for(var sa=0;sa(U.buffer instanceof SharedArrayBuffer&&(U=new Uint8Array(U)),$.decode.call($,U))}var tr=typeof TextDecoder!="undefined"?new Jr("utf8"):void 0;function vn(C,$,U){for(var te=$+U,ge=$;C[ge]&&!(ge>=te);)++ge;if(ge-$>16&&C.subarray&&tr)return tr.decode(C.subarray($,ge));for(var xe="";$>10,56320|aa&1023)}}return xe}function wn(C,$){return C?vn(i(),C,$):""}function ms(C,$,U,te){if(!(te>0))return 0;for(var ge=U,xe=U+te-1,Ne=0;Ne=55296&&_e<=57343){var $t=C.charCodeAt(++Ne);_e=65536+((_e&1023)<<10)|$t&1023}if(_e<=127){if(U>=xe)break;$[U++]=_e}else if(_e<=2047){if(U+1>=xe)break;$[U++]=192|_e>>6,$[U++]=128|_e&63}else if(_e<=65535){if(U+2>=xe)break;$[U++]=224|_e>>12,$[U++]=128|_e>>6&63,$[U++]=128|_e&63}else{if(U+3>=xe)break;$[U++]=240|_e>>18,$[U++]=128|_e>>12&63,$[U++]=128|_e>>6&63,$[U++]=128|_e&63}}return $[U]=0,U-ge}function so(C,$,U){return ms(C,i(),$,U)}function ic(C){for(var $=0,U=0;U=55296&&te<=57343&&(te=65536+((te&1023)<<10)|C.charCodeAt(++U)&1023),te<=127?++$:te<=2047?$+=2:te<=65535?$+=3:$+=4}return $}var gs=typeof TextDecoder!="undefined"?new Jr("utf-16le"):void 0;function Ua(C,$){s().set(C,$)}function Qd(C,$,U){for(var te=0;te>0]=C.charCodeAt(te);U||(s()[$>>0]=0)}function ql(C,$){return C%$>0&&(C+=$-C%$),C}var Pr,oc,lc,ep,uc,dc,l3,pc,hc;T&&(Pr=p.buffer);function ea(C){Pr=C,p.HEAP8=oc=new Int8Array(C),p.HEAP16=ep=new Int16Array(C),p.HEAP32=dc=new Int32Array(C),p.HEAPU8=lc=new Uint8Array(C),p.HEAPU16=uc=new Uint16Array(C),p.HEAPU32=l3=new Uint32Array(C),p.HEAPF32=pc=new Float32Array(C),p.HEAPF64=hc=new Float64Array(C)}var cc=p.INITIAL_MEMORY||16777216;if(T)$e=p.wasmMemory,Pr=p.buffer;else if(p.wasmMemory)$e=p.wasmMemory;else if($e=new WebAssembly.Memory({initial:cc/65536,maximum:32768,shared:!0}),!($e.buffer instanceof SharedArrayBuffer))throw J("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"),S&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");$e&&(Pr=$e.buffer),cc=Pr.byteLength,ea(Pr);var kn,Kl=[],ys=[],gg=[],fc=[],io=!1,yg=!1,mc=0;function oo(){return pt||mc>0}function _r(){if(p.preRun)for(typeof p.preRun=="function"&&(p.preRun=[p.preRun]);p.preRun.length;)u3(p.preRun.shift());bc(Kl)}function tp(){io=!0,!T&&bc(ys)}function Ag(){T||(Oe.terminateAllThreads(),yg=!0)}function xg(){if(!T){if(p.postRun)for(typeof p.postRun=="function"&&(p.postRun=[p.postRun]);p.postRun.length;)rp(p.postRun.shift());bc(fc)}}function u3(C){Kl.unshift(C)}function d3(C){ys.unshift(C)}function rp(C){fc.unshift(C)}var As=0,gc=null,ta=null;function np(C){As++,p.monitorRunDependencies&&p.monitorRunDependencies(As)}function p3(C){if(As--,p.monitorRunDependencies&&p.monitorRunDependencies(As),As==0&&(gc!==null&&(clearInterval(gc),gc=null),ta)){var $=ta;ta=null,$()}}p.preloadedImages={},p.preloadedAudios={};function Xl(C){T?postMessage({cmd:"onAbort",arg:C}):p.onAbort&&p.onAbort(C),C="Aborted("+C+")",J(C),yt=!0,$r=1,C+=". Build with -s ASSERTIONS=1 for more info.";var $=new WebAssembly.RuntimeError(C);throw f($),$}var bg="data:application/octet-stream;base64,";function yc(C){return C.startsWith(bg)}function Ac(C){return C.startsWith("file://")}var zr;zr="tfjs-backend-wasm-threaded-simd.wasm",yc(zr)||(zr=R(zr));function xc(C){try{if(C==zr&&dt)return new Uint8Array(dt);if(I)return I(C);throw"both async and sync fetching of the wasm failed"}catch($){Xl($)}}function Zl(){if(!dt&&(b||v)){if(typeof fetch=="function"&&!Ac(zr))return fetch(zr,{credentials:"same-origin"}).then(function(C){if(!C.ok)throw"failed to load wasm binary file at '"+zr+"'";return C.arrayBuffer()}).catch(function(){return xc(zr)});if(M)return new Promise(function(C,$){M(zr,function(U){C(new Uint8Array(U))},$)})}return Promise.resolve().then(function(){return xc(zr)})}function vg(){var C={env:Fc,wasi_snapshot_preview1:Fc};function $(Ne,_e){var $t=Ne.exports;if(p.asm=$t,Cg(p.asm.emscripten_tls_init),kn=p.asm.__indirect_function_table,d3(p.asm.__wasm_call_ctors),vt=_e,!T){var aa=Oe.unusedWorkers.length;Oe.unusedWorkers.forEach(function(sa){Oe.loadWasmModuleToWorker(sa,function(){--aa||p3("wasm-instantiate")})})}}T||np("wasm-instantiate");function U(Ne){$(Ne.instance,Ne.module)}function te(Ne){return Zl().then(function(_e){return WebAssembly.instantiate(_e,C)}).then(function(_e){return _e}).then(Ne,function(_e){J("failed to asynchronously prepare wasm: "+_e),Xl(_e)})}function ge(){return!dt&&typeof WebAssembly.instantiateStreaming=="function"&&!yc(zr)&&!Ac(zr)&&typeof fetch=="function"?fetch(zr,{credentials:"same-origin"}).then(function(Ne){var _e=WebAssembly.instantiateStreaming(Ne,C);return _e.then(U,function($t){return J("wasm streaming compile failed: "+$t),J("falling back to ArrayBuffer instantiation"),te(U)})}):te(U)}if(p.instantiateWasm)try{var xe=p.instantiateWasm(C,$);return xe}catch(Ne){return J("Module.instantiateWasm callback failed with error: "+Ne),!1}return ge().catch(f),{}}var h3,c3,wg={};function bc(C){for(;C.length>0;){var $=C.shift();if(typeof $=="function"){$(p);continue}var U=$.func;typeof U=="number"?$.arg===void 0?Jl(U)():Jl(U)($.arg):U($.arg===void 0?null:$.arg)}}function Yl(C){var $=j1(),U=C();return Oc($),U}function j9(C){return C}function f3(C){var $=/\b_Z[\w\d_]+/g;return C.replace($,function(U){var te=U;return U===te?U:te+" ["+U+"]"})}function kg(C){u()[C>>2]=0;var $=Oe.pthreads[C];delete Oe.pthreads[C],$.worker.terminate(),G1(C),Oe.runningWorkers.splice(Oe.runningWorkers.indexOf($.worker),1),$.worker.pthread=void 0}function Ig(C){var $=Oe.pthreads[C];$.worker.postMessage({cmd:"cancel"})}function vc(C){var $=Oe.pthreads[C];if($){u()[C>>2]=0;var U=$.worker;Oe.returnWorkerToPool(U)}}function wc(C){PE(C)}function Sg(C){if(C instanceof up||C=="unwind")return $r;x(1,C)}var Oe={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){T?Oe.initWorker():Oe.initMainThread()},initMainThread:function(){for(var C=8,$=0;$>2]=0;try{C()}finally{u()[N3>>2]=1}},receiveObjectTransfer:function(C){},threadInit:function(){for(var C in Oe.tlsInitFunctions)Oe.tlsInitFunctions[C]()},loadWasmModuleToWorker:function(C,$){C.onmessage=U=>{var te=U.data,ge=te.cmd;if(C.pthread&&(Oe.currentProxiedOperationCallerThread=C.pthread.threadInfoStruct),te.targetThread&&te.targetThread!=zc()){var xe=Oe.pthreads[te.targetThread];xe?xe.worker.postMessage(te,te.transferList):J('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"?w3():ge==="spawnThread"?Ic(te):ge==="cleanupThread"?vc(te.thread):ge==="killThread"?kg(te.thread):ge==="cancelThread"?Ig(te.thread):ge==="loaded"?(C.loaded=!0,$&&$(C),C.runPthread&&(C.runPthread(),delete C.runPthread)):ge==="print"?ee("Thread "+te.threadId+": "+te.text):ge==="printErr"?J("Thread "+te.threadId+": "+te.text):ge==="alert"?alert("Thread "+te.threadId+": "+te.text):te.target==="setimmediate"?C.postMessage(te):ge==="onAbort"?p.onAbort&&p.onAbort(te.arg):J("worker sent an unknown command "+ge),Oe.currentProxiedOperationCallerThread=void 0},C.onerror=U=>{var te="worker sent an error!";throw J(te+" "+U.filename+":"+U.lineno+": "+U.message),U},S&&(C.on("message",function(U){C.onmessage({data:U})}),C.on("error",function(U){C.onerror(U)}),C.on("detachedExit",function(){})),C.postMessage({cmd:"load",urlOrBlob:p.mainScriptUrlOrBlob||n,wasmMemory:$e,wasmModule:vt})},allocateUnusedWorker:function(){var C=R("tfjs-backend-wasm-threaded-simd.worker.js");Oe.unusedWorkers.push(new Worker(C))},getNewWorker:function(){return Oe.unusedWorkers.length==0&&(Oe.allocateUnusedWorker(),Oe.loadWasmModuleToWorker(Oe.unusedWorkers[0])),Oe.unusedWorkers.pop()}};function Tg(){var C=zc(),$=u()[C+44>>2],U=u()[C+48>>2],te=$-U;T3($,te),Oc($)}p.establishStackSpace=Tg;function kc(C){if(T)return po(1,0,C);try{wc(C)}catch($){Sg($)}}var lo=[];function Jl(C){var $=lo[C];return $||(C>=lo.length&&(lo.length=C+1),lo[C]=$=kn.get(C)),$}function Ng(C,$){return Jl(C)($)}p.invokeEntryPoint=Ng;function m3(){var C=new Error;if(!C.stack){try{throw new Error}catch($){C=$}if(!C.stack)return"(no stack trace available)"}return C.stack.toString()}function Cg(C,$,U){Oe.tlsInitFunctions.push(C)}function g3(C,$){kn.set(C,$),lo[C]=$}var uo;S?uo=()=>{var C=process.hrtime();return C[0]*1e3+C[1]/1e6}:T?uo=()=>performance.now()-p.__performance_now_clock_drift:uo=()=>performance.now();var Eg=!0;function Rg(C){return u()[v3()>>2]=C,C}function Mg(C,$){var U;if(C===0)U=Date.now();else if((C===1||C===4)&&Eg)U=uo();else return Rg(28),-1;return u()[$>>2]=U/1e3|0,u()[$+4>>2]=U%1e3*1e3*1e3|0,0}function Fg(C,$){return Mg(C,$)}function $g(C){k3(C,!v,1,!b),Oe.threadInit()}function Pg(C){T?postMessage({cmd:"cleanupThread",thread:C}):vc(C)}function Ic(C){var $=Oe.getNewWorker();if(!$)return 6;Oe.runningWorkers.push($);var U=Oe.pthreads[C.pthread_ptr]={worker:$,threadInfoStruct:C.pthread_ptr};$.pthread=U;var te={cmd:"run",start_routine:C.startRoutine,arg:C.arg,threadInfoStruct:C.pthread_ptr};return $.runPthread=()=>{te.time=performance.now(),$.postMessage(te,C.transferList)},$.loaded&&($.runPthread(),delete $.runPthread),0}function _g(C,$,U,te){if(typeof SharedArrayBuffer=="undefined")return J("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ge=[],xe=0;if(T&&(ge.length===0||xe))return I3(687865856,C,$,U,te);if(xe)return xe;var Ne={startRoutine:U,pthread_ptr:C,arg:te,transferList:ge};return T?(Ne.cmd="spawnThread",postMessage(Ne,ge),0):Ic(Ne)}function zg(){return 2097152}function Og(C,$){if(C==$)postMessage({cmd:"processQueuedMainThreadWork"});else if(T)postMessage({targetThread:C,cmd:"processThreadQueue"});else{var U=Oe.pthreads[C],te=U&&U.worker;if(!te)return;te.postMessage({cmd:"processThreadQueue"})}return 1}function Dg(){Xl("")}function Lg(){S||v||Z("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Sc(){return 2147483648}function Bg(C,$,U){i().copyWithin(C,$,$+U)}function Wg(){return S?uR().cpus().length:navigator.hardwareConcurrency}function po(C,$){var U=arguments.length-2,te=arguments;return Yl(function(){for(var ge=U,xe=au(ge*8),Ne=xe>>3,_e=0;_e>3,ge=0;ge<$;ge++)ap[ge]=h()[te+ge];var xe=C<0,Ne=xe?wg[-C-1]:o1[C];return Ne.apply(null,ap)}function Ug(C){try{return $e.grow(C-Pr.byteLength+65535>>>16),ea($e.buffer),1}catch($){}}function Gg(C){var $=i().length;if(C=C>>>0,C<=$)return!1;var U=Sc();if(C>U)return!1;for(var te=1;te<=4;te*=2){var ge=$*(1+.2/te);ge=Math.min(ge,C+100663296);var xe=Math.min(U,ql(Math.max(C,ge),65536)),Ne=Ug(xe);if(Ne)return!0}return!1}var Xe={inEventHandler:0,removeAllEventListeners:function(){for(var C=Xe.eventHandlers.length-1;C>=0;--C)Xe._removeHandler(C);Xe.eventHandlers=[],Xe.deferredCalls=[]},registerRemoveEventListeners:function(){Xe.removeEventListenersRegistered||(gg.push(Xe.removeAllEventListeners),Xe.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(C,$,U){function te(Ne,_e){if(Ne.length!=_e.length)return!1;for(var $t in Ne)if(Ne[$t]!=_e[$t])return!1;return!0}for(var ge in Xe.deferredCalls){var xe=Xe.deferredCalls[ge];if(xe.targetFunction==C&&te(xe.argsList,U))return}Xe.deferredCalls.push({targetFunction:C,precedence:$,argsList:U}),Xe.deferredCalls.sort(function(Ne,_e){return Ne.precedence<_e.precedence})},removeDeferredCalls:function(C){for(var $=0;$>2]=U,u()[xe+4>>2]=te,u()[xe+8>>2]=ge,U1(C,637534208,$,te,xe)})},getTargetThreadForEventCallback:function(C){switch(C){case 1:return 0;case 2:return Oe.currentProxiedOperationCallerThread;default:return C}},getNodeNameForTarget:function(C){return C?C==window?"#window":C==screen?"#screen":C&&C.nodeName?C.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function jg(C){var $=ic(C)+1,U=V1($);return so(C,U,$),U}function Hg(C,$,U,te){Yl(function(){var ge=au(12),xe=0;$&&(xe=jg($)),u()[ge>>2]=xe,u()[ge+4>>2]=U,u()[ge+8>>2]=te,U1(C,657457152,0,xe,ge)})}function qg(C,$,U,te){$=$?wn($):"",Hg(C,$,U,te)}function Kg(C){return C>2?wn(C):C}var Xg=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Zg(C){C=Kg(C);var $=Xg[C]||(typeof document!="undefined"?document.querySelector(C):void 0);return $}function sp(C){return Zg(C)}function Tc(C,$,U){var te=sp(C);if(!te)return-4;if(te.canvasSharedPtr&&(u()[te.canvasSharedPtr>>2]=$,u()[te.canvasSharedPtr+4>>2]=U),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=U,ge&&te.GLctxObject.GLctx.viewport(0,0,$,U)}else if(te.canvasSharedPtr){var Ne=u()[te.canvasSharedPtr+8>>2];return qg(Ne,C,$,U),1}else return-4;return 0}function Nc(C,$,U){return T?po(2,1,C,$,U):Tc(C,$,U)}function Yg(C,$,U){var te=sp(C);return te?Tc(C,$,U):Nc(C,$,U)}function Jg(){throw"unwind"}function Qg(C){var $=C.getExtension("ANGLE_instanced_arrays");if($)return C.vertexAttribDivisor=function(U,te){$.vertexAttribDivisorANGLE(U,te)},C.drawArraysInstanced=function(U,te,ge,xe){$.drawArraysInstancedANGLE(U,te,ge,xe)},C.drawElementsInstanced=function(U,te,ge,xe,Ne){$.drawElementsInstancedANGLE(U,te,ge,xe,Ne)},1}function e1(C){var $=C.getExtension("OES_vertex_array_object");if($)return C.createVertexArray=function(){return $.createVertexArrayOES()},C.deleteVertexArray=function(U){$.deleteVertexArrayOES(U)},C.bindVertexArray=function(U){$.bindVertexArrayOES(U)},C.isVertexArray=function(U){return $.isVertexArrayOES(U)},1}function t1(C){var $=C.getExtension("WEBGL_draw_buffers");if($)return C.drawBuffers=function(U,te){$.drawBuffersWEBGL(U,te)},1}function r1(C){return!!(C.multiDrawWebgl=C.getExtension("WEBGL_multi_draw"))}var Ft={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(C){Ft.lastError||(Ft.lastError=C)},getNewId:function(C){for(var $=Ft.counter++,U=C.length;U<$;U++)C[U]=null;return $},getSource:function(C,$,U,te){for(var ge="",xe=0;xe<$;++xe){var Ne=te?u()[te+xe*4>>2]:-1;ge+=wn(u()[U+xe*4>>2],Ne<0?void 0:Ne)}return ge},createContext:function(C,$){C.getContextSafariWebGL2Fixed||(C.getContextSafariWebGL2Fixed=C.getContext,C.getContext=function(ge,xe){var Ne=C.getContextSafariWebGL2Fixed(ge,xe);return ge=="webgl"==Ne instanceof WebGLRenderingContext?Ne:null});var U=C.getContext("webgl",$);if(!U)return 0;var te=Ft.registerContext(U,$);return te},registerContext:function(C,$){var U=V1(8);u()[U+4>>2]=zc();var te={handle:U,attributes:$,version:$.majorVersion,GLctx:C};return C.canvas&&(C.canvas.GLctxObject=te),Ft.contexts[U]=te,(typeof $.enableExtensionsByDefault=="undefined"||$.enableExtensionsByDefault)&&Ft.initExtensions(te),U},makeContextCurrent:function(C){return Ft.currentContext=Ft.contexts[C],p.ctx=Mc=Ft.currentContext&&Ft.currentContext.GLctx,!(C&&!Mc)},getContext:function(C){return Ft.contexts[C]},deleteContext:function(C){Ft.currentContext===Ft.contexts[C]&&(Ft.currentContext=null),typeof Xe=="object"&&Xe.removeAllHandlersOnTarget(Ft.contexts[C].GLctx.canvas),Ft.contexts[C]&&Ft.contexts[C].GLctx.canvas&&(Ft.contexts[C].GLctx.canvas.GLctxObject=void 0),b3(Ft.contexts[C].handle),Ft.contexts[C]=null},initExtensions:function(C){if(C||(C=Ft.currentContext),!C.initExtensionsDone){C.initExtensionsDone=!0;var $=C.GLctx;Qg($),e1($),t1($),$.disjointTimerQueryExt=$.getExtension("EXT_disjoint_timer_query"),r1($);var U=$.getSupportedExtensions()||[];U.forEach(function(te){!te.includes("lose_context")&&!te.includes("debug")&&$.getExtension(te)})}}},n1=["default","low-power","high-performance"];function a1(C,$){var U=$>>2,te=u()[U+6],ge={alpha:!!u()[U+0],depth:!!u()[U+1],stencil:!!u()[U+2],antialias:!!u()[U+3],premultipliedAlpha:!!u()[U+4],preserveDrawingBuffer:!!u()[U+5],powerPreference:n1[te],failIfMajorPerformanceCaveat:!!u()[U+7],majorVersion:u()[U+8],minorVersion:u()[U+9],enableExtensionsByDefault:u()[U+10],explicitSwapControl:u()[U+11],proxyContextToMainThread:u()[U+12],renderViaOffscreenBackBuffer:u()[U+13]},xe=sp(C);if(!xe||ge.explicitSwapControl)return 0;var Ne=Ft.createContext(xe,ge);return Ne}function s1(C,$){return a1(C,$)}var Ql={mappings:{},buffers:[null,[],[]],printChar:function(C,$){var U=Ql.buffers[C];$===0||$===10?((C===1?ee:J)(vn(U,0)),U.length=0):U.push($)},varargs:void 0,get:function(){Ql.varargs+=4;var C=u()[Ql.varargs-4>>2];return C},getStr:function(C){var $=wn(C);return $},get64:function(C,$){return C}};function Cc(C){return T?po(3,1,C):0}function Ec(C,$,U,te,ge){if(T)return po(4,1,C,$,U,te,ge)}function Rc(C,$,U,te){if(T)return po(5,1,C,$,U,te);for(var ge=0,xe=0;xe>2],_e=u()[$+4>>2];$+=8;for(var $t=0;$t<_e;$t++)Ql.printChar(C,i()[Ne+$t]);ge+=_e}return u()[te>>2]=ge,0}function i1(C){De(C)}Oe.init();var Mc,o1=[null,kc,Nc,Cc,Ec,Rc],y3=!1,Fc={__clock_gettime:Fg,__emscripten_init_main_thread_js:$g,__emscripten_thread_cleanup:Pg,__pthread_create_js:_g,_emscripten_default_pthread_stack_size:zg,_emscripten_notify_thread_queue:Og,abort:Dg,emscripten_check_blocking_allowed:Lg,emscripten_get_heap_max:Sc,emscripten_get_now:uo,emscripten_memcpy_big:Bg,emscripten_num_logical_cores:Wg,emscripten_receive_on_main_thread_js:Vg,emscripten_resize_heap:Gg,emscripten_set_canvas_element_size:Yg,emscripten_unwind_to_js_event_loop:Jg,emscripten_webgl_create_context:s1,exit:wc,fd_close:Cc,fd_seek:Ec,fd_write:Rc,memory:$e||p.wasmMemory,setTempRet0:i1},A3=vg(),l1=p.___wasm_call_ctors=function(){return(l1=p.___wasm_call_ctors=p.asm.__wasm_call_ctors).apply(null,arguments)},u1=p._init=function(){return(u1=p._init=p.asm.init).apply(null,arguments)},d1=p._init_with_threads_count=function(){return(d1=p._init_with_threads_count=p.asm.init_with_threads_count).apply(null,arguments)},p1=p._get_threads_count=function(){return(p1=p._get_threads_count=p.asm.get_threads_count).apply(null,arguments)},h1=p._register_tensor=function(){return(h1=p._register_tensor=p.asm.register_tensor).apply(null,arguments)},c1=p._dispose_data=function(){return(c1=p._dispose_data=p.asm.dispose_data).apply(null,arguments)},f1=p._dispose=function(){return(f1=p._dispose=p.asm.dispose).apply(null,arguments)},m1=p._Abs=function(){return(m1=p._Abs=p.asm.Abs).apply(null,arguments)},g1=p._Add=function(){return(g1=p._Add=p.asm.Add).apply(null,arguments)},y1=p._AddN=function(){return(y1=p._AddN=p.asm.AddN).apply(null,arguments)},A1=p._All=function(){return(A1=p._All=p.asm.All).apply(null,arguments)},x1=p._Any=function(){return(x1=p._Any=p.asm.Any).apply(null,arguments)},b1=p._ArgMax=function(){return(b1=p._ArgMax=p.asm.ArgMax).apply(null,arguments)},v1=p._AvgPool=function(){return(v1=p._AvgPool=p.asm.AvgPool).apply(null,arguments)},w1=p._BatchMatMul=function(){return(w1=p._BatchMatMul=p.asm.BatchMatMul).apply(null,arguments)},k1=p._Ceil=function(){return(k1=p._Ceil=p.asm.Ceil).apply(null,arguments)},I1=p._ClipByValue=function(){return(I1=p._ClipByValue=p.asm.ClipByValue).apply(null,arguments)},S1=p._Conv2D=function(){return(S1=p._Conv2D=p.asm.Conv2D).apply(null,arguments)},T1=p._Conv2DBackpropInput=function(){return(T1=p._Conv2DBackpropInput=p.asm.Conv2DBackpropInput).apply(null,arguments)},N1=p._Cos=function(){return(N1=p._Cos=p.asm.Cos).apply(null,arguments)},C1=p._Cosh=function(){return(C1=p._Cosh=p.asm.Cosh).apply(null,arguments)},E1=p._CropAndResize=function(){return(E1=p._CropAndResize=p.asm.CropAndResize).apply(null,arguments)},R1=p._Cumprod=function(){return(R1=p._Cumprod=p.asm.Cumprod).apply(null,arguments)},M1=p._Cumsum=function(){return(M1=p._Cumsum=p.asm.Cumsum).apply(null,arguments)},F1=p._DepthToSpace=function(){return(F1=p._DepthToSpace=p.asm.DepthToSpace).apply(null,arguments)},$1=p._DepthwiseConv2dNative=function(){return($1=p._DepthwiseConv2dNative=p.asm.DepthwiseConv2dNative).apply(null,arguments)},P1=p._Elu=function(){return(P1=p._Elu=p.asm.Elu).apply(null,arguments)},_1=p._Equal=function(){return(_1=p._Equal=p.asm.Equal).apply(null,arguments)},z1=p._Exp=function(){return(z1=p._Exp=p.asm.Exp).apply(null,arguments)},O1=p._FlipLeftRight=function(){return(O1=p._FlipLeftRight=p.asm.FlipLeftRight).apply(null,arguments)},$c=p._Floor=function(){return($c=p._Floor=p.asm.Floor).apply(null,arguments)},Pc=p._FloorDiv=function(){return(Pc=p._FloorDiv=p.asm.FloorDiv).apply(null,arguments)},ip=p._FusedBatchNorm=function(){return(ip=p._FusedBatchNorm=p.asm.FusedBatchNorm).apply(null,arguments)},D1=p._FusedConv2D=function(){return(D1=p._FusedConv2D=p.asm.FusedConv2D).apply(null,arguments)},L1=p._FusedDepthwiseConv2D=function(){return(L1=p._FusedDepthwiseConv2D=p.asm.FusedDepthwiseConv2D).apply(null,arguments)},eu=p._Gather=function(){return(eu=p._Gather=p.asm.Gather).apply(null,arguments)},op=p._GatherNd=function(){return(op=p._GatherNd=p.asm.GatherNd).apply(null,arguments)},lp=p._Greater=function(){return(lp=p._Greater=p.asm.Greater).apply(null,arguments)},x3=p._GreaterEqual=function(){return(x3=p._GreaterEqual=p.asm.GreaterEqual).apply(null,arguments)},tu=p._LeakyRelu=function(){return(tu=p._LeakyRelu=p.asm.LeakyRelu).apply(null,arguments)},ru=p._Less=function(){return(ru=p._Less=p.asm.Less).apply(null,arguments)},B1=p._LessEqual=function(){return(B1=p._LessEqual=p.asm.LessEqual).apply(null,arguments)},H=p._Log=function(){return(H=p._Log=p.asm.Log).apply(null,arguments)},ne=p._LogicalAnd=function(){return(ne=p._LogicalAnd=p.asm.LogicalAnd).apply(null,arguments)},ye=p._Max=function(){return(ye=p._Max=p.asm.Max).apply(null,arguments)},Re=p._MaxPool=function(){return(Re=p._MaxPool=p.asm.MaxPool).apply(null,arguments)},lt=p._Maximum=function(){return(lt=p._Maximum=p.asm.Maximum).apply(null,arguments)},ht=p._Mean=function(){return(ht=p._Mean=p.asm.Mean).apply(null,arguments)},Ye=p._Min=function(){return(Ye=p._Min=p.asm.Min).apply(null,arguments)},He=p._Minimum=function(){return(He=p._Minimum=p.asm.Minimum).apply(null,arguments)},Ht=p._MirrorPad=function(){return(Ht=p._MirrorPad=p.asm.MirrorPad).apply(null,arguments)},ra=p._Multiply=function(){return(ra=p._Multiply=p.asm.Multiply).apply(null,arguments)},na=p._Neg=function(){return(na=p._Neg=p.asm.Neg).apply(null,arguments)},nu=p._NonMaxSuppressionV3=function(){return(nu=p._NonMaxSuppressionV3=p.asm.NonMaxSuppressionV3).apply(null,arguments)},ho=p._NonMaxSuppressionV4=function(){return(ho=p._NonMaxSuppressionV4=p.asm.NonMaxSuppressionV4).apply(null,arguments)},W1=p._NonMaxSuppressionV5=function(){return(W1=p._NonMaxSuppressionV5=p.asm.NonMaxSuppressionV5).apply(null,arguments)},Qr=p._NotEqual=function(){return(Qr=p._NotEqual=p.asm.NotEqual).apply(null,arguments)},xs=p._OneHot=function(){return(xs=p._OneHot=p.asm.OneHot).apply(null,arguments)},_c=p._PadV2=function(){return(_c=p._PadV2=p.asm.PadV2).apply(null,arguments)},H9=p._Pow=function(){return(H9=p._Pow=p.asm.Pow).apply(null,arguments)},q9=p._Prelu=function(){return(q9=p._Prelu=p.asm.Prelu).apply(null,arguments)},K9=p._Prod=function(){return(K9=p._Prod=p.asm.Prod).apply(null,arguments)},X9=p._RealDiv=function(){return(X9=p._RealDiv=p.asm.RealDiv).apply(null,arguments)},Z9=p._Relu=function(){return(Z9=p._Relu=p.asm.Relu).apply(null,arguments)},Y9=p._Relu6=function(){return(Y9=p._Relu6=p.asm.Relu6).apply(null,arguments)},J9=p._ResizeBilinear=function(){return(J9=p._ResizeBilinear=p.asm.ResizeBilinear).apply(null,arguments)},Q9=p._Reverse=function(){return(Q9=p._Reverse=p.asm.Reverse).apply(null,arguments)},eE=p._RotateWithOffset=function(){return(eE=p._RotateWithOffset=p.asm.RotateWithOffset).apply(null,arguments)},tE=p._Round=function(){return(tE=p._Round=p.asm.Round).apply(null,arguments)},rE=p._Rsqrt=function(){return(rE=p._Rsqrt=p.asm.Rsqrt).apply(null,arguments)},nE=p._ScatterNd=function(){return(nE=p._ScatterNd=p.asm.ScatterNd).apply(null,arguments)},aE=p._SelectV2=function(){return(aE=p._SelectV2=p.asm.SelectV2).apply(null,arguments)},sE=p._Sigmoid=function(){return(sE=p._Sigmoid=p.asm.Sigmoid).apply(null,arguments)},iE=p._Sin=function(){return(iE=p._Sin=p.asm.Sin).apply(null,arguments)},oE=p._Softmax=function(){return(oE=p._Softmax=p.asm.Softmax).apply(null,arguments)},lE=p._SparseFillEmptyRows=function(){return(lE=p._SparseFillEmptyRows=p.asm.SparseFillEmptyRows).apply(null,arguments)},uE=p._SparseReshape=function(){return(uE=p._SparseReshape=p.asm.SparseReshape).apply(null,arguments)},dE=p._SparseSegmentReduction=function(){return(dE=p._SparseSegmentReduction=p.asm.SparseSegmentReduction).apply(null,arguments)},pE=p._Sqrt=function(){return(pE=p._Sqrt=p.asm.Sqrt).apply(null,arguments)},hE=p._Square=function(){return(hE=p._Square=p.asm.Square).apply(null,arguments)},cE=p._SquaredDifference=function(){return(cE=p._SquaredDifference=p.asm.SquaredDifference).apply(null,arguments)},fE=p._Step=function(){return(fE=p._Step=p.asm.Step).apply(null,arguments)},mE=p._StridedSlice=function(){return(mE=p._StridedSlice=p.asm.StridedSlice).apply(null,arguments)},gE=p._Sub=function(){return(gE=p._Sub=p.asm.Sub).apply(null,arguments)},yE=p._Sum=function(){return(yE=p._Sum=p.asm.Sum).apply(null,arguments)},AE=p._Tan=function(){return(AE=p._Tan=p.asm.Tan).apply(null,arguments)},xE=p._Tanh=function(){return(xE=p._Tanh=p.asm.Tanh).apply(null,arguments)},bE=p._Tile=function(){return(bE=p._Tile=p.asm.Tile).apply(null,arguments)},vE=p._TopK=function(){return(vE=p._TopK=p.asm.TopK).apply(null,arguments)},wE=p._Transform=function(){return(wE=p._Transform=p.asm.Transform).apply(null,arguments)},kE=p._Transpose=function(){return(kE=p._Transpose=p.asm.Transpose).apply(null,arguments)},IE=p.__FusedMatMul=function(){return(IE=p.__FusedMatMul=p.asm._FusedMatMul).apply(null,arguments)},V1=p._malloc=function(){return(V1=p._malloc=p.asm.malloc).apply(null,arguments)},b3=p._free=function(){return(b3=p._free=p.asm.free).apply(null,arguments)},SE=p._emscripten_tls_init=function(){return(SE=p._emscripten_tls_init=p.asm.emscripten_tls_init).apply(null,arguments)},v3=p.___errno_location=function(){return(v3=p.___errno_location=p.asm.__errno_location).apply(null,arguments)},zc=p._pthread_self=function(){return(zc=p._pthread_self=p.asm.pthread_self).apply(null,arguments)},w3=p._emscripten_main_thread_process_queued_calls=function(){return(w3=p._emscripten_main_thread_process_queued_calls=p.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},TE=p.__emscripten_thread_crashed=function(){return(TE=p.__emscripten_thread_crashed=p.asm._emscripten_thread_crashed).apply(null,arguments)},k3=p.__emscripten_thread_init=function(){return(k3=p.__emscripten_thread_init=p.asm._emscripten_thread_init).apply(null,arguments)},NE=p._emscripten_current_thread_process_queued_calls=function(){return(NE=p._emscripten_current_thread_process_queued_calls=p.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},CE=p._emscripten_main_browser_thread_id=function(){return(CE=p._emscripten_main_browser_thread_id=p.asm.emscripten_main_browser_thread_id).apply(null,arguments)},EE=p._emscripten_sync_run_in_main_thread_2=function(){return(EE=p._emscripten_sync_run_in_main_thread_2=p.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},I3=p._emscripten_sync_run_in_main_thread_4=function(){return(I3=p._emscripten_sync_run_in_main_thread_4=p.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},S3=p._emscripten_run_in_main_runtime_thread_js=function(){return(S3=p._emscripten_run_in_main_runtime_thread_js=p.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},U1=p._emscripten_dispatch_to_thread_=function(){return(U1=p._emscripten_dispatch_to_thread_=p.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},G1=p.__emscripten_thread_free_data=function(){return(G1=p.__emscripten_thread_free_data=p.asm._emscripten_thread_free_data).apply(null,arguments)},RE=p.__emscripten_thread_exit=function(){return(RE=p.__emscripten_thread_exit=p.asm._emscripten_thread_exit).apply(null,arguments)},ME=p._memalign=function(){return(ME=p._memalign=p.asm.memalign).apply(null,arguments)},T3=p._emscripten_stack_set_limits=function(){return(T3=p._emscripten_stack_set_limits=p.asm.emscripten_stack_set_limits).apply(null,arguments)},j1=p.stackSave=function(){return(j1=p.stackSave=p.asm.stackSave).apply(null,arguments)},Oc=p.stackRestore=function(){return(Oc=p.stackRestore=p.asm.stackRestore).apply(null,arguments)},au=p.stackAlloc=function(){return(au=p.stackAlloc=p.asm.stackAlloc).apply(null,arguments)},FE=p.dynCall_iijjiiii=function(){return(FE=p.dynCall_iijjiiii=p.asm.dynCall_iijjiiii).apply(null,arguments)},$E=p.dynCall_jiji=function(){return($E=p.dynCall_jiji=p.asm.dynCall_jiji).apply(null,arguments)},N3=p.__emscripten_allow_main_runtime_queued_calls=21456;p.cwrap=hr,p.keepRuntimeAlive=oo,p.PThread=Oe,p.PThread=Oe,p.wasmMemory=$e,p.ExitStatus=up;var Dc;function up(C){this.name="ExitStatus",this.message="Program terminated with exit("+C+")",this.status=C}ta=function C(){Dc||H1(),Dc||(ta=C)};function H1(C){if(C=C||y,As>0)return;if(T){c(p),tp(),postMessage({cmd:"loaded"});return}if(_r(),As>0)return;function $(){Dc||(Dc=!0,p.calledRun=!0,!yt&&(tp(),c(p),p.onRuntimeInitialized&&p.onRuntimeInitialized(),xg()))}p.setStatus?(p.setStatus("Running..."),setTimeout(function(){setTimeout(function(){p.setStatus("")},1),$()},1)):$()}p.run=H1;function PE(C,$){if($r=C,!$&&T)throw kc(C),"unwind";oo()||Ag(),_E(C)}function _E(C){$r=C,oo()||(Oe.terminateAllThreads(),p.onExit&&p.onExit(C),yt=!0),x(C,new up(C))}if(p.preInit)for(typeof p.preInit=="function"&&(p.preInit=[p.preInit]);p.preInit.length>0;)p.preInit.pop()();H1();var Lc;m&&(Lc={uncaughtException:process.listeners("uncaughtException").filter(function(C){return!m.uncaughtException.indexOf(C)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(C){return!m.unhandledRejection.indexOf(C)>-1})});var Bc;if(typeof WasmBackendModule!="undefined")Bc=WasmBackendModule;else if(typeof a!="undefined")Bc=a;else throw new Error("Could not find wasm module in post.js");if(Lc){var zE=Bc._dispose;Bc._dispose=function(){zE(),Lc.uncaughtException.forEach(function(C){process.removeListener("uncaughtException",C)}),Lc.unhandledRejection.forEach(function(C){process.removeListener("unhandledRejection",C)})}}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)}}),pR=ur({"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",f=typeof importScripts=="function",m=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,v;function S(H){H instanceof op||M("exiting due to exception: "+H)}var T,E,R;m?(f?g=hf().dirname(g)+"/":g=__dirname+"/",R=()=>{E||(T=u2(),E=hf())},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 op))throw H}),process.on("unhandledRejection",function(H){throw H}),p=(H,ne)=>{if(ep())throw process.exitCode=H,ne;S(ne),process.exit(H)},s.inspect=function(){return"[Emscripten Module object]"}):(c||f)&&(f?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},f&&(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)},v=H=>document.title=H);var _=s.print||console.log.bind(console),M=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.arguments&&(d=s.arguments),s.thisProgram&&(h=s.thisProgram),s.quit&&(p=s.quit);var I=4;function z(H){z.shown||(z.shown={}),z.shown[H]||(z.shown[H]=1,M(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},J;s.wasmBinary&&(J=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&io("no native wasm support detected");var Z,ae=!1,de;function Ae(H,ne){H||io(ne)}function be(H){var ne=s["_"+H];return ne}function Ee(H,ne,ye,Re,lt){var ht={string:function(Qr){var xs=0;if(Qr!=null&&Qr!==0){var _c=(Qr.length<<2)+1;xs=ip(_c),pt(Qr,xs,_c)}return xs},array:function(Qr){var xs=ip(Qr.length);return yt(Qr,xs),xs}};function Ye(Qr){return ne==="string"?ot(Qr):ne==="boolean"?Boolean(Qr):Qr}var He=be(H),Ht=[],ra=0;if(Re)for(var na=0;na=Re);)++lt;if(lt-ne>16&&H.subarray&&Be)return Be.decode(H.subarray(ne,lt));for(var ht="";ne>10,56320|ra&1023)}}return ht}function ot(H,ne){return H?Ze(hr,H,ne):""}function dt(H,ne,ye,Re){if(!(Re>0))return 0;for(var lt=ye,ht=ye+Re-1,Ye=0;Ye=55296&&He<=57343){var Ht=H.charCodeAt(++Ye);He=65536+((He&1023)<<10)|Ht&1023}if(He<=127){if(ye>=ht)break;ne[ye++]=He}else if(He<=2047){if(ye+1>=ht)break;ne[ye++]=192|He>>6,ne[ye++]=128|He&63}else if(He<=65535){if(ye+2>=ht)break;ne[ye++]=224|He>>12,ne[ye++]=128|He>>6&63,ne[ye++]=128|He&63}else{if(ye+3>=ht)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 pt(H,ne,ye){return dt(H,hr,ne,ye)}function $e(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 vt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function yt(H,ne){er.set(H,ne)}function $r(H,ne,ye){for(var Re=0;Re>0]=H.charCodeAt(Re);ye||(er[ne>>0]=0)}function pr(H,ne){return H%ne>0&&(H+=ne-H%ne),H}var Yr,er,hr,Qn,Jr,tr,vn,wn,ms;function so(H){Yr=H,s.HEAP8=er=new Int8Array(H),s.HEAP16=Qn=new Int16Array(H),s.HEAP32=tr=new Int32Array(H),s.HEAPU8=hr=new Uint8Array(H),s.HEAPU16=Jr=new Uint16Array(H),s.HEAPU32=vn=new Uint32Array(H),s.HEAPF32=wn=new Float32Array(H),s.HEAPF64=ms=new Float64Array(H)}var ic=s.INITIAL_MEMORY||16777216,gs,Ua=[],Qd=[],ql=[],Pr=!1,oc=!1,lc=0;function ep(){return ie||lc>0}function uc(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)hc(s.preRun.shift());rp(Ua)}function dc(){Pr=!0,rp(Qd)}function l3(){oc=!0}function pc(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)cc(s.postRun.shift());rp(ql)}function hc(H){Ua.unshift(H)}function ea(H){Qd.unshift(H)}function cc(H){ql.unshift(H)}var kn=0,Kl=null,ys=null;function gg(H){kn++,s.monitorRunDependencies&&s.monitorRunDependencies(kn)}function fc(H){if(kn--,s.monitorRunDependencies&&s.monitorRunDependencies(kn),kn==0&&(Kl!==null&&(clearInterval(Kl),Kl=null),ys)){var ne=ys;ys=null,ne()}}s.preloadedImages={},s.preloadedAudios={};function io(H){s.onAbort&&s.onAbort(H),H="Aborted("+H+")",M(H),ae=!0,de=1,H+=". Build with -s ASSERTIONS=1 for more info.";var ne=new WebAssembly.RuntimeError(H);throw o(ne),ne}var yg="data:application/octet-stream;base64,";function mc(H){return H.startsWith(yg)}function oo(H){return H.startsWith("file://")}var _r;_r="tfjs-backend-wasm.wasm",mc(_r)||(_r=y(_r));function tp(H){try{if(H==_r&&J)return new Uint8Array(J);if(b)return b(H);throw"both async and sync fetching of the wasm failed"}catch(ne){io(ne)}}function Ag(){if(!J&&(c||f)){if(typeof fetch=="function"&&!oo(_r))return fetch(_r,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+_r+"'";return H.arrayBuffer()}).catch(function(){return tp(_r)});if(x)return new Promise(function(H,ne){x(_r,function(ye){H(new Uint8Array(ye))},ne)})}return Promise.resolve().then(function(){return tp(_r)})}function xg(){var H={env:Yl,wasi_snapshot_preview1:Yl};function ne(Ye,He){var Ht=Ye.exports;s.asm=Ht,Z=s.asm.memory,so(Z.buffer),gs=s.asm.__indirect_function_table,ea(s.asm.__wasm_call_ctors),fc("wasm-instantiate")}gg("wasm-instantiate");function ye(Ye){ne(Ye.instance)}function Re(Ye){return Ag().then(function(He){return WebAssembly.instantiate(He,H)}).then(function(He){return He}).then(Ye,function(He){M("failed to asynchronously prepare wasm: "+He),io(He)})}function lt(){return!J&&typeof WebAssembly.instantiateStreaming=="function"&&!mc(_r)&&!oo(_r)&&typeof fetch=="function"?fetch(_r,{credentials:"same-origin"}).then(function(Ye){var He=WebAssembly.instantiateStreaming(Ye,H);return He.then(ye,function(Ht){return M("wasm streaming compile failed: "+Ht),M("falling back to ArrayBuffer instantiation"),Re(ye)})}):Re(ye)}if(s.instantiateWasm)try{var ht=s.instantiateWasm(H,ne);return ht}catch(Ye){return M("Module.instantiateWasm callback failed with error: "+Ye),!1}return lt().catch(o),{}}var u3,d3;function rp(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?np(ye)():np(ye)(ne.arg):ye(ne.arg===void 0?null:ne.arg)}}function As(H){return H}function gc(H){var ne=/\b_Z[\w\d_]+/g;return H.replace(ne,function(ye){var Re=ye;return ye===Re?ye:Re+" ["+ye+"]"})}var ta=[];function np(H){var ne=ta[H];return ne||(H>=ta.length&&(ta.length=H+1),ta[H]=ne=gs.get(H)),ne}function p3(){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 Xl(H,ne){gs.set(H,ne),ta[H]=ne}function bg(){io("")}function yc(H,ne,ye){hr.copyWithin(H,ne,ne+ye)}function Ac(){return 2147483648}function zr(H){try{return Z.grow(H-Yr.byteLength+65535>>>16),so(Z.buffer),1}catch(ne){}}function xc(H){var ne=hr.length;H=H>>>0;var ye=Ac();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 ht=Math.min(ye,pr(Math.max(H,lt),65536)),Ye=zr(ht);if(Ye)return!0}return!1}var Zl={mappings:{},buffers:[null,[],[]],printChar:function(H,ne){var ye=Zl.buffers[H];ne===0||ne===10?((H===1?_:M)(Ze(ye,0)),ye.length=0):ye.push(ne)},varargs:void 0,get:function(){Zl.varargs+=4;var H=tr[Zl.varargs-4>>2];return H},getStr:function(H){var ne=ot(H);return ne},get64:function(H,ne){return H}};function vg(H){return 0}function h3(H,ne,ye,Re,lt){}function c3(H,ne,ye,Re){for(var lt=0,ht=0;ht>2],He=tr[ne+4>>2];ne+=8;for(var Ht=0;Ht>2]=lt,0}function wg(H){ee(H)}var bc=!1,Yl={abort:bg,emscripten_memcpy_big:yc,emscripten_resize_heap:xc,fd_close:vg,fd_seek:h3,fd_write:c3,setTempRet0:wg},j9=xg(),f3=s.___wasm_call_ctors=function(){return(f3=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},kg=s._init=function(){return(kg=s._init=s.asm.init).apply(null,arguments)},Ig=s._init_with_threads_count=function(){return(Ig=s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},vc=s._get_threads_count=function(){return(vc=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},wc=s._register_tensor=function(){return(wc=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},Sg=s._dispose_data=function(){return(Sg=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},Oe=s._dispose=function(){return(Oe=s._dispose=s.asm.dispose).apply(null,arguments)},Tg=s._Abs=function(){return(Tg=s._Abs=s.asm.Abs).apply(null,arguments)},kc=s._Add=function(){return(kc=s._Add=s.asm.Add).apply(null,arguments)},lo=s._AddN=function(){return(lo=s._AddN=s.asm.AddN).apply(null,arguments)},Jl=s._All=function(){return(Jl=s._All=s.asm.All).apply(null,arguments)},Ng=s._Any=function(){return(Ng=s._Any=s.asm.Any).apply(null,arguments)},m3=s._ArgMax=function(){return(m3=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},Cg=s._AvgPool=function(){return(Cg=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},g3=s._BatchMatMul=function(){return(g3=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},uo=s._Ceil=function(){return(uo=s._Ceil=s.asm.Ceil).apply(null,arguments)},Eg=s._ClipByValue=function(){return(Eg=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},Rg=s._Conv2D=function(){return(Rg=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},Mg=s._Conv2DBackpropInput=function(){return(Mg=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},Fg=s._Cos=function(){return(Fg=s._Cos=s.asm.Cos).apply(null,arguments)},$g=s._Cosh=function(){return($g=s._Cosh=s.asm.Cosh).apply(null,arguments)},Pg=s._CropAndResize=function(){return(Pg=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},Ic=s._Cumprod=function(){return(Ic=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},_g=s._Cumsum=function(){return(_g=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},zg=s._DepthToSpace=function(){return(zg=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},Og=s._DepthwiseConv2dNative=function(){return(Og=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},Dg=s._Elu=function(){return(Dg=s._Elu=s.asm.Elu).apply(null,arguments)},Lg=s._Equal=function(){return(Lg=s._Equal=s.asm.Equal).apply(null,arguments)},Sc=s._Exp=function(){return(Sc=s._Exp=s.asm.Exp).apply(null,arguments)},Bg=s._FlipLeftRight=function(){return(Bg=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},Wg=s._Floor=function(){return(Wg=s._Floor=s.asm.Floor).apply(null,arguments)},po=s._FloorDiv=function(){return(po=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},ap=s._FusedBatchNorm=function(){return(ap=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},Vg=s._FusedConv2D=function(){return(Vg=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},Ug=s._FusedDepthwiseConv2D=function(){return(Ug=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},Gg=s._Gather=function(){return(Gg=s._Gather=s.asm.Gather).apply(null,arguments)},Xe=s._GatherNd=function(){return(Xe=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},jg=s._Greater=function(){return(jg=s._Greater=s.asm.Greater).apply(null,arguments)},Hg=s._GreaterEqual=function(){return(Hg=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},qg=s._LeakyRelu=function(){return(qg=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},Kg=s._Less=function(){return(Kg=s._Less=s.asm.Less).apply(null,arguments)},Xg=s._LessEqual=function(){return(Xg=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},Zg=s._Log=function(){return(Zg=s._Log=s.asm.Log).apply(null,arguments)},sp=s._LogicalAnd=function(){return(sp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Tc=s._Max=function(){return(Tc=s._Max=s.asm.Max).apply(null,arguments)},Nc=s._MaxPool=function(){return(Nc=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},Yg=s._Maximum=function(){return(Yg=s._Maximum=s.asm.Maximum).apply(null,arguments)},Jg=s._Mean=function(){return(Jg=s._Mean=s.asm.Mean).apply(null,arguments)},Qg=s._Min=function(){return(Qg=s._Min=s.asm.Min).apply(null,arguments)},e1=s._Minimum=function(){return(e1=s._Minimum=s.asm.Minimum).apply(null,arguments)},t1=s._MirrorPad=function(){return(t1=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},r1=s._Multiply=function(){return(r1=s._Multiply=s.asm.Multiply).apply(null,arguments)},Ft=s._Neg=function(){return(Ft=s._Neg=s.asm.Neg).apply(null,arguments)},n1=s._NonMaxSuppressionV3=function(){return(n1=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},a1=s._NonMaxSuppressionV4=function(){return(a1=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},s1=s._NonMaxSuppressionV5=function(){return(s1=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},Ql=s._NotEqual=function(){return(Ql=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},Cc=s._OneHot=function(){return(Cc=s._OneHot=s.asm.OneHot).apply(null,arguments)},Ec=s._PadV2=function(){return(Ec=s._PadV2=s.asm.PadV2).apply(null,arguments)},Rc=s._Pow=function(){return(Rc=s._Pow=s.asm.Pow).apply(null,arguments)},i1=s._Prelu=function(){return(i1=s._Prelu=s.asm.Prelu).apply(null,arguments)},Mc=s._Prod=function(){return(Mc=s._Prod=s.asm.Prod).apply(null,arguments)},o1=s._RealDiv=function(){return(o1=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},y3=s._Relu=function(){return(y3=s._Relu=s.asm.Relu).apply(null,arguments)},Fc=s._Relu6=function(){return(Fc=s._Relu6=s.asm.Relu6).apply(null,arguments)},A3=s._ResizeBilinear=function(){return(A3=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},l1=s._Reverse=function(){return(l1=s._Reverse=s.asm.Reverse).apply(null,arguments)},u1=s._RotateWithOffset=function(){return(u1=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},d1=s._Round=function(){return(d1=s._Round=s.asm.Round).apply(null,arguments)},p1=s._Rsqrt=function(){return(p1=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},h1=s._ScatterNd=function(){return(h1=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},c1=s._SelectV2=function(){return(c1=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},f1=s._Sigmoid=function(){return(f1=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},m1=s._Sin=function(){return(m1=s._Sin=s.asm.Sin).apply(null,arguments)},g1=s._Softmax=function(){return(g1=s._Softmax=s.asm.Softmax).apply(null,arguments)},y1=s._SparseFillEmptyRows=function(){return(y1=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},A1=s._SparseReshape=function(){return(A1=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},x1=s._SparseSegmentReduction=function(){return(x1=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},b1=s._Sqrt=function(){return(b1=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},v1=s._Square=function(){return(v1=s._Square=s.asm.Square).apply(null,arguments)},w1=s._SquaredDifference=function(){return(w1=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},k1=s._Step=function(){return(k1=s._Step=s.asm.Step).apply(null,arguments)},I1=s._StridedSlice=function(){return(I1=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},S1=s._Sub=function(){return(S1=s._Sub=s.asm.Sub).apply(null,arguments)},T1=s._Sum=function(){return(T1=s._Sum=s.asm.Sum).apply(null,arguments)},N1=s._Tan=function(){return(N1=s._Tan=s.asm.Tan).apply(null,arguments)},C1=s._Tanh=function(){return(C1=s._Tanh=s.asm.Tanh).apply(null,arguments)},E1=s._Tile=function(){return(E1=s._Tile=s.asm.Tile).apply(null,arguments)},R1=s._TopK=function(){return(R1=s._TopK=s.asm.TopK).apply(null,arguments)},M1=s._Transform=function(){return(M1=s._Transform=s.asm.Transform).apply(null,arguments)},F1=s._Transpose=function(){return(F1=s._Transpose=s.asm.Transpose).apply(null,arguments)},$1=s.__FusedMatMul=function(){return($1=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},P1=s._malloc=function(){return(P1=s._malloc=s.asm.malloc).apply(null,arguments)},_1=s._free=function(){return(_1=s._free=s.asm.free).apply(null,arguments)},z1=s.___errno_location=function(){return(z1=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},O1=s._emscripten_main_thread_process_queued_calls=function(){return(O1=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},$c=s.stackSave=function(){return($c=s.stackSave=s.asm.stackSave).apply(null,arguments)},Pc=s.stackRestore=function(){return(Pc=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},ip=s.stackAlloc=function(){return(ip=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},D1=s.dynCall_iijjiiii=function(){return(D1=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},L1=s.dynCall_jiji=function(){return(L1=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=Me;var eu;function op(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}ys=function H(){eu||lp(),eu||(ys=H)};function lp(H){if(H=H||d,kn>0||(uc(),kn>0))return;function ne(){eu||(eu=!0,s.calledRun=!0,!ae&&(dc(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),pc()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),ne()},1)):ne()}s.run=lp;function x3(H){de=H,ep()||(s.onExit&&s.onExit(H),ae=!0),p(H,new op(H))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();lp();var tu;l&&(tu={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 ru;if(typeof a!="undefined")ru=a;else if(typeof WasmBackendModuleThreadedSimd!="undefined")ru=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(tu){var B1=ru._dispose;ru._dispose=function(){B1(),tu.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),tu.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)}}),hR=1e-7,cR=1e-4,qp=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}},$u=class{refCount(e){return Sn("refCount")}incRef(e){return Sn("incRef")}timerAvailable(){return!0}time(e){return Sn("time")}read(e){return Sn("read")}readSync(e){return Sn("readSync")}readToGPU(e,t){return Sn("readToGPU")}numDataIds(){return Sn("numDataIds")}disposeData(e,t){return Sn("disposeData")}write(e,t,r){return Sn("write")}move(e,t,r,n,a){return Sn("move")}memory(){return Sn("memory")}floatPrecision(){return Sn("floatPrecision")}epsilon(){return this.floatPrecision()===32?hR:cR}dispose(){return Sn("dispose")}};function Sn(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 xw(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,t--,cf(e,t,r)}function fR(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--,cf(e,r,n),cf(t,r,n)}function $p(e,t,r){return Math.max(e,Math.min(t,r))}function mR(e){return e%2===0?e:e+1}function cf(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function gR(e){let t=0;for(let r=0;rr+` Shapes ${e} and ${t} must match`)}function Wo(e){P(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Eo(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 IR(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 Gn(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=>xu(n)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(n=>n<0?r+n:n)}function bw(e,t){let r=[],n=[],a=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||a?null:Gn(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 vw(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 ww(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 kw(e,t){for(let r=0;rt+=r.length),t}function Ts(e){return typeof e=="string"||e instanceof String}function Tw(e){return typeof e=="boolean"}function Nw(e){return typeof e=="number"}function Hf(e){return Array.isArray(e)?Hf(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Nw(e)?"float32":Ts(e)?"string":Tw(e)?"bool":"float32"}function Ms(e){return!!(e&&e.constructor&&e.call&&e.apply)}function ff(e,t){for(let r=t;r=0;--n)r[n]=r[n+1]*e[n+1];return r}function Cw(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 Cw(0,e,t,r)}function d2(e,t){let r=qf(e,t);for(let n=0;nn*a,1);if(t==null||t==="float32")return fu(e,new Float32Array(r));if(t==="int32")return fu(e,new Int32Array(r));if(t==="bool")return fu(e,new Uint8Array(r));throw new Error(`Unknown data type ${t}`)}function p2(e){e.forEach(t=>{P(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function NR(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]=MR(r,n)})}};function ER(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(r,...n)=>(RR(t,n[0],n[1]),n.join("="))),t}function RR(e,t,r){e[decodeURIComponent(t)]=decodeURIComponent(r||"")}function MR(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 Y(){return Aa}var Aa=null;function FR(e){Aa=e}var K1;function Rw(){if(K1==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");K1=e}return K1}function $R(){let e=Rw();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function c2(e,t){let r=$R();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}var Vo="Abs",_u="Acos",zu="Acosh",Ja="Add",Ks="AddN",Ou="All",Du="Any",Xs="ArgMax",Lu="ArgMin",Bu="Asin",Wu="Asinh",Vu="Atan",Uu="Atanh",Gu="Atan2",Zs="AvgPool",Kf="AvgPoolGrad",Kp="AvgPool3D",Xf="AvgPool3DGrad",Ys="BatchMatMul",Uo="BatchToSpaceND",Zf="Bincount",Mw="BroadcastTo",Yf="BroadcastArgs",Js="Cast",Qs="Ceil",Qa="ClipByValue",Xp="Complex",Zp="ComplexAbs",Go="Concat",ei="Conv2D",Jf="Conv2DBackpropFilter",ti="Conv2DBackpropInput",Yp="Conv3D",Qf="Conv3DBackpropFilterV2",em="Conv3DBackpropInputV2",ri="Cos",ni="Cosh",jo="Cumprod",ai="Cumsum",Ho="CropAndResize",tm="DenseBincount",qo="DepthToSpace",si="DepthwiseConv2dNative",rm="DepthwiseConv2dNativeBackpropFilter",nm="DepthwiseConv2dNativeBackpropInput",am="Diag",Jp="Dilation2D",mf="Dilation2DBackpropInput",gf="Dilation2DBackpropFilter",ii="RealDiv",Qp="Einsum",oi="Elu",sm="EluGrad",ju="Erf",Ko="Equal",li="Exp",Xo="ExpandDims",Zo="Expm1",im="FFT",Hu="Fill",Yo="FlipLeftRight",ui="Floor",di="FloorDiv",pi="FusedBatchNorm",Jo="GatherV2",Qo="GatherNd",el="Greater",hi="GreaterEqual",ci="Identity",om="IFFT",eh="Imag",qu="IsFinite",Ku="IsInf",Xu="IsNan",fi="LeakyRelu",tl="Less",rl="LessEqual",lm="LinSpace",mi="Log",Zu="Log1p",nl="LogicalAnd",Yu="LogicalNot",th="LogicalOr",Fw="LogSoftmax",rh="LRN",um="LRNGrad",gi="Max",yi="Maximum",Ai="MaxPool",dm="MaxPoolGrad",nh="MaxPool3D",pm="MaxPool3DGrad",hm="MaxPoolWithArgmax",xi="Mean",bi="Min",vi="Minimum",wi="MirrorPad",Ju="Mod",cm="Multinomial",ki="Multiply",al="Neg",sl="NotEqual",il="NonMaxSuppressionV3",Qu="NonMaxSuppressionV4",ol="NonMaxSuppressionV5",ll="OnesLike",ul="OneHot",dl="Pack",Ii="PadV2",PR="Pool",Si="Pow",Ti="Prelu",Ni="Prod",ed="Range",ah="Real",td="Reciprocal",Ci="Relu",pl="Reshape",rd="ResizeNearestNeighbor",fm="ResizeNearestNeighborGrad",Ei="ResizeBilinear",mm="ResizeBilinearGrad",Ri="Relu6",hl="Reverse",cl="Round",Mi="Rsqrt",fl="ScatterNd",ml="Select",nd="Selu",gl="Slice",Fi="Sin",yl="Sinh",ad="Sign",$i="Sigmoid",sd="Softplus",Pi="Sqrt",_i="Sum",Al="SpaceToBatchND",xl="SplitV",zi="Softmax",sh="SparseFillEmptyRows",id="SparseReshape",ih="SparseSegmentMean",oh="SparseSegmentSum",lh="SparseToDense",Oi="SquaredDifference",od="Square",bl="StridedSlice",uh="StringNGrams",gm="StringSplit",ym="StringToHashBucketFast",Di="Sub",vl="Tan",Li="Tanh",es="Tile",wl="TopK",kl="Transform",Bi="Transpose",Am="Unique",Il="Unpack",dh="UnsortedSegmentSum",Sl="ZerosLike",Wi="Step",Pp="FromPixels",Tl="RotateWithOffset",Fs="_FusedMatMul",$s="FusedConv2D",Ps="FusedDepthwiseConv2D";function Ss(...e){Y().getBool("IS_TEST")||Y().getBool("PROD")||console.warn(...e)}function _R(...e){Y().getBool("IS_TEST")||Y().getBool("PROD")||console.log(...e)}var bu=c2("kernelRegistry",()=>new Map),_p=c2("gradRegistry",()=>new Map);function yf(e,t){let r=f2(e,t);return bu.get(r)}function uy(e){return _p.get(e)}function Ra(e){let t=bu.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 jn(e){let{kernelName:t,backendName:r}=e,n=f2(t,r);bu.has(n)&&Ss(`The kernel '${t}' for backend '${r}' is already registered`),bu.set(n,e)}function $w(e){let{kernelName:t}=e;_p.has(t)&&Y().getBool("DEBUG")&&Ss(`Overriding the gradient for '${t}'`),_p.set(t,e)}function zR(e,t){let r=f2(e,t);if(!bu.has(r))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);bu.delete(r)}function OR(e){if(!_p.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);_p.delete(e)}function DR(e,t){Ra(e).forEach(r=>{let n=Object.assign({},r,{backendName:t});jn(n)})}function f2(e,t){return`${t}_${e}`}var w={};Le(w,{arraysEqual:()=>qs,assert:()=>P,assertNonNegativeIntegerDimensions:()=>p2,assertNonNull:()=>Wo,assertShapesMatch:()=>Vr,bytesFromStringArray:()=>Sw,bytesPerElement:()=>ly,checkConversionForErrors:()=>kw,clamp:()=>$p,computeStrides:()=>Pu,createScalarValue:()=>GR,createShuffledIndices:()=>wR,decodeString:()=>Af,distSquared:()=>AR,encodeString:()=>hh,fetch:()=>HR,fingerPrint64:()=>UR,flatten:()=>Eo,getArrayFromDType:()=>ww,getTypedArrayFromDType:()=>vw,hasEncodingLoss:()=>SR,hexToLong:()=>ph,indexToLoc:()=>CR,inferDtype:()=>Hf,inferFromImplicitShape:()=>IR,isBoolean:()=>Tw,isFunction:()=>Ms,isInt:()=>xu,isNumber:()=>Nw,isPromise:()=>h2,isScalarShape:()=>xR,isString:()=>Ts,isTypedArray:()=>Sr,isValidDtype:()=>Iw,locToIndex:()=>NR,makeOnesTypedArray:()=>d2,makeZerosNestedTypedArray:()=>TR,makeZerosTypedArray:()=>qf,nearestDivisor:()=>ff,nearestLargerEven:()=>mR,now:()=>zp,parseAxisParam:()=>Gn,randUniform:()=>yR,repeatedTry:()=>kR,rightPad:()=>Cp,shuffle:()=>xw,shuffleCombo:()=>fR,sizeFromShape:()=>Tt,sizeToSquarishShape:()=>vR,squeezeShape:()=>bw,sum:()=>gR,swap:()=>cf,tanh:()=>bR,toNestedArray:()=>fu,toTypedArray:()=>xm});var F3=Bo(ZE()),Ao=F3.default||F3;function ph(e){return Ao.fromString(e,!0,16)}var Pw=ph("c3a5c85c97cb3127"),mo=ph("b492b66fbe98f273"),Or=ph("9ae16a3b2f90404f");function dy(e){return e.xor(e.shru(47))}function _w(e,t,r){let n=e.slice(t,t+r);return Ao.fromBytes(Array.from(n),!0,!0)}function wt(e,t){return _w(e,t,8)}function $3(e,t){return _w(e,t,4)}function cr(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Cs(e,t,r=ph("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 LR(e,t,r,n,a,s){a=a.add(e),s=cr(s.add(a).add(n),21);let i=a;return a=a.add(t),a=a.add(r),s=s.add(cr(a,44)),[a.add(n),s.add(i)]}function Uc(e,t,r,n){return LR(wt(e,t),wt(e,t+8),wt(e,t+16),wt(e,t+24),r,n)}function BR(e,t=e.length){if(t>=8){let r=Or.add(t*2),n=wt(e,0).add(Or),a=wt(e,t-8),s=cr(a,37).mul(r).add(n),i=cr(n,25).add(a).mul(r);return Cs(s,i,r)}if(t>=4){let r=Or.add(t*2),n=$3(e,0);return Cs(n.shl(3).add(t),$3(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 dy(Or.mul(s).xor(Pw.mul(i))).mul(Or)}return Or}function WR(e,t=e.length){let r=Or.add(t*2),n=wt(e,0).mul(mo),a=wt(e,8),s=wt(e,t-8).mul(r),i=wt(e,t-16).mul(Or);return Cs(cr(n.add(a),43).add(cr(s,30)).add(i),n.add(cr(a.add(Or),18)).add(s),r)}function VR(e,t=e.length){let r=Or.add(t*2),n=wt(e,0).mul(Or),a=wt(e,8),s=wt(e,t-8).mul(r),i=wt(e,t-16).mul(Or),o=cr(n.add(a),43).add(cr(s,30)).add(i),l=Cs(o,n.add(cr(a.add(Or),18)).add(s),r),u=wt(e,16).mul(r),d=wt(e,24),h=o.add(wt(e,t-32)).mul(r),p=l.add(wt(e,t-24)).mul(r);return Cs(cr(u.add(d),43).add(cr(h,30)).add(p),u.add(cr(d.add(n),18)).add(h),r)}function UR(e,t=e.length){let r=Ao.fromNumber(81,!0);if(t<=32)return t<=16?BR(e,t):WR(e,t);if(t<=64)return VR(e,t);let n=r,a=r.mul(mo).add(113),s=dy(a.mul(Or).add(113)).mul(Or),i=[Ao.UZERO,Ao.UZERO],o=[Ao.UZERO,Ao.UZERO];n=n.mul(Or).add(wt(e,0));let l=0,u=(t-1>>6)*64,d=u+(t-1&63)-63;do n=cr(n.add(a).add(i[0]).add(wt(e,l+8)),37).mul(mo),a=cr(a.add(i[1]).add(wt(e,l+48)),42).mul(mo),n=n.xor(o[1]),a=a.add(i[0]).add(wt(e,l+40)),s=cr(s.add(o[0]),33).mul(mo),i=Uc(e,l,i[1].mul(mo),n.add(o[0])),o=Uc(e,l+32,s.add(o[1]),a.add(wt(e,l+16))),[s,n]=[n,s],l+=64;while(l!==u);let h=mo.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=cr(n.add(a).add(i[0]).add(wt(e,l+8)),37).mul(h),a=cr(a.add(i[1]).add(wt(e,l+48)),42).mul(h),n=n.xor(o[1].mul(9)),a=a.add(i[0].mul(9).add(wt(e,l+40))),s=cr(s.add(o[0]),33).mul(h),i=Uc(e,l,i[1].mul(h),n.add(o[0])),o=Uc(e,l+32,s.add(o[1]),a.add(wt(e,l+16))),[s,n]=[n,s],Cs(Cs(i[0],o[0],h).add(dy(a).mul(Pw)).add(s),Cs(i[1],o[1],h).add(n),h)}function GR(e,t){return t==="string"?hh(e):xm([e],t)}function jR(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function xm(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Eo(e)),Y().getBool("DEBUG")&&kw(e,t),jR(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=zp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(a);else{a();for(let o of n)o.dataSync();s=Promise.resolve({kernelMs:zp()-i})}if(Y().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{KR(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 KR(e,t,r){if(t!=="float32")return!1;for(let n=0;n0?f:""} `}}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 ZR(e,t,r){let n={},a={};for(let l=0;ln[m.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(!qs(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 P3=20,fp=3,X1=7;function JR(e,t,r,n){let a=Pu(t),s=QR(e,t,r,a),i=t.length,o=ef(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 QR(e,t,r,n){let a=Tt(t),s=n[n.length-1],i=new Array(s).fill(0),o=t.length,l=r==="complex64"?xp(e):e;if(o>1)for(let u=0;uP3){let g=fp*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-fp)*i,o*i));return r==="complex64"&&(y=xp(y),A=xp(A)),["["+y.map((x,b)=>Ap(x,a[b],r)).join(", ")+", ..., "+A.map((x,b)=>Ap(x,a[o-fp+b],r)).join(", ")+"]"]}let m=r==="complex64"?xp(e):Array.from(e);return["["+m.map((g,y)=>Ap(g,a[y],r)).join(", ")+"]"]}let u=t.slice(1),d=n.slice(1),h=n[0]*i,p=[];if(o>P3){for(let m=0;m`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||ww(t,this.size),this.strides=Pu(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;nAf(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(),ia().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=ia().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Af(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 ia().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(ia().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return pu.print(this,e)}clone(){return this.throwIfDisposed(),pu.clone(this)}toString(e=!1){let t=this.dataSync();return JR(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),pu.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),ia().makeVariable(this,e,t,r)}};Object.defineProperty(nt,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function aM(){return c2("Tensor",()=>nt)}aM();var Op=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(!qs(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);ia().disposeTensor(this),this.dataId=e.dataId,ia().incRef(this,null)}dispose(){ia().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(Op,Symbol.hasInstance,{value:e=>e instanceof nt&&e.assign!=null&&e.assign instanceof Function});var da={};Le(da,{assertTypesMatch:()=>Vw,getTensorsInContainer:()=>m2,isTensorInList:()=>iM,makeTypesMatch:()=>Dt});var Ow=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(Ow||{}),Dw=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(Dw||{}),Lw=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(Lw||{}),Bw=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(Bw||{}),Ww=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(Ww||{}),sM={float32:Bw,int32:Dw,bool:Lw,complex64:Ww};function Cr(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return sM[e][t]}function ch(e){return Cr(e,"int32")}function Dt(e,t){if(e.dtype===t.dtype)return[e,t];let r=Cr(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function Vw(e,t){P(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function iM(e,t){return t.some(r=>r.id===e.id)}function m2(e){let t=[];return Uw(e,t,new Set),t}function Uw(e,t,r){if(e==null)return;if(e instanceof nt){t.push(e);return}if(!oM(e))return;let n=e;for(let a in n){let s=n[a];r.has(s)||(r.add(s),Uw(s,t,r))}}function oM(e){return Array.isArray(e)||typeof e=="object"}function Z1(e){return e.kernelName!=null}var _3=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()}},py=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new _3}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){Ra(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 $u)&&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 py.nextTensorId++}nextVariableId(){return py.nextVariableId++}clone(e){let t=B.runKernel(ci,{x:e}),r={x:e},n=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return B.runKernel(Js,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,yf(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=Z1(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Z1(e)){let{kernelName:c,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=yf(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:f,attrs:m,backend:this.backend});let A=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,y,A);let x=A.map(b=>{if(b.rank!=null)return b;let{dataId:v,shape:S,dtype:T}=b;return this.makeTensorFromDataId(v,S,T)});if(n){let b=this.getTensorsForGradient(c,f,x);r=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:c}=e,f=m=>{!n||(r=m.map(g=>this.keep(this.clone(g))))};i=()=>{let m=this.backend.numDataIds();o=this.tidy(()=>c(this.backend,f));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,m,g),g}}let{inputs:u,attrs:d}=e,h=Z1(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=uy(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"&&Ts(e[0])&&(a=e.map(o=>hh(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=Sw(a);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,r,n){r=r||"float32";let a=new nt(t,r,e,this.nextTensorId());return this.trackTensor(a,n),a}makeVariable(e,t=!0,r,n){r=r||this.nextVariableId().toString(),n!=null&&n!==e.dtype&&(e=e.cast(n));let a=new Op(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*ly(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 Op||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*ly(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=uy(e);o!=null&&(n=o.gradFunc),n!=null&&(i.gradient=l=>(l=l.map((u,d)=>{if(u==null){let h=r[d],p=qf(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=m2(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=ZR(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?lM(a.shape):r,YR(i,s,l=>this.tidy(l),uM);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(Ms(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(Ms(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=zp(),r=await this.backend.time(e);return r.wallMs=zp()-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 _3;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}},g2=py;g2.nextTensorId=0;g2.nextVariableId=0;function lM(e){let t=d2(Tt(e),"float32");return B.makeTensor(t,e,"float32")}function Gw(){let e=Rw();if(e._tfengine==null){let t=new Ew(e);e._tfengine=new g2(t)}return FR(e._tfengine.ENV),tM(()=>e._tfengine),e._tfengine}var B=Gw();function uM(e,t){let r={a:e,b:t};return B.runKernel(Ja,r)}var fh={};Le(fh,{isBrowser:()=>jw,isMobile:()=>hM,mockIsMobile:()=>pM});function dM(){return typeof navigator!="undefined"&&navigator!=null}var hy;function pM(e){hy=e}function hM(e){if(hy!==void 0)return hy;if(e||dM()){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 jw(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Un=Y();Un.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.")});Un.registerFlag("IS_BROWSER",()=>jw());Un.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Un.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Un.registerFlag("PROD",()=>!1);Un.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Un.getBool("DEBUG"));Un.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Un.registerFlag("IS_TEST",()=>!1);Un.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Un.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Un.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function Ma(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)&&Y().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Hw(e,n,[]),n}function Hw(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),z3(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=Ma(e,a);!Sr(e)&&!Array.isArray(e)&&(e=[e]);let i=a!=="string"?xm(e,a):Eo(e,[],!0);return B.makeTensor(i,s,a)}function Dp(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)=>F(a,`${t}[${s}]`,r,n))}var qw="__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+qw;let a=(...s)=>{B.startScope(r);try{let i=n(...s);return h2(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 cM(e,t){let r=F(e,"real","complex"),n=F(t,"imag","complex");Vr(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(Xp,a)}var _s=W({complex_:cM});function Vi(e,t,r,n){if(n==null&&(n=Hf(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){p2(t);let a=Tt(t),s=Tt(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"?xm(e,n):Eo(e,[],!0),B.makeTensor(e,t,n)}function ct(e,t,r){let n=Ma(e,r);return Vi(e,t,n,r)}var cy={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},xf=4;async function fM(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)+xf*p.length,f=new Uint8Array(c),m=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 y2=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function O3(e){return y2?Buffer.byteLength(e):new Blob([e]).size}function gM(e){if(y2)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 D3(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 Xw(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 x2(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 mh(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:O3(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:O3(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function AM(){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 xM(){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 bM(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function vM(){let e=AM(),t=xM(),r=bM();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 Bt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Bt.instance==null&&(Bt.instance=new Bt),Bt.instance}static registerSaveRouter(e){Bt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Bt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Bt.getHandlers(e,"save")}static getLoadHandlers(e,t){return Bt.getHandlers(e,"load",t)}static getHandlers(e,t,r){let n=[];return(t==="load"?Bt.getInstance().loadRouters:Bt.getInstance().saveRouters).forEach(a=>{let s=a(e,r);s!==null&&n.push(s)}),n}},wM=e=>Bt.registerSaveRouter(e),kM=e=>Bt.registerLoadRouter(e),IM=e=>Bt.getSaveHandlers(e),SM=(e,t)=>Bt.getLoadHandlers(e,t),fy="tensorflowjs",my=1,wo="models_store",Ns="model_info_store";function Zw(){if(!Y().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 gy(e){let t=e.result;t.createObjectStore(wo,{keyPath:"modelPath"}),t.createObjectStore(Ns,{keyPath:"modelPath"})}var Ro=class{constructor(e){if(this.indexedDB=Zw(),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(fy,my);a.onupgradeneeded=()=>gy(a),a.onsuccess=()=>{let s=a.result;if(t==null){let i=s.transaction(wo,"readonly"),o=i.objectStore(wo).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=mh(t),o=s.transaction(Ns,"readwrite"),l=o.objectStore(Ns),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),d;u.onsuccess=()=>{d=s.transaction(wo,"readwrite");let h=d.objectStore(wo).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});h.onsuccess=()=>r({modelArtifactsInfo:i}),h.onerror=p=>{l=o.objectStore(Ns);let c=l.delete(this.modelPath);c.onsuccess=()=>(s.close(),n(h.error)),c.onerror=f=>(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)})}};Ro.URL_SCHEME="indexeddb://";var Yw=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ro.URL_SCHEME)?TM(e.slice(Ro.URL_SCHEME.length)):null;Bt.registerSaveRouter(Yw);Bt.registerLoadRouter(Yw);function TM(e){return new Ro(e)}function NM(e){return e.startsWith(Ro.URL_SCHEME)?e.slice(Ro.URL_SCHEME.length):e}var CM=class{constructor(){this.indexedDB=Zw()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(fy,my);r.onupgradeneeded=()=>gy(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(Ns,"readonly"),s=a.objectStore(Ns).getAll();s.onsuccess=()=>{let i={};for(let o of s.result)i[o.modelPath]=o.modelArtifactsInfo;e(i)},s.onerror=i=>(n.close(),t(s.error)),a.oncomplete=()=>n.close()},r.onerror=n=>t(r.error)})}async removeModel(e){return e=NM(e),new Promise((t,r)=>{let n=this.indexedDB.open(fy,my);n.onupgradeneeded=()=>gy(n),n.onsuccess=()=>{let a=n.result,s=a.transaction(Ns,"readwrite"),i=s.objectStore(Ns),o=i.get(e),l;o.onsuccess=()=>{if(o.result==null)return a.close(),r(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=i.delete(e),d=()=>{l=a.transaction(wo,"readwrite");let h=l.objectStore(wo).delete(e);h.onsuccess=()=>t(o.result.modelArtifactsInfo),h.onerror=p=>r(o.error)};u.onsuccess=d,u.onerror=h=>(d(),a.close(),r(o.error))}},o.onerror=u=>(a.close(),r(o.error)),s.oncomplete=()=>{l==null?a.close():l.oncomplete=()=>a.close()}},n.onerror=a=>r(n.error)})}},qa="/",hu="tensorflowjs_models",Jw="info",EM="model_topology",RM="weight_specs",MM="weight_data",FM="model_metadata";function Qw(e){return{info:[hu,e,Jw].join(qa),topology:[hu,e,EM].join(qa),weightSpecs:[hu,e,RM].join(qa),weightData:[hu,e,MM].join(qa),modelMetadata:[hu,e,FM].join(qa)}}function ek(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function $M(e){let t=e.split(qa);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(qa)}function PM(e){return e.startsWith(Mo.URL_SCHEME)?e.slice(Mo.URL_SCHEME.length):e}var Mo=class{constructor(e){if(!Y().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=Qw(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=mh(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,gM(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 ek(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=yM(s),t}};Mo.URL_SCHEME="localstorage://";var tk=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Mo.URL_SCHEME)?_M(e.slice(Mo.URL_SCHEME.length)):null;Bt.registerSaveRouter(tk);Bt.registerLoadRouter(tk);function _M(e){return new Mo(e)}var zM=class{constructor(){P(Y().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=hu+qa,r=qa+Jw;for(let n=0;n"scheme must not be undefined or null."),e.endsWith(mu)&&(e=e.slice(0,e.indexOf(mu))),P(e.length>0,()=>"scheme must not be an empty string.");let r=Tn.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 tf(e){if(e.indexOf(mu)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Tn.getSchemes().join(",")}`);return{scheme:e.split(mu)[0],path:e.split(mu)[1]}}async function rk(e,t,r=!1){P(e!==t,()=>`Old path and new path are the same: '${e}'`);let n=Bt.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=Bt.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=tf(e).scheme,l=tf(e).path,u=o===tf(e).scheme,d=await a.load();r&&u&&await Tn.getManager(o).removeModel(l);let h=await i.save(d);return r&&!u&&await Tn.getManager(o).removeModel(l),h.modelArtifactsInfo}async function OM(){let e=Tn.getSchemes(),t={};for(let r of e){let n=await Tn.getManager(r).listModels();for(let a in n){let s=r+mu+a;t[s]=n[a]}}return t}async function DM(e){let t=tf(e);return Tn.getManager(t.scheme).removeModel(t.path)}async function LM(e,t){return rk(e,t,!1)}async function BM(e,t){return rk(e,t,!0)}var WM=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(Y().get("IS_BROWSER")){Y().setPlatform("browser",new WM);try{Tn.registerManager(Mo.URL_SCHEME,new zM)}catch(e){}try{Tn.registerManager(Ro.URL_SCHEME,new CM)}catch(e){}}var VM={importFetch:()=>YE()},Y1,UM=class{constructor(){this.util=JE(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Y().global.fetch!=null?Y().global.fetch(e,t):(Y1==null&&(Y1=VM.importFetch()),Y1(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)}};Y().get("IS_NODE")&&!Y().get("IS_BROWSER")&&Y().setPlatform("node",new UM);function We(e,t="float32",r){return t=t||"float32",p2(e),new sr(e,t,r)}function GM(e,t){let r=F(e,"x","cast");if(!Iw(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(Js,n,a)}var me=W({cast_:GM});function jM(e){let t={x:F(e,"x","clone","string_or_numeric")};return B.runKernel(ci,t)}var Br=W({clone_:jM});function nk(e,t=!1){console.log(e.toString(t))}Gw();var HM={buffer:We,cast:me,clone:Br,print:nk};rM(HM);var Tr={};Le(Tr,{browserFiles:()=>QM,browserHTTPRequest:()=>aF,concatenateArrayBuffers:()=>A2,copyModel:()=>LM,decodeWeights:()=>Kw,encodeWeights:()=>fM,fromMemory:()=>iF,getLoadHandlers:()=>SM,getModelArtifactsForJSON:()=>x2,getModelArtifactsInfoForJSON:()=>mh,getSaveHandlers:()=>IM,http:()=>v2,isHTTPScheme:()=>Ay,listModels:()=>OM,loadWeights:()=>eF,moveModel:()=>BM,registerLoadRouter:()=>kM,registerSaveRouter:()=>wM,removeModel:()=>DM,weightsLoaderFactory:()=>sk,withSaveHandler:()=>oF});var qM="model",KM=".json",XM=".weights.bin";function L3(e){return new Promise(t=>setTimeout(t)).then(e)}var yy=class{constructor(e){if(!Y().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(yy.URL_SCHEME)&&(e=e.slice(yy.URL_SCHEME.length)),(e==null||e.length===0)&&(e=qM),this.modelJsonFileName=e+KM,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=Xw(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 L3(()=>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 L3(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:mh(e)}}}},bf=yy;bf.URL_SCHEME="downloads://";var ZM=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=x2(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,A2(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=>D3(a.name)),n={};for(let a of e)a.paths.forEach(s=>{let i=D3(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}},YM=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(bf.URL_SCHEME)?JM(e.slice(bf.URL_SCHEME.length)):null;Bt.registerSaveRouter(YM);function JM(e="model"){return new bf(e)}function QM(e){return new ZM(e)}function B3(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 ak(e,t){t==null&&(t={});let r=t.fetchFunc==null?Y().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 B3(n,t.onProgress,a,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await B3(i,t.onProgress,o,l)}async function eF(e,t="",r,n){return sk(a=>ak(a,{requestInit:n}))(e,t,r)}function sk(e){return async(t,r="",n)=>{let a=t.map(()=>!1),s={},i=n!=null?n.map(()=>!1):[],o=[];if(t.forEach((c,f)=>{let m=0;c.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,A=cy[y]*Tt(g.shape),x=()=>{a[f]=!0,s[f]==null&&(s[f]=[]),s[f].push({manifestEntry:g,groupOffset:m,sizeBytes:A})};n!=null?n.forEach((b,v)=>{b===g.name&&(x(),i[v]=!0)}):x(),o.push(g.name),m+=A})}),!i.every(c=>c)){let c=n.filter((f,m)=>!i[m]);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,f,m)=>(f&&c.push(m),c),[]),u=[];l.forEach(c=>{t[c].paths.forEach(f=>{let m=r+(r.endsWith("/")?"":"/")+f;u.push(m)})});let d=await e(u),h={},p=0;return l.forEach(c=>{let f=t[c].paths.length,m=0;for(let x=0;x{let b=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),v=Kw(b,[x.manifestEntry]);for(let S in v)h[S]=v[S]}),p+=f}),h}}var tF="application/octet-stream",rF="application/json",b2=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=Y().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=Xw(e,r);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:rF}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:tF}),"model.weights.bin");let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:mh(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 x2(t,a=>this.loadWeights(a))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[r,n]=nF(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 ak(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,A2(l)]}};b2.URL_SCHEME_REGEX=/^https?:\/\//;function nF(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?"),n=e.substring(0,t),a=r>t?e.substring(r):"";return[n+"/",a]}function Ay(e){return e.match(b2.URL_SCHEME_REGEX)!=null}var ik=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let r=!0;if(Array.isArray(e)?r=e.every(n=>Ay(n)):r=Ay(e),r)return v2(e,t)}return null};Bt.registerSaveRouter(ik);Bt.registerLoadRouter(ik);function v2(e,t){return new b2(e,t)}function aF(e,t){return v2(e,t)}var J1=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},sF=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function iF(e,t,r,n){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new J1(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 J1({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 J1({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n}))}function oF(e){return new sF(e)}var ok={};Le(ok,{confusionMatrix:()=>hF});function lF(e,t,r=!1,n=!1){let a=F(e,"a","matMul"),s=F(t,"b","matMul");[a,s]=Dt(a,s);let i={a,b:s},o={transposeA:r,transposeB:n};return B.runKernel(Ys,i,o)}var Je=W({matMul_:lF});function uF(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:F(e,"indices","oneHot","int32")},s={depth:t,onValue:r,offValue:n};return B.runKernel(ul,a,s)}var Lp=W({oneHot_:uF});function dF(e,t){let r=F(e,"x","transpose");if(t==null&&(t=r.shape.map((s,i)=>i).reverse()),P(r.rank===t.length,()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`),t.forEach(s=>{P(s>=0&&s`All entries in 'perm' must be between 0 and ${r.rank-1} but got ${t}`)}),r.rank<=1)return r.clone();let n={x:r},a={perm:t};return B.runKernel(Bi,n,a)}var tt=W({transpose_:dF});function pF(e,t,r){let n=F(e,"labels","confusionMatrix"),a=F(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=Lp(me(n,"int32"),r),i=Lp(me(a,"int32"),r),o=tt(s),l=Je(o,i);return me(l,"int32")}var hF=W({confusionMatrix_:pF}),Nl={};Le(Nl,{assertAndGetBroadcastShape:()=>bt,getBroadcastDims:()=>lk,getReductionAxes:()=>Zt});function lk(e,t){let r=e.length,n=[];for(let a=0;a1&&i===1&&n.unshift(s)}return n}function Zt(e,t){let r=[];for(let n=0;n1)&&r.unshift(s)}return r}function bt(e,t){let r=[],n=Math.max(e.length,t.length);for(let a=0;axF,fromPixelsAsync:()=>yF,toPixels:()=>AF});function uk(e,t,r){if(Wo(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=Ma(e,r);if(n.length!==3&&n.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(n.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Vi(e,t,n,r)}var co;function dk(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