/* 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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b10) => (typeof require !== "undefined" ? require : a)[b10] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw new Error('Dynamic require of "' + x + '" is not supported'); }); var __export = (target, all2) => { __markAsModule(target); 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 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: ${path} expecting json file`); return path; } 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); } 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: "", wasmPath: "", debug: true, async: true, warmup: "full", cacheSensitivity: 0.75, skipFrame: false, filter: { enabled: true, 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: 11, skipTime: 2e3, minConfidence: 0.2, iouThreshold: 0.1, return: false }, mesh: { enabled: true, modelPath: "facemesh.json" }, iris: { enabled: true, modelPath: "iris.json" }, emotion: { enabled: true, minConfidence: 0.1, skipFrames: 12, skipTime: 2e3, modelPath: "emotion.json" }, description: { enabled: true, modelPath: "faceres.json", skipFrames: 13, skipTime: 2e3, minConfidence: 0.1 }, antispoof: { enabled: false, skipFrames: 14, skipTime: 2e3, modelPath: "antispoof.json" } }, body: { enabled: true, modelPath: "movenet-lightning.json", detector: { modelPath: "" }, maxDetected: -1, minConfidence: 0.3, skipFrames: 1, skipTime: 2e3 }, hand: { enabled: true, rotation: true, skipFrames: 2, skipTime: 2e3, minConfidence: 0.5, iouThreshold: 0.2, maxDetected: -1, landmarks: true, detector: { modelPath: "handtrack.json" }, skeleton: { modelPath: "handskeleton.json" } }, object: { enabled: false, modelPath: "mb3-centernet.json", minConfidence: 0.2, iouThreshold: 0.4, maxDetected: 10, skipFrames: 15, skipTime: 2e3 }, segmentation: { enabled: false, modelPath: "selfie.json", blur: 8 } }; // dist/tfjs.esm.js var tfjs_esm_exports = {}; __export(tfjs_esm_exports, { Abs: () => ti, Acos: () => Mi, Acosh: () => Li, AdadeltaOptimizer: () => Hu, AdagradOptimizer: () => qu, AdamOptimizer: () => Ku, AdamaxOptimizer: () => Xu, Add: () => jn, AddN: () => $o, All: () => zi, Any: () => Bi, ArgMax: () => Ro, ArgMin: () => ml, Asin: () => Vi, Asinh: () => Gi, Atan: () => Wi, Atan2: () => ji, Atanh: () => Ui, AvgPool: () => Fo, AvgPool3D: () => fl, AvgPool3DGrad: () => Uc, AvgPoolGrad: () => Wc, BackendWasm: () => xb, BatchMatMul: () => Oo, BatchToSpaceND: () => ri, Bincount: () => jc, BroadcastArgs: () => Hc, BroadcastTo: () => rN, Callback: () => Sv, CallbackList: () => Lk, Cast: () => eo, Ceil: () => Po, ClipByValue: () => to, Complex: () => qc, ComplexAbs: () => dl, Concat: () => ni, Conv2D: () => Mo, Conv2DBackpropFilter: () => Kc, Conv2DBackpropInput: () => Lo, Conv3D: () => hl, Conv3DBackpropFilterV2: () => Xc, Conv3DBackpropInputV2: () => Yc, Cos: () => zo, Cosh: () => Bo, CropAndResize: () => Hi, Cumsum: () => Vo, CustomCallback: () => Bk, DataStorage: () => pl, DenseBincount: () => Zc, DepthToSpace: () => qi, DepthwiseConv2dNative: () => Go, DepthwiseConv2dNativeBackpropFilter: () => Jc, DepthwiseConv2dNativeBackpropInput: () => Qc, Diag: () => ep, Dilation2D: () => gl, Dilation2DBackpropFilter: () => rf, Dilation2DBackpropInput: () => tf, ENV: () => Xw, EarlyStopping: () => Nv, Einsum: () => tp, Elu: () => Uo, EluGrad: () => rp, Environment: () => Eg, Equal: () => Xi, Erf: () => Ki, Exp: () => jo, ExpandDims: () => oi, Expm1: () => Yi, FFT: () => np, Fill: () => xl, FlipLeftRight: () => Zi, Floor: () => Ho, FloorDiv: () => qo, FromPixels: () => nf, FusedBatchNorm: () => Ko, FusedConv2D: () => xi, FusedDepthwiseConv2D: () => yi, GPGPUContext: () => Xy, GatherNd: () => Ji, GatherV2: () => si, GraphModel: () => ly, Greater: () => Qi, GreaterEqual: () => Xo, History: () => zk, IFFT: () => op, Identity: () => ro, Imag: () => sp, InputSpec: () => Tt, IsFinite: () => ea, IsInf: () => ta, IsNan: () => ra, KernelBackend: () => Js, LRN: () => yl, LRNGrad: () => ap, LayerVariable: () => Ex, LayersModel: () => Yn, LeakyRelu: () => Yo, Less: () => na, LessEqual: () => oa, LinSpace: () => ip, Log: () => Zo, Log1p: () => sa, LogSoftmax: () => nN, LogicalAnd: () => ia, LogicalNot: () => au, LogicalOr: () => lu, MathBackendWebGL: () => _c, Max: () => Jo, MaxPool: () => es, MaxPool3D: () => bl, MaxPool3DGrad: () => up, MaxPoolGrad: () => lp, MaxPoolWithArgmax: () => cp, Maximum: () => Qo, Mean: () => ts, Min: () => rs, Minimum: () => ns, MirrorPad: () => os, Mod: () => aa, MomentumOptimizer: () => Yu, Multinomial: () => pp, Multiply: () => ss, Neg: () => ii, NonMaxSuppressionV3: () => ua, NonMaxSuppressionV4: () => ca, NonMaxSuppressionV5: () => pa, NotEqual: () => la, OP_SCOPE_SUFFIX: () => $N, OneHot: () => is, OnesLike: () => ai, Optimizer: () => qr, Pack: () => li, PadV2: () => as, Pool: () => hse, Pow: () => ls, Prelu: () => us, Prod: () => ma, RMSPropOptimizer: () => Zu, RNN: () => Ln, Range: () => wl, Rank: () => s_, Real: () => mp, RealDiv: () => Wo, Reciprocal: () => fa, Reduction: () => Yt, Relu: () => cs, Relu6: () => ms, Reshape: () => ui, ResizeBilinear: () => ps, ResizeBilinearGrad: () => dp, ResizeNearestNeighbor: () => _l, ResizeNearestNeighborGrad: () => fp, Reverse: () => fs, RotateWithOffset: () => ka, Round: () => ds, Rsqrt: () => hs, SGDOptimizer: () => Ga, ScatterNd: () => da, Select: () => ci, Selu: () => ha, Sequential: () => qa, Sigmoid: () => xs, Sign: () => xa, Sin: () => gs, Sinh: () => ga, Slice: () => pi, Softmax: () => ws, Softplus: () => ya, SpaceToBatchND: () => mi, SparseFillEmptyRows: () => hp, SparseReshape: () => gp, SparseSegmentMean: () => xp, SparseSegmentSum: () => yp, SparseToDense: () => bp, SplitV: () => fi, Sqrt: () => ys, Square: () => kl, SquaredDifference: () => _s, Step: () => no, StridedSlice: () => ba, StringNGrams: () => wp, StringSplit: () => _p, StringToHashBucketFast: () => kp, Sub: () => ks, Sum: () => bs, SymbolicTensor: () => cn, Tan: () => vs, Tanh: () => Cs, Tensor: () => Le, TensorBuffer: () => mt, Tile: () => Hn, TopK: () => wa, Transform: () => _a, Transpose: () => Is, Unique: () => vp, Unpack: () => di, UnsortedSegmentSum: () => vl, Variable: () => Sl, ZerosLike: () => hi, _FusedMatMul: () => gi, abs: () => Ct, acos: () => df, acosh: () => hf, add: () => Z, addN: () => F_, all: () => wu, any: () => El, argMax: () => As, argMin: () => gf, asin: () => xf, asinh: () => yf, atan: () => bf, atan2: () => wf, atanh: () => _f, avgPool: () => Ta, avgPool3d: () => kf, backend: () => A1, backend_util: () => I, basicLSTMCell: () => IU, batchNorm: () => lo, batchNorm2d: () => L_, batchNorm3d: () => z_, batchNorm4d: () => B_, batchToSpaceND: () => Ea, bincount: () => vf, booleanMaskAsync: () => JSe, broadcastArgs: () => V_, broadcastTo: () => Aa, browser: () => Gg, buffer: () => Ie, callbacks: () => PX, cast: () => Y, ceil: () => Cf, clipByValue: () => gr, clone: () => wn, complex: () => Pn, concat: () => tt, concat1d: () => G_, concat2d: () => W_, concat3d: () => U_, concat4d: () => j_, constraints: () => W2, conv1d: () => vu, conv2d: () => nn, conv2dTranspose: () => Cu, conv3d: () => If, conv3dTranspose: () => H_, copyRegisteredKernels: () => kse, cos: () => Da, cosh: () => Iu, cosineWindow: () => sx, cumsum: () => Su, customGrad: () => on, data: () => v$, denseBincount: () => q_, deprecationWarn: () => R_, depthToSpace: () => Sf, depthwiseConv2d: () => $s, deregisterOp: () => LX, device_util: () => xu, diag: () => ej, dilation2d: () => Nf, disableDeprecationWarnings: () => sue, dispose: () => De, disposeVariables: () => iue, div: () => ce, divNoNan: () => Tf, dot: () => K_, dropout: () => eT, einsum: () => X_, elu: () => Rs, enableDebugMode: () => oue, enableProdMode: () => nue, enclosingPowerOfTwo: () => tT, engine: () => Es, env: () => U, equal: () => kr, erf: () => Ef, exp: () => Kt, expandDims: () => mr, expm1: () => Af, eye: () => Lp, fft: () => Ba, fill: () => Fs, findBackend: () => mue, findBackendFactory: () => fue, floor: () => Os, floorDiv: () => bu, forceHalfFloat: () => XP, fused: () => fo, gather: () => uo, gatherND: () => J1, gather_util: () => Wg, getBackend: () => cue, getGradient: () => Jw, getKernel: () => sf, getKernelsForBackend: () => Ag, getThreadsCount: () => Koe, gpgpu_util: () => XO, grad: () => Aj, grads: () => Dj, greater: () => zt, greaterEqual: () => kn, ifft: () => _i, imag: () => Nu, image: () => Cn, inTopKAsync: () => l1e, initializers: () => uA, input: () => Xk, io: () => Lr, irfft: () => zu, isFinite: () => Y_, isInf: () => Z_, isNaN: () => Df, keep: () => Ft, kernel_impls: () => Gr, layers: () => UA, leakyRelu: () => $a, less: () => Tu, lessEqual: () => vn, linalg: () => BT, linspace: () => J_, loadGraphModel: () => m7, loadLayersModel: () => K5, localResponseNormalization: () => $f, log: () => xr, log1p: () => Ra, logSigmoid: () => Q_, logSoftmax: () => Eu, logSumExp: () => Ff, logicalAnd: () => Cr, logicalNot: () => Fa, logicalOr: () => Au, logicalXor: () => nk, losses: () => oFe, matMul: () => ze, math: () => p1, max: () => Rr, maxPool: () => Oa, maxPool3d: () => Of, maxPoolWithArgmax: () => ok, maximum: () => sn, mean: () => xt, memory: () => ff, meshgrid: () => Qj, metrics: () => jA, min: () => Al, minimum: () => Ps, mirrorPad: () => Pf, mod: () => Mf, model: () => H5, models: () => HA, moments: () => zp, movingAverage: () => CNe, mul: () => O, multiRNNCell: () => aH, multinomial: () => sk, neg: () => He, nextFrame: () => wk, norm: () => Wp, notEqual: () => mo, oneHot: () => Ts, ones: () => or, onesLike: () => fr, op: () => N, outerProduct: () => mH, pad: () => jr, pad1d: () => hH, pad2d: () => xH, pad3d: () => bH, pad4d: () => _H, pool: () => ik, pow: () => Hr, prelu: () => Ma, print: () => C_, prod: () => Du, profile: () => aue, rand: () => AH, randomGamma: () => LH, randomNormal: () => tx, randomUniform: () => Ms, range: () => La, ready: () => uue, real: () => Dl, reciprocal: () => Lf, registerBackend: () => Op, registerCallbackConstructor: () => X5, registerGradient: () => oN, registerKernel: () => uu, registerOp: () => MX, regularizers: () => qA, relu: () => Ir, relu6: () => Ru, removeBackend: () => pue, reshape: () => F, reverse: () => er, reverse1d: () => qH, reverse2d: () => XH, reverse3d: () => ZH, reverse4d: () => QH, rfft: () => Va, round: () => Fu, rsqrt: () => Ou, scalar: () => pe, scatterND: () => Y1, scatter_util: () => jg, selu: () => Pu, separableConv2d: () => zf, sequential: () => q5, serialization: () => ee, setBackend: () => q4, setPlatform: () => due, setThreadsCount: () => qoe, setWasmPath: () => joe, setWasmPaths: () => Hoe, setWebGLContext: () => tC, setdiff1dAsync: () => xk, sigmoid: () => zr, sign: () => Bf, signal: () => DRe, sin: () => Mu, sinh: () => Lu, slice: () => Oe, slice1d: () => Vf, slice2d: () => rx, slice3d: () => Gf, slice4d: () => Vp, slice_util: () => pr, softmax: () => za, softplus: () => co, spaceToBatchND: () => Pa, sparse: () => Kf, sparseToDense: () => ox, spectral: () => SRe, split: () => sr, sqrt: () => bt, square: () => Ve, squaredDifference: () => Bu, squeeze: () => Br, stack: () => Xt, step: () => Ls, stridedSlice: () => Wf, string: () => hx, sub: () => le, sum: () => me, sumOutType: () => hu, tan: () => Uf, tanh: () => Ds, tensor: () => Dr, tensor1d: () => $t, tensor2d: () => ki, tensor3d: () => T_, tensor4d: () => Iq, tensor5d: () => Sq, tensor6d: () => Nq, tensor_util: () => ao, test_util: () => T1, tidy: () => V, tile: () => vr, time: () => lue, topk: () => jf, train: () => Ju, transpose: () => Be, truncatedNormal: () => Vu, unique: () => Gp, unregisterGradient: () => _se, unregisterKernel: () => wse, unsortedSegmentSum: () => Hf, unstack: () => yr, upcastType: () => hr, util: () => b, valueAndGrad: () => $j, valueAndGrads: () => Rj, variable: () => yk, variableGrads: () => Zg, version: () => sse, version_converter: () => SD, version_core: () => E1, version_layers: () => lm, version_wasm: () => Xoe, version_webgl: () => KP, webgl: () => LTt, webgl_util: () => zO, where: () => St, whereAsync: () => qf, zeros: () => yt, zerosLike: () => Se }); var sW = Object.create; var Sg = Object.defineProperty; var iW = Object.getOwnPropertyDescriptor; var aW = Object.getOwnPropertyNames; var lW = Object.getPrototypeOf; var uW = Object.prototype.hasOwnProperty; var XS = (r) => Sg(r, "__esModule", { value: true }); var Lc = ((r) => typeof __require != "undefined" ? __require : typeof Proxy != "undefined" ? new Proxy(r, { get: (e, t) => (typeof __require != "undefined" ? __require : e)[t] }) : r)(function(r) { if (typeof __require != "undefined") return __require.apply(this, arguments); throw new Error('Dynamic require of "' + r + '" is not supported'); }); var qt = (r, e) => () => (e || r((e = { exports: {} }).exports, e), e.exports); var qe = (r, e) => { XS(r); for (var t in e) Sg(r, t, { get: e[t], enumerable: true }); }; var cW = (r, e, t) => { if (e && typeof e == "object" || typeof e == "function") for (let n of aW(e)) !uW.call(r, n) && n !== "default" && Sg(r, n, { get: () => e[n], enumerable: !(t = iW(e, n)) || t.enumerable }); return r; }; var ou = (r) => cW(XS(Sg(r != null ? sW(lW(r)) : {}, "default", r && r.__esModule && "default" in r ? { get: () => r.default, enumerable: true } : { value: r, enumerable: true })), r); var hN = qt((Cse, dN) => { dN.exports = Wt; var oo = null; try { oo = 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 (r) { } function Wt(r, e, t) { this.low = r | 0, this.high = e | 0, this.unsigned = !!t; } Wt.prototype.__isLong__; Object.defineProperty(Wt.prototype, "__isLong__", { value: true }); function Fn(r) { return (r && r.__isLong__) === true; } Wt.isLong = Fn; var sN = {}, iN = {}; function cu(r, e) { var t, n, o; return e ? (r >>>= 0, (o = 0 <= r && r < 256) && (n = iN[r], n) ? n : (t = Ut(r, (r | 0) < 0 ? -1 : 0, true), o && (iN[r] = t), t)) : (r |= 0, (o = -128 <= r && r < 128) && (n = sN[r], n) ? n : (t = Ut(r, r < 0 ? -1 : 0, false), o && (sN[r] = t), t)); } Wt.fromInt = cu; function so(r, e) { if (isNaN(r)) return e ? pu : io; if (e) { if (r < 0) return pu; if (r >= lN) return fN; } else { if (r <= -uN) return On; if (r + 1 >= uN) return mN; } return r < 0 ? so(-r, e).neg() : Ut(r % Ip | 0, r / Ip | 0, e); } Wt.fromNumber = so; function Ut(r, e, t) { return new Wt(r, e, t); } Wt.fromBits = Ut; var Dg = Math.pow; function e_(r, e, t) { if (r.length === 0) throw Error("empty string"); if (r === "NaN" || r === "Infinity" || r === "+Infinity" || r === "-Infinity") return io; if (typeof e == "number" ? (t = e, e = false) : e = !!e, t = t || 10, t < 2 || 36 < t) throw RangeError("radix"); var n; if ((n = r.indexOf("-")) > 0) throw Error("interior hyphen"); if (n === 0) return e_(r.substring(1), e, t).neg(); for (var o = so(Dg(t, 8)), s = io, a = 0; a < r.length; a += 8) { var i = Math.min(8, r.length - a), l = parseInt(r.substring(a, a + i), t); if (i < 8) { var u = so(Dg(t, i)); s = s.mul(u).add(so(l)); } else s = s.mul(o), s = s.add(so(l)); } return s.unsigned = e, s; } Wt.fromString = e_; function Ss(r, e) { return typeof r == "number" ? so(r, e) : typeof r == "string" ? e_(r, e) : Ut(r.low, r.high, typeof e == "boolean" ? e : r.unsigned); } Wt.fromValue = Ss; var aN = 1 << 16, RW = 1 << 24, Ip = aN * aN, lN = Ip * Ip, uN = lN / 2, cN = cu(RW), io = cu(0); Wt.ZERO = io; var pu = cu(0, true); Wt.UZERO = pu; var Sp = cu(1); Wt.ONE = Sp; var pN = cu(1, true); Wt.UONE = pN; var t_ = cu(-1); Wt.NEG_ONE = t_; var mN = Ut(4294967295 | 0, 2147483647 | 0, false); Wt.MAX_VALUE = mN; var fN = Ut(4294967295 | 0, 4294967295 | 0, true); Wt.MAX_UNSIGNED_VALUE = fN; var On = Ut(0, 2147483648 | 0, false); Wt.MIN_VALUE = On; var we = Wt.prototype; we.toInt = function() { return this.unsigned ? this.low >>> 0 : this.low; }; we.toNumber = function() { return this.unsigned ? (this.high >>> 0) * Ip + (this.low >>> 0) : this.high * Ip + (this.low >>> 0); }; we.toString = function(e) { if (e = e || 10, e < 2 || 36 < e) throw RangeError("radix"); if (this.isZero()) return "0"; if (this.isNegative()) if (this.eq(On)) { var t = so(e), n = this.div(t), o = n.mul(t).sub(this); return n.toString(e) + o.toInt().toString(e); } else return "-" + this.neg().toString(e); for (var s = so(Dg(e, 6), this.unsigned), a = this, i = ""; ; ) { var l = a.div(s), u = a.sub(l.mul(s)).toInt() >>> 0, c = u.toString(e); if (a = l, a.isZero()) return c + i; for (; c.length < 6; ) c = "0" + c; i = "" + c + i; } }; we.getHighBits = function() { return this.high; }; we.getHighBitsUnsigned = function() { return this.high >>> 0; }; we.getLowBits = function() { return this.low; }; we.getLowBitsUnsigned = function() { return this.low >>> 0; }; we.getNumBitsAbs = function() { if (this.isNegative()) return this.eq(On) ? 64 : this.neg().getNumBitsAbs(); for (var e = this.high != 0 ? this.high : this.low, t = 31; t > 0 && (e & 1 << t) == 0; t--) ; return this.high != 0 ? t + 33 : t + 1; }; we.isZero = function() { return this.high === 0 && this.low === 0; }; we.eqz = we.isZero; we.isNegative = function() { return !this.unsigned && this.high < 0; }; we.isPositive = function() { return this.unsigned || this.high >= 0; }; we.isOdd = function() { return (this.low & 1) == 1; }; we.isEven = function() { return (this.low & 1) == 0; }; we.equals = function(e) { return Fn(e) || (e = Ss(e)), this.unsigned !== e.unsigned && this.high >>> 31 == 1 && e.high >>> 31 == 1 ? false : this.high === e.high && this.low === e.low; }; we.eq = we.equals; we.notEquals = function(e) { return !this.eq(e); }; we.neq = we.notEquals; we.ne = we.notEquals; we.lessThan = function(e) { return this.comp(e) < 0; }; we.lt = we.lessThan; we.lessThanOrEqual = function(e) { return this.comp(e) <= 0; }; we.lte = we.lessThanOrEqual; we.le = we.lessThanOrEqual; we.greaterThan = function(e) { return this.comp(e) > 0; }; we.gt = we.greaterThan; we.greaterThanOrEqual = function(e) { return this.comp(e) >= 0; }; we.gte = we.greaterThanOrEqual; we.ge = we.greaterThanOrEqual; we.compare = function(e) { if (Fn(e) || (e = Ss(e)), this.eq(e)) return 0; var t = this.isNegative(), n = e.isNegative(); return t && !n ? -1 : !t && n ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1; }; we.comp = we.compare; we.negate = function() { return !this.unsigned && this.eq(On) ? On : this.not().add(Sp); }; we.neg = we.negate; we.add = function(e) { Fn(e) || (e = Ss(e)); var t = this.high >>> 16, n = this.high & 65535, o = this.low >>> 16, s = this.low & 65535, a = e.high >>> 16, i = e.high & 65535, l = e.low >>> 16, u = e.low & 65535, c = 0, p = 0, m = 0, f = 0; return f += s + u, m += f >>> 16, f &= 65535, m += o + l, p += m >>> 16, m &= 65535, p += n + i, c += p >>> 16, p &= 65535, c += t + a, c &= 65535, Ut(m << 16 | f, c << 16 | p, this.unsigned); }; we.subtract = function(e) { return Fn(e) || (e = Ss(e)), this.add(e.neg()); }; we.sub = we.subtract; we.multiply = function(e) { if (this.isZero()) return io; if (Fn(e) || (e = Ss(e)), oo) { var t = oo.mul(this.low, this.high, e.low, e.high); return Ut(t, oo.get_high(), this.unsigned); } if (e.isZero()) return io; if (this.eq(On)) return e.isOdd() ? On : io; if (e.eq(On)) return this.isOdd() ? On : io; if (this.isNegative()) return e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg(); if (e.isNegative()) return this.mul(e.neg()).neg(); if (this.lt(cN) && e.lt(cN)) return so(this.toNumber() * e.toNumber(), this.unsigned); var n = this.high >>> 16, o = this.high & 65535, s = this.low >>> 16, a = this.low & 65535, i = e.high >>> 16, l = e.high & 65535, u = e.low >>> 16, c = e.low & 65535, p = 0, m = 0, f = 0, d = 0; return d += a * c, f += d >>> 16, d &= 65535, f += s * c, m += f >>> 16, f &= 65535, f += a * u, m += f >>> 16, f &= 65535, m += o * c, p += m >>> 16, m &= 65535, m += s * u, p += m >>> 16, m &= 65535, m += a * l, p += m >>> 16, m &= 65535, p += n * c + o * u + s * l + a * i, p &= 65535, Ut(f << 16 | d, p << 16 | m, this.unsigned); }; we.mul = we.multiply; we.divide = function(e) { if (Fn(e) || (e = Ss(e)), e.isZero()) throw Error("division by zero"); if (oo) { if (!this.unsigned && this.high === -2147483648 && e.low === -1 && e.high === -1) return this; var t = (this.unsigned ? oo.div_u : oo.div_s)(this.low, this.high, e.low, e.high); return Ut(t, oo.get_high(), this.unsigned); } if (this.isZero()) return this.unsigned ? pu : io; var n, o, s; if (this.unsigned) { if (e.unsigned || (e = e.toUnsigned()), e.gt(this)) return pu; if (e.gt(this.shru(1))) return pN; s = pu; } else { if (this.eq(On)) { if (e.eq(Sp) || e.eq(t_)) return On; if (e.eq(On)) return Sp; var a = this.shr(1); return n = a.div(e).shl(1), n.eq(io) ? e.isNegative() ? Sp : t_ : (o = this.sub(e.mul(n)), s = n.add(o.div(e)), s); } else if (e.eq(On)) return this.unsigned ? pu : io; if (this.isNegative()) return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg(); if (e.isNegative()) return this.div(e.neg()).neg(); s = io; } for (o = this; o.gte(e); ) { n = Math.max(1, Math.floor(o.toNumber() / e.toNumber())); for (var i = Math.ceil(Math.log(n) / Math.LN2), l = i <= 48 ? 1 : Dg(2, i - 48), u = so(n), c = u.mul(e); c.isNegative() || c.gt(o); ) n -= l, u = so(n, this.unsigned), c = u.mul(e); u.isZero() && (u = Sp), s = s.add(u), o = o.sub(c); } return s; }; we.div = we.divide; we.modulo = function(e) { if (Fn(e) || (e = Ss(e)), oo) { var t = (this.unsigned ? oo.rem_u : oo.rem_s)(this.low, this.high, e.low, e.high); return Ut(t, oo.get_high(), this.unsigned); } return this.sub(this.div(e).mul(e)); }; we.mod = we.modulo; we.rem = we.modulo; we.not = function() { return Ut(~this.low, ~this.high, this.unsigned); }; we.and = function(e) { return Fn(e) || (e = Ss(e)), Ut(this.low & e.low, this.high & e.high, this.unsigned); }; we.or = function(e) { return Fn(e) || (e = Ss(e)), Ut(this.low | e.low, this.high | e.high, this.unsigned); }; we.xor = function(e) { return Fn(e) || (e = Ss(e)), Ut(this.low ^ e.low, this.high ^ e.high, this.unsigned); }; we.shiftLeft = function(e) { return Fn(e) && (e = e.toInt()), (e &= 63) == 0 ? this : e < 32 ? Ut(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : Ut(0, this.low << e - 32, this.unsigned); }; we.shl = we.shiftLeft; we.shiftRight = function(e) { return Fn(e) && (e = e.toInt()), (e &= 63) == 0 ? this : e < 32 ? Ut(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : Ut(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned); }; we.shr = we.shiftRight; we.shiftRightUnsigned = function(e) { if (Fn(e) && (e = e.toInt()), e &= 63, e === 0) return this; var t = this.high; if (e < 32) { var n = this.low; return Ut(n >>> e | t << 32 - e, t >>> e, this.unsigned); } else return e === 32 ? Ut(t, 0, this.unsigned) : Ut(t >>> e - 32, 0, this.unsigned); }; we.shru = we.shiftRightUnsigned; we.shr_u = we.shiftRightUnsigned; we.toSigned = function() { return this.unsigned ? Ut(this.low, this.high, false) : this; }; we.toUnsigned = function() { return this.unsigned ? this : Ut(this.low, this.high, true); }; we.toBytes = function(e) { return e ? this.toBytesLE() : this.toBytesBE(); }; we.toBytesLE = function() { var e = this.high, t = this.low; return [t & 255, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, e & 255, e >>> 8 & 255, e >>> 16 & 255, e >>> 24]; }; we.toBytesBE = function() { var e = this.high, t = this.low; return [e >>> 24, e >>> 16 & 255, e >>> 8 & 255, e & 255, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, t & 255]; }; Wt.fromBytes = function(e, t, n) { return n ? Wt.fromBytesLE(e, t) : Wt.fromBytesBE(e, t); }; Wt.fromBytesLE = function(e, t) { return new Wt(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t); }; Wt.fromBytesBE = function(e, t) { return new Wt(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t); }; }); var QN = qt(() => { }); var P1 = qt((O1, ak) => { (function(r, e, t) { function n(i) { var l = this, u = a(); l.next = function() { var c = 2091639 * l.s0 + l.c * 23283064365386963e-26; return l.s0 = l.s1, l.s1 = l.s2, l.s2 = c - (l.c = c | 0); }, l.c = 1, l.s0 = u(" "), l.s1 = u(" "), l.s2 = u(" "), l.s0 -= u(i), l.s0 < 0 && (l.s0 += 1), l.s1 -= u(i), l.s1 < 0 && (l.s1 += 1), l.s2 -= u(i), l.s2 < 0 && (l.s2 += 1), u = null; } function o(i, l) { return l.c = i.c, l.s0 = i.s0, l.s1 = i.s1, l.s2 = i.s2, l; } function s(i, l) { var u = new n(i), c = l && l.state, p = u.next; return p.int32 = function() { return u.next() * 4294967296 | 0; }, p.double = function() { return p() + (p() * 2097152 | 0) * 11102230246251565e-32; }, p.quick = p, c && (typeof c == "object" && o(c, u), p.state = function() { return o(u, {}); }), p; } function a() { var i = 4022871197, l = function(u) { u = u.toString(); for (var c = 0; c < u.length; c++) { i += u.charCodeAt(c); var p = 0.02519603282416938 * i; i = p >>> 0, p -= i, p *= i, i = p >>> 0, p -= i, i += p * 4294967296; } return (i >>> 0) * 23283064365386963e-26; }; return l; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.alea = s; })(O1, typeof ak == "object" && ak, typeof define == "function" && define); }); var L1 = qt((M1, lk) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.next = function() { var c = i.x ^ i.x << 11; return i.x = i.y, i.y = i.z, i.z = i.w, i.w ^= i.w >>> 19 ^ c ^ c >>> 8; }, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor128 = s; })(M1, typeof lk == "object" && lk, typeof define == "function" && define); }); var B1 = qt((z1, uk) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.x ^ i.x >>> 2; return i.x = i.y, i.y = i.z, i.z = i.w, i.w = i.v, (i.d = i.d + 362437 | 0) + (i.v = i.v ^ i.v << 4 ^ (c ^ c << 1)) | 0; }, i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.v = 0, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, u == l.length && (i.d = i.x << 10 ^ i.x >>> 4), i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i.v = a.v, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorwow = s; })(z1, typeof uk == "object" && uk, typeof define == "function" && define); }); var G1 = qt((V1, ck) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.x, c = i.i, p, m, f; return p = u[c], p ^= p >>> 7, m = p ^ p << 24, p = u[c + 1 & 7], m ^= p ^ p >>> 10, p = u[c + 3 & 7], m ^= p ^ p >>> 3, p = u[c + 4 & 7], m ^= p ^ p << 7, p = u[c + 7 & 7], p = p ^ p << 13, m ^= p ^ p << 9, u[c] = m, i.i = c + 1 & 7, m; }; function l(u, c) { var p, m, f = []; if (c === (c | 0)) m = f[0] = c; else for (c = "" + c, p = 0; p < c.length; ++p) f[p & 7] = f[p & 7] << 15 ^ c.charCodeAt(p) + f[p + 1 & 7] << 13; for (; f.length < 8; ) f.push(0); for (p = 0; p < 8 && f[p] === 0; ++p) ; for (p == 8 ? m = f[7] = -1 : m = f[p], u.x = f, u.i = 0, p = 256; p > 0; --p) u.next(); } l(i, a); } function o(a, i) { return i.x = a.x.slice(), i.i = a.i, i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.x && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorshift7 = s; })(V1, typeof ck == "object" && ck, typeof define == "function" && define); }); var U1 = qt((W1, pk) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.w, c = i.X, p = i.i, m, f; return i.w = u = u + 1640531527 | 0, f = c[p + 34 & 127], m = c[p = p + 1 & 127], f ^= f << 13, m ^= m << 17, f ^= f >>> 15, m ^= m >>> 12, f = c[p] = f ^ m, i.i = p, f + (u ^ u >>> 16) | 0; }; function l(u, c) { var p, m, f, d, h, g = [], x = 128; for (c === (c | 0) ? (m = c, c = null) : (c = c + "\0", m = 0, x = Math.max(x, c.length)), f = 0, d = -32; d < x; ++d) c && (m ^= c.charCodeAt((d + 32) % c.length)), d === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, d >= 0 && (h = h + 1640531527 | 0, p = g[d & 127] ^= m + h, f = p == 0 ? f + 1 : 0); for (f >= 128 && (g[(c && c.length || 0) & 127] = -1), f = 127, d = 4 * 128; d > 0; --d) m = g[f + 34 & 127], p = g[f = f + 1 & 127], m ^= m << 13, p ^= p << 17, m ^= m >>> 15, p ^= p >>> 12, g[f] = m ^ p; u.w = h, u.X = g, u.i = f; } l(i, a); } function o(a, i) { return i.i = a.i, i.w = a.w, i.X = a.X.slice(), i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.X && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor4096 = s; })(W1, typeof pk == "object" && pk, typeof define == "function" && define); }); var H1 = qt((j1, mk) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.b, p = i.c, m = i.d, f = i.a; return c = c << 25 ^ c >>> 7 ^ p, p = p - m | 0, m = m << 24 ^ m >>> 8 ^ f, f = f - c | 0, i.b = c = c << 20 ^ c >>> 12 ^ p, i.c = p = p - m | 0, i.d = m << 16 ^ p >>> 16 ^ f, i.a = f - c | 0; }, i.a = 0, i.b = 0, i.c = 2654435769 | 0, i.d = 1367130551, a === Math.floor(a) ? (i.a = a / 4294967296 | 0, i.b = a | 0) : l += a; for (var u = 0; u < l.length + 20; u++) i.b ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.a = a.a, i.b = a.b, i.c = a.c, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.tychei = s; })(j1, typeof mk == "object" && mk, typeof define == "function" && define); }); var fk = qt(() => { }); var q1 = qt((Zke, Qg) => { (function(r, e) { var t = this, n = 256, o = 6, s = 52, a = "random", i = e.pow(n, o), l = e.pow(2, s), u = l * 2, c = n - 1, p; function m(w, _, C) { var A = []; _ = _ == true ? { entropy: true } : _ || {}; var D = g(h(_.entropy ? [w, y(r)] : w == null ? x() : w, 3), A), R = new f(A), P = function() { for (var L = R.g(o), G = i, W = 0; L < l; ) L = (L + W) * n, G *= n, W = R.g(1); for (; L >= u; ) L /= 2, G /= 2, W >>>= 1; return (L + W) / G; }; return P.int32 = function() { return R.g(4) | 0; }, P.quick = function() { return R.g(4) / 4294967296; }, P.double = P, g(y(R.S), r), (_.pass || C || function(L, G, W, j) { return j && (j.S && d(j, R), L.state = function() { return d(R, {}); }), W ? (e[a] = L, G) : L; })(P, D, "global" in _ ? _.global : this == e, _.state); } e["seed" + a] = m; function f(w) { var _, C = w.length, A = this, D = 0, R = A.i = A.j = 0, P = A.S = []; for (C || (w = [C++]); D < n; ) P[D] = D++; for (D = 0; D < n; D++) P[D] = P[R = c & R + w[D % C] + (_ = P[D])], P[R] = _; (A.g = function(L) { for (var G, W = 0, j = A.i, H = A.j, q = A.S; L--; ) G = q[j = c & j + 1], W = W * n + q[c & (q[j] = q[H = c & H + G]) + (q[H] = G)]; return A.i = j, A.j = H, W; })(n); } function d(w, _) { return _.i = w.i, _.j = w.j, _.S = w.S.slice(), _; } function h(w, _) { var C = [], A = typeof w, D; if (_ && A == "object") for (D in w) try { C.push(h(w[D], _ - 1)); } catch (R) { } return C.length ? C : A == "string" ? w : w + "\0"; } function g(w, _) { for (var C = w + "", A, D = 0; D < C.length; ) _[c & D] = c & (A ^= _[c & D] * 19) + C.charCodeAt(D++); return y(_); } function x() { try { var w; return p && (w = p.randomBytes) ? w = w(n) : (w = new Uint8Array(n), (t.crypto || t.msCrypto).getRandomValues(w)), y(w); } catch (A) { var _ = t.navigator, C = _ && _.plugins; return [+new Date(), t, C, t.screen, y(r)]; } } function y(w) { return String.fromCharCode.apply(0, w); } if (g(e.random(), r), typeof Qg == "object" && Qg.exports) { Qg.exports = m; try { p = fk(); } catch (w) { } } else typeof define == "function" && define.amd && define(function() { return m; }); })([], Math); }); var dk = qt((Jke, K1) => { var DH = P1(), $H = L1(), RH = B1(), FH = G1(), OH = U1(), PH = H1(), $u = q1(); $u.alea = DH; $u.xor128 = $H; $u.xorwow = RH; $u.xorshift7 = FH; $u.xor4096 = OH; $u.tychei = PH; K1.exports = $u; }); var TD = qt((ND, n0) => { (function(r, e, t) { function n(i) { var l = this, u = a(); l.next = function() { var c = 2091639 * l.s0 + l.c * 23283064365386963e-26; return l.s0 = l.s1, l.s1 = l.s2, l.s2 = c - (l.c = c | 0); }, l.c = 1, l.s0 = u(" "), l.s1 = u(" "), l.s2 = u(" "), l.s0 -= u(i), l.s0 < 0 && (l.s0 += 1), l.s1 -= u(i), l.s1 < 0 && (l.s1 += 1), l.s2 -= u(i), l.s2 < 0 && (l.s2 += 1), u = null; } function o(i, l) { return l.c = i.c, l.s0 = i.s0, l.s1 = i.s1, l.s2 = i.s2, l; } function s(i, l) { var u = new n(i), c = l && l.state, p = u.next; return p.int32 = function() { return u.next() * 4294967296 | 0; }, p.double = function() { return p() + (p() * 2097152 | 0) * 11102230246251565e-32; }, p.quick = p, c && (typeof c == "object" && o(c, u), p.state = function() { return o(u, {}); }), p; } function a() { var i = 4022871197, l = function(u) { u = String(u); for (var c = 0; c < u.length; c++) { i += u.charCodeAt(c); var p = 0.02519603282416938 * i; i = p >>> 0, p -= i, p *= i, i = p >>> 0, p -= i, i += p * 4294967296; } return (i >>> 0) * 23283064365386963e-26; }; return l; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.alea = s; })(ND, typeof n0 == "object" && n0, typeof define == "function" && define); }); var AD = qt((ED, o0) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.next = function() { var c = i.x ^ i.x << 11; return i.x = i.y, i.y = i.z, i.z = i.w, i.w ^= i.w >>> 19 ^ c ^ c >>> 8; }, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor128 = s; })(ED, typeof o0 == "object" && o0, typeof define == "function" && define); }); var $D = qt((DD, s0) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.x ^ i.x >>> 2; return i.x = i.y, i.y = i.z, i.z = i.w, i.w = i.v, (i.d = i.d + 362437 | 0) + (i.v = i.v ^ i.v << 4 ^ (c ^ c << 1)) | 0; }, i.x = 0, i.y = 0, i.z = 0, i.w = 0, i.v = 0, a === (a | 0) ? i.x = a : l += a; for (var u = 0; u < l.length + 64; u++) i.x ^= l.charCodeAt(u) | 0, u == l.length && (i.d = i.x << 10 ^ i.x >>> 4), i.next(); } function o(a, i) { return i.x = a.x, i.y = a.y, i.z = a.z, i.w = a.w, i.v = a.v, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorwow = s; })(DD, typeof s0 == "object" && s0, typeof define == "function" && define); }); var FD = qt((RD, i0) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.x, c = i.i, p, m, f; return p = u[c], p ^= p >>> 7, m = p ^ p << 24, p = u[c + 1 & 7], m ^= p ^ p >>> 10, p = u[c + 3 & 7], m ^= p ^ p >>> 3, p = u[c + 4 & 7], m ^= p ^ p << 7, p = u[c + 7 & 7], p = p ^ p << 13, m ^= p ^ p << 9, u[c] = m, i.i = c + 1 & 7, m; }; function l(u, c) { var p, m, f = []; if (c === (c | 0)) m = f[0] = c; else for (c = "" + c, p = 0; p < c.length; ++p) f[p & 7] = f[p & 7] << 15 ^ c.charCodeAt(p) + f[p + 1 & 7] << 13; for (; f.length < 8; ) f.push(0); for (p = 0; p < 8 && f[p] === 0; ++p) ; for (p == 8 ? m = f[7] = -1 : m = f[p], u.x = f, u.i = 0, p = 256; p > 0; --p) u.next(); } l(i, a); } function o(a, i) { return i.x = a.x.slice(), i.i = a.i, i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.x && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xorshift7 = s; })(RD, typeof i0 == "object" && i0, typeof define == "function" && define); }); var PD = qt((OD, a0) => { (function(r, e, t) { function n(a) { var i = this; i.next = function() { var u = i.w, c = i.X, p = i.i, m, f; return i.w = u = u + 1640531527 | 0, f = c[p + 34 & 127], m = c[p = p + 1 & 127], f ^= f << 13, m ^= m << 17, f ^= f >>> 15, m ^= m >>> 12, f = c[p] = f ^ m, i.i = p, f + (u ^ u >>> 16) | 0; }; function l(u, c) { var p, m, f, d, h, g = [], x = 128; for (c === (c | 0) ? (m = c, c = null) : (c = c + "\0", m = 0, x = Math.max(x, c.length)), f = 0, d = -32; d < x; ++d) c && (m ^= c.charCodeAt((d + 32) % c.length)), d === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, d >= 0 && (h = h + 1640531527 | 0, p = g[d & 127] ^= m + h, f = p == 0 ? f + 1 : 0); for (f >= 128 && (g[(c && c.length || 0) & 127] = -1), f = 127, d = 4 * 128; d > 0; --d) m = g[f + 34 & 127], p = g[f = f + 1 & 127], m ^= m << 13, p ^= p << 17, m ^= m >>> 15, p ^= p >>> 12, g[f] = m ^ p; u.w = h, u.X = g, u.i = f; } l(i, a); } function o(a, i) { return i.i = a.i, i.w = a.w, i.X = a.X.slice(), i; } function s(a, i) { a == null && (a = +new Date()); var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (u.X && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.xor4096 = s; })(OD, typeof a0 == "object" && a0, typeof define == "function" && define); }); var LD = qt((MD, l0) => { (function(r, e, t) { function n(a) { var i = this, l = ""; i.next = function() { var c = i.b, p = i.c, m = i.d, f = i.a; return c = c << 25 ^ c >>> 7 ^ p, p = p - m | 0, m = m << 24 ^ m >>> 8 ^ f, f = f - c | 0, i.b = c = c << 20 ^ c >>> 12 ^ p, i.c = p = p - m | 0, i.d = m << 16 ^ p >>> 16 ^ f, i.a = f - c | 0; }, i.a = 0, i.b = 0, i.c = 2654435769 | 0, i.d = 1367130551, a === Math.floor(a) ? (i.a = a / 4294967296 | 0, i.b = a | 0) : l += a; for (var u = 0; u < l.length + 20; u++) i.b ^= l.charCodeAt(u) | 0, i.next(); } function o(a, i) { return i.a = a.a, i.b = a.b, i.c = a.c, i.d = a.d, i; } function s(a, i) { var l = new n(a), u = i && i.state, c = function() { return (l.next() >>> 0) / 4294967296; }; return c.double = function() { do var p = l.next() >>> 11, m = (l.next() >>> 0) / 4294967296, f = (p + m) / (1 << 21); while (f === 0); return f; }, c.int32 = l.next, c.quick = c, u && (typeof u == "object" && o(u, l), c.state = function() { return o(l, {}); }), c; } e && e.exports ? e.exports = s : t && t.amd ? t(function() { return s; }) : this.tychei = s; })(MD, typeof l0 == "object" && l0, typeof define == "function" && define); }); var BD = qt((zD, uy) => { (function(r, e, t) { var n = 256, o = 6, s = 52, a = "random", i = t.pow(n, o), l = t.pow(2, s), u = l * 2, c = n - 1, p; function m(w, _, C) { var A = []; _ = _ == true ? { entropy: true } : _ || {}; var D = g(h(_.entropy ? [w, y(e)] : w == null ? x() : w, 3), A), R = new f(A), P = function() { for (var L = R.g(o), G = i, W = 0; L < l; ) L = (L + W) * n, G *= n, W = R.g(1); for (; L >= u; ) L /= 2, G /= 2, W >>>= 1; return (L + W) / G; }; return P.int32 = function() { return R.g(4) | 0; }, P.quick = function() { return R.g(4) / 4294967296; }, P.double = P, g(y(R.S), e), (_.pass || C || function(L, G, W, j) { return j && (j.S && d(j, R), L.state = function() { return d(R, {}); }), W ? (t[a] = L, G) : L; })(P, D, "global" in _ ? _.global : this == t, _.state); } function f(w) { var _, C = w.length, A = this, D = 0, R = A.i = A.j = 0, P = A.S = []; for (C || (w = [C++]); D < n; ) P[D] = D++; for (D = 0; D < n; D++) P[D] = P[R = c & R + w[D % C] + (_ = P[D])], P[R] = _; (A.g = function(L) { for (var G, W = 0, j = A.i, H = A.j, q = A.S; L--; ) G = q[j = c & j + 1], W = W * n + q[c & (q[j] = q[H = c & H + G]) + (q[H] = G)]; return A.i = j, A.j = H, W; })(n); } function d(w, _) { return _.i = w.i, _.j = w.j, _.S = w.S.slice(), _; } function h(w, _) { var C = [], A = typeof w, D; if (_ && A == "object") for (D in w) try { C.push(h(w[D], _ - 1)); } catch (R) { } return C.length ? C : A == "string" ? w : w + "\0"; } function g(w, _) { for (var C = w + "", A, D = 0; D < C.length; ) _[c & D] = c & (A ^= _[c & D] * 19) + C.charCodeAt(D++); return y(_); } function x() { try { var w; return p && (w = p.randomBytes) ? w = w(n) : (w = new Uint8Array(n), (r.crypto || r.msCrypto).getRandomValues(w)), y(w); } catch (A) { var _ = r.navigator, C = _ && _.plugins; return [+new Date(), r, C, r.screen, y(e)]; } } function y(w) { return String.fromCharCode.apply(0, w); } if (g(t.random(), e), typeof uy == "object" && uy.exports) { uy.exports = m; try { p = fk(); } catch (w) { } } else typeof define == "function" && define.amd ? define(function() { return m; }) : t["seed" + a] = m; })(typeof self != "undefined" ? self : zD, [], Math); }); var u0 = qt((Yct, VD) => { var f7 = TD(), d7 = AD(), h7 = $D(), g7 = FD(), x7 = PD(), y7 = LD(), cc = BD(); cc.alea = f7; cc.xor128 = d7; cc.xorwow = h7; cc.xorshift7 = g7; cc.xor4096 = x7; cc.tychei = y7; VD.exports = cc; }); var c0 = qt(() => { }); var Lm = qt(() => { }); var nG = qt(() => { }); var oG = qt(() => { }); var sG = qt((hb, AS) => { var ES = function() { var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (r = r || __filename), function(e) { e = e || {}; function t() { return ne.buffer != Ke && Tr(ne.buffer), ht; } function n() { return ne.buffer != Ke && Tr(ne.buffer), Mt; } function o() { return ne.buffer != Ke && Tr(ne.buffer), gn; } function s() { return ne.buffer != Ke && Tr(ne.buffer), Or; } function a() { return ne.buffer != Ke && Tr(ne.buffer), Zr; } var i = typeof e != "undefined" ? e : {}, l, u; i.ready = new Promise(function(S, $) { l = S, u = $; }); var c = {}, p; for (p in i) i.hasOwnProperty(p) && (c[p] = i[p]); var m = [], f = "./this.program", d = function(S, $) { throw $; }, h = false, g = false, x = false, y = false; h = typeof window == "object", g = typeof importScripts == "function", x = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", y = !h && !x && !g; var w = i.ENVIRONMENT_IS_PTHREAD || false; w && (Ke = i.buffer); var _ = ""; function C(S) { return i.locateFile ? i.locateFile(S, _) : _ + S; } var A, D, R, P, L, G; if (x) { g ? _ = Lm().dirname(_) + "/" : _ = __dirname + "/", A = function($, B) { return L || (L = Lc("fs")), G || (G = Lm()), $ = G.normalize($), L.readFileSync($, B ? null : "utf8"); }, R = function($) { var B = A($, true); return B.buffer || (B = new Uint8Array(B)), de(B.buffer), B; }, process.argv.length > 1 && (f = process.argv[1].replace(/\\/g, "/")), m = process.argv.slice(2), process.on("uncaughtException", function(S) { if (!(S instanceof Ym)) throw S; }), process.on("unhandledRejection", Fi), d = function(S) { process.exit(S); }, i.inspect = function() { return "[Emscripten Module object]"; }; var W; try { W = nG(); } catch (S) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), S; } global.Worker = W.Worker; } else y ? (typeof read != "undefined" && (A = function($) { return read($); }), R = function($) { var B; return typeof readbuffer == "function" ? new Uint8Array(readbuffer($)) : (B = read($, "binary"), de(typeof B == "object"), B); }, typeof scriptArgs != "undefined" ? m = scriptArgs : typeof arguments != "undefined" && (m = arguments), typeof quit == "function" && (d = function(S) { quit(S); }), typeof print != "undefined" && (typeof console == "undefined" && (console = {}), console.log = print, console.warn = console.error = typeof printErr != "undefined" ? printErr : print)) : (h || g) && (g ? _ = self.location.href : typeof document != "undefined" && document.currentScript && (_ = document.currentScript.src), typeof r != "undefined" && r && (_ = r), _.indexOf("blob:") !== 0 ? _ = _.substr(0, _.lastIndexOf("/") + 1) : _ = "", x ? (A = function($, B) { return L || (L = Lc("fs")), G || (G = Lm()), $ = G.normalize($), L.readFileSync($, B ? null : "utf8"); }, R = function($) { var B = A($, true); return B.buffer || (B = new Uint8Array(B)), de(B.buffer), B; }) : (A = function(S) { var $ = new XMLHttpRequest(); return $.open("GET", S, false), $.send(null), $.responseText; }, g && (R = function(S) { var $ = new XMLHttpRequest(); return $.open("GET", S, false), $.responseType = "arraybuffer", $.send(null), new Uint8Array($.response); }), D = function(S, $, B) { var K = new XMLHttpRequest(); K.open("GET", S, true), K.responseType = "arraybuffer", K.onload = function() { if (K.status == 200 || K.status == 0 && K.response) { $(K.response); return; } B(); }, K.onerror = B, K.send(null); }), P = function(S) { document.title = S; }); x && typeof performance == "undefined" && (global.performance = oG().performance); var j = i.print || console.log.bind(console), H = i.printErr || console.warn.bind(console); for (p in c) c.hasOwnProperty(p) && (i[p] = c[p]); c = null, i.arguments && (m = i.arguments), i.thisProgram && (f = i.thisProgram), i.quit && (d = i.quit); function q(S) { q.shown || (q.shown = {}), q.shown[S] || (q.shown[S] = 1, H(S)); } var X = Atomics.load, re = Atomics.store, J = Atomics.compareExchange, oe; i.wasmBinary && (oe = i.wasmBinary); var se = i.noExitRuntime || true; typeof WebAssembly != "object" && Fi("no native wasm support detected"); var ne, fe, ae = false, ge; function de(S, $) { S || Fi("Assertion failed: " + $); } function ye(S) { var $ = i["_" + S]; return de($, "Cannot call unknown function " + S + ", make sure it is exported"), $; } function _e(S, $, B, K, be) { var he = { string: function(Jr) { var Mc = 0; if (Jr != null && Jr !== 0) { var KS = (Jr.length << 2) + 1; Mc = Fc(KS), ut(Jr, Mc, KS); } return Mc; }, array: function(Jr) { var Mc = Fc(Jr.length); return Dt(Jr, Mc), Mc; } }; function xe(Jr) { return $ === "string" ? Fe(Jr) : $ === "boolean" ? Boolean(Jr) : Jr; } var Te = ye(S), vt = [], Er = 0; if (K) for (var _r = 0; _r < K.length; _r++) { var cl = he[B[_r]]; cl ? (Er === 0 && (Er = Xm()), vt[_r] = cl(K[_r])) : vt[_r] = K[_r]; } var Pc = Te.apply(null, vt); return Pc = xe(Pc), Er !== 0 && Rc(Er), Pc; } function Re(S, $, B, K) { B = B || []; var be = B.every(function(xe) { return xe === "number"; }), he = $ !== "string"; return he && be && !K ? ye(S) : function() { return _e(S, $, B, arguments, K); }; } function Ee(S, $, B) { for (var K = $ + B, be = ""; !($ >= K); ) { var he = S[$++]; if (!he) return be; if (!(he & 128)) { be += String.fromCharCode(he); continue; } var xe = S[$++] & 63; if ((he & 224) == 192) { be += String.fromCharCode((he & 31) << 6 | xe); continue; } var Te = S[$++] & 63; if ((he & 240) == 224 ? he = (he & 15) << 12 | xe << 6 | Te : he = (he & 7) << 18 | xe << 12 | Te << 6 | S[$++] & 63, he < 65536) be += String.fromCharCode(he); else { var vt = he - 65536; be += String.fromCharCode(55296 | vt >> 10, 56320 | vt & 1023); } } return be; } function Fe(S, $) { return S ? Ee(n(), S, $) : ""; } function Ye(S, $, B, K) { if (!(K > 0)) return 0; for (var be = B, he = B + K - 1, xe = 0; xe < S.length; ++xe) { var Te = S.charCodeAt(xe); if (Te >= 55296 && Te <= 57343) { var vt = S.charCodeAt(++xe); Te = 65536 + ((Te & 1023) << 10) | vt & 1023; } if (Te <= 127) { if (B >= he) break; $[B++] = Te; } else if (Te <= 2047) { if (B + 1 >= he) break; $[B++] = 192 | Te >> 6, $[B++] = 128 | Te & 63; } else if (Te <= 65535) { if (B + 2 >= he) break; $[B++] = 224 | Te >> 12, $[B++] = 128 | Te >> 6 & 63, $[B++] = 128 | Te & 63; } else { if (B + 3 >= he) break; $[B++] = 240 | Te >> 18, $[B++] = 128 | Te >> 12 & 63, $[B++] = 128 | Te >> 6 & 63, $[B++] = 128 | Te & 63; } } return $[B] = 0, B - be; } function ut(S, $, B) { return Ye(S, n(), $, B); } function At(S) { for (var $ = 0, B = 0; B < S.length; ++B) { var K = S.charCodeAt(B); K >= 55296 && K <= 57343 && (K = 65536 + ((K & 1023) << 10) | S.charCodeAt(++B) & 1023), K <= 127 ? ++$ : K <= 2047 ? $ += 2 : K <= 65535 ? $ += 3 : $ += 4; } return $; } function Dt(S, $) { t().set(S, $); } function ft(S, $) { return S % $ > 0 && (S += $ - S % $), S; } var Ke, ht, Mt, Dn, lr, gn, Or, To, Zr; function Tr(S) { Ke = S, i.HEAP8 = ht = new Int8Array(S), i.HEAP16 = Dn = new Int16Array(S), i.HEAP32 = gn = new Int32Array(S), i.HEAPU8 = Mt = new Uint8Array(S), i.HEAPU16 = lr = new Uint16Array(S), i.HEAPU32 = Or = new Uint32Array(S), i.HEAPF32 = To = new Float32Array(S), i.HEAPF64 = Zr = new Float64Array(S); } var Gn = i.INITIAL_MEMORY || 16777216; if (w) ne = i.wasmMemory, Ke = i.buffer; else if (i.wasmMemory) ne = i.wasmMemory; else if (ne = new WebAssembly.Memory({ initial: Gn / 65536, maximum: 2147483648 / 65536, shared: true }), !(ne.buffer instanceof SharedArrayBuffer)) throw H("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"), x && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); ne && (Ke = ne.buffer), Gn = Ke.byteLength, Tr(Ke); var ur, xn = [], $n = [], Jl = [], Ql = [], Eo = [], Ri = false, zm = false; w || $n.push({ func: function() { yg(); } }); function Ec() { if (!w) { if (i.preRun) for (typeof i.preRun == "function" && (i.preRun = [i.preRun]); i.preRun.length; ) bb(i.preRun.shift()); Ac(xn); } } function rg() { Ri = true, !w && Ac($n); } function ng() { w || Ac(Jl); } function yn() { w || (zm = true); } function og() { if (!w) { if (i.postRun) for (typeof i.postRun == "function" && (i.postRun = [i.postRun]); i.postRun.length; ) wb(i.postRun.shift()); Ac(Eo); } } function bb(S) { xn.unshift(S); } function wb(S) { Eo.unshift(S); } var Jn = 0, Bm = null, eu = null; function _b(S) { de(!w, "addRunDependency cannot be used in a pthread worker"), Jn++, i.monitorRunDependencies && i.monitorRunDependencies(Jn); } function kb(S) { if (Jn--, i.monitorRunDependencies && i.monitorRunDependencies(Jn), Jn == 0 && (Bm !== null && (clearInterval(Bm), Bm = null), eu)) { var $ = eu; eu = null, $(); } } i.preloadedImages = {}, i.preloadedAudios = {}; function Fi(S) { i.onAbort && i.onAbort(S), w && console.error("Pthread aborting at " + new Error().stack), S += "", H(S), ae = true, ge = 1, S = "abort(" + S + "). Build with -s ASSERTIONS=1 for more info."; var $ = new WebAssembly.RuntimeError(S); throw u($), $; } function tu(S, $) { return String.prototype.startsWith ? S.startsWith($) : S.indexOf($) === 0; } var vb = "data:application/octet-stream;base64,"; function sg(S) { return tu(S, vb); } var Cb = "file://"; function ig(S) { return tu(S, Cb); } var bn = "tfjs-backend-wasm-threaded-simd.wasm"; sg(bn) || (bn = C(bn)); function ag(S) { try { if (S == bn && oe) return new Uint8Array(oe); if (R) return R(S); throw "both async and sync fetching of the wasm failed"; } catch ($) { Fi($); } } function Ib() { if (!oe && (h || g)) { if (typeof fetch == "function" && !ig(bn)) return fetch(bn, { credentials: "same-origin" }).then(function(S) { if (!S.ok) throw "failed to load wasm binary file at '" + bn + "'"; return S.arrayBuffer(); }).catch(function() { return ag(bn); }); if (D) return new Promise(function(S, $) { D(bn, function(B) { S(new Uint8Array(B)); }, $); }); } return Promise.resolve().then(function() { return ag(bn); }); } function Sb() { var S = { a: yw }; function $(xe, Te) { var vt = xe.exports; if (i.asm = vt, ur = i.asm.I, fe = Te, !w) { var Er = Ae.unusedWorkers.length; Ae.unusedWorkers.forEach(function(_r) { Ae.loadWasmModuleToWorker(_r, function() { --Er || kb("wasm-instantiate"); }); }); } } w || _b("wasm-instantiate"); function B(xe) { $(xe.instance, xe.module); } function K(xe) { return Ib().then(function(Te) { return WebAssembly.instantiate(Te, S); }).then(xe, function(Te) { H("failed to asynchronously prepare wasm: " + Te), Fi(Te); }); } function be() { return !oe && typeof WebAssembly.instantiateStreaming == "function" && !sg(bn) && !ig(bn) && typeof fetch == "function" ? fetch(bn, { credentials: "same-origin" }).then(function(xe) { var Te = WebAssembly.instantiateStreaming(xe, S); return Te.then(B, function(vt) { return H("wasm streaming compile failed: " + vt), H("falling back to ArrayBuffer instantiation"), K(B); }); }) : K(B); } if (i.instantiateWasm) try { var he = i.instantiateWasm(S, $); return he; } catch (xe) { return H("Module.instantiateWasm callback failed with error: " + xe), false; } return be().catch(u), {}; } var Nb = { 10520: function() { throw "Canceled!"; }, 10538: function(S, $) { setTimeout(function() { GS(S, $); }, 0); } }; function lg() { Ae.initRuntime(); } function Ac(S) { for (; S.length > 0; ) { var $ = S.shift(); if (typeof $ == "function") { $(i); continue; } var B = $.func; typeof B == "number" ? $.arg === void 0 ? ur.get(B)() : ur.get(B)($.arg) : B($.arg === void 0 ? null : $.arg); } } var sl = { EPERM: 63, ENOENT: 44, ESRCH: 71, EINTR: 27, EIO: 29, ENXIO: 60, E2BIG: 1, ENOEXEC: 45, EBADF: 8, ECHILD: 12, EAGAIN: 6, EWOULDBLOCK: 6, ENOMEM: 48, EACCES: 2, EFAULT: 21, ENOTBLK: 105, EBUSY: 10, EEXIST: 20, EXDEV: 75, ENODEV: 43, ENOTDIR: 54, EISDIR: 31, EINVAL: 28, ENFILE: 41, EMFILE: 33, ENOTTY: 59, ETXTBSY: 74, EFBIG: 22, ENOSPC: 51, ESPIPE: 70, EROFS: 69, EMLINK: 34, EPIPE: 64, EDOM: 18, ERANGE: 68, ENOMSG: 49, EIDRM: 24, ECHRNG: 106, EL2NSYNC: 156, EL3HLT: 107, EL3RST: 108, ELNRNG: 109, EUNATCH: 110, ENOCSI: 111, EL2HLT: 112, EDEADLK: 16, ENOLCK: 46, EBADE: 113, EBADR: 114, EXFULL: 115, ENOANO: 104, EBADRQC: 103, EBADSLT: 102, EDEADLOCK: 16, EBFONT: 101, ENOSTR: 100, ENODATA: 116, ETIME: 117, ENOSR: 118, ENONET: 119, ENOPKG: 120, EREMOTE: 121, ENOLINK: 47, EADV: 122, ESRMNT: 123, ECOMM: 124, EPROTO: 65, EMULTIHOP: 36, EDOTDOT: 125, EBADMSG: 9, ENOTUNIQ: 126, EBADFD: 127, EREMCHG: 128, ELIBACC: 129, ELIBBAD: 130, ELIBSCN: 131, ELIBMAX: 132, ELIBEXEC: 133, ENOSYS: 52, ENOTEMPTY: 55, ENAMETOOLONG: 37, ELOOP: 32, EOPNOTSUPP: 138, EPFNOSUPPORT: 139, ECONNRESET: 15, ENOBUFS: 42, EAFNOSUPPORT: 5, EPROTOTYPE: 67, ENOTSOCK: 57, ENOPROTOOPT: 50, ESHUTDOWN: 140, ECONNREFUSED: 14, EADDRINUSE: 3, ECONNABORTED: 13, ENETUNREACH: 40, ENETDOWN: 38, ETIMEDOUT: 73, EHOSTDOWN: 142, EHOSTUNREACH: 23, EINPROGRESS: 26, EALREADY: 7, EDESTADDRREQ: 17, EMSGSIZE: 35, EPROTONOSUPPORT: 66, ESOCKTNOSUPPORT: 137, EADDRNOTAVAIL: 4, ENETRESET: 39, EISCONN: 30, ENOTCONN: 53, ETOOMANYREFS: 141, EUSERS: 136, EDQUOT: 19, ESTALE: 72, ENOTSUP: 138, ENOMEDIUM: 148, EILSEQ: 25, EOVERFLOW: 61, ECANCELED: 11, ENOTRECOVERABLE: 56, EOWNERDEAD: 62, ESTRPIPE: 135 }; function Vm(S, $) { if (S <= 0 || S > t().length || S & true || $ < 0) return -28; if ($ == 0) return 0; $ >= 2147483647 && ($ = 1 / 0); var B = Atomics.load(o(), Oc >> 2), K = 0; if (B == S) { var be = Atomics.compareExchange(o(), Oc >> 2, B, 0); if (be == B && (--$, K = 1, $ <= 0)) return 1; } var he = Atomics.notify(o(), S >> 2, $); if (he >= 0) return he + K; throw "Atomics.notify returned an unexpected value " + he; } i._emscripten_futex_wake = Vm; function Tb(S) { if (w) throw "Internal Error! killThread() can only ever be called from main application thread!"; if (!S) throw "Internal Error! Null pthread_ptr in killThread!"; o()[S + 12 >> 2] = 0; var $ = Ae.pthreads[S]; $.worker.terminate(), Ae.freeThreadData($), Ae.runningWorkers.splice(Ae.runningWorkers.indexOf($.worker), 1), $.worker.pthread = void 0; } function Eb(S) { if (w) throw "Internal Error! cancelThread() can only ever be called from main application thread!"; if (!S) throw "Internal Error! Null pthread_ptr in cancelThread!"; var $ = Ae.pthreads[S]; $.worker.postMessage({ cmd: "cancel" }); } function ug(S) { if (w) throw "Internal Error! cleanupThread() can only ever be called from main application thread!"; if (!S) throw "Internal Error! Null pthread_ptr in cleanupThread!"; var $ = Ae.pthreads[S]; if ($) { o()[S + 12 >> 2] = 0; var B = $.worker; Ae.returnWorkerToPool(B); } } var Ae = { unusedWorkers: [], runningWorkers: [], initMainThreadBlock: function() { for (var S = 8, $ = 0; $ < S; ++$) Ae.allocateUnusedWorker(); }, initRuntime: function() { for (var S = nu(228), $ = 0; $ < 228 / 4; ++$) s()[S / 4 + $] = 0; o()[S + 12 >> 2] = S; var B = S + 152; o()[B >> 2] = B; for (var K = nu(512), $ = 0; $ < 128; ++$) s()[K / 4 + $] = 0; Atomics.store(s(), S + 100 >> 2, K), Atomics.store(s(), S + 40 >> 2, S), Vw(S, !g, 1), BS(S); }, initWorker: function() { }, pthreads: {}, threadExitHandlers: [], setThreadStatus: function() { }, runExitHandlers: function() { for (; Ae.threadExitHandlers.length > 0; ) Ae.threadExitHandlers.pop()(); w && ul() && zS(); }, runExitHandlersAndDeinitThread: function(S, $) { Atomics.store(s(), S + 56 >> 2, 1), Atomics.store(s(), S + 60 >> 2, 0), Ae.runExitHandlers(), Atomics.store(s(), S + 4 >> 2, $), Atomics.store(s(), S + 0 >> 2, 1), Vm(S + 0, 2147483647), Vw(0, 0, 0); }, threadExit: function(S) { var $ = ul(); $ && (Ae.runExitHandlersAndDeinitThread($, S), w && postMessage({ cmd: "exit" })); }, threadCancel: function() { Ae.runExitHandlersAndDeinitThread(ul(), -1), postMessage({ cmd: "cancelDone" }); }, terminateAllThreads: function() { for (var S in Ae.pthreads) { var $ = Ae.pthreads[S]; $ && $.worker && Ae.returnWorkerToPool($.worker); } Ae.pthreads = {}; for (var B = 0; B < Ae.unusedWorkers.length; ++B) { var K = Ae.unusedWorkers[B]; K.terminate(); } Ae.unusedWorkers = []; for (var B = 0; B < Ae.runningWorkers.length; ++B) { var K = Ae.runningWorkers[B], $ = K.pthread; Ae.freeThreadData($), K.terminate(); } Ae.runningWorkers = []; }, freeThreadData: function(S) { if (!!S) { if (S.threadInfoStruct) { var $ = o()[S.threadInfoStruct + 100 >> 2]; o()[S.threadInfoStruct + 100 >> 2] = 0, Km($), Km(S.threadInfoStruct); } S.threadInfoStruct = 0, S.allocatedOwnStack && S.stackBase && Km(S.stackBase), S.stackBase = 0, S.worker && (S.worker.pthread = null); } }, returnWorkerToPool: function(S) { Ae.runWithoutMainThreadQueuedCalls(function() { delete Ae.pthreads[S.pthread.threadInfoStruct], Ae.unusedWorkers.push(S), Ae.runningWorkers.splice(Ae.runningWorkers.indexOf(S), 1), Ae.freeThreadData(S.pthread), S.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(S) { o()[qS >> 2] = 0; try { S(); } finally { o()[qS >> 2] = 1; } }, receiveObjectTransfer: function(S) { }, loadWasmModuleToWorker: function(S, $) { S.onmessage = function(B) { var K = B.data, be = K.cmd; if (S.pthread && (Ae.currentProxiedOperationCallerThread = S.pthread.threadInfoStruct), K.targetThread && K.targetThread != ul()) { var he = Ae.pthreads[K.targetThread]; he ? he.worker.postMessage(B.data, K.transferList) : console.error('Internal error! Worker sent a message "' + be + '" to target pthread ' + K.targetThread + ", but that thread no longer exists!"), Ae.currentProxiedOperationCallerThread = void 0; return; } if (be === "processQueuedMainThreadWork") Cg(); else if (be === "spawnThread") gg(B.data); else if (be === "cleanupThread") ug(K.thread); else if (be === "killThread") Tb(K.thread); else if (be === "cancelThread") Eb(K.thread); else if (be === "loaded") S.loaded = true, $ && $(S), S.runPthread && (S.runPthread(), delete S.runPthread); else if (be === "print") j("Thread " + K.threadId + ": " + K.text); else if (be === "printErr") H("Thread " + K.threadId + ": " + K.text); else if (be === "alert") alert("Thread " + K.threadId + ": " + K.text); else if (be === "exit") { var xe = S.pthread && Atomics.load(s(), S.pthread.threadInfoStruct + 64 >> 2); xe && Ae.returnWorkerToPool(S); } else if (be === "exitProcess") try { oW(K.returnCode); } catch (Te) { if (Te instanceof Ym) return; throw Te; } else be === "cancelDone" ? Ae.returnWorkerToPool(S) : be === "objectTransfer" ? Ae.receiveObjectTransfer(B.data) : B.data.target === "setimmediate" ? S.postMessage(B.data) : H("worker sent an unknown command " + be); Ae.currentProxiedOperationCallerThread = void 0; }, S.onerror = function(B) { H("pthread sent an error! " + B.filename + ":" + B.lineno + ": " + B.message); }, x && (S.on("message", function(B) { S.onmessage({ data: B }); }), S.on("error", function(B) { S.onerror(B); }), S.on("exit", function(B) { })), S.postMessage({ cmd: "load", urlOrBlob: i.mainScriptUrlOrBlob || r, wasmMemory: ne, wasmModule: fe }); }, allocateUnusedWorker: function() { var S = C("tfjs-backend-wasm-threaded-simd.worker.js"); Ae.unusedWorkers.push(new Worker(S)); }, getNewWorker: function() { return Ae.unusedWorkers.length == 0 && (Ae.allocateUnusedWorker(), Ae.loadWasmModuleToWorker(Ae.unusedWorkers[0])), Ae.unusedWorkers.length > 0 ? Ae.unusedWorkers.pop() : null; }, busySpinWait: function(S) { for (var $ = performance.now() + S; performance.now() < $; ) ; } }; function Ab(S, $) { jS(S, $), Rc(S); } i.establishStackSpace = Ab; function Db() { return se; } i.getNoExitRuntime = Db; function $b(S, $) { return ur.get(S)($); } i.invokeEntryPoint = $b; function Rb(S, $, B, K) { Fi("Assertion failed: " + Fe(S) + ", at: " + [$ ? Fe($) : "unknown filename", B, K ? Fe(K) : "unknown function"]); } function Fb(S, $) { var B = _main(S, $); } var ru; x ? ru = function() { var S = process.hrtime(); return S[0] * 1e3 + S[1] / 1e6; } : w ? ru = function() { return performance.now() - i.__performance_now_clock_drift; } : typeof dateNow != "undefined" ? ru = dateNow : ru = function() { return performance.now(); }; function Ob(S) { return o()[MS() >> 2] = S, S; } function Pb(S, $) { if (w) return il(1, 1, S, $); } function Mb(S, $) { if (S == $) postMessage({ cmd: "processQueuedMainThreadWork" }); else if (w) postMessage({ targetThread: S, cmd: "processThreadQueue" }); else { var B = Ae.pthreads[S], K = B && B.worker; if (!K) return; K.postMessage({ cmd: "processThreadQueue" }); } return 1; } function Lb() { Fi(); } function zb(S, $, B) { var K = Wb($, B); return Nb[S].apply(null, K); } function Bb(S, $) { } function cg(S, $, B) { if (S <= 0 || S > t().length || S & true) return -28; if (h) { if (Atomics.load(o(), S >> 2) != $) return -6; for (var be = performance.now(), he = be + B, xe = Atomics.exchange(o(), Oc >> 2, S); ; ) { if (be = performance.now(), be > he) return xe = Atomics.exchange(o(), Oc >> 2, 0), -73; if (xe = Atomics.exchange(o(), Oc >> 2, 0), xe == 0) break; if (Cg(), Atomics.load(o(), S >> 2) != $) return -6; xe = Atomics.exchange(o(), Oc >> 2, S); } return 0; } else { var K = Atomics.wait(o(), S >> 2, $, B); if (K === "timed-out") return -73; if (K === "not-equal") return -6; if (K === "ok") return 0; throw "Atomics.wait returned an unexpected value " + K; } } function Vb(S, $, B) { n().copyWithin(S, $, $ + B); } function Gb() { return x ? Lc("os").cpus().length : navigator.hardwareConcurrency; } function il(S, $) { for (var B = arguments.length - 2, K = Xm(), be = B, he = Fc(be * 8), xe = he >> 3, Te = 0; Te < B; Te++) { var vt = arguments[2 + Te]; a()[xe + Te] = vt; } var Er = US(S, be, he, $); return Rc(K), Er; } var Gm = [], Wm = []; function Wb(S, $) { Wm.length = 0; var B; for ($ >>= 2; B = n()[S++]; ) { var K = B < 105; K && $ & 1 && $++, Wm.push(K ? a()[$++ >> 1] : o()[$]), ++$; } return Wm; } function Ub(S, $, B) { Gm.length = $; for (var K = B >> 3, be = 0; be < $; be++) Gm[be] = a()[K + be]; var he = S < 0, xe = he ? Nb[-S - 1] : xw[S]; return xe.apply(null, Gm); } function jb() { return n().length; } function Hb(S) { try { return ne.grow(S - Ke.byteLength + 65535 >>> 16), Tr(ne.buffer), 1; } catch ($) { } } function qb(S) { var $ = jb(); if (S <= $) return false; var B = 2147483648; if (S > B) return false; for (var K = 1; K <= 4; K *= 2) { var be = $ * (1 + 0.2 / K); be = Math.min(be, S + 100663296); var he = Math.min(B, ft(Math.max(S, be), 65536)), xe = Hb(he); if (xe) return true; } return false; } var Qe = { inEventHandler: 0, removeAllEventListeners: function() { for (var S = Qe.eventHandlers.length - 1; S >= 0; --S) Qe._removeHandler(S); Qe.eventHandlers = [], Qe.deferredCalls = []; }, registerRemoveEventListeners: function() { Qe.removeEventListenersRegistered || (Ql.push(Qe.removeAllEventListeners), Qe.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(S, $, B) { function K(xe, Te) { if (xe.length != Te.length) return false; for (var vt in xe) if (xe[vt] != Te[vt]) return false; return true; } for (var be in Qe.deferredCalls) { var he = Qe.deferredCalls[be]; if (he.targetFunction == S && K(he.argsList, B)) return; } Qe.deferredCalls.push({ targetFunction: S, precedence: $, argsList: B }), Qe.deferredCalls.sort(function(xe, Te) { return xe.precedence < Te.precedence; }); }, removeDeferredCalls: function(S) { for (var $ = 0; $ < Qe.deferredCalls.length; ++$) Qe.deferredCalls[$].targetFunction == S && (Qe.deferredCalls.splice($, 1), --$); }, canPerformEventHandlerRequests: function() { return Qe.inEventHandler && Qe.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { if (!!Qe.canPerformEventHandlerRequests()) for (var S = 0; S < Qe.deferredCalls.length; ++S) { var $ = Qe.deferredCalls[S]; Qe.deferredCalls.splice(S, 1), --S, $.targetFunction.apply(null, $.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(S, $) { for (var B = 0; B < Qe.eventHandlers.length; ++B) Qe.eventHandlers[B].target == S && (!$ || $ == Qe.eventHandlers[B].eventTypeString) && Qe._removeHandler(B--); }, _removeHandler: function(S) { var $ = Qe.eventHandlers[S]; $.target.removeEventListener($.eventTypeString, $.eventListenerFunc, $.useCapture), Qe.eventHandlers.splice(S, 1); }, registerOrRemoveHandler: function(S) { var $ = function(be) { ++Qe.inEventHandler, Qe.currentEventHandler = S, Qe.runDeferredCalls(), S.handlerFunc(be), Qe.runDeferredCalls(), --Qe.inEventHandler; }; if (S.callbackfunc) S.eventListenerFunc = $, S.target.addEventListener(S.eventTypeString, $, S.useCapture), Qe.eventHandlers.push(S), Qe.registerRemoveEventListeners(); else for (var B = 0; B < Qe.eventHandlers.length; ++B) Qe.eventHandlers[B].target == S.target && Qe.eventHandlers[B].eventTypeString == S.eventTypeString && Qe._removeHandler(B--); }, queueEventHandlerOnThread_iiii: function(S, $, B, K, be) { var he = Xm(), xe = Fc(12); o()[xe >> 2] = B, o()[xe + 4 >> 2] = K, o()[xe + 8 >> 2] = be, Bw(0, S, 637534208, $, K, xe), Rc(he); }, getTargetThreadForEventCallback: function(S) { switch (S) { case 1: return 0; case 2: return Ae.currentProxiedOperationCallerThread; default: return S; } }, getNodeNameForTarget: function(S) { return S ? S == window ? "#window" : S == screen ? "#screen" : S && S.nodeName ? S.nodeName : "" : ""; }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; function Kb(S) { var $ = At(S) + 1, B = nu($); return ut(S, B, $), B; } function Xb(S, $, B, K) { var be = Xm(), he = Fc(12), xe = 0; $ && (xe = Kb($)), o()[he >> 2] = xe, o()[he + 4 >> 2] = B, o()[he + 8 >> 2] = K, Bw(0, S, 657457152, 0, xe, he), Rc(be); } function Yb(S, $, B, K) { $ = $ ? Fe($) : "", Xb(S, $, B, K); } function Zb(S) { return S > 2 ? Fe(S) : S; } var Jb = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; function Qb(S) { S = Zb(S); var $ = Jb[S] || (typeof document != "undefined" ? document.querySelector(S) : void 0); return $; } function Um(S) { return Qb(S); } function pg(S, $, B) { var K = Um(S); if (!K) return -4; if (K.canvasSharedPtr && (o()[K.canvasSharedPtr >> 2] = $, o()[K.canvasSharedPtr + 4 >> 2] = B), K.offscreenCanvas || !K.controlTransferredOffscreen) { K.offscreenCanvas && (K = K.offscreenCanvas); var be = false; if (K.GLctxObject && K.GLctxObject.GLctx) { var he = K.GLctxObject.GLctx.getParameter(2978); be = he[0] === 0 && he[1] === 0 && he[2] === K.width && he[3] === K.height; } K.width = $, K.height = B, be && K.GLctxObject.GLctx.viewport(0, 0, $, B); } else if (K.canvasSharedPtr) { var xe = o()[K.canvasSharedPtr + 8 >> 2]; return Yb(xe, S, $, B), 1; } else return -4; return 0; } function mg(S, $, B) { return w ? il(2, 1, S, $, B) : pg(S, $, B); } function ew(S, $, B) { var K = Um(S); return K ? pg(S, $, B) : mg(S, $, B); } function tw(S) { } function rw(S, $) { } function nw(S) { var $ = S.getExtension("ANGLE_instanced_arrays"); if ($) return S.vertexAttribDivisor = function(B, K) { $.vertexAttribDivisorANGLE(B, K); }, S.drawArraysInstanced = function(B, K, be, he) { $.drawArraysInstancedANGLE(B, K, be, he); }, S.drawElementsInstanced = function(B, K, be, he, xe) { $.drawElementsInstancedANGLE(B, K, be, he, xe); }, 1; } function ow(S) { var $ = S.getExtension("OES_vertex_array_object"); if ($) return S.createVertexArray = function() { return $.createVertexArrayOES(); }, S.deleteVertexArray = function(B) { $.deleteVertexArrayOES(B); }, S.bindVertexArray = function(B) { $.bindVertexArrayOES(B); }, S.isVertexArray = function(B) { return $.isVertexArrayOES(B); }, 1; } function sw(S) { var $ = S.getExtension("WEBGL_draw_buffers"); if ($) return S.drawBuffers = function(B, K) { $.drawBuffersWEBGL(B, K); }, 1; } function iw(S) { return !!(S.multiDrawWebgl = S.getExtension("WEBGL_multi_draw")); } var gt = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], uniforms: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, timerQueriesEXT: [], programInfos: {}, stringCache: {}, unpackAlignment: 4, recordError: function($) { gt.lastError || (gt.lastError = $); }, getNewId: function(S) { for (var $ = gt.counter++, B = S.length; B < $; B++) S[B] = null; return $; }, getSource: function(S, $, B, K) { for (var be = "", he = 0; he < $; ++he) { var xe = K ? o()[K + he * 4 >> 2] : -1; be += Fe(o()[B + he * 4 >> 2], xe < 0 ? void 0 : xe); } return be; }, createContext: function(S, $) { var B = S.getContext("webgl", $); if (!B) return 0; var K = gt.registerContext(B, $); return K; }, registerContext: function(S, $) { var B = nu(8); o()[B + 4 >> 2] = ul(); var K = { handle: B, attributes: $, version: $.majorVersion, GLctx: S }; return S.canvas && (S.canvas.GLctxObject = K), gt.contexts[B] = K, (typeof $.enableExtensionsByDefault == "undefined" || $.enableExtensionsByDefault) && gt.initExtensions(K), B; }, makeContextCurrent: function(S) { return gt.currentContext = gt.contexts[S], i.ctx = al = gt.currentContext && gt.currentContext.GLctx, !(S && !al); }, getContext: function(S) { return gt.contexts[S]; }, deleteContext: function(S) { gt.currentContext === gt.contexts[S] && (gt.currentContext = null), typeof Qe == "object" && Qe.removeAllHandlersOnTarget(gt.contexts[S].GLctx.canvas), gt.contexts[S] && gt.contexts[S].GLctx.canvas && (gt.contexts[S].GLctx.canvas.GLctxObject = void 0), Km(gt.contexts[S].handle), gt.contexts[S] = null; }, initExtensions: function(S) { if (S || (S = gt.currentContext), !S.initExtensionsDone) { S.initExtensionsDone = true; var $ = S.GLctx; nw($), ow($), sw($), $.disjointTimerQueryExt = $.getExtension("EXT_disjoint_timer_query"), iw($); var B = $.getSupportedExtensions() || []; B.forEach(function(K) { K.indexOf("lose_context") < 0 && K.indexOf("debug") < 0 && $.getExtension(K); }); } }, populateUniformTable: function(S) { for (var $ = gt.programs[S], B = gt.programInfos[S] = { uniforms: {}, maxUniformLength: 0, maxAttributeLength: -1, maxUniformBlockNameLength: -1 }, K = B.uniforms, be = al.getProgramParameter($, 35718), he = 0; he < be; ++he) { var xe = al.getActiveUniform($, he), Te = xe.name; B.maxUniformLength = Math.max(B.maxUniformLength, Te.length + 1), Te.slice(-1) == "]" && (Te = Te.slice(0, Te.lastIndexOf("["))); var vt = al.getUniformLocation($, Te); if (vt) { var Er = gt.getNewId(gt.uniforms); K[Te] = [xe.size, Er], gt.uniforms[Er] = vt; for (var _r = 1; _r < xe.size; ++_r) { var cl = Te + "[" + _r + "]"; vt = al.getUniformLocation($, cl), Er = gt.getNewId(gt.uniforms), gt.uniforms[Er] = vt; } } } } }, aw = ["default", "low-power", "high-performance"]; function lw(S, $) { var B = $ >> 2, K = o()[B + (24 >> 2)], be = { alpha: !!o()[B + (0 >> 2)], depth: !!o()[B + (4 >> 2)], stencil: !!o()[B + (8 >> 2)], antialias: !!o()[B + (12 >> 2)], premultipliedAlpha: !!o()[B + (16 >> 2)], preserveDrawingBuffer: !!o()[B + (20 >> 2)], powerPreference: aw[K], failIfMajorPerformanceCaveat: !!o()[B + (28 >> 2)], majorVersion: o()[B + (32 >> 2)], minorVersion: o()[B + (36 >> 2)], enableExtensionsByDefault: o()[B + (40 >> 2)], explicitSwapControl: o()[B + (44 >> 2)], proxyContextToMainThread: o()[B + (48 >> 2)], renderViaOffscreenBackBuffer: o()[B + (52 >> 2)] }, he = Um(S); if (!he || be.explicitSwapControl) return 0; var xe = gt.createContext(he, be); return xe; } function uw(S, $) { return lw(S, $); } var Dc = { mappings: {}, buffers: [null, [], []], printChar: function(S, $) { var B = Dc.buffers[S]; $ === 0 || $ === 10 ? ((S === 1 ? j : H)(Ee(B, 0)), B.length = 0) : B.push($); }, varargs: void 0, get: function() { Dc.varargs += 4; var S = o()[Dc.varargs - 4 >> 2]; return S; }, getStr: function(S) { var $ = Fe(S); return $; }, get64: function(S, $) { return S; } }; function fg(S) { return w ? il(3, 1, S) : 0; } function dg(S, $, B, K, be) { if (w) return il(4, 1, S, $, B, K, be); } function hg(S, $, B, K) { if (w) return il(5, 1, S, $, B, K); for (var be = 0, he = 0; he < B; he++) { for (var xe = o()[$ + he * 8 >> 2], Te = o()[$ + (he * 8 + 4) >> 2], vt = 0; vt < Te; vt++) Dc.printChar(S, n()[xe + vt]); be += Te; } return o()[K >> 2] = be, 0; } function cw(S) { var $ = Ae.threadExitHandlers.pop(); S && $(); } function pw(S, $) { Ae.threadExitHandlers.push(function() { ur.get(S)($); }); } function gg(S) { if (w) throw "Internal Error! spawnThread() can only ever be called from main application thread!"; var $ = Ae.getNewWorker(); if ($.pthread !== void 0) throw "Internal error!"; if (!S.pthread_ptr) throw "Internal error, no pthread ptr!"; Ae.runningWorkers.push($); for (var B = nu(128 * 4), K = 0; K < 128; ++K) o()[B + K * 4 >> 2] = 0; var be = S.stackBase + S.stackSize, he = Ae.pthreads[S.pthread_ptr] = { worker: $, stackBase: S.stackBase, stackSize: S.stackSize, allocatedOwnStack: S.allocatedOwnStack, threadInfoStruct: S.pthread_ptr }, xe = he.threadInfoStruct >> 2; Atomics.store(s(), xe + (64 >> 2), S.detached), Atomics.store(s(), xe + (100 >> 2), B), Atomics.store(s(), xe + (40 >> 2), he.threadInfoStruct), Atomics.store(s(), xe + (80 >> 2), S.stackSize), Atomics.store(s(), xe + (76 >> 2), be), Atomics.store(s(), xe + (104 >> 2), S.stackSize), Atomics.store(s(), xe + (104 + 8 >> 2), be), Atomics.store(s(), xe + (104 + 12 >> 2), S.detached); var Te = LS(), vt = Te + 40; Atomics.store(s(), xe + (172 >> 2), vt), $.pthread = he; var Er = { cmd: "run", start_routine: S.startRoutine, arg: S.arg, threadInfoStruct: S.pthread_ptr, stackBase: S.stackBase, stackSize: S.stackSize }; $.runPthread = function() { Er.time = performance.now(), $.postMessage(Er, S.transferList); }, $.loaded && ($.runPthread(), delete $.runPthread); } function mw(S, $, B, K) { if (typeof SharedArrayBuffer == "undefined") return H("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; if (!S) return H("pthread_create called with a null thread pointer!"), 28; var be = [], he = 0; if (w && (be.length === 0 || he)) return WS(687865856, S, $, B, K); if (he) return he; var xe = 0, Te = 0, vt = 0; $ && $ != -1 ? (xe = o()[$ >> 2], xe += 81920, Te = o()[$ + 8 >> 2], vt = o()[$ + 12 >> 2] !== 0) : xe = 2097152; var Er = Te == 0; Er ? Te = HS(16, xe) : (Te -= xe, de(Te > 0)); for (var _r = nu(228), cl = 0; cl < 228 >> 2; ++cl) s()[(_r >> 2) + cl] = 0; o()[S >> 2] = _r, o()[_r + 12 >> 2] = _r; var Pc = _r + 152; o()[Pc >> 2] = Pc; var Jr = { stackBase: Te, stackSize: xe, allocatedOwnStack: Er, detached: vt, startRoutine: B, pthread_ptr: _r, arg: K, transferList: be }; return w ? (Jr.cmd = "spawnThread", postMessage(Jr, be)) : gg(Jr), 0; } function fw() { if (!!w) { var S = ul(); if (!!S) { var $ = Atomics.load(s(), S + 56 >> 2); if (!$) { var B = Atomics.load(s(), S + 0 >> 2); if (B == 2) throw "Canceled!"; } } } } function dw() { x || g || q("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); } function hw(S, $, B) { if (!S) return H("pthread_join attempted on a null thread pointer!"), sl.ESRCH; if (w && ul() == S) return H("PThread " + S + " is attempting to join to itself!"), sl.EDEADLK; if (!w && VS() == S) return H("Main thread " + S + " is attempting to join to itself!"), sl.EDEADLK; var K = o()[S + 12 >> 2]; if (K !== S) return H("pthread_join attempted on thread " + S + ", which does not point to a valid thread, or does not exist anymore!"), sl.ESRCH; var be = Atomics.load(s(), S + 64 >> 2); if (be) return H("Attempted to join thread " + S + ", which was already detached!"), sl.EINVAL; for (B && dw(); ; ) { var he = Atomics.load(s(), S + 0 >> 2); if (he == 1) { var xe = Atomics.load(s(), S + 4 >> 2); return $ && (o()[$ >> 2] = xe), Atomics.store(s(), S + 64 >> 2, 1), w ? postMessage({ cmd: "cleanupThread", thread: S }) : ug(S), 0; } if (!B) return sl.EBUSY; fw(), w || Cg(), cg(S + 0, he, w ? 100 : 1); } } function gw(S, $) { return hw(S, $, true); } function xg(S) { if (w) return il(6, 1, S); switch (S) { case 30: return 16384; case 85: var $ = 2147483648; return $ / 16384; case 132: case 133: case 12: case 137: case 138: case 15: case 235: case 16: case 17: case 18: case 19: case 20: case 149: case 13: case 10: case 236: case 153: case 9: case 21: case 22: case 159: case 154: case 14: case 77: case 78: case 139: case 82: case 68: case 67: case 164: case 11: case 29: case 47: case 48: case 95: case 52: case 51: case 46: return 200809; case 27: case 246: case 127: case 128: case 23: case 24: case 160: case 161: case 181: case 182: case 242: case 183: case 184: case 243: case 244: case 245: case 165: case 178: case 179: case 49: case 50: case 168: case 169: case 175: case 170: case 171: case 172: case 97: case 76: case 32: case 173: case 35: case 80: case 81: case 79: return -1; case 176: case 177: case 7: case 155: case 8: case 157: case 125: case 126: case 92: case 93: case 129: case 130: case 131: case 94: case 91: return 1; case 74: case 60: case 69: case 70: case 4: return 1024; case 31: case 42: case 72: return 32; case 87: case 26: case 33: return 2147483647; case 34: case 1: return 47839; case 38: case 36: return 99; case 43: case 37: return 2048; case 0: return 2097152; case 3: return 65536; case 28: return 32768; case 44: return 32767; case 75: return 16384; case 39: return 1e3; case 89: return 700; case 71: return 256; case 40: return 255; case 2: return 100; case 180: return 64; case 25: return 20; case 5: return 16; case 6: return 6; case 73: return 4; case 84: return typeof navigator == "object" && navigator.hardwareConcurrency || 1; } return Ob(28), -1; } w || Ae.initMainThreadBlock(); var al, xw = [null, Pb, mg, fg, dg, hg, xg], yw = { e: Rb, r: Fb, x: Mb, b: Lb, y: zb, j: Bb, d: cg, c: Vm, f: ru, p: Vb, A: Gb, u: Ub, q: qb, v: ew, i: tw, s: rw, w: uw, l: fg, n: dg, g: hg, o: lg, a: ne || i.wasmMemory, z: cw, k: pw, h: mw, m: gw, t: xg }, PS = Sb(), yg = i.___wasm_call_ctors = function() { return (yg = i.___wasm_call_ctors = i.asm.B).apply(null, arguments); }, bw = i._init = function() { return (bw = i._init = i.asm.C).apply(null, arguments); }, ww = i._init_with_threads_count = function() { return (ww = i._init_with_threads_count = i.asm.D).apply(null, arguments); }, _w = i._get_threads_count = function() { return (_w = i._get_threads_count = i.asm.E).apply(null, arguments); }, kw = i._register_tensor = function() { return (kw = i._register_tensor = i.asm.F).apply(null, arguments); }, vw = i._dispose_data = function() { return (vw = i._dispose_data = i.asm.G).apply(null, arguments); }, Cw = i._dispose = function() { return (Cw = i._dispose = i.asm.H).apply(null, arguments); }, Iw = i._Abs = function() { return (Iw = i._Abs = i.asm.J).apply(null, arguments); }, Sw = i._Add = function() { return (Sw = i._Add = i.asm.K).apply(null, arguments); }, Nw = i._AddN = function() { return (Nw = i._AddN = i.asm.L).apply(null, arguments); }, Tw = i._All = function() { return (Tw = i._All = i.asm.M).apply(null, arguments); }, Ew = i._Any = function() { return (Ew = i._Any = i.asm.N).apply(null, arguments); }, Aw = i._ArgMax = function() { return (Aw = i._ArgMax = i.asm.O).apply(null, arguments); }, Dw = i._AvgPool = function() { return (Dw = i._AvgPool = i.asm.P).apply(null, arguments); }, $w = i._BatchMatMul = function() { return ($w = i._BatchMatMul = i.asm.Q).apply(null, arguments); }, Rw = i._Ceil = function() { return (Rw = i._Ceil = i.asm.R).apply(null, arguments); }, Fw = i._ClipByValue = function() { return (Fw = i._ClipByValue = i.asm.S).apply(null, arguments); }, Ow = i._Conv2D = function() { return (Ow = i._Conv2D = i.asm.T).apply(null, arguments); }, Pw = i._Conv2DBackpropInput = function() { return (Pw = i._Conv2DBackpropInput = i.asm.U).apply(null, arguments); }, Mw = i._Cos = function() { return (Mw = i._Cos = i.asm.V).apply(null, arguments); }, Lw = i._Cosh = function() { return (Lw = i._Cosh = i.asm.W).apply(null, arguments); }, bg = i._CropAndResize = function() { return (bg = i._CropAndResize = i.asm.X).apply(null, arguments); }, wg = i._Cumsum = function() { return (wg = i._Cumsum = i.asm.Y).apply(null, arguments); }, _g = i._DepthToSpace = function() { return (_g = i._DepthToSpace = i.asm.Z).apply(null, arguments); }, jm = i._DepthwiseConv2dNative = function() { return (jm = i._DepthwiseConv2dNative = i.asm._).apply(null, arguments); }, $c = i._Elu = function() { return ($c = i._Elu = i.asm.$).apply(null, arguments); }, zw = i._Equal = function() { return (zw = i._Equal = i.asm.aa).apply(null, arguments); }, Hm = i._Exp = function() { return (Hm = i._Exp = i.asm.ba).apply(null, arguments); }, Q = i._FlipLeftRight = function() { return (Q = i._FlipLeftRight = i.asm.ca).apply(null, arguments); }, ie = i._Floor = function() { return (ie = i._Floor = i.asm.da).apply(null, arguments); }, Ce = i._FloorDiv = function() { return (Ce = i._FloorDiv = i.asm.ea).apply(null, arguments); }, pt = i._FusedBatchNorm = function() { return (pt = i._FusedBatchNorm = i.asm.fa).apply(null, arguments); }, nr = i._FusedConv2D = function() { return (nr = i._FusedConv2D = i.asm.ga).apply(null, arguments); }, Ht = i._FusedDepthwiseConv2D = function() { return (Ht = i._FusedDepthwiseConv2D = i.asm.ha).apply(null, arguments); }, nt = i._Gather = function() { return (nt = i._Gather = i.asm.ia).apply(null, arguments); }, ot = i._GatherNd = function() { return (ot = i._GatherNd = i.asm.ja).apply(null, arguments); }, Pr = i._Greater = function() { return (Pr = i._Greater = i.asm.ka).apply(null, arguments); }, Oi = i._GreaterEqual = function() { return (Oi = i._GreaterEqual = i.asm.la).apply(null, arguments); }, Pi = i._LeakyRelu = function() { return (Pi = i._LeakyRelu = i.asm.ma).apply(null, arguments); }, kg = i._Less = function() { return (kg = i._Less = i.asm.na).apply(null, arguments); }, qm = i._LessEqual = function() { return (qm = i._LessEqual = i.asm.oa).apply(null, arguments); }, Rn = i._Log = function() { return (Rn = i._Log = i.asm.pa).apply(null, arguments); }, ll = i._LogicalAnd = function() { return (ll = i._LogicalAnd = i.asm.qa).apply(null, arguments); }, vg = i._Max = function() { return (vg = i._Max = i.asm.ra).apply(null, arguments); }, mG = i._MaxPool = function() { return (mG = i._MaxPool = i.asm.sa).apply(null, arguments); }, fG = i._Maximum = function() { return (fG = i._Maximum = i.asm.ta).apply(null, arguments); }, dG = i._Mean = function() { return (dG = i._Mean = i.asm.ua).apply(null, arguments); }, hG = i._Min = function() { return (hG = i._Min = i.asm.va).apply(null, arguments); }, gG = i._Minimum = function() { return (gG = i._Minimum = i.asm.wa).apply(null, arguments); }, xG = i._MirrorPad = function() { return (xG = i._MirrorPad = i.asm.xa).apply(null, arguments); }, yG = i._Multiply = function() { return (yG = i._Multiply = i.asm.ya).apply(null, arguments); }, bG = i._Neg = function() { return (bG = i._Neg = i.asm.za).apply(null, arguments); }, wG = i._NonMaxSuppressionV3 = function() { return (wG = i._NonMaxSuppressionV3 = i.asm.Aa).apply(null, arguments); }, _G = i._NonMaxSuppressionV4 = function() { return (_G = i._NonMaxSuppressionV4 = i.asm.Ba).apply(null, arguments); }, kG = i._NonMaxSuppressionV5 = function() { return (kG = i._NonMaxSuppressionV5 = i.asm.Ca).apply(null, arguments); }, vG = i._NotEqual = function() { return (vG = i._NotEqual = i.asm.Da).apply(null, arguments); }, CG = i._OneHot = function() { return (CG = i._OneHot = i.asm.Ea).apply(null, arguments); }, IG = i._PadV2 = function() { return (IG = i._PadV2 = i.asm.Fa).apply(null, arguments); }, SG = i._Pow = function() { return (SG = i._Pow = i.asm.Ga).apply(null, arguments); }, NG = i._Prelu = function() { return (NG = i._Prelu = i.asm.Ha).apply(null, arguments); }, TG = i._Prod = function() { return (TG = i._Prod = i.asm.Ia).apply(null, arguments); }, EG = i._RealDiv = function() { return (EG = i._RealDiv = i.asm.Ja).apply(null, arguments); }, AG = i._Relu = function() { return (AG = i._Relu = i.asm.Ka).apply(null, arguments); }, DG = i._Relu6 = function() { return (DG = i._Relu6 = i.asm.La).apply(null, arguments); }, $G = i._ResizeBilinear = function() { return ($G = i._ResizeBilinear = i.asm.Ma).apply(null, arguments); }, RG = i._Reverse = function() { return (RG = i._Reverse = i.asm.Na).apply(null, arguments); }, FG = i._RotateWithOffset = function() { return (FG = i._RotateWithOffset = i.asm.Oa).apply(null, arguments); }, OG = i._Round = function() { return (OG = i._Round = i.asm.Pa).apply(null, arguments); }, PG = i._Rsqrt = function() { return (PG = i._Rsqrt = i.asm.Qa).apply(null, arguments); }, MG = i._ScatterNd = function() { return (MG = i._ScatterNd = i.asm.Ra).apply(null, arguments); }, LG = i._SelectV2 = function() { return (LG = i._SelectV2 = i.asm.Sa).apply(null, arguments); }, zG = i._Sigmoid = function() { return (zG = i._Sigmoid = i.asm.Ta).apply(null, arguments); }, BG = i._Sin = function() { return (BG = i._Sin = i.asm.Ua).apply(null, arguments); }, VG = i._Softmax = function() { return (VG = i._Softmax = i.asm.Va).apply(null, arguments); }, GG = i._Sqrt = function() { return (GG = i._Sqrt = i.asm.Wa).apply(null, arguments); }, WG = i._Square = function() { return (WG = i._Square = i.asm.Xa).apply(null, arguments); }, UG = i._SquaredDifference = function() { return (UG = i._SquaredDifference = i.asm.Ya).apply(null, arguments); }, jG = i._Step = function() { return (jG = i._Step = i.asm.Za).apply(null, arguments); }, HG = i._StridedSlice = function() { return (HG = i._StridedSlice = i.asm._a).apply(null, arguments); }, qG = i._Sub = function() { return (qG = i._Sub = i.asm.$a).apply(null, arguments); }, KG = i._Sum = function() { return (KG = i._Sum = i.asm.ab).apply(null, arguments); }, XG = i._Tan = function() { return (XG = i._Tan = i.asm.bb).apply(null, arguments); }, YG = i._Tanh = function() { return (YG = i._Tanh = i.asm.cb).apply(null, arguments); }, ZG = i._Tile = function() { return (ZG = i._Tile = i.asm.db).apply(null, arguments); }, JG = i._TopK = function() { return (JG = i._TopK = i.asm.eb).apply(null, arguments); }, QG = i._Transform = function() { return (QG = i._Transform = i.asm.fb).apply(null, arguments); }, eW = i._Transpose = function() { return (eW = i._Transpose = i.asm.gb).apply(null, arguments); }, tW = i.__FusedMatMul = function() { return (tW = i.__FusedMatMul = i.asm.hb).apply(null, arguments); }, nu = i._malloc = function() { return (nu = i._malloc = i.asm.ib).apply(null, arguments); }, Km = i._free = function() { return (Km = i._free = i.asm.jb).apply(null, arguments); }, MS = i.___errno_location = function() { return (MS = i.___errno_location = i.asm.kb).apply(null, arguments); }, LS = i._emscripten_get_global_libc = function() { return (LS = i._emscripten_get_global_libc = i.asm.lb).apply(null, arguments); }, ul = i._pthread_self = function() { return (ul = i._pthread_self = i.asm.mb).apply(null, arguments); }, zS = i.___pthread_tsd_run_dtors = function() { return (zS = i.___pthread_tsd_run_dtors = i.asm.nb).apply(null, arguments); }, Cg = i._emscripten_main_thread_process_queued_calls = function() { return (Cg = i._emscripten_main_thread_process_queued_calls = i.asm.ob).apply(null, arguments); }, rW = i._emscripten_current_thread_process_queued_calls = function() { return (rW = i._emscripten_current_thread_process_queued_calls = i.asm.pb).apply(null, arguments); }, BS = i._emscripten_register_main_browser_thread_id = function() { return (BS = i._emscripten_register_main_browser_thread_id = i.asm.qb).apply(null, arguments); }, VS = i._emscripten_main_browser_thread_id = function() { return (VS = i._emscripten_main_browser_thread_id = i.asm.rb).apply(null, arguments); }, GS = i.__emscripten_do_dispatch_to_thread = function() { return (GS = i.__emscripten_do_dispatch_to_thread = i.asm.sb).apply(null, arguments); }, WS = i._emscripten_sync_run_in_main_thread_4 = function() { return (WS = i._emscripten_sync_run_in_main_thread_4 = i.asm.tb).apply(null, arguments); }, US = i._emscripten_run_in_main_runtime_thread_js = function() { return (US = i._emscripten_run_in_main_runtime_thread_js = i.asm.ub).apply(null, arguments); }, Bw = i.__emscripten_call_on_thread = function() { return (Bw = i.__emscripten_call_on_thread = i.asm.vb).apply(null, arguments); }, nW = i._emscripten_tls_init = function() { return (nW = i._emscripten_tls_init = i.asm.wb).apply(null, arguments); }, Vw = i.__emscripten_thread_init = function() { return (Vw = i.__emscripten_thread_init = i.asm.xb).apply(null, arguments); }, Xm = i.stackSave = function() { return (Xm = i.stackSave = i.asm.yb).apply(null, arguments); }, Rc = i.stackRestore = function() { return (Rc = i.stackRestore = i.asm.zb).apply(null, arguments); }, Fc = i.stackAlloc = function() { return (Fc = i.stackAlloc = i.asm.Ab).apply(null, arguments); }, jS = i._emscripten_stack_set_limits = function() { return (jS = i._emscripten_stack_set_limits = i.asm.Bb).apply(null, arguments); }, HS = i._memalign = function() { return (HS = i._memalign = i.asm.Cb).apply(null, arguments); }, qS = i.__emscripten_allow_main_runtime_queued_calls = 10512, Oc = i.__emscripten_main_thread_futex = 12148; i.cwrap = Re, i.PThread = Ae, i.PThread = Ae, i.wasmMemory = ne, i.ExitStatus = Ym; var Ig; function Ym(S) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + S + ")", this.status = S; } eu = function S() { Ig || Gw(), Ig || (eu = S); }; function Gw(S) { if (S = S || m, Jn > 0) return; if (w) { l(i), rg(), postMessage({ cmd: "loaded" }); return; } if (Ec(), Jn > 0) return; function $() { Ig || (Ig = true, i.calledRun = true, !ae && (rg(), ng(), l(i), i.onRuntimeInitialized && i.onRuntimeInitialized(), og())); } i.setStatus ? (i.setStatus("Running..."), setTimeout(function() { setTimeout(function() { i.setStatus(""); }, 1), $(); }, 1)) : $(); } i.run = Gw; function oW(S, $) { if (!($ && se && S === 0)) { if (!$ && w) throw postMessage({ cmd: "exitProcess", returnCode: S }), new Ym(S); se || (Ae.terminateAllThreads(), ge = S, yn(), i.onExit && i.onExit(S), ae = true), d(S, new Ym(S)); } } if (i.preInit) for (typeof i.preInit == "function" && (i.preInit = [i.preInit]); i.preInit.length > 0; ) i.preInit.pop()(); return w && (se = false, Ae.initWorker()), Gw(), e.ready; }; }(); typeof hb == "object" && typeof AS == "object" ? AS.exports = ES : typeof define == "function" && define.amd ? define([], function() { return ES; }) : typeof hb == "object" && (hb.WasmBackendModuleThreadedSimd = ES); }); var aG = qt((gb, $S) => { var DS = function() { var r = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (r = r || __filename), function(e) { e = e || {}; var t = typeof e != "undefined" ? e : {}, n, o; t.ready = new Promise(function(Q, ie) { n = Q, o = ie; }); var s = {}, a; for (a in t) t.hasOwnProperty(a) && (s[a] = t[a]); var i = [], l = "./this.program", u = function(Q, ie) { throw ie; }, c = false, p = false, m = false, f = false; c = typeof window == "object", p = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", f = !c && !m && !p; var d = ""; function h(Q) { return t.locateFile ? t.locateFile(Q, d) : d + Q; } var g, x, y, w, _, C; m ? (p ? d = Lm().dirname(d) + "/" : d = __dirname + "/", g = function(ie, Ce) { return _ || (_ = Lc("fs")), C || (C = Lm()), ie = C.normalize(ie), _.readFileSync(ie, Ce ? null : "utf8"); }, y = function(ie) { var Ce = g(ie, true); return Ce.buffer || (Ce = new Uint8Array(Ce)), j(Ce.buffer), Ce; }, process.argv.length > 1 && (l = process.argv[1].replace(/\\/g, "/")), i = process.argv.slice(2), process.on("uncaughtException", function(Q) { if (!(Q instanceof zw)) throw Q; }), process.on("unhandledRejection", Eo), u = function(Q) { process.exit(Q); }, t.inspect = function() { return "[Emscripten Module object]"; }) : f ? (typeof read != "undefined" && (g = function(ie) { return read(ie); }), y = function(ie) { var Ce; return typeof readbuffer == "function" ? new Uint8Array(readbuffer(ie)) : (Ce = read(ie, "binary"), j(typeof Ce == "object"), Ce); }, typeof scriptArgs != "undefined" ? i = scriptArgs : typeof arguments != "undefined" && (i = arguments), typeof quit == "function" && (u = function(Q) { quit(Q); }), typeof print != "undefined" && (typeof console == "undefined" && (console = {}), console.log = print, console.warn = console.error = typeof printErr != "undefined" ? printErr : print)) : (c || p) && (p ? d = self.location.href : typeof document != "undefined" && document.currentScript && (d = document.currentScript.src), r && (d = r), d.indexOf("blob:") !== 0 ? d = d.substr(0, d.lastIndexOf("/") + 1) : d = "", g = function(Q) { var ie = new XMLHttpRequest(); return ie.open("GET", Q, false), ie.send(null), ie.responseText; }, p && (y = function(Q) { var ie = new XMLHttpRequest(); return ie.open("GET", Q, false), ie.responseType = "arraybuffer", ie.send(null), new Uint8Array(ie.response); }), x = function(Q, ie, Ce) { var pt = new XMLHttpRequest(); pt.open("GET", Q, true), pt.responseType = "arraybuffer", pt.onload = function() { if (pt.status == 200 || pt.status == 0 && pt.response) { ie(pt.response); return; } Ce(); }, pt.onerror = Ce, pt.send(null); }, w = function(Q) { document.title = Q; }); var A = t.print || console.log.bind(console), D = t.printErr || console.warn.bind(console); for (a in s) s.hasOwnProperty(a) && (t[a] = s[a]); s = null, t.arguments && (i = t.arguments), t.thisProgram && (l = t.thisProgram), t.quit && (u = t.quit); var R; t.wasmBinary && (R = t.wasmBinary); var P = t.noExitRuntime || true; typeof WebAssembly != "object" && Eo("no native wasm support detected"); var L, G = false, W; function j(Q, ie) { Q || Eo("Assertion failed: " + ie); } function H(Q) { var ie = t["_" + Q]; return j(ie, "Cannot call unknown function " + Q + ", make sure it is exported"), ie; } function q(Q, ie, Ce, pt, nr) { var Ht = { string: function(Rn) { var ll = 0; if (Rn != null && Rn !== 0) { var vg = (Rn.length << 2) + 1; ll = jm(vg), ne(Rn, ll, vg); } return ll; }, array: function(Rn) { var ll = jm(Rn.length); return fe(Rn, ll), ll; } }; function nt(Rn) { return ie === "string" ? oe(Rn) : ie === "boolean" ? Boolean(Rn) : Rn; } var ot = H(Q), Pr = [], Oi = 0; if (pt) for (var Pi = 0; Pi < pt.length; Pi++) { var kg = Ht[Ce[Pi]]; kg ? (Oi === 0 && (Oi = wg()), Pr[Pi] = kg(pt[Pi])) : Pr[Pi] = pt[Pi]; } var qm = ot.apply(null, Pr); return qm = nt(qm), Oi !== 0 && _g(Oi), qm; } function X(Q, ie, Ce, pt) { Ce = Ce || []; var nr = Ce.every(function(nt) { return nt === "number"; }), Ht = ie !== "string"; return Ht && nr && !pt ? H(Q) : function() { return q(Q, ie, Ce, arguments, pt); }; } var re = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; function J(Q, ie, Ce) { for (var pt = ie + Ce, nr = ie; Q[nr] && !(nr >= pt); ) ++nr; if (nr - ie > 16 && Q.subarray && re) return re.decode(Q.subarray(ie, nr)); for (var Ht = ""; ie < nr; ) { var nt = Q[ie++]; if (!(nt & 128)) { Ht += String.fromCharCode(nt); continue; } var ot = Q[ie++] & 63; if ((nt & 224) == 192) { Ht += String.fromCharCode((nt & 31) << 6 | ot); continue; } var Pr = Q[ie++] & 63; if ((nt & 240) == 224 ? nt = (nt & 15) << 12 | ot << 6 | Pr : nt = (nt & 7) << 18 | ot << 12 | Pr << 6 | Q[ie++] & 63, nt < 65536) Ht += String.fromCharCode(nt); else { var Oi = nt - 65536; Ht += String.fromCharCode(55296 | Oi >> 10, 56320 | Oi & 1023); } } return Ht; } function oe(Q, ie) { return Q ? J(ye, Q, ie) : ""; } function se(Q, ie, Ce, pt) { if (!(pt > 0)) return 0; for (var nr = Ce, Ht = Ce + pt - 1, nt = 0; nt < Q.length; ++nt) { var ot = Q.charCodeAt(nt); if (ot >= 55296 && ot <= 57343) { var Pr = Q.charCodeAt(++nt); ot = 65536 + ((ot & 1023) << 10) | Pr & 1023; } if (ot <= 127) { if (Ce >= Ht) break; ie[Ce++] = ot; } else if (ot <= 2047) { if (Ce + 1 >= Ht) break; ie[Ce++] = 192 | ot >> 6, ie[Ce++] = 128 | ot & 63; } else if (ot <= 65535) { if (Ce + 2 >= Ht) break; ie[Ce++] = 224 | ot >> 12, ie[Ce++] = 128 | ot >> 6 & 63, ie[Ce++] = 128 | ot & 63; } else { if (Ce + 3 >= Ht) break; ie[Ce++] = 240 | ot >> 18, ie[Ce++] = 128 | ot >> 12 & 63, ie[Ce++] = 128 | ot >> 6 & 63, ie[Ce++] = 128 | ot & 63; } } return ie[Ce] = 0, Ce - nr; } function ne(Q, ie, Ce) { return se(Q, ye, ie, Ce); } function fe(Q, ie) { de.set(Q, ie); } function ae(Q, ie) { return Q % ie > 0 && (Q += ie - Q % ie), Q; } var ge, de, ye, _e, Re, Ee, Fe, Ye, ut; function At(Q) { ge = Q, t.HEAP8 = de = new Int8Array(Q), t.HEAP16 = _e = new Int16Array(Q), t.HEAP32 = Ee = new Int32Array(Q), t.HEAPU8 = ye = new Uint8Array(Q), t.HEAPU16 = Re = new Uint16Array(Q), t.HEAPU32 = Fe = new Uint32Array(Q), t.HEAPF32 = Ye = new Float32Array(Q), t.HEAPF64 = ut = new Float64Array(Q); } var Dt = t.INITIAL_MEMORY || 16777216, ft, Ke = [], ht = [], Mt = [], Dn = [], lr = false; ht.push({ func: function() { lg(); } }); function gn() { if (t.preRun) for (typeof t.preRun == "function" && (t.preRun = [t.preRun]); t.preRun.length; ) Tr(t.preRun.shift()); Jn(Ke); } function Or() { lr = true, Jn(ht); } function To() { Jn(Mt); } function Zr() { if (t.postRun) for (typeof t.postRun == "function" && (t.postRun = [t.postRun]); t.postRun.length; ) Gn(t.postRun.shift()); Jn(Dn); } function Tr(Q) { Ke.unshift(Q); } function Gn(Q) { Dn.unshift(Q); } var ur = 0, xn = null, $n = null; function Jl(Q) { ur++, t.monitorRunDependencies && t.monitorRunDependencies(ur); } function Ql(Q) { if (ur--, t.monitorRunDependencies && t.monitorRunDependencies(ur), ur == 0 && (xn !== null && (clearInterval(xn), xn = null), $n)) { var ie = $n; $n = null, ie(); } } t.preloadedImages = {}, t.preloadedAudios = {}; function Eo(Q) { t.onAbort && t.onAbort(Q), Q += "", D(Q), G = true, W = 1, Q = "abort(" + Q + "). Build with -s ASSERTIONS=1 for more info."; var ie = new WebAssembly.RuntimeError(Q); throw o(ie), ie; } function Ri(Q, ie) { return String.prototype.startsWith ? Q.startsWith(ie) : Q.indexOf(ie) === 0; } var zm = "data:application/octet-stream;base64,"; function Ec(Q) { return Ri(Q, zm); } var rg = "file://"; function ng(Q) { return Ri(Q, rg); } var yn = "tfjs-backend-wasm.wasm"; Ec(yn) || (yn = h(yn)); function og(Q) { try { if (Q == yn && R) return new Uint8Array(R); if (y) return y(Q); throw "both async and sync fetching of the wasm failed"; } catch (ie) { Eo(ie); } } function bb() { if (!R && (c || p)) { if (typeof fetch == "function" && !ng(yn)) return fetch(yn, { credentials: "same-origin" }).then(function(Q) { if (!Q.ok) throw "failed to load wasm binary file at '" + yn + "'"; return Q.arrayBuffer(); }).catch(function() { return og(yn); }); if (x) return new Promise(function(Q, ie) { x(yn, function(Ce) { Q(new Uint8Array(Ce)); }, ie); }); } return Promise.resolve().then(function() { return og(yn); }); } function wb() { var Q = { a: Sb }; function ie(nt, ot) { var Pr = nt.exports; t.asm = Pr, L = t.asm.j, At(L.buffer), ft = t.asm.r, Ql("wasm-instantiate"); } Jl("wasm-instantiate"); function Ce(nt) { ie(nt.instance); } function pt(nt) { return bb().then(function(ot) { return WebAssembly.instantiate(ot, Q); }).then(nt, function(ot) { D("failed to asynchronously prepare wasm: " + ot), Eo(ot); }); } function nr() { return !R && typeof WebAssembly.instantiateStreaming == "function" && !Ec(yn) && !ng(yn) && typeof fetch == "function" ? fetch(yn, { credentials: "same-origin" }).then(function(nt) { var ot = WebAssembly.instantiateStreaming(nt, Q); return ot.then(Ce, function(Pr) { return D("wasm streaming compile failed: " + Pr), D("falling back to ArrayBuffer instantiation"), pt(Ce); }); }) : pt(Ce); } if (t.instantiateWasm) try { var Ht = t.instantiateWasm(Q, ie); return Ht; } catch (nt) { return D("Module.instantiateWasm callback failed with error: " + nt), false; } return nr().catch(o), {}; } function Jn(Q) { for (; Q.length > 0; ) { var ie = Q.shift(); if (typeof ie == "function") { ie(t); continue; } var Ce = ie.func; typeof Ce == "number" ? ie.arg === void 0 ? ft.get(Ce)() : ft.get(Ce)(ie.arg) : Ce(ie.arg === void 0 ? null : ie.arg); } } function Bm() { Eo(); } function eu(Q, ie, Ce) { ye.copyWithin(Q, ie, ie + Ce); } function _b() { return ye.length; } function kb(Q) { try { return L.grow(Q - ge.byteLength + 65535 >>> 16), At(L.buffer), 1; } catch (ie) { } } function Fi(Q) { var ie = _b(), Ce = 2147483648; if (Q > Ce) return false; for (var pt = 1; pt <= 4; pt *= 2) { var nr = ie * (1 + 0.2 / pt); nr = Math.min(nr, Q + 100663296); var Ht = Math.min(Ce, ae(Math.max(Q, nr), 65536)), nt = kb(Ht); if (nt) return true; } return false; } var tu = { mappings: {}, buffers: [null, [], []], printChar: function(Q, ie) { var Ce = tu.buffers[Q]; ie === 0 || ie === 10 ? ((Q === 1 ? A : D)(J(Ce, 0)), Ce.length = 0) : Ce.push(ie); }, varargs: void 0, get: function() { tu.varargs += 4; var Q = Ee[tu.varargs - 4 >> 2]; return Q; }, getStr: function(Q) { var ie = oe(Q); return ie; }, get64: function(Q, ie) { return Q; } }; function vb(Q) { return 0; } function sg(Q, ie, Ce, pt, nr) { } function Cb(Q, ie, Ce, pt) { for (var nr = 0, Ht = 0; Ht < Ce; Ht++) { for (var nt = Ee[ie + Ht * 8 >> 2], ot = Ee[ie + (Ht * 8 + 4) >> 2], Pr = 0; Pr < ot; Pr++) tu.printChar(Q, ye[nt + Pr]); nr += ot; } return Ee[pt >> 2] = nr, 0; } function ig() { return 6; } function bn() { return 28; } function ag(Q) { return Ee[bg() >> 2] = Q, Q; } function Ib(Q) { switch (Q) { case 30: return 16384; case 85: var ie = 2147483648; return ie / 16384; case 132: case 133: case 12: case 137: case 138: case 15: case 235: case 16: case 17: case 18: case 19: case 20: case 149: case 13: case 10: case 236: case 153: case 9: case 21: case 22: case 159: case 154: case 14: case 77: case 78: case 139: case 82: case 68: case 67: case 164: case 11: case 29: case 47: case 48: case 95: case 52: case 51: case 46: return 200809; case 27: case 246: case 127: case 128: case 23: case 24: case 160: case 161: case 181: case 182: case 242: case 183: case 184: case 243: case 244: case 245: case 165: case 178: case 179: case 49: case 50: case 168: case 169: case 175: case 170: case 171: case 172: case 97: case 76: case 32: case 173: case 35: case 80: case 81: case 79: return -1; case 176: case 177: case 7: case 155: case 8: case 157: case 125: case 126: case 92: case 93: case 129: case 130: case 131: case 94: case 91: return 1; case 74: case 60: case 69: case 70: case 4: return 1024; case 31: case 42: case 72: return 32; case 87: case 26: case 33: return 2147483647; case 34: case 1: return 47839; case 38: case 36: return 99; case 43: case 37: return 2048; case 0: return 2097152; case 3: return 65536; case 28: return 32768; case 44: return 32767; case 75: return 16384; case 39: return 1e3; case 89: return 700; case 71: return 256; case 40: return 255; case 2: return 100; case 180: return 64; case 25: return 20; case 5: return 16; case 6: return 6; case 73: return 4; case 84: return typeof navigator == "object" && navigator.hardwareConcurrency || 1; } return ag(28), -1; } var Sb = { a: Bm, d: eu, e: Fi, f: vb, c: sg, b: Cb, h: ig, g: bn, i: Ib }, Nb = wb(), lg = t.___wasm_call_ctors = function() { return (lg = t.___wasm_call_ctors = t.asm.k).apply(null, arguments); }, Ac = t._init = function() { return (Ac = t._init = t.asm.l).apply(null, arguments); }, sl = t._init_with_threads_count = function() { return (sl = t._init_with_threads_count = t.asm.m).apply(null, arguments); }, Vm = t._get_threads_count = function() { return (Vm = t._get_threads_count = t.asm.n).apply(null, arguments); }, Tb = t._register_tensor = function() { return (Tb = t._register_tensor = t.asm.o).apply(null, arguments); }, Eb = t._dispose_data = function() { return (Eb = t._dispose_data = t.asm.p).apply(null, arguments); }, ug = t._dispose = function() { return (ug = t._dispose = t.asm.q).apply(null, arguments); }, Ae = t._Abs = function() { return (Ae = t._Abs = t.asm.s).apply(null, arguments); }, Ab = t._Add = function() { return (Ab = t._Add = t.asm.t).apply(null, arguments); }, Db = t._AddN = function() { return (Db = t._AddN = t.asm.u).apply(null, arguments); }, $b = t._All = function() { return ($b = t._All = t.asm.v).apply(null, arguments); }, Rb = t._Any = function() { return (Rb = t._Any = t.asm.w).apply(null, arguments); }, Fb = t._ArgMax = function() { return (Fb = t._ArgMax = t.asm.x).apply(null, arguments); }, ru = t._AvgPool = function() { return (ru = t._AvgPool = t.asm.y).apply(null, arguments); }, Ob = t._BatchMatMul = function() { return (Ob = t._BatchMatMul = t.asm.z).apply(null, arguments); }, Pb = t._Ceil = function() { return (Pb = t._Ceil = t.asm.A).apply(null, arguments); }, Mb = t._ClipByValue = function() { return (Mb = t._ClipByValue = t.asm.B).apply(null, arguments); }, Lb = t._Conv2D = function() { return (Lb = t._Conv2D = t.asm.C).apply(null, arguments); }, zb = t._Conv2DBackpropInput = function() { return (zb = t._Conv2DBackpropInput = t.asm.D).apply(null, arguments); }, Bb = t._Cos = function() { return (Bb = t._Cos = t.asm.E).apply(null, arguments); }, cg = t._Cosh = function() { return (cg = t._Cosh = t.asm.F).apply(null, arguments); }, Vb = t._CropAndResize = function() { return (Vb = t._CropAndResize = t.asm.G).apply(null, arguments); }, Gb = t._Cumsum = function() { return (Gb = t._Cumsum = t.asm.H).apply(null, arguments); }, il = t._DepthToSpace = function() { return (il = t._DepthToSpace = t.asm.I).apply(null, arguments); }, Gm = t._DepthwiseConv2dNative = function() { return (Gm = t._DepthwiseConv2dNative = t.asm.J).apply(null, arguments); }, Wm = t._Elu = function() { return (Wm = t._Elu = t.asm.K).apply(null, arguments); }, Wb = t._Equal = function() { return (Wb = t._Equal = t.asm.L).apply(null, arguments); }, Ub = t._Exp = function() { return (Ub = t._Exp = t.asm.M).apply(null, arguments); }, jb = t._FlipLeftRight = function() { return (jb = t._FlipLeftRight = t.asm.N).apply(null, arguments); }, Hb = t._Floor = function() { return (Hb = t._Floor = t.asm.O).apply(null, arguments); }, qb = t._FloorDiv = function() { return (qb = t._FloorDiv = t.asm.P).apply(null, arguments); }, Qe = t._FusedBatchNorm = function() { return (Qe = t._FusedBatchNorm = t.asm.Q).apply(null, arguments); }, Kb = t._FusedConv2D = function() { return (Kb = t._FusedConv2D = t.asm.R).apply(null, arguments); }, Xb = t._FusedDepthwiseConv2D = function() { return (Xb = t._FusedDepthwiseConv2D = t.asm.S).apply(null, arguments); }, Yb = t._Gather = function() { return (Yb = t._Gather = t.asm.T).apply(null, arguments); }, Zb = t._GatherNd = function() { return (Zb = t._GatherNd = t.asm.U).apply(null, arguments); }, Jb = t._Greater = function() { return (Jb = t._Greater = t.asm.V).apply(null, arguments); }, Qb = t._GreaterEqual = function() { return (Qb = t._GreaterEqual = t.asm.W).apply(null, arguments); }, Um = t._LeakyRelu = function() { return (Um = t._LeakyRelu = t.asm.X).apply(null, arguments); }, pg = t._Less = function() { return (pg = t._Less = t.asm.Y).apply(null, arguments); }, mg = t._LessEqual = function() { return (mg = t._LessEqual = t.asm.Z).apply(null, arguments); }, ew = t._Log = function() { return (ew = t._Log = t.asm._).apply(null, arguments); }, tw = t._LogicalAnd = function() { return (tw = t._LogicalAnd = t.asm.$).apply(null, arguments); }, rw = t._Max = function() { return (rw = t._Max = t.asm.aa).apply(null, arguments); }, nw = t._MaxPool = function() { return (nw = t._MaxPool = t.asm.ba).apply(null, arguments); }, ow = t._Maximum = function() { return (ow = t._Maximum = t.asm.ca).apply(null, arguments); }, sw = t._Mean = function() { return (sw = t._Mean = t.asm.da).apply(null, arguments); }, iw = t._Min = function() { return (iw = t._Min = t.asm.ea).apply(null, arguments); }, gt = t._Minimum = function() { return (gt = t._Minimum = t.asm.fa).apply(null, arguments); }, aw = t._MirrorPad = function() { return (aw = t._MirrorPad = t.asm.ga).apply(null, arguments); }, lw = t._Multiply = function() { return (lw = t._Multiply = t.asm.ha).apply(null, arguments); }, uw = t._Neg = function() { return (uw = t._Neg = t.asm.ia).apply(null, arguments); }, Dc = t._NonMaxSuppressionV3 = function() { return (Dc = t._NonMaxSuppressionV3 = t.asm.ja).apply(null, arguments); }, fg = t._NonMaxSuppressionV4 = function() { return (fg = t._NonMaxSuppressionV4 = t.asm.ka).apply(null, arguments); }, dg = t._NonMaxSuppressionV5 = function() { return (dg = t._NonMaxSuppressionV5 = t.asm.la).apply(null, arguments); }, hg = t._NotEqual = function() { return (hg = t._NotEqual = t.asm.ma).apply(null, arguments); }, cw = t._OneHot = function() { return (cw = t._OneHot = t.asm.na).apply(null, arguments); }, pw = t._PadV2 = function() { return (pw = t._PadV2 = t.asm.oa).apply(null, arguments); }, gg = t._Pow = function() { return (gg = t._Pow = t.asm.pa).apply(null, arguments); }, mw = t._Prelu = function() { return (mw = t._Prelu = t.asm.qa).apply(null, arguments); }, fw = t._Prod = function() { return (fw = t._Prod = t.asm.ra).apply(null, arguments); }, dw = t._RealDiv = function() { return (dw = t._RealDiv = t.asm.sa).apply(null, arguments); }, hw = t._Relu = function() { return (hw = t._Relu = t.asm.ta).apply(null, arguments); }, gw = t._Relu6 = function() { return (gw = t._Relu6 = t.asm.ua).apply(null, arguments); }, xg = t._ResizeBilinear = function() { return (xg = t._ResizeBilinear = t.asm.va).apply(null, arguments); }, al = t._Reverse = function() { return (al = t._Reverse = t.asm.wa).apply(null, arguments); }, xw = t._RotateWithOffset = function() { return (xw = t._RotateWithOffset = t.asm.xa).apply(null, arguments); }, yw = t._Round = function() { return (yw = t._Round = t.asm.ya).apply(null, arguments); }, PS = t._Rsqrt = function() { return (PS = t._Rsqrt = t.asm.za).apply(null, arguments); }, yg = t._ScatterNd = function() { return (yg = t._ScatterNd = t.asm.Aa).apply(null, arguments); }, bw = t._SelectV2 = function() { return (bw = t._SelectV2 = t.asm.Ba).apply(null, arguments); }, ww = t._Sigmoid = function() { return (ww = t._Sigmoid = t.asm.Ca).apply(null, arguments); }, _w = t._Sin = function() { return (_w = t._Sin = t.asm.Da).apply(null, arguments); }, kw = t._Softmax = function() { return (kw = t._Softmax = t.asm.Ea).apply(null, arguments); }, vw = t._Sqrt = function() { return (vw = t._Sqrt = t.asm.Fa).apply(null, arguments); }, Cw = t._Square = function() { return (Cw = t._Square = t.asm.Ga).apply(null, arguments); }, Iw = t._SquaredDifference = function() { return (Iw = t._SquaredDifference = t.asm.Ha).apply(null, arguments); }, Sw = t._Step = function() { return (Sw = t._Step = t.asm.Ia).apply(null, arguments); }, Nw = t._StridedSlice = function() { return (Nw = t._StridedSlice = t.asm.Ja).apply(null, arguments); }, Tw = t._Sub = function() { return (Tw = t._Sub = t.asm.Ka).apply(null, arguments); }, Ew = t._Sum = function() { return (Ew = t._Sum = t.asm.La).apply(null, arguments); }, Aw = t._Tan = function() { return (Aw = t._Tan = t.asm.Ma).apply(null, arguments); }, Dw = t._Tanh = function() { return (Dw = t._Tanh = t.asm.Na).apply(null, arguments); }, $w = t._Tile = function() { return ($w = t._Tile = t.asm.Oa).apply(null, arguments); }, Rw = t._TopK = function() { return (Rw = t._TopK = t.asm.Pa).apply(null, arguments); }, Fw = t._Transform = function() { return (Fw = t._Transform = t.asm.Qa).apply(null, arguments); }, Ow = t._Transpose = function() { return (Ow = t._Transpose = t.asm.Ra).apply(null, arguments); }, Pw = t.__FusedMatMul = function() { return (Pw = t.__FusedMatMul = t.asm.Sa).apply(null, arguments); }, Mw = t._malloc = function() { return (Mw = t._malloc = t.asm.Ta).apply(null, arguments); }, Lw = t._free = function() { return (Lw = t._free = t.asm.Ua).apply(null, arguments); }, bg = t.___errno_location = function() { return (bg = t.___errno_location = t.asm.Va).apply(null, arguments); }, wg = t.stackSave = function() { return (wg = t.stackSave = t.asm.Wa).apply(null, arguments); }, _g = t.stackRestore = function() { return (_g = t.stackRestore = t.asm.Xa).apply(null, arguments); }, jm = t.stackAlloc = function() { return (jm = t.stackAlloc = t.asm.Ya).apply(null, arguments); }; t.cwrap = X; var $c; function zw(Q) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + Q + ")", this.status = Q; } $n = function Q() { $c || Hm(), $c || ($n = Q); }; function Hm(Q) { if (Q = Q || i, ur > 0 || (gn(), ur > 0)) return; function ie() { $c || ($c = true, t.calledRun = true, !G && (Or(), To(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), Zr())); } t.setStatus ? (t.setStatus("Running..."), setTimeout(function() { setTimeout(function() { t.setStatus(""); }, 1), ie(); }, 1)) : ie(); } if (t.run = Hm, t.preInit) for (typeof t.preInit == "function" && (t.preInit = [t.preInit]); t.preInit.length > 0; ) t.preInit.pop()(); return Hm(), e.ready; }; }(); typeof gb == "object" && typeof $S == "object" ? $S.exports = DS : typeof define == "function" && define.amd ? define([], function() { return DS; }) : typeof gb == "object" && (gb.WasmBackendModule = DS); }); var pW = 1e-7; var mW = 1e-4; var pl = class { constructor(e, t) { this.backend = e, this.dataMover = t, this.data = new WeakMap(), this.dataIdsCount = 0; } get(e) { return this.data.has(e) || this.dataMover.moveData(this.backend, e), this.data.get(e); } set(e, t) { this.dataIdsCount++, this.data.set(e, t); } has(e) { return this.data.has(e); } delete(e) { return this.dataIdsCount--, this.data.delete(e); } numDataIds() { return this.dataIdsCount; } }; var Js = class { refCount(e) { return Qn("refCount"); } incRef(e) { return Qn("incRef"); } timerAvailable() { return true; } time(e) { return Qn("time"); } read(e) { return Qn("read"); } readSync(e) { return Qn("readSync"); } numDataIds() { return Qn("numDataIds"); } disposeData(e, t) { return Qn("disposeData"); } write(e, t, n) { return Qn("write"); } move(e, t, n, o, s) { return Qn("move"); } memory() { return Qn("memory"); } floatPrecision() { return Qn("floatPrecision"); } epsilon() { return this.floatPrecision() === 32 ? pW : mW; } dispose() { return Qn("dispose"); } }; function Qn(r) { throw new Error(`'${r}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`); } function YS(r) { let e = r.length, t = 0; for (; e > 0; ) t = Math.random() * e | 0, e--, Ng(r, e, t); } function fW(r, e) { if (r.length !== e.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${r.length}Second array length was ${e.length}`); let t = r.length, n = 0; for (; t > 0; ) n = Math.random() * t | 0, t--, Ng(r, t, n), Ng(e, t, n); } function zc(r, e, t) { return Math.max(r, Math.min(e, t)); } function dW(r) { return r % 2 == 0 ? r : r + 1; } function Ng(r, e, t) { let n = r[e]; r[e] = r[t], r[t] = n; } function hW(r) { let e = 0; for (let t = 0; t < r.length; t++) e += r[t]; return e; } function gW(r, e) { let t = Math.random(); return e * t + (1 - t) * r; } function xW(r, e) { let t = 0; for (let n = 0; n < r.length; n++) { let o = Number(r[n]) - Number(e[n]); t += o * o; } return t; } function E(r, e) { if (!r) throw new Error(typeof e == "string" ? e : e()); } function Rt(r, e, t = "") { E(Qr(r, e), () => t + ` Shapes ${r} and ${e} must match`); } function Wn(r) { E(r != null, () => "The input to the tensor constructor must be a non-null value."); } function Ao(r, e = [], t = false) { if (e == null && (e = []), Array.isArray(r) || dr(r) && !t) for (let n = 0; n < r.length; ++n) Ao(r[n], e, t); else e.push(r); return e; } function st(r) { if (r.length === 0) return 1; let e = r[0]; for (let t = 1; t < r.length; t++) e *= r[t]; return e; } function yW(r) { return r.length === 0; } function Qr(r, e) { if (r === e) return true; if (r == null || e == null || r.length !== e.length) return false; for (let t = 0; t < r.length; t++) if (r[t] !== e[t]) return false; return true; } function it(r) { return r % 1 == 0; } function bW(r) { if (Math.tanh != null) return Math.tanh(r); if (r === 1 / 0) return 1; if (r === -1 / 0) return -1; { let e = Math.exp(2 * r); return (e - 1) / (e + 1); } } function wW(r) { let e = Math.ceil(Math.sqrt(r)); return [e, Math.ceil(r / e)]; } function _W(r) { let e = new Uint32Array(r); for (let t = 0; t < r; ++t) e[t] = t; return YS(e), e; } function su(r, e) { return e <= r.length ? r : r + " ".repeat(e - r.length); } function kW(r, e = (n) => 0, t) { return new Promise((n, o) => { let s = 0, a = () => { if (r()) { n(); return; } s++; let i = e(s); if (t != null && s >= t) { o(); return; } setTimeout(a, i); }; a(); }); } function vW(r, e) { let t = 1, n = -1; for (let s = 0; s < r.length; ++s) if (r[s] >= 0) t *= r[s]; else if (r[s] === -1) { if (n !== -1) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${s}`); n = s; } else if (r[s] < 0) throw Error(`Shapes can not be < 0. Found ${r[s]} at dim ${s}`); if (n === -1) { if (e > 0 && e !== t) throw Error(`Size(${e}) must match the product of shape ${r}`); return r; } if (t === 0) throw Error(`Cannot infer the missing size in [${r}] when there are 0 elements`); if (e % t != 0) throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`); let o = r.slice(); return o[n] = e / t, o; } function cr(r, e) { let t = e.length; return r = r == null ? e.map((n, o) => o) : [].concat(r), E(r.every((n) => n >= -t && n < t), () => `All values in axis param must be in range [-${t}, ${t}) but got axis ${r}`), E(r.every((n) => it(n)), () => `All values in axis param must be integers but got axis ${r}`), r.map((n) => n < 0 ? t + n : n); } function Ww(r, e) { let t = [], n = [], o = e != null && Array.isArray(e) && e.length === 0, s = e == null || o ? null : cr(e, r).sort(), a = 0; for (let i = 0; i < r.length; ++i) { if (s != null) { if (s[a] === i && r[i] !== 1) throw new Error(`Can't squeeze axis ${i} since its dim '${r[i]}' is not 1`); (s[a] == null || s[a] > i) && r[i] === 1 && (t.push(r[i]), n.push(i)), s[a] <= i && a++; } r[i] !== 1 && (t.push(r[i]), n.push(i)); } return { newShape: t, keptDims: n }; } function Uw(r, e) { let t = null; if (r == null || r === "float32") t = new Float32Array(e); else if (r === "int32") t = new Int32Array(e); else if (r === "bool") t = new Uint8Array(e); else throw new Error(`Unknown data type ${r}`); return t; } function jw(r, e) { let t = null; if (r == null || r === "float32") t = new Float32Array(e); else if (r === "int32") t = new Int32Array(e); else if (r === "bool") t = new Uint8Array(e); else if (r === "string") t = new Array(e); else throw new Error(`Unknown data type ${r}`); return t; } function Hw(r, e) { for (let t = 0; t < r.length; t++) { let n = r[t]; if (isNaN(n) || !isFinite(n)) throw Error(`A tensor of type ${e} being uploaded contains ${n}.`); } } function qw(r) { return r === "bool" || r === "complex64" || r === "float32" || r === "int32" || r === "string"; } function CW(r, e) { return !(e === "complex64" || e === "float32" && r !== "complex64" || e === "int32" && r !== "float32" && r !== "complex64" || e === "bool" && r === "bool"); } function dr(r) { return r instanceof Float32Array || r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray; } function Tg(r) { if (r === "float32" || r === "int32") return 4; if (r === "complex64") return 8; if (r === "bool") return 1; throw new Error(`Unknown dtype ${r}`); } function Kw(r) { if (r == null) return 0; let e = 0; return r.forEach((t) => e += t.length), e; } function Do(r) { return typeof r == "string" || r instanceof String; } function ZS(r) { return typeof r == "boolean"; } function JS(r) { return typeof r == "number"; } function Bc(r) { return Array.isArray(r) ? Bc(r[0]) : r instanceof Float32Array ? "float32" : r instanceof Int32Array || r instanceof Uint8Array || r instanceof Uint8ClampedArray ? "int32" : JS(r) ? "float32" : Do(r) ? "string" : ZS(r) ? "bool" : "float32"; } function Qs(r) { return !!(r && r.constructor && r.call && r.apply); } function Vc(r, e) { for (let t = e; t < r; ++t) if (r % t == 0) return t; return r; } function ei(r) { let e = r.length; if (e < 2) return []; let t = new Array(e - 1); t[e - 2] = r[e - 1]; for (let n = e - 3; n >= 0; --n) t[n] = t[n + 1] * r[n + 1]; return t; } function QS(r, e, t, n = false) { let o = new Array(); if (e.length === 1) { let s = e[0] * (n ? 2 : 1); for (let a = 0; a < s; a++) o[a] = t[r + a]; } else { let s = e[0], a = e.slice(1), i = a.reduce((l, u) => l * u) * (n ? 2 : 1); for (let l = 0; l < s; l++) o[l] = QS(r + l * i, a, t, n); } return o; } function iu(r, e, t = false) { if (r.length === 0) return e[0]; let n = r.reduce((o, s) => o * s) * (t ? 2 : 1); if (n === 0) return []; if (n !== e.length) throw new Error(`[${r}] does not match the input size ${e.length}${t ? " for a complex tensor" : ""}.`); return QS(0, r, e, t); } function Zm(r, e) { let t = Gc(r, e); for (let n = 0; n < t.length; n++) t[n] = 1; return t; } function Gc(r, e) { if (e == null || e === "float32" || e === "complex64") return new Float32Array(r); if (e === "int32") return new Int32Array(r); if (e === "bool") return new Uint8Array(r); throw new Error(`Unknown data type ${e}`); } function IW(r, e) { let t = r.reduce((n, o) => n * o, 1); if (e == null || e === "float32") return iu(r, new Float32Array(t)); if (e === "int32") return iu(r, new Int32Array(t)); if (e === "bool") return iu(r, new Uint8Array(t)); throw new Error(`Unknown data type ${e}`); } function Jm(r) { r.forEach((e) => { E(Number.isInteger(e) && e >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${r}].`); }); } function SW(r, e, t) { if (e === 0) return 0; if (e === 1) return r[0]; let n = r[r.length - 1]; for (let o = 0; o < r.length - 1; ++o) n += t[o] * r[o]; return n; } function NW(r, e, t) { if (e === 0) return []; if (e === 1) return [r]; let n = new Array(e); for (let o = 0; o < n.length - 1; ++o) n[o] = Math.floor(r / t[o]), r -= n[o] * t[o]; return n[n.length - 1] = r, n; } function Qm(r) { return r && r.then && typeof r.then == "function"; } function Un(...r) { U().getBool("IS_TEST") || U().getBool("PROD") || console.warn(...r); } function TW(...r) { U().getBool("IS_TEST") || U().getBool("PROD") || console.log(...r); } var eN = "tfjsflags"; var Eg = class { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = EW, this.populateURLFlags(); } setPlatform(e, t) { this.platform != null && Un(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`), this.platformName = e, this.platform = t; } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, this.urlFlags[e] != null) { let o = this.urlFlags[e]; Un(`Setting feature override from URL ${e}: ${o}.`), this.set(e, o); } } 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 (Qm(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); eN in e && e[eN].split(",").forEach((n) => { let [o, s] = n.split(":"); this.urlFlags[o] = DW(o, s); }); } }; function EW(r) { let e = {}; return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (t, ...n) => (AW(e, n[0], n[1]), n.join("="))), e; } function AW(r, e, t) { r[decodeURIComponent(e)] = decodeURIComponent(t || ""); } function DW(r, e) { if (e = e.toLowerCase(), e === "true" || e === "false") return e === "true"; if (`${+e}` === e) return +e; throw new Error(`Could not parse value flag value ${e} for flag ${r}.`); } function U() { return Xw; } var Xw = null; function tN(r) { Xw = r; } var Yw; function Zw() { if (Yw == null) { let r; if (typeof window != "undefined") r = window; else if (typeof global != "undefined") r = global; else if (typeof process != "undefined") r = process; else if (typeof self != "undefined") r = self; else throw new Error("Could not find a global object"); Yw = r; } return Yw; } function $W() { let r = Zw(); return r._tfGlobals == null && (r._tfGlobals = new Map()), r._tfGlobals; } function ef(r, e) { let t = $W(); if (t.has(r)) return t.get(r); { let n = e(); return t.set(r, n), t.get(r); } } var ti = "Abs"; var Mi = "Acos"; var Li = "Acosh"; var jn = "Add"; var $o = "AddN"; var zi = "All"; var Bi = "Any"; var Ro = "ArgMax"; var ml = "ArgMin"; var Vi = "Asin"; var Gi = "Asinh"; var Wi = "Atan"; var Ui = "Atanh"; var ji = "Atan2"; var Fo = "AvgPool"; var Wc = "AvgPoolGrad"; var fl = "AvgPool3D"; var Uc = "AvgPool3DGrad"; var Oo = "BatchMatMul"; var ri = "BatchToSpaceND"; var jc = "Bincount"; var rN = "BroadcastTo"; var Hc = "BroadcastArgs"; var eo = "Cast"; var Po = "Ceil"; var to = "ClipByValue"; var qc = "Complex"; var dl = "ComplexAbs"; var ni = "Concat"; var Mo = "Conv2D"; var Kc = "Conv2DBackpropFilter"; var Lo = "Conv2DBackpropInput"; var hl = "Conv3D"; var Xc = "Conv3DBackpropFilterV2"; var Yc = "Conv3DBackpropInputV2"; var zo = "Cos"; var Bo = "Cosh"; var Vo = "Cumsum"; var Hi = "CropAndResize"; var Zc = "DenseBincount"; var qi = "DepthToSpace"; var Go = "DepthwiseConv2dNative"; var Jc = "DepthwiseConv2dNativeBackpropFilter"; var Qc = "DepthwiseConv2dNativeBackpropInput"; var ep = "Diag"; var gl = "Dilation2D"; var tf = "Dilation2DBackpropInput"; var rf = "Dilation2DBackpropFilter"; var Wo = "RealDiv"; var tp = "Einsum"; var Uo = "Elu"; var rp = "EluGrad"; var Ki = "Erf"; var Xi = "Equal"; var jo = "Exp"; var oi = "ExpandDims"; var Yi = "Expm1"; var np = "FFT"; var xl = "Fill"; var Zi = "FlipLeftRight"; var Ho = "Floor"; var qo = "FloorDiv"; var Ko = "FusedBatchNorm"; var si = "GatherV2"; var Ji = "GatherNd"; var Qi = "Greater"; var Xo = "GreaterEqual"; var ro = "Identity"; var op = "IFFT"; var sp = "Imag"; var ea = "IsFinite"; var ta = "IsInf"; var ra = "IsNan"; var Yo = "LeakyRelu"; var na = "Less"; var oa = "LessEqual"; var ip = "LinSpace"; var Zo = "Log"; var sa = "Log1p"; var ia = "LogicalAnd"; var au = "LogicalNot"; var lu = "LogicalOr"; var nN = "LogSoftmax"; var yl = "LRN"; var ap = "LRNGrad"; var Jo = "Max"; var Qo = "Maximum"; var es = "MaxPool"; var lp = "MaxPoolGrad"; var bl = "MaxPool3D"; var up = "MaxPool3DGrad"; var cp = "MaxPoolWithArgmax"; var ts = "Mean"; var rs = "Min"; var ns = "Minimum"; var os = "MirrorPad"; var aa = "Mod"; var pp = "Multinomial"; var ss = "Multiply"; var ii = "Neg"; var la = "NotEqual"; var ua = "NonMaxSuppressionV3"; var ca = "NonMaxSuppressionV4"; var pa = "NonMaxSuppressionV5"; var ai = "OnesLike"; var is = "OneHot"; var li = "Pack"; var as = "PadV2"; var hse = "Pool"; var ls = "Pow"; var us = "Prelu"; var ma = "Prod"; var wl = "Range"; var mp = "Real"; var fa = "Reciprocal"; var cs = "Relu"; var ui = "Reshape"; var _l = "ResizeNearestNeighbor"; var fp = "ResizeNearestNeighborGrad"; var ps = "ResizeBilinear"; var dp = "ResizeBilinearGrad"; var ms = "Relu6"; var fs = "Reverse"; var ds = "Round"; var hs = "Rsqrt"; var da = "ScatterNd"; var ci = "Select"; var ha = "Selu"; var pi = "Slice"; var gs = "Sin"; var ga = "Sinh"; var xa = "Sign"; var xs = "Sigmoid"; var ya = "Softplus"; var ys = "Sqrt"; var bs = "Sum"; var mi = "SpaceToBatchND"; var fi = "SplitV"; var ws = "Softmax"; var hp = "SparseFillEmptyRows"; var gp = "SparseReshape"; var xp = "SparseSegmentMean"; var yp = "SparseSegmentSum"; var bp = "SparseToDense"; var _s = "SquaredDifference"; var kl = "Square"; var ba = "StridedSlice"; var wp = "StringNGrams"; var _p = "StringSplit"; var kp = "StringToHashBucketFast"; var ks = "Sub"; var vs = "Tan"; var Cs = "Tanh"; var Hn = "Tile"; var wa = "TopK"; var _a = "Transform"; var Is = "Transpose"; var vp = "Unique"; var di = "Unpack"; var vl = "UnsortedSegmentSum"; var hi = "ZerosLike"; var no = "Step"; var nf = "FromPixels"; var ka = "RotateWithOffset"; var gi = "_FusedMatMul"; var xi = "FusedConv2D"; var yi = "FusedDepthwiseConv2D"; var Cp = ef("kernelRegistry", () => new Map()); var of = ef("gradRegistry", () => new Map()); function sf(r, e) { let t = Qw(r, e); return Cp.get(t); } function Jw(r) { return of.get(r); } function Ag(r) { let e = Cp.entries(), t = []; for (; ; ) { let { done: n, value: o } = e.next(); if (n) break; let [s, a] = o, [i] = s.split("_"); i === r && t.push(a); } return t; } function uu(r) { let { kernelName: e, backendName: t } = r, n = Qw(e, t); Cp.has(n) && Un(`The kernel '${e}' for backend '${t}' is already registered`), Cp.set(n, r); } function oN(r) { let { kernelName: e } = r; of.has(e) && U().getBool("DEBUG") && Un(`Overriding the gradient for '${e}'`), of.set(e, r); } function wse(r, e) { let t = Qw(r, e); if (!Cp.has(t)) throw new Error(`The kernel '${r}' for backend '${e}' is not registered`); Cp.delete(t); } function _se(r) { if (!of.has(r)) throw new Error(`The gradient '${r}' for backend is not registered`); of.delete(r); } function kse(r, e) { Ag(r).forEach((n) => { let o = Object.assign({}, n, { backendName: e }); uu(o); }); } function Qw(r, e) { return `${e}_${r}`; } var b = {}; qe(b, { arraysEqual: () => Qr, assert: () => E, assertNonNegativeIntegerDimensions: () => Jm, assertNonNull: () => Wn, assertShapesMatch: () => Rt, bytesFromStringArray: () => Kw, bytesPerElement: () => Tg, checkConversionForErrors: () => Hw, clamp: () => zc, computeStrides: () => ei, createScalarValue: () => zW, createShuffledIndices: () => _W, decodeString: () => Tp, distSquared: () => xW, encodeString: () => Il, fetch: () => VW, fingerPrint64: () => LW, flatten: () => Ao, getArrayFromDType: () => jw, getTypedArrayFromDType: () => Uw, hasEncodingLoss: () => CW, hexToLong: () => af, indexToLoc: () => NW, inferDtype: () => Bc, inferFromImplicitShape: () => vW, isBoolean: () => ZS, isFunction: () => Qs, isInt: () => it, isNumber: () => JS, isPromise: () => Qm, isScalarShape: () => yW, isString: () => Do, isTypedArray: () => dr, isValidDtype: () => qw, locToIndex: () => SW, makeOnesTypedArray: () => Zm, makeZerosNestedTypedArray: () => IW, makeZerosTypedArray: () => Gc, nearestDivisor: () => Vc, nearestLargerEven: () => dW, now: () => du, parseAxisParam: () => cr, randUniform: () => gW, repeatedTry: () => kW, rightPad: () => su, shuffle: () => YS, shuffleCombo: () => fW, sizeFromShape: () => st, sizeToSquarishShape: () => wW, squeezeShape: () => Ww, sum: () => hW, swap: () => Ng, tanh: () => bW, toNestedArray: () => iu, toTypedArray: () => Np }); var gN = ou(hN()); var mu = gN.default || gN; function af(r) { return mu.fromString(r, true, 16); } var xN = af("c3a5c85c97cb3127"); var fu = af("b492b66fbe98f273"); var en = af("9ae16a3b2f90404f"); function r_(r) { return r.xor(r.shru(47)); } function yN(r, e, t) { let n = r.slice(e, e + t); return mu.fromBytes(Array.from(n), true, true); } function Lt(r, e) { return yN(r, e, 8); } function bN(r, e) { return yN(r, e, 4); } function Ar(r, e) { return e === 0 ? r : r.shru(e).or(r.shl(64 - e)); } function Cl(r, e, t = af("9ddfea08eb382d69")) { let n = r.xor(e).mul(t); n = n.xor(n.shru(47)); let o = e.xor(n).mul(t); return o = o.xor(o.shru(47)), o = o.mul(t), o; } function FW(r, e, t, n, o, s) { o = o.add(r), s = Ar(s.add(o).add(n), 21); let a = o; return o = o.add(e), o = o.add(t), s = s.add(Ar(o, 44)), [o.add(n), s.add(a)]; } function $g(r, e, t, n) { return FW(Lt(r, e), Lt(r, e + 8), Lt(r, e + 16), Lt(r, e + 24), t, n); } function OW(r, e = r.length) { if (e >= 8) { let t = en.add(e * 2), n = Lt(r, 0).add(en), o = Lt(r, e - 8), s = Ar(o, 37).mul(t).add(n), a = Ar(n, 25).add(o).mul(t); return Cl(s, a, t); } if (e >= 4) { let t = en.add(e * 2), n = bN(r, 0); return Cl(n.shl(3).add(e), bN(r, e - 4), t); } if (e > 0) { let t = r[0], n = r[e >> 1], o = r[e - 1], s = t + (n << 8), a = e + (o << 2); return r_(en.mul(s).xor(xN.mul(a))).mul(en); } return en; } function PW(r, e = r.length) { let t = en.add(e * 2), n = Lt(r, 0).mul(fu), o = Lt(r, 8), s = Lt(r, e - 8).mul(t), a = Lt(r, e - 16).mul(en); return Cl(Ar(n.add(o), 43).add(Ar(s, 30)).add(a), n.add(Ar(o.add(en), 18)).add(s), t); } function MW(r, e = r.length) { let t = en.add(e * 2), n = Lt(r, 0).mul(en), o = Lt(r, 8), s = Lt(r, e - 8).mul(t), a = Lt(r, e - 16).mul(en), i = Ar(n.add(o), 43).add(Ar(s, 30)).add(a), l = Cl(i, n.add(Ar(o.add(en), 18)).add(s), t), u = Lt(r, 16).mul(t), c = Lt(r, 24), p = i.add(Lt(r, e - 32)).mul(t), m = l.add(Lt(r, e - 24)).mul(t); return Cl(Ar(u.add(c), 43).add(Ar(p, 30)).add(m), u.add(Ar(c.add(n), 18)).add(p), t); } function LW(r, e = r.length) { let t = mu.fromNumber(81, true); if (e <= 32) return e <= 16 ? OW(r, e) : PW(r, e); if (e <= 64) return MW(r, e); let n = t, o = t.mul(fu).add(113), s = r_(o.mul(en).add(113)).mul(en), a = [mu.UZERO, mu.UZERO], i = [mu.UZERO, mu.UZERO]; n = n.mul(en).add(Lt(r, 0)); let l = 0, u = (e - 1 >> 6) * 64, c = u + (e - 1 & 63) - 63; do n = Ar(n.add(o).add(a[0]).add(Lt(r, l + 8)), 37).mul(fu), o = Ar(o.add(a[1]).add(Lt(r, l + 48)), 42).mul(fu), n = n.xor(i[1]), o = o.add(a[0]).add(Lt(r, l + 40)), s = Ar(s.add(i[0]), 33).mul(fu), a = $g(r, l, a[1].mul(fu), n.add(i[0])), i = $g(r, l + 32, s.add(i[1]), o.add(Lt(r, l + 16))), [s, n] = [n, s], l += 64; while (l !== u); let p = fu.add(s.and(255).shl(1)); return l = c, i[0] = i[0].add(e - 1 & 63), a[0] = a[0].add(i[0]), i[0] = i[0].add(a[0]), n = Ar(n.add(o).add(a[0]).add(Lt(r, l + 8)), 37).mul(p), o = Ar(o.add(a[1]).add(Lt(r, l + 48)), 42).mul(p), n = n.xor(i[1].mul(9)), o = o.add(a[0].mul(9).add(Lt(r, l + 40))), s = Ar(s.add(i[0]), 33).mul(p), a = $g(r, l, a[1].mul(p), n.add(i[0])), i = $g(r, l + 32, s.add(i[1]), o.add(Lt(r, l + 16))), [s, n] = [n, s], Cl(Cl(a[0], i[0], p).add(r_(o).mul(xN)).add(s), Cl(a[1], i[1], p).add(n), p); } function zW(r, e) { return e === "string" ? Il(r) : Np([r], e); } function BW(r, e) { return r instanceof Float32Array && e === "float32" || r instanceof Int32Array && e === "int32" || r instanceof Uint8Array && e === "bool"; } function Np(r, e) { if (e === "string") throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(r) && (r = Ao(r)), U().getBool("DEBUG") && Hw(r, e), BW(r, e)) return r; if (e == null || e === "float32" || e === "complex64") return new Float32Array(r); if (e === "int32") return new Int32Array(r); if (e === "bool") { let t = new Uint8Array(r.length); for (let n = 0; n < t.length; ++n) Math.round(r[n]) !== 0 && (t[n] = 1); return t; } else throw new Error(`Unknown data type ${e}`); } function du() { return U().platform.now(); } function VW(r, e) { return U().platform.fetch(r, e); } function Il(r, e = "utf-8") { return e = e || "utf-8", U().platform.encode(r, e); } function Tp(r, e = "utf-8") { return e = e || "utf-8", U().platform.decode(r, e); } var n_ = class { constructor(e, t) { this.backendTimer = e, this.logger = t, t == null && (this.logger = new wN()); } profileKernel(e, t, n) { let o, s = () => { o = n(); }, a, i = du(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(s); else { s(); for (let u of o) u.dataSync(); a = Promise.resolve({ kernelMs: du() - i }); } if (U().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < o.length; u++) { let c = o[u]; c.data().then((p) => { GW(p, c.dtype, e); }); } return { kernelName: e, outputs: o, 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: o, inputs: s, extraInfo: a } = e; n.forEach((i) => { Promise.all([i.data(), o, a]).then((l) => { this.logger.logKernelProfile(t, i, l[0], l[1], s, l[2]); }); }); } }; function GW(r, e, t) { if (e !== "float32") return false; for (let n = 0; n < r.length; n++) { let o = r[n]; if (isNaN(o) || !isFinite(o)) return console.warn(`Found ${o} in the result of '${t}'`), true; } return false; } var wN = class { logKernelProfile(e, t, n, o, s, a) { let i = typeof o == "number" ? su(`${o}ms`, 9) : o.error, l = su(e, 25), u = t.rank, c = t.size, p = su(t.shape.toString(), 14), m = ""; for (let f in s) { let d = s[f]; if (d != null) { let h = d.shape || t.shape, g = h.length; m += `${f}: ${g}D ${g > 0 ? h : ""} `; } } console.log(`%c${l} %c${i} %c${u}D ${p} %c${c} %c${m} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; function _N(r, e, t) { let n = {}, o = {}; for (let l = 0; l < e.length; l++) n[e[l].id] = true; for (let l = 0; l < r.length; l++) { let u = r[l], c = u.inputs; for (let p in c) { let m = c[p], f = false; for (let d = 0; d < e.length; d++) if (n[m.id]) { u.outputs.forEach((h) => n[h.id] = true), f = true, o[u.id] = true; break; } if (f) break; } } let s = {}; s[t.id] = true; let a = {}; for (let l = r.length - 1; l >= 0; l--) { let u = r[l], c = u.inputs; for (let p = 0; p < u.outputs.length; p++) if (s[u.outputs[p].id]) { for (let m in c) s[c[m].id] = true, a[u.id] = true; break; } } let i = []; for (let l = 0; l < r.length; l++) { let u = r[l]; if (o[u.id] && a[u.id]) { let c = {}; for (let m in u.inputs) { let f = u.inputs[m]; n[f.id] && (c[m] = f); } let p = Object.assign({}, u); p.inputs = c, p.outputs = u.outputs, i.push(p); } } return i; } function kN(r, e, t, n) { for (let o = e.length - 1; o >= 0; o--) { let s = e[o], a = []; if (s.outputs.forEach((l) => { let u = r[l.id]; u != null ? a.push(u) : a.push(null); }), s.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`); let i = s.gradient(a); for (let l in s.inputs) { if (!(l in i)) throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(i)}.`); let u = t(() => i[l]()); if (u.dtype !== "float32") throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`); let c = s.inputs[l]; if (!Qr(u.shape, c.shape)) throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`); if (r[c.id] == null) r[c.id] = u; else { let p = r[c.id]; r[c.id] = n(p, u), p.dispose(); } } } } var vN = 20; var lf = 3; var o_ = 7; function CN(r, e, t, n) { let o = ei(e), s = WW(r, e, t, o), a = e.length, i = Rg(r, e, t, o, s), l = ["Tensor"]; return n && (l.push(` dtype: ${t}`), l.push(` rank: ${a}`), l.push(` shape: [${e}]`), l.push(" values:")), l.push(i.map((u) => " " + u).join(` `)), l.join(` `); } function WW(r, e, t, n) { let o = st(e), s = n[n.length - 1], a = new Array(s).fill(0), i = e.length, l = t === "complex64" ? cf(r) : r; if (i > 1) for (let u = 0; u < o / s; u++) { let c = u * s; for (let p = 0; p < s; p++) a[p] = Math.max(a[p], uf(l[c + p], 0, t).length); } return a; } function uf(r, e, t) { let n; return Array.isArray(r) ? n = `${parseFloat(r[0].toFixed(o_))} + ${parseFloat(r[1].toFixed(o_))}j` : Do(r) ? n = `'${r}'` : t === "bool" ? n = IN(r) : n = parseFloat(r.toFixed(o_)).toString(), su(n, e); } function IN(r) { return r === 0 ? "false" : "true"; } function Rg(r, e, t, n, o, s = true) { let a = t === "complex64" ? 2 : 1, i = e[0], l = e.length; if (l === 0) { if (t === "complex64") { let h = cf(r); return [uf(h[0], 0, t)]; } return t === "bool" ? [IN(r[0])] : [r[0].toString()]; } if (l === 1) { if (i > vN) { let g = lf * a, x = Array.from(r.slice(0, g)), y = Array.from(r.slice((i - lf) * a, i * a)); return t === "complex64" && (x = cf(x), y = cf(y)), ["[" + x.map((w, _) => uf(w, o[_], t)).join(", ") + ", ..., " + y.map((w, _) => uf(w, o[i - lf + _], t)).join(", ") + "]"]; } let h = t === "complex64" ? cf(r) : Array.from(r); return ["[" + h.map((g, x) => uf(g, o[x], t)).join(", ") + "]"]; } let u = e.slice(1), c = n.slice(1), p = n[0] * a, m = []; if (i > vN) { for (let h = 0; h < lf; h++) { let g = h * p, x = g + p; m.push(...Rg(r.slice(g, x), u, t, c, o, false)); } m.push("..."); for (let h = i - lf; h < i; h++) { let g = h * p, x = g + p; m.push(...Rg(r.slice(g, x), u, t, c, o, h === i - 1)); } } else for (let h = 0; h < i; h++) { let g = h * p, x = g + p; m.push(...Rg(r.slice(g, x), u, t, c, o, h === i - 1)); } let f = l === 2 ? "," : ""; m[0] = "[" + m[0] + f; for (let h = 1; h < m.length - 1; h++) m[h] = " " + m[h] + f; let d = `, `; for (let h = 2; h < l; h++) d += ` `; return m[m.length - 1] = " " + m[m.length - 1] + "]" + (s ? "" : d), m; } function cf(r) { let e = []; for (let t = 0; t < r.length; t += 2) e.push([r[t], r[t + 1]]); return e; } var mt = class { constructor(e, t, n) { if (this.dtype = t, this.shape = e.slice(), this.size = st(e), n != null) { let o = n.length; E(o === this.size, () => `Length of values '${o}' 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 || jw(t, this.size), this.strides = ei(e); } set(e, ...t) { t.length === 0 && (t = [0]), E(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 o of e) { if (o < 0 || o >= this.shape[t]) { let s = `Requested out of range element at ${e}. Buffer shape=${this.shape}`; throw new Error(s); } t++; } let n = e[e.length - 1]; for (let o = 0; o < e.length - 1; ++o) n += this.strides[o] * e[o]; 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 bi().makeTensor(this.values, this.shape, this.dtype); } }; var bi = null; var Ep = null; var UW = null; function SN(r) { bi = r; } function NN(r) { Ep = r; } function TN(r) { UW = r; } var Le = class { constructor(e, t, n, o) { this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t || "float32", this.size = st(e), this.strides = ei(e), this.dataId = n, this.id = o, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; } get rank() { return this.shape.length; } async buffer() { let e = await this.data(); return Ep.buffer(this.shape, this.dtype, e); } bufferSync() { return Ep.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); return iu(this.shape, e, this.dtype === "complex64"); } arraySync() { return iu(this.shape, this.dataSync(), this.dtype === "complex64"); } async data() { this.throwIfDisposed(); let e = bi().read(this.dataId); if (this.dtype === "string") { let t = await e; try { return t.map((n) => Tp(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; } dataSync() { this.throwIfDisposed(); let e = bi().readSync(this.dataId); if (this.dtype === "string") try { return e.map((t) => Tp(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 bi().read(this.dataId); return this.dtype === "string" ? e : new Uint8Array(e.buffer); } dispose() { this.isDisposed || (bi().disposeTensor(this), this.isDisposedInternal = true); } get isDisposed() { return this.isDisposedInternal; } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed."); } print(e = false) { return Ep.print(this, e); } clone() { return this.throwIfDisposed(), Ep.clone(this); } toString(e = false) { let t = this.dataSync(); return CN(t, this.shape, this.dtype, e); } cast(e) { return this.throwIfDisposed(), Ep.cast(this, e); } variable(e = true, t, n) { return this.throwIfDisposed(), bi().makeVariable(this, e, t, n); } }; Object.defineProperty(Le, Symbol.hasInstance, { value: (r) => !!r && r.data != null && r.dataSync != null && r.throwIfDisposed != null }); function M() { return ef("Tensor", () => Le); } M(); var Sl = class extends Le { constructor(e, t, n, o) { super(e.shape, e.dtype, e.dataId, o); 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 (!Qr(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); bi().disposeTensor(this), this.dataId = e.dataId, bi().incRef(this, null); } dispose() { bi().disposeVariable(this), this.isDisposedInternal = true; } }; Object.defineProperty(Sl, Symbol.hasInstance, { value: (r) => r instanceof Le && r.assign != null && r.assign instanceof Function }); var ao = {}; qe(ao, { assertTypesMatch: () => c_, getTensorsInContainer: () => pf, isTensorInList: () => HW, makeTypesMatch: () => je }); var s_; (function(r) { r.R0 = "R0", r.R1 = "R1", r.R2 = "R2", r.R3 = "R3", r.R4 = "R4", r.R5 = "R5", r.R6 = "R6"; })(s_ || (s_ = {})); var i_; (function(r) { r.float32 = "float32", r.int32 = "int32", r.bool = "int32", r.complex64 = "complex64"; })(i_ || (i_ = {})); var a_; (function(r) { r.float32 = "float32", r.int32 = "int32", r.bool = "bool", r.complex64 = "complex64"; })(a_ || (a_ = {})); var l_; (function(r) { r.float32 = "float32", r.int32 = "float32", r.bool = "float32", r.complex64 = "complex64"; })(l_ || (l_ = {})); var u_; (function(r) { r.float32 = "complex64", r.int32 = "complex64", r.bool = "complex64", r.complex64 = "complex64"; })(u_ || (u_ = {})); var jW = { float32: l_, int32: i_, bool: a_, complex64: u_ }; function hr(r, e) { if (r === "string" || e === "string") { if (r === "string" && e === "string") return "string"; throw new Error(`Can not upcast ${r} with ${e}`); } return jW[r][e]; } function hu(r) { return hr(r, "int32"); } function je(r, e) { if (r.dtype === e.dtype) return [r, e]; let t = hr(r.dtype, e.dtype); return [r.cast(t), e.cast(t)]; } function c_(r, e) { E(r.dtype === e.dtype, () => `The dtypes of the first(${r.dtype}) and second(${e.dtype}) input must match`); } function HW(r, e) { return e.some((t) => t.id === r.id); } function pf(r) { let e = [], t = new Set(); return EN(r, e, t), e; } function EN(r, e, t) { if (r == null) return; if (r instanceof Le) { e.push(r); return; } if (!qW(r)) return; let n = r; for (let o in n) { let s = n[o]; t.has(s) || (t.add(s), EN(s, e, t)); } } function qW(r) { return Array.isArray(r) || typeof r == "object"; } function p_(r) { return r.kernelName != null; } var m_ = class { constructor() { this.registeredVariables = {}, this.nextTapeNodeId = 0, this.numBytes = 0, this.numTensors = 0, this.numStringTensors = 0, this.numDataBuffers = 0, this.gradientDepth = 0, this.kernelDepth = 0, this.scopeStack = [], this.numDataMovesStack = [], this.nextScopeId = 0, this.tensorInfo = new WeakMap(), this.profiling = 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 gu = class { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new m_(); } 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 ? (Un(`${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 n_(this.backendInstance), true; } setupRegisteredKernels() { Ag(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { Ag(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 Js) && typeof n.then == "function") { let o = ++this.pendingBackendInitId, s = n.then((a) => o < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (o < this.pendingBackendInitId || (this.pendingBackendInit = null, Un(`Initialization of backend ${e} failed`), Un(a.stack || a.message)), false)); return this.pendingBackendInit = s, { success: s, asyncInit: true }; } else return this.registry[e] = n, { success: true, asyncInit: false }; } catch (n) { return Un(`Initialization of backend ${e} failed`), Un(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: o, asyncInit: s } = this.initializeBackend(n); if (s || o) return { name: n, asyncInit: s }; } throw new Error("Could not initialize any backends, all backend initializations failed."); } moveData(e, t) { let n = this.state.tensorInfo.get(t), o = n.backend, s = this.readSync(t), a = o.refCount(t); o.disposeData(t, true), n.backend = e, e.move(t, s, 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 o; return this.scopedRun(() => this.startScope(n), () => this.endScope(o), () => (o = t(), o instanceof Promise && console.error("Cannot return a Promise inside of tidy."), o)); } scopedRun(e, t, n) { e(); try { let o = n(); return t(), o; } catch (o) { throw t(), o; } } nextTensorId() { return gu.nextTensorId++; } nextVariableId() { return gu.nextVariableId++; } clone(e) { let t = T.runKernel(ro, { x: e }), n = { x: e }, o = (a) => ({ x: () => { let i = "float32", l = { x: a }, u = { dtype: i }; return T.runKernel(eo, l, u); } }), s = []; return this.addTapeNode(this.state.activeScope.name, n, [t], o, s, {}), t; } runKernel(e, t, n) { if (this.backendName == null && this.backend, !(sf(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 o = this.backend.numDataIds(), s = 0; n.forEach((l) => { s += l.dtype === "complex64" ? 3 : 1; }); let a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = o - t - s - 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 = [], o = this.isTapeOn(), s = this.state.numBytes, a = this.state.numTensors; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0); let i; this.backendName == null && this.backend; let l, u = p_(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; if (p_(e)) { let { kernelName: d, inputs: h, attrs: g } = e; this.backendName == null && this.backend; let x = sf(d, this.backendName); E(x != null, () => `Cannot find registered kernel '${d}' for backend '${this.backendName}'`), i = () => { let y = this.backend.numDataIds(); l = x.kernelFunc({ inputs: h, attrs: g, backend: this.backend }); let w = Array.isArray(l) ? l : [l]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(d, y, w); let _ = w.map((C) => { if (C.rank != null) return C; let { dataId: A, shape: D, dtype: R } = C; return this.makeTensorFromDataId(A, D, R); }); if (o) { let C = this.getTensorsForGradient(d, h, _); n = this.saveTensorsForBackwardMode(C); } return _; }; } else { let { forwardFunc: d } = e, h = (g) => { !o || (n = g.map((x) => this.keep(this.clone(x)))); }; i = () => { let g = this.backend.numDataIds(); l = this.tidy(() => d(this.backend, h)); let x = Array.isArray(l) ? l : [l]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, g, x), x; }; } let { inputs: c, attrs: p } = e, m = p_(e) ? null : e.backwardsFunc, f; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = i() : (f = this.profiler.profileKernel(u, c, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(f), t = f.outputs); }), o && this.addTapeNode(u, c, t, m, n, p), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - s, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(c).map((d) => c[d] != null ? c[d].shape : null), outputShapes: t.map((d) => d.shape), kernelTimeMs: f.timeMs, extraInfo: f.extraInfo }), Array.isArray(l) ? t : t[0]; } saveTensorsForBackwardMode(e) { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { let o = Jw(e); if (o != null) { let s = o.inputsToSave || [], a = o.outputsToSave || [], i; o.saveAllInputs ? (E(Array.isArray(t), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t).map((u) => t[u])) : i = s.map((u) => t[u]); let l = n.filter((u, c) => a[c]); return i.concat(l); } return []; } makeTensor(e, t, n, o) { if (e == null) throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", o = o || this.backend; let s = e; n === "string" && Do(e[0]) && (s = e.map((l) => Il(l))); let a = o.write(s, t, n), i = new Le(t, n, a, this.nextTensorId()); if (this.trackTensor(i, o), n === "string") { let l = this.state.tensorInfo.get(a), u = Kw(s); this.state.numBytes += u - l.bytes, l.bytes = u; } return i; } makeTensorFromDataId(e, t, n, o) { n = n || "float32"; let s = new Le(t, n, e, this.nextTensorId()); return this.trackTensor(s, o), s; } makeVariable(e, t = true, n, o) { n = n || this.nextVariableId().toString(), o != null && o !== e.dtype && (e = e.cast(o)); let s = new Sl(e, t, n, this.nextTensorId()); if (this.state.registeredVariables[s.name] != null) throw new Error(`Variable with name ${s.name} was already registered`); return this.state.registeredVariables[s.name] = s, this.incRef(s, this.backend), s; } trackTensor(e, t) { this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++; let n = 0; e.dtype !== "complex64" && e.dtype !== "string" && (n = e.size * Tg(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 Sl || 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 * Tg(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((o) => o.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - t, this.state.activeProfile.newTensors = this.state.numTensors - n; for (let o of this.state.activeProfile.kernels) o.kernelTimeMs = await o.kernelTimeMs, o.extraInfo = await o.extraInfo; return this.state.activeProfile; } isTapeOn() { return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; } addTapeNode(e, t, n, o, s, a) { let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: s }, l = Jw(e); l != null && (o = l.gradFunc), o != null && (i.gradient = (u) => (u = u.map((c, p) => { if (c == null) { let m = n[p], f = Gc(m.size, m.dtype); return this.makeTensor(f, m.shape, m.dtype); } return c; }), o(u.length > 1 ? u : u[0], s, 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 = pf(e), n = new Set(t.map((s) => s.id)); for (let s = 0; s < this.state.activeScope.track.length; s++) { let a = this.state.activeScope.track[s]; !a.kept && !n.has(a.id) && a.dispose(); } let o = this.state.scopeStack.pop(); this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t.forEach((s) => { !s.kept && s.scopeId === o.id && this.track(s); }); } gradients(e, t, n, o = false) { if (E(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 s = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", e)); E(s instanceof Le, () => "The result y returned by f() must be a tensor."); let a = _N(this.state.activeTape, t, s); if (!o && 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[s.id] = n == null ? KW(s.shape) : n, kN(i, a, (u) => this.tidy(u), XW); let l = t.map((u) => i[u.id]); return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((u) => { for (let c of u.saved) c.dispose(); }), this.state.activeTape = null), { value: s, grads: l }; }); } customGrad(e) { return E(Qs(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { E(t.every((i) => i instanceof Le), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors"); let n, o = {}; t.forEach((i, l) => { o[l] = i; }); let s = (i, l) => (n = e(...t, l), E(n.value instanceof Le, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), E(Qs(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (i, l) => { let u = n.gradFunc(i, l), c = Array.isArray(u) ? u : [u]; E(c.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(...)."), E(c.every((m) => m instanceof Le), () => "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 p = {}; return c.forEach((m, f) => { p[f] = () => m; }), p; }; return this.runKernelFunc({ forwardFunc: s, backwardsFunc: a, inputs: o }); }; } readSync(e) { return this.state.tensorInfo.get(e).backend.readSync(e); } read(e) { return this.state.tensorInfo.get(e).backend.read(e); } async time(e) { let t = du(), n = await this.backend.time(e); return n.wallMs = du() - 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 m_(); 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; } }; gu.nextTensorId = 0; gu.nextVariableId = 0; function KW(r) { let e = Zm(st(r), "float32"); return T.makeTensor(e, r, "float32"); } function f_() { let r = Zw(); if (r._tfengine == null) { let e = new Eg(r); r._tfengine = new gu(e); } return tN(r._tfengine.ENV), SN(() => r._tfengine), r._tfengine; } var T = f_(); function XW(r, e) { let t = { a: r, b: e }; return T.runKernel(jn, t); } var xu = {}; qe(xu, { isBrowser: () => h_, isMobile: () => JW, mockIsMobile: () => ZW }); function YW() { return typeof navigator != "undefined" && navigator != null; } var d_; function ZW(r) { d_ = r; } function JW(r) { if (d_ !== void 0) return d_; if (r || YW()) { if (r || (r = navigator), r.product === "ReactNative") return true; let e = r.userAgent || r.vendor || (typeof window != "undefined" ? window.opera : ""); if (!e) { let t = r; return t.userAgentData && t.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(e) || /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(e.substr(0, 4)); } return false; } function h_() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } var Ns = U(); Ns.registerFlag("DEBUG", () => false, (r) => { r && 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."); }); Ns.registerFlag("IS_BROWSER", () => h_()); Ns.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); Ns.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); Ns.registerFlag("PROD", () => false); Ns.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => Ns.getBool("DEBUG")); Ns.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => true); Ns.registerFlag("IS_TEST", () => false); Ns.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => true); Ns.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); function Mr(r, e) { let t = r; if (dr(r)) return e === "string" ? [] : [r.length]; if (!Array.isArray(r)) return []; let n = []; for (; Array.isArray(t) || dr(t) && e !== "string"; ) n.push(t.length), t = t[0]; return Array.isArray(r) && U().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && AN(r, n, []), n; } function AN(r, e, t) { if (t = t || [], !Array.isArray(r) && !dr(r)) { E(e.length === 0, () => `Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`); return; } E(e.length > 0, () => `Element arr[${t.join("][")}] should be a primitive, but is an array of ${r.length} elements`), E(r.length === e[0], () => `Element arr[${t.join("][")}] should have ${e[0]} elements, but has ${r.length} elements`); let n = e.slice(1); for (let o = 0; o < r.length; ++o) AN(r[o], n, t.concat(o)); } function DN(r, e, t, n) { if (r !== "string_or_numeric") { if (r == null) throw new Error("Expected dtype cannot be null."); if (r !== "numeric" && r !== e || r === "numeric" && e === "string") throw new Error(`Argument '${t}' passed to '${n}' must be ${r} tensor, but got ${e} tensor`); } } function k(r, e, t, n = "numeric") { if (r instanceof Le) return DN(n, r.dtype, e, t), r; let o = Bc(r); if (o !== "string" && ["bool", "int32", "float32"].indexOf(n) >= 0 && (o = n), DN(n, o, e, t), r == null || !dr(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "string") { let l = r == null ? "null" : r.constructor.name; throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${l}'`); } let s = Mr(r, o); !dr(r) && !Array.isArray(r) && (r = [r]); let i = o !== "string" ? Np(r, o) : Ao(r, [], true); return T.makeTensor(i, s, o); } function va(r, e, t, n = "numeric") { if (!Array.isArray(r)) throw new Error(`Argument ${e} passed to ${t} must be a \`Tensor[]\` or \`TensorLike[]\``); return r.map((s, a) => k(s, `${e}[${a}]`, t, n)); } var $N = "__op"; function N(r) { let e = Object.keys(r); if (e.length !== 1) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`); let t = e[0], n = r[t]; t.endsWith("_") && (t = t.substring(0, t.length - 1)), t = t + $N; let o = (...s) => { T.startScope(t); try { let a = n(...s); return Qm(a) && console.error("Cannot return a Promise inside of tidy."), T.endScope(a), a; } catch (a) { throw T.endScope(null), a; } }; return Object.defineProperty(o, "name", { value: t, configurable: true }), o; } function QW(r, e) { let t = k(r, "real", "complex"), n = k(e, "imag", "complex"); Rt(t.shape, n.shape, `real and imag shapes, ${t.shape} and ${n.shape}, must match in call to tf.complex().`); let o = { real: t, imag: n }; return T.runKernel(qc, o); } var Pn = N({ complex_: QW }); function tn(r, e, t, n) { if (n == null && (n = Bc(r)), n === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if (!dr(r) && !Array.isArray(r) && typeof r != "number" && typeof r != "boolean" && typeof r != "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 (e != null) { Jm(e); let o = st(e), s = st(t); E(o === s, () => `Based on the provided shape, [${e}], the tensor should have ${o} values but has ${s}`); for (let a = 0; a < t.length; ++a) { let i = t[a], l = a === t.length - 1 ? i !== st(e.slice(a)) : true; E(t[a] === e[a] || !l, () => `Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `); } } return !dr(r) && !Array.isArray(r) && (r = [r]), e = e || t, r = n !== "string" ? Np(r, n) : Ao(r, [], true), T.makeTensor(r, e, n); } function Dr(r, e, t) { let n = Mr(r, t); return tn(r, e, n, t); } var mf = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; var Fg = 4; async function RN(r, e) { let t = [], n = [], o = Array.isArray(r) ? r.map((a) => a.name) : Object.keys(r); for (let a = 0; a < o.length; ++a) { let i = o[a], l = Array.isArray(r) ? r[a].tensor : r[i]; if (l.dtype !== "float32" && l.dtype !== "int32" && l.dtype !== "bool" && l.dtype !== "string" && l.dtype !== "complex64") throw new Error(`Unsupported dtype in weight '${i}': ${l.dtype}`); let u = { name: i, shape: l.shape, dtype: l.dtype }; if (l.dtype === "string") { let c = new Promise(async (p) => { let m = await l.bytes(), f = m.reduce((g, x) => g + x.length, 0) + Fg * m.length, d = new Uint8Array(f), h = 0; for (let g = 0; g < m.length; g++) { let x = m[g], y = new Uint8Array(new Uint32Array([x.length]).buffer); d.set(y, h), h += Fg, d.set(x, h), h += x.length; } p(d); }); n.push(c); } else n.push(l.data()); e != null && (u.group = e), t.push(u); } let s = await Promise.all(n); return { data: e4(s), specs: t }; } function Og(r, e) { let t = {}, n, o = 0; for (let s of e) { let a = s.name, i = s.dtype, l = s.shape, u = st(l), c; if ("quantization" in s) { let p = s.quantization; if (p.dtype === "uint8" || p.dtype === "uint16") { if (!("min" in p && "scale" in p)) throw new Error(`Weight ${s.name} with quantization ${p.dtype} doesn't have corresponding metadata min and scale.`); } else if (p.dtype === "float16") { if (i !== "float32") throw new Error(`Weight ${s.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${i}.`); } else throw new Error(`Weight ${s.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); let m = mf[p.dtype], f = r.slice(o, o + u * m), d = p.dtype === "uint8" ? new Uint8Array(f) : new Uint16Array(f); if (i === "float32") if (p.dtype === "uint8" || p.dtype === "uint16") { c = new Float32Array(d.length); for (let h = 0; h < d.length; h++) { let g = d[h]; c[h] = g * p.scale + p.min; } } else if (p.dtype === "float16") n === void 0 && (n = o4()), c = n(d); else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`); else if (i === "int32") { if (p.dtype !== "uint8" && p.dtype !== "uint16") throw new Error(`Unsupported quantization type ${p.dtype} for weight type int32.`); c = new Int32Array(d.length); for (let h = 0; h < d.length; h++) { let g = d[h]; c[h] = Math.round(g * p.scale + p.min); } } else throw new Error(`Unsupported dtype in weight '${a}': ${i}`); o += u * m; } else if (i === "string") { let p = st(s.shape); c = []; for (let m = 0; m < p; m++) { let f = new Uint32Array(r.slice(o, o + Fg))[0]; o += Fg; let d = new Uint8Array(r.slice(o, o + f)); c.push(d), o += f; } } else { let p = mf[i], m = r.slice(o, o + u * p); if (i === "float32") c = new Float32Array(m); else if (i === "int32") c = new Int32Array(m); else if (i === "bool") c = new Uint8Array(m); else if (i === "complex64") { c = new Float32Array(m); let f = new Float32Array(c.length / 2), d = new Float32Array(c.length / 2); for (let x = 0; x < f.length; x++) f[x] = c[x * 2], d[x] = c[x * 2 + 1]; let h = Dr(f, l, "float32"), g = Dr(d, l, "float32"); t[a] = Pn(h, g), h.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${a}': ${i}`); o += u * p; } i !== "complex64" && (t[a] = Dr(c, l, i)); } return t; } function e4(r) { if (r === null) throw new Error(`Invalid input value: ${JSON.stringify(r)}`); let e = 0, t = []; r.forEach((s) => { if (e += s.byteLength, t.push(s.byteLength === s.buffer.byteLength ? s : new s.constructor(s)), !(s instanceof Float32Array || s instanceof Int32Array || s instanceof Uint8Array)) throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`); }); let n = new Uint8Array(e), o = 0; return t.forEach((s) => { n.set(new Uint8Array(s.buffer), o), o += s.byteLength; }), n.buffer; } var g_ = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); function FN(r) { return g_ ? Buffer.byteLength(r) : new Blob([r]).size; } function ON(r) { if (g_) return Buffer.from(r).toString("base64"); let e = new Uint8Array(r), t = ""; for (let n = 0, o = e.length; n < o; n++) t += String.fromCharCode(e[n]); return btoa(t); } function PN(r) { if (g_) { let n = Buffer.from(r, "base64"); return n.buffer.slice(n.byteOffset, n.byteOffset + n.byteLength); } let e = atob(r), t = new Uint8Array(e.length); for (let n = 0; n < e.length; ++n) t.set([e.charCodeAt(n)], n); return t.buffer; } function Ap(r) { if (r.length === 1) return r[0]; let e = 0; r.forEach((o) => { e += o.byteLength; }); let t = new Uint8Array(e), n = 0; return r.forEach((o) => { t.set(new Uint8Array(o), n), n += o.byteLength; }), t.buffer; } function x_(r) { let e = "/"; for (r = r.trim(); r.endsWith(e); ) r = r.slice(0, r.length - 1); let t = r.split(e); return t[t.length - 1]; } function Pg(r, e) { let t = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy, weightsManifest: e }; return r.signature != null && (t.signature = r.signature), r.userDefinedMetadata != null && (t.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (t.modelInitializer = r.modelInitializer), r.trainingConfig != null && (t.trainingConfig = r.trainingConfig), t; } async function Dp(r, e) { let t = { modelTopology: r.modelTopology, format: r.format, generatedBy: r.generatedBy, convertedBy: r.convertedBy }; if (r.trainingConfig != null && (t.trainingConfig = r.trainingConfig), r.weightsManifest != null) { let [n, o] = await e(r.weightsManifest); t.weightSpecs = n, t.weightData = o; } return r.signature != null && (t.signature = r.signature), r.userDefinedMetadata != null && (t.userDefinedMetadata = r.userDefinedMetadata), r.modelInitializer != null && (t.modelInitializer = r.modelInitializer), t; } function wi(r) { if (r.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer."); return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: r.modelTopology == null ? 0 : FN(JSON.stringify(r.modelTopology)), weightSpecsBytes: r.weightSpecs == null ? 0 : FN(JSON.stringify(r.weightSpecs)), weightDataBytes: r.weightData == null ? 0 : r.weightData.byteLength }; } function t4() { let r = (t) => { let n = t << 13, o = 0; for (; (n & 8388608) == 0; ) o -= 8388608, n <<= 1; return n &= ~8388608, o += 947912704, n | o; }, e = new Uint32Array(2048); e[0] = 0; for (let t = 1; t < 1024; t++) e[t] = r(t); for (let t = 1024; t < 2048; t++) e[t] = 939524096 + (t - 1024 << 13); return e; } function r4() { let r = new Uint32Array(64); r[0] = 0, r[31] = 1199570944, r[32] = 2147483648, r[63] = 3347054592; for (let e = 1; e < 31; e++) r[e] = e << 23; for (let e = 33; e < 63; e++) r[e] = 2147483648 + (e - 32 << 23); return r; } function n4() { let r = new Uint32Array(64); for (let e = 0; e < 64; e++) r[e] = 1024; return r[0] = r[32] = 0, r; } function o4() { let r = t4(), e = r4(), t = n4(); return (n) => { let o = new ArrayBuffer(4 * n.length), s = new Uint32Array(o); for (let a = 0; a < n.length; a++) { let i = n[a], l = r[t[i >> 10] + (i & 1023)] + e[i >> 10]; s[a] = l; } return new Float32Array(o); }; } var Et = class { constructor() { this.saveRouters = [], this.loadRouters = []; } static getInstance() { return Et.instance == null && (Et.instance = new Et()), Et.instance; } static registerSaveRouter(e) { Et.getInstance().saveRouters.push(e); } static registerLoadRouter(e) { Et.getInstance().loadRouters.push(e); } static getSaveHandlers(e) { return Et.getHandlers(e, "save"); } static getLoadHandlers(e, t) { return Et.getHandlers(e, "load", t); } static getHandlers(e, t, n) { let o = []; return (t === "load" ? Et.getInstance().loadRouters : Et.getInstance().saveRouters).forEach((a) => { let i = a(e, n); i !== null && o.push(i); }), o; } }; var MN = (r) => Et.registerSaveRouter(r); var LN = (r) => Et.registerLoadRouter(r); var zN = (r) => Et.getSaveHandlers(r); var BN = (r, e) => Et.getLoadHandlers(r, e); var y_ = "tensorflowjs"; var b_ = 1; var yu = "models_store"; var Nl = "model_info_store"; function VN() { if (!U().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); let r = typeof window == "undefined" ? self : window, e = r.indexedDB || r.mozIndexedDB || r.webkitIndexedDB || r.msIndexedDB || r.shimIndexedDB; if (e == null) throw new Error("The current browser does not appear to support IndexedDB."); return e; } function w_(r) { let e = r.result; e.createObjectStore(yu, { keyPath: "modelPath" }), e.createObjectStore(Nl, { keyPath: "modelPath" }); } var Ca = class { constructor(e) { if (this.indexedDB = VN(), 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, o) => { let s = this.indexedDB.open(y_, b_); s.onupgradeneeded = () => w_(s), s.onsuccess = () => { let a = s.result; if (t == null) { let i = a.transaction(yu, "readonly"), u = i.objectStore(yu).get(this.modelPath); u.onsuccess = () => { if (u.result == null) return a.close(), o(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`)); n(u.result.modelArtifacts); }, u.onerror = (c) => (a.close(), o(u.error)), i.oncomplete = () => a.close(); } else { let i = wi(t), l = a.transaction(Nl, "readwrite"), u = l.objectStore(Nl), c = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), p; c.onsuccess = () => { p = a.transaction(yu, "readwrite"); let f = p.objectStore(yu).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); f.onsuccess = () => n({ modelArtifactsInfo: i }), f.onerror = (d) => { u = l.objectStore(Nl); let h = u.delete(this.modelPath); h.onsuccess = () => (a.close(), o(f.error)), h.onerror = (g) => (a.close(), o(f.error)); }; }, c.onerror = (m) => (a.close(), o(c.error)), l.oncomplete = () => { p == null ? a.close() : p.oncomplete = () => a.close(); }; } }, s.onerror = (a) => o(s.error); }); } }; Ca.URL_SCHEME = "indexeddb://"; var GN = (r) => U().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Ca.URL_SCHEME) ? s4(r.slice(Ca.URL_SCHEME.length)) : null; Et.registerSaveRouter(GN); Et.registerLoadRouter(GN); function s4(r) { return new Ca(r); } function i4(r) { return r.startsWith(Ca.URL_SCHEME) ? r.slice(Ca.URL_SCHEME.length) : r; } var __ = class { constructor() { this.indexedDB = VN(); } async listModels() { return new Promise((e, t) => { let n = this.indexedDB.open(y_, b_); n.onupgradeneeded = () => w_(n), n.onsuccess = () => { let o = n.result, s = o.transaction(Nl, "readonly"), i = s.objectStore(Nl).getAll(); i.onsuccess = () => { let l = {}; for (let u of i.result) l[u.modelPath] = u.modelArtifactsInfo; e(l); }, i.onerror = (l) => (o.close(), t(i.error)), s.oncomplete = () => o.close(); }, n.onerror = (o) => t(n.error); }); } async removeModel(e) { return e = i4(e), new Promise((t, n) => { let o = this.indexedDB.open(y_, b_); o.onupgradeneeded = () => w_(o), o.onsuccess = () => { let s = o.result, a = s.transaction(Nl, "readwrite"), i = a.objectStore(Nl), l = i.get(e), u; l.onsuccess = () => { if (l.result == null) return s.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { let c = i.delete(e), p = () => { u = s.transaction(yu, "readwrite"); let f = u.objectStore(yu).delete(e); f.onsuccess = () => t(l.result.modelArtifactsInfo), f.onerror = (d) => n(l.error); }; c.onsuccess = p, c.onerror = (m) => (p(), s.close(), n(l.error)); } }, l.onerror = (c) => (s.close(), n(l.error)), a.oncomplete = () => { u == null ? s.close() : u.oncomplete = () => s.close(); }; }, o.onerror = (s) => n(o.error); }); } }; var Ia = "/"; var $p = "tensorflowjs_models"; var WN = "info"; var a4 = "model_topology"; var l4 = "weight_specs"; var u4 = "weight_data"; var c4 = "model_metadata"; function UN(r) { return { info: [$p, r, WN].join(Ia), topology: [$p, r, a4].join(Ia), weightSpecs: [$p, r, l4].join(Ia), weightData: [$p, r, u4].join(Ia), modelMetadata: [$p, r, c4].join(Ia) }; } function jN(r) { for (let e of Object.values(r)) window.localStorage.removeItem(e); } function p4(r) { let e = r.split(Ia); if (e.length < 3) throw new Error(`Invalid key format: ${r}`); return e.slice(1, e.length - 1).join(Ia); } function m4(r) { return r.startsWith(Sa.URL_SCHEME) ? r.slice(Sa.URL_SCHEME.length) : r; } var Sa = class { constructor(e) { if (!U().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 = UN(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), o = wi(e); try { this.LS.setItem(this.keys.info, JSON.stringify(o)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, ON(e.weightData)); let s = { 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(s)), { modelArtifactsInfo: o }; } catch (s) { throw jN(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=${o.modelTopologyBytes}, weightSpecsBytes=${o.weightSpecsBytes}, weightDataBytes=${o.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 o = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); if (o == null) throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`); t.weightSpecs = o; let s = this.LS.getItem(this.keys.modelMetadata); if (s != null) { let i = JSON.parse(s); 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 = PN(a), t; } }; Sa.URL_SCHEME = "localstorage://"; var HN = (r) => U().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Sa.URL_SCHEME) ? f4(r.slice(Sa.URL_SCHEME.length)) : null; Et.registerSaveRouter(HN); Et.registerLoadRouter(HN); function f4(r) { return new Sa(r); } var k_ = class { constructor() { E(U().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), E(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage; } async listModels() { let e = {}, t = $p + Ia, n = Ia + WN; for (let o = 0; o < this.LS.length; ++o) { let s = this.LS.key(o); if (s.startsWith(t) && s.endsWith(n)) { let a = p4(s); e[a] = JSON.parse(this.LS.getItem(s)); } } return e; } async removeModel(e) { e = m4(e); let t = UN(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 jN(t), n; } }; var Rp = "://"; var rn = class { constructor() { this.managers = {}; } static getInstance() { return rn.instance == null && (rn.instance = new rn()), rn.instance; } static registerManager(e, t) { E(e != null, () => "scheme must not be undefined or null."), e.endsWith(Rp) && (e = e.slice(0, e.indexOf(Rp))), E(e.length > 0, () => "scheme must not be an empty string."); let n = rn.getInstance(); E(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 Mg(r) { if (r.indexOf(Rp) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${rn.getSchemes().join(",")}`); return { scheme: r.split(Rp)[0], path: r.split(Rp)[1] }; } async function qN(r, e, t = false) { E(r !== e, () => `Old path and new path are the same: '${r}'`); let n = Et.getLoadHandlers(r); E(n.length > 0, () => `Copying failed because no load handler is found for source URL ${r}.`), E(n.length < 2, () => `Copying failed because more than one (${n.length}) load handlers for source URL ${r}.`); let o = n[0], s = Et.getSaveHandlers(e); E(s.length > 0, () => `Copying failed because no save handler is found for destination URL ${e}.`), E(s.length < 2, () => `Copying failed because more than one (${n.length}) save handlers for destination URL ${e}.`); let a = s[0], i = Mg(r).scheme, l = Mg(r).path, u = i === Mg(r).scheme, c = await o.load(); t && u && await rn.getManager(i).removeModel(l); let p = await a.save(c); return t && !u && await rn.getManager(i).removeModel(l), p.modelArtifactsInfo; } async function KN() { let r = rn.getSchemes(), e = {}; for (let t of r) { let n = await rn.getManager(t).listModels(); for (let o in n) { let s = t + Rp + o; e[s] = n[o]; } } return e; } async function XN(r) { let e = Mg(r); return rn.getManager(e.scheme).removeModel(e.path); } async function YN(r, e) { return qN(r, e, false); } async function ZN(r, e) { return qN(r, e, true); } var JN = 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 (U().get("IS_BROWSER")) { U().setPlatform("browser", new JN()); try { rn.registerManager(Sa.URL_SCHEME, new k_()); } catch (r) { } try { rn.registerManager(Ca.URL_SCHEME, new __()); } catch (r) { } } var d4 = { importFetch: () => QN() }; var v_; var e1 = class { constructor() { this.util = Lc("util"), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { return U().global.fetch != null ? U().global.fetch(e, t) : (v_ == null && (v_ = d4.importFetch()), v_(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); } }; U().get("IS_NODE") && U().setPlatform("node", new e1()); function Ie(r, e = "float32", t) { return e = e || "float32", Jm(r), new mt(r, e, t); } function h4(r, e) { let t = k(r, "x", "cast"); if (!qw(e)) throw new Error(`Failed to cast to unknown dtype ${e}`); if (e === "string" && t.dtype !== "string" || e !== "string" && t.dtype === "string") throw new Error("Only strings can be casted to strings"); let n = { x: t }, o = { dtype: e }; return T.runKernel(eo, n, o); } var Y = N({ cast_: h4 }); function g4(r) { let t = { x: k(r, "x", "clone", "string_or_numeric") }; return T.runKernel(ro, t); } var wn = N({ clone_: g4 }); function C_(r, e = false) { console.log(r.toString(e)); } f_(); var x4 = { buffer: Ie, cast: Y, clone: wn, print: C_ }; NN(x4); var Lr = {}; qe(Lr, { browserFiles: () => n1, browserHTTPRequest: () => i1, concatenateArrayBuffers: () => Ap, copyModel: () => YN, decodeWeights: () => Og, encodeWeights: () => RN, fromMemory: () => l1, getLoadHandlers: () => BN, getModelArtifactsForJSON: () => Dp, getModelArtifactsInfoForJSON: () => wi, getSaveHandlers: () => zN, http: () => Bg, isHTTPScheme: () => zg, listModels: () => KN, loadWeights: () => o1, moveModel: () => ZN, registerLoadRouter: () => LN, registerSaveRouter: () => MN, removeModel: () => XN, weightsLoaderFactory: () => N_, withSaveHandler: () => u1 }); var y4 = "model"; var b4 = ".json"; var w4 = ".weights.bin"; function t1(r) { return new Promise((e) => setTimeout(e)).then(r); } var Tl = class { constructor(e) { if (!U().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(Tl.URL_SCHEME) && (e = e.slice(Tl.URL_SCHEME.length)), (e == null || e.length === 0) && (e = y4), this.modelJsonFileName = e + b4, this.weightDataFileName = e + w4; } 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 }], o = Pg(e, n), s = window.URL.createObjectURL(new Blob([JSON.stringify(o)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; if (a.download = this.modelJsonFileName, a.href = s, await t1(() => 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 t1(() => i.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: wi(e) }; } } }; Tl.URL_SCHEME = "downloads://"; var r1 = 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 = (o) => { let s = JSON.parse(o.target.result), a = s.modelTopology; if (a == null) { t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); return; } if (s.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 l = Dp(s, (u) => this.loadWeights(u)); e(l); }, n.onerror = (o) => 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 o = this.checkManifestAndWeightFiles(e), s = n.map((a) => this.loadWeightsFile(a, o[a])); return Promise.all(s).then((a) => [t, Ap(a)]); } loadWeightsFile(e, t) { return new Promise((n, o) => { let s = new FileReader(); s.onload = (a) => { let i = a.target.result; n(i); }, s.onerror = (a) => o(`Failed to weights data from file of path '${e}'.`), s.readAsArrayBuffer(t); }); } checkManifestAndWeightFiles(e) { let t = [], n = this.weightsFiles.map((s) => x_(s.name)), o = {}; for (let s of e) s.paths.forEach((a) => { let i = x_(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.`); o[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 o; } }; var _4 = (r) => U().getBool("IS_BROWSER") && !Array.isArray(r) && r.startsWith(Tl.URL_SCHEME) ? k4(r.slice(Tl.URL_SCHEME.length)) : null; Et.registerSaveRouter(_4); function k4(r = "model") { return new Tl(r); } function n1(r) { return new r1(r); } function I_(r, e, t, n) { a(r), t = t == null ? 0 : t, n = n == null ? 1 : n, i(t, n); let o = 0, s = (l) => (l.then((u) => { let c = t + ++o / r.length * (n - t); return e(c), u; }), l); function a(l) { E(l != null && Array.isArray(l) && l.length > 0, () => "promises must be a none empty array"); } function i(l, u) { E(l >= 0 && l <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${l}`), E(u >= 0 && u <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${u}`), E(u >= l, () => `startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`); } return Promise.all(r.map(s)); } async function S_(r, e) { e == null && (e = {}); let t = e.fetchFunc == null ? U().platform.fetch : e.fetchFunc, n = r.map((p) => t(p, e.requestInit, { isBinary: true })), o = 0, s = 0.5, i = (e.onProgress == null ? await Promise.all(n) : await I_(n, e.onProgress, o, s)).map((p) => p.arrayBuffer()), l = 0.5, u = 1; return e.onProgress == null ? await Promise.all(i) : await I_(i, e.onProgress, l, u); } async function o1(r, e = "", t, n) { return N_((a) => S_(a, { requestInit: n }))(r, e, t); } function N_(r) { return async (e, t = "", n) => { let o = e.map(() => false), s = {}, a = n != null ? n.map(() => false) : [], i = []; if (e.forEach((f, d) => { let h = 0; f.weights.forEach((g) => { let x = "quantization" in g ? g.quantization.dtype : g.dtype, y = mf[x] * st(g.shape), w = () => { o[d] = true, s[d] == null && (s[d] = []), s[d].push({ manifestEntry: g, groupOffset: h, sizeBytes: y }); }; n != null ? n.forEach((_, C) => { _ === g.name && (w(), a[C] = true); }) : w(), i.push(g.name), h += y; }); }), !a.every((f) => f)) { let f = n.filter((d, h) => !a[h]); throw new Error(`Could not find weights in manifest with names: ${f.join(", ")}. Manifest JSON has weights with names: ${i.join(", ")}.`); } let l = o.reduce((f, d, h) => (d && f.push(h), f), []), u = []; l.forEach((f) => { e[f].paths.forEach((d) => { let h = t + (t.endsWith("/") ? "" : "/") + d; u.push(h); }); }); let c = await r(u), p = {}, m = 0; return l.forEach((f) => { let d = e[f].paths.length, h = 0; for (let _ = 0; _ < d; _++) h += c[m + _].byteLength; let g = new ArrayBuffer(h), x = new Uint8Array(g), y = 0; for (let _ = 0; _ < d; _++) { let C = new Uint8Array(c[m + _]); x.set(C, y), y += C.byteLength; } s[f].forEach((_) => { let C = g.slice(_.groupOffset, _.groupOffset + _.sizeBytes), A = Og(C, [_.manifestEntry]); for (let D in A) p[D] = A[D]; }), m += d; }), p; }; } var v4 = "application/octet-stream"; var C4 = "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 ? (E(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 = U().platform.fetch, E(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && E(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t.requestInit != null && t.requestInit.body != null) throw new Error("requestInit is expected to have no pre-existing body, but has one."); this.requestInit = t.requestInit || {}; } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); let t = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit); t.body = new FormData(); let n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], o = Pg(e, n); t.body.append("model.json", new Blob([JSON.stringify(o)], { type: C4 }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: v4 }), "model.weights.bin"); let s = await this.fetch(this.path, t); if (s.ok) return { modelArtifactsInfo: wi(e), responses: [s] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.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 (s) { 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, o = t.weightsManifest; if (n == null && o == null) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); return Dp(t, (s) => this.loadWeights(s)); } async loadWeights(e) { let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, o] = I4(t), s = this.weightPathPrefix || n, a = []; for (let c of e) a.push(...c.weights); let i = [], l = []; for (let c of e) for (let p of c.paths) this.weightUrlConverter != null ? l.push(this.weightUrlConverter(p)) : i.push(s + p + o); this.weightUrlConverter && i.push(...await Promise.all(l)); let u = await S_(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); return [a, Ap(u)]; } }; Lg.URL_SCHEME_REGEX = /^https?:\/\//; function I4(r) { let e = r.lastIndexOf("/"), t = r.lastIndexOf("?"), n = r.substring(0, e), o = t > e ? r.substring(t) : ""; return [n + "/", o]; } function zg(r) { return r.match(Lg.URL_SCHEME_REGEX) != null; } var s1 = (r, e) => { if (typeof fetch == "undefined" && (e == null || e.fetchFunc == null)) return null; { let t = true; if (Array.isArray(r) ? t = r.every((n) => zg(n)) : t = zg(r), t) return Bg(r, e); } return null; }; Et.registerSaveRouter(s1); Et.registerLoadRouter(s1); function Bg(r, e) { return new Lg(r, e); } function i1(r, e) { return Bg(r, e); } var Vg = class { constructor(e) { this.modelArtifacts = e; } async load() { return this.modelArtifacts; } }; var a1 = class { constructor(e) { this.saveHandler = e; } async save(e) { return this.saveHandler(e); } }; function l1(r, e, t, n) { return arguments.length === 1 ? r.modelTopology != null || r.weightSpecs != null ? new Vg(r) : (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 Vg({ modelTopology: r })) : (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 Vg({ modelTopology: r, weightSpecs: e, weightData: t, trainingConfig: n })); } function u1(r) { return new a1(r); } var p1 = {}; qe(p1, { confusionMatrix: () => c1 }); function S4(r, e, t = false, n = false) { let o = k(r, "a", "matMul"), s = k(e, "b", "matMul"); [o, s] = je(o, s); let a = { a: o, b: s }, i = { transposeA: t, transposeB: n }; return T.runKernel(Oo, a, i); } var ze = N({ matMul_: S4 }); function N4(r, e, t = 1, n = 0) { if (e < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`); let s = { indices: k(r, "indices", "oneHot", "int32") }, a = { depth: e, onValue: t, offValue: n }; return T.runKernel(is, s, a); } var Ts = N({ oneHot_: N4 }); function T4(r, e) { let t = k(r, "x", "transpose"); if (e == null && (e = t.shape.map((s, a) => a).reverse()), E(t.rank === e.length, () => `Error in transpose: rank of input ${t.rank} must match length of perm ${e}.`), e.forEach((s) => { E(s >= 0 && s < t.rank, () => `All entries in 'perm' must be between 0 and ${t.rank - 1} but got ${e}`); }), t.rank <= 1) return t.clone(); let n = { x: t }, o = { perm: e }; return T.runKernel(Is, n, o); } var Be = N({ transpose_: T4 }); function E4(r, e, t) { let n = k(r, "labels", "confusionMatrix"), o = k(e, "predictions", "confusionMatrix"); E(t == null || t > 0 && Number.isInteger(t), () => `If provided, numClasses must be a positive integer, but got ${t}`), E(n.rank === 1, () => `Expected the rank of labels to be 1, but got ${n.rank}`), E(o.rank === 1, () => `Expected the rank of predictions to be 1, but got ${o.rank}`), E(n.shape[0] === o.shape[0], () => `Mismatch in the number of examples: ${n.shape[0]} vs. ${o.shape[0]}. Labels and predictions should have the same number of elements.`), E(t > 0 && Number.isInteger(t), () => `numClasses is required to be a positive integer, but got ${t}`); let s = Ts(Y(n, "int32"), t), a = Ts(Y(o, "int32"), t), i = Be(s), l = ze(i, a); return Y(l, "int32"); } var c1 = N({ confusionMatrix_: E4 }); var Gg = {}; qe(Gg, { fromPixels: () => P4, fromPixelsAsync: () => F4, toPixels: () => O4 }); function T_(r, e, t) { if (Wn(r), e != null && e.length !== 3) throw new Error("tensor3d() requires shape to have three numbers"); let n = Mr(r, t); if (n.length !== 3 && n.length !== 1) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (n.length === 1 && e == null) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); return tn(r, e, n, t); } var Fp; function m1(r, e = 3) { if (e > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (r == null) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); let t = false, n = false, o = false, s = false, a = false, i = false; if (r.data instanceof Uint8Array) t = true; else if (typeof ImageData != "undefined" && r instanceof ImageData) n = true; else if (typeof HTMLVideoElement != "undefined" && r instanceof HTMLVideoElement) o = true; else if (typeof HTMLImageElement != "undefined" && r instanceof HTMLImageElement) s = true; else if (r.getContext != null) a = true; else if (typeof ImageBitmap != "undefined" && r instanceof ImageBitmap) i = 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 ${r.constructor.name}`); if (o) { let d = 2; if (o && r.readyState < d) throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the