@brandvc/webgazer2
Version:
1,699 lines • 2.32 MB
JavaScript
/*!
WebGazer.js: Democratizing Webcam Eye Tracking on the Browser
Copyright (c) 2016, Brown WebGazer Team
Licensed under GPLv3. Companies with a valuation of less than $1M can use WebGazer.js under LGPLv3.
*/
var B$ = Object.defineProperty;
var V$ = (n, e, t) => e in n ? B$(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var Re = (n, e, t) => V$(n, typeof e != "symbol" ? e + "" : e, t);
function W$(n, e) {
for (var t = 0; t < e.length; t++) {
const s = e[t];
if (typeof s != "string" && !Array.isArray(s)) {
for (const r in s)
if (r !== "default" && !(r in n)) {
const o = Object.getOwnPropertyDescriptor(s, r);
o && Object.defineProperty(n, r, o.get ? o : {
enumerable: !0,
get: () => s[r]
});
}
}
}
return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
}
/**
* @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 U$ = 1e-7, G$ = 1e-4;
class Ky {
constructor(e, t) {
this.backend = e, this.dataMover = t, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0;
}
get(e) {
return this.data.has(e) || this.dataMover.moveData(this.backend, e), this.data.get(e);
}
set(e, t) {
this.dataIdsCount++, this.data.set(e, t);
}
has(e) {
return this.data.has(e);
}
delete(e) {
return this.dataIdsCount--, this.data.delete(e);
}
numDataIds() {
return this.dataIdsCount;
}
}
class bp {
refCount(e) {
return Bn("refCount");
}
incRef(e) {
return Bn("incRef");
}
timerAvailable() {
return !0;
}
time(e) {
return Bn("time");
}
read(e) {
return Bn("read");
}
readSync(e) {
return Bn("readSync");
}
readToGPU(e, t) {
return Bn("readToGPU");
}
numDataIds() {
return Bn("numDataIds");
}
disposeData(e, t) {
return Bn("disposeData");
}
write(e, t, s) {
return Bn("write");
}
move(e, t, s, r, o) {
return Bn("move");
}
memory() {
return Bn("memory");
}
/** Returns the highest precision for floats in bits (e.g. 16 or 32) */
floatPrecision() {
return Bn("floatPrecision");
}
/** Returns the smallest representable number. */
epsilon() {
return this.floatPrecision() === 32 ? U$ : G$;
}
dispose() {
return Bn("dispose");
}
}
function Bn(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 H$(n) {
let e = n.length, t = 0;
for (; e > 0; )
t = Math.random() * e | 0, e--, Ro(n, e, t);
}
function oo(n, e, t) {
return Math.max(n, Math.min(e, t));
}
function xp(n) {
return n % 2 === 0 ? n : n + 1;
}
function Ro(n, e, t) {
const s = n[e];
n[e] = n[t], n[t] = s;
}
function j$(n) {
let e = 0;
for (let t = 0; t < n.length; t++)
e += n[t];
return e;
}
function N(n, e) {
if (!n)
throw new Error(typeof e == "string" ? e : e());
}
function Pn(n, e, t = "") {
N(je(n, e), () => t + ` Shapes ${n} and ${e} must match`);
}
function pa(n) {
N(n != null, () => "The input to the tensor constructor must be a non-null value.");
}
function Ko(n, e = [], t = !1) {
if (e == null && (e = []), Array.isArray(n) || Hs(n) && !t)
for (let s = 0; s < n.length; ++s)
Ko(n[s], e, t);
else
e.push(n);
return e;
}
function Z(n) {
if (n.length === 0)
return 1;
let e = n[0];
for (let t = 1; t < n.length; t++)
e *= n[t];
return e;
}
function je(n, e) {
if (n === e)
return !0;
if (n == null || e == null || n.length !== e.length)
return !1;
for (let t = 0; t < n.length; t++)
if (n[t] !== e[t])
return !1;
return !0;
}
function Xo(n) {
return n % 1 === 0;
}
function gd(n) {
const e = Math.ceil(Math.sqrt(n));
return [e, Math.ceil(n / e)];
}
function Bo(n, e) {
return e <= n.length ? n : n + " ".repeat(e - n.length);
}
function Zg(n, e = (r) => 0, t, s = setTimeout) {
return new Promise((r, o) => {
let a = 0;
const i = () => {
if (n()) {
r();
return;
}
a++;
const l = e(a);
if (t != null && a >= t) {
o();
return;
}
s(i, l);
};
i();
});
}
function Xy(n, e) {
let t = 1, s = -1;
for (let o = 0; o < n.length; ++o)
if (n[o] >= 0)
t *= n[o];
else if (n[o] === -1) {
if (s !== -1)
throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${o}`);
s = o;
} else if (n[o] < 0)
throw Error(`Shapes can not be < 0. Found ${n[o]} at dim ${o}`);
if (s === -1) {
if (e > 0 && e !== t)
throw Error(`Size(${e}) must match the product of shape ${n}`);
return n;
}
if (t === 0)
throw Error(`Cannot infer the missing size in [${n}] when there are 0 elements`);
if (e % t !== 0)
throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`);
const r = n.slice();
return r[s] = e / t, r;
}
function ze(n, e) {
const t = e.length;
return n = n == null ? e.map((s, r) => r) : [].concat(n), N(n.every((s) => s >= -t && s < t), () => `All values in axis param must be in range [-${t}, ${t}) but got axis ${n}`), N(n.every((s) => Xo(s)), () => `All values in axis param must be integers but got axis ${n}`), n.map((s) => s < 0 ? t + s : s);
}
function Rr(n, e) {
const t = [], s = [], r = e != null && Array.isArray(e) && e.length === 0, o = e == null || r ? null : ze(e, n).sort();
let a = 0;
for (let i = 0; i < n.length; ++i) {
if (o != null) {
if (o[a] === i && n[i] !== 1)
throw new Error(`Can't squeeze axis ${i} since its dim '${n[i]}' is not 1`);
(o[a] == null || o[a] > i) && n[i] === 1 && (t.push(n[i]), s.push(i)), o[a] <= i && a++;
}
n[i] !== 1 && (t.push(n[i]), s.push(i));
}
return { newShape: t, keptDims: s };
}
function Ht(n, e) {
let t = null;
if (n == null || n === "float32")
t = new Float32Array(e);
else if (n === "int32")
t = new Int32Array(e);
else if (n === "bool")
t = new Uint8Array(e);
else
throw new Error(`Unknown data type ${n}`);
return t;
}
function Wt(n, e) {
let t = null;
if (n == null || n === "float32")
t = new Float32Array(e);
else if (n === "int32")
t = new Int32Array(e);
else if (n === "bool")
t = new Uint8Array(e);
else if (n === "string")
t = new Array(e);
else
throw new Error(`Unknown data type ${n}`);
return t;
}
function q$(n, e) {
for (let t = 0; t < n.length; t++) {
const s = n[t];
if (isNaN(s) || !isFinite(s))
throw Error(`A tensor of type ${e} being uploaded contains ${s}.`);
}
}
function K$(n) {
return n === "bool" || n === "complex64" || n === "float32" || n === "int32" || n === "string";
}
function Yy(n, e) {
return !(e === "complex64" || e === "float32" && n !== "complex64" || e === "int32" && n !== "float32" && n !== "complex64" || e === "bool" && n === "bool");
}
function Hs(n) {
return n instanceof Float32Array || n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray;
}
function yd(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 X$(n) {
if (n == null)
return 0;
let e = 0;
return n.forEach((t) => e += t.length), e;
}
function ai(n) {
return typeof n == "string" || n instanceof String;
}
function Y$(n) {
return typeof n == "boolean";
}
function bd(n) {
return typeof n == "number";
}
function ii(n) {
return Array.isArray(n) ? ii(n[0]) : n instanceof Float32Array ? "float32" : n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray ? "int32" : bd(n) ? "float32" : ai(n) ? "string" : Y$(n) ? "bool" : "float32";
}
function xd(n) {
return !!(n && n.constructor && n.call && n.apply);
}
function wd(n, e) {
for (let t = e; t < n; ++t)
if (n % t === 0)
return t;
return n;
}
function Te(n) {
const e = n.length;
if (e < 2)
return [];
const t = new Array(e - 1);
t[e - 2] = n[e - 1];
for (let s = e - 3; s >= 0; --s)
t[s] = t[s + 1] * n[s + 1];
return t;
}
function Zy(n, e, t, s = !1) {
const r = new Array();
if (e.length === 1) {
const o = e[0] * (s ? 2 : 1);
for (let a = 0; a < o; a++)
r[a] = t[n + a];
} else {
const o = e[0], a = e.slice(1), i = a.reduce((l, c) => l * c) * (s ? 2 : 1);
for (let l = 0; l < o; l++)
r[l] = Zy(n + l * i, a, t, s);
}
return r;
}
function us(n, e, t = !1) {
if (n.length === 0)
return e[0];
const s = n.reduce((r, o) => r * o) * (t ? 2 : 1);
if (s === 0)
return [];
if (s !== e.length)
throw new Error(`[${n}] does not match the input size ${e.length}${t ? " for a complex tensor" : ""}.`);
return Zy(0, n, e, t);
}
function wp(n, e) {
const t = sn(n, e);
for (let s = 0; s < t.length; s++)
t[s] = 1;
return t;
}
function sn(n, e) {
if (e == null || e === "float32" || e === "complex64")
return new Float32Array(n);
if (e === "int32")
return new Int32Array(n);
if (e === "bool")
return new Uint8Array(n);
throw new Error(`Unknown data type ${e}`);
}
function Jy(n, e) {
const t = n.reduce((s, r) => s * r, 1);
if (e == null || e === "float32")
return us(n, new Float32Array(t));
if (e === "int32")
return us(n, new Int32Array(t));
if (e === "bool")
return us(n, new Uint8Array(t));
throw new Error(`Unknown data type ${e}`);
}
function Qy(n) {
n.forEach((e) => {
N(Number.isInteger(e) && e >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${n}].`);
});
}
function Vs(n, e, t) {
if (e === 0)
return 0;
if (e === 1)
return n[0];
let s = n[n.length - 1];
for (let r = 0; r < n.length - 1; ++r)
s += t[r] * n[r];
return s;
}
function fa(n, e, t) {
if (e === 0)
return [];
if (e === 1)
return [n];
const s = new Array(e);
for (let r = 0; r < s.length - 1; ++r)
s[r] = Math.floor(n / t[r]), n -= s[r] * t[r];
return s[s.length - 1] = n, s;
}
function Yo(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 Jg = "tfjsflags";
class Z$ {
// tslint:disable-next-line: no-any
constructor(e) {
this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = J$, this.populateURLFlags();
}
setPlatform(e, t) {
this.platform != null && (K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t;
}
registerFlag(e, t, s) {
if (this.flagRegistry[e] = { evaluationFn: t, setHook: s }, this.urlFlags[e] != null) {
const r = this.urlFlags[e];
K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${r}.`), this.set(e, r);
}
}
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];
const t = this.evaluateFlag(e);
if (Yo(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;
}
// For backwards compatibility.
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 > "u" || typeof this.global.location > "u" || typeof this.global.location.search > "u")
return;
const e = this.getQueryParams(this.global.location.search);
Jg in e && e[Jg].split(",").forEach((s) => {
const [r, o] = s.split(":");
this.urlFlags[r] = eC(r, o);
});
}
}
function J$(n) {
const e = {};
return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (t, ...s) => (Q$(e, s[0], s[1]), s.join("="))), e;
}
function Q$(n, e, t) {
n[decodeURIComponent(e)] = decodeURIComponent(t || "");
}
function eC(n, 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 ${n}.`);
}
function K() {
return e1;
}
let e1 = null;
function tC(n) {
e1 = 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 Gh;
function t1() {
if (Gh == 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");
Gh = n;
}
return Gh;
}
function nC() {
const n = t1();
return n._tfGlobals == null && (n._tfGlobals = /* @__PURE__ */ new Map()), n._tfGlobals;
}
function vp(n, e) {
const t = nC();
if (t.has(n))
return t.get(n);
{
const s = e();
return t.set(n, s), t.get(n);
}
}
const Gc = "Abs", li = "Acos", ci = "Acosh", ma = "Add", Hc = "AddN", Ip = "All", $p = "Any", jc = "ArgMax", qc = "ArgMin", ui = "Asin", hi = "Asinh", di = "Atan", pi = "Atanh", fi = "Atan2", Kc = "AvgPool", Cp = "AvgPoolGrad", Xc = "AvgPool3D", Sp = "AvgPool3DGrad", Yc = "BatchMatMul", Zc = "BatchToSpaceND", Np = "Bincount", sC = "BroadcastTo", kp = "BroadcastArgs", mi = "Cast", gi = "Ceil", yi = "ClipByValue", Tp = "Complex", Jc = "ComplexAbs", Qc = "Concat", eu = "Conv2D", Ep = "Conv2DBackpropFilter", tu = "Conv2DBackpropInput", nu = "Conv3D", Dp = "Conv3DBackpropFilterV2", Ap = "Conv3DBackpropInputV2", bi = "Cos", xi = "Cosh", Rp = "Cumprod", su = "Cumsum", Fp = "CropAndResize", _p = "DenseBincount", Op = "DepthToSpace", ru = "DepthwiseConv2dNative", Lp = "DepthwiseConv2dNativeBackpropFilter", Pp = "DepthwiseConv2dNativeBackpropInput", zp = "Diag", ou = "Dilation2D", vd = "Dilation2DBackpropInput", Id = "Dilation2DBackpropFilter", wi = "RealDiv", Mp = "Einsum", vi = "Elu", Bp = "EluGrad", Ii = "Erf", au = "Equal", $i = "Exp", iu = "ExpandDims", Ci = "Expm1", Vp = "FFT", Wp = "Fill", Up = "FlipLeftRight", Si = "Floor", Ni = "FloorDiv", lu = "FusedBatchNorm", cu = "GatherV2", Gp = "GatherNd", uu = "Greater", ki = "GreaterEqual", Ti = "Identity", Hp = "IFFT", jp = "Imag", Ei = "IsFinite", Di = "IsInf", Ai = "IsNan", hu = "LeakyRelu", du = "Less", pu = "LessEqual", qp = "LinSpace", Ri = "Log", Fi = "Log1p", fu = "LogicalAnd", mu = "LogicalNot", gu = "LogicalOr", rC = "LogSoftmax", yu = "LRN", Kp = "LRNGrad", bu = "Max", _i = "Maximum", xu = "MaxPool", Xp = "MaxPoolGrad", wu = "MaxPool3D", Yp = "MaxPool3DGrad", Zp = "MaxPoolWithArgmax", vu = "Mean", Iu = "Min", Oi = "Minimum", $u = "MirrorPad", Li = "Mod", Jp = "Multinomial", Pi = "Multiply", Cu = "Neg", Su = "NotEqual", Qp = "NonMaxSuppressionV3", ef = "NonMaxSuppressionV4", tf = "NonMaxSuppressionV5", Nu = "OnesLike", ku = "OneHot", Tu = "Pack", Eu = "PadV2", zi = "Pow", Du = "Prelu", Au = "Prod", nf = "RaggedGather", sf = "RaggedTensorToTensor", rf = "Range", of = "Real", Mi = "Reciprocal", Bi = "Relu", Ru = "Reshape", Fu = "ResizeNearestNeighbor", af = "ResizeNearestNeighborGrad", _u = "ResizeBilinear", lf = "ResizeBilinearGrad", Vi = "Relu6", Ou = "Reverse", Wi = "Round", Ui = "Rsqrt", cf = "ScatterNd", uf = "SearchSorted", Lu = "Select", Gi = "Selu", Pu = "Slice", Hi = "Sin", ji = "Sinh", qi = "Sign", Ki = "Sigmoid", Xi = "Softplus", Yi = "Sqrt", zu = "Sum", Mu = "SpaceToBatchND", Bu = "SplitV", Vu = "Softmax", hf = "SparseFillEmptyRows", df = "SparseReshape", pf = "SparseSegmentMean", ff = "SparseSegmentSum", mf = "SparseToDense", Zi = "SquaredDifference", gf = "Square", yf = "StridedSlice", bf = "StringNGrams", xf = "StringSplit", wf = "StringToHashBucketFast", Ji = "Sub", Qi = "Tan", el = "Tanh", tl = "Tile", vf = "TopK", If = "Transform", Vo = "Transpose", $f = "Unique", Wu = "Unpack", Uu = "UnsortedSegmentSum", Gu = "ZerosLike", nl = "Step", $d = "FromPixels", Cf = "RotateWithOffset", ic = "_FusedMatMul", lc = "FusedConv2D", cc = "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 Vn(...n) {
K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(...n);
}
function oC(...n) {
K().getBool("IS_TEST") || K().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 uc = vp("kernelRegistry", () => /* @__PURE__ */ new Map()), Cd = vp("gradRegistry", () => /* @__PURE__ */ new Map());
function Sd(n, e) {
const t = s1(n, e);
return uc.get(t);
}
function Qg(n) {
return Cd.get(n);
}
function e0(n) {
const e = uc.entries(), t = [];
for (; ; ) {
const { done: s, value: r } = e.next();
if (s)
break;
const [o, a] = r, [i] = o.split("_");
i === n && t.push(a);
}
return t;
}
function n1(n) {
const { kernelName: e, backendName: t } = n, s = s1(e, t);
uc.has(s) && Vn(`The kernel '${e}' for backend '${t}' is already registered`), uc.set(s, n);
}
function aC(n) {
const { kernelName: e } = n;
Cd.has(e) && K().getBool("DEBUG") && Vn(`Overriding the gradient for '${e}'`), Cd.set(e, n);
}
function s1(n, e) {
return `${e}_${n}`;
}
var ss = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function r1(n) {
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
function iC(n) {
if (n.__esModule) return n;
var e = n.default;
if (typeof e == "function") {
var t = function s() {
return this instanceof s ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
};
t.prototype = e.prototype;
} else t = {};
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(n).forEach(function(s) {
var r = Object.getOwnPropertyDescriptor(n, s);
Object.defineProperty(t, s, r.get ? r : {
enumerable: !0,
get: function() {
return n[s];
}
});
}), t;
}
var o1 = dt, rs = null;
try {
rs = 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 {
}
function dt(n, e, t) {
this.low = n | 0, this.high = e | 0, this.unsigned = !!t;
}
dt.prototype.__isLong__;
Object.defineProperty(dt.prototype, "__isLong__", { value: !0 });
function zn(n) {
return (n && n.__isLong__) === !0;
}
dt.isLong = zn;
var t0 = {}, n0 = {};
function mo(n, e) {
var t, s, r;
return e ? (n >>>= 0, (r = 0 <= n && n < 256) && (s = n0[n], s) ? s : (t = pt(n, (n | 0) < 0 ? -1 : 0, !0), r && (n0[n] = t), t)) : (n |= 0, (r = -128 <= n && n < 128) && (s = t0[n], s) ? s : (t = pt(n, n < 0 ? -1 : 0, !1), r && (t0[n] = t), t));
}
dt.fromInt = mo;
function os(n, e) {
if (isNaN(n))
return e ? Qr : as;
if (e) {
if (n < 0)
return Qr;
if (n >= a1)
return c1;
} else {
if (n <= -r0)
return En;
if (n + 1 >= r0)
return l1;
}
return n < 0 ? os(-n, e).neg() : pt(n % Zo | 0, n / Zo | 0, e);
}
dt.fromNumber = os;
function pt(n, e, t) {
return new dt(n, e, t);
}
dt.fromBits = pt;
var hc = Math.pow;
function Sf(n, e, t) {
if (n.length === 0)
throw Error("empty string");
if (n === "NaN" || n === "Infinity" || n === "+Infinity" || n === "-Infinity")
return as;
if (typeof e == "number" ? (t = e, e = !1) : e = !!e, t = t || 10, t < 2 || 36 < t)
throw RangeError("radix");
var s;
if ((s = n.indexOf("-")) > 0)
throw Error("interior hyphen");
if (s === 0)
return Sf(n.substring(1), e, t).neg();
for (var r = os(hc(t, 8)), o = as, a = 0; a < n.length; a += 8) {
var i = Math.min(8, n.length - a), l = parseInt(n.substring(a, a + i), t);
if (i < 8) {
var c = os(hc(t, i));
o = o.mul(c).add(os(l));
} else
o = o.mul(r), o = o.add(os(l));
}
return o.unsigned = e, o;
}
dt.fromString = Sf;
function Rs(n, e) {
return typeof n == "number" ? os(n, e) : typeof n == "string" ? Sf(n, e) : pt(n.low, n.high, typeof e == "boolean" ? e : n.unsigned);
}
dt.fromValue = Rs;
var s0 = 65536, lC = 1 << 24, Zo = s0 * s0, a1 = Zo * Zo, r0 = a1 / 2, o0 = mo(lC), as = mo(0);
dt.ZERO = as;
var Qr = mo(0, !0);
dt.UZERO = Qr;
var zo = mo(1);
dt.ONE = zo;
var i1 = mo(1, !0);
dt.UONE = i1;
var Nd = mo(-1);
dt.NEG_ONE = Nd;
var l1 = pt(-1, 2147483647, !1);
dt.MAX_VALUE = l1;
var c1 = pt(-1, -1, !0);
dt.MAX_UNSIGNED_VALUE = c1;
var En = pt(0, -2147483648, !1);
dt.MIN_VALUE = En;
var pe = dt.prototype;
pe.toInt = function() {
return this.unsigned ? this.low >>> 0 : this.low;
};
pe.toNumber = function() {
return this.unsigned ? (this.high >>> 0) * Zo + (this.low >>> 0) : this.high * Zo + (this.low >>> 0);
};
pe.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(En)) {
var t = os(e), s = this.div(t), r = s.mul(t).sub(this);
return s.toString(e) + r.toInt().toString(e);
} else
return "-" + this.neg().toString(e);
for (var o = os(hc(e, 6), this.unsigned), a = this, i = ""; ; ) {
var l = a.div(o), c = a.sub(l.mul(o)).toInt() >>> 0, u = c.toString(e);
if (a = l, a.isZero())
return u + i;
for (; u.length < 6; )
u = "0" + u;
i = "" + u + i;
}
};
pe.getHighBits = function() {
return this.high;
};
pe.getHighBitsUnsigned = function() {
return this.high >>> 0;
};
pe.getLowBits = function() {
return this.low;
};
pe.getLowBitsUnsigned = function() {
return this.low >>> 0;
};
pe.getNumBitsAbs = function() {
if (this.isNegative())
return this.eq(En) ? 64 : this.neg().getNumBitsAbs();
for (var e = this.high != 0 ? this.high : this.low, t = 31; t > 0 && !(e & 1 << t); t--)
;
return this.high != 0 ? t + 33 : t + 1;
};
pe.isZero = function() {
return this.high === 0 && this.low === 0;
};
pe.eqz = pe.isZero;
pe.isNegative = function() {
return !this.unsigned && this.high < 0;
};
pe.isPositive = function() {
return this.unsigned || this.high >= 0;
};
pe.isOdd = function() {
return (this.low & 1) === 1;
};
pe.isEven = function() {
return (this.low & 1) === 0;
};
pe.equals = function(e) {
return zn(e) || (e = Rs(e)), this.unsigned !== e.unsigned && this.high >>> 31 === 1 && e.high >>> 31 === 1 ? !1 : this.high === e.high && this.low === e.low;
};
pe.eq = pe.equals;
pe.notEquals = function(e) {
return !this.eq(
/* validates */
e
);
};
pe.neq = pe.notEquals;
pe.ne = pe.notEquals;
pe.lessThan = function(e) {
return this.comp(
/* validates */
e
) < 0;
};
pe.lt = pe.lessThan;
pe.lessThanOrEqual = function(e) {
return this.comp(
/* validates */
e
) <= 0;
};
pe.lte = pe.lessThanOrEqual;
pe.le = pe.lessThanOrEqual;
pe.greaterThan = function(e) {
return this.comp(
/* validates */
e
) > 0;
};
pe.gt = pe.greaterThan;
pe.greaterThanOrEqual = function(e) {
return this.comp(
/* validates */
e
) >= 0;
};
pe.gte = pe.greaterThanOrEqual;
pe.ge = pe.greaterThanOrEqual;
pe.compare = function(e) {
if (zn(e) || (e = Rs(e)), this.eq(e))
return 0;
var t = this.isNegative(), s = e.isNegative();
return t && !s ? -1 : !t && s ? 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;
};
pe.comp = pe.compare;
pe.negate = function() {
return !this.unsigned && this.eq(En) ? En : this.not().add(zo);
};
pe.neg = pe.negate;
pe.add = function(e) {
zn(e) || (e = Rs(e));
var t = this.high >>> 16, s = this.high & 65535, r = this.low >>> 16, o = this.low & 65535, a = e.high >>> 16, i = e.high & 65535, l = e.low >>> 16, c = e.low & 65535, u = 0, h = 0, d = 0, p = 0;
return p += o + c, d += p >>> 16, p &= 65535, d += r + l, h += d >>> 16, d &= 65535, h += s + i, u += h >>> 16, h &= 65535, u += t + a, u &= 65535, pt(d << 16 | p, u << 16 | h, this.unsigned);
};
pe.subtract = function(e) {
return zn(e) || (e = Rs(e)), this.add(e.neg());
};
pe.sub = pe.subtract;
pe.multiply = function(e) {
if (this.isZero())
return as;
if (zn(e) || (e = Rs(e)), rs) {
var t = rs.mul(
this.low,
this.high,
e.low,
e.high
);
return pt(t, rs.get_high(), this.unsigned);
}
if (e.isZero())
return as;
if (this.eq(En))
return e.isOdd() ? En : as;
if (e.eq(En))
return this.isOdd() ? En : as;
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(o0) && e.lt(o0))
return os(this.toNumber() * e.toNumber(), this.unsigned);
var s = this.high >>> 16, r = this.high & 65535, o = this.low >>> 16, a = this.low & 65535, i = e.high >>> 16, l = e.high & 65535, c = e.low >>> 16, u = e.low & 65535, h = 0, d = 0, p = 0, f = 0;
return f += a * u, p += f >>> 16, f &= 65535, p += o * u, d += p >>> 16, p &= 65535, p += a * c, d += p >>> 16, p &= 65535, d += r * u, h += d >>> 16, d &= 65535, d += o * c, h += d >>> 16, d &= 65535, d += a * l, h += d >>> 16, d &= 65535, h += s * u + r * c + o * l + a * i, h &= 65535, pt(p << 16 | f, h << 16 | d, this.unsigned);
};
pe.mul = pe.multiply;
pe.divide = function(e) {
if (zn(e) || (e = Rs(e)), e.isZero())
throw Error("division by zero");
if (rs) {
if (!this.unsigned && this.high === -2147483648 && e.low === -1 && e.high === -1)
return this;
var t = (this.unsigned ? rs.div_u : rs.div_s)(
this.low,
this.high,
e.low,
e.high
);
return pt(t, rs.get_high(), this.unsigned);
}
if (this.isZero())
return this.unsigned ? Qr : as;
var s, r, o;
if (this.unsigned) {
if (e.unsigned || (e = e.toUnsigned()), e.gt(this))
return Qr;
if (e.gt(this.shru(1)))
return i1;
o = Qr;
} else {
if (this.eq(En)) {
if (e.eq(zo) || e.eq(Nd))
return En;
if (e.eq(En))
return zo;
var a = this.shr(1);
return s = a.div(e).shl(1), s.eq(as) ? e.isNegative() ? zo : Nd : (r = this.sub(e.mul(s)), o = s.add(r.div(e)), o);
} else if (e.eq(En))
return this.unsigned ? Qr : as;
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();
o = as;
}
for (r = this; r.gte(e); ) {
s = Math.max(1, Math.floor(r.toNumber() / e.toNumber()));
for (var i = Math.ceil(Math.log(s) / Math.LN2), l = i <= 48 ? 1 : hc(2, i - 48), c = os(s), u = c.mul(e); u.isNegative() || u.gt(r); )
s -= l, c = os(s, this.unsigned), u = c.mul(e);
c.isZero() && (c = zo), o = o.add(c), r = r.sub(u);
}
return o;
};
pe.div = pe.divide;
pe.modulo = function(e) {
if (zn(e) || (e = Rs(e)), rs) {
var t = (this.unsigned ? rs.rem_u : rs.rem_s)(
this.low,
this.high,
e.low,
e.high
);
return pt(t, rs.get_high(), this.unsigned);
}
return this.sub(this.div(e).mul(e));
};
pe.mod = pe.modulo;
pe.rem = pe.modulo;
pe.not = function() {
return pt(~this.low, ~this.high, this.unsigned);
};
pe.and = function(e) {
return zn(e) || (e = Rs(e)), pt(this.low & e.low, this.high & e.high, this.unsigned);
};
pe.or = function(e) {
return zn(e) || (e = Rs(e)), pt(this.low | e.low, this.high | e.high, this.unsigned);
};
pe.xor = function(e) {
return zn(e) || (e = Rs(e)), pt(this.low ^ e.low, this.high ^ e.high, this.unsigned);
};
pe.shiftLeft = function(e) {
return zn(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? pt(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : pt(0, this.low << e - 32, this.unsigned);
};
pe.shl = pe.shiftLeft;
pe.shiftRight = function(e) {
return zn(e) && (e = e.toInt()), (e &= 63) === 0 ? this : e < 32 ? pt(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : pt(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned);
};
pe.shr = pe.shiftRight;
pe.shiftRightUnsigned = function(e) {
if (zn(e) && (e = e.toInt()), e &= 63, e === 0)
return this;
var t = this.high;
if (e < 32) {
var s = this.low;
return pt(s >>> e | t << 32 - e, t >>> e, this.unsigned);
} else return e === 32 ? pt(t, 0, this.unsigned) : pt(t >>> e - 32, 0, this.unsigned);
};
pe.shru = pe.shiftRightUnsigned;
pe.shr_u = pe.shiftRightUnsigned;
pe.toSigned = function() {
return this.unsigned ? pt(this.low, this.high, !1) : this;
};
pe.toUnsigned = function() {
return this.unsigned ? this : pt(this.low, this.high, !0);
};
pe.toBytes = function(e) {
return e ? this.toBytesLE() : this.toBytesBE();
};
pe.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
];
};
pe.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
];
};
dt.fromBytes = function(e, t, s) {
return s ? dt.fromBytesLE(e, t) : dt.fromBytesBE(e, t);
};
dt.fromBytesLE = function(e, t) {
return new dt(
e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24,
e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24,
t
);
};
dt.fromBytesBE = function(e, t) {
return new dt(
e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7],
e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3],
t
);
};
const u1 = /* @__PURE__ */ r1(o1), cC = /* @__PURE__ */ W$({
__proto__: null,
default: u1
}, [o1]);
/**
* @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 Yr = (
// tslint:disable-next-line
u1 || cC
);
function Hu(n) {
return Yr.fromString(n, !0, 16);
}
const h1 = Hu("c3a5c85c97cb3127"), Kr = Hu("b492b66fbe98f273"), cn = Hu("9ae16a3b2f90404f");
function kd(n) {
return n.xor(n.shru(47));
}
function d1(n, e, t) {
const s = n.slice(e, e + t);
return Yr.fromBytes(Array.from(s), !0, !0);
}
function lt(n, e) {
return d1(n, e, 8);
}
function a0(n, e) {
return d1(n, e, 4);
}
function Vt(n, e) {
return e === 0 ? n : n.shru(e).or(n.shl(64 - e));
}
function yr(n, e, t = Hu("9ddfea08eb382d69")) {
let s = n.xor(e).mul(t);
s = s.xor(s.shru(47));
let r = e.xor(s).mul(t);
return r = r.xor(r.shru(47)), r = r.mul(t), r;
}
function uC(n, e, t, s, r, o) {
r = r.add(n), o = Vt(o.add(r).add(s), 21);
const a = r;
return r = r.add(e), r = r.add(t), o = o.add(Vt(r, 44)), [r.add(s), o.add(a)];
}
function Ll(n, e, t, s) {
return uC(lt(n, e), lt(n, e + 8), lt(n, e + 16), lt(n, e + 24), t, s);
}
function hC(n, e = n.length) {
if (e >= 8) {
const t = cn.add(e * 2), s = lt(n, 0).add(cn), r = lt(n, e - 8), o = Vt(r, 37).mul(t).add(s), a = Vt(s, 25).add(r).mul(t);
return yr(o, a, t);
}
if (e >= 4) {
const t = cn.add(e * 2), s = a0(n, 0);
return yr(s.shl(3).add(e), a0(n, e - 4), t);
}
if (e > 0) {
const t = n[0], s = n[e >> 1], r = n[e - 1], o = t + (s << 8), a = e + (r << 2);
return kd(cn.mul(o).xor(h1.mul(a))).mul(cn);
}
return cn;
}
function dC(n, e = n.length) {
const t = cn.add(e * 2), s = lt(n, 0).mul(Kr), r = lt(n, 8), o = lt(n, e - 8).mul(t), a = lt(n, e - 16).mul(cn);
return yr(Vt(s.add(r), 43).add(Vt(o, 30)).add(a), s.add(Vt(r.add(cn), 18)).add(o), t);
}
function pC(n, e = n.length) {
const t = cn.add(e * 2), s = lt(n, 0).mul(cn), r = lt(n, 8), o = lt(n, e - 8).mul(t), a = lt(n, e - 16).mul(cn), i = Vt(s.add(r), 43).add(Vt(o, 30)).add(a), l = yr(i, s.add(Vt(r.add(cn), 18)).add(o), t), c = lt(n, 16).mul(t), u = lt(n, 24), h = i.add(lt(n, e - 32)).mul(t), d = l.add(lt(n, e - 24)).mul(t);
return yr(Vt(c.add(u), 43).add(Vt(h, 30)).add(d), c.add(Vt(u.add(s), 18)).add(h), t);
}
function fC(n, e = n.length) {
const t = Yr.fromNumber(81, !0);
if (e <= 32)
return e <= 16 ? hC(n, e) : dC(n, e);
if (e <= 64)
return pC(n, e);
let s = t, r = t.mul(Kr).add(113), o = kd(r.mul(cn).add(113)).mul(cn), a = [Yr.UZERO, Yr.UZERO], i = [Yr.UZERO, Yr.UZERO];
s = s.mul(cn).add(lt(n, 0));
let l = 0;
const c = (e - 1 >> 6) * 64, u = c + (e - 1 & 63) - 63;
do
s = Vt(s.add(r).add(a[0]).add(lt(n, l + 8)), 37).mul(Kr), r = Vt(r.add(a[1]).add(lt(n, l + 48)), 42).mul(Kr), s = s.xor(i[1]), r = r.add(a[0]).add(lt(n, l + 40)), o = Vt(o.add(i[0]), 33).mul(Kr), a = Ll(n, l, a[1].mul(Kr), s.add(i[0])), i = Ll(n, l + 32, o.add(i[1]), r.add(lt(n, l + 16))), [o, s] = [s, o], l += 64;
while (l !== c);
const h = Kr.add(o.and(255).shl(1));
return l = u, i[0] = i[0].add(e - 1 & 63), a[0] = a[0].add(i[0]), i[0] = i[0].add(a[0]), s = Vt(s.add(r).add(a[0]).add(lt(n, l + 8)), 37).mul(h), r = Vt(r.add(a[1]).add(lt(n, l + 48)), 42).mul(h), s = s.xor(i[1].mul(9)), r = r.add(a[0].mul(9).add(lt(n, l + 40))), o = Vt(o.add(i[0]), 33).mul(h), a = Ll(n, l, a[1].mul(h), s.add(i[0])), i = Ll(n, l + 32, o.add(i[1]), r.add(lt(n, l + 16))), [o, s] = [s, o], yr(yr(a[0], i[0], h).add(kd(r).mul(h1)).add(o), yr(a[1], i[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 Fr(n, e) {
return e === "string" ? br(n) : go([n], e);
}
function mC(n, e) {
return n instanceof Float32Array && e === "float32" || n instanceof Int32Array && e === "int32" || n instanceof Uint8Array && e === "bool";
}
function go(n, e) {
if (e === "string")
throw new Error("Cannot convert a string[] to a TypedArray");
if (Array.isArray(n) && (n = Ko(n)), K().getBool("DEBUG") && q$(n, e), mC(n, e))
return n;
if (e == null || e === "float32" || e === "complex64")
return new Float32Array(n);
if (e === "int32")
return new Int32Array(n);
if (e === "bool") {
const t = new Uint8Array(n.length);
for (let s = 0; s < t.length; ++s)
Math.round(n[s]) !== 0 && (t[s] = 1);
return t;
} else
throw new Error(`Unknown data type ${e}`);
}
function bn() {
return K().platform.now();
}
function br(n, e = "utf-8") {
return e = e || "utf-8", K().platform.encode(n, e);
}
function vr(n, e = "utf-8") {
return e = e || "utf-8", K().platform.decode(n, e);
}
/**
* @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 gC {
constructor(e, t) {
this.backendTimer = e, this.logger = t, t == null && (this.logger = new bC());
}
profileKernel(e, t, s) {
let r;
const o = () => {
r = s();
};
let a;
const i = bn();
if (this.backendTimer.timerAvailable())
a = this.backendTimer.time(o);
else {
o();
for (const c of r)
c.dataSync();
a = Promise.resolve({ kernelMs: bn() - i });
}
if (K().getBool("CHECK_COMPUTATION_FOR_ERRORS"))
for (let c = 0; c < r.length; c++) {
const u = r[c];
u.data().then((h) => {
yC(h, u.dtype, e);
});
}
return {
kernelName: e,
outputs: r,
inputs: t,
timeMs: a.then((c) => c.kernelMs),
extraInfo: a.then((c) => c.getExtraProfileInfo != null ? c.getExtraProfileInfo() : "")
};
}
logKernelProfile(e) {
const { kernelName: t, outputs: s, timeMs: r, inputs: o, extraInfo: a } = e;
s.forEach((i) => {
Promise.all([i.data(), r, a]).then((l) => {
this.logger.logKernelProfile(t, i, l[0], l[1], o, l[2]);
});
});
}
}
function yC(n, e, t) {
if (e !== "float32")
return !1;
for (let s = 0; s < n.length; s++) {
const r = n[s];
if (isNaN(r) || !isFinite(r))
return console.warn(`Found ${r} in the result of '${t}'`), !0;
}
return !1;
}
class bC {
logKernelProfile(e, t, s, r, o, a) {
const i = typeof r == "number" ? Bo(`${r}ms`, 9) : r.error, l = Bo(e, 25), c = t.rank, u = t.size, h = Bo(t.shape.toString(), 14);
let d = "";
for (const p in o) {
const f = o[p];
if (f != null) {
const m = f.shape || t.shape, g = m.length;
d += `${p}: ${g}D ${g > 0 ? m : ""} `;
}
}
console.log(`%c${l} %c${i} %c${c}D ${h} %c${u} %c${d} %c${a}`, "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 xC(n, e, t) {
const s = {}, r = {};
for (let l = 0; l < e.length; l++)
s[e[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 < e.length; f++)
if (s[d.id]) {
c.outputs.forEach((m) => s[m.id] = !0), p = !0, r[c.id] = !0;
break;
}
if (p)
break;
}
}
const o = {};
o[t.id] = !0;
const a = {};
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 (o[c.outputs[h].id]) {
for (const d in u)
o[u[d].id] = !0, a[c.id] = !0;
break;
}
}
const i = [];
for (let l = 0; l < n.length; l++) {
const c = n[l];
if (r[c.id] && a[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, i.push(h);
}
}
return i;
}
function wC(n, e, t, s) {
for (let r = e.length - 1; r >= 0; r--) {
const o = e[r], a = [];
if (o.outputs.forEach((l) => {
const c = n[l.id];
c != null ? a.push(c) : a.push(null);
}), o.gradient == null)
throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);
const i = o.gradient(a);
for (const l in o.inputs) {
if (!(l in i))
throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(i)}.`);
const c = t(() => i[l]());
if (c.dtype !== "float32")
throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);
const u = o.inputs[l];
if (!je(c.shape, u.shape))
throw new Error(`Error in gradient for op ${o.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 i0 = 20, Fa = 3, Hh = 7;
function vC(n, e, t, s) {
const r = Te(e), o = IC(n, e, t, r), a = e.length, i = tc(n, e, t, r, o), l = ["Tensor"];
return s && (l.push(` dtype: ${t}`), l.push(` rank: ${a}`), l.push(` shape: [${e}]`), l.push(" values:")), l.push(i.map((c) => " " + c).join(`
`)), l.join(`
`);
}
function IC(n, e, t, s) {
const r = Z(e), o = s[s.length - 1], a = new Array(o).fill(0), i = e.length, l = t === "complex64" ? za(n) : n;
if (i > 1)
for (let c = 0; c < r / o; c++) {
const u = c * o;
for (let h = 0; h < o; h++)
a[h] = Math.max(a[h], Pa(l[u + h], 0, t).length);
}
return a;
}
function Pa(n, e, t) {
let s;
return Array.isArray(n) ? s = `${parseFloat(n[0].toFixed(Hh))} + ${parseFloat(n[1].toFixed(Hh))}j` : ai(n) ? s = `'${n}'` : t === "bool" ? s = p1(n) : s = parseFloat(n.toFixed(Hh)).toString(), Bo(s, e);
}
function p1(n) {
return n === 0 ? "false" : "true";
}
function tc(n, e, t, s, r, o = !0) {
const a = t === "complex64" ? 2 : 1, i = e[0], l = e.length;
if (l === 0) {
if (t === "complex64") {
const m = za(n);
return [Pa(m[0], 0, t)];
}
return t === "bool" ? [p1(n[0])] : [n[0].toString()];
}
if (l === 1) {
if (i > i0) {
const g = Fa * a;
let y = Array.from(n.slice(0, g)), b = Array.from(n.slice((i - Fa) * a, i * a));
return t === "complex64" && (y = za(y), b = za(b)), [