@api.stream/studio-kit
Version:
Client SDK for building studio experiences with API.stream
1,311 lines • 3.37 MB
JavaScript
var zi = Object.defineProperty;
var Ki = (a, u, c) => u in a ? zi(a, u, { enumerable: !0, configurable: !0, writable: !0, value: c }) : a[u] = c;
var Ft = (a, u, c) => (Ki(a, typeof u != "symbol" ? u + "" : u, c), c);
import React, { useState, useEffect, useContext, useMemo, useRef, useLayoutEffect, useCallback } from "react";
import ReactDOM from "react-dom";
var commonjsGlobal$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function getDefaultExportFromCjs$2(a) {
return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
}
function getAugmentedNamespace(a) {
if (a.__esModule)
return a;
var u = a.default;
if (typeof u == "function") {
var c = function l() {
return this instanceof l ? Reflect.construct(u, arguments, this.constructor) : u.apply(this, arguments);
};
c.prototype = u.prototype;
} else
c = {};
return Object.defineProperty(c, "__esModule", { value: !0 }), Object.keys(a).forEach(function(l) {
var v = Object.getOwnPropertyDescriptor(a, l);
Object.defineProperty(c, l, v.get ? v : {
enumerable: !0,
get: function() {
return a[l];
}
});
}), c;
}
var lib$2 = {};
function e(a) {
this.message = a;
}
e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
var r$2 = typeof window < "u" && window.atob && window.atob.bind(window) || function(a) {
var u = String(a).replace(/=+$/, "");
if (u.length % 4 == 1)
throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
for (var c, l, v = 0, p = 0, _ = ""; l = u.charAt(p++); ~l && (c = v % 4 ? 64 * c + l : l, v++ % 4) ? _ += String.fromCharCode(255 & c >> (-2 * v & 6)) : 0)
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(l);
return _;
};
function t(a) {
var u = a.replace(/-/g, "+").replace(/_/g, "/");
switch (u.length % 4) {
case 0:
break;
case 2:
u += "==";
break;
case 3:
u += "=";
break;
default:
throw "Illegal base64url string!";
}
try {
return function(c) {
return decodeURIComponent(r$2(c).replace(/(.)/g, function(l, v) {
var p = v.charCodeAt(0).toString(16).toUpperCase();
return p.length < 2 && (p = "0" + p), "%" + p;
}));
}(u);
} catch {
return r$2(u);
}
}
function n(a) {
this.message = a;
}
function o(a, u) {
if (typeof a != "string")
throw new n("Invalid token specified");
var c = (u = u || {}).header === !0 ? 0 : 1;
try {
return JSON.parse(t(a.split(".")[c]));
} catch (l) {
throw new n("Invalid token specified: " + l.message);
}
}
n.prototype = new Error(), n.prototype.name = "InvalidTokenError";
const jwtDecode_esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
InvalidTokenError: n,
default: o
}, Symbol.toStringTag, { value: "Module" })), require$$0$3 = /* @__PURE__ */ getAugmentedNamespace(jwtDecode_esm);
var getRandomValues, rnds8 = new Uint8Array(16);
function rng() {
if (!getRandomValues && (getRandomValues = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !getRandomValues))
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
return getRandomValues(rnds8);
}
const REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
function validate$2(a) {
return typeof a == "string" && REGEX.test(a);
}
var byteToHex = [];
for (var i$2 = 0; i$2 < 256; ++i$2)
byteToHex.push((i$2 + 256).toString(16).substr(1));
function stringify(a) {
var u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, c = (byteToHex[a[u + 0]] + byteToHex[a[u + 1]] + byteToHex[a[u + 2]] + byteToHex[a[u + 3]] + "-" + byteToHex[a[u + 4]] + byteToHex[a[u + 5]] + "-" + byteToHex[a[u + 6]] + byteToHex[a[u + 7]] + "-" + byteToHex[a[u + 8]] + byteToHex[a[u + 9]] + "-" + byteToHex[a[u + 10]] + byteToHex[a[u + 11]] + byteToHex[a[u + 12]] + byteToHex[a[u + 13]] + byteToHex[a[u + 14]] + byteToHex[a[u + 15]]).toLowerCase();
if (!validate$2(c))
throw TypeError("Stringified UUID is invalid");
return c;
}
var _nodeId, _clockseq, _lastMSecs = 0, _lastNSecs = 0;
function v1(a, u, c) {
var l = u && c || 0, v = u || new Array(16);
a = a || {};
var p = a.node || _nodeId, _ = a.clockseq !== void 0 ? a.clockseq : _clockseq;
if (p == null || _ == null) {
var I = a.random || (a.rng || rng)();
p == null && (p = _nodeId = [I[0] | 1, I[1], I[2], I[3], I[4], I[5]]), _ == null && (_ = _clockseq = (I[6] << 8 | I[7]) & 16383);
}
var M = a.msecs !== void 0 ? a.msecs : Date.now(), L = a.nsecs !== void 0 ? a.nsecs : _lastNSecs + 1, F = M - _lastMSecs + (L - _lastNSecs) / 1e4;
if (F < 0 && a.clockseq === void 0 && (_ = _ + 1 & 16383), (F < 0 || M > _lastMSecs) && a.nsecs === void 0 && (L = 0), L >= 1e4)
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
_lastMSecs = M, _lastNSecs = L, _clockseq = _, M += 122192928e5;
var V = ((M & 268435455) * 1e4 + L) % 4294967296;
v[l++] = V >>> 24 & 255, v[l++] = V >>> 16 & 255, v[l++] = V >>> 8 & 255, v[l++] = V & 255;
var X = M / 4294967296 * 1e4 & 268435455;
v[l++] = X >>> 8 & 255, v[l++] = X & 255, v[l++] = X >>> 24 & 15 | 16, v[l++] = X >>> 16 & 255, v[l++] = _ >>> 8 | 128, v[l++] = _ & 255;
for (var oe = 0; oe < 6; ++oe)
v[l + oe] = p[oe];
return u || stringify(v);
}
function parse$3(a) {
if (!validate$2(a))
throw TypeError("Invalid UUID");
var u, c = new Uint8Array(16);
return c[0] = (u = parseInt(a.slice(0, 8), 16)) >>> 24, c[1] = u >>> 16 & 255, c[2] = u >>> 8 & 255, c[3] = u & 255, c[4] = (u = parseInt(a.slice(9, 13), 16)) >>> 8, c[5] = u & 255, c[6] = (u = parseInt(a.slice(14, 18), 16)) >>> 8, c[7] = u & 255, c[8] = (u = parseInt(a.slice(19, 23), 16)) >>> 8, c[9] = u & 255, c[10] = (u = parseInt(a.slice(24, 36), 16)) / 1099511627776 & 255, c[11] = u / 4294967296 & 255, c[12] = u >>> 24 & 255, c[13] = u >>> 16 & 255, c[14] = u >>> 8 & 255, c[15] = u & 255, c;
}
function stringToBytes(a) {
a = unescape(encodeURIComponent(a));
for (var u = [], c = 0; c < a.length; ++c)
u.push(a.charCodeAt(c));
return u;
}
var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8", URL$1 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
function v35(a, u, c) {
function l(v, p, _, I) {
if (typeof v == "string" && (v = stringToBytes(v)), typeof p == "string" && (p = parse$3(p)), p.length !== 16)
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
var M = new Uint8Array(16 + v.length);
if (M.set(p), M.set(v, p.length), M = c(M), M[6] = M[6] & 15 | u, M[8] = M[8] & 63 | 128, _) {
I = I || 0;
for (var L = 0; L < 16; ++L)
_[I + L] = M[L];
return _;
}
return stringify(M);
}
try {
l.name = a;
} catch {
}
return l.DNS = DNS, l.URL = URL$1, l;
}
function md5$3(a) {
if (typeof a == "string") {
var u = unescape(encodeURIComponent(a));
a = new Uint8Array(u.length);
for (var c = 0; c < u.length; ++c)
a[c] = u.charCodeAt(c);
}
return md5ToHexEncodedArray(wordsToMd5(bytesToWords(a), a.length * 8));
}
function md5ToHexEncodedArray(a) {
for (var u = [], c = a.length * 32, l = "0123456789abcdef", v = 0; v < c; v += 8) {
var p = a[v >> 5] >>> v % 32 & 255, _ = parseInt(l.charAt(p >>> 4 & 15) + l.charAt(p & 15), 16);
u.push(_);
}
return u;
}
function getOutputLength(a) {
return (a + 64 >>> 9 << 4) + 14 + 1;
}
function wordsToMd5(a, u) {
a[u >> 5] |= 128 << u % 32, a[getOutputLength(u) - 1] = u;
for (var c = 1732584193, l = -271733879, v = -1732584194, p = 271733878, _ = 0; _ < a.length; _ += 16) {
var I = c, M = l, L = v, F = p;
c = md5ff(c, l, v, p, a[_], 7, -680876936), p = md5ff(p, c, l, v, a[_ + 1], 12, -389564586), v = md5ff(v, p, c, l, a[_ + 2], 17, 606105819), l = md5ff(l, v, p, c, a[_ + 3], 22, -1044525330), c = md5ff(c, l, v, p, a[_ + 4], 7, -176418897), p = md5ff(p, c, l, v, a[_ + 5], 12, 1200080426), v = md5ff(v, p, c, l, a[_ + 6], 17, -1473231341), l = md5ff(l, v, p, c, a[_ + 7], 22, -45705983), c = md5ff(c, l, v, p, a[_ + 8], 7, 1770035416), p = md5ff(p, c, l, v, a[_ + 9], 12, -1958414417), v = md5ff(v, p, c, l, a[_ + 10], 17, -42063), l = md5ff(l, v, p, c, a[_ + 11], 22, -1990404162), c = md5ff(c, l, v, p, a[_ + 12], 7, 1804603682), p = md5ff(p, c, l, v, a[_ + 13], 12, -40341101), v = md5ff(v, p, c, l, a[_ + 14], 17, -1502002290), l = md5ff(l, v, p, c, a[_ + 15], 22, 1236535329), c = md5gg(c, l, v, p, a[_ + 1], 5, -165796510), p = md5gg(p, c, l, v, a[_ + 6], 9, -1069501632), v = md5gg(v, p, c, l, a[_ + 11], 14, 643717713), l = md5gg(l, v, p, c, a[_], 20, -373897302), c = md5gg(c, l, v, p, a[_ + 5], 5, -701558691), p = md5gg(p, c, l, v, a[_ + 10], 9, 38016083), v = md5gg(v, p, c, l, a[_ + 15], 14, -660478335), l = md5gg(l, v, p, c, a[_ + 4], 20, -405537848), c = md5gg(c, l, v, p, a[_ + 9], 5, 568446438), p = md5gg(p, c, l, v, a[_ + 14], 9, -1019803690), v = md5gg(v, p, c, l, a[_ + 3], 14, -187363961), l = md5gg(l, v, p, c, a[_ + 8], 20, 1163531501), c = md5gg(c, l, v, p, a[_ + 13], 5, -1444681467), p = md5gg(p, c, l, v, a[_ + 2], 9, -51403784), v = md5gg(v, p, c, l, a[_ + 7], 14, 1735328473), l = md5gg(l, v, p, c, a[_ + 12], 20, -1926607734), c = md5hh(c, l, v, p, a[_ + 5], 4, -378558), p = md5hh(p, c, l, v, a[_ + 8], 11, -2022574463), v = md5hh(v, p, c, l, a[_ + 11], 16, 1839030562), l = md5hh(l, v, p, c, a[_ + 14], 23, -35309556), c = md5hh(c, l, v, p, a[_ + 1], 4, -1530992060), p = md5hh(p, c, l, v, a[_ + 4], 11, 1272893353), v = md5hh(v, p, c, l, a[_ + 7], 16, -155497632), l = md5hh(l, v, p, c, a[_ + 10], 23, -1094730640), c = md5hh(c, l, v, p, a[_ + 13], 4, 681279174), p = md5hh(p, c, l, v, a[_], 11, -358537222), v = md5hh(v, p, c, l, a[_ + 3], 16, -722521979), l = md5hh(l, v, p, c, a[_ + 6], 23, 76029189), c = md5hh(c, l, v, p, a[_ + 9], 4, -640364487), p = md5hh(p, c, l, v, a[_ + 12], 11, -421815835), v = md5hh(v, p, c, l, a[_ + 15], 16, 530742520), l = md5hh(l, v, p, c, a[_ + 2], 23, -995338651), c = md5ii(c, l, v, p, a[_], 6, -198630844), p = md5ii(p, c, l, v, a[_ + 7], 10, 1126891415), v = md5ii(v, p, c, l, a[_ + 14], 15, -1416354905), l = md5ii(l, v, p, c, a[_ + 5], 21, -57434055), c = md5ii(c, l, v, p, a[_ + 12], 6, 1700485571), p = md5ii(p, c, l, v, a[_ + 3], 10, -1894986606), v = md5ii(v, p, c, l, a[_ + 10], 15, -1051523), l = md5ii(l, v, p, c, a[_ + 1], 21, -2054922799), c = md5ii(c, l, v, p, a[_ + 8], 6, 1873313359), p = md5ii(p, c, l, v, a[_ + 15], 10, -30611744), v = md5ii(v, p, c, l, a[_ + 6], 15, -1560198380), l = md5ii(l, v, p, c, a[_ + 13], 21, 1309151649), c = md5ii(c, l, v, p, a[_ + 4], 6, -145523070), p = md5ii(p, c, l, v, a[_ + 11], 10, -1120210379), v = md5ii(v, p, c, l, a[_ + 2], 15, 718787259), l = md5ii(l, v, p, c, a[_ + 9], 21, -343485551), c = safeAdd(c, I), l = safeAdd(l, M), v = safeAdd(v, L), p = safeAdd(p, F);
}
return [c, l, v, p];
}
function bytesToWords(a) {
if (a.length === 0)
return [];
for (var u = a.length * 8, c = new Uint32Array(getOutputLength(u)), l = 0; l < u; l += 8)
c[l >> 5] |= (a[l / 8] & 255) << l % 32;
return c;
}
function safeAdd(a, u) {
var c = (a & 65535) + (u & 65535), l = (a >> 16) + (u >> 16) + (c >> 16);
return l << 16 | c & 65535;
}
function bitRotateLeft(a, u) {
return a << u | a >>> 32 - u;
}
function md5cmn(a, u, c, l, v, p) {
return safeAdd(bitRotateLeft(safeAdd(safeAdd(u, a), safeAdd(l, p)), v), c);
}
function md5ff(a, u, c, l, v, p, _) {
return md5cmn(u & c | ~u & l, a, u, v, p, _);
}
function md5gg(a, u, c, l, v, p, _) {
return md5cmn(u & l | c & ~l, a, u, v, p, _);
}
function md5hh(a, u, c, l, v, p, _) {
return md5cmn(u ^ c ^ l, a, u, v, p, _);
}
function md5ii(a, u, c, l, v, p, _) {
return md5cmn(c ^ (u | ~l), a, u, v, p, _);
}
var v3 = v35("v3", 48, md5$3);
const v3$1 = v3;
function v4(a, u, c) {
a = a || {};
var l = a.random || (a.rng || rng)();
if (l[6] = l[6] & 15 | 64, l[8] = l[8] & 63 | 128, u) {
c = c || 0;
for (var v = 0; v < 16; ++v)
u[c + v] = l[v];
return u;
}
return stringify(l);
}
function f$1(a, u, c, l) {
switch (a) {
case 0:
return u & c ^ ~u & l;
case 1:
return u ^ c ^ l;
case 2:
return u & c ^ u & l ^ c & l;
case 3:
return u ^ c ^ l;
}
}
function ROTL(a, u) {
return a << u | a >>> 32 - u;
}
function sha1$1(a) {
var u = [1518500249, 1859775393, 2400959708, 3395469782], c = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
if (typeof a == "string") {
var l = unescape(encodeURIComponent(a));
a = [];
for (var v = 0; v < l.length; ++v)
a.push(l.charCodeAt(v));
} else
Array.isArray(a) || (a = Array.prototype.slice.call(a));
a.push(128);
for (var p = a.length / 4 + 2, _ = Math.ceil(p / 16), I = new Array(_), M = 0; M < _; ++M) {
for (var L = new Uint32Array(16), F = 0; F < 16; ++F)
L[F] = a[M * 64 + F * 4] << 24 | a[M * 64 + F * 4 + 1] << 16 | a[M * 64 + F * 4 + 2] << 8 | a[M * 64 + F * 4 + 3];
I[M] = L;
}
I[_ - 1][14] = (a.length - 1) * 8 / Math.pow(2, 32), I[_ - 1][14] = Math.floor(I[_ - 1][14]), I[_ - 1][15] = (a.length - 1) * 8 & 4294967295;
for (var V = 0; V < _; ++V) {
for (var X = new Uint32Array(80), oe = 0; oe < 16; ++oe)
X[oe] = I[V][oe];
for (var Z = 16; Z < 80; ++Z)
X[Z] = ROTL(X[Z - 3] ^ X[Z - 8] ^ X[Z - 14] ^ X[Z - 16], 1);
for (var ae = c[0], ne = c[1], fe = c[2], ie = c[3], be = c[4], ge = 0; ge < 80; ++ge) {
var Ce = Math.floor(ge / 20), Me = ROTL(ae, 5) + f$1(Ce, ne, fe, ie) + be + u[Ce] + X[ge] >>> 0;
be = ie, ie = fe, fe = ROTL(ne, 30) >>> 0, ne = ae, ae = Me;
}
c[0] = c[0] + ae >>> 0, c[1] = c[1] + ne >>> 0, c[2] = c[2] + fe >>> 0, c[3] = c[3] + ie >>> 0, c[4] = c[4] + be >>> 0;
}
return [c[0] >> 24 & 255, c[0] >> 16 & 255, c[0] >> 8 & 255, c[0] & 255, c[1] >> 24 & 255, c[1] >> 16 & 255, c[1] >> 8 & 255, c[1] & 255, c[2] >> 24 & 255, c[2] >> 16 & 255, c[2] >> 8 & 255, c[2] & 255, c[3] >> 24 & 255, c[3] >> 16 & 255, c[3] >> 8 & 255, c[3] & 255, c[4] >> 24 & 255, c[4] >> 16 & 255, c[4] >> 8 & 255, c[4] & 255];
}
var v5 = v35("v5", 80, sha1$1);
const v5$1 = v5, nil = "00000000-0000-0000-0000-000000000000";
function version$5(a) {
if (!validate$2(a))
throw TypeError("Invalid UUID");
return parseInt(a.substr(14, 1), 16);
}
const esmBrowser = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
NIL: nil,
parse: parse$3,
stringify,
v1,
v3: v3$1,
v4,
v5: v5$1,
validate: validate$2,
version: version$5
}, Symbol.toStringTag, { value: "Module" })), require$$1$6 = /* @__PURE__ */ getAugmentedNamespace(esmBrowser);
let EnhancedMap$1 = class extends Map {
/**
* If key has a mapping already returns the currently associated value. If
* there is no mapping, calls the computer which must return a value V.
* The value is then stored for given key and returned.
* @param key Key
* @param computer Computer which is called only if key has no mapping yet.
* @return Existing value if the key already existed, or the newly computed value.
*/
computeIfAbsent(u, c) {
if (this.has(u))
return this.get(u);
const l = c(u);
return this.set(u, l), l;
}
/**
* If the key exists already calls given computer, if the key does not exist
* this method does nothing.
*
* The computer is called with current key and current value associated. The
* computer can return a (new) value V or undefined. When undefined is returned
* the key is removed from this map, when a V is returned the key is updated
* with the new value V.
* @param key Key
* @param computer Computer which is called only if the key has a mapping already
* @return Undefined if the key has no mapping, otherwise the value returned from computer
*/
computeIfPresent(u, c) {
const l = this.get(u);
if (l === void 0)
return;
const v = c(u, l);
return v !== void 0 ? this.set(u, v) : this.delete(u), v;
}
/**
* Computes a value for given key, the computer can return a value V (in which case the map
* will set the value for given key), if it returns undefined the mapping for key K will be
* removed.
* @param key Key to compute
* @param computer Computer which is called, note that the currentValue argument contains the existing
* value or is undefined when no mapping exists for the key.
* @return The newly computed value
*/
compute(u, c) {
const l = this.get(u), v = c(u, l);
return v ? this.set(u, v) : this.delete(u), v;
}
};
var InternalLogLevel$1;
(function(a) {
a[a.Trace = 0] = "Trace", a[a.Debug = 1] = "Debug", a[a.Info = 2] = "Info", a[a.Warn = 3] = "Warn", a[a.Error = 4] = "Error";
})(InternalLogLevel$1 || (InternalLogLevel$1 = {}));
function getInternalLogger$1(a) {
return provider$1.getLogger(a);
}
const INTERNAL_LOGGING_SETTINGS$1 = {
/**
* Changes the log level for the internal logging (for all new and existing loggers)
* @param level New log level
*/
setInternalLogLevel: (a) => provider$1.changeLogLevel(a),
/**
* Changes where messages are written to for all new and existing loggers),
* by default they are written to the console.
* @param fnOutput Function to write messages to
*/
setOutput: (a) => provider$1.changeOutput(a),
/**
* Resets the log level and output back to defaults (level to error and writing to console)
* for all new and existing loggers.
*/
reset: () => provider$1.reset()
};
let InternalLoggerImpl$1 = class {
constructor(u, c, l) {
this._name = u, this._level = c, this._fnOutput = l;
}
trace(u) {
this.log(InternalLogLevel$1.Trace, u);
}
debug(u) {
this.log(InternalLogLevel$1.Debug, u);
}
error(u, c) {
this.log(InternalLogLevel$1.Error, u, c);
}
info(u) {
this.log(InternalLogLevel$1.Info, u);
}
warn(u, c) {
this.log(InternalLogLevel$1.Warn, u, c);
}
setLevel(u) {
this._level = u;
}
setOutput(u) {
this._fnOutput = u;
}
log(u, c, l) {
this._level > u || this._fnOutput(`${InternalLogLevel$1[this._level].toString()} <INTERNAL LOGGER> ${this._name} ${c()}${l ? `
` + l.stack : ""}`);
}
}, InternalProviderImpl$1 = class Zt {
constructor() {
this._loggers = new EnhancedMap$1(), this._logLevel = InternalLogLevel$1.Error, this._fnOutput = Zt.logConsole;
}
getLogger(u) {
return this._loggers.computeIfAbsent(u, (c) => new InternalLoggerImpl$1(c, this._logLevel, this._fnOutput));
}
changeLogLevel(u) {
this._logLevel = u, this._loggers.forEach((c) => c.setLevel(u));
}
changeOutput(u) {
this._fnOutput = u, this._loggers.forEach((c) => c.setOutput(this._fnOutput));
}
reset() {
this.changeLogLevel(InternalLogLevel$1.Error), this._fnOutput = Zt.logConsole, this._loggers.forEach((u) => u.setOutput(this._fnOutput));
}
static logConsole(u) {
console && console.log && console.log(u);
}
};
const provider$1 = new InternalProviderImpl$1();
var InternalLogger$1 = /* @__PURE__ */ Object.freeze({
__proto__: null,
get InternalLogLevel() {
return InternalLogLevel$1;
},
getInternalLogger: getInternalLogger$1,
INTERNAL_LOGGING_SETTINGS: INTERNAL_LOGGING_SETTINGS$1
}), LogLevel$2;
(function(a) {
a[a.Trace = 0] = "Trace", a[a.Debug = 1] = "Debug", a[a.Info = 2] = "Info", a[a.Warn = 3] = "Warn", a[a.Error = 4] = "Error", a[a.Fatal = 5] = "Fatal";
})(LogLevel$2 || (LogLevel$2 = {}));
(function(a) {
function u(c) {
switch (c.toLowerCase()) {
case "trace":
return a.Trace;
case "debug":
return a.Debug;
case "info":
return a.Info;
case "warn":
return a.Warn;
case "error":
return a.Error;
case "fatal":
return a.Fatal;
default:
return;
}
}
a.toLogLevel = u;
})(LogLevel$2 || (LogLevel$2 = {}));
let CoreLoggerImpl$1 = class Ni {
constructor(u) {
this._runtime = u;
}
get id() {
return this._runtime.id;
}
get logLevel() {
return this._runtime.level;
}
get runtimeSettings() {
return Object.assign({}, this._runtime);
}
set runtimeSettings(u) {
this._runtime = u;
}
trace(u, ...c) {
this.logMessage(LogLevel$2.Trace, u, c);
}
debug(u, ...c) {
this.logMessage(LogLevel$2.Debug, u, c);
}
info(u, ...c) {
this.logMessage(LogLevel$2.Info, u, c);
}
warn(u, ...c) {
this.logMessage(LogLevel$2.Warn, u, c);
}
error(u, ...c) {
this.logMessage(LogLevel$2.Error, u, c);
}
fatal(u, ...c) {
this.logMessage(LogLevel$2.Fatal, u, c);
}
logMessage(u, c, l) {
if (this._runtime.level > u)
return;
const v = Date.now(), p = typeof c == "string" ? c : c(), _ = Ni.getErrorAndArgs(l);
switch (this._runtime.channel.type) {
case "RawLogChannel":
this._runtime.channel.write({
message: p,
exception: _.error,
args: _.args,
timeInMillis: v,
level: u,
logNames: this._runtime.name
}, this._runtime.argumentFormatter);
return;
case "LogChannel":
this._runtime.channel.write(this.createLogMessage(p, u, _, v));
break;
}
}
formatArgValue(u) {
try {
return this._runtime.argumentFormatter(u);
} catch {
return `>>ARG CONVERT FAILED: '${u !== void 0 ? u.toString() : "undefined"}'<<`;
}
}
createLogMessage(u, c, l, v) {
let p;
const _ = l.error, I = l.args;
_ && (p = `${_.name}: ${_.message}`, _.stack && (p += `@
${_.stack}`));
const M = this._runtime.dateFormatter(v);
let L = LogLevel$2[c].toUpperCase();
L.length < 5 && (L += " ");
const F = typeof this._runtime.name == "string" ? this._runtime.name : this._runtime.name.join(", "), V = typeof I < "u" && I.length > 0 ? " [" + I.map((oe) => this.formatArgValue(oe)).join(", ") + "]" : "";
return {
message: M + " " + L + " [" + F + "] " + u + V,
error: p
};
}
static getErrorAndArgs(u) {
if (u.length === 0)
return {};
let c, l;
const v = u[0];
if (v instanceof Error)
return c = v, l = u.length > 1 ? u.slice(1) : void 0, { error: c, args: l };
if (typeof v == "function") {
const p = v();
return p instanceof Error ? (c = p, l = u.length > 1 ? u.slice(1) : void 0, { error: c, args: l }) : u.length === 1 ? Array.isArray(p) ? { args: p.length > 0 ? p : void 0 } : { args: p } : Array.isArray(p) ? { args: [...p, ...u.slice(1)] } : { args: [p, ...u.slice(1)] };
}
return { args: u };
}
};
function padStart$1(a, u, c = " ") {
return padInternal$1(a, u, "start", c);
}
function padEnd$1(a, u, c = " ") {
return padInternal$1(a, u, "end", c);
}
function maxLengthStringValueInArray$1(a) {
return a.map((u) => u.length).reduce((u, c) => c > u ? c : u, 0);
}
function padInternal$1(a, u, c, l = " ") {
if (u <= a.length)
return a;
if (l.length > 1)
throw new Error(`Fill char must be one char exactly, it is: ${l.length}`);
const v = u - a.length;
let p = "";
for (let _ = 0; _ < v; _++)
p += l;
return c === "start" ? p + a : a + p;
}
function formatArgument$1(a) {
return a === void 0 ? "undefined" : JSON.stringify(a);
}
function formatDate$1(a) {
const u = new Date(a), c = u.getFullYear(), l = padStart$1((u.getMonth() + 1).toString(), 2, "0"), v = padStart$1(u.getDate().toString(), 2, "0"), p = padStart$1(u.getHours().toString(), 2, "0"), _ = padStart$1(u.getMinutes().toString(), 2, "0"), I = padStart$1(u.getSeconds().toString(), 2, "0"), M = padStart$1(u.getMilliseconds().toString(), 2, "0");
return `${c}-${l}-${v} ${p}:${_}:${I},${M}`;
}
let ConsoleLogChannel$1 = class {
constructor() {
this.type = "LogChannel";
}
write(u) {
console && console.log && console.log(u.message + (u.error ? `
${u.error}` : ""));
}
};
var DefaultChannels$1;
(function(a) {
function u() {
return new ConsoleLogChannel$1();
}
a.createConsoleChannel = u;
})(DefaultChannels$1 || (DefaultChannels$1 = {}));
let LogProviderImpl$1 = class Wt {
constructor(u, c) {
this._log = getInternalLogger$1("core.impl.LogProviderImpl"), this._name = u, this._settings = c, this._loggers = new EnhancedMap$1(), this._idToKeyMap = new EnhancedMap$1(), this._globalRuntimeSettings = { level: c.level, channel: c.channel }, this._nextLoggerId = 1, this._log.trace(() => `Created LogProviderImpl with settings: ${JSON.stringify(this._settings)}`);
}
get runtimeSettings() {
return Object.assign(Object.assign({}, this._settings), { level: this._globalRuntimeSettings.level, channel: this._globalRuntimeSettings.channel });
}
getLogger(u) {
return this.getOrCreateLogger(u);
}
updateLoggerRuntime(u, c) {
this._log.debug(() => `Updating logger ${u.id} runtime settings using: '${JSON.stringify(c)}'`);
const l = this._idToKeyMap.get(u.id);
return l === void 0 ? (this._log.warn(() => `Cannot update logger with id: ${u.id}, it was not found.`), !1) : (this._loggers.computeIfPresent(l, (v, p) => (p.runtimeSettings = Wt.mergeRuntimeSettingsIntoLogRuntime(p.runtimeSettings, c), p)), !0);
}
updateRuntimeSettings(u) {
this._log.debug(() => `Updating global runtime settings and updating existing loggers runtime settings using: '${JSON.stringify(u)}'`), this._globalRuntimeSettings = {
/* It's unclear, but not checking explicitly on undefined here makes the test fail, it makes no sense as level is a number | undefined essentially. */
level: u.level !== void 0 ? u.level : this._globalRuntimeSettings.level,
channel: u.channel !== void 0 ? u.channel : this._globalRuntimeSettings.channel
}, this._loggers.forEach((c) => c.runtimeSettings = Wt.mergeRuntimeSettingsIntoLogRuntime(c.runtimeSettings, u));
}
/**
* Removes all state and loggers, it reverts back to as it was after initial construction.
*/
clear() {
this._loggers.clear(), this._idToKeyMap.clear(), this._globalRuntimeSettings = Object.assign({}, this._settings), this._nextLoggerId = 1;
}
getOrCreateLogger(u) {
const c = Wt.createKey(u), l = this._loggers.computeIfAbsent(c, () => {
const v = {
level: this._globalRuntimeSettings.level,
channel: this._globalRuntimeSettings.channel,
id: this.nextLoggerId(),
name: u,
argumentFormatter: this._settings.argumentFormatter,
dateFormatter: this._settings.dateFormatter
};
return new CoreLoggerImpl$1(v);
});
return this._idToKeyMap.computeIfAbsent(l.id, () => c), l;
}
nextLoggerId() {
const u = this._name + "_" + this._nextLoggerId;
return this._nextLoggerId++, u;
}
static mergeRuntimeSettingsIntoLogRuntime(u, c) {
return Object.assign(Object.assign({}, u), {
/* It's unclear, but not checking explicitly on undefined here makes the test fail, it makes no sense as level is a number | undefined essentially. */
level: c.level !== void 0 ? c.level : u.level,
channel: c.channel !== void 0 ? c.channel : u.channel
});
}
static createKey(u) {
return typeof u == "string" ? u : u.join(",");
}
};
function createLogProvider$1(a, u) {
return new LogProviderImpl$1(a, u);
}
var index$4 = /* @__PURE__ */ Object.freeze({
__proto__: null,
EnhancedMap: EnhancedMap$1,
padStart: padStart$1,
padEnd: padEnd$1,
maxLengthStringValueInArray: maxLengthStringValueInArray$1
});
class ArrayLogChannel {
constructor() {
this._buffer = [], this.type = "LogChannel";
}
write(u) {
this._buffer.push(u);
}
get logMessages() {
return this._buffer;
}
get messages() {
return this._buffer.map((u) => u.message);
}
}
class ArrayRawLogChannel {
constructor() {
this._buffer = [], this.type = "RawLogChannel";
}
write(u, c) {
this._buffer.push(u);
}
get messages() {
return this._buffer.map((u) => u.message);
}
get errors() {
return this._buffer.map((u) => u.exception);
}
get size() {
return this._buffer.length;
}
get rawMessages() {
return this._buffer;
}
clear() {
this._buffer = [];
}
}
class TestControlMessage {
constructor() {
this._messages = [], this.write = this.write.bind(this);
}
get messages() {
return this._messages;
}
write(u) {
this._messages.push(u);
}
clear() {
this._messages = [];
}
}
var TestClasses = /* @__PURE__ */ Object.freeze({
__proto__: null,
ArrayLogChannel,
ArrayRawLogChannel,
TestControlMessage
});
const typescriptLogging_esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
$internal: InternalLogger$1,
$test: TestClasses,
get DefaultChannels() {
return DefaultChannels$1;
},
get LogLevel() {
return LogLevel$2;
},
createLogProvider: createLogProvider$1,
formatArgument: formatArgument$1,
formatDate: formatDate$1,
util: index$4
}, Symbol.toStringTag, { value: "Module" })), require$$2$1 = /* @__PURE__ */ getAugmentedNamespace(typescriptLogging_esm);
var layoutapi = {}, lib$1 = {}, lib = {}, Metadata = {};
Object.defineProperty(Metadata, "__esModule", { value: !0 });
Metadata.Metadata = void 0;
Metadata.Metadata = function(u) {
const c = /* @__PURE__ */ new Map(), l = {
set(v, p) {
if (v = normalizeKey(v), Array.isArray(p))
if (p.length === 0)
c.delete(v);
else {
for (const _ of p)
validate$1(v, _);
c.set(v, v.endsWith("-bin") ? p : [p.join(", ")]);
}
else
validate$1(v, p), c.set(v, [p]);
return l;
},
append(v, p) {
v = normalizeKey(v), validate$1(v, p);
let _ = c.get(v);
return _ == null && (_ = [], c.set(v, _)), _.push(p), v.endsWith("-bin") || c.set(v, [_.join(", ")]), l;
},
delete(v) {
v = normalizeKey(v), c.delete(v);
},
get(v) {
var p;
return v = normalizeKey(v), (p = c.get(v)) === null || p === void 0 ? void 0 : p[0];
},
getAll(v) {
var p;
return v = normalizeKey(v), (p = c.get(v)) !== null && p !== void 0 ? p : [];
},
has(v) {
return v = normalizeKey(v), c.has(v);
},
[Symbol.iterator]() {
return c[Symbol.iterator]();
}
};
if (u != null) {
const v = isIterable$1(u) ? u : Object.entries(u);
for (const [p, _] of v)
l.set(p, _);
}
return l;
};
function normalizeKey(a) {
return a.toLowerCase();
}
function validate$1(a, u) {
if (!/^[0-9a-z_.-]+$/.test(a))
throw new Error(`Metadata key '${a}' contains illegal characters`);
if (a.endsWith("-bin")) {
if (!(u instanceof Uint8Array))
throw new Error(`Metadata key '${a}' ends with '-bin', thus it must have binary value`);
} else {
if (typeof u != "string")
throw new Error(`Metadata key '${a}' doesn't end with '-bin', thus it must have string value`);
if (!/^[ -~]*$/.test(u))
throw new Error(`Metadata value '${u}' of key '${a}' contains illegal characters`);
}
}
function isIterable$1(a) {
return Symbol.iterator in a;
}
var Status = {};
(function(a) {
Object.defineProperty(a, "__esModule", { value: !0 }), a.Status = void 0, function(u) {
u[u.OK = 0] = "OK", u[u.CANCELLED = 1] = "CANCELLED", u[u.UNKNOWN = 2] = "UNKNOWN", u[u.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT", u[u.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", u[u.NOT_FOUND = 5] = "NOT_FOUND", u[u.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", u[u.PERMISSION_DENIED = 7] = "PERMISSION_DENIED", u[u.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED", u[u.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", u[u.ABORTED = 10] = "ABORTED", u[u.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", u[u.UNIMPLEMENTED = 12] = "UNIMPLEMENTED", u[u.INTERNAL = 13] = "INTERNAL", u[u.UNAVAILABLE = 14] = "UNAVAILABLE", u[u.DATA_LOSS = 15] = "DATA_LOSS", u[u.UNAUTHENTICATED = 16] = "UNAUTHENTICATED";
}(a.Status || (a.Status = {}));
})(Status);
var MethodDescriptor = {};
Object.defineProperty(MethodDescriptor, "__esModule", { value: !0 });
var CallOptions = {};
Object.defineProperty(CallOptions, "__esModule", { value: !0 });
var ClientMiddleware = {};
Object.defineProperty(ClientMiddleware, "__esModule", { value: !0 });
var composeClientMiddleware$1 = {};
Object.defineProperty(composeClientMiddleware$1, "__esModule", { value: !0 });
composeClientMiddleware$1.composeClientMiddleware = void 0;
function composeClientMiddleware(a, u) {
return (c, l) => u(Object.assign(Object.assign({}, c), { next: (v, p) => a(Object.assign(Object.assign({}, c), { request: v }), p) }), l);
}
composeClientMiddleware$1.composeClientMiddleware = composeClientMiddleware;
var ClientError$1 = {}, cjs = {}, helpers = {};
helpers.__esModule = void 0;
helpers.__esModule = !0;
var objectSetPrototypeOfIsDefined = typeof Object.setPrototypeOf == "function", objectGetPrototypeOfIsDefined = typeof Object.getPrototypeOf == "function", objectDefinePropertyIsDefined = typeof Object.defineProperty == "function", objectCreateIsDefined = typeof Object.create == "function", objectHasOwnPropertyIsDefined = typeof Object.prototype.hasOwnProperty == "function", setPrototypeOf = function(u, c) {
objectSetPrototypeOfIsDefined ? Object.setPrototypeOf(u, c) : u.__proto__ = c;
};
helpers.setPrototypeOf = setPrototypeOf;
var getPrototypeOf$1 = function(u) {
return objectGetPrototypeOfIsDefined ? Object.getPrototypeOf(u) : u.__proto__ || u.prototype;
};
helpers.getPrototypeOf = getPrototypeOf$1;
var ie8ObjectDefinePropertyBug = !1, defineProperty$1 = function a(u, c, l) {
if (objectDefinePropertyIsDefined && !ie8ObjectDefinePropertyBug)
try {
Object.defineProperty(u, c, l);
} catch {
ie8ObjectDefinePropertyBug = !0, a(u, c, l);
}
else
u[c] = l.value;
};
helpers.defineProperty = defineProperty$1;
var hasOwnProperty$g = function(u, c) {
return objectHasOwnPropertyIsDefined ? u.hasOwnProperty(u, c) : u[c] === void 0;
};
helpers.hasOwnProperty = hasOwnProperty$g;
var objectCreate$1 = function(u, c) {
if (objectCreateIsDefined)
return Object.create(u, c);
var l = function() {
};
l.prototype = u;
var v = new l();
if (typeof c > "u")
return v;
if (typeof c == "null")
throw new Error("PropertyDescriptors must not be null.");
if (typeof c == "object")
for (var p in c)
hasOwnProperty$g(c, p) && (v[p] = c[p].value);
return v;
};
helpers.objectCreate = objectCreate$1;
(function(a) {
a.__esModule = void 0, a.__esModule = !0;
var u = helpers, c = u.setPrototypeOf, l = u.getPrototypeOf, v = u.defineProperty, p = u.objectCreate, _ = new Error().toString() === "[object Error]", I = "";
function M(L) {
var F = this.constructor, V = F.name || function() {
var ne = F.toString().match(/^function\s*([^\s(]+)/);
return ne === null ? I || "Error" : ne[1];
}(), X = V === "Error", oe = X ? I : V, Z = Error.apply(this, arguments);
if (c(Z, l(this)), !(Z instanceof F) || !(Z instanceof M)) {
var Z = this;
Error.apply(this, arguments), v(Z, "message", {
configurable: !0,
enumerable: !1,
value: L,
writable: !0
});
}
if (v(Z, "name", {
configurable: !0,
enumerable: !1,
value: oe,
writable: !0
}), Error.captureStackTrace && Error.captureStackTrace(
Z,
X ? M : F
), Z.stack === void 0) {
var ae = new Error(L);
ae.name = Z.name, Z.stack = ae.stack;
}
return _ && v(Z, "toString", {
configurable: !0,
enumerable: !1,
value: function() {
return (this.name || "Error") + (typeof this.message > "u" ? "" : ": " + this.message);
},
writable: !0
}), Z;
}
I = M.name || "ExtendableError", M.prototype = p(Error.prototype, {
constructor: {
value: Error,
enumerable: !1,
writable: !0,
configurable: !0
}
}), a.ExtendableError = M, a.default = a.ExtendableError;
})(cjs);
Object.defineProperty(ClientError$1, "__esModule", { value: !0 });
ClientError$1.ClientError = void 0;
const ts_error_1$1 = cjs, Status_1$1 = Status;
class ClientError extends ts_error_1$1.ExtendableError {
constructor(u, c, l) {
super(`${u} ${Status_1$1.Status[c]}: ${l}`), this.path = u, this.code = c, this.details = l, this.name = "ClientError", Object.defineProperty(this, "@@nice-grpc", {
value: !0
}), Object.defineProperty(this, "@@nice-grpc:ClientError", {
value: !0
});
}
static [Symbol.hasInstance](u) {
return this !== ClientError ? this.prototype.isPrototypeOf(u) : typeof u == "object" && u !== null && (u.constructor === ClientError || u["@@nice-grpc:ClientError"] === !0 || u.name === "ClientError" && u["@@nice-grpc"] === !0);
}
}
ClientError$1.ClientError = ClientError;
var CallContext = {};
Object.defineProperty(CallContext, "__esModule", { value: !0 });
var ServerMiddleware = {};
Object.defineProperty(ServerMiddleware, "__esModule", { value: !0 });
var composeServerMiddleware$1 = {};
Object.defineProperty(composeServerMiddleware$1, "__esModule", { value: !0 });
composeServerMiddleware$1.composeServerMiddleware = void 0;
function composeServerMiddleware(a, u) {
return (c, l) => a(Object.assign(Object.assign({}, c), { next: (v, p) => u(Object.assign(Object.assign({}, c), { request: v }), p) }), l);
}
composeServerMiddleware$1.composeServerMiddleware = composeServerMiddleware;
var ServerError$1 = {};
Object.defineProperty(ServerError$1, "__esModule", { value: !0 });
ServerError$1.ServerError = void 0;
const ts_error_1 = cjs, Status_1 = Status;
class ServerError extends ts_error_1.ExtendableError {
constructor(u, c) {
super(`${Status_1.Status[u]}: ${c}`), this.code = u, this.details = c, this.name = "ServerError", Object.defineProperty(this, "@@nice-grpc", {
value: !0
}), Object.defineProperty(this, "@@nice-grpc:ServerError", {
value: !0
});
}
static [Symbol.hasInstance](u) {
return this !== ServerError ? this.prototype.isPrototypeOf(u) : typeof u == "object" && u !== null && (u.constructor === ServerError || u["@@nice-grpc:ServerError"] === !0 || u.name === "ServerError" && u["@@nice-grpc"] === !0);
}
}
ServerError$1.ServerError = ServerError;
(function(a) {
var u = commonjsGlobal$1 && commonjsGlobal$1.__createBinding || (Object.create ? function(l, v, p, _) {
_ === void 0 && (_ = p);
var I = Object.getOwnPropertyDescriptor(v, p);
(!I || ("get" in I ? !v.__esModule : I.writable || I.configurable)) && (I = { enumerable: !0, get: function() {
return v[p];
} }), Object.defineProperty(l, _, I);
} : function(l, v, p, _) {
_ === void 0 && (_ = p), l[_] = v[p];
}), c = commonjsGlobal$1 && commonjsGlobal$1.__exportStar || function(l, v) {
for (var p in l)
p !== "default" && !Object.prototype.hasOwnProperty.call(v, p) && u(v, l, p);
};
Object.defineProperty(a, "__esModule", { value: !0 }), c(Metadata, a), c(Status, a), c(MethodDescriptor, a), c(CallOptions, a), c(ClientMiddleware, a), c(composeClientMiddleware$1, a), c(ClientError$1, a), c(CallContext, a), c(ServerMiddleware, a), c(composeServerMiddleware$1, a), c(ServerError$1, a);
})(lib);
var serviceDefinitions = {}, grpcWeb = {};
Object.defineProperty(grpcWeb, "__esModule", { value: !0 });
grpcWeb.isGrpcWebServiceDefinition = grpcWeb.fromGrpcWebServiceDefinition = void 0;
function fromGrpcWebServiceDefinition(a) {
const u = {};
for (const [c, l] of Object.entries(a)) {
if (c === "serviceName")
continue;
const v = l;
u[uncapitalize(c)] = {
path: `/${a.serviceName}/${c}`,
requestStream: v.requestStream,
responseStream: v.responseStream,
requestDeserialize: v.requestType.deserializeBinary,
requestSerialize: (p) => p.serializeBinary(),
responseDeserialize: v.responseType.deserializeBinary,
responseSerialize: (p) => p.serializeBinary(),
options: {}
};
}
return u;
}
grpcWeb.fromGrpcWebServiceDefinition = fromGrpcWebServiceDefinition;
function isGrpcWebServiceDefinition(a) {
return "prototype" in a;
}
grpcWeb.isGrpcWebServiceDefinition = isGrpcWebServiceDefinition;
function uncapitalize(a) {
return a.length === 0 ? a : a[0].toLowerCase() + a.slice(1);
}
var tsProto = {};
Object.defineProperty(tsProto, "__esModule", { value: !0 });
tsProto.isTsProtoServiceDefinition = tsProto.fromTsProtoServiceDefinition = void 0;
function fromTsProtoServiceDefinition(a) {
const u = {};
for (const [c, l] of Object.entries(a.methods)) {
const v = l.requestType.encode, p = l.requestType.fromPartial, _ = l.responseType.encode, I = l.responseType.fromPartial;
u[c] = {
path: `/${a.fullName}/${l.name}`,
requestStream: l.requestStream,
responseStream: l.responseStream,
requestDeserialize: l.requestType.decode,
requestSerialize: p != null ? (M) => v(p(M)).finish() : (M) => v(M).finish(),
responseDeserialize: l.responseType.decode,
responseSerialize: I != null ? (M) => _(I(M)).finish() : (M) => _(M).finish(),
options: l.options
};
}
return u;
}
tsProto.fromTsProtoServiceDefinition = fromTsProtoServiceDefinition;
function isTsProtoServiceDefinition(a) {
return "name" in a && "fullName" in a && "methods" in a;
}
tsProto.isTsProtoServiceDefinition = isTsProtoServiceDefinition;
Object.defineProperty(serviceDefinitions, "__esModule", { value: !0 });
serviceDefinitions.normalizeServiceDefinition = void 0;
const grpc_web_1 = grpcWeb, ts_proto_1 = tsProto;
function normalizeServiceDefinition(a) {
return (0, grpc_web_1.isGrpcWebServiceDefinition)(a) ? (0, grpc_web_1.fromGrpcWebServiceDefinition)(a) : (0, ts_proto_1.isTsProtoServiceDefinition)(a) ? (0, ts_proto_1.fromTsProtoServiceDefinition)(a) : a;
}
serviceDefinitions.normalizeServiceDefinition = normalizeServiceDefinition;
var channel = {}, fetch$1 = {};
class AbortError extends Error {
constructor() {
super("The operation has been aborted"), this.message = "The operation has been aborted", this.name = "AbortError", typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, this.constructor);
}
}
function isAbortError(a) {
return typeof a == "object" && a !== null && a.name === "AbortError";
}
function throwIfAborted(a) {
if (a.aborted)
throw new AbortError();
}
function rethrowAbortError(a) {
if (isAbortError(a))
throw a;
}
function catchAbortError(a) {
if (!isAbortError(a))
throw a;
}
function execute(a, u) {
return new Promise((c, l) => {
if (a.aborted) {
l(new AbortError());
return;
}
let v, p = !1;
function _() {
p || (p = !0, v != null && v());
}
const I = u((M) => {
c(M), _();
}, (M) => {
l(M), _();
});
if (!p) {
const M = () => {
const L = I();
L == null ? l(new AbortError()) : L.then(() => {
l(new AbortError());
}, (F) => {
l(F);
}), _();
};
a.addEventListener("abort", M), v = () => {
a.removeEventListener("abort", M);
};
}
});
}
function abortable(a, u) {
if (a.aborted) {
const c = () => {
};
u.then(c, c);
}
return execute(a, (c, l) => (u.then(c, l), () => {
}));
}
function delay$1(a, u) {
return execute(a, (c) => {
const l = typeof u == "number" ? u : u.getTime() - Date.now(), v = setTimeout(c, l);
return () => {
clearTimeout(v);
};
});
}
function forever(a) {
return execute(a, () => () => {
});
}
function waitForEvent(a, u, c, l) {
return execute(a, (v) => {
let p, _ = !1;
return p = listen(u, c, (...M) => {
v(M.length > 1 ? M : M[0]), _ = !0, p != null && p();
}, l), _ && p(), () => {
_ = !0, p != null && p();
};
});
}
function listen(a, u, c, l) {
if (isEventTarget(a))
return a.addEventListener(u, c, l), () => a.removeEventListener(u, c, l);
if (isJQueryStyleEventEmitter(a))
return a.on(u, c), () => a.off(u, c);
if (isNodeStyleEventEmitter(a))
return a.addListener(u, c), () => a.removeListener(u, c);
throw new Error("Invalid event target");
}
function isNodeStyleEventEmitter(a) {
return isFunction$4(a.addListener) && isFunction$4(a.removeListener);
}
function isJQueryStyleEventEmitter(a) {
return isFunction$4(a.on) && isFunction$4(a.off);
}
function isEventTarget(a) {
return isFunction$4(a.addEventListener) && isFunction$4(a.removeEventListener);
}
const isFunction$4 = (a) => typeof a == "function";
function all(a, u) {
return new Promise((c, l) => {
if (a.aborted) {
l(new AbortError());
return;
}
const v = new AbortController(), p = u(v.signal);
if (p.length === 0) {
c([]);
return;
}
const _ = () => {
v.abort();
};
a.addEventListener("abort", _);
let I;
const M = new Array(p.length);
let L = 0;
function F() {
L += 1, L === p.length && (a.removeEventListener("abort", _), I != null ? l(I.reason) : c(M));
}
for (const [V, X] of p.entries())
X.then((oe) => {
M[V] = oe, F();
}, (oe) => {
v.abort(), (I == null || !isAbortError(oe) && isAbortError(I.reason)) && (I = { reason: oe }), F();
});
});
}
function race$2(a, u) {
return new Promise((c, l) => {
if (a.aborted) {
l(new AbortError());
return;
}
const v = new AbortController(), p = u(v.signal), _ = () => {
v.abort();
};
a.addEventListener("abort", _);
let I = 0;
function M(F) {
v.abort(), I += 1, I === p.length && (a.removeEventListener("abort", _), F.status === "fulfilled" ? c(F.value) : l(F.reason));
}
let L;
for (const F of p)
F.then((V) => {
L == null && (L = { status: "fulfilled", value: V }), M(L);
}, (V) => {
(L == null || !isAbortError(V) && (L.status === "fulfilled" || isAbortError(L.reason))) && (L = { status: "rejected", reason: V }), M(L);
});
});
}
async function retry$1(a, u, c = {}) {
const { baseMs: l = 1e3, maxDelayMs: v = 3e4, onError: p, maxAttempts: _ = 1 / 0 } = c;
let I = 0;
const M = () => {
I = -1;
};
for (; ; )
try {
return await u(a, I, M);
} catch (L) {
if (rethrowAbortError(L), I >= _)
throw L;
let F;
if (I === -1)
F = 0;
else {
const V = Math.min(v, Math.pow(2, I) * l);
F = Math.round(V * (1 + Math.random()) / 2);
}
p && p(L, I, F), F !== 0 && await delay$1(a, F), I += 1;
}
}
function spawn(a, u) {
if (a.aborted)
return Promise.reject(new AbortError());
const c = [], l = new AbortController(), v = l.signal, p = () => {
l.abort();
};
a.addEventListener("abort", p);
const _ = () => {
a.removeEventListener("abort", p);
}, I = /* @__PURE__ */ new Set(), M = () => {
for (const V of I)
V.abort();
};
v.addEventListener("abort", M);
const L = () => {
v.removeEventListener("abort", M);
};
let F = new Promise((V, X) => {
let oe, Z;
ae((ne) => u(ne, {
defer(fe) {
c.push(fe);
},
fork: ae
})).join().then((ne) => {
l.abort(), oe = { value: ne };
}, (ne) => {
l.abort(), (!isAbortError(ne) || Z == null) && (Z = { error: ne });
});
function ae(ne) {
if (v.aborted)
return {
abort() {
},
async join() {
throw new AbortError();
}
};
const fe = new AbortController(), ie = fe.signal, be = ne(ie), ge = {
abort() {
fe.abort();
},
join: () => be
};
return I.add(ge), be.catch(catchAbortError).catch((Ce) => {
Z = { error: Ce }, l.abort();
}).finally(() => {
I.delete(ge), I.size === 0 && (Z != null ? X(Z.error) : V(oe.value));
}), ge;
}
});
return F = F.finally(() => {
_(), L();
let V = Promise.resolve();
for (let X = c.length - 1; X >= 0; X--)
V = V.finally(c[X]);
return V;
}), F;
}
function run(a) {
const u = new AbortController(), c = a(u.signal).catch(catchAbortError);
return () => (u.abort(), c);
}
function proactiveRetry(a, u, c = {}) {
const { baseMs: l = 1e3, onError: v, maxAttempts: p = 1 / 0 } = c;
return execute(a, (_, I) => {
const M = new AbortController();
let L = !1;
const F = /* @__PURE__ */ new Map();
function V(Z) {
M.abort(), F.clear(), _(Z);
}
function X(Z, ae) {
if (F.delete(ae), L && F.size === 0) {
I(Z);
return;
}
if (!isAbortError(Z) && v)
try {
v(Z, ae);
} catch (ne) {
M.abort(), F.clear(), I(ne);
}
}
async function oe(Z) {
for (let ae = 0; ; ae++) {
const ne = u(Z, ae);
if (F.set(ae, ne), ne.then(V, (be) => X(be, ae)), ae + 1 >= p)
break;
const fe = Math.pow(2, ae) * l, ie = Math.round(fe * (1 + Math.random()) / 2);
await delay$1(Z, ie);
}
L = !0;
}
return oe(M.signal).catch(catchAbortError), () => {
M.abort();
};
});
}
const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
AbortError,
abortable,
all,
catchAbortError,
delay: delay$1,
execute,
forever,
isAbortError,
proactiveRetry,
race: race$2,
rethrowAbortError,
retry: retry$1,
run,
spawn,
throwIfAborted,
waitForEvent
}, Symbol.toStringTag, { value: "Module" })), require$$1$5 = /* @__PURE__ */ getAugmentedNamespace(es);
var buffer$3 = {}, base64Js = {};
base64Js.byteLength = byteLength;
base64Js.toByteArray = toByteArray;
base64Js.fromByteArray = fromByteArr