UNPKG

@seven.io/client

Version:
1,313 lines 82.6 kB
var st = Object.defineProperty; var it = (t, e, n) => e in t ? st(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var S = (t, e, n) => it(t, typeof e != "symbol" ? e + "" : e, n); const Ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ue = "ARRAYBUFFER not supported by this environment", We = "UINT8ARRAY not supported by this environment"; function Ae(t, e, n, r) { let a, s, o; const h = e || [0], c = (n = n || 0) >>> 3, l = r === -1 ? 3 : 0; for (a = 0; a < t.length; a += 1) o = a + c, s = o >>> 2, h.length <= s && h.push(0), h[s] |= t[a] << 8 * (l + r * (o % 4)); return { value: h, binLen: 8 * t.length + n }; } function Z(t, e, n) { switch (e) { case "UTF8": case "UTF16BE": case "UTF16LE": break; default: throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE"); } switch (t) { case "HEX": return function(r, a, s) { return function(o, h, c, l) { let d, u, f, g; if (o.length % 2 != 0) throw new Error("String of HEX type must be in byte increments"); const m = h || [0], y = (c = c || 0) >>> 3, b = l === -1 ? 3 : 0; for (d = 0; d < o.length; d += 2) { if (u = parseInt(o.substr(d, 2), 16), isNaN(u)) throw new Error("String of HEX type contains invalid characters"); for (g = (d >>> 1) + y, f = g >>> 2; m.length <= f; ) m.push(0); m[f] |= u << 8 * (b + l * (g % 4)); } return { value: m, binLen: 4 * o.length + c }; }(r, a, s, n); }; case "TEXT": return function(r, a, s) { return function(o, h, c, l, d) { let u, f, g, m, y, b, x, N, M = 0; const T = c || [0], P = (l = l || 0) >>> 3; if (h === "UTF8") for (x = d === -1 ? 3 : 0, g = 0; g < o.length; g += 1) for (u = o.charCodeAt(g), f = [], 128 > u ? f.push(u) : 2048 > u ? (f.push(192 | u >>> 6), f.push(128 | 63 & u)) : 55296 > u || 57344 <= u ? f.push(224 | u >>> 12, 128 | u >>> 6 & 63, 128 | 63 & u) : (g += 1, u = 65536 + ((1023 & u) << 10 | 1023 & o.charCodeAt(g)), f.push(240 | u >>> 18, 128 | u >>> 12 & 63, 128 | u >>> 6 & 63, 128 | 63 & u)), m = 0; m < f.length; m += 1) { for (b = M + P, y = b >>> 2; T.length <= y; ) T.push(0); T[y] |= f[m] << 8 * (x + d * (b % 4)), M += 1; } else for (x = d === -1 ? 2 : 0, N = h === "UTF16LE" && d !== 1 || h !== "UTF16LE" && d === 1, g = 0; g < o.length; g += 1) { for (u = o.charCodeAt(g), N === !0 && (m = 255 & u, u = m << 8 | u >>> 8), b = M + P, y = b >>> 2; T.length <= y; ) T.push(0); T[y] |= u << 8 * (x + d * (b % 4)), M += 2; } return { value: T, binLen: 8 * M + l }; }(r, e, a, s, n); }; case "B64": return function(r, a, s) { return function(o, h, c, l) { let d, u, f, g, m, y, b, x = 0; const N = h || [0], M = (c = c || 0) >>> 3, T = l === -1 ? 3 : 0, P = o.indexOf("="); if (o.search(/^[a-zA-Z0-9=+/]+$/) === -1) throw new Error("Invalid character in base-64 string"); if (o = o.replace(/=/g, ""), P !== -1 && P < o.length) throw new Error("Invalid '=' found in base-64 string"); for (u = 0; u < o.length; u += 4) { for (m = o.substr(u, 4), g = 0, f = 0; f < m.length; f += 1) d = Ce.indexOf(m.charAt(f)), g |= d << 18 - 6 * f; for (f = 0; f < m.length - 1; f += 1) { for (b = x + M, y = b >>> 2; N.length <= y; ) N.push(0); N[y] |= (g >>> 16 - 8 * f & 255) << 8 * (T + l * (b % 4)), x += 1; } } return { value: N, binLen: 8 * x + c }; }(r, a, s, n); }; case "BYTES": return function(r, a, s) { return function(o, h, c, l) { let d, u, f, g; const m = h || [0], y = (c = c || 0) >>> 3, b = l === -1 ? 3 : 0; for (u = 0; u < o.length; u += 1) d = o.charCodeAt(u), g = u + y, f = g >>> 2, m.length <= f && m.push(0), m[f] |= d << 8 * (b + l * (g % 4)); return { value: m, binLen: 8 * o.length + c }; }(r, a, s, n); }; case "ARRAYBUFFER": try { new ArrayBuffer(0); } catch { throw new Error(Ue); } return function(r, a, s) { return function(o, h, c, l) { return Ae(new Uint8Array(o), h, c, l); }(r, a, s, n); }; case "UINT8ARRAY": try { new Uint8Array(0); } catch { throw new Error(We); } return function(r, a, s) { return Ae(r, a, s, n); }; default: throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY"); } } function Ne(t, e, n, r) { switch (t) { case "HEX": return function(a) { return function(s, o, h, c) { const l = "0123456789abcdef"; let d, u, f = ""; const g = o / 8, m = h === -1 ? 3 : 0; for (d = 0; d < g; d += 1) u = s[d >>> 2] >>> 8 * (m + h * (d % 4)), f += l.charAt(u >>> 4 & 15) + l.charAt(15 & u); return c.outputUpper ? f.toUpperCase() : f; }(a, e, n, r); }; case "B64": return function(a) { return function(s, o, h, c) { let l, d, u, f, g, m = ""; const y = o / 8, b = h === -1 ? 3 : 0; for (l = 0; l < y; l += 3) for (f = l + 1 < y ? s[l + 1 >>> 2] : 0, g = l + 2 < y ? s[l + 2 >>> 2] : 0, u = (s[l >>> 2] >>> 8 * (b + h * (l % 4)) & 255) << 16 | (f >>> 8 * (b + h * ((l + 1) % 4)) & 255) << 8 | g >>> 8 * (b + h * ((l + 2) % 4)) & 255, d = 0; d < 4; d += 1) m += 8 * l + 6 * d <= o ? Ce.charAt(u >>> 6 * (3 - d) & 63) : c.b64Pad; return m; }(a, e, n, r); }; case "BYTES": return function(a) { return function(s, o, h) { let c, l, d = ""; const u = o / 8, f = h === -1 ? 3 : 0; for (c = 0; c < u; c += 1) l = s[c >>> 2] >>> 8 * (f + h * (c % 4)) & 255, d += String.fromCharCode(l); return d; }(a, e, n); }; case "ARRAYBUFFER": try { new ArrayBuffer(0); } catch { throw new Error(Ue); } return function(a) { return function(s, o, h) { let c; const l = o / 8, d = new ArrayBuffer(l), u = new Uint8Array(d), f = h === -1 ? 3 : 0; for (c = 0; c < l; c += 1) u[c] = s[c >>> 2] >>> 8 * (f + h * (c % 4)) & 255; return d; }(a, e, n); }; case "UINT8ARRAY": try { new Uint8Array(0); } catch { throw new Error(We); } return function(a) { return function(s, o, h) { let c; const l = o / 8, d = h === -1 ? 3 : 0, u = new Uint8Array(l); for (c = 0; c < l; c += 1) u[c] = s[c >>> 2] >>> 8 * (d + h * (c % 4)) & 255; return u; }(a, e, n); }; default: throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY"); } } const ie = 4294967296, w = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298], F = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428], Y = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], oe = "Chosen SHA variant is not supported", Ke = "Cannot set numRounds with MAC"; function le(t, e) { let n, r; const a = t.binLen >>> 3, s = e.binLen >>> 3, o = a << 3, h = 4 - a << 3; if (a % 4 != 0) { for (n = 0; n < s; n += 4) r = a + n >>> 2, t.value[r] |= e.value[n >>> 2] << o, t.value.push(0), t.value[r + 1] |= e.value[n >>> 2] >>> h; return (t.value.length << 2) - 4 >= s + a && t.value.pop(), { value: t.value, binLen: t.binLen + e.binLen }; } return { value: t.value.concat(e.value), binLen: t.binLen + e.binLen }; } function xe(t) { const e = { outputUpper: !1, b64Pad: "=", outputLen: -1 }, n = t || {}, r = "Output length must be a multiple of 8"; if (e.outputUpper = n.outputUpper || !1, n.b64Pad && (e.b64Pad = n.b64Pad), n.outputLen) { if (n.outputLen % 8 != 0) throw new Error(r); e.outputLen = n.outputLen; } else if (n.shakeLen) { if (n.shakeLen % 8 != 0) throw new Error(r); e.outputLen = n.shakeLen; } if (typeof e.outputUpper != "boolean") throw new Error("Invalid outputUpper formatting option"); if (typeof e.b64Pad != "string") throw new Error("Invalid b64Pad formatting option"); return e; } function K(t, e, n, r) { const a = t + " must include a value and format"; if (!e) { if (!r) throw new Error(a); return r; } if (e.value === void 0 || !e.format) throw new Error(a); return Z(e.format, e.encoding || "UTF8", n)(e.value); } class me { constructor(e, n, r) { const a = r || {}; if (this.t = n, this.i = a.encoding || "UTF8", this.numRounds = a.numRounds || 1, isNaN(this.numRounds) || this.numRounds !== parseInt(this.numRounds, 10) || 1 > this.numRounds) throw new Error("numRounds must a integer >= 1"); this.o = e, this.h = [], this.u = 0, this.l = !1, this.A = 0, this.H = !1, this.S = [], this.p = []; } update(e) { let n, r = 0; const a = this.m >>> 5, s = this.C(e, this.h, this.u), o = s.binLen, h = s.value, c = o >>> 5; for (n = 0; n < c; n += a) r + this.m <= o && (this.U = this.v(h.slice(n, n + a), this.U), r += this.m); return this.A += r, this.h = h.slice(r >>> 5), this.u = o % this.m, this.l = !0, this; } getHash(e, n) { let r, a, s = this.R; const o = xe(n); if (this.K) { if (o.outputLen === -1) throw new Error("Output length must be specified in options"); s = o.outputLen; } const h = Ne(e, s, this.T, o); if (this.H && this.g) return h(this.g(o)); for (a = this.F(this.h.slice(), this.u, this.A, this.L(this.U), s), r = 1; r < this.numRounds; r += 1) this.K && s % 32 != 0 && (a[a.length - 1] &= 16777215 >>> 24 - s % 32), a = this.F(a, s, 0, this.B(this.o), s); return h(a); } setHMACKey(e, n, r) { if (!this.M) throw new Error("Variant does not support HMAC"); if (this.l) throw new Error("Cannot set MAC key after calling update"); const a = Z(n, (r || {}).encoding || "UTF8", this.T); this.k(a(e)); } k(e) { const n = this.m >>> 3, r = n / 4 - 1; let a; if (this.numRounds !== 1) throw new Error(Ke); if (this.H) throw new Error("MAC key already set"); for (n < e.binLen / 8 && (e.value = this.F(e.value, e.binLen, 0, this.B(this.o), this.R)); e.value.length <= r; ) e.value.push(0); for (a = 0; a <= r; a += 1) this.S[a] = 909522486 ^ e.value[a], this.p[a] = 1549556828 ^ e.value[a]; this.U = this.v(this.S, this.U), this.A = this.m, this.H = !0; } getHMAC(e, n) { const r = xe(n); return Ne(e, this.R, this.T, r)(this.Y()); } Y() { let e; if (!this.H) throw new Error("Cannot call getHMAC without first setting MAC key"); const n = this.F(this.h.slice(), this.u, this.A, this.L(this.U), this.R); return e = this.v(this.p, this.B(this.o)), e = this.F(n, this.R, this.m, e, this.R), e; } } function Q(t, e) { return t << e | t >>> 32 - e; } function H(t, e) { return t >>> e | t << 32 - e; } function Be(t, e) { return t >>> e; } function Te(t, e, n) { return t ^ e ^ n; } function je(t, e, n) { return t & e ^ ~t & n; } function Xe(t, e, n) { return t & e ^ t & n ^ e & n; } function ot(t) { return H(t, 2) ^ H(t, 13) ^ H(t, 22); } function E(t, e) { const n = (65535 & t) + (65535 & e); return (65535 & (t >>> 16) + (e >>> 16) + (n >>> 16)) << 16 | 65535 & n; } function ut(t, e, n, r) { const a = (65535 & t) + (65535 & e) + (65535 & n) + (65535 & r); return (65535 & (t >>> 16) + (e >>> 16) + (n >>> 16) + (r >>> 16) + (a >>> 16)) << 16 | 65535 & a; } function ae(t, e, n, r, a) { const s = (65535 & t) + (65535 & e) + (65535 & n) + (65535 & r) + (65535 & a); return (65535 & (t >>> 16) + (e >>> 16) + (n >>> 16) + (r >>> 16) + (a >>> 16) + (s >>> 16)) << 16 | 65535 & s; } function ct(t) { return H(t, 7) ^ H(t, 18) ^ Be(t, 3); } function ht(t) { return H(t, 6) ^ H(t, 11) ^ H(t, 25); } function lt(t) { return [1732584193, 4023233417, 2562383102, 271733878, 3285377520]; } function Ge(t, e) { let n, r, a, s, o, h, c; const l = []; for (n = e[0], r = e[1], a = e[2], s = e[3], o = e[4], c = 0; c < 80; c += 1) l[c] = c < 16 ? t[c] : Q(l[c - 3] ^ l[c - 8] ^ l[c - 14] ^ l[c - 16], 1), h = c < 20 ? ae(Q(n, 5), je(r, a, s), o, 1518500249, l[c]) : c < 40 ? ae(Q(n, 5), Te(r, a, s), o, 1859775393, l[c]) : c < 60 ? ae(Q(n, 5), Xe(r, a, s), o, 2400959708, l[c]) : ae(Q(n, 5), Te(r, a, s), o, 3395469782, l[c]), o = s, s = a, a = Q(r, 30), r = n, n = h; return e[0] = E(n, e[0]), e[1] = E(r, e[1]), e[2] = E(a, e[2]), e[3] = E(s, e[3]), e[4] = E(o, e[4]), e; } function ft(t, e, n, r) { let a; const s = 15 + (e + 65 >>> 9 << 4), o = e + n; for (; t.length <= s; ) t.push(0); for (t[e >>> 5] |= 128 << 24 - e % 32, t[s] = 4294967295 & o, t[s - 1] = o / ie | 0, a = 0; a < t.length; a += 16) r = Ge(t.slice(a, a + 16), r); return r; } let dt = class extends me { constructor(t, e, n) { if (t !== "SHA-1") throw new Error(oe); super(t, e, n); const r = n || {}; this.M = !0, this.g = this.Y, this.T = -1, this.C = Z(this.t, this.i, this.T), this.v = Ge, this.L = function(a) { return a.slice(); }, this.B = lt, this.F = ft, this.U = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.m = 512, this.R = 160, this.K = !1, r.hmacKey && this.k(K("hmacKey", r.hmacKey, this.T)); } }; function Ee(t) { let e; return e = t == "SHA-224" ? F.slice() : Y.slice(), e; } function Me(t, e) { let n, r, a, s, o, h, c, l, d, u, f; const g = []; for (n = e[0], r = e[1], a = e[2], s = e[3], o = e[4], h = e[5], c = e[6], l = e[7], f = 0; f < 64; f += 1) g[f] = f < 16 ? t[f] : ut(H(m = g[f - 2], 17) ^ H(m, 19) ^ Be(m, 10), g[f - 7], ct(g[f - 15]), g[f - 16]), d = ae(l, ht(o), je(o, h, c), w[f], g[f]), u = E(ot(n), Xe(n, r, a)), l = c, c = h, h = o, o = E(s, d), s = a, a = r, r = n, n = E(d, u); var m; return e[0] = E(n, e[0]), e[1] = E(r, e[1]), e[2] = E(a, e[2]), e[3] = E(s, e[3]), e[4] = E(o, e[4]), e[5] = E(h, e[5]), e[6] = E(c, e[6]), e[7] = E(l, e[7]), e; } let mt = class extends me { constructor(t, e, n) { if (t !== "SHA-224" && t !== "SHA-256") throw new Error(oe); super(t, e, n); const r = n || {}; this.g = this.Y, this.M = !0, this.T = -1, this.C = Z(this.t, this.i, this.T), this.v = Me, this.L = function(a) { return a.slice(); }, this.B = Ee, this.F = function(a, s, o, h) { return function(c, l, d, u, f) { let g, m; const y = 15 + (l + 65 >>> 9 << 4), b = l + d; for (; c.length <= y; ) c.push(0); for (c[l >>> 5] |= 128 << 24 - l % 32, c[y] = 4294967295 & b, c[y - 1] = b / ie | 0, g = 0; g < c.length; g += 16) u = Me(c.slice(g, g + 16), u); return m = f === "SHA-224" ? [u[0], u[1], u[2], u[3], u[4], u[5], u[6]] : u, m; }(a, s, o, h, t); }, this.U = Ee(t), this.m = 512, this.R = t === "SHA-224" ? 224 : 256, this.K = !1, r.hmacKey && this.k(K("hmacKey", r.hmacKey, this.T)); } }; class i { constructor(e, n) { this.N = e, this.I = n; } } function Oe(t, e) { let n; return e > 32 ? (n = 64 - e, new i(t.I << e | t.N >>> n, t.N << e | t.I >>> n)) : e !== 0 ? (n = 32 - e, new i(t.N << e | t.I >>> n, t.I << e | t.N >>> n)) : t; } function _(t, e) { let n; return e < 32 ? (n = 32 - e, new i(t.N >>> e | t.I << n, t.I >>> e | t.N << n)) : (n = 64 - e, new i(t.I >>> e | t.N << n, t.N >>> e | t.I << n)); } function Qe(t, e) { return new i(t.N >>> e, t.I >>> e | t.N << 32 - e); } function wt(t, e, n) { return new i(t.N & e.N ^ t.N & n.N ^ e.N & n.N, t.I & e.I ^ t.I & n.I ^ e.I & n.I); } function gt(t) { const e = _(t, 28), n = _(t, 34), r = _(t, 39); return new i(e.N ^ n.N ^ r.N, e.I ^ n.I ^ r.I); } function I(t, e) { let n, r; n = (65535 & t.I) + (65535 & e.I), r = (t.I >>> 16) + (e.I >>> 16) + (n >>> 16); const a = (65535 & r) << 16 | 65535 & n; return n = (65535 & t.N) + (65535 & e.N) + (r >>> 16), r = (t.N >>> 16) + (e.N >>> 16) + (n >>> 16), new i((65535 & r) << 16 | 65535 & n, a); } function yt(t, e, n, r) { let a, s; a = (65535 & t.I) + (65535 & e.I) + (65535 & n.I) + (65535 & r.I), s = (t.I >>> 16) + (e.I >>> 16) + (n.I >>> 16) + (r.I >>> 16) + (a >>> 16); const o = (65535 & s) << 16 | 65535 & a; return a = (65535 & t.N) + (65535 & e.N) + (65535 & n.N) + (65535 & r.N) + (s >>> 16), s = (t.N >>> 16) + (e.N >>> 16) + (n.N >>> 16) + (r.N >>> 16) + (a >>> 16), new i((65535 & s) << 16 | 65535 & a, o); } function bt(t, e, n, r, a) { let s, o; s = (65535 & t.I) + (65535 & e.I) + (65535 & n.I) + (65535 & r.I) + (65535 & a.I), o = (t.I >>> 16) + (e.I >>> 16) + (n.I >>> 16) + (r.I >>> 16) + (a.I >>> 16) + (s >>> 16); const h = (65535 & o) << 16 | 65535 & s; return s = (65535 & t.N) + (65535 & e.N) + (65535 & n.N) + (65535 & r.N) + (65535 & a.N) + (o >>> 16), o = (t.N >>> 16) + (e.N >>> 16) + (n.N >>> 16) + (r.N >>> 16) + (a.N >>> 16) + (s >>> 16), new i((65535 & o) << 16 | 65535 & s, h); } function ee(t, e) { return new i(t.N ^ e.N, t.I ^ e.I); } function pt(t) { const e = _(t, 19), n = _(t, 61), r = Qe(t, 6); return new i(e.N ^ n.N ^ r.N, e.I ^ n.I ^ r.I); } function vt(t) { const e = _(t, 1), n = _(t, 8), r = Qe(t, 7); return new i(e.N ^ n.N ^ r.N, e.I ^ n.I ^ r.I); } function St(t) { const e = _(t, 14), n = _(t, 18), r = _(t, 41); return new i(e.N ^ n.N ^ r.N, e.I ^ n.I ^ r.I); } const At = [new i(w[0], 3609767458), new i(w[1], 602891725), new i(w[2], 3964484399), new i(w[3], 2173295548), new i(w[4], 4081628472), new i(w[5], 3053834265), new i(w[6], 2937671579), new i(w[7], 3664609560), new i(w[8], 2734883394), new i(w[9], 1164996542), new i(w[10], 1323610764), new i(w[11], 3590304994), new i(w[12], 4068182383), new i(w[13], 991336113), new i(w[14], 633803317), new i(w[15], 3479774868), new i(w[16], 2666613458), new i(w[17], 944711139), new i(w[18], 2341262773), new i(w[19], 2007800933), new i(w[20], 1495990901), new i(w[21], 1856431235), new i(w[22], 3175218132), new i(w[23], 2198950837), new i(w[24], 3999719339), new i(w[25], 766784016), new i(w[26], 2566594879), new i(w[27], 3203337956), new i(w[28], 1034457026), new i(w[29], 2466948901), new i(w[30], 3758326383), new i(w[31], 168717936), new i(w[32], 1188179964), new i(w[33], 1546045734), new i(w[34], 1522805485), new i(w[35], 2643833823), new i(w[36], 2343527390), new i(w[37], 1014477480), new i(w[38], 1206759142), new i(w[39], 344077627), new i(w[40], 1290863460), new i(w[41], 3158454273), new i(w[42], 3505952657), new i(w[43], 106217008), new i(w[44], 3606008344), new i(w[45], 1432725776), new i(w[46], 1467031594), new i(w[47], 851169720), new i(w[48], 3100823752), new i(w[49], 1363258195), new i(w[50], 3750685593), new i(w[51], 3785050280), new i(w[52], 3318307427), new i(w[53], 3812723403), new i(w[54], 2003034995), new i(w[55], 3602036899), new i(w[56], 1575990012), new i(w[57], 1125592928), new i(w[58], 2716904306), new i(w[59], 442776044), new i(w[60], 593698344), new i(w[61], 3733110249), new i(w[62], 2999351573), new i(w[63], 3815920427), new i(3391569614, 3928383900), new i(3515267271, 566280711), new i(3940187606, 3454069534), new i(4118630271, 4000239992), new i(116418474, 1914138554), new i(174292421, 2731055270), new i(289380356, 3203993006), new i(460393269, 320620315), new i(685471733, 587496836), new i(852142971, 1086792851), new i(1017036298, 365543100), new i(1126000580, 2618297676), new i(1288033470, 3409855158), new i(1501505948, 4234509866), new i(1607167915, 987167468), new i(1816402316, 1246189591)]; function Pe(t) { return t === "SHA-384" ? [new i(3418070365, F[0]), new i(1654270250, F[1]), new i(2438529370, F[2]), new i(355462360, F[3]), new i(1731405415, F[4]), new i(41048885895, F[5]), new i(3675008525, F[6]), new i(1203062813, F[7])] : [new i(Y[0], 4089235720), new i(Y[1], 2227873595), new i(Y[2], 4271175723), new i(Y[3], 1595750129), new i(Y[4], 2917565137), new i(Y[5], 725511199), new i(Y[6], 4215389547), new i(Y[7], 327033209)]; } function Ie(t, e) { let n, r, a, s, o, h, c, l, d, u, f, g; const m = []; for (n = e[0], r = e[1], a = e[2], s = e[3], o = e[4], h = e[5], c = e[6], l = e[7], f = 0; f < 80; f += 1) f < 16 ? (g = 2 * f, m[f] = new i(t[g], t[g + 1])) : m[f] = yt(pt(m[f - 2]), m[f - 7], vt(m[f - 15]), m[f - 16]), d = bt(l, St(o), (b = h, x = c, new i((y = o).N & b.N ^ ~y.N & x.N, y.I & b.I ^ ~y.I & x.I)), At[f], m[f]), u = I(gt(n), wt(n, r, a)), l = c, c = h, h = o, o = I(s, d), s = a, a = r, r = n, n = I(d, u); var y, b, x; return e[0] = I(n, e[0]), e[1] = I(r, e[1]), e[2] = I(a, e[2]), e[3] = I(s, e[3]), e[4] = I(o, e[4]), e[5] = I(h, e[5]), e[6] = I(c, e[6]), e[7] = I(l, e[7]), e; } let Nt = class extends me { constructor(t, e, n) { if (t !== "SHA-384" && t !== "SHA-512") throw new Error(oe); super(t, e, n); const r = n || {}; this.g = this.Y, this.M = !0, this.T = -1, this.C = Z(this.t, this.i, this.T), this.v = Ie, this.L = function(a) { return a.slice(); }, this.B = Pe, this.F = function(a, s, o, h) { return function(c, l, d, u, f) { let g, m; const y = 31 + (l + 129 >>> 10 << 5), b = l + d; for (; c.length <= y; ) c.push(0); for (c[l >>> 5] |= 128 << 24 - l % 32, c[y] = 4294967295 & b, c[y - 1] = b / ie | 0, g = 0; g < c.length; g += 32) u = Ie(c.slice(g, g + 32), u); return m = f === "SHA-384" ? [u[0].N, u[0].I, u[1].N, u[1].I, u[2].N, u[2].I, u[3].N, u[3].I, u[4].N, u[4].I, u[5].N, u[5].I] : [u[0].N, u[0].I, u[1].N, u[1].I, u[2].N, u[2].I, u[3].N, u[3].I, u[4].N, u[4].I, u[5].N, u[5].I, u[6].N, u[6].I, u[7].N, u[7].I], m; }(a, s, o, h, t); }, this.U = Pe(t), this.m = 1024, this.R = t === "SHA-384" ? 384 : 512, this.K = !1, r.hmacKey && this.k(K("hmacKey", r.hmacKey, this.T)); } }; const xt = [new i(0, 1), new i(0, 32898), new i(2147483648, 32906), new i(2147483648, 2147516416), new i(0, 32907), new i(0, 2147483649), new i(2147483648, 2147516545), new i(2147483648, 32777), new i(0, 138), new i(0, 136), new i(0, 2147516425), new i(0, 2147483658), new i(0, 2147516555), new i(2147483648, 139), new i(2147483648, 32905), new i(2147483648, 32771), new i(2147483648, 32770), new i(2147483648, 128), new i(0, 32778), new i(2147483648, 2147483658), new i(2147483648, 2147516545), new i(2147483648, 32896), new i(0, 2147483649), new i(2147483648, 2147516424)], Tt = [[0, 36, 3, 41, 18], [1, 44, 10, 45, 2], [62, 6, 43, 15, 61], [28, 55, 25, 21, 56], [27, 20, 39, 8, 14]]; function pe(t) { let e; const n = []; for (e = 0; e < 5; e += 1) n[e] = [new i(0, 0), new i(0, 0), new i(0, 0), new i(0, 0), new i(0, 0)]; return n; } function Et(t) { let e; const n = []; for (e = 0; e < 5; e += 1) n[e] = t[e].slice(); return n; } function ue(t, e) { let n, r, a, s; const o = [], h = []; if (t !== null) for (r = 0; r < t.length; r += 2) e[(r >>> 1) % 5][(r >>> 1) / 5 | 0] = ee(e[(r >>> 1) % 5][(r >>> 1) / 5 | 0], new i(t[r + 1], t[r])); for (n = 0; n < 24; n += 1) { for (s = pe(), r = 0; r < 5; r += 1) o[r] = (c = e[r][0], l = e[r][1], d = e[r][2], u = e[r][3], f = e[r][4], new i(c.N ^ l.N ^ d.N ^ u.N ^ f.N, c.I ^ l.I ^ d.I ^ u.I ^ f.I)); for (r = 0; r < 5; r += 1) h[r] = ee(o[(r + 4) % 5], Oe(o[(r + 1) % 5], 1)); for (r = 0; r < 5; r += 1) for (a = 0; a < 5; a += 1) e[r][a] = ee(e[r][a], h[r]); for (r = 0; r < 5; r += 1) for (a = 0; a < 5; a += 1) s[a][(2 * r + 3 * a) % 5] = Oe(e[r][a], Tt[r][a]); for (r = 0; r < 5; r += 1) for (a = 0; a < 5; a += 1) e[r][a] = ee(s[r][a], new i(~s[(r + 1) % 5][a].N & s[(r + 2) % 5][a].N, ~s[(r + 1) % 5][a].I & s[(r + 2) % 5][a].I)); e[0][0] = ee(e[0][0], xt[n]); } var c, l, d, u, f; return e; } function $e(t) { let e, n, r = 0; const a = [0, 0], s = [4294967295 & t, t / ie & 2097151]; for (e = 6; e >= 0; e--) n = s[e >> 2] >>> 8 * e & 255, n === 0 && r === 0 || (a[r + 1 >> 2] |= n << 8 * (r + 1), r += 1); return r = r !== 0 ? r : 1, a[0] |= r, { value: r + 1 > 4 ? a : [a[0]], binLen: 8 + 8 * r }; } function ge(t) { return le($e(t.binLen), t); } function Re(t, e) { let n, r = $e(e); r = le(r, t); const a = e >>> 2, s = (a - r.value.length % a) % a; for (n = 0; n < s; n++) r.value.push(0); return r.value; } let Mt = class extends me { constructor(t, e, n) { let r = 6, a = 0; super(t, e, n); const s = n || {}; if (this.numRounds !== 1) { if (s.kmacKey || s.hmacKey) throw new Error(Ke); if (this.o === "CSHAKE128" || this.o === "CSHAKE256") throw new Error("Cannot set numRounds for CSHAKE variants"); } switch (this.T = 1, this.C = Z(this.t, this.i, this.T), this.v = ue, this.L = Et, this.B = pe, this.U = pe(), this.K = !1, t) { case "SHA3-224": this.m = a = 1152, this.R = 224, this.M = !0, this.g = this.Y; break; case "SHA3-256": this.m = a = 1088, this.R = 256, this.M = !0, this.g = this.Y; break; case "SHA3-384": this.m = a = 832, this.R = 384, this.M = !0, this.g = this.Y; break; case "SHA3-512": this.m = a = 576, this.R = 512, this.M = !0, this.g = this.Y; break; case "SHAKE128": r = 31, this.m = a = 1344, this.R = -1, this.K = !0, this.M = !1, this.g = null; break; case "SHAKE256": r = 31, this.m = a = 1088, this.R = -1, this.K = !0, this.M = !1, this.g = null; break; case "KMAC128": r = 4, this.m = a = 1344, this.X(n), this.R = -1, this.K = !0, this.M = !1, this.g = this._; break; case "KMAC256": r = 4, this.m = a = 1088, this.X(n), this.R = -1, this.K = !0, this.M = !1, this.g = this._; break; case "CSHAKE128": this.m = a = 1344, r = this.O(n), this.R = -1, this.K = !0, this.M = !1, this.g = null; break; case "CSHAKE256": this.m = a = 1088, r = this.O(n), this.R = -1, this.K = !0, this.M = !1, this.g = null; break; default: throw new Error(oe); } this.F = function(o, h, c, l, d) { return function(u, f, g, m, y, b, x) { let N, M, T = 0; const P = [], U = y >>> 5, G = f >>> 5; for (N = 0; N < G && f >= y; N += U) m = ue(u.slice(N, N + U), m), f -= y; for (u = u.slice(N), f %= y; u.length < U; ) u.push(0); for (N = f >>> 3, u[N >> 2] ^= b << N % 4 * 8, u[U - 1] ^= 2147483648, m = ue(u, m); 32 * P.length < x && (M = m[T % 5][T / 5 | 0], P.push(M.I), !(32 * P.length >= x)); ) P.push(M.N), T += 1, 64 * T % y == 0 && (ue(null, m), T = 0); return P; }(o, h, 0, l, a, r, d); }, s.hmacKey && this.k(K("hmacKey", s.hmacKey, this.T)); } O(t, e) { const n = function(a) { const s = a || {}; return { funcName: K("funcName", s.funcName, 1, { value: [], binLen: 0 }), customization: K("Customization", s.customization, 1, { value: [], binLen: 0 }) }; }(t || {}); e && (n.funcName = e); const r = le(ge(n.funcName), ge(n.customization)); if (n.customization.binLen !== 0 || n.funcName.binLen !== 0) { const a = Re(r, this.m >>> 3); for (let s = 0; s < a.length; s += this.m >>> 5) this.U = this.v(a.slice(s, s + (this.m >>> 5)), this.U), this.A += this.m; return 4; } return 31; } X(t) { const e = function(r) { const a = r || {}; return { kmacKey: K("kmacKey", a.kmacKey, 1), funcName: { value: [1128353099], binLen: 32 }, customization: K("Customization", a.customization, 1, { value: [], binLen: 0 }) }; }(t || {}); this.O(t, e.funcName); const n = Re(ge(e.kmacKey), this.m >>> 3); for (let r = 0; r < n.length; r += this.m >>> 5) this.U = this.v(n.slice(r, r + (this.m >>> 5)), this.U), this.A += this.m; this.H = !0; } _(t) { const e = le({ value: this.h.slice(), binLen: this.u }, function(n) { let r, a, s = 0; const o = [0, 0], h = [4294967295 & n, n / ie & 2097151]; for (r = 6; r >= 0; r--) a = h[r >> 2] >>> 8 * r & 255, a === 0 && s === 0 || (o[s >> 2] |= a << 8 * s, s += 1); return s = s !== 0 ? s : 1, o[s >> 2] |= s << 8 * s, { value: s + 1 > 4 ? o : [o[0]], binLen: 8 + 8 * s }; }(t.outputLen)); return this.F(e.value, e.binLen, this.A, this.L(this.U), t.outputLen); } }; class Ot { constructor(e, n, r) { if (e == "SHA-1") this.P = new dt(e, n, r); else if (e == "SHA-224" || e == "SHA-256") this.P = new mt(e, n, r); else if (e == "SHA-384" || e == "SHA-512") this.P = new Nt(e, n, r); else { if (e != "SHA3-224" && e != "SHA3-256" && e != "SHA3-384" && e != "SHA3-512" && e != "SHAKE128" && e != "SHAKE256" && e != "CSHAKE128" && e != "CSHAKE256" && e != "KMAC128" && e != "KMAC256") throw new Error(oe); this.P = new Mt(e, n, r); } } update(e) { return this.P.update(e), this; } getHash(e, n) { return this.P.getHash(e, n); } setHMACKey(e, n, r) { this.P.setHMACKey(e, n, r); } getHMAC(e, n) { return this.P.getHMAC(e, n); } } function Pt(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } var Ve = { exports: {} }, A = Ve.exports = {}, k, L; function ve() { throw new Error("setTimeout has not been defined"); } function Se() { throw new Error("clearTimeout has not been defined"); } (function() { try { typeof setTimeout == "function" ? k = setTimeout : k = ve; } catch { k = ve; } try { typeof clearTimeout == "function" ? L = clearTimeout : L = Se; } catch { L = Se; } })(); function Je(t) { if (k === setTimeout) return setTimeout(t, 0); if ((k === ve || !k) && setTimeout) return k = setTimeout, setTimeout(t, 0); try { return k(t, 0); } catch { try { return k.call(null, t, 0); } catch { return k.call(this, t, 0); } } } function It(t) { if (L === clearTimeout) return clearTimeout(t); if ((L === Se || !L) && clearTimeout) return L = clearTimeout, clearTimeout(t); try { return L(t); } catch { try { return L.call(null, t); } catch { return L.call(this, t); } } } var q = [], J = !1, X, he = -1; function Rt() { !J || !X || (J = !1, X.length ? q = X.concat(q) : he = -1, q.length && ze()); } function ze() { if (!J) { var t = Je(Rt); J = !0; for (var e = q.length; e; ) { for (X = q, q = []; ++he < e; ) X && X[he].run(); he = -1, e = q.length; } X = null, J = !1, It(t); } } A.nextTick = function(t) { var e = new Array(arguments.length - 1); if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) e[n - 1] = arguments[n]; q.push(new Ze(t, e)), q.length === 1 && !J && Je(ze); }; function Ze(t, e) { this.fun = t, this.array = e; } Ze.prototype.run = function() { this.fun.apply(null, this.array); }; A.title = "browser"; A.browser = !0; A.env = {}; A.argv = []; A.version = ""; A.versions = {}; function C() { } A.on = C; A.addListener = C; A.once = C; A.off = C; A.removeListener = C; A.removeAllListeners = C; A.emit = C; A.prependListener = C; A.prependOnceListener = C; A.listeners = function(t) { return []; }; A.binding = function(t) { throw new Error("process.binding is not supported"); }; A.cwd = function() { return "/"; }; A.chdir = function(t) { throw new Error("process.chdir is not supported"); }; A.umask = function() { return 0; }; var Dt = Ve.exports; const z = /* @__PURE__ */ Pt(Dt); var kt = typeof window < "u" && typeof window.document < "u"; // @ts-expect-error typeof z < "u" && // @ts-expect-error z.versions != null && // @ts-expect-error z.versions.node != null; typeof window < "u" && window.name === "nodejs" || typeof navigator < "u" && "userAgent" in navigator && typeof navigator.userAgent == "string" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom")); // @ts-expect-error typeof Deno < "u" && // @ts-expect-error typeof Deno.version < "u" && // @ts-expect-error typeof Deno.version.deno < "u"; typeof z < "u" && z.versions != null && z.versions.bun != null; var R = /* @__PURE__ */ ((t) => (t[t.InvalidCountryCode = 201] = "InvalidCountryCode", t[t.InvalidRecipientNumber = 202] = "InvalidRecipientNumber", t[t.MissingAuthentication = 300] = "MissingAuthentication", t[t.MissingParameterTo = 301] = "MissingParameterTo", t[t.MissingParameterType = 304] = "MissingParameterType", t[t.MissingParameterText = 305] = "MissingParameterText", t[t.InvalidSender = 306] = "InvalidSender", t[t.MissingParameterUrl = 307] = "MissingParameterUrl", t[t.InvalidType = 400] = "InvalidType", t[t.ParameterLongExceedsCharLimit = 401] = "ParameterLongExceedsCharLimit", t[t.PreventedByReloadLock = 402] = "PreventedByReloadLock", t[t.DailyLimitReachedForNumber = 403] = "DailyLimitReachedForNumber", t[t.InsufficientCredits = 500] = "InsufficientCredits", t[t.CarrierFailed = 600] = "CarrierFailed", t[t.UnknownError = 700] = "UnknownError", t[t.MissingLogoFile = 801] = "MissingLogoFile", t[t.NonExistingLogoFile = 802] = "NonExistingLogoFile", t[t.MissingRingTone = 803] = "MissingRingTone", t[t.InvalidApiKey = 900] = "InvalidApiKey", t[t.InvalidMessageId = 901] = "InvalidMessageId", t[t.DeactivatedApi = 902] = "DeactivatedApi", t[t.DisallowedIp = 903] = "DisallowedIp", t))(R || {}); class Lt { static uuid(e = 32) { return [...Array(e)].map(() => Math.random().toString(36)[2]).join(""); } } const V = class V { constructor(e) { S(this, "request", async (e, n, r, a = "application/json") => { let s = `${V.BASE_URL}/${n}`; const o = { Accept: "application/json", "Content-Type": a, SentWith: this.options.sentWith ?? "js" }; this.options.apiKey.startsWith("Bearer ") ? o.Authorization = this.options.apiKey : o["X-Api-Key"] = this.options.apiKey; const h = { method: e }, c = a === V.CONTENT_TYPE_URLENCODED, l = new URLSearchParams(); if (r && Object.keys(r).length) switch (Object.entries(r).forEach(([m, y]) => { Array.isArray(y) ? y.forEach((b) => l.append(m, b)) : l.set(m, y); }), e) { case "get": s += `?${l.toString()}`; break; default: h.body = c ? l.toString() : JSON.stringify(r); } if (this.options.signingSecret) { const m = () => Object.keys(r).length ? c ? l.toString() : e === "get" ? "" : JSON.stringify(r) : "", y = Number.parseInt((Date.now() / 1e3).toString()), b = Lt.uuid(32), x = e.toUpperCase(), N = m(); let M; if (kt) { const { md5: U } = await import("./md5-CKqfIF0D.js").then((G) => G.m); M = U(N); } else { const { createHash: U } = await import("./index-9mKjRVJO.js").then((at) => at.i), G = U("md5"); G.update(N), M = G.digest("hex"); } const T = [y, b, x, s, M].join(` `), P = new Ot("SHA-256", "TEXT", { hmacKey: { format: "TEXT", value: this.options.signingSecret } }).update(T).getHash("HEX"); o["X-Nonce"] = b, o["X-Signature"] = P, o["X-Timestamp"] = y.toString(); } const d = await fetch(s, { ...h, headers: o }); let u = await d.text(), f = null; try { u = JSON.parse(u); } catch { } const g = typeof u; if (g === "string" || g === "number") { const m = Number.parseFloat(`${u}`); Number.isInteger(m) && (f = m); } if (this.options.debug && console.debug({ request: { ...h, body: h.body instanceof URLSearchParams ? Object.fromEntries(h.body) : h.body, url: s }, response: { apiCode: f, body: u, headers: Object.fromEntries(d.headers), status: d.status } }), f && f in R) throw new Error(`${f}: ${R[f]}`); return u; }); this.options = e; } }; S(V, "BASE_URL", "https://gateway.seven.io/api"), S(V, "CONTENT_TYPE_URLENCODED", "application/x-www-form-urlencoded"); let fe = V; class O { constructor(e) { this.client = e; } } const et = 6048e5, Ht = 864e5, De = Symbol.for("constructDateFrom"); function B(t, e) { return typeof t == "function" ? t(e) : t && typeof t == "object" && De in t ? t[De](e) : t instanceof Date ? new t.constructor(e) : new Date(e); } function D(t, e) { return B(e || t, t); } let _t = {}; function we() { return _t; } function se(t, e) { var h, c, l, d; const n = we(), r = (e == null ? void 0 : e.weekStartsOn) ?? ((c = (h = e == null ? void 0 : e.locale) == null ? void 0 : h.options) == null ? void 0 : c.weekStartsOn) ?? n.weekStartsOn ?? ((d = (l = n.locale) == null ? void 0 : l.options) == null ? void 0 : d.weekStartsOn) ?? 0, a = D(t, e == null ? void 0 : e.in), s = a.getDay(), o = (s < r ? 7 : 0) + s - r; return a.setDate(a.getDate() - o), a.setHours(0, 0, 0, 0), a; } function de(t, e) { return se(t, { ...e, weekStartsOn: 1 }); } function tt(t, e) { const n = D(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = B(n, 0); a.setFullYear(r + 1, 0, 4), a.setHours(0, 0, 0, 0); const s = de(a), o = B(n, 0); o.setFullYear(r, 0, 4), o.setHours(0, 0, 0, 0); const h = de(o); return n.getTime() >= s.getTime() ? r + 1 : n.getTime() >= h.getTime() ? r : r - 1; } function ke(t) { const e = D(t), n = new Date( Date.UTC( e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds() ) ); return n.setUTCFullYear(e.getFullYear()), +t - +n; } function Ft(t, ...e) { const n = B.bind( null, e.find((r) => typeof r == "object") ); return e.map(n); } function Le(t, e) { const n = D(t, e == null ? void 0 : e.in); return n.setHours(0, 0, 0, 0), n; } function Yt(t, e, n) { const [r, a] = Ft( n == null ? void 0 : n.in, t, e ), s = Le(r), o = Le(a), h = +s - ke(s), c = +o - ke(o); return Math.round((h - c) / Ht); } function qt(t, e) { const n = tt(t, e), r = B(t, 0); return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), de(r); } function Ct(t) { return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]"; } function Ut(t) { return !(!Ct(t) && typeof t != "number" || isNaN(+D(t))); } function Wt(t, e) { const n = D(t, e == null ? void 0 : e.in); return n.setFullYear(n.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n; } const Kt = { lessThanXSeconds: { one: "less than a second", other: "less than {{count}} seconds" }, xSeconds: { one: "1 second", other: "{{count}} seconds" }, halfAMinute: "half a minute", lessThanXMinutes: { one: "less than a minute", other: "less than {{count}} minutes" }, xMinutes: { one: "1 minute", other: "{{count}} minutes" }, aboutXHours: { one: "about 1 hour", other: "about {{count}} hours" }, xHours: { one: "1 hour", other: "{{count}} hours" }, xDays: { one: "1 day", other: "{{count}} days" }, aboutXWeeks: { one: "about 1 week", other: "about {{count}} weeks" }, xWeeks: { one: "1 week", other: "{{count}} weeks" }, aboutXMonths: { one: "about 1 month", other: "about {{count}} months" }, xMonths: { one: "1 month", other: "{{count}} months" }, aboutXYears: { one: "about 1 year", other: "about {{count}} years" }, xYears: { one: "1 year", other: "{{count}} years" }, overXYears: { one: "over 1 year", other: "over {{count}} years" }, almostXYears: { one: "almost 1 year", other: "almost {{count}} years" } }, Bt = (t, e, n) => { let r; const a = Kt[t]; return typeof a == "string" ? r = a : e === 1 ? r = a.one : r = a.other.replace("{{count}}", e.toString()), n != null && n.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r; }; function ye(t) { return (e = {}) => { const n = e.width ? String(e.width) : t.defaultWidth; return t.formats[n] || t.formats[t.defaultWidth]; }; } const jt = { full: "EEEE, MMMM do, y", long: "MMMM do, y", medium: "MMM d, y", short: "MM/dd/yyyy" }, Xt = { full: "h:mm:ss a zzzz", long: "h:mm:ss a z", medium: "h:mm:ss a", short: "h:mm a" }, Gt = { full: "{{date}} 'at' {{time}}", long: "{{date}} 'at' {{time}}", medium: "{{date}}, {{time}}", short: "{{date}}, {{time}}" }, Qt = { date: ye({ formats: jt, defaultWidth: "full" }), time: ye({ formats: Xt, defaultWidth: "full" }), dateTime: ye({ formats: Gt, defaultWidth: "full" }) }, $t = { lastWeek: "'last' eeee 'at' p", yesterday: "'yesterday at' p", today: "'today at' p", tomorrow: "'tomorrow at' p", nextWeek: "eeee 'at' p", other: "P" }, Vt = (t, e, n, r) => $t[t]; function te(t) { return (e, n) => { const r = n != null && n.context ? String(n.context) : "standalone"; let a; if (r === "formatting" && t.formattingValues) { const o = t.defaultFormattingWidth || t.defaultWidth, h = n != null && n.width ? String(n.width) : o; a = t.formattingValues[h] || t.formattingValues[o]; } else { const o = t.defaultWidth, h = n != null && n.width ? String(n.width) : t.defaultWidth; a = t.values[h] || t.values[o]; } const s = t.argumentCallback ? t.argumentCallback(e) : e; return a[s]; }; } const Jt = { narrow: ["B", "A"], abbreviated: ["BC", "AD"], wide: ["Before Christ", "Anno Domini"] }, zt = { narrow: ["1", "2", "3", "4"], abbreviated: ["Q1", "Q2", "Q3", "Q4"], wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] }, Zt = { narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], abbreviated: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], wide: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] }, en = { narrow: ["S", "M", "T", "W", "T", "F", "S"], short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], wide: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] }, tn = { narrow: { am: "a", pm: "p", midnight: "mi", noon: "n", morning: "morning", afternoon: "afternoon", evening: "evening", night: "night" }, abbreviated: { am: "AM", pm: "PM", midnight: "midnight", noon: "noon", morning: "morning", afternoon: "afternoon", evening: "evening", night: "night" }, wide: { am: "a.m.", pm: "p.m.", midnight: "midnight", noon: "noon", morning: "morning", afternoon: "afternoon", evening: "evening", night: "night" } }, nn = { narrow: { am: "a", pm: "p", midnight: "mi", noon: "n", morning: "in the morning", afternoon: "in the afternoon", evening: "in the evening", night: "at night" }, abbreviated: { am: "AM", pm: "PM", midnight: "midnight", noon: "noon", morning: "in the morning", afternoon: "in the afternoon", evening: "in the evening", night: "at night" }, wide: { am: "a.m.", pm: "p.m.", midnight: "midnight", noon: "noon", morning: "in the morning", afternoon: "in the afternoon", evening: "in the evening", night: "at night" } }, rn = (t, e) => { const n = Number(t), r = n % 100; if (r > 20 || r < 10) switch (r % 10) { case 1: return n + "st"; case 2: return n + "nd"; case 3: return n + "rd"; } return n + "th"; }, an = { ordinalNumber: rn, era: te({ values: Jt, defaultWidth: "wide" }), quarter: te({ values: zt, defaultWidth: "wide", argumentCallback: (t) => t - 1 }), month: te({ values: Zt, defaultWidth: "wide" }), day: te({ values: en, defaultWidth: "wide" }), dayPeriod: te({ values: tn, defaultWidth: "wide", formattingValues: nn, defaultFormattingWidth: "wide" }) }; function ne(t) { return (e, n = {}) => { const r = n.width, a = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], s = e.match(a); if (!s) return null; const o = s[0], h = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], c = Array.isArray(h) ? on(h, (u) => u.test(o)) : ( // [TODO] -- I challenge you to fix the type sn(h, (u) => u.test(o)) ); let l; l = t.valueCallback ? t.valueCallback(c) : c, l = n.valueCallback ? ( // [TODO] -- I challenge you to fix the type n.valueCallback(l) ) : l; const d = e.slice(o.length); return { value: l, rest: d }; }; } function sn(t, e) { for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n) && e(t[n])) return n; } function on(t, e) { for (let n = 0; n < t.length; n++) if (e(t[n])) return n; } function un(t) { return (e, n = {}) => { const r = e.match(t.matchPattern); if (!r) return null; const a = r[0], s = e.match(t.parsePattern); if (!s) return null; let o = t.valueCallback ? t.valueCallback(s[0]) : s[0]; o = n.valueCallback ? n.valueCallback(o) : o; const h = e.slice(a.length); return { value: o, rest: h }; }; } const cn = /^(\d+)(th|st|nd|rd)?/i, hn = /\d+/i, ln = { narrow: /^(b|a)/i, abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, wide: /^(before christ|before common era|anno domini|common era)/i }, fn = { any: [/^b/i, /^(a|c)/i] }, dn = { narrow: /^[1234]/i, abbreviated: /^q[1234]/i, wide: /^[1234](th|st|nd|rd)? quarter/i }, mn = { any: [/1/i, /2/i, /3/i, /4/i] }, wn = { narrow: /^[jfmasond]/i, abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i }, gn = { narrow: [ /^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i ], any: [ /^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i ] }, yn = { narrow: /^[smtwf]/i, short: /^(su|mo|tu|we|th|fr|sa)/i, abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i }, bn = { narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] }, pn = { narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i }, vn = { any: { am: /^a/i, pm: /^p/i, midnight: /^mi/i, noon: /^no/i, morning: /morning/i, afternoon: /afternoon/i, evening: /evening/i, night: /night/i } }, Sn = { ordinalNumber: un({ matchPattern: cn, parsePattern: hn, valueCallback: (t) => parseInt(t, 10) }), era: ne({ matchPatterns: ln, defaultMatchWidth: "wide", parsePatterns: fn, defaultParseWidth: "any" }), quarter: ne({ matchPatterns: dn, defaultMatchWidth: "wide", parsePatterns: mn, defaultParseWidth: "any", valueCallback: (t) => t + 1 }), month: ne({ matchPatterns: wn, defaultMatchWidth: "wide", parsePatterns: gn, defaultParseWidth: "any" }), day: ne({ matchPatterns: yn, defaultMatchWidth: "wide", parsePatterns: bn, defaultParseWidth: "any" }), dayPeriod: ne({ matchPatterns: pn, defaultMatchWidth: "any", parsePatterns: vn, defaultParseWidth: "any" }) }, An = { code: "en-US", formatDistance: Bt, formatLong: Qt, formatRelative: Vt, localize: an, match: Sn, options: { weekStartsOn: 0, firstWeekContainsDate: 1 } }; function Nn(t, e) { const n = D(t, e == null ? void 0 : e.in); return Yt(n, Wt(n)) + 1; } function xn(t, e) { const n = D(t, e == null ? void 0 : e.in), r = +de(n) - +qt(n); return Math.round(r / et) + 1; } function nt(t, e) { var d, u, f, g; const n = D(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = we(), s = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((u = (d = e == null ? void 0 : e.locale) == null ? void 0 : d.options) == null ? void 0 : u.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((g = (f = a.locale) == null ? void 0 : f.options) == null ? void 0 : g.firstWeekContainsDate) ?? 1, o = B((e == null ? void 0 : e.in) || t, 0); o.setFullYear(r + 1, 0, s), o.setHours(0, 0, 0, 0); const h = se(o, e), c = B((e == null ? void 0 : e.in) || t, 0); c.setFullYear(r, 0, s), c.setHours(0, 0, 0, 0); const l = se(c, e); return +n >= +h ? r + 1 : +n >= +l ? r : r - 1; } function Tn(t, e) { var h, c, l, d; const n = we(), r = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((c = (h = e == null ? void 0 : e.locale) == null ? void 0 : h.optio