/* Human homepage: author: ' */ var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all2) => { for (var name in all2) __defProp(target, name, { get: all2[name], enumerable: true }); }; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; var __accessCheck = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet = (obj, member, getter) => { __accessCheck(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet = (obj, member, value, setter) => { __accessCheck(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; // src/util/util.ts function log(...msg) { const dt2 = new Date(); const ts2 = `${dt2.getHours().toString().padStart(2, "0")}:${dt2.getMinutes().toString().padStart(2, "0")}:${dt2.getSeconds().toString().padStart(2, "0")}.${dt2.getMilliseconds().toString().padStart(3, "0")}`; if (msg) console.log(ts2, "Human:", ...msg); } function join(folder, file) { const separator = folder.endsWith("/") ? "" : "/"; const skipJoin = file.startsWith(".") || file.startsWith("/") || file.startsWith("http:") || file.startsWith("https:") || file.startsWith("file:"); const path = skipJoin ? `${file}` : `${folder}${separator}${file}`; if (!path.toLocaleLowerCase().includes(".json")) throw new Error(`modelpath error: expecting json file: ${path}`); return path; } var now = () => { if (typeof performance !== "undefined") return performance.now(); return parseInt((Number(process.hrtime.bigint()) / 1e3 / 1e3).toString()); }; function validate(defaults, config3, parent = "config", msgs = []) { for (const key of Object.keys(config3)) { if (typeof config3[key] === "object") { validate(defaults[key], config3[key], key, msgs); } else { const defined = defaults && typeof defaults[key] !== "undefined"; if (!defined) msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` }); const same = defaults && typeof defaults[key] === typeof config3[key]; if (defined && !same) msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] }); } } if (config3.debug && parent === "config" && msgs.length > 0) log("invalid configuration", msgs); return msgs; } function mergeDeep(...objects) { const isObject = (obj) => obj && typeof obj === "object"; return objects.reduce((prev, obj) => { Object.keys(obj || {}).forEach((key) => { const pVal = prev[key]; const oVal = obj[key]; if (Array.isArray(pVal) && Array.isArray(oVal)) prev[key] = pVal.concat(...oVal); else if (isObject(pVal) && isObject(oVal)) prev[key] = mergeDeep(pVal, oVal); else prev[key] = oVal; }); return prev; }, {}); } // src/config.ts var config = { backend: "", modelBasePath: "", cacheModels: true, wasmPath: "", wasmPlatformFetch: false, debug: true, async: true, warmup: "full", cacheSensitivity: 0.7, skipAllowed: false, deallocate: false, filter: { enabled: true, equalization: false, width: 0, height: 0, flip: false, return: true, brightness: 0, contrast: 0, sharpness: 0, blur: 0, saturation: 0, hue: 0, negative: false, sepia: false, vintage: false, kodachrome: false, technicolor: false, polaroid: false, pixelate: 0 }, gesture: { enabled: true }, face: { enabled: true, detector: { modelPath: "blazeface.json", rotation: true, maxDetected: 1, skipFrames: 99, skipTime: 2500, minConfidence: 0.2, iouThreshold: 0.1, mask: false, return: false }, mesh: { enabled: true, modelPath: "facemesh.json" }, attention: { enabled: false, modelPath: "facemesh-attention.json" }, iris: { enabled: true, modelPath: "iris.json" }, emotion: { enabled: true, minConfidence: 0.1, skipFrames: 99, skipTime: 1500, modelPath: "emotion.json" }, description: { enabled: true, modelPath: "faceres.json", skipFrames: 99, skipTime: 3e3, minConfidence: 0.1 }, antispoof: { enabled: false, skipFrames: 99, skipTime: 4e3, modelPath: "antispoof.json" }, liveness: { enabled: false, skipFrames: 99, skipTime: 4e3, modelPath: "liveness.json" } }, body: { enabled: true, modelPath: "movenet-lightning.json", maxDetected: -1, minConfidence: 0.3, skipFrames: 1, skipTime: 200 }, hand: { enabled: true, rotation: true, skipFrames: 99, skipTime: 1e3, minConfidence: 0.5, iouThreshold: 0.2, maxDetected: -1, landmarks: true, detector: { modelPath: "handtrack.json" }, skeleton: { modelPath: "handlandmark-full.json" } }, object: { enabled: false, modelPath: "mb3-centernet.json", minConfidence: 0.2, iouThreshold: 0.4, maxDetected: 10, skipFrames: 99, skipTime: 2e3 }, segmentation: { enabled: false, modelPath: "selfie.json", blur: 8 } }; // dist/tfjs.esm.js var tfjs_esm_exports = {}; __export(tfjs_esm_exports, { Abs: () => uo, Acos: () => rl, Acosh: () => al, AdadeltaOptimizer: () => gb, AdagradOptimizer: () => bb, AdamOptimizer: () => yb, AdamaxOptimizer: () => vb, Add: () => Sr, AddN: () => Ia, All: () => il, Any: () => ol, ArgMax: () => Sa, ArgMin: () => ul, Asin: () => ll, Asinh: () => cl, Atan: () => dl, Atan2: () => hl, Atanh: () => pl, AvgPool: () => Ca, AvgPool3D: () => Kd, AvgPool3DGrad: () => lg, AvgPoolGrad: () => ug, BackendWasm: () => Pde, BatchMatMul: () => Na, BatchToSpaceND: () => lo, Bincount: () => cg, BroadcastArgs: () => dg, BroadcastTo: () => O$, Callback: () => FW, CallbackList: () => YL, Cast: () => Ta, Ceil: () => $a, ClipByValue: () => Cr, Complex: () => Xd, ComplexAbs: () => Yd, Concat: () => co, Conv2D: () => _a, Conv2DBackpropFilter: () => pg, Conv2DBackpropInput: () => Aa, Conv3D: () => Qd, Conv3DBackpropFilterV2: () => hg, Conv3DBackpropInputV2: () => fg, Cos: () => Ea, Cosh: () => Ra, CropAndResize: () => ho, Cumprod: () => po, Cumsum: () => Da, CustomCallback: () => JL, DataStorage: () => Hd, DenseBincount: () => mg, DepthToSpace: () => fo, DepthwiseConv2dNative: () => Fa, DepthwiseConv2dNativeBackpropFilter: () => gg, DepthwiseConv2dNativeBackpropInput: () => bg, Diag: () => yg, Dilation2D: () => Zd, Dilation2DBackpropFilter: () => Zf, Dilation2DBackpropInput: () => Qf, ENV: () => rk, EarlyStopping: () => OW, Einsum: () => Jd, Elu: () => Pa, EluGrad: () => vg, Environment: () => _$, Equal: () => mo, Erf: () => fl, Exp: () => za, ExpandDims: () => go, Expm1: () => bo, FFT: () => xg, Fill: () => ml, FlipLeftRight: () => yo, Floor: () => Ma, FloorDiv: () => La, FromPixels: () => fd, FusedBatchNorm: () => Ba, FusedConv2D: () => ia, FusedDepthwiseConv2D: () => oa, GPGPUContext: () => Xf, GatherNd: () => xo, GatherV2: () => vo, GraphModel: () => B4, Greater: () => wo, GreaterEqual: () => Va, History: () => ZL, IFFT: () => wg, Identity: () => Wa, Imag: () => ep, InputSpec: () => Dt, IsFinite: () => gl, IsInf: () => bl, IsNan: () => yl, KernelBackend: () => sl, LRN: () => np, LRNGrad: () => Ig, LayerVariable: () => dz, LayersModel: () => hr, LeakyRelu: () => Ua, Less: () => ko, LessEqual: () => Io, LinSpace: () => kg, Log: () => Ga, Log1p: () => vl, LogSoftmax: () => P$, LogicalAnd: () => So, LogicalNot: () => xl, LogicalOr: () => tp, MathBackendCPU: () => HS, MathBackendWebGL: () => G1, Max: () => Ha, MaxPool: () => ja, MaxPool3D: () => sp, MaxPool3DGrad: () => Cg, MaxPoolGrad: () => Sg, MaxPoolWithArgmax: () => Ng, Maximum: () => qa, Mean: () => Ka, Min: () => Xa, Minimum: () => Ya, MirrorPad: () => Qa, Mod: () => wl, MomentumOptimizer: () => xb, Multinomial: () => Tg, Multiply: () => Za, Neg: () => Co, NonMaxSuppressionV3: () => To, NonMaxSuppressionV4: () => kl, NonMaxSuppressionV5: () => $o, NotEqual: () => No, OP_SCOPE_SUFFIX: () => f_, OneHot: () => Ao, OnesLike: () => _o, Optimizer: () => Ar, OptimizerConstructors: () => Ur, Pack: () => Eo, PadV2: () => Ja, Pool: () => Wde, Pow: () => ei, Prelu: () => ti, Prod: () => ni, RMSPropOptimizer: () => wb, RNN: () => Er, Range: () => Il, Rank: () => a_, Real: () => rp, RealDiv: () => Oa, Reciprocal: () => Sl, Reduction: () => dO, Relu: () => si, Relu6: () => ai, Reshape: () => Ro, ResizeBilinear: () => ri, ResizeBilinearGrad: () => _g, ResizeNearestNeighbor: () => Cl, ResizeNearestNeighborGrad: () => $g, Reverse: () => Do, RotateWithOffset: () => jo, Round: () => Fo, Rsqrt: () => ii, SGDOptimizer: () => Cp, ScatterNd: () => Oo, Select: () => Po, Selu: () => Nl, Sequential: () => Hb, Sigmoid: () => ui, Sign: () => Tl, Sin: () => oi, Sinh: () => Mo, Slice: () => zo, Softmax: () => di, Softplus: () => $l, SpaceToBatchND: () => Lo, SparseFillEmptyRows: () => ap, SparseReshape: () => _l, SparseSegmentMean: () => ip, SparseSegmentSum: () => op, SparseToDense: () => up, SplitV: () => Bo, Sqrt: () => li, Square: () => Al, SquaredDifference: () => pi, Step: () => gi, StridedSlice: () => Vo, StringNGrams: () => lp, StringSplit: () => Ag, StringToHashBucketFast: () => Eg, Sub: () => hi, Sum: () => ci, SymbolicTensor: () => $s, Tan: () => Wo, Tanh: () => fi, Tensor: () => et, TensorBuffer: () => Vt, Tile: () => Nr, TopK: () => Uo, Transform: () => Go, Transpose: () => mi, Unique: () => Rg, Unpack: () => Ho, UnsortedSegmentSum: () => cp, Variable: () => gd, ZerosLike: () => qo, _FusedMatMul: () => aa, abs: () => Mt, acos: () => XA, acosh: () => QA, add: () => ie, addN: () => JA, all: () => Qk, any: () => hm, argMax: () => qu, argMin: () => rE, asin: () => iE, asinh: () => uE, atan: () => cE, atan2: () => pE, atanh: () => fE, avgPool: () => qg, avgPool3d: () => tI, backend: () => WA, backend_util: () => C, basicLSTMCell: () => ipe, batchNorm: () => Ku, batchNorm2d: () => DE, batchNorm3d: () => OE, batchNorm4d: () => zE, batchToSpaceND: () => jg, bincount: () => nI, booleanMaskAsync: () => Fpe, broadcastArgs: () => BE, broadcastTo: () => nd, broadcast_util: () => Ko, browser: () => Ek, buffer: () => De, callbacks: () => Gpe, cast: () => ce, ceil: () => UE, clipByValue: () => Vn, clone: () => cr, complex: () => ua, concat: () => Ft, concat1d: () => qE, concat2d: () => KE, concat3d: () => YE, concat4d: () => ZE, constraints: () => TL, conv1d: () => sI, conv2d: () => da, conv2dTranspose: () => rI, conv3d: () => aI, conv3dTranspose: () => iR, copyRegisteredKernels: () => Hde, cos: () => Xg, cosh: () => oI, cosineWindow: () => RI, cumprod: () => mm, cumsum: () => uI, customGrad: () => js, data: () => V4, denseBincount: () => pR, deprecationWarn: () => Xk, depthToSpace: () => fR, depthwiseConv2d: () => mp, deregisterOp: () => qpe, device_util: () => hp, diag: () => ope, dilation2d: () => yR, disableDeprecationWarnings: () => Xde, dispose: () => Re, disposeVariables: () => Yde, div: () => xe, divNoNan: () => IR, dot: () => upe, dropout: () => iF, einsum: () => NR, elu: () => gp, enableDebugMode: () => Kde, enableProdMode: () => jde, enclosingPowerOfTwo: () => oF, engine: () => Ss, env: () => X, equal: () => Xn, erf: () => _R, exp: () => Yn, expandDims: () => Pn, expm1: () => DR, eye: () => lI, fft: () => db, fill: () => Pl, findBackend: () => spe, findBackendFactory: () => rpe, floor: () => bp, floorDiv: () => Yk, forceHalfFloat: () => JX, fused: () => fa, gather: () => Xu, gatherND: () => sF, gather_util: () => Dk, getBackend: () => tpe, getGradient: () => rx, getKernel: () => Jf, getKernelsForBackend: () => em, getThreadsCount: () => nhe, gpgpu_util: () => VK, grad: () => dpe, grads: () => ppe, greater: () => Un, greaterEqual: () => Xo, ifft: () => Id, imag: () => Yg, image: () => jn, inTopKAsync: () => Ppe, initializers: () => RL, input: () => GB, io: () => An, irfft: () => CI, isFinite: () => lpe, isInf: () => cpe, isNaN: () => GR, keep: () => Ht, kernel_impls: () => xs, layers: () => KL, leakyRelu: () => Qg, less: () => cI, lessEqual: () => Yo, linalg: () => HO, linspace: () => KR, loadGraphModel: () => jpe, loadLayersModel: () => Wpe, localResponseNormalization: () => YR, log: () => Qn, log1p: () => Zg, logSigmoid: () => mpe, logSoftmax: () => dI, logSumExp: () => cD, logicalAnd: () => Ds, logicalNot: () => tb, logicalOr: () => mI, logicalXor: () => gpe, losses: () => Lpe, matMul: () => We, math: () => dA, max: () => As, maxPool: () => nb, maxPool3d: () => gI, maxPoolWithArgmax: () => yD, maximum: () => _r, mean: () => St, memory: () => pm, meshgrid: () => bpe, metrics: () => hW, min: () => gm, minimum: () => vp, mirrorPad: () => SD, mod: () => ND, model: () => Bpe, models: () => _W, moments: () => sb, movingAverage: () => Ope, mul: () => V, multiRNNCell: () => ype, multinomial: () => ED, neg: () => kt, nextFrame: () => BI, norm: () => AI, notEqual: () => Yu, oneHot: () => vd, ones: () => Mn, onesLike: () => Zn, op: () => L, outerProduct: () => vpe, pad: () => bi, pad1d: () => xpe, pad2d: () => wpe, pad3d: () => kpe, pad4d: () => Ipe, pool: () => Spe, pow: () => ha, prelu: () => ab, print: () => K_, prod: () => bI, profile: () => Qde, rand: () => Cpe, randomGamma: () => Npe, randomNormal: () => ZD, randomUniform: () => Ml, range: () => Qu, ready: () => epe, real: () => wd, reciprocal: () => n3, registerBackend: () => fp, registerCallbackConstructor: () => Upe, registerGradient: () => M$, registerKernel: () => El, registerOp: () => Hpe, regularizers: () => AW, relu: () => Ys, relu6: () => yI, removeBackend: () => npe, reshape: () => G, reverse: () => Jn, reverse1d: () => Tpe, reverse2d: () => $pe, reverse3d: () => _pe, reverse4d: () => Ape, rfft: () => pb, round: () => vI, rsqrt: () => xI, scalar: () => we, scatterND: () => J3, scatter_util: () => Ok, selu: () => wI, separableConv2d: () => f3, sequential: () => Vpe, serialization: () => ae, setBackend: () => Jde, setPlatform: () => ape, setThreadsCount: () => the, setWasmPath: () => Jpe, setWasmPaths: () => ehe, setWebGLContext: () => D5, setdiff1dAsync: () => g3, shared: () => ev, sigmoid: () => qs, sign: () => y3, signal: () => Mpe, sin: () => kI, sinh: () => II, slice: () => qe, slice1d: () => ub, slice2d: () => SI, slice3d: () => lb, slice4d: () => kd, slice_util: () => wt, softmax: () => cb, softplus: () => zl, spaceToBatchND: () => rb, sparse: () => Wc, sparseToDense: () => EI, spectral: () => zpe, split: () => Bn, sqrt: () => cn, square: () => ct, squaredDifference: () => NI, squeeze: () => gr, stack: () => es, step: () => xp, stridedSlice: () => z3, string: () => Bf, sub: () => ge, sum: () => ve, sumOutType: () => pp, tan: () => L3, tanh: () => ju, tensor: () => fs, tensor1d: () => Qt, tensor2d: () => Yi, tensor3d: () => bA, tensor4d: () => Epe, tensor5d: () => Rpe, tensor6d: () => Dpe, tensor_util: () => _s, test_util: () => FA, tidy: () => j, tile: () => ps, time: () => Zde, topk: () => V3, train: () => Mi, transpose: () => Ge, truncatedNormal: () => hb, unique: () => mx, unregisterGradient: () => Gde, unregisterKernel: () => Ude, unsortedSegmentSum: () => H3, unstack: () => Fs, upcastType: () => ln, util: () => w, valueAndGrad: () => hpe, valueAndGrads: () => fpe, variable: () => j3, variableGrads: () => JR, version: () => rhe, version_converter: () => Kpe, version_core: () => qde, version_cpu: () => Xpe, version_layers: () => f0, version_wasm: () => she, version_webgl: () => Ype, webgl: () => Qpe, webgl_util: () => R5, webgpu: () => yoe, where: () => vn, whereAsync: () => $I, zeros: () => $t, zerosLike: () => je }); var GT = Object.create; var Ud = Object.defineProperty; var HT = Object.getOwnPropertyDescriptor; var qw = Object.getOwnPropertyNames; var qT = Object.getPrototypeOf; var jT = Object.prototype.hasOwnProperty; var KT = (e) => Ud(e, "__esModule", { value: true }); var zt = (e, t) => function() { return t || (0, e[qw(e)[0]])((t = { exports: {} }).exports, t), t.exports; }; var Ae = (e, t) => { for (var n in t) Ud(e, n, { get: t[n], enumerable: true }); }; var XT = (e, t, n, s) => { if (t && typeof t == "object" || typeof t == "function") for (let r of qw(t)) !jT.call(e, r) && (n || r !== "default") && Ud(e, r, { get: () => t[r], enumerable: !(s = HT(t, r)) || s.enumerable }); return e; }; var wa = (e, t) => XT(KT(Ud(e != null ? GT(qT(e)) : {}, "default", !t && e && e.__esModule ? { get: () => e.default, enumerable: true } : { value: e, enumerable: true })), e); var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { t.exports = s; var n = null; try { n = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; } catch (F) { } function s(F, T, z) { this.low = F | 0, this.high = T | 0, this.unsigned = !!z; } s.prototype.__isLong__, Object.defineProperty(s.prototype, "__isLong__", { value: true }); function r(F) { return (F && F.__isLong__) === true; } s.isLong = r; var a = {}, i = {}; function o(F, T) { var z, W, q; return T ? (F >>>= 0, (q = 0 <= F && F < 256) && (W = i[F], W) ? W : (z = l(F, (F | 0) < 0 ? -1 : 0, true), q && (i[F] = z), z)) : (F |= 0, (q = -128 <= F && F < 128) && (W = a[F], W) ? W : (z = l(F, F < 0 ? -1 : 0, false), q && (a[F] = z), z)); } s.fromInt = o; function u(F, T) { if (isNaN(F)) return T ? x : v; if (T) { if (F < 0) return x; if (F >= g) return A; } else { if (F <= -b) return P; if (F + 1 >= b) return E; } return F < 0 ? u(-F, T).neg() : l(F % m | 0, F / m | 0, T); } s.fromNumber = u; function l(F, T, z) { return new s(F, T, z); } s.fromBits = l; var c = Math.pow; function p(F, T, z) { if (F.length === 0) throw Error("empty string"); if (F === "NaN" || F === "Infinity" || F === "+Infinity" || F === "-Infinity") return v; if (typeof T == "number" ? (z = T, T = false) : T = !!T, z = z || 10, z < 2 || 36 < z) throw RangeError("radix"); var W; if ((W = F.indexOf("-")) > 0) throw Error("interior hyphen"); if (W === 0) return p(F.substring(1), T, z).neg(); for (var q = u(c(z, 8)), K = v, Y = 0; Y < F.length; Y += 8) { var Z = Math.min(8, F.length - Y), te = parseInt(F.substring(Y, Y + Z), z); if (Z < 8) { var ee = u(c(z, Z)); K = K.mul(ee).add(u(te)); } else K = K.mul(q), K = K.add(u(te)); } return K.unsigned = T, K; } s.fromString = p; function d(F, T) { return typeof F == "number" ? u(F, T) : typeof F == "string" ? p(F, T) : l(F.low, F.high, typeof T == "boolean" ? T : F.unsigned); } s.fromValue = d; var h = 1 << 16, f = 1 << 24, m = h * h, g = m * m, b = g / 2, y = o(f), v = o(0); s.ZERO = v; var x = o(0, true); s.UZERO = x; var k = o(1); s.ONE = k; var S = o(1, true); s.UONE = S; var $ = o(-1); s.NEG_ONE = $; var E = l(-1, 2147483647, false); s.MAX_VALUE = E; var A = l(-1, -1, true); s.MAX_UNSIGNED_VALUE = A; var P = l(0, -2147483648, false); s.MIN_VALUE = P; var R = s.prototype; R.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low; }, R.toNumber = function() { return this.unsigned ? (this.high >>> 0) * m + (this.low >>> 0) : this.high * m + (this.low >>> 0); }, R.toString = function(T) { if (T = T || 10, T < 2 || 36 < T) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) if (this.eq(P)) { var z = u(T), W = this.div(z), q = W.mul(z).sub(this); return W.toString(T) + q.toInt().toString(T); } else return "-" + this.neg().toString(T); for (var K = u(c(T, 6), this.unsigned), Y = this, Z = ""; ; ) { var te = Y.div(K), ee = Y.sub(te.mul(K)).toInt() >>> 0, se = ee.toString(T); if (Y = te, Y.isZero()) return se + Z; for (; se.length < 6; ) se = "0" + se; Z = "" + se + Z; } }, R.getHighBits = function() { return this.high; }, R.getHighBitsUnsigned = function() { return this.high >>> 0; }, R.getLowBits = function() { return this.low; }, R.getLowBitsUnsigned = function() { return this.low >>> 0; }, R.getNumBitsAbs = function() { if (this.isNegative()) return this.eq(P) ? 64 : this.neg().getNumBitsAbs(); for (var T = this.high != 0 ? this.high : this.low, z = 31; z > 0 && (T & 1 << z) == 0; z--) ; return this.high != 0 ? z + 33 : z + 1; }, R.isZero = function() { return this.high === 0 && this.low === 0; }, R.eqz = R.isZero, R.isNegative = function() { return !this.unsigned && this.high < 0; }, R.isPositive = function() { return this.unsigned || this.high >= 0; }, R.isOdd = function() { return (this.low & 1) === 1; }, R.isEven = function() { return (this.low & 1) === 0; }, R.equals = function(T) { return r(T) || (T = d(T)), this.unsigned !== T.unsigned && this.high >>> 31 === 1 && T.high >>> 31 === 1 ? false : this.high === T.high && this.low === T.low; }, R.eq = R.equals, R.notEquals = function(T) { return !this.eq(T); }, R.neq = R.notEquals, R.ne = R.notEquals, R.lessThan = function(T) { return this.comp(T) < 0; }, R.lt = R.lessThan, R.lessThanOrEqual = function(T) { return this.comp(T) <= 0; }, R.lte = R.lessThanOrEqual, R.le = R.lessThanOrEqual, R.greaterThan = function(T) { return this.comp(T) > 0; }, R.gt = R.greaterThan, R.greaterThanOrEqual = function(T) { return this.comp(T) >= 0; }, R.gte = R.greaterThanOrEqual, R.ge = R.greaterThanOrEqual, R.compare = function(T) { if (r(T) || (T = d(T)), this.eq(T)) return 0; var z = this.isNegative(), W = T.isNegative(); return z && !W ? -1 : !z && W ? 1 : this.unsigned ? T.high >>> 0 > this.high >>> 0 || T.high === this.high && T.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(T).isNegative() ? -1 : 1; }, R.comp = R.compare, R.negate = function() { return !this.unsigned && this.eq(P) ? P : this.not().add(k); }, R.neg = R.negate, R.add = function(T) { r(T) || (T = d(T)); var z = this.high >>> 16, W = this.high & 65535, q = this.low >>> 16, K = this.low & 65535, Y = T.high >>> 16, Z = T.high & 65535, te = T.low >>> 16, ee = T.low & 65535, se = 0, ne = 0, oe = 0, re = 0; return re += K + ee, oe += re >>> 16, re &= 65535, oe += q + te, ne += oe >>> 16, oe &= 65535, ne += W + Z, se += ne >>> 16, ne &= 65535, se += z + Y, se &= 65535, l(oe << 16 | re, se << 16 | ne, this.unsigned); }, R.subtract = function(T) { return r(T) || (T = d(T)), this.add(T.neg()); }, R.sub = R.subtract, R.multiply = function(T) { if (this.isZero()) return v; if (r(T) || (T = d(T)), n) { var z = n.mul(this.low, this.high, T.low, T.high); return l(z, n.get_high(), this.unsigned); } if (T.isZero()) return v; if (this.eq(P)) return T.isOdd() ? P : v; if (T.eq(P)) return this.isOdd() ? P : v; if (this.isNegative()) return T.isNegative() ? this.neg().mul(T.neg()) : this.neg().mul(T).neg(); if (T.isNegative()) return this.mul(T.neg()).neg(); if (this.lt(y) && T.lt(y)) return u(this.toNumber() * T.toNumber(), this.unsigned); var W = this.high >>> 16, q = this.high & 65535, K = this.low >>> 16, Y = this.low & 65535, Z = T.high >>> 16, te = T.high & 65535, ee = T.low >>> 16, se = T.low & 65535, ne = 0, oe = 0, re = 0, le = 0; return le += Y * se, re += le >>> 16, le &= 65535, re += K * se, oe += re >>> 16, re &= 65535, re += Y * ee, oe += re >>> 16, re &= 65535, oe += q * se, ne += oe >>> 16, oe &= 65535, oe += K * ee, ne += oe >>> 16, oe &= 65535, oe += Y * te, ne += oe >>> 16, oe &= 65535, ne += W * se + q * ee + K * te + Y * Z, ne &= 65535, l(re << 16 | le, ne << 16 | oe, this.unsigned); }, R.mul = R.multiply, R.divide = function(T) { if (r(T) || (T = d(T)), T.isZero()) throw Error("division by zero"); if (n) { if (!this.unsigned && this.high === -2147483648 && T.low === -1 && T.high === -1) return this; var z = (this.unsigned ? n.div_u : n.div_s)(this.low, this.high, T.low, T.high); return l(z, n.get_high(), this.unsigned); } if (this.isZero()) return this.unsigned ? x : v; var W, q, K; if (this.unsigned) { if (T.unsigned || (T = T.toUnsigned()), T.gt(this)) return x; if (T.gt(this.shru(1))) return S; K = x; } else { if (this.eq(P)) { if (T.eq(k) || T.eq($)) return P; if (T.eq(P)) return k; var Y = this.shr(1); return W = Y.div(T).shl(1), W.eq(v) ? T.isNegative() ? k : $ : (q = this.sub(T.mul(W)), K = W.add(q.div(T)), K); } else if (T.eq(P)) return this.unsigned ? x : v; if (this.isNegative()) return T.isNegative() ? this.neg().div(T.neg()) : this.neg().div(T).neg(); if (T.isNegative()) return this.div(T.neg()).neg(); K = v; } for (q = this; q.gte(T); ) { W = Math.max(1, Math.floor(q.toNumber() / T.toNumber())); for (var Z = Math.ceil(Math.log(W) / Math.LN2), te = Z <= 48 ? 1 : c(2, Z - 48), ee = u(W), se = ee.mul(T); se.isNegative() || se.gt(q); ) W -= te, ee = u(W, this.unsigned), se = ee.mul(T); ee.isZero() && (ee = k), K = K.add(ee), q = q.sub(se); } return K; }, R.div = R.divide, R.modulo = function(T) { if (r(T) || (T = d(T)), n) { var z = (this.unsigned ? n.rem_u : n.rem_s)(this.low, this.high, T.low, T.high); return l(z, n.get_high(), this.unsigned); } return this.sub(this.div(T).mul(T)); }, R.mod = R.modulo, R.rem = R.modulo, R.not = function() { return l(~this.low, ~this.high, this.unsigned); }, R.and = function(T) { return r(T) || (T = d(T)), l(this.low & T.low, this.high & T.high, this.unsigned); }, R.or = function(T) { return r(T) || (T = d(T)), l(this.low | T.low, this.high | T.high, this.unsigned); }, R.xor = function(T) { return r(T) || (T = d(T)), l(this.low ^ T.low, this.high ^ T.high, this.unsigned); }, R.shiftLeft = function(T) { return r(T) && (T = T.toInt()), (T &= 63) === 0 ? this : T < 32 ? l(this.low << T, this.high << T | this.low >>> 32 - T, this.unsigned) : l(0, this.low << T - 32, this.unsigned); }, R.shl = R.shiftLeft, R.shiftRight = function(T) { return r(T) && (T = T.toInt()), (T &= 63) === 0 ? this : T < 32 ? l(this.low >>> T | this.high << 32 - T, this.high >> T, this.unsigned) : l(this.high >> T - 32, this.high >= 0 ? 0 : -1, this.unsigned); }, R.shr = R.shiftRight, R.shiftRightUnsigned = function(T) { if (r(T) && (T = T.toInt()), T &= 63, T === 0) return this; var z = this.high; if (T < 32) { var W = this.low; return l(W >>> T | z << 32 - T, z >>> T, this.unsigned); } else return T === 32 ? l(z, 0, this.unsigned) : l(z >>> T - 32, 0, this.unsigned); }, R.shru = R.shiftRightUnsigned, R.shr_u = R.shiftRightUnsigned, R.toSigned = function() { return this.unsigned ? l(this.low, this.high, false) : this; }, R.toUnsigned = function() { return this.unsigned ? this : l(this.low, this.high, true); }, R.toBytes = function(T) { return T ? this.toBytesLE() : this.toBytesBE(); }, R.toBytesLE = function() { var T = this.high, z = this.low; return [z & 255, z >>> 8 & 255, z >>> 16 & 255, z >>> 24, T & 255, T >>> 8 & 255, T >>> 16 & 255, T >>> 24]; }, R.toBytesBE = function() { var T = this.high, z = this.low; return [T >>> 24, T >>> 16 & 255, T >>> 8 & 255, T & 255, z >>> 24, z >>> 16 & 255, z >>> 8 & 255, z & 255]; }, s.fromBytes = function(T, z, W) { return W ? s.fromBytesLE(T, z) : s.fromBytesBE(T, z); }, s.fromBytesLE = function(T, z) { return new s(T[0] | T[1] << 8 | T[2] << 16 | T[3] << 24, T[4] | T[5] << 8 | T[6] << 16 | T[7] << 24, z); }, s.fromBytesBE = function(T, z) { return new s(T[4] << 24 | T[5] << 16 | T[6] << 8 | T[7], T[0] << 24 | T[1] << 16 | T[2] << 8 | T[3], z); }; } }); var QT = zt({ "(disabled):src/node_modules/node-fetch/browser.js"() { } }); var ZT = zt({ "(disabled):util"() { } }); var JT = zt({ "src/node_modules/seedrandom/lib/alea.js"(e, t) { (function(n, s, r) { function a(l) { var c = this, p = u(); c.next = function() { var d = 2091639 * c.s0 + c.c * 23283064365386963e-26; return c.s0 = c.s1, c.s1 = c.s2, c.s2 = d - (c.c = d | 0); }, c.c = 1, c.s0 = p(" "), c.s1 = p(" "), c.s2 = p(" "), c.s0 -= p(l), c.s0 < 0 && (c.s0 += 1), c.s1 -= p(l), c.s1 < 0 && (c.s1 += 1), c.s2 -= p(l), c.s2 < 0 && (c.s2 += 1), p = null; } function i(l, c) { return c.c = l.c, c.s0 = l.s0, c.s1 = l.s1, c.s2 = l.s2, c; } function o(l, c) { var p = new a(l), d = c && c.state, h = p.next; return h.int32 = function() { return p.next() * 4294967296 | 0; }, h.double = function() { return h() + (h() * 2097152 | 0) * 11102230246251565e-32; }, h.quick = h, d && (typeof d == "object" && i(d, p), h.state = function() { return i(p, {}); }), h; } function u() { var l = 4022871197, c = function(p) { p = String(p); for (var d = 0; d < p.length; d++) { l += p.charCodeAt(d); var h = 0.02519603282416938 * l; l = h >>> 0, h -= l, h *= l, l = h >>> 0, h -= l, l += h * 4294967296; } return (l >>> 0) * 23283064365386963e-26; }; return c; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.alea = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var e$ = zt({ "src/node_modules/seedrandom/lib/xor128.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; l.x = 0, l.y = 0, l.z = 0, l.w = 0, l.next = function() { var d = l.x ^ l.x << 11; return l.x = l.y, l.y = l.z, l.z = l.w, l.w ^= l.w >>> 19 ^ d ^ d >>> 8; }, u === (u | 0) ? l.x = u : c += u; for (var p = 0; p < c.length + 64; p++) l.x ^= c.charCodeAt(p) | 0, l.next(); } function i(u, l) { return l.x = u.x, l.y = u.y, l.z = u.z, l.w = u.w, l; } function o(u, l) { var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (typeof p == "object" && i(p, c), d.state = function() { return i(c, {}); }), d; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xor128 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var t$ = zt({ "src/node_modules/seedrandom/lib/xorwow.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; l.next = function() { var d = l.x ^ l.x >>> 2; return l.x = l.y, l.y = l.z, l.z = l.w, l.w = l.v, (l.d = l.d + 362437 | 0) + (l.v = l.v ^ l.v << 4 ^ (d ^ d << 1)) | 0; }, l.x = 0, l.y = 0, l.z = 0, l.w = 0, l.v = 0, u === (u | 0) ? l.x = u : c += u; for (var p = 0; p < c.length + 64; p++) l.x ^= c.charCodeAt(p) | 0, p == c.length && (l.d = l.x << 10 ^ l.x >>> 4), l.next(); } function i(u, l) { return l.x = u.x, l.y = u.y, l.z = u.z, l.w = u.w, l.v = u.v, l.d = u.d, l; } function o(u, l) { var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (typeof p == "object" && i(p, c), d.state = function() { return i(c, {}); }), d; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xorwow = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var n$ = zt({ "src/node_modules/seedrandom/lib/xorshift7.js"(e, t) { (function(n, s, r) { function a(u) { var l = this; l.next = function() { var p = l.x, d = l.i, h, f, m; return h = p[d], h ^= h >>> 7, f = h ^ h << 24, h = p[d + 1 & 7], f ^= h ^ h >>> 10, h = p[d + 3 & 7], f ^= h ^ h >>> 3, h = p[d + 4 & 7], f ^= h ^ h << 7, h = p[d + 7 & 7], h = h ^ h << 13, f ^= h ^ h << 9, p[d] = f, l.i = d + 1 & 7, f; }; function c(p, d) { var h, f, m = []; if (d === (d | 0)) f = m[0] = d; else for (d = "" + d, h = 0; h < d.length; ++h) m[h & 7] = m[h & 7] << 15 ^ d.charCodeAt(h) + m[h + 1 & 7] << 13; for (; m.length < 8; ) m.push(0); for (h = 0; h < 8 && m[h] === 0; ++h) ; for (h == 8 ? f = m[7] = -1 : f = m[h], p.x = m, p.i = 0, h = 256; h > 0; --h) p.next(); } c(l, u); } function i(u, l) { return l.x = u.x.slice(), l.i = u.i, l; } function o(u, l) { u == null && (u = +new Date()); var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (p.x && i(p, c), d.state = function() { return i(c, {}); }), d; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xorshift7 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var s$ = zt({ "src/node_modules/seedrandom/lib/xor4096.js"(e, t) { (function(n, s, r) { function a(u) { var l = this; l.next = function() { var p = l.w, d = l.X, h = l.i, f, m; return l.w = p = p + 1640531527 | 0, m = d[h + 34 & 127], f = d[h = h + 1 & 127], m ^= m << 13, f ^= f << 17, m ^= m >>> 15, f ^= f >>> 12, m = d[h] = m ^ f, l.i = h, m + (p ^ p >>> 16) | 0; }; function c(p, d) { var h, f, m, g, b, y = [], v = 128; for (d === (d | 0) ? (f = d, d = null) : (d = d + "\0", f = 0, v = Math.max(v, d.length)), m = 0, g = -32; g < v; ++g) d && (f ^= d.charCodeAt((g + 32) % d.length)), g === 0 && (b = f), f ^= f << 10, f ^= f >>> 15, f ^= f << 4, f ^= f >>> 13, g >= 0 && (b = b + 1640531527 | 0, h = y[g & 127] ^= f + b, m = h == 0 ? m + 1 : 0); for (m >= 128 && (y[(d && d.length || 0) & 127] = -1), m = 127, g = 4 * 128; g > 0; --g) f = y[m + 34 & 127], h = y[m = m + 1 & 127], f ^= f << 13, h ^= h << 17, f ^= f >>> 15, h ^= h >>> 12, y[m] = f ^ h; p.w = b, p.X = y, p.i = m; } c(l, u); } function i(u, l) { return l.i = u.i, l.w = u.w, l.X = u.X.slice(), l; } function o(u, l) { u == null && (u = +new Date()); var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (p.X && i(p, c), d.state = function() { return i(c, {}); }), d; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.xor4096 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var r$ = zt({ "src/node_modules/seedrandom/lib/tychei.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; l.next = function() { var d = l.b, h = l.c, f = l.d, m = l.a; return d = d << 25 ^ d >>> 7 ^ h, h = h - f | 0, f = f << 24 ^ f >>> 8 ^ m, m = m - d | 0, l.b = d = d << 20 ^ d >>> 12 ^ h, l.c = h = h - f | 0, l.d = f << 16 ^ h >>> 16 ^ m, l.a = m - d | 0; }, l.a = 0, l.b = 0, l.c = -1640531527, l.d = 1367130551, u === Math.floor(u) ? (l.a = u / 4294967296 | 0, l.b = u | 0) : c += u; for (var p = 0; p < c.length + 20; p++) l.b ^= c.charCodeAt(p) | 0, l.next(); } function i(u, l) { return l.a = u.a, l.b = u.b, l.c = u.c, l.d = u.d, l; } function o(u, l) { var c = new a(u), p = l && l.state, d = function() { return (c.next() >>> 0) / 4294967296; }; return d.double = function() { do var h = c.next() >>> 11, f = (c.next() >>> 0) / 4294967296, m = (h + f) / (1 << 21); while (m === 0); return m; }, d.int32 = c.next, d.quick = d, p && (typeof p == "object" && i(p, c), d.state = function() { return i(c, {}); }), d; } s && s.exports ? s.exports = o : r && r.amd ? r(function() { return o; }) : this.tychei = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); var a$ = zt({ "(disabled):crypto"() { } }); var i$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { (function(n, s, r) { var a = 256, i = 6, o = 52, u = "random", l = r.pow(a, i), c = r.pow(2, o), p = c * 2, d = a - 1, h; function f(k, S, $) { var E = []; S = S == true ? { entropy: true } : S || {}; var A = y(b(S.entropy ? [k, x(s)] : k == null ? v() : k, 3), E), P = new m(E), R = function() { for (var F = P.g(i), T = l, z = 0; F < c; ) F = (F + z) * a, T *= a, z = P.g(1); for (; F >= p; ) F /= 2, T /= 2, z >>>= 1; return (F + z) / T; }; return R.int32 = function() { return P.g(4) | 0; }, R.quick = function() { return P.g(4) / 4294967296; }, R.double = R, y(x(P.S), s), (S.pass || $ || function(F, T, z, W) { return W && (W.S && g(W, P), F.state = function() { return g(P, {}); }), z ? (r[u] = F, T) : F; })(R, A, "global" in S ? S.global : this == r, S.state); } function m(k) { var S, $ = k.length, E = this, A = 0, P = E.i = E.j = 0, R = E.S = []; for ($ || (k = [$++]); A < a; ) R[A] = A++; for (A = 0; A < a; A++) R[A] = R[P = d & P + k[A % $] + (S = R[A])], R[P] = S; (E.g = function(F) { for (var T, z = 0, W = E.i, q = E.j, K = E.S; F--; ) T = K[W = d & W + 1], z = z * a + K[d & (K[W] = K[q = d & q + T]) + (K[q] = T)]; return E.i = W, E.j = q, z; })(a); } function g(k, S) { return S.i = k.i, S.j = k.j, S.S = k.S.slice(), S; } function b(k, S) { var $ = [], E = typeof k, A; if (S && E == "object") for (A in k) try { $.push(b(k[A], S - 1)); } catch (P) { } return $.length ? $ : E == "string" ? k : k + "\0"; } function y(k, S) { for (var $ = k + "", E, A = 0; A < $.length; ) S[d & A] = d & (E ^= S[d & A] * 19) + $.charCodeAt(A++); return x(S); } function v() { try { var k; return h && (k = h.randomBytes) ? k = k(a) : (k = new Uint8Array(a), (n.crypto || n.msCrypto).getRandomValues(k)), x(k); } catch (E) { var S = n.navigator, $ = S && S.plugins; return [+new Date(), n, $, n.screen, x(s)]; } } function x(k) { return String.fromCharCode.apply(0, k); } if (y(r.random(), s), typeof t == "object" && t.exports) { t.exports = f; try { h = a$(); } catch (k) { } } else typeof define == "function" && define.amd ? define(function() { return f; }) : r["seed" + u] = f; })(typeof self != "undefined" ? self : e, [], Math); } }); var Gd = zt({ "src/node_modules/seedrandom/index.js"(e, t) { var n = JT(), s = e$(), r = t$(), a = n$(), i = s$(), o = r$(), u = i$(); u.alea = n, u.xor128 = s, u.xorwow = r, u.xorshift7 = a, u.xor4096 = i, u.tychei = o, t.exports = u; } }); var jw = zt({ "(disabled):src/node_modules/string_decoder/index.js"() { } }); var sg = zt({ "(disabled):fs"() { } }); var dd = zt({ "(disabled):path"() { } }); var o$ = zt({ "(disabled):worker_threads"() { } }); var u$ = zt({ "(disabled):perf_hooks"() { } }); var l$ = zt({ "(disabled):os"() { } }); var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e, t) { var n = (() => { var s = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (s = s || __filename), function(r) { r = r || {}; function a() { return Ce.buffer != tn && rs(Ce.buffer), ic; } function i() { return Ce.buffer != tn && rs(Ce.buffer), oc; } function o() { return Ce.buffer != tn && rs(Ce.buffer), fu; } function u() { return Ce.buffer != tn && rs(Ce.buffer), uc; } function l() { return Ce.buffer != tn && rs(Ce.buffer), lc; } function c() { return Ce.buffer != tn && rs(Ce.buffer), cc; } function p() { return Ce.buffer != tn && rs(Ce.buffer), dc; } var d = typeof r != "undefined" ? r : {}, h, f; d.ready = new Promise(function(N, D) { h = N, f = D; }); var m; typeof process != "undefined" && process.listeners && (m = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var g = Object.assign({}, d), b = [], y = "./this.program", v = (N, D) => { throw D; }, x = typeof window == "object", k = typeof importScripts == "function", S = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", $ = d.ENVIRONMENT_IS_PTHREAD || false, E = ""; function A(N) { return d.locateFile ? d.locateFile(N, E) : E + N; } var P, R, F, T; function z(N) { if (N instanceof Iu) return; ee("exiting due to exception: " + N); } var W, q, K; if (S) { k ? E = dd().dirname(E) + "/" : E = __dirname + "/", K = () => { q || (W = sg(), q = dd()); }, P = function(B, Q) { return K(), B = q.normalize(B), W.readFileSync(B, Q ? void 0 : "utf8"); }, F = (D) => { var B = P(D, true); return B.buffer || (B = new Uint8Array(B)), B; }, R = (D, B, Q) => { K(), D = q.normalize(D), W.readFile(D, function(ue, pe) { ue ? Q(ue) : B(pe.buffer); }); }, process.argv.length > 1 && (y = process.argv[1].replace(/\\/g, "/")), b = process.argv.slice(2), process.on("uncaughtException", function(D) { if (!(D instanceof Iu)) throw D; }), process.on("unhandledRejection", function(D) { throw D; }), v = (D, B) => { if (zr()) throw process.exitCode = D, B; z(B), process.exit(D); }, d.inspect = function() { return "[Emscripten Module object]"; }; let N; try { N = o$(); } catch (D) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), D; } global.Worker = N.Worker; } else (x || k) && (k ? E = self.location.href : typeof document != "undefined" && document.currentScript && (E = document.currentScript.src), typeof s != "undefined" && s && (E = s), E.indexOf("blob:") !== 0 ? E = E.substr(0, E.replace(/[?#].*/, "").lastIndexOf("/") + 1) : E = "", S || (P = (N) => { var D = new XMLHttpRequest(); return D.open("GET", N, false), D.send(null), D.responseText; }, k && (F = (N) => { var D = new XMLHttpRequest(); return D.open("GET", N, false), D.responseType = "arraybuffer", D.send(null), new Uint8Array(D.response); }), R = (N, D, B) => { var Q = new XMLHttpRequest(); Q.open("GET", N, true), Q.responseType = "arraybuffer", Q.onload = () => { if (Q.status == 200 || Q.status == 0 && Q.response) { D(Q.response); return; } B(); }, Q.onerror = B, Q.send(null); }), T = (N) => document.title = N); S && typeof performance == "undefined" && (global.performance = u$().performance); var Y = console.log.bind(console), Z = console.warn.bind(console); S && (K(), Y = (N) => W.writeSync(1, N + ` `), Z = (N) => W.writeSync(2, N + ` `)); var te = d.print || Y, ee = d.printErr || Z; Object.assign(d, g), g = null, d.arguments && (b = d.arguments), d.thisProgram && (y = d.thisProgram), d.quit && (v = d.quit); var se = 4; function ne(N) { ne.shown || (ne.shown = {}), ne.shown[N] || (ne.shown[N] = 1, ee(N)); } function oe(N, D) { if (typeof WebAssembly.Function == "function") { for (var B = { i: "i32", j: "i64", f: "f32", d: "f64" }, Q = { parameters: [], results: D[0] == "v" ? [] : [B[D[0]]] }, ue = 1; ue < D.length; ++ue) Q.parameters.push(B[D[ue]]); return new WebAssembly.Function(Q, N); } var pe = [1, 0, 1, 96], ye = D.slice(0, 1), Te = D.slice(1), bt = { i: 127, j: 126, f: 125, d: 124 }; pe.push(Te.length); for (var ue = 0; ue < Te.length; ++ue) pe.push(bt[Te[ue]]); ye == "v" ? pe.push(0) : pe = pe.concat([1, bt[ye]]), pe[1] = pe.length - 2; var us = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(pe, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), ls = new WebAssembly.Module(us), Bc = new WebAssembly.Instance(ls, { e: { f: N } }), Su = Bc.exports.f; return Su; } var re = [], le; function me() { if (re.length) return re.pop(); try { Fn.grow(1); } catch (N) { throw N instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : N; } return Fn.length - 1; } function ke(N, D) { for (var B = N; B < N + D; B++) { var Q = Ai(B); Q && le.set(Q, B); } } var Se = 0, Ee = (N) => { Se = N; }, Pe = Atomics.load, Xe = Atomics.store, Je = Atomics.compareExchange, Ye; d.wasmBinary && (Ye = d.wasmBinary); var tt = d.noExitRuntime || true; typeof WebAssembly != "object" && Ti("no native wasm support detected"); var Ce, ut, rt = false, Zt; function Nt(N, D) { N || Ti(D); } function Sn(N) { var D = d["_" + N]; return D; } function Et(N, D, B, Q, ue) { var pe = { string: function(Tn) { var zi = 0; if (Tn != null && Tn !== 0) { var nx = (Tn.length << 2) + 1; zi = Pi(nx), Ls(Tn, zi, nx); } return zi; }, array: function(Tn) { var zi = Pi(Tn.length); return Bs(Tn, zi), zi; } }; function ye(Tn) { return D === "string" ? en(Tn) : D === "boolean" ? Boolean(Tn) : Tn; } var Te = Sn(N), bt = [], us = 0; if (Q) for (var ls = 0; ls < Q.length; ls++) { var Bc = pe[B[ls]]; Bc ? (us === 0 && (us = Df()), bt[ls] = Bc(Q[ls])) : bt[ls] = Q[ls]; } var Su = Te.apply(null, bt); function UT(Tn) { return us !== 0 && Pc(us), ye(Tn); } return Su = UT(Su), Su; } function Jt(N, D, B, Q) { B = B || []; var ue = B.every(function(ye) { return ye === "number"; }), pe = D !== "string"; return pe && ue && !Q ? Sn(N) : function() { return Et(N, D, B, arguments, Q); }; } var Cn = 1; function Nn(N) { var D = new TextDecoder(N); this.decode = (B) => (B.buffer instanceof SharedArrayBuffer && (B = new Uint8Array(B)), D.decode.call(D, B)); } var Xt = typeof TextDecoder != "undefined" ? new Nn("utf8") : void 0; function Dn(N, D, B) { for (var Q = D + B, ue = D; N[ue] && !(ue >= Q); ) ++ue; if (ue - D > 16 && N.subarray && Xt) return Xt.decode(N.subarray(D, ue)); for (var pe = ""; D < ue; ) { var ye = N[D++]; if (!(ye & 128)) { pe += String.fromCharCode(ye); continue; } var Te = N[D++] & 63; if ((ye & 224) == 192) { pe += String.fromCharCode((ye & 31) << 6 | Te); continue; } var bt = N[D++] & 63; if ((ye & 240) == 224 ? ye = (ye & 15) << 12 | Te << 6 | bt : ye = (ye & 7) << 18 | Te << 12 | bt << 6 | N[D++] & 63, ye < 65536) pe += String.fromCharCode(ye); else { var us = ye - 65536; pe += String.fromCharCode(55296 | us >> 10, 56320 | us & 1023); } } return pe; } function en(N, D) { return N ? Dn(i(), N, D) : ""; } function Ms(N, D, B, Q) { if (!(Q > 0)) return 0; for (var ue = B, pe = B + Q - 1, ye = 0; ye < N.length; ++ye) { var Te = N.charCodeAt(ye); if (Te >= 55296 && Te <= 57343) { var bt = N.charCodeAt(++ye); Te = 65536 + ((Te & 1023) << 10) | bt & 1023; } if (Te <= 127) { if (B >= pe) break; D[B++] = Te; } else if (Te <= 2047) { if (B + 1 >= pe) break; D[B++] = 192 | Te >> 6, D[B++] = 128 | Te & 63; } else if (Te <= 65535) { if (B + 2 >= pe) break; D[B++] = 224 | Te >> 12, D[B++] = 128 | Te >> 6 & 63, D[B++] = 128 | Te & 63; } else { if (B + 3 >= pe) break; D[B++] = 240 | Te >> 18, D[B++] = 128 | Te >> 12 & 63, D[B++] = 128 | Te >> 6 & 63, D[B++] = 128 | Te & 63; } } return D[B] = 0, B - ue; } function Ls(N, D, B) { return Ms(N, i(), D, B); } function Si(N) { for (var D = 0, B = 0; B < N.length; ++B) { var Q = N.charCodeAt(B); Q >= 55296 && Q <= 57343 && (Q = 65536 + ((Q & 1023) << 10) | N.charCodeAt(++B) & 1023), Q <= 127 ? ++D : Q <= 2047 ? D += 2 : Q <= 65535 ? D += 3 : D += 4; } return D; } var er = typeof TextDecoder != "undefined" ? new Nn("utf-16le") : void 0; function Bs(N, D) { a().set(N, D); } function hu(N, D, B) { for (var Q = 0; Q < N.length; ++Q) a()[D++ >> 0] = N.charCodeAt(Q); B || (a()[D >> 0] = 0); } function Ci(N, D) { return N % D > 0 && (N += D - N % D), N; } var tn, ic, oc, fu, uc, lc, Pv, cc, dc; $ && (tn = d.buffer); function rs(N) { tn = N, d.HEAP8 = ic = new Int8Array(N), d.HEAP16 = fu = new Int16Array(N), d.HEAP32 = lc = new Int32Array(N), d.HEAPU8 = oc = new Uint8Array(N), d.HEAPU16 = uc = new Uint16Array(N), d.HEAPU32 = Pv = new Uint32Array(N), d.HEAPF32 = cc = new Float32Array(N), d.HEAPF64 = dc = new Float64Array(N); } var pc = d.INITIAL_MEMORY || 16777216; if ($) Ce = d.wasmMemory, tn = d.buffer; else if (d.wasmMemory) Ce = d.wasmMemory; else if (Ce = new WebAssembly.Memory({ initial: pc / 65536, maximum: 32768, shared: true }), !(Ce.buffer instanceof SharedArrayBuffer)) throw ee("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"), S && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); Ce && (tn = Ce.buffer), pc = tn.byteLength, rs(tn); var Fn, Ni = [], tr = [], sh = [], hc = [], Pr = false, rh = false, fc = 0; function zr() { return tt || fc > 0; } function nn() { if (d.preRun) for (typeof d.preRun == "function" && (d.preRun = [d.preRun]); d.preRun.length; ) zv(d.preRun.shift()); vc(Ni); } function mu() { Pr = true, !$ && vc(tr); } function ah() { $ || (_e.terminateAllThreads(), rh = true); } function ih() { if (!$) { if (d.postRun) for (typeof d.postRun == "function" && (d.postRun = [d.postRun]); d.postRun.length; ) gu(d.postRun.shift()); vc(hc); } } function zv(N) { Ni.unshift(N); } function Mv(N) { tr.unshift(N); } function gu(N) { hc.unshift(N); } var nr = 0, mc = null, as = null; function bu(N) { nr++, d.monitorRunDependencies && d.monitorRunDependencies(nr); } function Lv(N) { if (nr--, d.monitorRunDependencies && d.monitorRunDependencies(nr), nr == 0 && (mc !== null && (clearInterval(mc), mc = null), as)) { var D = as; as = null, D(); } } d.preloadedImages = {}, d.preloadedAudios = {}; function Ti(N) { $ ? postMessage({ cmd: "onAbort", arg: N }) : d.onAbort && d.onAbort(N), N = "Aborted(" + N + ")", ee(N), rt = true, Zt = 1, N += ". Build with -s ASSERTIONS=1 for more info."; var D = new WebAssembly.RuntimeError(N); throw f(D), D; } var oh = "data:application/octet-stream;base64,"; function gc(N) { return N.startsWith(oh); } function bc(N) { return N.startsWith("file://"); } var sn; sn = "tfjs-backend-wasm-threaded-simd.wasm", gc(sn) || (sn = A(sn)); function yc(N) { try { if (N == sn && Ye) return new Uint8Array(Ye); if (F) return F(N); throw "both async and sync fetching of the wasm failed"; } catch (D) { Ti(D); } } function $i() { if (!Ye && (x || k)) { if (typeof fetch == "function" && !bc(sn)) return fetch(sn, { credentials: "same-origin" }).then(function(N) { if (!N.ok) throw "failed to load wasm binary file at '" + sn + "'"; return N.arrayBuffer(); }).catch(function() { return yc(sn); }); if (R) return new Promise(function(N, D) { R(sn, function(B) { N(new Uint8Array(B)); }, D); }); } return Promise.resolve().then(function() { return yc(sn); }); } function uh() { var N = { env: Ec, wasi_snapshot_preview1: Ec }; function D(ye, Te) { var bt = ye.exports; if (d.asm = bt, mh(d.asm.emscripten_tls_init), Fn = d.asm.__indirect_function_table, Mv(d.asm.__wasm_call_ctors), ut = Te, !$) { var us = _e.unusedWorkers.length; _e.unusedWorkers.forEach(function(ls) { _e.loadWasmModuleToWorker(ls, function() { --us || Lv("wasm-instantiate"); }); }); } } $ || bu("wasm-instantiate"); function B(ye) { D(ye.instance, ye.module); } function Q(ye) { return $i().then(function(Te) { return WebAssembly.instantiate(Te, N); }).then(function(Te) { return Te; }).then(ye, function(Te) { ee("failed to asynchronously prepare wasm: " + Te), Ti(Te); }); } function ue() { return !Ye && typeof WebAssembly.instantiateStreaming == "function" && !gc(sn) && !bc(sn) && typeof fetch == "function" ? fetch(sn, { credentials: "same-origin" }).then(function(ye) { var Te = WebAssembly.instantiateStreaming(ye, N); return Te.then(B, function(bt) { return ee("wasm streaming compile failed: " + bt), ee("falling back to ArrayBuffer instantiation"), Q(B); }); }) : Q(B); } if (d.instantiateWasm) try { var pe = d.instantiateWasm(N, D); return pe; } catch (ye) { return ee("Module.instantiateWasm callback failed with error: " + ye), false; } return ue().catch(f), {}; } var Bv, Vv, lh = {}; function vc(N) { for (; N.length > 0; ) { var D = N.shift(); if (typeof D == "function") { D(d); continue; } var B = D.func; typeof B == "number" ? D.arg === void 0 ? Ai(B)() : Ai(B)(D.arg) : B(D.arg === void 0 ? null : D.arg); } } function _i(N) { var D = Df(), B = N(); return Pc(D), B; } function QN(N) { return N; } function Wv(N) { var D = /\b_Z[\w\d_]+/g; return N.replace(D, function(B) { var Q = B; return B === Q ? B : Q + " [" + B + "]"; }); } function ch(N) { l()[N >> 2] = 0; var D = _e.pthreads[N]; delete _e.pthreads[N], D.worker.terminate(), Rf(N), _e.runningWorkers.splice(_e.runningWorkers.indexOf(D.worker), 1), D.worker.pthread = void 0; } function dh(N) { var D = _e.pthreads[N]; D.worker.postMessage({ cmd: "cancel" }); } function xc(N) { var D = _e.pthreads[N]; if (D) { l()[N >> 2] = 0; var B = D.worker; _e.returnWorkerToPool(B); } } function wc(N) { BT(N); } function ph(N) { if (N instanceof Iu || N == "unwind") return Zt; v(1, N); } var _e = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], init: function() { $ ? _e.initWorker() : _e.initMainThread(); }, initMainThread: function() { for (var N = 8, D = 0; D < N; ++D) _e.allocateUnusedWorker(); }, initWorker: function() { tt = false; }, pthreads: {}, setExitStatus: function(N) { Zt = N; }, terminateAllThreads: function() { for (var N in _e.pthreads) { var D = _e.pthreads[N]; D && D.worker && _e.returnWorkerToPool(D.worker); } for (var B = 0; B < _e.unusedWorkers.length; ++B) { var Q = _e.unusedWorkers[B]; Q.terminate(); } _e.unusedWorkers = []; }, returnWorkerToPool: function(N) { _e.runWithoutMainThreadQueuedCalls(function() { delete _e.pthreads[N.pthread.threadInfoStruct], _e.unusedWorkers.push(N), _e.runningWorkers.splice(_e.runningWorkers.indexOf(N), 1), Rf(N.pthread.threadInfoStruct), N.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(N) { l()[tx >> 2] = 0; try { N(); } finally { l()[tx >> 2] = 1; } }, receiveObjectTransfer: function(N) { }, threadInit: function() { for (var N in _e.tlsInitFunctions) _e.tlsInitFunctions[N](); }, loadWasmModuleToWorker: function(N, D) { N.onmessage = (B) => { var Q = B.data, ue = Q.cmd; if (N.pthread && (_e.currentProxiedOperationCallerThread = N.pthread.threadInfoStruct), Q.targetThread && Q.targetThread != Oc()) { var pe = _e.pthreads[Q.targetThread]; pe ? pe.worker.postMessage(Q, Q.transferList) : ee('Internal error! Worker sent a message "' + ue + '" to target pthread ' + Q.targetThread + ", but that thread no longer exists!"), _e.currentProxiedOperationCallerThread = void 0; return; } ue === "processQueuedMainThreadWork" ? Yv() : ue === "spawnThread" ? Ic(Q) : ue === "cleanupThread" ? xc(Q.thread) : ue === "killThread" ? ch(Q.thread) : ue === "cancelThread" ? dh(Q.thread) : ue === "loaded" ? (N.loaded = true, D && D(N), N.runPthread && (N.runPthread(), delete N.runPthread)) : ue === "print" ? te("Thread " + Q.threadId + ": " + Q.text) : ue === "printErr" ? ee("Thread " + Q.threadId + ": " + Q.text) : ue === "alert" ? alert("Thread " + Q.threadId + ": " + Q.text) : Q.target === "setimmediate" ? N.postMessage(Q) : ue === "onAbort" ? d.onAbort && d.onAbort(Q.arg) : ee("worker sent an unknown command " + ue), _e.currentProxiedOperationCallerThread = void 0; }, N.onerror = (B) => { var Q = "worker sent an error!"; throw ee(Q + " " + B.filename + ":" + B.lineno + ": " + B.message), B; }, S && (N.on("message", function(B) { N.onmessage({ data: B }); }), N.on("error", function(B) { N.onerror(B); }), N.on("detachedExit", function() { })), N.postMessage({ cmd: "load", urlOrBlob: d.mainScriptUrlOrBlob || s, wasmMemory: Ce, wasmModule: ut }); }, allocateUnusedWorker: function() { var N = A("tfjs-backend-wasm-threaded-simd.worker.js"); _e.unusedWorkers.push(new Worker(N)); }, getNewWorker: function() { return _e.unusedWorkers.length == 0 && (_e.allocateUnusedWorker(), _e.loadWasmModuleToWorker(_e.unusedWorkers[0])), _e.unusedWorkers.pop(); } }; function hh() { var N = Oc(), D = l()[N + 44 >> 2], B = l()[N + 48 >> 2], Q = D - B; ex(D, Q), Pc(D); } d.establishStackSpace = hh; function kc(N) { if ($) return Br(1, 0, N); try { wc(N); } catch (D) { ph(D); } } var Mr = []; function Ai(N) { var D = Mr[N]; return D || (N >= Mr.length && (Mr.length = N + 1), Mr[N] = D = Fn.get(N)), D; } function fh(N, D) { return Ai(N)(D); } d.invokeEntryPoint = fh; function Uv() { var N = new Error(); if (!N.stack) { try { throw new Error(); } catch (D) { N = D; } if (!N.stack) return "(no stack trace available)"; } return N.stack.toString(); } function mh(N, D, B) { _e.tlsInitFunctions.push(N); } function Gv(N, D) { Fn.set(N, D), Mr[N] = D; } var Lr; S ? Lr = () => { var N = process.hrtime(); return N[0] * 1e3 + N[1] / 1e6; } : $ ? Lr = () => performance.now() - d.__performance_now_clock_drift : Lr = () => performance.now(); var gh = true; function bh(N) { return l()[Xv() >> 2] = N, N; } function yh(N, D) { var B; if (N === 0) B = Date.now(); else if ((N === 1 || N === 4) && gh) B = Lr(); else return bh(28), -1; return l()[D >> 2] = B / 1e3 | 0, l()[D + 4 >> 2] = B % 1e3 * 1e3 * 1e3 | 0, 0; } function vh(N, D) { return yh(N, D); } function xh(N) { Qv(N, !k, 1, !x), _e.threadInit(); } function wh(N) { $ ? postMessage({ cmd: "cleanupThread", thread: N }) : xc(N); } function Ic(N) { var D = _e.getNewWorker(); if (!D) return 6; _e.runningWorkers.push(D); var B = _e.pthreads[N.pthread_ptr] = { worker: D, threadInfoStruct: N.pthread_ptr }; D.pthread = B; var Q = { cmd: "run", start_routine: N.startRoutine, arg: N.arg, threadInfoStruct: N.pthread_ptr }; return D.runPthread = () => { Q.time = performance.now(), D.postMessage(Q, N.transferList); }, D.loaded && (D.runPthread(), delete D.runPthread), 0; } function kh(N, D, B, Q) { if (typeof SharedArrayBuffer == "undefined") return ee("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; var ue = [], pe = 0; if ($ && (ue.length === 0 || pe)) return Zv(687865856, N, D, B, Q); if (pe) return pe; var ye = { startRoutine: B, pthread_ptr: N, arg: Q, transferList: ue }; return $ ? (ye.cmd = "spawnThread", postMessage(ye, ue), 0) : Ic(ye); } function Ih() { return 2097152; } function Sh(N, D) { if (N == D) postMessage({ cmd: "processQueuedMainThreadWork" }); else if ($) postMessage({ targetThread: N, cmd: "processThreadQueue" }); else { var B = _e.pthreads[N], Q = B && B.worker; if (!Q) return; Q.postMessage({ cmd: "processThreadQueue" }); } return 1; } function Ch() { Ti(""); } function Nh() { S || k || ne("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); } function Sc() { return 2147483648; } function Th(N, D, B) { i().copyWithin(N, D, D + B); } function $h() { return S ? l$().cpus().length : navigator.hardwareConcurrency; } function Br(N, D) { var B = arguments.length - 2, Q = arguments; return _i(function() { for (var ue = B, pe = Pi(ue * 8), ye = pe >> 3, Te = 0; Te < B; Te++) { var bt = Q[2 + Te]; p()[ye + Te] = bt; } return Jv(N, ue, pe, D); }); } var yu = []; function _h(N, D, B) { yu.length = D; for (var Q = B >> 3, ue = 0; ue < D; ue++) yu[ue] = p()[Q + ue]; var pe = N < 0, ye = pe ? lh[-N - 1] : Kh[N]; return ye.apply(null, yu); } function Ah(N) { try { return Ce.grow(N - tn.byteLength + 65535 >>> 16), rs(Ce.buffer), 1; } catch (D) { } } function Eh(N) { var D = i().length; if (N = N >>> 0, N <= D) return false; var B = Sc(); if (N > B) return false; for (var Q = 1; Q <= 4; Q *= 2) { var ue = D * (1 + 0.2 / Q); ue = Math.min(ue, N + 100663296); var pe = Math.min(B, Ci(Math.max(N, ue), 65536)), ye = Ah(pe); if (ye) return true; } return false; } var Be = { inEventHandler: 0, removeAllEventListeners: function() { for (var N = Be.eventHandlers.length - 1; N >= 0; --N) Be._removeHandler(N); Be.eventHandlers = [], Be.deferredCalls = []; }, registerRemoveEventListeners: function() { Be.removeEventListenersRegistered || (sh.push(Be.removeAllEventListeners), Be.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(N, D, B) { function Q(ye, Te) { if (ye.length != Te.length) return false; for (var bt in ye) if (ye[bt] != Te[bt]) return false; return true; } for (var ue in Be.deferredCalls) { var pe = Be.deferredCalls[ue]; if (pe.targetFunction == N && Q(pe.argsList, B)) return; } Be.deferredCalls.push({ targetFunction: N, precedence: D, argsList: B }), Be.deferredCalls.sort(function(ye, Te) { return ye.precedence < Te.precedence; }); }, removeDeferredCalls: function(N) { for (var D = 0; D < Be.deferredCalls.length; ++D) Be.deferredCalls[D].targetFunction == N && (Be.deferredCalls.splice(D, 1), --D); }, canPerformEventHandlerRequests: function() { return Be.inEventHandler && Be.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { if (!!Be.canPerformEventHandlerRequests()) for (var N = 0; N < Be.deferredCalls.length; ++N) { var D = Be.deferredCalls[N]; Be.deferredCalls.splice(N, 1), --N, D.targetFunction.apply(null, D.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(N, D) { for (var B = 0; B < Be.eventHandlers.length; ++B) Be.eventHandlers[B].target == N && (!D || D == Be.eventHandlers[B].eventTypeString) && Be._removeHandler(B--); }, _removeHandler: function(N) { var D = Be.eventHandlers[N]; D.target.removeEventListener(D.eventTypeString, D.eventListenerFunc, D.useCapture), Be.eventHandlers.splice(N, 1); }, registerOrRemoveHandler: function(N) { var D = function(ue) { ++Be.inEventHandler, Be.currentEventHandler = N, Be.runDeferredCalls(), N.handlerFunc(ue), Be.runDeferredCalls(), --Be.inEventHandler; }; if (N.callbackfunc) N.eventListenerFunc = D, N.target.addEventListener(N.eventTypeString, D, N.useCapture), Be.eventHandlers.push(N), Be.registerRemoveEventListeners(); else for (var B = 0; B < Be.eventHandlers.length; ++B) Be.eventHandlers[B].target == N.target && Be.eventHandlers[B].eventTypeString == N.eventTypeString && Be._removeHandler(B--); }, queueEventHandlerOnThread_iiii: function(N, D, B, Q, ue) { _i(function() { var pe = Pi(12); l()[pe >> 2] = B, l()[pe + 4 >> 2] = Q, l()[pe + 8 >> 2] = ue, Ef(N, 637534208, D, Q, pe); }); }, getTargetThreadForEventCallback: function(N) { switch (N) { case 1: return 0; case 2: return _e.currentProxiedOperationCallerThread; default: return N; } }, getNodeNameForTarget: function(N) { return N ? N == window ? "#window" : N == screen ? "#screen" : N && N.nodeName ? N.nodeName : "" : ""; }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; function Rh(N) { var D = Si(N) + 1, B = Af(D); return Ls(N, B, D), B; } function Dh(N, D, B, Q) { _i(function() { var ue = Pi(12), pe = 0; D && (pe = Rh(D)), l()[ue >> 2] = pe, l()[ue + 4 >> 2] = B, l()[ue + 8 >> 2] = Q, Ef(N, 657457152, 0, pe, ue); }); } function Fh(N, D, B, Q) { D = D ? en(D) : "", Dh(N, D, B, Q); } function Oh(N) { return N > 2 ? en(N) : N; } var Ph = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; function zh(N) { N = Oh(N); var D = Ph[N] || (typeof document != "undefined" ? document.querySelector(N) : void 0); return D; } function vu(N) { return zh(N); } function Cc(N, D, B) { var Q = vu(N); if (!Q) return -4; if (Q.canvasSharedPtr && (l()[Q.canvasSharedPtr >> 2] = D, l()[Q.canvasSharedPtr + 4 >> 2] = B), Q.offscreenCanvas || !Q.controlTransferredOffscreen) { Q.offscreenCanvas && (Q = Q.offscreenCanvas); var ue = false; if (Q.GLctxObject && Q.GLctxObject.GLctx) { var pe = Q.GLctxObject.GLctx.getParameter(2978); ue = pe[0] === 0 && pe[1] === 0 && pe[2] === Q.width && pe[3] === Q.height; } Q.width = D, Q.height = B, ue && Q.GLctxObject.GLctx.viewport(0, 0, D, B); } else if (Q.canvasSharedPtr) { var ye = l()[Q.canvasSharedPtr + 8 >> 2]; return Fh(ye, N, D, B), 1; } else return -4; return 0; } function Nc(N, D, B) { return $ ? Br(2, 1, N, D, B) : Cc(N, D, B); } function Mh(N, D, B) { var Q = vu(N); return Q ? Cc(N, D, B) : Nc(N, D, B); } function Lh() { throw "unwind"; } function Bh(N) { var D = N.getExtension("ANGLE_instanced_arrays"); if (D) return N.vertexAttribDivisor = function(B, Q) { D.vertexAttribDivisorANGLE(B, Q); }, N.drawArraysInstanced = function(B, Q, ue, pe) { D.drawArraysInstancedANGLE(B, Q, ue, pe); }, N.drawElementsInstanced = function(B, Q, ue, pe, ye) { D.drawElementsInstancedANGLE(B, Q, ue, pe, ye); }, 1; } function Vh(N) { var D = N.getExtension("OES_vertex_array_object"); if (D) return N.createVertexArray = function() { return D.createVertexArrayOES(); }, N.deleteVertexArray = function(B) { D.deleteVertexArrayOES(B); }, N.bindVertexArray = function(B) { D.bindVertexArrayOES(B); }, N.isVertexArray = function(B) { return D.isVertexArrayOES(B); }, 1; } function Wh(N) { var D = N.getExtension("WEBGL_draw_buffers"); if (D) return N.drawBuffers = function(B, Q) { D.drawBuffersWEBGL(B, Q); }, 1; } function Uh(N) { return !!(N.multiDrawWebgl = N.getExtension("WEBGL_multi_draw")); } var gt = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, queries: [], stringCache: {}, unpackAlignment: 4, recordError: function(D) { gt.lastError || (gt.lastError = D); }, getNewId: function(N) { for (var D = gt.counter++, B = N.length; B < D; B++) N[B] = null; return D; }, getSource: function(N, D, B, Q) { for (var ue = "", pe = 0; pe < D; ++pe) { var ye = Q ? l()[Q + pe * 4 >> 2] : -1; ue += en(l()[B + pe * 4 >> 2], ye < 0 ? void 0 : ye); } return ue; }, createContext: function(N, D) { N.getContextSafariWebGL2Fixed || (N.getContextSafariWebGL2Fixed = N.getContext, N.getContext = function(ue, pe) { var ye = N.getContextSafariWebGL2Fixed(ue, pe); return ue == "webgl" == ye instanceof WebGLRenderingContext ? ye : null; }); var B = N.getContext("webgl", D); if (!B) return 0; var Q = gt.registerContext(B, D); return Q; }, registerContext: function(N, D) { var B = Af(8); l()[B + 4 >> 2] = Oc(); var Q = { handle: B, attributes: D, version: D.majorVersion, GLctx: N }; return N.canvas && (N.canvas.GLctxObject = Q), gt.contexts[B] = Q, (typeof D.enableExtensionsByDefault == "undefined" || D.enableExtensionsByDefault) && gt.initExtensions(Q), B; }, makeContextCurrent: function(N) { return gt.currentContext = gt.contexts[N], d.ctx = Ac = gt.currentContext && gt.currentContext.GLctx, !(N && !Ac); }, getContext: function(N) { return gt.contexts[N]; }, deleteContext: function(N) { gt.currentContext === gt.contexts[N] && (gt.currentContext = null), typeof Be == "object" && Be.removeAllHandlersOnTarget(gt.contexts[N].GLctx.canvas), gt.contexts[N] && gt.contexts[N].GLctx.canvas && (gt.contexts[N].GLctx.canvas.GLctxObject = void 0), Kv(gt.contexts[N].handle), gt.contexts[N] = null; }, initExtensions: function(N) { if (N || (N = gt.currentContext), !N.initExtensionsDone) { N.initExtensionsDone = true; var D = N.GLctx; Bh(D), Vh(D), Wh(D), D.disjointTimerQueryExt = D.getExtension("EXT_disjoint_timer_query"), Uh(D); var B = D.getSupportedExtensions() || []; B.forEach(function(Q) { !Q.includes("lose_context") && !Q.includes("debug") && D.getExtension(Q); }); } } }, Gh = ["default", "low-power", "high-performance"]; function Hh(N, D) { var B = D >> 2, Q = l()[B + 6], ue = { alpha: !!l()[B + 0], depth: !!l()[B + 1], stencil: !!l()[B + 2], antialias: !!l()[B + 3], premultipliedAlpha: !!l()[B + 4], preserveDrawingBuffer: !!l()[B + 5], powerPreference: Gh[Q], failIfMajorPerformanceCaveat: !!l()[B + 7], majorVersion: l()[B + 8], minorVersion: l()[B + 9], enableExtensionsByDefault: l()[B + 10], explicitSwapControl: l()[B + 11], proxyContextToMainThread: l()[B + 12], renderViaOffscreenBackBuffer: l()[B + 13] }, pe = vu(N); if (!pe || ue.explicitSwapControl) return 0; var ye = gt.createContext(pe, ue); return ye; } function qh(N, D) { return Hh(N, D); } var Ei = { mappings: {}, buffers: [null, [], []], printChar: function(N, D) { var B = Ei.buffers[N]; D === 0 || D === 10 ? ((N === 1 ? te : ee)(Dn(B, 0)), B.length = 0) : B.push(D); }, varargs: void 0, get: function() { Ei.varargs += 4; var N = l()[Ei.varargs - 4 >> 2]; return N; }, getStr: function(N) { var D = en(N); return D; }, get64: function(N, D) { return N; } }; function Tc(N) { return $ ? Br(3, 1, N) : 0; } function $c(N, D, B, Q, ue) { if ($) return Br(4, 1, N, D, B, Q, ue); } function _c(N, D, B, Q) { if ($) return Br(5, 1, N, D, B, Q); for (var ue = 0, pe = 0; pe < B; pe++) { var ye = l()[D >> 2], Te = l()[D + 4 >> 2]; D += 8; for (var bt = 0; bt < Te; bt++) Ei.printChar(N, i()[ye + bt]); ue += Te; } return l()[Q >> 2] = ue, 0; } function jh(N) { Ee(N); } _e.init(); var Ac, Kh = [null, kc, Nc, Tc, $c, _c], Hv = false, Ec = { __clock_gettime: vh, __emscripten_init_main_thread_js: xh, __emscripten_thread_cleanup: wh, __pthread_create_js: kh, _emscripten_default_pthread_stack_size: Ih, _emscripten_notify_thread_queue: Sh, abort: Ch, emscripten_check_blocking_allowed: Nh, emscripten_get_heap_max: Sc, emscripten_get_now: Lr, emscripten_memcpy_big: Th, emscripten_num_logical_cores: $h, emscripten_receive_on_main_thread_js: _h, emscripten_resize_heap: Eh, emscripten_set_canvas_element_size: Mh, emscripten_unwind_to_js_event_loop: Lh, emscripten_webgl_create_context: qh, exit: wc, fd_close: Tc, fd_seek: $c, fd_write: _c, memory: Ce || d.wasmMemory, setTempRet0: jh }, qv = uh(), Xh = d.___wasm_call_ctors = function() { return (Xh = d.___wasm_call_ctors = d.asm.__wasm_call_ctors).apply(null, arguments); }, Yh = d._init = function() { return (Yh = d._init = d.asm.init).apply(null, arguments); }, Qh = d._init_with_threads_count = function() { return (Qh = d._init_with_threads_count = d.asm.init_with_threads_count).apply(null, arguments); }, Zh = d._get_threads_count = function() { return (Zh = d._get_threads_count = d.asm.get_threads_count).apply(null, arguments); }, Jh = d._register_tensor = function() { return (Jh = d._register_tensor = d.asm.register_tensor).apply(null, arguments); }, ef = d._dispose_data = function() { return (ef = d._dispose_data = d.asm.dispose_data).apply(null, arguments); }, tf = d._dispose = function() { return (tf = d._dispose = d.asm.dispose).apply(null, arguments); }, nf = d._Abs = function() { return (nf = d._Abs = d.asm.Abs).apply(null, arguments); }, sf = d._Add = function() { return (sf = d._Add = d.asm.Add).apply(null, arguments); }, rf = d._AddN = function() { return (rf = d._AddN = d.asm.AddN).apply(null, arguments); }, af = d._All = function() { return (af = d._All = d.asm.All).apply(null, arguments); }, of = d._Any = function() { return (of = d._Any = d.asm.Any).apply(null, arguments); }, uf = d._ArgMax = function() { return (uf = d._ArgMax = d.asm.ArgMax).apply(null, arguments); }, lf = d._AvgPool = function() { return (lf = d._AvgPool = d.asm.AvgPool).apply(null, arguments); }, cf = d._BatchMatMul = function() { return (cf = d._BatchMatMul = d.asm.BatchMatMul).apply(null, arguments); }, df = d._Ceil = function() { return (df = d._Ceil = d.asm.Ceil).apply(null, arguments); }, pf = d._ClipByValue = function() { return (pf = d._ClipByValue = d.asm.ClipByValue).apply(null, arguments); }, hf = d._Conv2D = function() { return (hf = d._Conv2D = d.asm.Conv2D).apply(null, arguments); }, ff = d._Conv2DBackpropInput = function() { return (ff = d._Conv2DBackpropInput = d.asm.Conv2DBackpropInput).apply(null, arguments); }, mf = d._Cos = function() { return (mf = d._Cos = d.asm.Cos).apply(null, arguments); }, gf = d._Cosh = function() { return (gf = d._Cosh = d.asm.Cosh).apply(null, arguments); }, bf = d._CropAndResize = function() { return (bf = d._CropAndResize = d.asm.CropAndResize).apply(null, arguments); }, yf = d._Cumprod = function() { return (yf = d._Cumprod = d.asm.Cumprod).apply(null, arguments); }, vf = d._Cumsum = function() { return (vf = d._Cumsum = d.asm.Cumsum).apply(null, arguments); }, xf = d._DepthToSpace = function() { return (xf = d._DepthToSpace = d.asm.DepthToSpace).apply(null, arguments); }, wf = d._DepthwiseConv2dNative = function() { return (wf = d._DepthwiseConv2dNative = d.asm.DepthwiseConv2dNative).apply(null, arguments); }, kf = d._Elu = function() { return (kf = d._Elu = d.asm.Elu).apply(null, arguments); }, If = d._Equal = function() { return (If = d._Equal = d.asm.Equal).apply(null, arguments); }, Sf = d._Exp = function() { return (Sf = d._Exp = d.asm.Exp).apply(null, arguments); }, Cf = d._FlipLeftRight = function() { return (Cf = d._FlipLeftRight = d.asm.FlipLeftRight).apply(null, arguments); }, Rc = d._Floor = function() { return (Rc = d._Floor = d.asm.Floor).apply(null, arguments); }, Dc = d._FloorDiv = function() { return (Dc = d._FloorDiv = d.asm.FloorDiv).apply(null, arguments); }, xu = d._FusedBatchNorm = function() { return (xu = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); }, Nf = d._FusedConv2D = function() { return (Nf = d._FusedConv2D = d.asm.FusedConv2D).apply(null, arguments); }, Tf = d._FusedDepthwiseConv2D = function() { return (Tf = d._FusedDepthwiseConv2D = d.asm.FusedDepthwiseConv2D).apply(null, arguments); }, Ri = d._Gather = function() { return (Ri = d._Gather = d.asm.Gather).apply(null, arguments); }, wu = d._GatherNd = function() { return (wu = d._GatherNd = d.asm.GatherNd).apply(null, arguments); }, ku = d._Greater = function() { return (ku = d._Greater = d.asm.Greater).apply(null, arguments); }, jv = d._GreaterEqual = function() { return (jv = d._GreaterEqual = d.asm.GreaterEqual).apply(null, arguments); }, Di = d._LeakyRelu = function() { return (Di = d._LeakyRelu = d.asm.LeakyRelu).apply(null, arguments); }, Fi = d._Less = function() { return (Fi = d._Less = d.asm.Less).apply(null, arguments); }, $f = d._LessEqual = function() { return ($f = d._LessEqual = d.asm.LessEqual).apply(null, arguments); }, H = d._Log = function() { return (H = d._Log = d.asm.Log).apply(null, arguments); }, J = d._LogicalAnd = function() { return (J = d._LogicalAnd = d.asm.LogicalAnd).apply(null, arguments); }, de = d._Max = function() { return (de = d._Max = d.asm.Max).apply(null, arguments); }, Ie = d._MaxPool = function() { return (Ie = d._MaxPool = d.asm.MaxPool).apply(null, arguments); }, Qe = d._Maximum = function() { return (Qe = d._Maximum = d.asm.Maximum).apply(null, arguments); }, Ze = d._Mean = function() { return (Ze = d._Mean = d.asm.Mean).apply(null, arguments); }, Ve = d._Min = function() { return (Ve = d._Min = d.asm.Min).apply(null, arguments); }, ze = d._Minimum = function() { return (ze = d._Minimum = d.asm.Minimum).apply(null, arguments); }, Tt = d._MirrorPad = function() { return (Tt = d._MirrorPad = d.asm.MirrorPad).apply(null, arguments); }, is = d._Multiply = function() { return (is = d._Multiply = d.asm.Multiply).apply(null, arguments); }, os = d._Neg = function() { return (os = d._Neg = d.asm.Neg).apply(null, arguments); }, Oi = d._NonMaxSuppressionV3 = function() { return (Oi = d._NonMaxSuppressionV3 = d.asm.NonMaxSuppressionV3).apply(null, arguments); }, Vr = d._NonMaxSuppressionV4 = function() { return (Vr = d._NonMaxSuppressionV4 = d.asm.NonMaxSuppressionV4).apply(null, arguments); }, _f = d._NonMaxSuppressionV5 = function() { return (_f = d._NonMaxSuppressionV5 = d.asm.NonMaxSuppressionV5).apply(null, arguments); }, rn = d._NotEqual = function() { return (rn = d._NotEqual = d.asm.NotEqual).apply(null, arguments); }, sr = d._OneHot = function() { return (sr = d._OneHot = d.asm.OneHot).apply(null, arguments); }, Fc = d._PadV2 = function() { return (Fc = d._PadV2 = d.asm.PadV2).apply(null, arguments); }, ZN = d._Pow = function() { return (ZN = d._Pow = d.asm.Pow).apply(null, arguments); }, JN = d._Prelu = function() { return (JN = d._Prelu = d.asm.Prelu).apply(null, arguments); }, eT = d._Prod = function() { return (eT = d._Prod = d.asm.Prod).apply(null, arguments); }, tT = d._RealDiv = function() { return (tT = d._RealDiv = d.asm.RealDiv).apply(null, arguments); }, nT = d._Relu = function() { return (nT = d._Relu = d.asm.Relu).apply(null, arguments); }, sT = d._Relu6 = function() { return (sT = d._Relu6 = d.asm.Relu6).apply(null, arguments); }, rT = d._ResizeBilinear = function() { return (rT = d._ResizeBilinear = d.asm.ResizeBilinear).apply(null, arguments); }, aT = d._Reverse = function() { return (aT = d._Reverse = d.asm.Reverse).apply(null, arguments); }, iT = d._RotateWithOffset = function() { return (iT = d._RotateWithOffset = d.asm.RotateWithOffset).apply(null, arguments); }, oT = d._Round = function() { return (oT = d._Round = d.asm.Round).apply(null, arguments); }, uT = d._Rsqrt = function() { return (uT = d._Rsqrt = d.asm.Rsqrt).apply(null, arguments); }, lT = d._ScatterNd = function() { return (lT = d._ScatterNd = d.asm.ScatterNd).apply(null, arguments); }, cT = d._SelectV2 = function() { return (cT = d._SelectV2 = d.asm.SelectV2).apply(null, arguments); }, dT = d._Sigmoid = function() { return (dT = d._Sigmoid = d.asm.Sigmoid).apply(null, arguments); }, pT = d._Sin = function() { return (pT = d._Sin = d.asm.Sin).apply(null, arguments); }, hT = d._Softmax = function() { return (hT = d._Softmax = d.asm.Softmax).apply(null, arguments); }, fT = d._SparseFillEmptyRows = function() { return (fT = d._SparseFillEmptyRows = d.asm.SparseFillEmptyRows).apply(null, arguments); }, mT = d._SparseReshape = function() { return (mT = d._SparseReshape = d.asm.SparseReshape).apply(null, arguments); }, gT = d._SparseSegmentReduction = function() { return (gT = d._SparseSegmentReduction = d.asm.SparseSegmentReduction).apply(null, arguments); }, bT = d._Sqrt = function() { return (bT = d._Sqrt = d.asm.Sqrt).apply(null, arguments); }, yT = d._Square = function() { return (yT = d._Square = d.asm.Square).apply(null, arguments); }, vT = d._SquaredDifference = function() { return (vT = d._SquaredDifference = d.asm.SquaredDifference).apply(null, arguments); }, xT = d._Step = function() { return (xT = d._Step = d.asm.Step).apply(null, arguments); }, wT = d._StridedSlice = function() { return (wT = d._StridedSlice = d.asm.StridedSlice).apply(null, arguments); }, kT = d._Sub = function() { return (kT = d._Sub = d.asm.Sub).apply(null, arguments); }, IT = d._Sum = function() { return (IT = d._Sum = d.asm.Sum).apply(null, arguments); }, ST = d._Tan = function() { return (ST = d._Tan = d.asm.Tan).apply(null, arguments); }, CT = d._Tanh = function() { return (CT = d._Tanh = d.asm.Tanh).apply(null, arguments); }, NT = d._Tile = function() { return (NT = d._Tile = d.asm.Tile).apply(null, arguments); }, TT = d._TopK = function() { return (TT = d._TopK = d.asm.TopK).apply(null, arguments); }, $T = d._Transform = function() { return ($T = d._Transform = d.asm.Transform).apply(null, arguments); }, _T = d._Transpose = function() { return (_T = d._Transpose = d.asm.Transpose).apply(null, arguments); }, AT = d.__FusedMatMul = function() { return (AT = d.__FusedMatMul = d.asm._FusedMatMul).apply(null, arguments); }, Af = d._malloc = function() { return (Af = d._malloc = d.asm.malloc).apply(null, arguments); }, Kv = d._free = function() { return (Kv = d._free = d.asm.free).apply(null, arguments); }, ET = d._emscripten_tls_init = function() { return (ET = d._emscripten_tls_init = d.asm.emscripten_tls_init).apply(null, arguments); }, Xv = d.___errno_location = function() { return (Xv = d.___errno_location = d.asm.__errno_location).apply(null, arguments); }, Oc = d._pthread_self = function() { return (Oc = d._pthread_self = d.asm.pthread_self).apply(null, arguments); }, Yv = d._emscripten_main_thread_process_queued_calls = function() { return (Yv = d._emscripten_main_thread_process_queued_calls = d.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); }, RT = d.__emscripten_thread_crashed = function() { return (RT = d.__emscripten_thread_crashed = d.asm._emscripten_thread_crashed).apply(null, arguments); }, Qv = d.__emscripten_thread_init = function() { return (Qv = d.__emscripten_thread_init = d.asm._emscripten_thread_init).apply(null, arguments); }, DT = d._emscripten_current_thread_process_queued_calls = function() { return (DT = d._emscripten_current_thread_process_queued_calls = d.asm.emscripten_current_thread_process_queued_calls).apply(null, arguments); }, FT = d._emscripten_main_browser_thread_id = function() { return (FT = d._emscripten_main_browser_thread_id = d.asm.emscripten_main_browser_thread_id).apply(null, arguments); }, OT = d._emscripten_sync_run_in_main_thread_2 = function() { return (OT = d._emscripten_sync_run_in_main_thread_2 = d.asm.emscripten_sync_run_in_main_thread_2).apply(null, arguments); }, Zv = d._emscripten_sync_run_in_main_thread_4 = function() { return (Zv = d._emscripten_sync_run_in_main_thread_4 = d.asm.emscripten_sync_run_in_main_thread_4).apply(null, arguments); }, Jv = d._emscripten_run_in_main_runtime_thread_js = function() { return (Jv = d._emscripten_run_in_main_runtime_thread_js = d.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments); }, Ef = d._emscripten_dispatch_to_thread_ = function() { return (Ef = d._emscripten_dispatch_to_thread_ = d.asm.emscripten_dispatch_to_thread_).apply(null, arguments); }, Rf = d.__emscripten_thread_free_data = function() { return (Rf = d.__emscripten_thread_free_data = d.asm._emscripten_thread_free_data).apply(null, arguments); }, PT = d.__emscripten_thread_exit = function() { return (PT = d.__emscripten_thread_exit = d.asm._emscripten_thread_exit).apply(null, arguments); }, zT = d._memalign = function() { return (zT = d._memalign = d.asm.memalign).apply(null, arguments); }, ex = d._emscripten_stack_set_limits = function() { return (ex = d._emscripten_stack_set_limits = d.asm.emscripten_stack_set_limits).apply(null, arguments); }, Df = d.stackSave = function() { return (Df = d.stackSave = d.asm.stackSave).apply(null, arguments); }, Pc = d.stackRestore = function() { return (Pc = d.stackRestore = d.asm.stackRestore).apply(null, arguments); }, Pi = d.stackAlloc = function() { return (Pi = d.stackAlloc = d.asm.stackAlloc).apply(null, arguments); }, MT = d.dynCall_iijjiiii = function() { return (MT = d.dynCall_iijjiiii = d.asm.dynCall_iijjiiii).apply(null, arguments); }, LT = d.dynCall_jiji = function() { return (LT = d.dynCall_jiji = d.asm.dynCall_jiji).apply(null, arguments); }, tx = d.__emscripten_allow_main_runtime_queued_calls = 21456; d.cwrap = Jt, d.keepRuntimeAlive = zr, d.PThread = _e, d.PThread = _e, d.wasmMemory = Ce, d.ExitStatus = Iu; var zc; function Iu(N) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + N + ")", this.status = N; } as = function N() { zc || Ff(), zc || (as = N); }; function Ff(N) { if (N = N || b, nr > 0) return; if ($) { h(d), mu(), postMessage({ cmd: "loaded" }); return; } if (nn(), nr > 0) return; function D() { zc || (zc = true, d.calledRun = true, !rt && (mu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), ih())); } d.setStatus ? (d.setStatus("Running..."), setTimeout(function() { setTimeout(function() { d.setStatus(""); }, 1), D(); }, 1)) : D(); } d.run = Ff; function BT(N, D) { if (Zt = N, !D && $) throw kc(N), "unwind"; zr() || ah(), VT(N); } function VT(N) { Zt = N, zr() || (_e.terminateAllThreads(), d.onExit && d.onExit(N), rt = true), v(N, new Iu(N)); } if (d.preInit) for (typeof d.preInit == "function" && (d.preInit = [d.preInit]); d.preInit.length > 0; ) d.preInit.pop()(); Ff(); var Mc; m && (Mc = { uncaughtException: process.listeners("uncaughtException").filter(function(N) { return !m.uncaughtException.indexOf(N) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(N) { return !m.unhandledRejection.indexOf(N) > -1; }) }); var Lc; if (typeof WasmBackendModule != "undefined") Lc = WasmBackendModule; else if (typeof r != "undefined") Lc = r; else throw new Error("Could not find wasm module in post.js"); if (Mc) { var WT = Lc._dispose; Lc._dispose = function() { WT(), Mc.uncaughtException.forEach(function(N) { process.removeListener("uncaughtException", N); }), Mc.unhandledRejection.forEach(function(N) { process.removeListener("unhandledRejection", N); }); }; } return r.ready; }; })(); typeof e == "object" && typeof t == "object" ? t.exports = n : typeof define == "function" && define.amd ? define([], function() { return n; }) : typeof e == "object" && (e.WasmBackendModuleThreadedSimd = n); } }); var d$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { var n = (() => { var s = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (s = s || __filename), function(r) { r = r || {}; var a = typeof r != "undefined" ? r : {}, i, o; a.ready = new Promise(function(H, J) { i = H, o = J; }); var u; typeof process != "undefined" && process.listeners && (u = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var l = Object.assign({}, a), c = [], p = "./this.program", d = (H, J) => { throw J; }, h = typeof window == "object", f = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", g = ""; function b(H) { return a.locateFile ? a.locateFile(H, g) : g + H; } var y, v, x, k; function S(H) { if (H instanceof wu) return; R("exiting due to exception: " + H); } var $, E, A; m ? (f ? g = dd().dirname(g) + "/" : g = __dirname + "/", A = () => { E || ($ = sg(), E = dd()); }, y = function(J, de) { return A(), J = E.normalize(J), $.readFileSync(J, de ? void 0 : "utf8"); }, x = (H) => { var J = y(H, true); return J.buffer || (J = new Uint8Array(J)), J; }, v = (H, J, de) => { A(), H = E.normalize(H), $.readFile(H, function(Ie, Qe) { Ie ? de(Ie) : J(Qe.buffer); }); }, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), c = process.argv.slice(2), process.on("uncaughtException", function(H) { if (!(H instanceof wu)) throw H; }), process.on("unhandledRejection", function(H) { throw H; }), d = (H, J) => { if (fu()) throw process.exitCode = H, J; S(J), process.exit(H); }, a.inspect = function() { return "[Emscripten Module object]"; }) : (h || f) && (f ? g = self.location.href : typeof document != "undefined" && document.currentScript && (g = document.currentScript.src), s && (g = s), g.indexOf("blob:") !== 0 ? g = g.substr(0, g.replace(/[?#].*/, "").lastIndexOf("/") + 1) : g = "", y = (H) => { var J = new XMLHttpRequest(); return J.open("GET", H, false), J.send(null), J.responseText; }, f && (x = (H) => { var J = new XMLHttpRequest(); return J.open("GET", H, false), J.responseType = "arraybuffer", J.send(null), new Uint8Array(J.response); }), v = (H, J, de) => { var Ie = new XMLHttpRequest(); Ie.open("GET", H, true), Ie.responseType = "arraybuffer", Ie.onload = () => { if (Ie.status == 200 || Ie.status == 0 && Ie.response) { J(Ie.response); return; } de(); }, Ie.onerror = de, Ie.send(null); }, k = (H) => document.title = H); var P = a.print || console.log.bind(console), R = a.printErr || console.warn.bind(console); Object.assign(a, l), l = null, a.arguments && (c = a.arguments), a.thisProgram && (p = a.thisProgram), a.quit && (d = a.quit); var F = 4; function T(H) { T.shown || (T.shown = {}), T.shown[H] || (T.shown[H] = 1, R(H)); } function z(H, J) { if (typeof WebAssembly.Function == "function") { for (var de = { i: "i32", j: "i64", f: "f32", d: "f64" }, Ie = { parameters: [], results: J[0] == "v" ? [] : [de[J[0]]] }, Qe = 1; Qe < J.length; ++Qe) Ie.parameters.push(de[J[Qe]]); return new WebAssembly.Function(Ie, H); } var Ze = [1, 0, 1, 96], Ve = J.slice(0, 1), ze = J.slice(1), Tt = { i: 127, j: 126, f: 125, d: 124 }; Ze.push(ze.length); for (var Qe = 0; Qe < ze.length; ++Qe) Ze.push(Tt[ze[Qe]]); Ve == "v" ? Ze.push(0) : Ze = Ze.concat([1, Tt[Ve]]), Ze[1] = Ze.length - 2; var is = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(Ze, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), os = new WebAssembly.Module(is), Oi = new WebAssembly.Instance(os, { e: { f: H } }), Vr = Oi.exports.f; return Vr; } var W = [], q; function K() { if (W.length) return W.pop(); try { er.grow(1); } catch (H) { throw H instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : H; } return er.length - 1; } function Y(H, J) { for (var de = H; de < H + J; de++) { var Ie = bu(de); Ie && q.set(Ie, de); } } var Z = 0, te = (H) => { Z = H; }, ee; a.wasmBinary && (ee = a.wasmBinary); var se = a.noExitRuntime || true; typeof WebAssembly != "object" && Pr("no native wasm support detected"); var ne, oe = false, re; function le(H, J) { H || Pr(J); } function me(H) { var J = a["_" + H]; return J; } function ke(H, J, de, Ie, Qe) { var Ze = { string: function(rn) { var sr = 0; if (rn != null && rn !== 0) { var Fc = (rn.length << 2) + 1; sr = xu(Fc), tt(rn, sr, Fc); } return sr; }, array: function(rn) { var sr = xu(rn.length); return rt(rn, sr), sr; } }; function Ve(rn) { return J === "string" ? Je(rn) : J === "boolean" ? Boolean(rn) : rn; } var ze = me(H), Tt = [], is = 0; if (Ie) for (var os = 0; os < Ie.length; os++) { var Oi = Ze[de[os]]; Oi ? (is === 0 && (is = Rc()), Tt[os] = Oi(Ie[os])) : Tt[os] = Ie[os]; } var Vr = ze.apply(null, Tt); function _f(rn) { return is !== 0 && Dc(is), Ve(rn); } return Vr = _f(Vr), Vr; } function Se(H, J, de, Ie) { de = de || []; var Qe = de.every(function(Ve) { return Ve === "number"; }), Ze = J !== "string"; return Ze && Qe && !Ie ? me(H) : function() { return ke(H, J, de, arguments, Ie); }; } var Ee = 1, Pe = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; function Xe(H, J, de) { for (var Ie = J + de, Qe = J; H[Qe] && !(Qe >= Ie); ) ++Qe; if (Qe - J > 16 && H.subarray && Pe) return Pe.decode(H.subarray(J, Qe)); for (var Ze = ""; J < Qe; ) { var Ve = H[J++]; if (!(Ve & 128)) { Ze += String.fromCharCode(Ve); continue; } var ze = H[J++] & 63; if ((Ve & 224) == 192) { Ze += String.fromCharCode((Ve & 31) << 6 | ze); continue; } var Tt = H[J++] & 63; if ((Ve & 240) == 224 ? Ve = (Ve & 15) << 12 | ze << 6 | Tt : Ve = (Ve & 7) << 18 | ze << 12 | Tt << 6 | H[J++] & 63, Ve < 65536) Ze += String.fromCharCode(Ve); else { var is = Ve - 65536; Ze += String.fromCharCode(55296 | is >> 10, 56320 | is & 1023); } } return Ze; } function Je(H, J) { return H ? Xe(Jt, H, J) : ""; } function Ye(H, J, de, Ie) { if (!(Ie > 0)) return 0; for (var Qe = de, Ze = de + Ie - 1, Ve = 0; Ve < H.length; ++Ve) { var ze = H.charCodeAt(Ve); if (ze >= 55296 && ze <= 57343) { var Tt = H.charCodeAt(++Ve); ze = 65536 + ((ze & 1023) << 10) | Tt & 1023; } if (ze <= 127) { if (de >= Ze) break; J[de++] = ze; } else if (ze <= 2047) { if (de + 1 >= Ze) break; J[de++] = 192 | ze >> 6, J[de++] = 128 | ze & 63; } else if (ze <= 65535) { if (de + 2 >= Ze) break; J[de++] = 224 | ze >> 12, J[de++] = 128 | ze >> 6 & 63, J[de++] = 128 | ze & 63; } else { if (de + 3 >= Ze) break; J[de++] = 240 | ze >> 18, J[de++] = 128 | ze >> 12 & 63, J[de++] = 128 | ze >> 6 & 63, J[de++] = 128 | ze & 63; } } return J[de] = 0, de - Qe; } function tt(H, J, de) { return Ye(H, Jt, J, de); } function Ce(H) { for (var J = 0, de = 0; de < H.length; ++de) { var Ie = H.charCodeAt(de); Ie >= 55296 && Ie <= 57343 && (Ie = 65536 + ((Ie & 1023) << 10) | H.charCodeAt(++de) & 1023), Ie <= 127 ? ++J : Ie <= 2047 ? J += 2 : Ie <= 65535 ? J += 3 : J += 4; } return J; } var ut = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : void 0; function rt(H, J) { Et.set(H, J); } function Zt(H, J, de) { for (var Ie = 0; Ie < H.length; ++Ie) Et[J++ >> 0] = H.charCodeAt(Ie); de || (Et[J >> 0] = 0); } function Nt(H, J) { return H % J > 0 && (H += J - H % J), H; } var Sn, Et, Jt, Cn, Nn, Xt, Dn, en, Ms; function Ls(H) { Sn = H, a.HEAP8 = Et = new Int8Array(H), a.HEAP16 = Cn = new Int16Array(H), a.HEAP32 = Xt = new Int32Array(H), a.HEAPU8 = Jt = new Uint8Array(H), a.HEAPU16 = Nn = new Uint16Array(H), a.HEAPU32 = Dn = new Uint32Array(H), a.HEAPF32 = en = new Float32Array(H), a.HEAPF64 = Ms = new Float64Array(H); } var Si = a.INITIAL_MEMORY || 16777216, er, Bs = [], hu = [], Ci = [], tn = false, ic = false, oc = 0; function fu() { return se || oc > 0; } function uc() { if (a.preRun) for (typeof a.preRun == "function" && (a.preRun = [a.preRun]); a.preRun.length; ) dc(a.preRun.shift()); gu(Bs); } function lc() { tn = true, gu(hu); } function Pv() { ic = true; } function cc() { if (a.postRun) for (typeof a.postRun == "function" && (a.postRun = [a.postRun]); a.postRun.length; ) pc(a.postRun.shift()); gu(Ci); } function dc(H) { Bs.unshift(H); } function rs(H) { hu.unshift(H); } function pc(H) { Ci.unshift(H); } var Fn = 0, Ni = null, tr = null; function sh(H) { Fn++, a.monitorRunDependencies && a.monitorRunDependencies(Fn); } function hc(H) { if (Fn--, a.monitorRunDependencies && a.monitorRunDependencies(Fn), Fn == 0 && (Ni !== null && (clearInterval(Ni), Ni = null), tr)) { var J = tr; tr = null, J(); } } a.preloadedImages = {}, a.preloadedAudios = {}; function Pr(H) { a.onAbort && a.onAbort(H), H = "Aborted(" + H + ")", R(H), oe = true, re = 1, H += ". Build with -s ASSERTIONS=1 for more info."; var J = new WebAssembly.RuntimeError(H); throw o(J), J; } var rh = "data:application/octet-stream;base64,"; function fc(H) { return H.startsWith(rh); } function zr(H) { return H.startsWith("file://"); } var nn; nn = "tfjs-backend-wasm.wasm", fc(nn) || (nn = b(nn)); function mu(H) { try { if (H == nn && ee) return new Uint8Array(ee); if (x) return x(H); throw "both async and sync fetching of the wasm failed"; } catch (J) { Pr(J); } } function ah() { if (!ee && (h || f)) { if (typeof fetch == "function" && !zr(nn)) return fetch(nn, { credentials: "same-origin" }).then(function(H) { if (!H.ok) throw "failed to load wasm binary file at '" + nn + "'"; return H.arrayBuffer(); }).catch(function() { return mu(nn); }); if (v) return new Promise(function(H, J) { v(nn, function(de) { H(new Uint8Array(de)); }, J); }); } return Promise.resolve().then(function() { return mu(nn); }); } function ih() { var H = { env: _i, wasi_snapshot_preview1: _i }; function J(Ve, ze) { var Tt = Ve.exports; a.asm = Tt, ne = a.asm.memory, Ls(ne.buffer), er = a.asm.__indirect_function_table, rs(a.asm.__wasm_call_ctors), hc("wasm-instantiate"); } sh("wasm-instantiate"); function de(Ve) { J(Ve.instance); } function Ie(Ve) { return ah().then(function(ze) { return WebAssembly.instantiate(ze, H); }).then(function(ze) { return ze; }).then(Ve, function(ze) { R("failed to asynchronously prepare wasm: " + ze), Pr(ze); }); } function Qe() { return !ee && typeof WebAssembly.instantiateStreaming == "function" && !fc(nn) && !zr(nn) && typeof fetch == "function" ? fetch(nn, { credentials: "same-origin" }).then(function(Ve) { var ze = WebAssembly.instantiateStreaming(Ve, H); return ze.then(de, function(Tt) { return R("wasm streaming compile failed: " + Tt), R("falling back to ArrayBuffer instantiation"), Ie(de); }); }) : Ie(de); } if (a.instantiateWasm) try { var Ze = a.instantiateWasm(H, J); return Ze; } catch (Ve) { return R("Module.instantiateWasm callback failed with error: " + Ve), false; } return Qe().catch(o), {}; } var zv, Mv; function gu(H) { for (; H.length > 0; ) { var J = H.shift(); if (typeof J == "function") { J(a); continue; } var de = J.func; typeof de == "number" ? J.arg === void 0 ? bu(de)() : bu(de)(J.arg) : de(J.arg === void 0 ? null : J.arg); } } function nr(H) { return H; } function mc(H) { var J = /\b_Z[\w\d_]+/g; return H.replace(J, function(de) { var Ie = de; return de === Ie ? de : Ie + " [" + de + "]"; }); } var as = []; function bu(H) { var J = as[H]; return J || (H >= as.length && (as.length = H + 1), as[H] = J = er.get(H)), J; } function Lv() { var H = new Error(); if (!H.stack) { try { throw new Error(); } catch (J) { H = J; } if (!H.stack) return "(no stack trace available)"; } return H.stack.toString(); } function Ti(H, J) { er.set(H, J), as[H] = J; } function oh() { Pr(""); } function gc(H, J, de) { Jt.copyWithin(H, J, J + de); } function bc() { return 2147483648; } function sn(H) { try { return ne.grow(H - Sn.byteLength + 65535 >>> 16), Ls(ne.buffer), 1; } catch (J) { } } function yc(H) { var J = Jt.length; H = H >>> 0; var de = bc(); if (H > de) return false; for (var Ie = 1; Ie <= 4; Ie *= 2) { var Qe = J * (1 + 0.2 / Ie); Qe = Math.min(Qe, H + 100663296); var Ze = Math.min(de, Nt(Math.max(H, Qe), 65536)), Ve = sn(Ze); if (Ve) return true; } return false; } var $i = { mappings: {}, buffers: [null, [], []], printChar: function(H, J) { var de = $i.buffers[H]; J === 0 || J === 10 ? ((H === 1 ? P : R)(Xe(de, 0)), de.length = 0) : de.push(J); }, varargs: void 0, get: function() { $i.varargs += 4; var H = Xt[$i.varargs - 4 >> 2]; return H; }, getStr: function(H) { var J = Je(H); return J; }, get64: function(H, J) { return H; } }; function uh(H) { return 0; } function Bv(H, J, de, Ie, Qe) { } function Vv(H, J, de, Ie) { for (var Qe = 0, Ze = 0; Ze < de; Ze++) { var Ve = Xt[J >> 2], ze = Xt[J + 4 >> 2]; J += 8; for (var Tt = 0; Tt < ze; Tt++) $i.printChar(H, Jt[Ve + Tt]); Qe += ze; } return Xt[Ie >> 2] = Qe, 0; } function lh(H) { te(H); } var vc = false, _i = { abort: oh, emscripten_memcpy_big: gc, emscripten_resize_heap: yc, fd_close: uh, fd_seek: Bv, fd_write: Vv, setTempRet0: lh }, QN = ih(), Wv = a.___wasm_call_ctors = function() { return (Wv = a.___wasm_call_ctors = a.asm.__wasm_call_ctors).apply(null, arguments); }, ch = a._init = function() { return (ch = a._init = a.asm.init).apply(null, arguments); }, dh = a._init_with_threads_count = function() { return (dh = a._init_with_threads_count = a.asm.init_with_threads_count).apply(null, arguments); }, xc = a._get_threads_count = function() { return (xc = a._get_threads_count = a.asm.get_threads_count).apply(null, arguments); }, wc = a._register_tensor = function() { return (wc = a._register_tensor = a.asm.register_tensor).apply(null, arguments); }, ph = a._dispose_data = function() { return (ph = a._dispose_data = a.asm.dispose_data).apply(null, arguments); }, _e = a._dispose = function() { return (_e = a._dispose = a.asm.dispose).apply(null, arguments); }, hh = a._Abs = function() { return (hh = a._Abs = a.asm.Abs).apply(null, arguments); }, kc = a._Add = function() { return (kc = a._Add = a.asm.Add).apply(null, arguments); }, Mr = a._AddN = function() { return (Mr = a._AddN = a.asm.AddN).apply(null, arguments); }, Ai = a._All = function() { return (Ai = a._All = a.asm.All).apply(null, arguments); }, fh = a._Any = function() { return (fh = a._Any = a.asm.Any).apply(null, arguments); }, Uv = a._ArgMax = function() { return (Uv = a._ArgMax = a.asm.ArgMax).apply(null, arguments); }, mh = a._AvgPool = function() { return (mh = a._AvgPool = a.asm.AvgPool).apply(null, arguments); }, Gv = a._BatchMatMul = function() { return (Gv = a._BatchMatMul = a.asm.BatchMatMul).apply(null, arguments); }, Lr = a._Ceil = function() { return (Lr = a._Ceil = a.asm.Ceil).apply(null, arguments); }, gh = a._ClipByValue = function() { return (gh = a._ClipByValue = a.asm.ClipByValue).apply(null, arguments); }, bh = a._Conv2D = function() { return (bh = a._Conv2D = a.asm.Conv2D).apply(null, arguments); }, yh = a._Conv2DBackpropInput = function() { return (yh = a._Conv2DBackpropInput = a.asm.Conv2DBackpropInput).apply(null, arguments); }, vh = a._Cos = function() { return (vh = a._Cos = a.asm.Cos).apply(null, arguments); }, xh = a._Cosh = function() { return (xh = a._Cosh = a.asm.Cosh).apply(null, arguments); }, wh = a._CropAndResize = function() { return (wh = a._CropAndResize = a.asm.CropAndResize).apply(null, arguments); }, Ic = a._Cumprod = function() { return (Ic = a._Cumprod = a.asm.Cumprod).apply(null, arguments); }, kh = a._Cumsum = function() { return (kh = a._Cumsum = a.asm.Cumsum).apply(null, arguments); }, Ih = a._DepthToSpace = function() { return (Ih = a._DepthToSpace = a.asm.DepthToSpace).apply(null, arguments); }, Sh = a._DepthwiseConv2dNative = function() { return (Sh = a._DepthwiseConv2dNative = a.asm.DepthwiseConv2dNative).apply(null, arguments); }, Ch = a._Elu = function() { return (Ch = a._Elu = a.asm.Elu).apply(null, arguments); }, Nh = a._Equal = function() { return (Nh = a._Equal = a.asm.Equal).apply(null, arguments); }, Sc = a._Exp = function() { return (Sc = a._Exp = a.asm.Exp).apply(null, arguments); }, Th = a._FlipLeftRight = function() { return (Th = a._FlipLeftRight = a.asm.FlipLeftRight).apply(null, arguments); }, $h = a._Floor = function() { return ($h = a._Floor = a.asm.Floor).apply(null, arguments); }, Br = a._FloorDiv = function() { return (Br = a._FloorDiv = a.asm.FloorDiv).apply(null, arguments); }, yu = a._FusedBatchNorm = function() { return (yu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); }, _h = a._FusedConv2D = function() { return (_h = a._FusedConv2D = a.asm.FusedConv2D).apply(null, arguments); }, Ah = a._FusedDepthwiseConv2D = function() { return (Ah = a._FusedDepthwiseConv2D = a.asm.FusedDepthwiseConv2D).apply(null, arguments); }, Eh = a._Gather = function() { return (Eh = a._Gather = a.asm.Gather).apply(null, arguments); }, Be = a._GatherNd = function() { return (Be = a._GatherNd = a.asm.GatherNd).apply(null, arguments); }, Rh = a._Greater = function() { return (Rh = a._Greater = a.asm.Greater).apply(null, arguments); }, Dh = a._GreaterEqual = function() { return (Dh = a._GreaterEqual = a.asm.GreaterEqual).apply(null, arguments); }, Fh = a._LeakyRelu = function() { return (Fh = a._LeakyRelu = a.asm.LeakyRelu).apply(null, arguments); }, Oh = a._Less = function() { return (Oh = a._Less = a.asm.Less).apply(null, arguments); }, Ph = a._LessEqual = function() { return (Ph = a._LessEqual = a.asm.LessEqual).apply(null, arguments); }, zh = a._Log = function() { return (zh = a._Log = a.asm.Log).apply(null, arguments); }, vu = a._LogicalAnd = function() { return (vu = a._LogicalAnd = a.asm.LogicalAnd).apply(null, arguments); }, Cc = a._Max = function() { return (Cc = a._Max = a.asm.Max).apply(null, arguments); }, Nc = a._MaxPool = function() { return (Nc = a._MaxPool = a.asm.MaxPool).apply(null, arguments); }, Mh = a._Maximum = function() { return (Mh = a._Maximum = a.asm.Maximum).apply(null, arguments); }, Lh = a._Mean = function() { return (Lh = a._Mean = a.asm.Mean).apply(null, arguments); }, Bh = a._Min = function() { return (Bh = a._Min = a.asm.Min).apply(null, arguments); }, Vh = a._Minimum = function() { return (Vh = a._Minimum = a.asm.Minimum).apply(null, arguments); }, Wh = a._MirrorPad = function() { return (Wh = a._MirrorPad = a.asm.MirrorPad).apply(null, arguments); }, Uh = a._Multiply = function() { return (Uh = a._Multiply = a.asm.Multiply).apply(null, arguments); }, gt = a._Neg = function() { return (gt = a._Neg = a.asm.Neg).apply(null, arguments); }, Gh = a._NonMaxSuppressionV3 = function() { return (Gh = a._NonMaxSuppressionV3 = a.asm.NonMaxSuppressionV3).apply(null, arguments); }, Hh = a._NonMaxSuppressionV4 = function() { return (Hh = a._NonMaxSuppressionV4 = a.asm.NonMaxSuppressionV4).apply(null, arguments); }, qh = a._NonMaxSuppressionV5 = function() { return (qh = a._NonMaxSuppressionV5 = a.asm.NonMaxSuppressionV5).apply(null, arguments); }, Ei = a._NotEqual = function() { return (Ei = a._NotEqual = a.asm.NotEqual).apply(null, arguments); }, Tc = a._OneHot = function() { return (Tc = a._OneHot = a.asm.OneHot).apply(null, arguments); }, $c = a._PadV2 = function() { return ($c = a._PadV2 = a.asm.PadV2).apply(null, arguments); }, _c = a._Pow = function() { return (_c = a._Pow = a.asm.Pow).apply(null, arguments); }, jh = a._Prelu = function() { return (jh = a._Prelu = a.asm.Prelu).apply(null, arguments); }, Ac = a._Prod = function() { return (Ac = a._Prod = a.asm.Prod).apply(null, arguments); }, Kh = a._RealDiv = function() { return (Kh = a._RealDiv = a.asm.RealDiv).apply(null, arguments); }, Hv = a._Relu = function() { return (Hv = a._Relu = a.asm.Relu).apply(null, arguments); }, Ec = a._Relu6 = function() { return (Ec = a._Relu6 = a.asm.Relu6).apply(null, arguments); }, qv = a._ResizeBilinear = function() { return (qv = a._ResizeBilinear = a.asm.ResizeBilinear).apply(null, arguments); }, Xh = a._Reverse = function() { return (Xh = a._Reverse = a.asm.Reverse).apply(null, arguments); }, Yh = a._RotateWithOffset = function() { return (Yh = a._RotateWithOffset = a.asm.RotateWithOffset).apply(null, arguments); }, Qh = a._Round = function() { return (Qh = a._Round = a.asm.Round).apply(null, arguments); }, Zh = a._Rsqrt = function() { return (Zh = a._Rsqrt = a.asm.Rsqrt).apply(null, arguments); }, Jh = a._ScatterNd = function() { return (Jh = a._ScatterNd = a.asm.ScatterNd).apply(null, arguments); }, ef = a._SelectV2 = function() { return (ef = a._SelectV2 = a.asm.SelectV2).apply(null, arguments); }, tf = a._Sigmoid = function() { return (tf = a._Sigmoid = a.asm.Sigmoid).apply(null, arguments); }, nf = a._Sin = function() { return (nf = a._Sin = a.asm.Sin).apply(null, arguments); }, sf = a._Softmax = function() { return (sf = a._Softmax = a.asm.Softmax).apply(null, arguments); }, rf = a._SparseFillEmptyRows = function() { return (rf = a._SparseFillEmptyRows = a.asm.SparseFillEmptyRows).apply(null, arguments); }, af = a._SparseReshape = function() { return (af = a._SparseReshape = a.asm.SparseReshape).apply(null, arguments); }, of = a._SparseSegmentReduction = function() { return (of = a._SparseSegmentReduction = a.asm.SparseSegmentReduction).apply(null, arguments); }, uf = a._Sqrt = function() { return (uf = a._Sqrt = a.asm.Sqrt).apply(null, arguments); }, lf = a._Square = function() { return (lf = a._Square = a.asm.Square).apply(null, arguments); }, cf = a._SquaredDifference = function() { return (cf = a._SquaredDifference = a.asm.SquaredDifference).apply(null, arguments); }, df = a._Step = function() { return (df = a._Step = a.asm.Step).apply(null, arguments); }, pf = a._StridedSlice = function() { return (pf = a._StridedSlice = a.asm.StridedSlice).apply(null, arguments); }, hf = a._Sub = function() { return (hf = a._Sub = a.asm.Sub).apply(null, arguments); }, ff = a._Sum = function() { return (ff = a._Sum = a.asm.Sum).apply(null, arguments); }, mf = a._Tan = function() { return (mf = a._Tan = a.asm.Tan).apply(null, arguments); }, gf = a._Tanh = function() { return (gf = a._Tanh = a.asm.Tanh).apply(null, arguments); }, bf = a._Tile = function() { return (bf = a._Tile = a.asm.Tile).apply(null, arguments); }, yf = a._TopK = function() { return (yf = a._TopK = a.asm.TopK).apply(null, arguments); }, vf = a._Transform = function() { return (vf = a._Transform = a.asm.Transform).apply(null, arguments); }, xf = a._Transpose = function() { return (xf = a._Transpose = a.asm.Transpose).apply(null, arguments); }, wf = a.__FusedMatMul = function() { return (wf = a.__FusedMatMul = a.asm._FusedMatMul).apply(null, arguments); }, kf = a._malloc = function() { return (kf = a._malloc = a.asm.malloc).apply(null, arguments); }, If = a._free = function() { return (If = a._free = a.asm.free).apply(null, arguments); }, Sf = a.___errno_location = function() { return (Sf = a.___errno_location = a.asm.__errno_location).apply(null, arguments); }, Cf = a._emscripten_main_thread_process_queued_calls = function() { return (Cf = a._emscripten_main_thread_process_queued_calls = a.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); }, Rc = a.stackSave = function() { return (Rc = a.stackSave = a.asm.stackSave).apply(null, arguments); }, Dc = a.stackRestore = function() { return (Dc = a.stackRestore = a.asm.stackRestore).apply(null, arguments); }, xu = a.stackAlloc = function() { return (xu = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); }, Nf = a.dynCall_iijjiiii = function() { return (Nf = a.dynCall_iijjiiii = a.asm.dynCall_iijjiiii).apply(null, arguments); }, Tf = a.dynCall_jiji = function() { return (Tf = a.dynCall_jiji = a.asm.dynCall_jiji).apply(null, arguments); }; a.cwrap = Se; var Ri; function wu(H) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + H + ")", this.status = H; } tr = function H() { Ri || ku(), Ri || (tr = H); }; function ku(H) { if (H = H || c, Fn > 0 || (uc(), Fn > 0)) return; function J() { Ri || (Ri = true, a.calledRun = true, !oe && (lc(), i(a), a.onRuntimeInitialized && a.onRuntimeInitialized(), cc())); } a.setStatus ? (a.setStatus("Running..."), setTimeout(function() { setTimeout(function() { a.setStatus(""); }, 1), J(); }, 1)) : J(); } a.run = ku; function jv(H) { re = H, fu() || (a.onExit && a.onExit(H), oe = true), d(H, new wu(H)); } if (a.preInit) for (typeof a.preInit == "function" && (a.preInit = [a.preInit]); a.preInit.length > 0; ) a.preInit.pop()(); ku(); var Di; u && (Di = { uncaughtException: process.listeners("uncaughtException").filter(function(H) { return !u.uncaughtException.indexOf(H) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(H) { return !u.unhandledRejection.indexOf(H) > -1; }) }); var Fi; if (typeof r != "undefined") Fi = r; else if (typeof WasmBackendModuleThreadedSimd != "undefined") Fi = WasmBackendModuleThreadedSimd; else throw new Error("Could not find wasm module in post.js"); if (Di) { var $f = Fi._dispose; Fi._dispose = function() { $f(), Di.uncaughtException.forEach(function(H) { process.removeListener("uncaughtException", H); }), Di.unhandledRejection.forEach(function(H) { process.removeListener("unhandledRejection", H); }); }; } return r.ready; }; })(); typeof e == "object" && typeof t == "object" ? t.exports = n : typeof define == "function" && define.amd ? define([], function() { return n; }) : typeof e == "object" && (e.WasmBackendModule = n); } }); var p$ = 1e-7; var h$ = 1e-4; var Hd = class { constructor(e, t) { this.backend = e, this.dataMover = t, this.data = /* @__PURE__ */ 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; } }; var sl = class { refCount(e) { return On("refCount"); } incRef(e) { return On("incRef"); } timerAvailable() { return true; } time(e) { return On("time"); } read(e) { return On("read"); } readSync(e) { return On("readSync"); } readToGPU(e, t) { return On("readToGPU"); } numDataIds() { return On("numDataIds"); } disposeData(e, t) { return On("disposeData"); } write(e, t, n) { return On("write"); } move(e, t, n, s, r) { return On("move"); } memory() { return On("memory"); } floatPrecision() { return On("floatPrecision"); } epsilon() { return this.floatPrecision() === 32 ? p$ : h$; } dispose() { return On("dispose"); } }; function On(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 Kw(e) { let t = e.length, n = 0; for (; t > 0; ) n = Math.random() * t | 0, t--, pd(e, t, n); } function f$(e, t) { if (e.length !== t.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`); let n = e.length, s = 0; for (; n > 0; ) s = Math.random() * n | 0, n--, pd(e, n, s), pd(t, n, s); } function Wu(e, t, n) { return Math.max(e, Math.min(t, n)); } function m$(e) { return e % 2 === 0 ? e : e + 1; } function pd(e, t, n) { let s = e[t]; e[t] = e[n], e[n] = s; } function g$(e) { let t = 0; for (let n = 0; n < e.length; n++) t += e[n]; return t; } function b$(e, t) { let n = Math.random(); return t * n + (1 - n) * e; } function y$(e, t) { let n = 0; for (let s = 0; s < e.length; s++) { let r = Number(e[s]) - Number(t[s]); n += r * r; } return n; } function O(e, t) { if (!e) throw new Error(typeof t == "string" ? t : t()); } function pn(e, t, n = "") { O(Ir(e, t), () => n + ` Shapes ${e} and ${t} must match`); } function ka(e) { O(e != null, () => "The input to the tensor constructor must be a non-null value."); } function ra(e, t = [], n = false) { if (t == null && (t = []), Array.isArray(e) || Yt(e) && !n) for (let s = 0; s < e.length; ++s) ra(e[s], t, n); else t.push(e); return t; } function pt(e) { if (e.length === 0) return 1; let t = e[0]; for (let n = 1; n < e.length; n++) t *= e[n]; return t; } function v$(e) { return e.length === 0; } function Ir(e, t) { if (e === t) return true; if (e == null || t == null || e.length !== t.length) return false; for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return false; return true; } function Zi(e) { return e % 1 === 0; } function x$(e) { if (Math.tanh != null) return Math.tanh(e); if (e === 1 / 0) return 1; if (e === -1 / 0) return -1; { let t = Math.exp(2 * e); return (t - 1) / (t + 1); } } function w$(e) { let t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)]; } function k$(e) { let t = new Uint32Array(e); for (let n = 0; n < e; ++n) t[n] = n; return Kw(t), t; } function Mu(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length); } function I$(e, t = (s) => 0, n) { return new Promise((s, r) => { let a = 0, i = () => { if (e()) { s(); return; } a++; let o = t(a); if (n != null && a >= n) { r(); return; } setTimeout(i, o); }; i(); }); } function S$(e, t) { let n = 1, s = -1; for (let a = 0; a < e.length; ++a) if (e[a] >= 0) n *= e[a]; else if (e[a] === -1) { if (s !== -1) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`); s = a; } else if (e[a] < 0) throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`); if (s === -1) { if (t > 0 && t !== n) throw Error(`Size(${t}) must match the product of shape ${e}`); return e; } if (n === 0) throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`); if (t % n !== 0) throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`); let r = e.slice(); return r[s] = t / n, r; } function ts(e, t) { let n = t.length; return e = e == null ? t.map((s, r) => r) : [].concat(e), O(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), O(e.every((s) => Zi(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s); } function Xw(e, t) { let n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : ts(t, e).sort(), i = 0; for (let o = 0; o < e.length; ++o) { if (a != null) { if (a[i] === o && e[o] !== 1) throw new Error(`Can't squeeze axis ${o} since its dim '${e[o]}' is not 1`); (a[i] == null || a[i] > o) && e[o] === 1 && (n.push(e[o]), s.push(o)), a[i] <= o && i++; } e[o] !== 1 && (n.push(e[o]), s.push(o)); } return { newShape: n, keptDims: s }; } function Yw(e, t) { let n = null; if (e == null || e === "float32") n = new Float32Array(t); else if (e === "int32") n = new Int32Array(t); else if (e === "bool") n = new Uint8Array(t); else throw new Error(`Unknown data type ${e}`); return n; } function Qw(e, t) { let n = null; if (e == null || e === "float32") n = new Float32Array(t); else if (e === "int32") n = new Int32Array(t); else if (e === "bool") n = new Uint8Array(t); else if (e === "string") n = new Array(t); else throw new Error(`Unknown data type ${e}`); return n; } function Zw(e, t) { for (let n = 0; n < e.length; n++) { let s = e[n]; if (isNaN(s) || !isFinite(s)) throw Error(`A tensor of type ${t} being uploaded contains ${s}.`); } } function Jw(e) { return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string"; } function C$(e, t) { return !(t === "complex64" || t === "float32" && e !== "complex64" || t === "int32" && e !== "float32" && e !== "complex64" || t === "bool" && e === "bool"); } function Yt(e) { return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray; } function Yf(e) { if (e === "float32" || e === "int32") return 4; if (e === "complex64") return 8; if (e === "bool") return 1; throw new Error(`Unknown dtype ${e}`); } function ek(e) { if (e == null) return 0; let t = 0; return e.forEach((n) => t += n.length), t; } function or(e) { return typeof e == "string" || e instanceof String; } function tk(e) { return typeof e == "boolean"; } function nk(e) { return typeof e == "number"; } function qd(e) { return Array.isArray(e) ? qd(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : nk(e) ? "float32" : or(e) ? "string" : tk(e) ? "bool" : "float32"; } function fr(e) { return !!(e && e.constructor && e.call && e.apply); } function hd(e, t) { for (let n = t; n < e; ++n) if (e % n === 0) return n; return e; } function oo(e) { let t = e.length; if (t < 2) return []; let n = new Array(t - 1); n[t - 2] = e[t - 1]; for (let s = t - 3; s >= 0; --s) n[s] = n[s + 1] * e[s + 1]; return n; } function sk(e, t, n, s = false) { let r = new Array(); if (t.length === 1) { let a = t[0] * (s ? 2 : 1); for (let i = 0; i < a; i++) r[i] = n[e + i]; } else { let a = t[0], i = t.slice(1), o = i.reduce((u, l) => u * l) * (s ? 2 : 1); for (let u = 0; u < a; u++) r[u] = sk(e + u * o, i, n, s); } return r; } function ji(e, t, n = false) { if (e.length === 0) return t[0]; let s = e.reduce((r, a) => r * a) * (n ? 2 : 1); if (s === 0) return []; if (s !== t.length) throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`); return sk(0, e, t, n); } function rg(e, t) { let n = jd(e, t); for (let s = 0; s < n.length; s++) n[s] = 1; return n; } function jd(e, t) { if (t == null || t === "float32" || t === "complex64") return new Float32Array(e); if (t === "int32") return new Int32Array(e); if (t === "bool") return new Uint8Array(e); throw new Error(`Unknown data type ${t}`); } function N$(e, t) { let n = e.reduce((s, r) => s * r, 1); if (t == null || t === "float32") return ji(e, new Float32Array(n)); if (t === "int32") return ji(e, new Int32Array(n)); if (t === "bool") return ji(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`); } function ag(e) { e.forEach((t) => { O(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`); }); } function T$(e, t, n) { if (t === 0) return 0; if (t === 1) return e[0]; let s = e[e.length - 1]; for (let r = 0; r < e.length - 1; ++r) s += n[r] * e[r]; return s; } function $$(e, t, n) { if (t === 0) return []; if (t === 1) return [e]; let s = new Array(t); for (let r = 0; r < s.length - 1; ++r) s[r] = Math.floor(e / n[r]), e -= s[r] * n[r]; return s[s.length - 1] = e, s; } function ig(e) { return e && e.then && typeof e.then == "function"; } var sx = "tfjsflags"; var _$ = class { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = A$, this.populateURLFlags(); } setPlatform(e, t) { this.platform != null && (X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t; } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, this.urlFlags[e] != null) { let s = this.urlFlags[e]; X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${s}.`), this.set(e, s); } } async getAsync(e) { return e in this.flags ? this.flags[e] : (this.flags[e] = await this.evaluateFlag(e), this.flags[e]); } get(e) { if (e in this.flags) return this.flags[e]; let t = this.evaluateFlag(e); if (ig(t)) throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`); return this.flags[e] = t, this.flags[e]; } getNumber(e) { return this.get(e); } getBool(e) { return this.get(e); } getFlags() { return this.flags; } get features() { return this.flags; } set(e, t) { if (this.flagRegistry[e] == null) throw new Error(`Cannot set flag ${e} as it has not been registered.`); this.flags[e] = t, this.flagRegistry[e].setHook != null && this.flagRegistry[e].setHook(t); } evaluateFlag(e) { if (this.flagRegistry[e] == null) throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`); return this.flagRegistry[e].evaluationFn(); } setFlags(e) { this.flags = Object.assign({}, e); } reset() { this.flags = {}, this.urlFlags = {}, this.populateURLFlags(); } populateURLFlags() { if (typeof this.global == "undefined" || typeof this.global.location == "undefined" || typeof this.global.location.search == "undefined") return; let e = this.getQueryParams(this.global.location.search); sx in e && e[sx].split(",").forEach((n) => { let [s, r] = n.split(":"); this.urlFlags[s] = R$(s, r); }); } }; function A$(e) { let t = {}; return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (E$(t, s[0], s[1]), s.join("="))), t; } function E$(e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || ""); } function R$(e, t) { if (t = t.toLowerCase(), t === "true" || t === "false") return t === "true"; if (`${+t}` === t) return +t; throw new Error(`Could not parse value flag value ${t} for flag ${e}.`); } function X() { return rk; } var rk = null; function D$(e) { rk = e; } var Of; function ak() { if (Of == 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"); Of = e; } return Of; } function F$() { let e = ak(); return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals; } function og(e, t) { let n = F$(); if (n.has(e)) return n.get(e); { let s = t(); return n.set(e, s), n.get(e); } } var uo = "Abs"; var rl = "Acos"; var al = "Acosh"; var Sr = "Add"; var Ia = "AddN"; var il = "All"; var ol = "Any"; var Sa = "ArgMax"; var ul = "ArgMin"; var ll = "Asin"; var cl = "Asinh"; var dl = "Atan"; var pl = "Atanh"; var hl = "Atan2"; var Ca = "AvgPool"; var ug = "AvgPoolGrad"; var Kd = "AvgPool3D"; var lg = "AvgPool3DGrad"; var Na = "BatchMatMul"; var lo = "BatchToSpaceND"; var cg = "Bincount"; var O$ = "BroadcastTo"; var dg = "BroadcastArgs"; var Ta = "Cast"; var $a = "Ceil"; var Cr = "ClipByValue"; var Xd = "Complex"; var Yd = "ComplexAbs"; var co = "Concat"; var _a = "Conv2D"; var pg = "Conv2DBackpropFilter"; var Aa = "Conv2DBackpropInput"; var Qd = "Conv3D"; var hg = "Conv3DBackpropFilterV2"; var fg = "Conv3DBackpropInputV2"; var Ea = "Cos"; var Ra = "Cosh"; var po = "Cumprod"; var Da = "Cumsum"; var ho = "CropAndResize"; var mg = "DenseBincount"; var fo = "DepthToSpace"; var Fa = "DepthwiseConv2dNative"; var gg = "DepthwiseConv2dNativeBackpropFilter"; var bg = "DepthwiseConv2dNativeBackpropInput"; var yg = "Diag"; var Zd = "Dilation2D"; var Qf = "Dilation2DBackpropInput"; var Zf = "Dilation2DBackpropFilter"; var Oa = "RealDiv"; var Jd = "Einsum"; var Pa = "Elu"; var vg = "EluGrad"; var fl = "Erf"; var mo = "Equal"; var za = "Exp"; var go = "ExpandDims"; var bo = "Expm1"; var xg = "FFT"; var ml = "Fill"; var yo = "FlipLeftRight"; var Ma = "Floor"; var La = "FloorDiv"; var Ba = "FusedBatchNorm"; var vo = "GatherV2"; var xo = "GatherNd"; var wo = "Greater"; var Va = "GreaterEqual"; var Wa = "Identity"; var wg = "IFFT"; var ep = "Imag"; var gl = "IsFinite"; var bl = "IsInf"; var yl = "IsNan"; var Ua = "LeakyRelu"; var ko = "Less"; var Io = "LessEqual"; var kg = "LinSpace"; var Ga = "Log"; var vl = "Log1p"; var So = "LogicalAnd"; var xl = "LogicalNot"; var tp = "LogicalOr"; var P$ = "LogSoftmax"; var np = "LRN"; var Ig = "LRNGrad"; var Ha = "Max"; var qa = "Maximum"; var ja = "MaxPool"; var Sg = "MaxPoolGrad"; var sp = "MaxPool3D"; var Cg = "MaxPool3DGrad"; var Ng = "MaxPoolWithArgmax"; var Ka = "Mean"; var Xa = "Min"; var Ya = "Minimum"; var Qa = "MirrorPad"; var wl = "Mod"; var Tg = "Multinomial"; var Za = "Multiply"; var Co = "Neg"; var No = "NotEqual"; var To = "NonMaxSuppressionV3"; var kl = "NonMaxSuppressionV4"; var $o = "NonMaxSuppressionV5"; var _o = "OnesLike"; var Ao = "OneHot"; var Eo = "Pack"; var Ja = "PadV2"; var Wde = "Pool"; var ei = "Pow"; var ti = "Prelu"; var ni = "Prod"; var Il = "Range"; var rp = "Real"; var Sl = "Reciprocal"; var si = "Relu"; var Ro = "Reshape"; var Cl = "ResizeNearestNeighbor"; var $g = "ResizeNearestNeighborGrad"; var ri = "ResizeBilinear"; var _g = "ResizeBilinearGrad"; var ai = "Relu6"; var Do = "Reverse"; var Fo = "Round"; var ii = "Rsqrt"; var Oo = "ScatterNd"; var Po = "Select"; var Nl = "Selu"; var zo = "Slice"; var oi = "Sin"; var Mo = "Sinh"; var Tl = "Sign"; var ui = "Sigmoid"; var $l = "Softplus"; var li = "Sqrt"; var ci = "Sum"; var Lo = "SpaceToBatchND"; var Bo = "SplitV"; var di = "Softmax"; var ap = "SparseFillEmptyRows"; var _l = "SparseReshape"; var ip = "SparseSegmentMean"; var op = "SparseSegmentSum"; var up = "SparseToDense"; var pi = "SquaredDifference"; var Al = "Square"; var Vo = "StridedSlice"; var lp = "StringNGrams"; var Ag = "StringSplit"; var Eg = "StringToHashBucketFast"; var hi = "Sub"; var Wo = "Tan"; var fi = "Tanh"; var Nr = "Tile"; var Uo = "TopK"; var Go = "Transform"; var mi = "Transpose"; var Rg = "Unique"; var Ho = "Unpack"; var cp = "UnsortedSegmentSum"; var qo = "ZerosLike"; var gi = "Step"; var fd = "FromPixels"; var jo = "RotateWithOffset"; var aa = "_FusedMatMul"; var ia = "FusedConv2D"; var oa = "FusedDepthwiseConv2D"; function ir(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(...e); } function z$(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.log(...e); } var Ji = og("kernelRegistry", () => /* @__PURE__ */ new Map()); var Uu = og("gradRegistry", () => /* @__PURE__ */ new Map()); function Jf(e, t) { let n = Dg(e, t); return Ji.get(n); } function rx(e) { return Uu.get(e); } function em(e) { let t = Ji.entries(), n = []; for (; ; ) { let { done: s, value: r } = t.next(); if (s) break; let [a, i] = r, [o] = a.split("_"); o === e && n.push(i); } return n; } function El(e) { let { kernelName: t, backendName: n } = e, s = Dg(t, n); Ji.has(s) && ir(`The kernel '${t}' for backend '${n}' is already registered`), Ji.set(s, e); } function M$(e) { let { kernelName: t } = e; Uu.has(t) && X().getBool("DEBUG") && ir(`Overriding the gradient for '${t}'`), Uu.set(t, e); } function Ude(e, t) { let n = Dg(e, t); if (!Ji.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); Ji.delete(n); } function Gde(e) { if (!Uu.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); Uu.delete(e); } function Hde(e, t) { em(e).forEach((s) => { let r = Object.assign({}, s, { backendName: t }); El(r); }); } function Dg(e, t) { return `${t}_${e}`; } var w = {}; Ae(w, { arraysEqual: () => Ir, assert: () => O, assertNonNegativeIntegerDimensions: () => ag, assertNonNull: () => ka, assertShapesMatch: () => pn, bytesFromStringArray: () => ek, bytesPerElement: () => Yf, checkConversionForErrors: () => Zw, clamp: () => Wu, computeStrides: () => oo, createScalarValue: () => G$, createShuffledIndices: () => k$, decodeString: () => md, distSquared: () => y$, encodeString: () => Dl, fetch: () => q$, fingerPrint64: () => U$, flatten: () => ra, getArrayFromDType: () => Qw, getTypedArrayFromDType: () => Yw, hasEncodingLoss: () => C$, hexToLong: () => Rl, indexToLoc: () => $$, inferDtype: () => qd, inferFromImplicitShape: () => S$, isBoolean: () => tk, isFunction: () => fr, isInt: () => Zi, isNumber: () => nk, isPromise: () => ig, isScalarShape: () => v$, isString: () => or, isTypedArray: () => Yt, isValidDtype: () => Jw, locToIndex: () => T$, makeOnesTypedArray: () => rg, makeZerosNestedTypedArray: () => N$, makeZerosTypedArray: () => jd, nearestDivisor: () => hd, nearestLargerEven: () => m$, now: () => Gu, parseAxisParam: () => ts, randUniform: () => b$, repeatedTry: () => I$, rightPad: () => Mu, shuffle: () => Kw, shuffleCombo: () => f$, sizeFromShape: () => pt, sizeToSquarishShape: () => w$, squeezeShape: () => Xw, sum: () => g$, swap: () => pd, tanh: () => x$, toNestedArray: () => ji, toTypedArray: () => dp }); var ax = wa(YT()); var jr = ax.default || ax; function Rl(e) { return jr.fromString(e, true, 16); } var ik = Rl("c3a5c85c97cb3127"); var Hr = Rl("b492b66fbe98f273"); var an = Rl("9ae16a3b2f90404f"); function tm(e) { return e.xor(e.shru(47)); } function ok(e, t, n) { let s = e.slice(t, t + n); return jr.fromBytes(Array.from(s), true, true); } function lt(e, t) { return ok(e, t, 8); } function ix(e, t) { return ok(e, t, 4); } function Lt(e, t) { return t === 0 ? e : e.shru(t).or(e.shl(64 - t)); } function lr(e, t, n = Rl("9ddfea08eb382d69")) { let s = e.xor(t).mul(n); s = s.xor(s.shru(47)); let r = t.xor(s).mul(n); return r = r.xor(r.shru(47)), r = r.mul(n), r; } function L$(e, t, n, s, r, a) { r = r.add(e), a = Lt(a.add(r).add(s), 21); let i = r; return r = r.add(t), r = r.add(n), a = a.add(Lt(r, 44)), [r.add(s), a.add(i)]; } function Vc(e, t, n, s) { return L$(lt(e, t), lt(e, t + 8), lt(e, t + 16), lt(e, t + 24), n, s); } function B$(e, t = e.length) { if (t >= 8) { let n = an.add(t * 2), s = lt(e, 0).add(an), r = lt(e, t - 8), a = Lt(r, 37).mul(n).add(s), i = Lt(s, 25).add(r).mul(n); return lr(a, i, n); } if (t >= 4) { let n = an.add(t * 2), s = ix(e, 0); return lr(s.shl(3).add(t), ix(e, t - 4), n); } if (t > 0) { let n = e[0], s = e[t >> 1], r = e[t - 1], a = n + (s << 8), i = t + (r << 2); return tm(an.mul(a).xor(ik.mul(i))).mul(an); } return an; } function V$(e, t = e.length) { let n = an.add(t * 2), s = lt(e, 0).mul(Hr), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(an); return lr(Lt(s.add(r), 43).add(Lt(a, 30)).add(i), s.add(Lt(r.add(an), 18)).add(a), n); } function W$(e, t = e.length) { let n = an.add(t * 2), s = lt(e, 0).mul(an), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(an), o = Lt(s.add(r), 43).add(Lt(a, 30)).add(i), u = lr(o, s.add(Lt(r.add(an), 18)).add(a), n), l = lt(e, 16).mul(n), c = lt(e, 24), p = o.add(lt(e, t - 32)).mul(n), d = u.add(lt(e, t - 24)).mul(n); return lr(Lt(l.add(c), 43).add(Lt(p, 30)).add(d), l.add(Lt(c.add(s), 18)).add(p), n); } function U$(e, t = e.length) { let n = jr.fromNumber(81, true); if (t <= 32) return t <= 16 ? B$(e, t) : V$(e, t); if (t <= 64) return W$(e, t); let s = n, r = n.mul(Hr).add(113), a = tm(r.mul(an).add(113)).mul(an), i = [jr.UZERO, jr.UZERO], o = [jr.UZERO, jr.UZERO]; s = s.mul(an).add(lt(e, 0)); let u = 0, l = (t - 1 >> 6) * 64, c = l + (t - 1 & 63) - 63; do s = Lt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(Hr), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(Hr), s = s.xor(o[1]), r = r.add(i[0]).add(lt(e, u + 40)), a = Lt(a.add(o[0]), 33).mul(Hr), i = Vc(e, u, i[1].mul(Hr), s.add(o[0])), o = Vc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], u += 64; while (u !== l); let p = Hr.add(a.and(255).shl(1)); return u = c, o[0] = o[0].add(t - 1 & 63), i[0] = i[0].add(o[0]), o[0] = o[0].add(i[0]), s = Lt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(p), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(p), s = s.xor(o[1].mul(9)), r = r.add(i[0].mul(9).add(lt(e, u + 40))), a = Lt(a.add(o[0]), 33).mul(p), i = Vc(e, u, i[1].mul(p), s.add(o[0])), o = Vc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], lr(lr(i[0], o[0], p).add(tm(r).mul(ik)).add(a), lr(i[1], o[1], p).add(s), p); } function G$(e, t) { return t === "string" ? Dl(e) : dp([e], t); } function H$(e, t) { return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool"; } function dp(e, t) { if (t === "string") throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(e) && (e = ra(e)), X().getBool("DEBUG") && Zw(e, t), H$(e, t)) return e; if (t == null || t === "float32" || t === "complex64") return new Float32Array(e); if (t === "int32") return new Int32Array(e); if (t === "bool") { let n = new Uint8Array(e.length); for (let s = 0; s < n.length; ++s) Math.round(e[s]) !== 0 && (n[s] = 1); return n; } else throw new Error(`Unknown data type ${t}`); } function Gu() { return X().platform.now(); } function q$(e, t) { return X().platform.fetch(e, t); } function Dl(e, t = "utf-8") { return t = t || "utf-8", X().platform.encode(e, t); } function md(e, t = "utf-8") { return t = t || "utf-8", X().platform.decode(e, t); } var j$ = class { constructor(e, t) { this.backendTimer = e, this.logger = t, t == null && (this.logger = new X$()); } profileKernel(e, t, n) { let s, r = () => { s = n(); }, a, i = Gu(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(r); else { r(); for (let u of s) u.dataSync(); a = Promise.resolve({ kernelMs: Gu() - i }); } if (X().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < s.length; u++) { let l = s[u]; l.data().then((c) => { K$(c, l.dtype, e); }); } return { kernelName: e, outputs: s, inputs: t, timeMs: a.then((u) => u.kernelMs), extraInfo: a.then((u) => u.getExtraProfileInfo != null ? u.getExtraProfileInfo() : "") }; } logKernelProfile(e) { let { kernelName: t, outputs: n, timeMs: s, inputs: r, extraInfo: a } = e; n.forEach((i) => { Promise.all([i.data(), s, a]).then((o) => { this.logger.logKernelProfile(t, i, o[0], o[1], r, o[2]); }); }); } }; function K$(e, t, n) { if (t !== "float32") return false; for (let s = 0; s < e.length; s++) { let r = e[s]; if (isNaN(r) || !isFinite(r)) return console.warn(`Found ${r} in the result of '${n}'`), true; } return false; } var X$ = class { logKernelProfile(e, t, n, s, r, a) { let i = typeof s == "number" ? Mu(`${s}ms`, 9) : s.error, o = Mu(e, 25), u = t.rank, l = t.size, c = Mu(t.shape.toString(), 14), p = ""; for (let d in r) { let h = r[d]; if (h != null) { let f = h.shape || t.shape, m = f.length; p += `${d}: ${m}D ${m > 0 ? f : ""} `; } } console.log(`%c${o} %c${i} %c${u}D ${c} %c${l} %c${p} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; function Y$(e, t, n) { let s = {}, r = {}; for (let u = 0; u < t.length; u++) s[t[u].id] = true; for (let u = 0; u < e.length; u++) { let l = e[u], c = l.inputs; for (let p in c) { let d = c[p], h = false; for (let f = 0; f < t.length; f++) if (s[d.id]) { l.outputs.forEach((m) => s[m.id] = true), h = true, r[l.id] = true; break; } if (h) break; } } let a = {}; a[n.id] = true; let i = {}; for (let u = e.length - 1; u >= 0; u--) { let l = e[u], c = l.inputs; for (let p = 0; p < l.outputs.length; p++) if (a[l.outputs[p].id]) { for (let d in c) a[c[d].id] = true, i[l.id] = true; break; } } let o = []; for (let u = 0; u < e.length; u++) { let l = e[u]; if (r[l.id] && i[l.id]) { let c = {}; for (let d in l.inputs) { let h = l.inputs[d]; s[h.id] && (c[d] = h); } let p = Object.assign({}, l); p.inputs = c, p.outputs = l.outputs, o.push(p); } } return o; } function Q$(e, t, n, s) { for (let r = t.length - 1; r >= 0; r--) { let a = t[r], i = []; if (a.outputs.forEach((u) => { let l = e[u.id]; l != null ? i.push(l) : i.push(null); }), a.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`); let o = a.gradient(i); for (let u in a.inputs) { if (!(u in o)) throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(o)}.`); let l = n(() => o[u]()); if (l.dtype !== "float32") throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`); let c = a.inputs[u]; if (!Ir(l.shape, c.shape)) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`); if (e[c.id] == null) e[c.id] = l; else { let p = e[c.id]; e[c.id] = s(p, l), p.dispose(); } } } } var ox = 20; var Cu = 3; var Pf = 7; function Z$(e, t, n, s) { let r = oo(t), a = J$(e, t, n, r), i = t.length, o = ed(e, t, n, r, a), u = ["Tensor"]; return s && (u.push(` dtype: ${n}`), u.push(` rank: ${i}`), u.push(` shape: [${t}]`), u.push(" values:")), u.push(o.map((l) => " " + l).join(` `)), u.join(` `); } function J$(e, t, n, s) { let r = pt(t), a = s[s.length - 1], i = new Array(a).fill(0), o = t.length, u = n === "complex64" ? Au(e) : e; if (o > 1) for (let l = 0; l < r / a; l++) { let c = l * a; for (let p = 0; p < a; p++) i[p] = Math.max(i[p], _u(u[c + p], 0, n).length); } return i; } function _u(e, t, n) { let s; return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(Pf))} + ${parseFloat(e[1].toFixed(Pf))}j` : or(e) ? s = `'${e}'` : n === "bool" ? s = uk(e) : s = parseFloat(e.toFixed(Pf)).toString(), Mu(s, t); } function uk(e) { return e === 0 ? "false" : "true"; } function ed(e, t, n, s, r, a = true) { let i = n === "complex64" ? 2 : 1, o = t[0], u = t.length; if (u === 0) { if (n === "complex64") { let m = Au(e); return [_u(m[0], 0, n)]; } return n === "bool" ? [uk(e[0])] : [e[0].toString()]; } if (u === 1) { if (o > ox) { let g = Cu * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - Cu) * i, o * i)); return n === "complex64" && (b = Au(b), y = Au(y)), ["[" + b.map((v, x) => _u(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => _u(v, r[o - Cu + x], n)).join(", ") + "]"]; } let m = n === "complex64" ? Au(e) : Array.from(e); return ["[" + m.map((g, b) => _u(g, r[b], n)).join(", ") + "]"]; } let l = t.slice(1), c = s.slice(1), p = s[0] * i, d = []; if (o > ox) { for (let m = 0; m < Cu; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, false)); } d.push("..."); for (let m = o - Cu; m < o; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); } } else for (let m = 0; m < o; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); } let h = u === 2 ? "," : ""; d[0] = "[" + d[0] + h; for (let m = 1; m < d.length - 1; m++) d[m] = " " + d[m] + h; let f = `, `; for (let m = 2; m < u; m++) f += ` `; return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : f), d; } function Au(e) { let t = []; for (let n = 0; n < e.length; n += 2) t.push([e[n], e[n + 1]]); return t; } var Vt = class { constructor(e, t, n) { if (this.dtype = t, this.shape = e.slice(), this.size = pt(e), n != null) { let s = n.length; O(s === this.size, () => `Length of values '${s}' does not match the size inferred by the shape '${this.size}'.`); } if (t === "complex64") throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag)."); this.values = n || Qw(t, this.size), this.strides = oo(e); } set(e, ...t) { t.length === 0 && (t = [0]), O(t.length === this.rank, () => `The number of provided coordinates (${t.length}) must match the rank (${this.rank})`); let n = this.locToIndex(t); this.values[n] = e; } get(...e) { e.length === 0 && (e = [0]); let t = 0; for (let s of e) { if (s < 0 || s >= this.shape[t]) { let r = `Requested out of range element at ${e}. Buffer shape=${this.shape}`; throw new Error(r); } t++; } let n = e[e.length - 1]; for (let s = 0; s < e.length - 1; ++s) n += this.strides[s] * e[s]; return this.values[n]; } locToIndex(e) { if (this.rank === 0) return 0; if (this.rank === 1) return e[0]; let t = e[e.length - 1]; for (let n = 0; n < e.length - 1; ++n) t += this.strides[n] * e[n]; return t; } indexToLoc(e) { if (this.rank === 0) return []; if (this.rank === 1) return [e]; let t = new Array(this.shape.length); for (let n = 0; n < t.length - 1; ++n) t[n] = Math.floor(e / this.strides[n]), e -= t[n] * this.strides[n]; return t[t.length - 1] = e, t; } get rank() { return this.shape.length; } toTensor() { return cs().makeTensor(this.values, this.shape, this.dtype); } }; var cs = null; var Gi = null; var e_ = null; function t_(e) { cs = e; } function n_(e) { Gi = e; } function s_(e) { e_ = e; } var et = class { constructor(e, t, n, s) { this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t || "float32", this.size = pt(e), this.strides = oo(e), this.dataId = n, this.id = s, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; } get rank() { return this.shape.length; } async buffer() { let e = await this.data(); return Gi.buffer(this.shape, this.dtype, e); } bufferSync() { return Gi.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); return ji(this.shape, e, this.dtype === "complex64"); } arraySync() { return ji(this.shape, this.dataSync(), this.dtype === "complex64"); } async data() { this.throwIfDisposed(); let e = cs().read(this.dataId); if (this.dtype === "string") { let t = await e; try { return t.map((n) => md(n)); } catch (n) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes()."); } } return e; } dataToGPU(e) { return this.throwIfDisposed(), cs().readToGPU(this.dataId, e); } dataSync() { this.throwIfDisposed(); let e = cs().readSync(this.dataId); if (this.dtype === "string") try { return e.map((t) => md(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 cs().read(this.dataId); return this.dtype === "string" ? e : new Uint8Array(e.buffer); } dispose() { this.isDisposed || (cs().disposeTensor(this), this.isDisposedInternal = true); } get isDisposed() { return this.isDisposedInternal; } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed."); } print(e = false) { return Gi.print(this, e); } clone() { return this.throwIfDisposed(), Gi.clone(this); } toString(e = false) { let t = this.dataSync(); return Z$(t, this.shape, this.dtype, e); } cast(e) { return this.throwIfDisposed(), Gi.cast(this, e); } variable(e = true, t, n) { return this.throwIfDisposed(), cs().makeVariable(this, e, t, n); } }; Object.defineProperty(et, Symbol.hasInstance, { value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null }); function r_() { return og("Tensor", () => et); } r_(); var gd = class extends et { constructor(e, t, n, s) { super(e.shape, e.dtype, e.dataId, s), this.trainable = t, this.name = n; } assign(e) { if (e.dtype !== this.dtype) throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`); if (!Ir(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); cs().disposeTensor(this), this.dataId = e.dataId, cs().incRef(this, null); } dispose() { cs().disposeVariable(this), this.isDisposedInternal = true; } }; Object.defineProperty(gd, Symbol.hasInstance, { value: (e) => e instanceof et && e.assign != null && e.assign instanceof Function }); var _s = {}; Ae(_s, { assertTypesMatch: () => hk, getTensorsInContainer: () => Fg, isTensorInList: () => o_, makeTypesMatch: () => vt }); var a_ = ((e) => (e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6", e))(a_ || {}); var lk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64", e))(lk || {}); var ck = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64", e))(ck || {}); var dk = ((e) => (e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64", e))(dk || {}); var pk = ((e) => (e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64", e))(pk || {}); var i_ = { float32: dk, int32: lk, bool: ck, complex64: pk }; function ln(e, t) { if (e === "string" || t === "string") { if (e === "string" && t === "string") return "string"; throw new Error(`Can not upcast ${e} with ${t}`); } return i_[e][t]; } function pp(e) { return ln(e, "int32"); } function vt(e, t) { if (e.dtype === t.dtype) return [e, t]; let n = ln(e.dtype, t.dtype); return [e.cast(n), t.cast(n)]; } function hk(e, t) { O(e.dtype === t.dtype, () => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`); } function o_(e, t) { return t.some((n) => n.id === e.id); } function Fg(e) { let t = []; return fk(e, t, /* @__PURE__ */ new Set()), t; } function fk(e, t, n) { if (e == null) return; if (e instanceof et) { t.push(e); return; } if (!u_(e)) return; let s = e; for (let r in s) { let a = s[r]; n.has(a) || (n.add(a), fk(a, t, n)); } } function u_(e) { return Array.isArray(e) || typeof e == "object"; } function zf(e) { return e.kernelName != null; } var ux = 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 = /* @__PURE__ */ new WeakMap(), this.profiling = false, 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(); } }; var nm = class { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new ux(); } 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.length; t++) { let n = e[t]; if (await this.initializeBackend(n).success) { await this.setBackend(n); return; } } throw new Error("Could not initialize any backends, all backend initializations failed."); } get backend() { if (this.pendingBackendInit != null) throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`); if (this.backendInstance == null) { let { name: e, asyncInit: t } = this.initializeBackendsAndReturnBest(); if (t) throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`); this.setBackend(e); } return this.backendInstance; } backendNames() { return Object.keys(this.registryFactory); } findBackend(e) { if (!(e in this.registry)) if (e in this.registryFactory) { let { asyncInit: t } = this.initializeBackend(e); if (t) return null; } else return null; return this.registry[e]; } findBackendFactory(e) { return e in this.registryFactory ? this.registryFactory[e].factory : null; } registerBackend(e, t, n = 1) { return e in this.registryFactory ? (ir(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = { factory: t, priority: n }, true); } async setBackend(e) { if (this.registryFactory[e] == null) throw new Error(`Backend name '${e}' not found in registry`); if (this.backendName = e, this.registry[e] == null) { this.backendInstance = null; let { success: t, asyncInit: n } = this.initializeBackend(e); if (!(n ? await t : t)) return false; } return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new j$(this.backendInstance), true; } setupRegisteredKernels() { em(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { em(e).forEach((n) => { n.disposeFunc != null && n.disposeFunc(this.registry[e]); }); } initializeBackend(e) { let t = this.registryFactory[e]; if (t == null) throw new Error(`Cannot initialize backend ${e}, no registration found.`); try { let n = t.factory(); if (n && !(n instanceof sl) && typeof n.then == "function") { let s = ++this.pendingBackendInitId, r = n.then((a) => s < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (s < this.pendingBackendInitId || (this.pendingBackendInit = null, ir(`Initialization of backend ${e} failed`), ir(a.stack || a.message)), false)); return this.pendingBackendInit = r, { success: r, asyncInit: true }; } else return this.registry[e] = n, { success: true, asyncInit: false }; } catch (n) { return ir(`Initialization of backend ${e} failed`), ir(n.stack || n.message), { success: false, asyncInit: false }; } } removeBackend(e) { if (!(e in this.registryFactory)) throw new Error(`${e} backend not found in registry`); this.backendName === e && this.pendingBackendInit != null && this.pendingBackendInitId++, e in this.registry && (this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]), delete this.registryFactory[e], this.backendName === e && (this.pendingBackendInit = null, this.backendName = null, this.backendInstance = null); } getSortedBackends() { if (Object.keys(this.registryFactory).length === 0) throw new Error("No backend found in registry."); return Object.keys(this.registryFactory).sort((e, t) => this.registryFactory[t].priority - this.registryFactory[e].priority); } initializeBackendsAndReturnBest() { let e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { let n = e[t], { success: s, asyncInit: r } = this.initializeBackend(n); if (r || s) return { name: n, asyncInit: r }; } throw new Error("Could not initialize any backends, all backend initializations failed."); } moveData(e, t) { let n = this.state.tensorInfo.get(t), s = n.backend, r = this.readSync(t), a = s.refCount(t); s.disposeData(t, true), n.backend = e, e.move(t, r, n.shape, n.dtype, a), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++; } tidy(e, t) { let n = null; if (t == null) { if (typeof e != "function") throw new Error("Please provide a function to tidy()"); t = e; } else { if (typeof e != "string" && !(e instanceof String)) throw new Error("When calling with two arguments, the first argument to tidy() must be a string"); if (typeof t != "function") throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function"); n = e; } let s; return this.scopedRun(() => this.startScope(n), () => this.endScope(s), () => (s = t(), s instanceof Promise && console.error("Cannot return a Promise inside of tidy."), s)); } scopedRun(e, t, n) { e(); try { let s = n(); return t(), s; } catch (s) { throw t(), s; } } nextTensorId() { return nm.nextTensorId++; } nextVariableId() { return nm.nextVariableId++; } clone(e) { let t = M.runKernel(Wa, { x: e }), n = { x: e }, s = (a) => ({ x: () => { let i = "float32", o = { x: a }, u = { dtype: i }; return M.runKernel(Ta, o, u); } }), r = []; return this.addTapeNode(this.state.activeScope.name, n, [t], s, r, {}), t; } runKernel(e, t, n) { if (this.backendName == null && this.backend, !(Jf(e, this.backendName) != null)) throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`); return this.runKernelFunc({ kernelName: e, inputs: t, attrs: n }); } shouldCheckForMemLeaks() { return this.ENV.getBool("IS_TEST"); } checkKernelForMemLeak(e, t, n) { let s = this.backend.numDataIds(), r = 0; n.forEach((o) => { r += o.dtype === "complex64" ? 3 : 1; }); let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = s - t - r - a; if (i > 0) throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`); } runKernelFunc(e) { let t, n = [], s = this.isTapeOn(), r = this.state.numBytes, a = this.state.numTensors; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0); let i; this.backendName == null && this.backend; let o, u = zf(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; if (zf(e)) { let { kernelName: h, inputs: f, attrs: m } = e; this.backendName == null && this.backend; let g = Jf(h, this.backendName); O(g != null, () => `Cannot find registered kernel '${h}' for backend '${this.backendName}'`), i = () => { let b = this.backend.numDataIds(); o = g.kernelFunc({ inputs: f, attrs: m, backend: this.backend }); let y = Array.isArray(o) ? o : [o]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(h, b, y); let v = y.map((x) => { if (x.rank != null) return x; let { dataId: k, shape: S, dtype: $ } = x; return this.makeTensorFromDataId(k, S, $); }); if (s) { let x = this.getTensorsForGradient(h, f, v); n = this.saveTensorsForBackwardMode(x); } return v; }; } else { let { forwardFunc: h } = e, f = (m) => { !s || (n = m.map((g) => this.keep(this.clone(g)))); }; i = () => { let m = this.backend.numDataIds(); o = this.tidy(() => h(this.backend, f)); let g = Array.isArray(o) ? o : [o]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, m, g), g; }; } let { inputs: l, attrs: c } = e, p = zf(e) ? null : e.backwardsFunc, d; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = i() : (d = this.profiler.profileKernel(u, l, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(d), t = d.outputs); }), s && this.addTapeNode(u, l, t, p, n, c), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - r, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(l).map((h) => l[h] != null ? l[h].shape : null), outputShapes: t.map((h) => h.shape), kernelTimeMs: d.timeMs, extraInfo: d.extraInfo }), Array.isArray(o) ? t : t[0]; } saveTensorsForBackwardMode(e) { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { let s = rx(e); if (s != null) { let r = s.inputsToSave || [], a = s.outputsToSave || [], i; s.saveAllInputs ? (O(Array.isArray(t), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t).map((u) => t[u])) : i = r.map((u) => t[u]); let o = n.filter((u, l) => a[l]); return i.concat(o); } return []; } makeTensor(e, t, n, s) { if (e == null) throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", s = s || this.backend; let r = e; n === "string" && or(e[0]) && (r = e.map((o) => Dl(o))); let a = s.write(r, t, n), i = new et(t, n, a, this.nextTensorId()); if (this.trackTensor(i, s), n === "string") { let o = this.state.tensorInfo.get(a), u = ek(r); this.state.numBytes += u - o.bytes, o.bytes = u; } return i; } makeTensorFromDataId(e, t, n, s) { n = n || "float32"; let r = new et(t, n, e, this.nextTensorId()); return this.trackTensor(r, s), r; } makeVariable(e, t = true, n, s) { n = n || this.nextVariableId().toString(), s != null && s !== e.dtype && (e = e.cast(s)); let r = new gd(e, t, n, this.nextTensorId()); if (this.state.registeredVariables[r.name] != null) throw new Error(`Variable with name ${r.name} was already registered`); return this.state.registeredVariables[r.name] = r, this.incRef(r, this.backend), r; } trackTensor(e, t) { this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++; let n = 0; e.dtype !== "complex64" && e.dtype !== "string" && (n = e.size * Yf(e.dtype)), this.state.numBytes += n, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t || this.backend, dtype: e.dtype, shape: e.shape, bytes: n })), e instanceof gd || this.track(e); } incRef(e, t) { this.trackTensor(e, t), this.backend.incRef(e.dataId); } removeDataId(e, t) { this.state.tensorInfo.has(e) && this.state.tensorInfo.get(e).backend === t && (this.state.tensorInfo.delete(e), this.state.numDataBuffers--); } disposeTensor(e) { if (!this.state.tensorInfo.has(e.dataId)) return; let t = this.state.tensorInfo.get(e.dataId); if (this.state.numTensors--, e.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= t.bytes), e.dtype !== "complex64" && e.dtype !== "string") { let n = e.size * Yf(e.dtype); this.state.numBytes -= n; } t.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t.backend); } disposeVariables() { for (let e in this.state.registeredVariables) { let t = this.state.registeredVariables[e]; this.disposeVariable(t); } } disposeVariable(e) { this.disposeTensor(e), this.state.registeredVariables[e.name] != null && delete this.state.registeredVariables[e.name]; } memory() { let e = this.backend.memory(); return e.numTensors = this.state.numTensors, e.numDataBuffers = this.state.numDataBuffers, e.numBytes = this.state.numBytes, this.state.numStringTensors > 0 && (e.unreliable = true, 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 = true; let t = this.state.numBytes, n = this.state.numTensors; this.state.activeProfile.kernels = [], this.state.activeProfile.result = await e(), this.state.profiling = false, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((s) => s.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - t, this.state.activeProfile.newTensors = this.state.numTensors - n; for (let s of this.state.activeProfile.kernels) s.kernelTimeMs = await s.kernelTimeMs, s.extraInfo = await s.extraInfo; return this.state.activeProfile; } isTapeOn() { return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; } addTapeNode(e, t, n, s, r, a) { let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: r }, o = rx(e); o != null && (s = o.gradFunc), s != null && (i.gradient = (u) => (u = u.map((l, c) => { if (l == null) { let p = n[c], d = jd(p.size, p.dtype); return this.makeTensor(d, p.shape, p.dtype); } return l; }), s(u.length > 1 ? u : u[0], r, a))), this.state.activeTape.push(i); } keep(e) { return e.kept = true, 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 = Fg(e), n = new Set(t.map((r) => r.id)); for (let r = 0; r < this.state.activeScope.track.length; r++) { let a = this.state.activeScope.track[r]; !a.kept && !n.has(a.id) && a.dispose(); } let s = this.state.scopeStack.pop(); this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t.forEach((r) => { !r.kept && r.scopeId === s.id && this.track(r); }); } gradients(e, t, n, s = false) { if (O(t.length > 0, () => "gradients() received an empty list of xs."), n != null && n.dtype !== "float32") throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`); let r = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", e)); O(r instanceof et, () => "The result y returned by f() must be a tensor."); let a = Y$(this.state.activeTape, t, r); if (!s && a.length === 0 && t.length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y."); return this.tidy("backward", () => { let i = {}; i[r.id] = n == null ? l_(r.shape) : n, Q$(i, a, (u) => this.tidy(u), c_); let o = t.map((u) => i[u.id]); return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((u) => { for (let l of u.saved) l.dispose(); }), this.state.activeTape = null), { value: r, grads: o }; }); } customGrad(e) { return O(fr(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { O(t.every((i) => i instanceof et), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors"); let n, s = {}; t.forEach((i, o) => { s[o] = i; }); let r = (i, o) => (n = e(...t, o), O(n.value instanceof et, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), O(fr(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (i, o) => { let u = n.gradFunc(i, o), l = Array.isArray(u) ? u : [u]; O(l.length === t.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), O(l.every((p) => p instanceof et), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."); let c = {}; return l.forEach((p, d) => { c[d] = () => p; }), c; }; return this.runKernelFunc({ forwardFunc: r, backwardsFunc: a, inputs: s }); }; } readSync(e) { return this.state.tensorInfo.get(e).backend.readSync(e); } read(e) { return this.state.tensorInfo.get(e).backend.read(e); } readToGPU(e, t) { return this.state.tensorInfo.get(e).backend.readToGPU(e, t); } async time(e) { let t = Gu(), n = await this.backend.time(e); return n.wallMs = Gu() - t, n; } track(e) { return this.state.activeScope != null && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e; } get registeredVariables() { return this.state.registeredVariables; } reset() { this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new ux(); 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; } }; var Og = nm; Og.nextTensorId = 0; Og.nextVariableId = 0; function l_(e) { let t = rg(pt(e), "float32"); return M.makeTensor(t, e, "float32"); } function mk() { let e = ak(); if (e._tfengine == null) { let t = new _$(e); e._tfengine = new Og(t); } return D$(e._tfengine.ENV), t_(() => e._tfengine), e._tfengine; } var M = mk(); function c_(e, t) { let n = { a: e, b: t }; return M.runKernel(Sr, n); } var hp = {}; Ae(hp, { isBrowser: () => gk, isMobile: () => h_, mockIsMobile: () => p_ }); function d_() { return typeof navigator != "undefined" && navigator != null; } var sm; function p_(e) { sm = e; } function h_(e) { if (sm !== void 0) return sm; if (e || d_()) { if (e || (e = navigator), e.product === "ReactNative") return true; let t = e.userAgent || e.vendor || (typeof window != "undefined" ? window.opera : ""); if (!t) { let n = e; return n.userAgentData && n.userAgentData.mobile; } return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4)); } return false; } function gk() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } var Kn = X(); Kn.registerFlag("DEBUG", () => false, (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."); }); Kn.registerFlag("IS_BROWSER", () => gk()); Kn.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); Kn.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); Kn.registerFlag("PROD", () => false); Kn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => Kn.getBool("DEBUG")); Kn.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true); Kn.registerFlag("IS_TEST", () => false); Kn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true); Kn.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); Kn.registerFlag("ENGINE_COMPILE_ONLY", () => false); function Rs(e, t) { let n = e; if (Yt(e)) return t === "string" ? [] : [e.length]; if (!Array.isArray(e)) return []; let s = []; for (; Array.isArray(n) || Yt(n) && t !== "string"; ) s.push(n.length), n = n[0]; return Array.isArray(e) && X().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && bk(e, s, []), s; } function bk(e, t, n) { if (n = n || [], !Array.isArray(e) && !Yt(e)) { O(t.length === 0, () => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`); return; } O(t.length > 0, () => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`), O(e.length === t[0], () => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`); let s = t.slice(1); for (let r = 0; r < e.length; ++r) bk(e[r], s, n.concat(r)); } function lx(e, t, n, s) { if (e !== "string_or_numeric") { if (e == null) throw new Error("Expected dtype cannot be null."); if (e !== "numeric" && e !== t || e === "numeric" && t === "string") throw new Error(`Argument '${n}' passed to '${s}' must be ${e} tensor, but got ${t} tensor`); } } function _(e, t, n, s = "numeric") { if (e instanceof et) return lx(s, e.dtype, t, n), e; let r = qd(e); if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), lx(s, r, t, n), e == null || !Yt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") { let u = e == null ? "null" : e.constructor.name; throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${u}'`); } let a = Rs(e, r); !Yt(e) && !Array.isArray(e) && (e = [e]); let o = r !== "string" ? dp(e, r) : ra(e, [], true); return M.makeTensor(o, a, r); } function Hu(e, t, n, s = "numeric") { if (!Array.isArray(e)) throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``); return e.map((a, i) => _(a, `${t}[${i}]`, n, s)); } var f_ = "__op"; function L(e) { let t = Object.keys(e); if (t.length !== 1) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`); let n = t[0], s = e[n]; n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n + f_; let r = (...a) => { M.startScope(n); try { let i = s(...a); return ig(i) && console.error("Cannot return a Promise inside of tidy."), M.endScope(i), i; } catch (i) { throw M.endScope(null), i; } }; return Object.defineProperty(r, "name", { value: n, configurable: true }), r; } function m_(e, t) { let n = _(e, "real", "complex"), s = _(t, "imag", "complex"); pn(n.shape, s.shape, `real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`); let r = { real: n, imag: s }; return M.runKernel(Xd, r); } var ua = L({ complex_: m_ }); function Tr(e, t, n, s) { if (s == null && (s = qd(e)), s === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if (!Yt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray"); if (t != null) { ag(t); let r = pt(t), a = pt(n); O(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`); for (let i = 0; i < n.length; ++i) { let o = n[i], u = i === n.length - 1 ? o !== pt(t.slice(i)) : true; O(n[i] === t[i] || !u, () => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `); } } return !Yt(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? dp(e, s) : ra(e, [], true), M.makeTensor(e, t, s); } function fs(e, t, n) { let s = Rs(e, n); return Tr(e, t, s, n); } var rm = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; var bd = 4; async function g_(e, t) { let n = [], s = [], r = Array.isArray(e) ? e.map((i) => i.name) : Object.keys(e); for (let i = 0; i < r.length; ++i) { let o = r[i], u = Array.isArray(e) ? e[i].tensor : e[o]; if (u.dtype !== "float32" && u.dtype !== "int32" && u.dtype !== "bool" && u.dtype !== "string" && u.dtype !== "complex64") throw new Error(`Unsupported dtype in weight '${o}': ${u.dtype}`); let l = { name: o, shape: u.shape, dtype: u.dtype }; if (u.dtype === "string") { let c = new Promise(async (p) => { let d = await u.bytes(), h = d.reduce((g, b) => g + b.length, 0) + bd * d.length, f = new Uint8Array(h), m = 0; for (let g = 0; g < d.length; g++) { let b = d[g], y = new Uint8Array(new Uint32Array([b.length]).buffer); f.set(y, m), m += bd, f.set(b, m), m += b.length; } p(f); }); s.push(c); } else s.push(u.data()); t != null && (l.group = t), n.push(l); } let a = await Promise.all(s); return { data: b_(a), specs: n }; } function yk(e, t) { let n = {}, s, r = 0; for (let a of t) { let i = a.name, o = a.dtype, u = a.shape, l = pt(u), c; if ("quantization" in a) { let p = a.quantization; if (p.dtype === "uint8" || p.dtype === "uint16") { if (!("min" in p && "scale" in p)) throw new Error(`Weight ${a.name} with quantization ${p.dtype} doesn't have corresponding metadata min and scale.`); } else if (p.dtype === "float16") { if (o !== "float32") throw new Error(`Weight ${a.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${o}.`); } else throw new Error(`Weight ${a.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); let d = rm[p.dtype], h = e.slice(r, r + l * d), f = p.dtype === "uint8" ? new Uint8Array(h) : new Uint16Array(h); if (o === "float32") if (p.dtype === "uint8" || p.dtype === "uint16") { c = new Float32Array(f.length); for (let m = 0; m < f.length; m++) { let g = f[m]; c[m] = g * p.scale + p.min; } } else if (p.dtype === "float16") s === void 0 && (s = I_()), c = s(f); else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`); else if (o === "int32") { if (p.dtype !== "uint8" && p.dtype !== "uint16") throw new Error(`Unsupported quantization type ${p.dtype} for weight type int32.`); c = new Int32Array(f.length); for (let m = 0; m < f.length; m++) { let g = f[m]; c[m] = Math.round(g * p.scale + p.min); } } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += l * d; } else if (o === "string") { let p = pt(a.shape); c = []; for (let d = 0; d < p; d++) { let h = new Uint32Array(e.slice(r, r + bd))[0]; r += bd; let f = new Uint8Array(e.slice(r, r + h)); c.push(f), r += h; } } else { let p = rm[o], d = e.slice(r, r + l * p); if (o === "float32") c = new Float32Array(d); else if (o === "int32") c = new Int32Array(d); else if (o === "bool") c = new Uint8Array(d); else if (o === "complex64") { c = new Float32Array(d); let h = new Float32Array(c.length / 2), f = new Float32Array(c.length / 2); for (let b = 0; b < h.length; b++) h[b] = c[b * 2], f[b] = c[b * 2 + 1]; let m = fs(h, u, "float32"), g = fs(f, u, "float32"); n[i] = ua(m, g), m.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += l * p; } o !== "complex64" && (n[i] = fs(c, u, o)); } return n; } function b_(e) { if (e === null) throw new Error(`Invalid input value: ${JSON.stringify(e)}`); let t = 0, n = []; e.forEach((a) => { if (t += a.byteLength, n.push(a.byteLength === a.buffer.byteLength ? a : new a.constructor(a)), !(a instanceof Float32Array || a instanceof Int32Array || a instanceof Uint8Array)) throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`); }); let s = new Uint8Array(t), r = 0; return n.forEach((a) => { s.set(new Uint8Array(a.buffer), r), r += a.byteLength; }), s.buffer; } var Pg = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); function cx(e) { return Pg ? Buffer.byteLength(e) : new Blob([e]).size; } function y_(e) { if (Pg) return Buffer.from(e).toString("base64"); let t = new Uint8Array(e), n = ""; for (let s = 0, r = t.length; s < r; s++) n += String.fromCharCode(t[s]); return btoa(n); } function v_(e) { if (Pg) { let s = Buffer.from(e, "base64"); return s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength); } let t = atob(e), n = new Uint8Array(t.length); for (let s = 0; s < t.length; ++s) n.set([t.charCodeAt(s)], s); return n.buffer; } function zg(e) { if (e.length === 1) return e[0]; let t = 0; e.forEach((r) => { t += r.byteLength; }); let n = new Uint8Array(t), s = 0; return e.forEach((r) => { n.set(new Uint8Array(r), s), s += r.byteLength; }), n.buffer; } function dx(e) { let t = "/"; for (e = e.trim(); e.endsWith(t); ) e = e.slice(0, e.length - 1); let n = e.split(t); return n[n.length - 1]; } function vk(e, t) { let n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, weightsManifest: t }; return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), n; } async function Mg(e, t) { let n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy }; if (e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), e.weightsManifest != null) { let [s, r] = await t(e.weightsManifest); n.weightSpecs = s, n.weightData = r; } return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), n; } function Fl(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 : cx(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : cx(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; } function x_() { let e = (n) => { let s = n << 13, r = 0; for (; (s & 8388608) === 0; ) r -= 8388608, s <<= 1; return s &= -8388609, r += 947912704, s | r; }, t = new Uint32Array(2048); t[0] = 0; for (let n = 1; n < 1024; n++) t[n] = e(n); for (let n = 1024; n < 2048; n++) t[n] = 939524096 + (n - 1024 << 13); return t; } function w_() { 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 k_() { let e = new Uint32Array(64); for (let t = 0; t < 64; t++) e[t] = 1024; return e[0] = e[32] = 0, e; } function I_() { let e = x_(), t = w_(), n = k_(); return (s) => { let r = new ArrayBuffer(4 * s.length), a = new Uint32Array(r); for (let i = 0; i < s.length; i++) { let o = s[i], u = e[n[o >> 10] + (o & 1023)] + t[o >> 10]; a[i] = u; } return new Float32Array(r); }; } var xt = class { constructor() { this.saveRouters = [], this.loadRouters = []; } static getInstance() { return xt.instance == null && (xt.instance = new xt()), xt.instance; } static registerSaveRouter(e) { xt.getInstance().saveRouters.push(e); } static registerLoadRouter(e) { xt.getInstance().loadRouters.push(e); } static getSaveHandlers(e) { return xt.getHandlers(e, "save"); } static getLoadHandlers(e, t) { return xt.getHandlers(e, "load", t); } static getHandlers(e, t, n) { let s = []; return (t === "load" ? xt.getInstance().loadRouters : xt.getInstance().saveRouters).forEach((a) => { let i = a(e, n); i !== null && s.push(i); }), s; } }; var S_ = (e) => xt.registerSaveRouter(e); var C_ = (e) => xt.registerLoadRouter(e); var N_ = (e) => xt.getSaveHandlers(e); var T_ = (e, t) => xt.getLoadHandlers(e, t); var am = "tensorflowjs"; var im = 1; var Qr = "models_store"; var ur = "model_info_store"; function xk() { if (!X().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); let e = typeof window == "undefined" ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB; if (t == null) throw new Error("The current browser does not appear to support IndexedDB."); return t; } function om(e) { let t = e.result; t.createObjectStore(Qr, { keyPath: "modelPath" }), t.createObjectStore(ur, { keyPath: "modelPath" }); } var la = class { constructor(e) { if (this.indexedDB = xk(), e == null || !e) throw new Error("For IndexedDB, modelPath must not be null, undefined or empty."); this.modelPath = e; } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); return this.databaseAction(this.modelPath, e); } async load() { return this.databaseAction(this.modelPath); } databaseAction(e, t) { return new Promise((n, s) => { let r = this.indexedDB.open(am, im); r.onupgradeneeded = () => om(r), r.onsuccess = () => { let a = r.result; if (t == null) { let i = a.transaction(Qr, "readonly"), u = i.objectStore(Qr).get(this.modelPath); u.onsuccess = () => { if (u.result == null) return a.close(), s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`)); n(u.result.modelArtifacts); }, u.onerror = (l) => (a.close(), s(u.error)), i.oncomplete = () => a.close(); } else { let i = Fl(t), o = a.transaction(ur, "readwrite"), u = o.objectStore(ur), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), c; l.onsuccess = () => { c = a.transaction(Qr, "readwrite"); let d = c.objectStore(Qr).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); d.onsuccess = () => n({ modelArtifactsInfo: i }), d.onerror = (h) => { u = o.objectStore(ur); let f = u.delete(this.modelPath); f.onsuccess = () => (a.close(), s(d.error)), f.onerror = (m) => (a.close(), s(d.error)); }; }, l.onerror = (p) => (a.close(), s(l.error)), o.oncomplete = () => { c == null ? a.close() : c.oncomplete = () => a.close(); }; } }, r.onerror = (a) => s(r.error); }); } }; la.URL_SCHEME = "indexeddb://"; var wk = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(la.URL_SCHEME) ? $_(e.slice(la.URL_SCHEME.length)) : null; xt.registerSaveRouter(wk); xt.registerLoadRouter(wk); function $_(e) { return new la(e); } function __(e) { return e.startsWith(la.URL_SCHEME) ? e.slice(la.URL_SCHEME.length) : e; } var A_ = class { constructor() { this.indexedDB = xk(); } async listModels() { return new Promise((e, t) => { let n = this.indexedDB.open(am, im); n.onupgradeneeded = () => om(n), n.onsuccess = () => { let s = n.result, r = s.transaction(ur, "readonly"), i = r.objectStore(ur).getAll(); i.onsuccess = () => { let o = {}; for (let u of i.result) o[u.modelPath] = u.modelArtifactsInfo; e(o); }, i.onerror = (o) => (s.close(), t(i.error)), r.oncomplete = () => s.close(); }, n.onerror = (s) => t(n.error); }); } async removeModel(e) { return e = __(e), new Promise((t, n) => { let s = this.indexedDB.open(am, im); s.onupgradeneeded = () => om(s), s.onsuccess = () => { let r = s.result, a = r.transaction(ur, "readwrite"), i = a.objectStore(ur), o = i.get(e), u; o.onsuccess = () => { if (o.result == null) return r.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { let l = i.delete(e), c = () => { u = r.transaction(Qr, "readwrite"); let d = u.objectStore(Qr).delete(e); d.onsuccess = () => t(o.result.modelArtifactsInfo), d.onerror = (h) => n(o.error); }; l.onsuccess = c, l.onerror = (p) => (c(), r.close(), n(o.error)); } }, o.onerror = (l) => (r.close(), n(o.error)), a.oncomplete = () => { u == null ? r.close() : u.oncomplete = () => r.close(); }; }, s.onerror = (r) => n(s.error); }); } }; var Gs = "/"; var Hi = "tensorflowjs_models"; var kk = "info"; var E_ = "model_topology"; var R_ = "weight_specs"; var D_ = "weight_data"; var F_ = "model_metadata"; function Ik(e) { return { info: [Hi, e, kk].join(Gs), topology: [Hi, e, E_].join(Gs), weightSpecs: [Hi, e, R_].join(Gs), weightData: [Hi, e, D_].join(Gs), modelMetadata: [Hi, e, F_].join(Gs) }; } function Sk(e) { for (let t of Object.values(e)) window.localStorage.removeItem(t); } function O_(e) { let t = e.split(Gs); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); return t.slice(1, t.length - 1).join(Gs); } function P_(e) { return e.startsWith(ca.URL_SCHEME) ? e.slice(ca.URL_SCHEME.length) : e; } var ca = class { constructor(e) { if (!X().getBool("IS_BROWSER") || typeof window == "undefined" || typeof window.localStorage == "undefined") throw new Error("The current environment does not support local storage."); if (this.LS = window.localStorage, e == null || !e) throw new Error("For local storage, modelPath must not be null, undefined or empty."); this.modelPath = e, this.keys = Ik(this.modelPath); } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); { let t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), s = Fl(e); try { this.LS.setItem(this.keys.info, JSON.stringify(s)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, y_(e.weightData)); let r = { format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, signature: e.signature != null ? e.signature : void 0, userDefinedMetadata: e.userDefinedMetadata != null ? e.userDefinedMetadata : void 0, modelInitializer: e.modelInitializer != null ? e.modelInitializer : void 0, trainingConfig: e.trainingConfig != null ? e.trainingConfig : void 0 }; return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(r)), { modelArtifactsInfo: s }; } catch (r) { throw Sk(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`); } } } async load() { let e = JSON.parse(this.LS.getItem(this.keys.info)); if (e == null) throw new Error(`In local storage, there is no model with name '${this.modelPath}'`); if (e.modelTopologyType !== "JSON") throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet."); let t = {}, n = JSON.parse(this.LS.getItem(this.keys.topology)); if (n == null) throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`); t.modelTopology = n; let s = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); if (s == null) throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`); t.weightSpecs = s; let r = this.LS.getItem(this.keys.modelMetadata); if (r != null) { let i = JSON.parse(r); t.format = i.format, t.generatedBy = i.generatedBy, t.convertedBy = i.convertedBy, i.signature != null && (t.signature = i.signature), i.userDefinedMetadata != null && (t.userDefinedMetadata = i.userDefinedMetadata), i.modelInitializer != null && (t.modelInitializer = i.modelInitializer), i.trainingConfig != null && (t.trainingConfig = i.trainingConfig); } let a = this.LS.getItem(this.keys.weightData); if (a == null) throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`); return t.weightData = v_(a), t; } }; ca.URL_SCHEME = "localstorage://"; var Ck = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(ca.URL_SCHEME) ? z_(e.slice(ca.URL_SCHEME.length)) : null; xt.registerSaveRouter(Ck); xt.registerLoadRouter(Ck); function z_(e) { return new ca(e); } var M_ = class { constructor() { O(X().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), O(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage; } async listModels() { let e = {}, t = Hi + Gs, n = Gs + kk; for (let s = 0; s < this.LS.length; ++s) { let r = this.LS.key(s); if (r.startsWith(t) && r.endsWith(n)) { let a = O_(r); e[a] = JSON.parse(this.LS.getItem(r)); } } return e; } async removeModel(e) { e = P_(e); let t = Ik(e); if (this.LS.getItem(t.info) == null) throw new Error(`Cannot find model at path '${e}'`); let n = JSON.parse(this.LS.getItem(t.info)); return Sk(t), n; } }; var Ki = "://"; var zn = class { constructor() { this.managers = {}; } static getInstance() { return zn.instance == null && (zn.instance = new zn()), zn.instance; } static registerManager(e, t) { O(e != null, () => "scheme must not be undefined or null."), e.endsWith(Ki) && (e = e.slice(0, e.indexOf(Ki))), O(e.length > 0, () => "scheme must not be an empty string."); let n = zn.getInstance(); O(n.managers[e] == null, () => `A model store manager is already registered for scheme '${e}'.`), n.managers[e] = t; } static getManager(e) { let t = this.getInstance().managers[e]; if (t == null) throw new Error(`Cannot find model manager for scheme '${e}'`); return t; } static getSchemes() { return Object.keys(this.getInstance().managers); } }; function td(e) { if (e.indexOf(Ki) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(",")}`); return { scheme: e.split(Ki)[0], path: e.split(Ki)[1] }; } async function Nk(e, t, n = false) { O(e !== t, () => `Old path and new path are the same: '${e}'`); let s = xt.getLoadHandlers(e); O(s.length > 0, () => `Copying failed because no load handler is found for source URL ${e}.`), O(s.length < 2, () => `Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`); let r = s[0], a = xt.getSaveHandlers(t); O(a.length > 0, () => `Copying failed because no save handler is found for destination URL ${t}.`), O(a.length < 2, () => `Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`); let i = a[0], o = td(e).scheme, u = td(e).path, l = o === td(e).scheme, c = await r.load(); n && l && await zn.getManager(o).removeModel(u); let p = await i.save(c); return n && !l && await zn.getManager(o).removeModel(u), p.modelArtifactsInfo; } async function L_() { let e = zn.getSchemes(), t = {}; for (let n of e) { let s = await zn.getManager(n).listModels(); for (let r in s) { let a = n + Ki + r; t[a] = s[r]; } } return t; } async function B_(e) { let t = td(e); return zn.getManager(t.scheme).removeModel(t.path); } async function V_(e, t) { return Nk(e, t, false); } async function W_(e, t) { return Nk(e, t, true); } var U_ = class { fetch(e, t) { return fetch(e, t); } now() { return performance.now(); } encode(e, t) { if (t !== "utf-8" && t !== "utf8") throw new Error(`Browser's encoder only supports utf-8, but got ${t}`); return this.textEncoder == null && (this.textEncoder = new TextEncoder()), this.textEncoder.encode(e); } decode(e, t) { return new TextDecoder(t).decode(e); } }; if (X().get("IS_BROWSER")) { X().setPlatform("browser", new U_()); try { zn.registerManager(ca.URL_SCHEME, new M_()); } catch (e) { } try { zn.registerManager(la.URL_SCHEME, new A_()); } catch (e) { } } var G_ = { importFetch: () => QT() }; var Mf; var H_ = class { constructor() { this.util = ZT(), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { return X().global.fetch != null ? X().global.fetch(e, t) : (Mf == null && (Mf = G_.importFetch()), Mf(e, t)); } now() { let e = process.hrtime(); return e[0] * 1e3 + e[1] / 1e6; } encode(e, t) { if (t !== "utf-8" && t !== "utf8") throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`); return this.textEncoder.encode(e); } decode(e, t) { return e.length === 0 ? "" : new this.util.TextDecoder(t).decode(e); } }; X().get("IS_NODE") && !X().get("IS_BROWSER") && X().setPlatform("node", new H_()); function De(e, t = "float32", n) { return t = t || "float32", ag(e), new Vt(e, t, n); } function q_(e, t) { let n = _(e, "x", "cast"); if (!Jw(t)) throw new Error(`Failed to cast to unknown dtype ${t}`); if (t === "string" && n.dtype !== "string" || t !== "string" && n.dtype === "string") throw new Error("Only strings can be casted to strings"); let s = { x: n }, r = { dtype: t }; return M.runKernel(Ta, s, r); } var ce = L({ cast_: q_ }); function j_(e) { let n = { x: _(e, "x", "clone", "string_or_numeric") }; return M.runKernel(Wa, n); } var cr = L({ clone_: j_ }); function K_(e, t = false) { console.log(e.toString(t)); } mk(); var X_ = { buffer: De, cast: ce, clone: cr, print: K_ }; n_(X_); var An = {}; Ae(An, { browserFiles: () => nA, browserHTTPRequest: () => oA, concatenateArrayBuffers: () => zg, copyModel: () => V_, decodeWeights: () => yk, encodeWeights: () => g_, fromMemory: () => lA, getLoadHandlers: () => T_, getModelArtifactsForJSON: () => Mg, getModelArtifactsInfoForJSON: () => Fl, getSaveHandlers: () => N_, http: () => Bg, isHTTPScheme: () => lm, listModels: () => L_, loadWeights: () => sA, moveModel: () => W_, registerLoadRouter: () => C_, registerSaveRouter: () => S_, removeModel: () => B_, weightsLoaderFactory: () => $k, withSaveHandler: () => cA }); var Y_ = "model"; var Q_ = ".json"; var Z_ = ".weights.bin"; function px(e) { return new Promise((t) => setTimeout(t)).then(e); } var um = class { constructor(e) { if (!X().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(um.URL_SCHEME) && (e = e.slice(um.URL_SCHEME.length)), (e == null || e.length === 0) && (e = Y_), this.modelJsonFileName = e + Q_, this.weightDataFileName = e + Z_; } async save(e) { if (typeof document == "undefined") throw new Error("Browser downloads are not supported in this environment since `document` is not present"); let t = window.URL.createObjectURL(new Blob([e.weightData], { type: "application/octet-stream" })); if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet."); { let n = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], s = vk(e, n), r = window.URL.createObjectURL(new Blob([JSON.stringify(s)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; if (a.download = this.modelJsonFileName, a.href = r, await px(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) { let i = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; i.download = this.weightDataFileName, i.href = t, await px(() => i.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: Fl(e) }; } } }; var yd = um; yd.URL_SCHEME = "downloads://"; var J_ = class { constructor(e) { if (e == null || e.length < 1) throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`); this.jsonFile = e[0], this.weightsFiles = e.slice(1); } async load() { return new Promise((e, t) => { let n = new FileReader(); n.onload = (s) => { let r = JSON.parse(s.target.result), a = r.modelTopology; if (a == null) { t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); return; } if (r.weightsManifest == null) { t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`)); return; } if (this.weightsFiles.length === 0) { e({ modelTopology: a }); return; } let o = Mg(r, (u) => this.loadWeights(u)); e(o); }, n.onerror = (s) => t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), n.readAsText(this.jsonFile); }); } loadWeights(e) { let t = [], n = []; for (let a of e) t.push(...a.weights), n.push(...a.paths); let s = this.checkManifestAndWeightFiles(e), r = n.map((a) => this.loadWeightsFile(a, s[a])); return Promise.all(r).then((a) => [t, zg(a)]); } loadWeightsFile(e, t) { return new Promise((n, s) => { let r = new FileReader(); r.onload = (a) => { let i = a.target.result; n(i); }, r.onerror = (a) => s(`Failed to weights data from file of path '${e}'.`), r.readAsArrayBuffer(t); }); } checkManifestAndWeightFiles(e) { let t = [], n = this.weightsFiles.map((r) => dx(r.name)), s = {}; for (let r of e) r.paths.forEach((a) => { let i = dx(a); if (t.indexOf(i) !== -1) throw new Error(`Duplicate file basename found in weights manifest: '${i}'`); if (t.push(i), n.indexOf(i) === -1) throw new Error(`Weight file with basename '${i}' is not provided.`); s[a] = this.weightsFiles[n.indexOf(i)]; }); if (t.length !== this.weightsFiles.length) throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`); return s; } }; var eA = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(yd.URL_SCHEME) ? tA(e.slice(yd.URL_SCHEME.length)) : null; xt.registerSaveRouter(eA); function tA(e = "model") { return new yd(e); } function nA(e) { return new J_(e); } function hx(e, t, n, s) { i(e), n = n == null ? 0 : n, s = s == null ? 1 : s, o(n, s); let r = 0, a = (u) => (u.then((l) => { let c = n + ++r / e.length * (s - n); return t(c), l; }), u); function i(u) { O(u != null && Array.isArray(u) && u.length > 0, () => "promises must be a none empty array"); } function o(u, l) { O(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${u}`), O(l >= 0 && l <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${l}`), O(l >= u, () => `startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`); } return Promise.all(e.map(a)); } async function Tk(e, t) { t == null && (t = {}); let n = t.fetchFunc == null ? X().platform.fetch : t.fetchFunc, s = e.map((p) => n(p, t.requestInit, { isBinary: true })), r = 0, a = 0.5, o = (t.onProgress == null ? await Promise.all(s) : await hx(s, t.onProgress, r, a)).map((p) => p.arrayBuffer()), u = 0.5, l = 1; return t.onProgress == null ? await Promise.all(o) : await hx(o, t.onProgress, u, l); } async function sA(e, t = "", n, s) { return $k((i) => Tk(i, { requestInit: s }))(e, t, n); } function $k(e) { return async (t, n = "", s) => { let r = t.map(() => false), a = {}, i = s != null ? s.map(() => false) : [], o = []; if (t.forEach((h, f) => { let m = 0; h.weights.forEach((g) => { let b = "quantization" in g ? g.quantization.dtype : g.dtype, y = rm[b] * pt(g.shape), v = () => { r[f] = true, a[f] == null && (a[f] = []), a[f].push({ manifestEntry: g, groupOffset: m, sizeBytes: y }); }; s != null ? s.forEach((x, k) => { x === g.name && (v(), i[k] = true); }) : v(), o.push(g.name), m += y; }); }), !i.every((h) => h)) { let h = s.filter((f, m) => !i[m]); throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`); } let u = r.reduce((h, f, m) => (f && h.push(m), h), []), l = []; u.forEach((h) => { t[h].paths.forEach((f) => { let m = n + (n.endsWith("/") ? "" : "/") + f; l.push(m); }); }); let c = await e(l), p = {}, d = 0; return u.forEach((h) => { let f = t[h].paths.length, m = 0; for (let x = 0; x < f; x++) m += c[d + x].byteLength; let g = new ArrayBuffer(m), b = new Uint8Array(g), y = 0; for (let x = 0; x < f; x++) { let k = new Uint8Array(c[d + x]); b.set(k, y), y += k.byteLength; } a[h].forEach((x) => { let k = g.slice(x.groupOffset, x.groupOffset + x.sizeBytes), S = yk(k, [x.manifestEntry]); for (let $ in S) p[$] = S[$]; }), d += f; }), p; }; } var rA = "application/octet-stream"; var aA = "application/json"; var Lg = class { constructor(e, t) { if (this.DEFAULT_METHOD = "POST", t == null && (t = {}), this.weightPathPrefix = t.weightPathPrefix, this.onProgress = t.onProgress, this.weightUrlConverter = t.weightUrlConverter, t.fetchFunc != null ? (O(typeof t.fetchFunc == "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"), this.fetch = t.fetchFunc) : this.fetch = X().platform.fetch, O(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && O(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t.requestInit != null && t.requestInit.body != null) throw new Error("requestInit is expected to have no pre-existing body, but has one."); this.requestInit = t.requestInit || {}; } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); let t = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit); t.body = new FormData(); let n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], s = vk(e, n); t.body.append("model.json", new Blob([JSON.stringify(s)], { type: aA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: rA }), "model.weights.bin"); let r = await this.fetch(this.path, t); if (r.ok) return { modelArtifactsInfo: Fl(e), responses: [r] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`); } async load() { let e = await this.fetch(this.path, this.requestInit); if (!e.ok) throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`); let t; try { t = await e.json(); } catch (r) { let a = `Failed to parse model JSON of response from ${this.path}.`; throw this.path.endsWith(".pb") ? a += " Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository." : a += " Please make sure the server is serving valid JSON for this request.", new Error(a); } let n = t.modelTopology, s = t.weightsManifest; if (n == null && s == null) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); return Mg(t, (r) => this.loadWeights(r)); } async loadWeights(e) { let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, s] = iA(t), r = this.weightPathPrefix || n, a = []; for (let l of e) a.push(...l.weights); let i = [], o = []; for (let l of e) for (let c of l.paths) this.weightUrlConverter != null ? o.push(this.weightUrlConverter(c)) : i.push(r + c + s); this.weightUrlConverter && i.push(...await Promise.all(o)); let u = await Tk(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); return [a, zg(u)]; } }; Lg.URL_SCHEME_REGEX = /^https?:\/\//; function iA(e) { let t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), s = e.substring(0, t), r = n > t ? e.substring(n) : ""; return [s + "/", r]; } function lm(e) { return e.match(Lg.URL_SCHEME_REGEX) != null; } var _k = (e, t) => { if (typeof fetch == "undefined" && (t == null || t.fetchFunc == null)) return null; { let n = true; if (Array.isArray(e) ? n = e.every((s) => lm(s)) : n = lm(e), n) return Bg(e, t); } return null; }; xt.registerSaveRouter(_k); xt.registerLoadRouter(_k); function Bg(e, t) { return new Lg(e, t); } function oA(e, t) { return Bg(e, t); } var Lf = class { constructor(e) { this.modelArtifacts = e; } async load() { return this.modelArtifacts; } }; var uA = class { constructor(e) { this.saveHandler = e; } async save(e) { return this.saveHandler(e); } }; function lA(e, t, n, s) { return arguments.length === 1 ? e.modelTopology != null || e.weightSpecs != null ? new Lf(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 Lf({ 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 Lf({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: s })); } function cA(e) { return new uA(e); } var dA = {}; Ae(dA, { confusionMatrix: () => gA }); function pA(e, t, n = false, s = false) { let r = _(e, "a", "matMul"), a = _(t, "b", "matMul"); [r, a] = vt(r, a); let i = { a: r, b: a }, o = { transposeA: n, transposeB: s }; return M.runKernel(Na, i, o); } var We = L({ matMul_: pA }); function hA(e, t, n = 1, s = 0) { if (t < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`); let a = { indices: _(e, "indices", "oneHot", "int32") }, i = { depth: t, onValue: n, offValue: s }; return M.runKernel(Ao, a, i); } var vd = L({ oneHot_: hA }); function fA(e, t) { let n = _(e, "x", "transpose"); if (t == null && (t = n.shape.map((a, i) => i).reverse()), O(n.rank === t.length, () => `Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`), t.forEach((a) => { O(a >= 0 && a < n.rank, () => `All entries in 'perm' must be between 0 and ${n.rank - 1} but got ${t}`); }), n.rank <= 1) return n.clone(); let s = { x: n }, r = { perm: t }; return M.runKernel(mi, s, r); } var Ge = L({ transpose_: fA }); function mA(e, t, n) { let s = _(e, "labels", "confusionMatrix"), r = _(t, "predictions", "confusionMatrix"); O(n == null || n > 0 && Number.isInteger(n), () => `If provided, numClasses must be a positive integer, but got ${n}`), O(s.rank === 1, () => `Expected the rank of labels to be 1, but got ${s.rank}`), O(r.rank === 1, () => `Expected the rank of predictions to be 1, but got ${r.rank}`), O(s.shape[0] === r.shape[0], () => `Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`), O(n > 0 && Number.isInteger(n), () => `numClasses is required to be a positive integer, but got ${n}`); let a = vd(ce(s, "int32"), n), i = vd(ce(r, "int32"), n), o = Ge(a), u = We(o, i); return ce(u, "int32"); } var gA = L({ confusionMatrix_: mA }); var Ko = {}; Ae(Ko, { assertAndGetBroadcastShape: () => it, getBroadcastDims: () => Ak, getReductionAxes: () => _t }); function Ak(e, t) { let n = e.length, s = []; for (let r = 0; r < n; r++) { let a = n - 1 - r, i = e[a] || 1; (t[t.length - 1 - r] || 1) > 1 && i === 1 && s.unshift(a); } return s; } function _t(e, t) { let n = []; for (let s = 0; s < t.length; s++) { let r = e[e.length - s - 1], a = t.length - s - 1, i = t[a]; (r == null || r === 1 && i > 1) && n.unshift(a); } return n; } function it(e, t) { let n = [], s = Math.max(e.length, t.length); for (let r = 0; r < s; r++) { let a = e[e.length - r - 1]; a == null && (a = 1); let i = t[t.length - r - 1]; if (i == null && (i = 1), a === 1) n.unshift(i); else if (i === 1) n.unshift(a); else if (a !== i) { let o = `Operands could not be broadcast together with shapes ${e} and ${t}.`; throw Error(o); } else n.unshift(a); } return n; } var Ek = {}; Ae(Ek, { fromPixels: () => SA, fromPixelsAsync: () => kA, toPixels: () => IA }); function bA(e, t, n) { if (ka(e), t != null && t.length !== 3) throw new Error("tensor3d() requires shape to have three numbers"); let s = Rs(e, n); if (s.length !== 3 && s.length !== 1) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (s.length === 1 && t == null) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); return Tr(e, t, s, n); } var Wr; function Rk(e, t = 3) { if (t > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (e == null) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); let n = false, s = false, r = false, a = false, i = false, o = false; if (e.data instanceof Uint8Array) n = true; else if (typeof ImageData != "undefined" && e instanceof ImageData) s = true; else if (typeof HTMLVideoElement != "undefined" && e instanceof HTMLVideoElement) r = true; else if (typeof HTMLImageElement != "undefined" && e instanceof HTMLImageElement) a = true; else if (e.getContext != null) i = true; else if (typeof ImageBitmap != "undefined" && e instanceof ImageBitmap) o = true; else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`); if (r && r && e.readyState < 2) throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the