UNPKG

bry-biometric-collector

Version:

BRy web-collector component for biometric capture.

1,458 lines (1,457 loc) 1.88 MB
import { bt as eo } from "./main_f7bde95f_3.2.1.js"; import { r as x1, l as b1, L as y1 } from "./___vite-browser-external_commonjs-proxy_eec4c905_3.2.1.js"; import "./face_api_0e3ce8c8_3.2.1.js"; var pu = { exports: {} }; pu.exports; (function(n) { (function(t, e, s) { function o(l) { var c = this, u = a(); c.next = function() { var h = 2091639 * c.s0 + c.c * 23283064365386963e-26; return c.s0 = c.s1, c.s1 = c.s2, c.s2 = h - (c.c = h | 0); }, c.c = 1, c.s0 = u(" "), c.s1 = u(" "), c.s2 = u(" "), c.s0 -= u(l), c.s0 < 0 && (c.s0 += 1), c.s1 -= u(l), c.s1 < 0 && (c.s1 += 1), c.s2 -= u(l), c.s2 < 0 && (c.s2 += 1), u = null; } function r(l, c) { return c.c = l.c, c.s0 = l.s0, c.s1 = l.s1, c.s2 = l.s2, c; } function i(l, c) { var u = new o(l), h = c && c.state, d = u.next; return d.int32 = function() { return u.next() * 4294967296 | 0; }, d.double = function() { return d() + (d() * 2097152 | 0) * 11102230246251565e-32; }, d.quick = d, h && (typeof h == "object" && r(h, u), d.state = function() { return r(u, {}); }), d; } function a() { var l = 4022871197, c = function(u) { u = String(u); for (var h = 0; h < u.length; h++) { l += u.charCodeAt(h); var d = 0.02519603282416938 * l; l = d >>> 0, d -= l, d *= l, l = d >>> 0, d -= l, l += d * 4294967296; } return (l >>> 0) * 23283064365386963e-26; }; return c; } e && e.exports ? e.exports = i : s && s.amd ? s(function() { return i; }) : this.alea = i; })( eo, n, // present in node.js !1 // present with an AMD loader ); })(pu); var w1 = pu.exports, fu = { exports: {} }; fu.exports; (function(n) { (function(t, e, s) { function o(a) { var l = this, c = ""; l.x = 0, l.y = 0, l.z = 0, l.w = 0, l.next = function() { var h = l.x ^ l.x << 11; return l.x = l.y, l.y = l.z, l.z = l.w, l.w ^= l.w >>> 19 ^ h ^ h >>> 8; }, a === (a | 0) ? l.x = a : c += a; for (var u = 0; u < c.length + 64; u++) l.x ^= c.charCodeAt(u) | 0, l.next(); } function r(a, l) { return l.x = a.x, l.y = a.y, l.z = a.z, l.w = a.w, l; } function i(a, l) { var c = new o(a), u = l && l.state, h = function() { return (c.next() >>> 0) / 4294967296; }; return h.double = function() { do var d = c.next() >>> 11, p = (c.next() >>> 0) / 4294967296, f = (d + p) / (1 << 21); while (f === 0); return f; }, h.int32 = c.next, h.quick = h, u && (typeof u == "object" && r(u, c), h.state = function() { return r(c, {}); }), h; } e && e.exports ? e.exports = i : s && s.amd ? s(function() { return i; }) : this.xor128 = i; })( eo, n, // present in node.js !1 // present with an AMD loader ); })(fu); var C1 = fu.exports, mu = { exports: {} }; mu.exports; (function(n) { (function(t, e, s) { function o(a) { var l = this, c = ""; l.next = function() { var h = l.x ^ l.x >>> 2; return l.x = l.y, l.y = l.z, l.z = l.w, l.w = l.v, (l.d = l.d + 362437 | 0) + (l.v = l.v ^ l.v << 4 ^ (h ^ h << 1)) | 0; }, l.x = 0, l.y = 0, l.z = 0, l.w = 0, l.v = 0, a === (a | 0) ? l.x = a : c += a; for (var u = 0; u < c.length + 64; u++) l.x ^= c.charCodeAt(u) | 0, u == c.length && (l.d = l.x << 10 ^ l.x >>> 4), l.next(); } function r(a, l) { return l.x = a.x, l.y = a.y, l.z = a.z, l.w = a.w, l.v = a.v, l.d = a.d, l; } function i(a, l) { var c = new o(a), u = l && l.state, h = function() { return (c.next() >>> 0) / 4294967296; }; return h.double = function() { do var d = c.next() >>> 11, p = (c.next() >>> 0) / 4294967296, f = (d + p) / (1 << 21); while (f === 0); return f; }, h.int32 = c.next, h.quick = h, u && (typeof u == "object" && r(u, c), h.state = function() { return r(c, {}); }), h; } e && e.exports ? e.exports = i : s && s.amd ? s(function() { return i; }) : this.xorwow = i; })( eo, n, // present in node.js !1 // present with an AMD loader ); })(mu); var $1 = mu.exports, gu = { exports: {} }; gu.exports; (function(n) { (function(t, e, s) { function o(a) { var l = this; l.next = function() { var u = l.x, h = l.i, d, p; return d = u[h], d ^= d >>> 7, p = d ^ d << 24, d = u[h + 1 & 7], p ^= d ^ d >>> 10, d = u[h + 3 & 7], p ^= d ^ d >>> 3, d = u[h + 4 & 7], p ^= d ^ d << 7, d = u[h + 7 & 7], d = d ^ d << 13, p ^= d ^ d << 9, u[h] = p, l.i = h + 1 & 7, p; }; function c(u, h) { var d, p = []; if (h === (h | 0)) p[0] = h; else for (h = "" + h, d = 0; d < h.length; ++d) p[d & 7] = p[d & 7] << 15 ^ h.charCodeAt(d) + p[d + 1 & 7] << 13; for (; p.length < 8; ) p.push(0); for (d = 0; d < 8 && p[d] === 0; ++d) ; for (d == 8 ? p[7] = -1 : p[d], u.x = p, u.i = 0, d = 256; d > 0; --d) u.next(); } c(l, a); } function r(a, l) { return l.x = a.x.slice(), l.i = a.i, l; } function i(a, l) { a == null && (a = +/* @__PURE__ */ new Date()); var c = new o(a), u = l && l.state, h = function() { return (c.next() >>> 0) / 4294967296; }; return h.double = function() { do var d = c.next() >>> 11, p = (c.next() >>> 0) / 4294967296, f = (d + p) / (1 << 21); while (f === 0); return f; }, h.int32 = c.next, h.quick = h, u && (u.x && r(u, c), h.state = function() { return r(c, {}); }), h; } e && e.exports ? e.exports = i : s && s.amd ? s(function() { return i; }) : this.xorshift7 = i; })( eo, n, // present in node.js !1 // present with an AMD loader ); })(gu); var I1 = gu.exports, xu = { exports: {} }; xu.exports; (function(n) { (function(t, e, s) { function o(a) { var l = this; l.next = function() { var u = l.w, h = l.X, d = l.i, p, f; return l.w = u = u + 1640531527 | 0, f = h[d + 34 & 127], p = h[d = d + 1 & 127], f ^= f << 13, p ^= p << 17, f ^= f >>> 15, p ^= p >>> 12, f = h[d] = f ^ p, l.i = d, f + (u ^ u >>> 16) | 0; }; function c(u, h) { var d, p, f, m, g, x = [], b = 128; for (h === (h | 0) ? (p = h, h = null) : (h = h + "\0", p = 0, b = Math.max(b, h.length)), f = 0, m = -32; m < b; ++m) h && (p ^= h.charCodeAt((m + 32) % h.length)), m === 0 && (g = p), p ^= p << 10, p ^= p >>> 15, p ^= p << 4, p ^= p >>> 13, m >= 0 && (g = g + 1640531527 | 0, d = x[m & 127] ^= p + g, f = d == 0 ? f + 1 : 0); for (f >= 128 && (x[(h && h.length || 0) & 127] = -1), f = 127, m = 4 * 128; m > 0; --m) p = x[f + 34 & 127], d = x[f = f + 1 & 127], p ^= p << 13, d ^= d << 17, p ^= p >>> 15, d ^= d >>> 12, x[f] = p ^ d; u.w = g, u.X = x, u.i = f; } c(l, a); } function r(a, l) { return l.i = a.i, l.w = a.w, l.X = a.X.slice(), l; } function i(a, l) { a == null && (a = +/* @__PURE__ */ new Date()); var c = new o(a), u = l && l.state, h = function() { return (c.next() >>> 0) / 4294967296; }; return h.double = function() { do var d = c.next() >>> 11, p = (c.next() >>> 0) / 4294967296, f = (d + p) / (1 << 21); while (f === 0); return f; }, h.int32 = c.next, h.quick = h, u && (u.X && r(u, c), h.state = function() { return r(c, {}); }), h; } e && e.exports ? e.exports = i : s && s.amd ? s(function() { return i; }) : this.xor4096 = i; })( eo, // window object or global n, // present in node.js !1 // present with an AMD loader ); })(xu); var k1 = xu.exports, bu = { exports: {} }; bu.exports; (function(n) { (function(t, e, s) { function o(a) { var l = this, c = ""; l.next = function() { var h = l.b, d = l.c, p = l.d, f = l.a; return h = h << 25 ^ h >>> 7 ^ d, d = d - p | 0, p = p << 24 ^ p >>> 8 ^ f, f = f - h | 0, l.b = h = h << 20 ^ h >>> 12 ^ d, l.c = d = d - p | 0, l.d = p << 16 ^ d >>> 16 ^ f, l.a = f - h | 0; }, l.a = 0, l.b = 0, l.c = -1640531527, l.d = 1367130551, a === Math.floor(a) ? (l.a = a / 4294967296 | 0, l.b = a | 0) : c += a; for (var u = 0; u < c.length + 20; u++) l.b ^= c.charCodeAt(u) | 0, l.next(); } function r(a, l) { return l.a = a.a, l.b = a.b, l.c = a.c, l.d = a.d, l; } function i(a, l) { var c = new o(a), u = l && l.state, h = function() { return (c.next() >>> 0) / 4294967296; }; return h.double = function() { do var d = c.next() >>> 11, p = (c.next() >>> 0) / 4294967296, f = (d + p) / (1 << 21); while (f === 0); return f; }, h.int32 = c.next, h.quick = h, u && (typeof u == "object" && r(u, c), h.state = function() { return r(c, {}); }), h; } e && e.exports ? e.exports = i : s && s.amd ? s(function() { return i; }) : this.tychei = i; })( eo, n, // present in node.js !1 // present with an AMD loader ); })(bu); var v1 = bu.exports, Ff = { exports: {} }; (function(n) { (function(t, e, s) { var o = 256, r = 6, i = 52, a = "random", l = s.pow(o, r), c = s.pow(2, i), u = c * 2, h = o - 1, d; function p(y, C, $) { var k = []; C = C == !0 ? { entropy: !0 } : C || {}; var v = x(g( C.entropy ? [y, w(e)] : y ?? b(), 3 ), k), S = new f(k), T = function() { for (var F = S.g(r), L = l, M = 0; F < c; ) F = (F + M) * o, L *= o, M = S.g(1); for (; F >= u; ) F /= 2, L /= 2, M >>>= 1; return (F + M) / L; }; return T.int32 = function() { return S.g(4) | 0; }, T.quick = function() { return S.g(4) / 4294967296; }, T.double = T, x(w(S.S), e), (C.pass || $ || function(F, L, M, B) { return B && (B.S && m(B, S), F.state = function() { return m(S, {}); }), M ? (s[a] = F, L) : F; })( T, v, "global" in C ? C.global : this == s, C.state ); } function f(y) { var C, $ = y.length, k = this, v = 0, S = k.i = k.j = 0, T = k.S = []; for ($ || (y = [$++]); v < o; ) T[v] = v++; for (v = 0; v < o; v++) T[v] = T[S = h & S + y[v % $] + (C = T[v])], T[S] = C; (k.g = function(F) { for (var L, M = 0, B = k.i, z = k.j, V = k.S; F--; ) L = V[B = h & B + 1], M = M * o + V[h & (V[B] = V[z = h & z + L]) + (V[z] = L)]; return k.i = B, k.j = z, M; })(o); } function m(y, C) { return C.i = y.i, C.j = y.j, C.S = y.S.slice(), C; } function g(y, C) { var $ = [], k = typeof y, v; if (C && k == "object") for (v in y) try { $.push(g(y[v], C - 1)); } catch { } return $.length ? $ : k == "string" ? y : y + "\0"; } function x(y, C) { for (var $ = y + "", k, v = 0; v < $.length; ) C[h & v] = h & (k ^= C[h & v] * 19) + $.charCodeAt(v++); return w(C); } function b() { try { var y; return d && (y = d.randomBytes) ? y = y(o) : (y = new Uint8Array(o), (t.crypto || t.msCrypto).getRandomValues(y)), w(y); } catch { var C = t.navigator, $ = C && C.plugins; return [+/* @__PURE__ */ new Date(), t, $, t.screen, w(e)]; } } function w(y) { return String.fromCharCode.apply(0, y); } if (x(s.random(), e), n.exports) { n.exports = p; try { d = x1; } catch { } } else s["seed" + a] = p; })( // global: `self` in browsers (including strict mode and web workers), // otherwise `this` in Node and other environments typeof self < "u" ? self : eo, [], // pool: entropy pool starts empty Math // math: package containing random, pow, and seedrandom ); })(Ff); var S1 = Ff.exports, N1 = w1, T1 = C1, E1 = $1, R1 = I1, D1 = k1, A1 = v1, no = S1; no.alea = N1; no.xor128 = T1; no.xorwow = E1; no.xorshift7 = R1; no.xor4096 = D1; no.tychei = A1; var yu = no; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const F1 = 1e-7, O1 = 1e-4; class Of { constructor(t, e) { this.backend = t, this.dataMover = e, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0; } get(t) { return this.data.has(t) || this.dataMover.moveData(this.backend, t), this.data.get(t); } set(t, e) { this.dataIdsCount++, this.data.set(t, e); } has(t) { return this.data.has(t); } delete(t) { return this.dataIdsCount--, this.data.delete(t); } numDataIds() { return this.dataIdsCount; } } class wu { refCount(t) { return Be("refCount"); } incRef(t) { return Be("incRef"); } timerAvailable() { return !0; } time(t) { return Be("time"); } read(t) { return Be("read"); } readSync(t) { return Be("readSync"); } readToGPU(t, e) { return Be("readToGPU"); } numDataIds() { return Be("numDataIds"); } disposeData(t, e) { return Be("disposeData"); } write(t, e, s) { return Be("write"); } move(t, e, s, o, r) { return Be("move"); } createTensorFromGPUData(t, e, s) { return Be("createTensorFromGPUData"); } memory() { return Be("memory"); } /** Returns the highest precision for floats in bits (e.g. 16 or 32) */ floatPrecision() { return Be("floatPrecision"); } /** Returns the smallest representable number. */ epsilon() { return this.floatPrecision() === 32 ? F1 : O1; } dispose() { return Be("dispose"); } } function Be(n) { throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`); } /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function _1(n) { let t = n.length, e = 0; for (; t > 0; ) e = Math.random() * t | 0, t--, xo(n, t, e); } function Vs(n, t, e) { return Math.max(n, Math.min(t, e)); } function Cu(n) { return n % 2 === 0 ? n : n + 1; } function xo(n, t, e) { const s = n[t]; n[t] = n[e], n[e] = s; } function L1(n) { let t = 0; for (let e = 0; e < n.length; e++) t += n[e]; return t; } function I(n, t) { if (!n) throw new Error(typeof t == "string" ? t : t()); } function $u(n, t, e = "") { I(Et(n, t), () => e + ` Shapes ${n} and ${t} must match`); } function _f(n) { I(n != null, () => "The input to the tensor constructor must be a non-null value."); } function G(n) { if (n.length === 0) return 1; let t = n[0]; for (let e = 1; e < n.length; e++) t *= n[e]; return t; } function Et(n, t) { if (n === t) return !0; if (n == null || t == null || n.length !== t.length) return !1; for (let e = 0; e < n.length; e++) if (n[e] !== t[e]) return !1; return !0; } function vo(n) { return n % 1 === 0; } function Ec(n) { const t = Math.ceil(Math.sqrt(n)); return [t, Math.ceil(n / t)]; } function wo(n, t) { return t <= n.length ? n : n + " ".repeat(t - n.length); } function ep(n, t = (o) => 0, e, s) { return new Promise((o, r) => { let i = 0; const a = () => { if (n()) { o(); return; } i++; const l = t(i); if (e != null && i >= e) { r(); return; } s != null ? s(a, l) : setTimeout(a, l); }; a(); }); } function Lf(n, t) { let e = 1, s = -1; for (let r = 0; r < n.length; ++r) if (n[r] >= 0) e *= n[r]; else if (n[r] === -1) { if (s !== -1) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${r}`); s = r; } else if (n[r] < 0) throw Error(`Shapes can not be < 0. Found ${n[r]} at dim ${r}`); if (s === -1) { if (t > 0 && t !== e) throw Error(`Size(${t}) must match the product of shape ${n}`); return n; } if (e === 0) throw Error(`Cannot infer the missing size in [${n}] when there are 0 elements`); if (t % e !== 0) throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${e}`); const o = n.slice(); return o[s] = t / e, o; } function wt(n, t) { const e = t.length; return n = n == null ? t.map((s, o) => o) : [].concat(n), I(n.every((s) => s >= -e && s < e), () => `All values in axis param must be in range [-${e}, ${e}) but got axis ${n}`), I(n.every((s) => vo(s)), () => `All values in axis param must be integers but got axis ${n}`), n.map((s) => s < 0 ? e + s : s); } function ys(n, t) { const e = [], s = [], o = t != null && Array.isArray(t) && t.length === 0, r = t == null || o ? null : wt(t, n).sort(); let i = 0; for (let a = 0; a < n.length; ++a) { if (r != null) { if (r[i] === a && n[a] !== 1) throw new Error(`Can't squeeze axis ${a} since its dim '${n[a]}' is not 1`); (r[i] == null || r[i] > a) && n[a] === 1 && (e.push(n[a]), s.push(a)), r[i] <= a && i++; } n[a] !== 1 && (e.push(n[a]), s.push(a)); } return { newShape: e, keptDims: s }; } function we(n, t) { return qt(n, t); } function qt(n, t) { let e = null; if (n == null || n === "float32") e = new Float32Array(t); else if (n === "int32") e = new Int32Array(t); else if (n === "bool") e = new Uint8Array(t); else if (n === "string") e = new Array(t); else throw new Error(`Unknown data type ${n}`); return e; } function M1(n, t) { for (let e = 0; e < n.length; e++) { const s = n[e]; if (isNaN(s) || !isFinite(s)) throw Error(`A tensor of type ${t} being uploaded contains ${s}.`); } } function P1(n) { return n === "bool" || n === "complex64" || n === "float32" || n === "int32" || n === "string"; } function Mf(n, t) { return !(t === "complex64" || t === "float32" && n !== "complex64" || t === "int32" && n !== "float32" && n !== "complex64" || t === "bool" && n === "bool"); } function ra(n) { if (n === "float32" || n === "int32") return 4; if (n === "complex64") return 8; if (n === "bool") return 1; throw new Error(`Unknown dtype ${n}`); } function z1(n) { if (n == null) return 0; let t = 0; return n.forEach((e) => t += e.length), t; } function vr(n) { return typeof n == "string" || n instanceof String; } function B1(n) { return typeof n == "boolean"; } function Rc(n) { return typeof n == "number"; } function Lo(n) { return Array.isArray(n) ? Lo(n[0]) : n instanceof Float32Array ? "float32" : n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray ? "int32" : Rc(n) ? "float32" : vr(n) ? "string" : B1(n) ? "bool" : "float32"; } function Dc(n) { return !!(n && n.constructor && n.call && n.apply); } function Ac(n, t) { for (let e = t; e < n; ++e) if (n % e === 0) return e; return n; } function lt(n) { const t = n.length; if (t < 2) return []; const e = new Array(t - 1); e[t - 2] = n[t - 1]; for (let s = t - 3; s >= 0; --s) e[s] = e[s + 1] * n[s + 1]; return e; } function Pf(n, t, e, s = !1) { const o = new Array(); if (t.length === 1) { const r = t[0] * (s ? 2 : 1); for (let i = 0; i < r; i++) o[i] = e[n + i]; } else { const r = t[0], i = t.slice(1), a = i.reduce((l, c) => l * c) * (s ? 2 : 1); for (let l = 0; l < r; l++) o[l] = Pf(n + l * a, i, e, s); } return o; } function xn(n, t, e = !1) { if (n.length === 0) return t[0]; const s = n.reduce((o, r) => o * r) * (e ? 2 : 1); if (s === 0) return []; if (s !== t.length) throw new Error(`[${n}] does not match the input size ${t.length}${e ? " for a complex tensor" : ""}.`); return Pf(0, n, t, e); } function V1(n, t) { if (Array.isArray(n)) return n; if (t === "float32") return n instanceof Float32Array ? n : new Float32Array(n); if (t === "int32") return n instanceof Int32Array ? n : new Int32Array(n); if (t === "bool" || t === "string") return Uint8Array.from(new Int32Array(n)); throw new Error(`Unknown dtype ${t}`); } function Iu(n, t) { const e = Ce(n, t); for (let s = 0; s < e.length; s++) e[s] = 1; return e; } function Ce(n, t) { if (t == null || t === "float32" || t === "complex64") return new Float32Array(n); if (t === "int32") return new Int32Array(n); if (t === "bool") return new Uint8Array(n); throw new Error(`Unknown data type ${t}`); } function zf(n, t) { const e = n.reduce((s, o) => s * o, 1); if (t == null || t === "float32") return xn(n, new Float32Array(e)); if (t === "int32") return xn(n, new Int32Array(e)); if (t === "bool") return xn(n, new Uint8Array(e)); throw new Error(`Unknown data type ${t}`); } function Jn(n) { n.forEach((t) => { I(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${n}].`); }); } function Rn(n, t, e) { if (t === 0) return 0; if (t === 1) return n[0]; let s = n[n.length - 1]; for (let o = 0; o < n.length - 1; ++o) s += e[o] * n[o]; return s; } function Mo(n, t, e) { if (t === 0) return []; if (t === 1) return [n]; const s = new Array(t); for (let o = 0; o < s.length - 1; ++o) s[o] = Math.floor(n / e[o]), n -= s[o] * e[o]; return s[s.length - 1] = n, s; } function ku(n) { return n && n.then && typeof n.then == "function"; } /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const np = "tfjsflags"; class W1 { // tslint:disable-next-line: no-any constructor(t) { this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = U1, this.populateURLFlags(); } setPlatform(t, e) { this.platform != null && (P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`)), this.platformName = t, this.platform = e; } registerFlag(t, e, s) { if (this.flagRegistry[t] = { evaluationFn: e, setHook: s }, this.urlFlags[t] != null) { const o = this.urlFlags[t]; P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(`Setting feature override from URL ${t}: ${o}.`), this.set(t, o); } } async getAsync(t) { return t in this.flags ? this.flags[t] : (this.flags[t] = await this.evaluateFlag(t), this.flags[t]); } get(t) { if (t in this.flags) return this.flags[t]; const e = this.evaluateFlag(t); if (ku(e)) throw new Error(`Flag ${t} cannot be synchronously evaluated. Please use getAsync() instead.`); return this.flags[t] = e, this.flags[t]; } getNumber(t) { return this.get(t); } getBool(t) { return this.get(t); } getString(t) { return this.get(t); } getFlags() { return this.flags; } // For backwards compatibility. get features() { return this.flags; } set(t, e) { if (this.flagRegistry[t] == null) throw new Error(`Cannot set flag ${t} as it has not been registered.`); this.flags[t] = e, this.flagRegistry[t].setHook != null && this.flagRegistry[t].setHook(e); } evaluateFlag(t) { if (this.flagRegistry[t] == null) throw new Error(`Cannot evaluate flag '${t}': no evaluation function found.`); return this.flagRegistry[t].evaluationFn(); } setFlags(t) { this.flags = Object.assign({}, t); } reset() { this.flags = {}, this.urlFlags = {}, this.populateURLFlags(); } populateURLFlags() { if (typeof this.global > "u" || typeof this.global.location > "u" || typeof this.global.location.search > "u") return; const t = this.getQueryParams(this.global.location.search); np in t && t[np].split(",").forEach((s) => { const [o, r] = s.split(":"); this.urlFlags[o] = H1(o, r); }); } } function U1(n) { const t = {}; return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (e, ...s) => (G1(t, s[0], s[1]), s.join("="))), t; } function G1(n, t, e) { n[decodeURIComponent(t)] = decodeURIComponent(e || ""); } function H1(n, t) { const e = t.toLowerCase(); return e === "true" || e === "false" ? e === "true" : `${+e}` === e ? +e : t; } function P() { return Bf; } let Bf = null; function K1(n) { Bf = n; } /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ let hc; function Vf() { if (hc == null) { let n; if (typeof window < "u") n = window; else if (typeof global < "u") n = global; else if (typeof process < "u") n = process; else if (typeof self < "u") n = self; else throw new Error("Could not find a global object"); hc = n; } return hc; } function j1() { const n = Vf(); return n._tfGlobals == null && (n._tfGlobals = /* @__PURE__ */ new Map()), n._tfGlobals; } function vu(n, t) { const e = j1(); if (e.has(n)) return e.get(n); { const s = t(); return e.set(n, s), e.get(n); } } const Fa = "Abs", Sr = "Acos", Nr = "Acosh", Po = "Add", Su = "AddN", Nu = "All", Tu = "Any", Oa = "ArgMax", _a = "ArgMin", Tr = "Asin", Er = "Asinh", Rr = "Atan", Dr = "Atanh", Ar = "Atan2", La = "AvgPool", Eu = "AvgPoolGrad", Ma = "AvgPool3D", Ru = "AvgPool3DGrad", Pa = "BatchMatMul", za = "BatchToSpaceND", Du = "Bincount", Au = "BitwiseAnd", X1 = "BroadcastTo", Wf = "BroadcastArgs", Fr = "Cast", Or = "Ceil", _r = "ClipByValue", Fu = "Complex", Ba = "ComplexAbs", Va = "Concat", Wa = "Conv2D", Ou = "Conv2DBackpropFilter", Ua = "Conv2DBackpropInput", Ga = "Conv3D", _u = "Conv3DBackpropFilterV2", Lu = "Conv3DBackpropInputV2", Lr = "Cos", Mr = "Cosh", Mu = "Cumprod", Ha = "Cumsum", Pu = "CropAndResize", zu = "DenseBincount", Bu = "DepthToSpace", Ka = "DepthwiseConv2dNative", Vu = "DepthwiseConv2dNativeBackpropFilter", Wu = "DepthwiseConv2dNativeBackpropInput", Uf = "Diag", ja = "Dilation2D", Fc = "Dilation2DBackpropInput", Oc = "Dilation2DBackpropFilter", q1 = "Draw", Pr = "RealDiv", Uu = "Einsum", zr = "Elu", Gu = "EluGrad", Br = "Erf", Xa = "Equal", Vr = "Exp", qa = "ExpandDims", Wr = "Expm1", Hu = "FFT", Ku = "Fill", ju = "FlipLeftRight", Ur = "Floor", Gr = "FloorDiv", Ya = "FusedBatchNorm", Ja = "GatherV2", Gf = "GatherNd", Za = "Greater", Hr = "GreaterEqual", Kr = "Identity", Xu = "IFFT", qu = "Imag", jr = "IsFinite", Xr = "IsInf", qr = "IsNan", Qa = "LeakyRelu", tl = "Less", el = "LessEqual", Hf = "LinSpace", Yr = "Log", Jr = "Log1p", nl = "LogicalAnd", sl = "LogicalNot", ol = "LogicalOr", Y1 = "LogSoftmax", rl = "LRN", Yu = "LRNGrad", il = "Max", Zr = "Maximum", al = "MaxPool", Ju = "MaxPoolGrad", ll = "MaxPool3D", Zu = "MaxPool3DGrad", Kf = "MaxPoolWithArgmax", cl = "Mean", ul = "Min", Qr = "Minimum", hl = "MirrorPad", ti = "Mod", jf = "Multinomial", ei = "Multiply", dl = "Neg", pl = "NotEqual", Qu = "NonMaxSuppressionV3", th = "NonMaxSuppressionV4", eh = "NonMaxSuppressionV5", fl = "OnesLike", ml = "OneHot", gl = "Pack", xl = "PadV2", ni = "Pow", bl = "Prelu", yl = "Prod", Xf = "RaggedGather", qf = "RaggedRange", Yf = "RaggedTensorToTensor", nh = "Range", sh = "Real", si = "Reciprocal", oi = "Relu", wl = "Reshape", Cl = "ResizeNearestNeighbor", oh = "ResizeNearestNeighborGrad", $l = "ResizeBilinear", rh = "ResizeBilinearGrad", ri = "Relu6", Il = "Reverse", ii = "Round", ai = "Rsqrt", Jf = "ScatterNd", Zf = "TensorScatterUpdate", Qf = "SearchSorted", kl = "Select", li = "Selu", vl = "Slice", ci = "Sin", ui = "Sinh", hi = "Sign", di = "Sigmoid", pi = "Softplus", fi = "Sqrt", Sl = "Sum", Nl = "SpaceToBatchND", Tl = "SplitV", El = "Softmax", tm = "SparseFillEmptyRows", em = "SparseReshape", nm = "SparseSegmentMean", sm = "SparseSegmentSum", om = "SparseToDense", mi = "SquaredDifference", ih = "Square", ah = "StaticRegexReplace", lh = "StridedSlice", rm = "StringNGrams", im = "StringSplit", am = "StringToHashBucketFast", gi = "Sub", xi = "Tan", bi = "Tanh", yi = "Tile", ch = "TopK", uh = "Transform", Co = "Transpose", hh = "Unique", Rl = "Unpack", Dl = "UnsortedSegmentSum", Al = "ZerosLike", wi = "Step", J1 = "FromPixels", dh = "RotateWithOffset", ia = "_FusedMatMul", aa = "FusedConv2D", lm = "FusedDepthwiseConv2D"; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function je(...n) { P().getBool("IS_TEST") || P().getBool("PROD") || console.warn(...n); } function Z1(...n) { P().getBool("IS_TEST") || P().getBool("PROD") || console.log(...n); } /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const la = vu("kernelRegistry", () => /* @__PURE__ */ new Map()), _c = vu("gradRegistry", () => /* @__PURE__ */ new Map()); function sp(n, t) { const e = um(n, t); return la.get(e); } function op(n) { return _c.get(n); } function rp(n) { const t = la.entries(), e = []; for (; ; ) { const { done: s, value: o } = t.next(); if (s) break; const [r, i] = o, [a] = r.split("_"); a === n && e.push(i); } return e; } function cm(n) { const { kernelName: t, backendName: e } = n, s = um(t, e); la.has(s) && je(`The kernel '${t}' for backend '${e}' is already registered`), la.set(s, n); } function Q1(n) { const { kernelName: t } = n; _c.has(t) && P().getBool("DEBUG") && je(`Overriding the gradient for '${t}'`), _c.set(t, n); } function um(n, t) { return `${t}_${n}`; } /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function hm(n) { return n instanceof Float32Array || n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray; } /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Fs = ( // tslint:disable-next-line b1 || y1 ); function Fl(n) { return Fs.fromString(n, !0, 16); } const dm = Fl("c3a5c85c97cb3127"), As = Fl("b492b66fbe98f273"), Te = Fl("9ae16a3b2f90404f"); function Lc(n) { return n.xor(n.shru(47)); } function pm(n, t, e) { const s = n.slice(t, t + e); return Fs.fromBytes(Array.from(s), !0, !0); } function Pt(n, t) { return pm(n, t, 8); } function ip(n, t) { return pm(n, t, 4); } function ue(n, t) { return t === 0 ? n : n.shru(t).or(n.shl(64 - t)); } function cs(n, t, e = Fl("9ddfea08eb382d69")) { let s = n.xor(t).mul(e); s = s.xor(s.shru(47)); let o = t.xor(s).mul(e); return o = o.xor(o.shru(47)), o = o.mul(e), o; } function tw(n, t, e, s, o, r) { o = o.add(n), r = ue(r.add(o).add(s), 21); const i = o; return o = o.add(t), o = o.add(e), r = r.add(ue(o, 44)), [o.add(s), r.add(i)]; } function Gi(n, t, e, s) { return tw(Pt(n, t), Pt(n, t + 8), Pt(n, t + 16), Pt(n, t + 24), e, s); } function ew(n, t = n.length) { if (t >= 8) { const e = Te.add(t * 2), s = Pt(n, 0).add(Te), o = Pt(n, t - 8), r = ue(o, 37).mul(e).add(s), i = ue(s, 25).add(o).mul(e); return cs(r, i, e); } if (t >= 4) { const e = Te.add(t * 2), s = ip(n, 0); return cs(s.shl(3).add(t), ip(n, t - 4), e); } if (t > 0) { const e = n[0], s = n[t >> 1], o = n[t - 1], r = e + (s << 8), i = t + (o << 2); return Lc(Te.mul(r).xor(dm.mul(i))).mul(Te); } return Te; } function nw(n, t = n.length) { const e = Te.add(t * 2), s = Pt(n, 0).mul(As), o = Pt(n, 8), r = Pt(n, t - 8).mul(e), i = Pt(n, t - 16).mul(Te); return cs(ue(s.add(o), 43).add(ue(r, 30)).add(i), s.add(ue(o.add(Te), 18)).add(r), e); } function sw(n, t = n.length) { const e = Te.add(t * 2), s = Pt(n, 0).mul(Te), o = Pt(n, 8), r = Pt(n, t - 8).mul(e), i = Pt(n, t - 16).mul(Te), a = ue(s.add(o), 43).add(ue(r, 30)).add(i), l = cs(a, s.add(ue(o.add(Te), 18)).add(r), e), c = Pt(n, 16).mul(e), u = Pt(n, 24), h = a.add(Pt(n, t - 32)).mul(e), d = l.add(Pt(n, t - 24)).mul(e); return cs(ue(c.add(u), 43).add(ue(h, 30)).add(d), c.add(ue(u.add(s), 18)).add(h), e); } function ow(n, t = n.length) { const e = Fs.fromNumber(81, !0); if (t <= 32) return t <= 16 ? ew(n, t) : nw(n, t); if (t <= 64) return sw(n, t); let s = e, o = e.mul(As).add(113), r = Lc(o.mul(Te).add(113)).mul(Te), i = [Fs.UZERO, Fs.UZERO], a = [Fs.UZERO, Fs.UZERO]; s = s.mul(Te).add(Pt(n, 0)); let l = 0; const c = (t - 1 >> 6) * 64, u = c + (t - 1 & 63) - 63; do s = ue(s.add(o).add(i[0]).add(Pt(n, l + 8)), 37).mul(As), o = ue(o.add(i[1]).add(Pt(n, l + 48)), 42).mul(As), s = s.xor(a[1]), o = o.add(i[0]).add(Pt(n, l + 40)), r = ue(r.add(a[0]), 33).mul(As), i = Gi(n, l, i[1].mul(As), s.add(a[0])), a = Gi(n, l + 32, r.add(a[1]), o.add(Pt(n, l + 16))), [r, s] = [s, r], l += 64; while (l !== c); const h = As.add(r.and(255).shl(1)); return l = u, a[0] = a[0].add(t - 1 & 63), i[0] = i[0].add(a[0]), a[0] = a[0].add(i[0]), s = ue(s.add(o).add(i[0]).add(Pt(n, l + 8)), 37).mul(h), o = ue(o.add(i[1]).add(Pt(n, l + 48)), 42).mul(h), s = s.xor(a[1].mul(9)), o = o.add(i[0].mul(9).add(Pt(n, l + 40))), r = ue(r.add(a[0]), 33).mul(h), i = Gi(n, l, i[1].mul(h), s.add(a[0])), a = Gi(n, l + 32, r.add(a[1]), o.add(Pt(n, l + 16))), [r, s] = [s, r], cs(cs(i[0], a[0], h).add(Lc(o).mul(dm)).add(r), cs(i[1], a[1], h).add(s), h); } /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ws(n, t) { return t === "string" ? us(n) : so([n], t); } function rw(n, t) { return n instanceof Float32Array && t === "float32" || n instanceof Int32Array && t === "int32" || n instanceof Uint8Array && t === "bool"; } function so(n, t) { if (t === "string") throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(n) && (n = Ws(n)), P().getBool("DEBUG") && M1(n, t), rw(n, t)) return n; if (t == null || t === "float32" || t === "complex64") return new Float32Array(n); if (t === "int32") return new Int32Array(n); if (t === "bool") { const e = new Uint8Array(n.length); for (let s = 0; s < e.length; ++s) Math.round(n[s]) !== 0 && (e[s] = 1); return e; } else throw new Error(`Unknown data type ${t}`); } function Fe() { return P().platform.now(); } function us(n, t = "utf-8") { return t = t || "utf-8", P().platform.encode(n, t); } function ps(n, t = "utf-8") { return t = t || "utf-8", P().platform.decode(n, t); } function rn(n) { return P().platform.isTypedArray != null ? P().platform.isTypedArray(n) : hm(n); } function Ws(n, t = [], e = !1) { if (t == null && (t = []), typeof n == "boolean" || typeof n == "number" || typeof n == "string" || ku(n) || n == null || rn(n) && e) t.push(n); else if (Array.isArray(n) || rn(n)) for (let s = 0; s < n.length; ++s) Ws(n[s], t, e); else { let s = -1; for (const o of Object.keys(n)) /^([1-9]+[0-9]*|0)$/.test(o) && (s = Math.max(s, Number(o))); for (let o = 0; o <= s; o++) Ws(n[o], t, e); } return t; } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class iw { constructor(t, e) { this.backendTimer = t, this.logger = e, e == null && (this.logger = new lw()); } profileKernel(t, e, s) { let o; const r = () => { o = s(); }; let i; const a = Fe(); if (this.backendTimer.timerAvailable()) i = this.backendTimer.time(r); else { r(); for (const c of o) c.dataSync(); i = Promise.resolve({ kernelMs: Fe() - a }); } if (P().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let c = 0; c < o.length; c++) { const u = o[c]; u.data().then((h) => { aw(h, u.dtype, t); }); } return { kernelName: t, outputs: o, inputs: e, timeMs: i.then((c) => c.kernelMs), extraInfo: i.then((c) => c.getExtraProfileInfo != null ? c.getExtraProfileInfo() : "") }; } logKernelProfile(t) { const { kernelName: e, outputs: s, timeMs: o, inputs: r, extraInfo: i } = t; s.forEach((a) => { Promise.all([a.data(), o, i]).then((l) => { this.logger.logKernelProfile(e, a, l[0], l[1], r, l[2]); }); }); } } function aw(n, t, e) { if (t !== "float32") return !1; for (let s = 0; s < n.length; s++) { const o = n[s]; if (isNaN(o) || !isFinite(o)) return console.warn(`Found ${o} in the result of '${e}'`), !0; } return !1; } class lw { logKernelProfile(t, e, s, o, r, i) { const a = typeof o == "number" ? wo(`${o}ms`, 9) : o.error, l = wo(t, 25), c = e.rank, u = e.size, h = wo(e.shape.toString(), 14); let d = ""; for (const p in r) { const f = r[p]; if (f != null) { const m = f.shape || e.shape, g = m.length; d += `${p}: ${g}D ${g > 0 ? m : ""} `; } } console.log(`%c${l} %c${a} %c${c}D ${h} %c${u} %c${d} %c${i}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } } /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function cw(n, t, e) { const s = {}, o = {}; for (let l = 0; l < t.length; l++) s[t[l].id] = !0; for (let l = 0; l < n.length; l++) { const c = n[l], u = c.inputs; for (const h in u) { const d = u[h]; let p = !1; for (let f = 0; f < t.length; f++) if (s[d.id]) { c.outputs.forEach((m) => s[m.id] = !0), p = !0, o[c.id] = !0; break; } if (p) break; } } const r = {}; r[e.id] = !0; const i = {}; for (let l = n.length - 1; l >= 0; l--) { const c = n[l], u = c.inputs; for (let h = 0; h < c.outputs.length; h++) if (r[c.outputs[h].id]) { for (const d in u) r[u[d].id] = !0, i[c.id] = !0; break; } } const a = []; for (let l = 0; l < n.length; l++) { const c = n[l]; if (o[c.id] && i[c.id]) { const u = {}; for (const d in c.inputs) { const p = c.inputs[d]; s[p.id] && (u[d] = p); } const h = Object.assign({}, c); h.inputs = u, h.outputs = c.outputs, a.push(h); } } return a; } function uw(n, t, e, s) { for (let o = t.length - 1; o >= 0; o--) { const r = t[o], i = []; if (r.outputs.forEach((l) => { const c = n[l.id]; c != null ? i.push(c) : i.push(null); }), r.gradient == null) throw new Error(`Cannot compute gradient: gradient function not found for ${r.kernelName}.`); const a = r.gradient(i); for (const l in r.inputs) { if (!(l in a)) throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`); const c = e(() => a[l]()); if (c.dtype !== "float32") throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`); const u = r.inputs[l]; if (!Et(c.shape, u.shape)) throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${u.shape}'`); if (n[u.id] == null) n[u.id] = c; else { const h = n[u.id]; n[u.id] = s(h, c), h.dispose(); } } } } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const ap = 20, tr = 3, dc = 7; function hw(n, t, e, s) { const o = lt(t), r = dw(n, t, e, o), i = t.length, a = sa(n, t, e, o, r), l = ["Tensor"]; return s && (l.push(` dtype: ${e}`), l.push(` rank: ${i}`), l.push(` shape: [${t}]`), l.push(" values:")), l.push(a.map((c) => " " + c).join(` `)), l.join(` `); } function dw(n, t, e, s) { const o = G(t), r = s[s.length - 1], i = new Array(r).fill(0), a = t.length, l = e === "complex64" ? rr(n) : n; if (a > 1) for (let c = 0; c < o / r; c++) { const u = c * r; for (let h = 0; h < r; h++) i[h] = Math.max(i[h], or(l[u + h], 0, e).length); } return i; } function or(n, t, e) { let s; return Array.isArray(n) ? s = `${parseFloat(n[0].toFixed(dc))} + ${parseFloat(n[1].toFixed(dc))}j` : vr(n) ? s = `'${n}'` : e === "bool" ? s = fm(n) : s = parseFloat(n.toFixed(dc)).toString(), wo(s, t); } function fm(n) { return n === 0 ? "false" : "true"; } function sa(n, t, e, s, o, r = !0) { const i = e === "complex64" ? 2 : 1, a = t[0], l = t.length; if (l === 0) { if (e === "complex64") { const m = rr(n); return [or(m[0], 0, e)]; } return e === "bool" ? [fm(n[0])] : [n[0].toString()]; } if (l === 1) { if (a > ap) { const g = tr * i; let x = Array.from(n.slice(0, g)), b = Array.from(n.slice((a - tr) * i, a * i)); return e === "complex64" && (x = rr(x), b = rr(b)), [ "[" + x.map((w, y) => or(w, o[y], e)).join(", ") + ", ..., " + b.map((w, y) => or(w, o[a - tr + y], e)).join(", ") + "]" ]; } return [ "[" + (e === "complex64" ? rr(n) : Array.from(n)).map((g, x) => or(g, o[x], e)).join(", ") + "]" ]; } const c = t.slice(1), u = s.slice(1), h = s[0] * i, d = []; if (a > ap) { for (let m = 0; m < tr; m++) { const g = m * h, x = g + h; d.push(...sa( n.slice(g, x), c, e, u, o, !1 /* isLast */ )); } d.push("..."); for (let m = a - tr; m < a; m++) { const g = m * h, x = g + h; d.push(...sa( n.slice(g, x), c, e, u, o, m === a - 1 /* isLast */ )); } } else for (let m = 0; m < a; m++) { const g = m * h, x = g + h; d.push(...sa( n.slice(g, x), c, e, u, o, m === a - 1 /* isLast */ )); } const p = l === 2 ? "," : ""; d[0] = "[" + (a > 0 ? d[0] + p : ""); for (let m = 1; m < d.length - 1; m++) d[m] = " " + d[m] + p; let f = `, `; for (let m = 2; m < l; m++) f += ` `; return d[d.length - 1] = " " + d[d.length - 1] + "]" + (r ? "" : f), d; } function rr(n) { const t = []; for (let e = 0; e < n.length; e += 2) t.push([n[e], n[e + 1]]); return t; } /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software