UNPKG

@danidoble/webserial

Version:
1,282 lines 208 kB
var yn = Object.defineProperty; var Te = (n) => { throw TypeError(n); }; var bn = (n, i, t) => i in n ? yn(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t; var Ce = (n, i, t) => bn(n, typeof i != "symbol" ? i + "" : i, t), Pn = (n, i, t) => i.has(n) || Te("Cannot " + t); var Ae = (n, i, t) => i.has(n) ? Te("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(n) : i.set(n, t); var p = (n, i, t) => (Pn(n, i, "access private method"), t); import { K as vn, a as wn, h as Re, i as G, b as Oe, w as xe } from "./kernel-BLbpgXHp.js"; var En = "0123456789abcdefghijklmnopqrstuvwxyz"; function $(n) { return En.charAt(n); } function Sn(n, i) { return n & i; } function Et(n, i) { return n | i; } function De(n, i) { return n ^ i; } function Ie(n, i) { return n & ~i; } function Tn(n) { if (n == 0) return -1; var i = 0; return (n & 65535) == 0 && (n >>= 16, i += 16), (n & 255) == 0 && (n >>= 8, i += 8), (n & 15) == 0 && (n >>= 4, i += 4), (n & 3) == 0 && (n >>= 2, i += 2), (n & 1) == 0 && ++i, i; } function Cn(n) { for (var i = 0; n != 0; ) n &= n - 1, ++i; return i; } var at = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ti = "="; function Vt(n) { var i, t, e = ""; for (i = 0; i + 3 <= n.length; i += 3) t = parseInt(n.substring(i, i + 3), 16), e += at.charAt(t >> 6) + at.charAt(t & 63); for (i + 1 == n.length ? (t = parseInt(n.substring(i, i + 1), 16), e += at.charAt(t << 2)) : i + 2 == n.length && (t = parseInt(n.substring(i, i + 2), 16), e += at.charAt(t >> 2) + at.charAt((t & 3) << 4)); (e.length & 3) > 0; ) e += ti; return e; } function Be(n) { var i = "", t, e = 0, r = 0; for (t = 0; t < n.length && n.charAt(t) != ti; ++t) { var s = at.indexOf(n.charAt(t)); s < 0 || (e == 0 ? (i += $(s >> 2), r = s & 3, e = 1) : e == 1 ? (i += $(r << 2 | s >> 4), r = s & 15, e = 2) : e == 2 ? (i += $(r), i += $(s >> 2), r = s & 3, e = 3) : (i += $(r << 2 | s >> 4), i += $(s & 15), e = 0)); } return e == 1 && (i += $(r << 2)), i; } var rt, An = { decode: function(n) { var i; if (rt === void 0) { var t = "0123456789ABCDEF", e = ` \f \r  \u2028\u2029`; for (rt = {}, i = 0; i < 16; ++i) rt[t.charAt(i)] = i; for (t = t.toLowerCase(), i = 10; i < 16; ++i) rt[t.charAt(i)] = i; for (i = 0; i < e.length; ++i) rt[e.charAt(i)] = -1; } var r = [], s = 0, a = 0; for (i = 0; i < n.length; ++i) { var o = n.charAt(i); if (o == "=") break; if (o = rt[o], o != -1) { if (o === void 0) throw new Error("Illegal character at offset " + i); s |= o, ++a >= 2 ? (r[r.length] = s, s = 0, a = 0) : s <<= 4; } } if (a) throw new Error("Hex encoding incomplete: 4 bits missing"); return r; } }, Y, Yt = { decode: function(n) { var i; if (Y === void 0) { var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", e = `= \f \r  \u2028\u2029`; for (Y = /* @__PURE__ */ Object.create(null), i = 0; i < 64; ++i) Y[t.charAt(i)] = i; for (Y["-"] = 62, Y._ = 63, i = 0; i < e.length; ++i) Y[e.charAt(i)] = -1; } var r = [], s = 0, a = 0; for (i = 0; i < n.length; ++i) { var o = n.charAt(i); if (o == "=") break; if (o = Y[o], o != -1) { if (o === void 0) throw new Error("Illegal character at offset " + i); s |= o, ++a >= 4 ? (r[r.length] = s >> 16, r[r.length] = s >> 8 & 255, r[r.length] = s & 255, s = 0, a = 0) : s <<= 6; } } switch (a) { case 1: throw new Error("Base64 encoding incomplete: at least 2 bits missing"); case 2: r[r.length] = s >> 10; break; case 3: r[r.length] = s >> 16, r[r.length] = s >> 8 & 255; break; } return r; }, re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/, unarmor: function(n) { var i = Yt.re.exec(n); if (i) if (i[1]) n = i[1]; else if (i[2]) n = i[2]; else throw new Error("RegExp out of sync"); return Yt.decode(n); } }, st = 1e13, pt = ( /** @class */ function() { function n(i) { this.buf = [+i || 0]; } return n.prototype.mulAdd = function(i, t) { var e = this.buf, r = e.length, s, a; for (s = 0; s < r; ++s) a = e[s] * i + t, a < st ? t = 0 : (t = 0 | a / st, a -= t * st), e[s] = a; t > 0 && (e[s] = t); }, n.prototype.sub = function(i) { var t = this.buf, e = t.length, r, s; for (r = 0; r < e; ++r) s = t[r] - i, s < 0 ? (s += st, i = 1) : i = 0, t[r] = s; for (; t[t.length - 1] === 0; ) t.pop(); }, n.prototype.toString = function(i) { if ((i || 10) != 10) throw new Error("only base 10 is supported"); for (var t = this.buf, e = t[t.length - 1].toString(), r = t.length - 2; r >= 0; --r) e += (st + t[r]).toString().substring(1); return e; }, n.prototype.valueOf = function() { for (var i = this.buf, t = 0, e = i.length - 1; e >= 0; --e) t = t * st + i[e]; return t; }, n.prototype.simplify = function() { var i = this.buf; return i.length == 1 ? i[0] : this; }, n; }() ), ei = "…", Rn = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/, On = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/; function ct(n, i) { return n.length > i && (n = n.substring(0, i) + ei), n; } var zt = ( /** @class */ function() { function n(i, t) { this.hexDigits = "0123456789ABCDEF", i instanceof n ? (this.enc = i.enc, this.pos = i.pos) : (this.enc = i, this.pos = t); } return n.prototype.get = function(i) { if (i === void 0 && (i = this.pos++), i >= this.enc.length) throw new Error("Requesting byte offset ".concat(i, " on a stream of length ").concat(this.enc.length)); return typeof this.enc == "string" ? this.enc.charCodeAt(i) : this.enc[i]; }, n.prototype.hexByte = function(i) { return this.hexDigits.charAt(i >> 4 & 15) + this.hexDigits.charAt(i & 15); }, n.prototype.hexDump = function(i, t, e) { for (var r = "", s = i; s < t; ++s) if (r += this.hexByte(this.get(s)), e !== !0) switch (s & 15) { case 7: r += " "; break; case 15: r += ` `; break; default: r += " "; } return r; }, n.prototype.isASCII = function(i, t) { for (var e = i; e < t; ++e) { var r = this.get(e); if (r < 32 || r > 176) return !1; } return !0; }, n.prototype.parseStringISO = function(i, t) { for (var e = "", r = i; r < t; ++r) e += String.fromCharCode(this.get(r)); return e; }, n.prototype.parseStringUTF = function(i, t) { for (var e = "", r = i; r < t; ) { var s = this.get(r++); s < 128 ? e += String.fromCharCode(s) : s > 191 && s < 224 ? e += String.fromCharCode((s & 31) << 6 | this.get(r++) & 63) : e += String.fromCharCode((s & 15) << 12 | (this.get(r++) & 63) << 6 | this.get(r++) & 63); } return e; }, n.prototype.parseStringBMP = function(i, t) { for (var e = "", r, s, a = i; a < t; ) r = this.get(a++), s = this.get(a++), e += String.fromCharCode(r << 8 | s); return e; }, n.prototype.parseTime = function(i, t, e) { var r = this.parseStringISO(i, t), s = (e ? Rn : On).exec(r); return s ? (e && (s[1] = +s[1], s[1] += +s[1] < 70 ? 2e3 : 1900), r = s[1] + "-" + s[2] + "-" + s[3] + " " + s[4], s[5] && (r += ":" + s[5], s[6] && (r += ":" + s[6], s[7] && (r += "." + s[7]))), s[8] && (r += " UTC", s[8] != "Z" && (r += s[8], s[9] && (r += ":" + s[9]))), r) : "Unrecognized time: " + r; }, n.prototype.parseInteger = function(i, t) { for (var e = this.get(i), r = e > 127, s = r ? 255 : 0, a, o = ""; e == s && ++i < t; ) e = this.get(i); if (a = t - i, a === 0) return r ? -1 : 0; if (a > 4) { for (o = e, a <<= 3; ((+o ^ s) & 128) == 0; ) o = +o << 1, --a; o = "(" + a + ` bit) `; } r && (e = e - 256); for (var c = new pt(e), u = i + 1; u < t; ++u) c.mulAdd(256, this.get(u)); return o + c.toString(); }, n.prototype.parseBitString = function(i, t, e) { for (var r = this.get(i), s = (t - i - 1 << 3) - r, a = "(" + s + ` bit) `, o = "", c = i + 1; c < t; ++c) { for (var u = this.get(c), l = c == t - 1 ? r : 0, f = 7; f >= l; --f) o += u >> f & 1 ? "1" : "0"; if (o.length > e) return a + ct(o, e); } return a + o; }, n.prototype.parseOctetString = function(i, t, e) { if (this.isASCII(i, t)) return ct(this.parseStringISO(i, t), e); var r = t - i, s = "(" + r + ` byte) `; e /= 2, r > e && (t = i + e); for (var a = i; a < t; ++a) s += this.hexByte(this.get(a)); return r > e && (s += ei), s; }, n.prototype.parseOID = function(i, t, e) { for (var r = "", s = new pt(), a = 0, o = i; o < t; ++o) { var c = this.get(o); if (s.mulAdd(128, c & 127), a += 7, !(c & 128)) { if (r === "") if (s = s.simplify(), s instanceof pt) s.sub(80), r = "2." + s.toString(); else { var u = s < 80 ? s < 40 ? 0 : 1 : 2; r = u + "." + (s - u * 40); } else r += "." + s.toString(); if (r.length > e) return ct(r, e); s = new pt(), a = 0; } } return a > 0 && (r += ".incomplete"), r; }, n; }() ), xn = ( /** @class */ function() { function n(i, t, e, r, s) { if (!(r instanceof Ne)) throw new Error("Invalid tag value."); this.stream = i, this.header = t, this.length = e, this.tag = r, this.sub = s; } return n.prototype.typeName = function() { switch (this.tag.tagClass) { case 0: switch (this.tag.tagNumber) { case 0: return "EOC"; case 1: return "BOOLEAN"; case 2: return "INTEGER"; case 3: return "BIT_STRING"; case 4: return "OCTET_STRING"; case 5: return "NULL"; case 6: return "OBJECT_IDENTIFIER"; case 7: return "ObjectDescriptor"; case 8: return "EXTERNAL"; case 9: return "REAL"; case 10: return "ENUMERATED"; case 11: return "EMBEDDED_PDV"; case 12: return "UTF8String"; case 16: return "SEQUENCE"; case 17: return "SET"; case 18: return "NumericString"; case 19: return "PrintableString"; // ASCII subset case 20: return "TeletexString"; // aka T61String case 21: return "VideotexString"; case 22: return "IA5String"; // ASCII case 23: return "UTCTime"; case 24: return "GeneralizedTime"; case 25: return "GraphicString"; case 26: return "VisibleString"; // ASCII subset case 27: return "GeneralString"; case 28: return "UniversalString"; case 30: return "BMPString"; } return "Universal_" + this.tag.tagNumber.toString(); case 1: return "Application_" + this.tag.tagNumber.toString(); case 2: return "[" + this.tag.tagNumber.toString() + "]"; // Context case 3: return "Private_" + this.tag.tagNumber.toString(); } }, n.prototype.content = function(i) { if (this.tag === void 0) return null; i === void 0 && (i = 1 / 0); var t = this.posContent(), e = Math.abs(this.length); if (!this.tag.isUniversal()) return this.sub !== null ? "(" + this.sub.length + " elem)" : this.stream.parseOctetString(t, t + e, i); switch (this.tag.tagNumber) { case 1: return this.stream.get(t) === 0 ? "false" : "true"; case 2: return this.stream.parseInteger(t, t + e); case 3: return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseBitString(t, t + e, i); case 4: return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseOctetString(t, t + e, i); // case 0x05: // NULL case 6: return this.stream.parseOID(t, t + e, i); // case 0x07: // ObjectDescriptor // case 0x08: // EXTERNAL // case 0x09: // REAL // case 0x0A: // ENUMERATED // case 0x0B: // EMBEDDED_PDV case 16: // SEQUENCE case 17: return this.sub !== null ? "(" + this.sub.length + " elem)" : "(no elem)"; case 12: return ct(this.stream.parseStringUTF(t, t + e), i); case 18: // NumericString case 19: // PrintableString case 20: // TeletexString case 21: // VideotexString case 22: // IA5String // case 0x19: // GraphicString case 26: return ct(this.stream.parseStringISO(t, t + e), i); case 30: return ct(this.stream.parseStringBMP(t, t + e), i); case 23: // UTCTime case 24: return this.stream.parseTime(t, t + e, this.tag.tagNumber == 23); } return null; }, n.prototype.toString = function() { return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + (this.sub === null ? "null" : this.sub.length) + "]"; }, n.prototype.toPrettyString = function(i) { i === void 0 && (i = ""); var t = i + this.typeName() + " @" + this.stream.pos; if (this.length >= 0 && (t += "+"), t += this.length, this.tag.tagConstructed ? t += " (constructed)" : this.tag.isUniversal() && (this.tag.tagNumber == 3 || this.tag.tagNumber == 4) && this.sub !== null && (t += " (encapsulates)"), t += ` `, this.sub !== null) { i += " "; for (var e = 0, r = this.sub.length; e < r; ++e) t += this.sub[e].toPrettyString(i); } return t; }, n.prototype.posStart = function() { return this.stream.pos; }, n.prototype.posContent = function() { return this.stream.pos + this.header; }, n.prototype.posEnd = function() { return this.stream.pos + this.header + Math.abs(this.length); }, n.prototype.toHexString = function() { return this.stream.hexDump(this.posStart(), this.posEnd(), !0); }, n.decodeLength = function(i) { var t = i.get(), e = t & 127; if (e == t) return e; if (e > 6) throw new Error("Length over 48 bits not supported at position " + (i.pos - 1)); if (e === 0) return null; t = 0; for (var r = 0; r < e; ++r) t = t * 256 + i.get(); return t; }, n.prototype.getHexStringValue = function() { var i = this.toHexString(), t = this.header * 2, e = this.length * 2; return i.substr(t, e); }, n.decode = function(i) { var t; i instanceof zt ? t = i : t = new zt(i, 0); var e = new zt(t), r = new Ne(t), s = n.decodeLength(t), a = t.pos, o = a - e.pos, c = null, u = function() { var f = []; if (s !== null) { for (var g = a + s; t.pos < g; ) f[f.length] = n.decode(t); if (t.pos != g) throw new Error("Content size is not correct for container starting at offset " + a); } else try { for (; ; ) { var P = n.decode(t); if (P.tag.isEOC()) break; f[f.length] = P; } s = a - t.pos; } catch (m) { throw new Error("Exception while decoding undefined length content: " + m); } return f; }; if (r.tagConstructed) c = u(); else if (r.isUniversal() && (r.tagNumber == 3 || r.tagNumber == 4)) try { if (r.tagNumber == 3 && t.get() != 0) throw new Error("BIT STRINGs with unused bits cannot encapsulate."); c = u(); for (var l = 0; l < c.length; ++l) if (c[l].tag.isEOC()) throw new Error("EOC is not supposed to be actual content."); } catch { c = null; } if (c === null) { if (s === null) throw new Error("We can't skip over an invalid tag with undefined length at offset " + a); t.pos = a + Math.abs(s); } return new n(e, o, s, r, c); }, n; }() ), Ne = ( /** @class */ function() { function n(i) { var t = i.get(); if (this.tagClass = t >> 6, this.tagConstructed = (t & 32) !== 0, this.tagNumber = t & 31, this.tagNumber == 31) { var e = new pt(); do t = i.get(), e.mulAdd(128, t & 127); while (t & 128); this.tagNumber = e.simplify(); } } return n.prototype.isUniversal = function() { return this.tagClass === 0; }, n.prototype.isEOC = function() { return this.tagClass === 0 && this.tagNumber === 0; }, n; }() ), Z, Dn = 244837814094590, Ve = (Dn & 16777215) == 15715070, N = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997], In = (1 << 26) / N[N.length - 1], E = ( /** @class */ function() { function n(i, t, e) { i != null && (typeof i == "number" ? this.fromNumber(i, t, e) : t == null && typeof i != "string" ? this.fromString(i, 256) : this.fromString(i, t)); } return n.prototype.toString = function(i) { if (this.s < 0) return "-" + this.negate().toString(i); var t; if (i == 16) t = 4; else if (i == 8) t = 3; else if (i == 2) t = 1; else if (i == 32) t = 5; else if (i == 4) t = 2; else return this.toRadix(i); var e = (1 << t) - 1, r, s = !1, a = "", o = this.t, c = this.DB - o * this.DB % t; if (o-- > 0) for (c < this.DB && (r = this[o] >> c) > 0 && (s = !0, a = $(r)); o >= 0; ) c < t ? (r = (this[o] & (1 << c) - 1) << t - c, r |= this[--o] >> (c += this.DB - t)) : (r = this[o] >> (c -= t) & e, c <= 0 && (c += this.DB, --o)), r > 0 && (s = !0), s && (a += $(r)); return s ? a : "0"; }, n.prototype.negate = function() { var i = S(); return n.ZERO.subTo(this, i), i; }, n.prototype.abs = function() { return this.s < 0 ? this.negate() : this; }, n.prototype.compareTo = function(i) { var t = this.s - i.s; if (t != 0) return t; var e = this.t; if (t = e - i.t, t != 0) return this.s < 0 ? -t : t; for (; --e >= 0; ) if ((t = this[e] - i[e]) != 0) return t; return 0; }, n.prototype.bitLength = function() { return this.t <= 0 ? 0 : this.DB * (this.t - 1) + St(this[this.t - 1] ^ this.s & this.DM); }, n.prototype.mod = function(i) { var t = S(); return this.abs().divRemTo(i, null, t), this.s < 0 && t.compareTo(n.ZERO) > 0 && i.subTo(t, t), t; }, n.prototype.modPowInt = function(i, t) { var e; return i < 256 || t.isEven() ? e = new Ue(t) : e = new Le(t), this.exp(i, e); }, n.prototype.clone = function() { var i = S(); return this.copyTo(i), i; }, n.prototype.intValue = function() { if (this.s < 0) { if (this.t == 1) return this[0] - this.DV; if (this.t == 0) return -1; } else { if (this.t == 1) return this[0]; if (this.t == 0) return 0; } return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]; }, n.prototype.byteValue = function() { return this.t == 0 ? this.s : this[0] << 24 >> 24; }, n.prototype.shortValue = function() { return this.t == 0 ? this.s : this[0] << 16 >> 16; }, n.prototype.signum = function() { return this.s < 0 ? -1 : this.t <= 0 || this.t == 1 && this[0] <= 0 ? 0 : 1; }, n.prototype.toByteArray = function() { var i = this.t, t = []; t[0] = this.s; var e = this.DB - i * this.DB % 8, r, s = 0; if (i-- > 0) for (e < this.DB && (r = this[i] >> e) != (this.s & this.DM) >> e && (t[s++] = r | this.s << this.DB - e); i >= 0; ) e < 8 ? (r = (this[i] & (1 << e) - 1) << 8 - e, r |= this[--i] >> (e += this.DB - 8)) : (r = this[i] >> (e -= 8) & 255, e <= 0 && (e += this.DB, --i)), (r & 128) != 0 && (r |= -256), s == 0 && (this.s & 128) != (r & 128) && ++s, (s > 0 || r != this.s) && (t[s++] = r); return t; }, n.prototype.equals = function(i) { return this.compareTo(i) == 0; }, n.prototype.min = function(i) { return this.compareTo(i) < 0 ? this : i; }, n.prototype.max = function(i) { return this.compareTo(i) > 0 ? this : i; }, n.prototype.and = function(i) { var t = S(); return this.bitwiseTo(i, Sn, t), t; }, n.prototype.or = function(i) { var t = S(); return this.bitwiseTo(i, Et, t), t; }, n.prototype.xor = function(i) { var t = S(); return this.bitwiseTo(i, De, t), t; }, n.prototype.andNot = function(i) { var t = S(); return this.bitwiseTo(i, Ie, t), t; }, n.prototype.not = function() { for (var i = S(), t = 0; t < this.t; ++t) i[t] = this.DM & ~this[t]; return i.t = this.t, i.s = ~this.s, i; }, n.prototype.shiftLeft = function(i) { var t = S(); return i < 0 ? this.rShiftTo(-i, t) : this.lShiftTo(i, t), t; }, n.prototype.shiftRight = function(i) { var t = S(); return i < 0 ? this.lShiftTo(-i, t) : this.rShiftTo(i, t), t; }, n.prototype.getLowestSetBit = function() { for (var i = 0; i < this.t; ++i) if (this[i] != 0) return i * this.DB + Tn(this[i]); return this.s < 0 ? this.t * this.DB : -1; }, n.prototype.bitCount = function() { for (var i = 0, t = this.s & this.DM, e = 0; e < this.t; ++e) i += Cn(this[e] ^ t); return i; }, n.prototype.testBit = function(i) { var t = Math.floor(i / this.DB); return t >= this.t ? this.s != 0 : (this[t] & 1 << i % this.DB) != 0; }, n.prototype.setBit = function(i) { return this.changeBit(i, Et); }, n.prototype.clearBit = function(i) { return this.changeBit(i, Ie); }, n.prototype.flipBit = function(i) { return this.changeBit(i, De); }, n.prototype.add = function(i) { var t = S(); return this.addTo(i, t), t; }, n.prototype.subtract = function(i) { var t = S(); return this.subTo(i, t), t; }, n.prototype.multiply = function(i) { var t = S(); return this.multiplyTo(i, t), t; }, n.prototype.divide = function(i) { var t = S(); return this.divRemTo(i, t, null), t; }, n.prototype.remainder = function(i) { var t = S(); return this.divRemTo(i, null, t), t; }, n.prototype.divideAndRemainder = function(i) { var t = S(), e = S(); return this.divRemTo(i, t, e), [t, e]; }, n.prototype.modPow = function(i, t) { var e = i.bitLength(), r, s = J(1), a; if (e <= 0) return s; e < 18 ? r = 1 : e < 48 ? r = 3 : e < 144 ? r = 4 : e < 768 ? r = 5 : r = 6, e < 8 ? a = new Ue(t) : t.isEven() ? a = new Nn(t) : a = new Le(t); var o = [], c = 3, u = r - 1, l = (1 << r) - 1; if (o[1] = a.convert(this), r > 1) { var f = S(); for (a.sqrTo(o[1], f); c <= l; ) o[c] = S(), a.mulTo(f, o[c - 2], o[c]), c += 2; } var g = i.t - 1, P, m = !0, b = S(), y; for (e = St(i[g]) - 1; g >= 0; ) { for (e >= u ? P = i[g] >> e - u & l : (P = (i[g] & (1 << e + 1) - 1) << u - e, g > 0 && (P |= i[g - 1] >> this.DB + e - u)), c = r; (P & 1) == 0; ) P >>= 1, --c; if ((e -= c) < 0 && (e += this.DB, --g), m) o[P].copyTo(s), m = !1; else { for (; c > 1; ) a.sqrTo(s, b), a.sqrTo(b, s), c -= 2; c > 0 ? a.sqrTo(s, b) : (y = s, s = b, b = y), a.mulTo(b, o[P], s); } for (; g >= 0 && (i[g] & 1 << e) == 0; ) a.sqrTo(s, b), y = s, s = b, b = y, --e < 0 && (e = this.DB - 1, --g); } return a.revert(s); }, n.prototype.modInverse = function(i) { var t = i.isEven(); if (this.isEven() && t || i.signum() == 0) return n.ZERO; for (var e = i.clone(), r = this.clone(), s = J(1), a = J(0), o = J(0), c = J(1); e.signum() != 0; ) { for (; e.isEven(); ) e.rShiftTo(1, e), t ? ((!s.isEven() || !a.isEven()) && (s.addTo(this, s), a.subTo(i, a)), s.rShiftTo(1, s)) : a.isEven() || a.subTo(i, a), a.rShiftTo(1, a); for (; r.isEven(); ) r.rShiftTo(1, r), t ? ((!o.isEven() || !c.isEven()) && (o.addTo(this, o), c.subTo(i, c)), o.rShiftTo(1, o)) : c.isEven() || c.subTo(i, c), c.rShiftTo(1, c); e.compareTo(r) >= 0 ? (e.subTo(r, e), t && s.subTo(o, s), a.subTo(c, a)) : (r.subTo(e, r), t && o.subTo(s, o), c.subTo(a, c)); } if (r.compareTo(n.ONE) != 0) return n.ZERO; if (c.compareTo(i) >= 0) return c.subtract(i); if (c.signum() < 0) c.addTo(i, c); else return c; return c.signum() < 0 ? c.add(i) : c; }, n.prototype.pow = function(i) { return this.exp(i, new Bn()); }, n.prototype.gcd = function(i) { var t = this.s < 0 ? this.negate() : this.clone(), e = i.s < 0 ? i.negate() : i.clone(); if (t.compareTo(e) < 0) { var r = t; t = e, e = r; } var s = t.getLowestSetBit(), a = e.getLowestSetBit(); if (a < 0) return t; for (s < a && (a = s), a > 0 && (t.rShiftTo(a, t), e.rShiftTo(a, e)); t.signum() > 0; ) (s = t.getLowestSetBit()) > 0 && t.rShiftTo(s, t), (s = e.getLowestSetBit()) > 0 && e.rShiftTo(s, e), t.compareTo(e) >= 0 ? (t.subTo(e, t), t.rShiftTo(1, t)) : (e.subTo(t, e), e.rShiftTo(1, e)); return a > 0 && e.lShiftTo(a, e), e; }, n.prototype.isProbablePrime = function(i) { var t, e = this.abs(); if (e.t == 1 && e[0] <= N[N.length - 1]) { for (t = 0; t < N.length; ++t) if (e[0] == N[t]) return !0; return !1; } if (e.isEven()) return !1; for (t = 1; t < N.length; ) { for (var r = N[t], s = t + 1; s < N.length && r < In; ) r *= N[s++]; for (r = e.modInt(r); t < s; ) if (r % N[t++] == 0) return !1; } return e.millerRabin(i); }, n.prototype.copyTo = function(i) { for (var t = this.t - 1; t >= 0; --t) i[t] = this[t]; i.t = this.t, i.s = this.s; }, n.prototype.fromInt = function(i) { this.t = 1, this.s = i < 0 ? -1 : 0, i > 0 ? this[0] = i : i < -1 ? this[0] = i + this.DV : this.t = 0; }, n.prototype.fromString = function(i, t) { var e; if (t == 16) e = 4; else if (t == 8) e = 3; else if (t == 256) e = 8; else if (t == 2) e = 1; else if (t == 32) e = 5; else if (t == 4) e = 2; else { this.fromRadix(i, t); return; } this.t = 0, this.s = 0; for (var r = i.length, s = !1, a = 0; --r >= 0; ) { var o = e == 8 ? +i[r] & 255 : ke(i, r); if (o < 0) { i.charAt(r) == "-" && (s = !0); continue; } s = !1, a == 0 ? this[this.t++] = o : a + e > this.DB ? (this[this.t - 1] |= (o & (1 << this.DB - a) - 1) << a, this[this.t++] = o >> this.DB - a) : this[this.t - 1] |= o << a, a += e, a >= this.DB && (a -= this.DB); } e == 8 && (+i[0] & 128) != 0 && (this.s = -1, a > 0 && (this[this.t - 1] |= (1 << this.DB - a) - 1 << a)), this.clamp(), s && n.ZERO.subTo(this, this); }, n.prototype.clamp = function() { for (var i = this.s & this.DM; this.t > 0 && this[this.t - 1] == i; ) --this.t; }, n.prototype.dlShiftTo = function(i, t) { var e; for (e = this.t - 1; e >= 0; --e) t[e + i] = this[e]; for (e = i - 1; e >= 0; --e) t[e] = 0; t.t = this.t + i, t.s = this.s; }, n.prototype.drShiftTo = function(i, t) { for (var e = i; e < this.t; ++e) t[e - i] = this[e]; t.t = Math.max(this.t - i, 0), t.s = this.s; }, n.prototype.lShiftTo = function(i, t) { for (var e = i % this.DB, r = this.DB - e, s = (1 << r) - 1, a = Math.floor(i / this.DB), o = this.s << e & this.DM, c = this.t - 1; c >= 0; --c) t[c + a + 1] = this[c] >> r | o, o = (this[c] & s) << e; for (var c = a - 1; c >= 0; --c) t[c] = 0; t[a] = o, t.t = this.t + a + 1, t.s = this.s, t.clamp(); }, n.prototype.rShiftTo = function(i, t) { t.s = this.s; var e = Math.floor(i / this.DB); if (e >= this.t) { t.t = 0; return; } var r = i % this.DB, s = this.DB - r, a = (1 << r) - 1; t[0] = this[e] >> r; for (var o = e + 1; o < this.t; ++o) t[o - e - 1] |= (this[o] & a) << s, t[o - e] = this[o] >> r; r > 0 && (t[this.t - e - 1] |= (this.s & a) << s), t.t = this.t - e, t.clamp(); }, n.prototype.subTo = function(i, t) { for (var e = 0, r = 0, s = Math.min(i.t, this.t); e < s; ) r += this[e] - i[e], t[e++] = r & this.DM, r >>= this.DB; if (i.t < this.t) { for (r -= i.s; e < this.t; ) r += this[e], t[e++] = r & this.DM, r >>= this.DB; r += this.s; } else { for (r += this.s; e < i.t; ) r -= i[e], t[e++] = r & this.DM, r >>= this.DB; r -= i.s; } t.s = r < 0 ? -1 : 0, r < -1 ? t[e++] = this.DV + r : r > 0 && (t[e++] = r), t.t = e, t.clamp(); }, n.prototype.multiplyTo = function(i, t) { var e = this.abs(), r = i.abs(), s = e.t; for (t.t = s + r.t; --s >= 0; ) t[s] = 0; for (s = 0; s < r.t; ++s) t[s + e.t] = e.am(0, r[s], t, s, 0, e.t); t.s = 0, t.clamp(), this.s != i.s && n.ZERO.subTo(t, t); }, n.prototype.squareTo = function(i) { for (var t = this.abs(), e = i.t = 2 * t.t; --e >= 0; ) i[e] = 0; for (e = 0; e < t.t - 1; ++e) { var r = t.am(e, t[e], i, 2 * e, 0, 1); (i[e + t.t] += t.am(e + 1, 2 * t[e], i, 2 * e + 1, r, t.t - e - 1)) >= t.DV && (i[e + t.t] -= t.DV, i[e + t.t + 1] = 1); } i.t > 0 && (i[i.t - 1] += t.am(e, t[e], i, 2 * e, 0, 1)), i.s = 0, i.clamp(); }, n.prototype.divRemTo = function(i, t, e) { var r = i.abs(); if (!(r.t <= 0)) { var s = this.abs(); if (s.t < r.t) { t != null && t.fromInt(0), e != null && this.copyTo(e); return; } e == null && (e = S()); var a = S(), o = this.s, c = i.s, u = this.DB - St(r[r.t - 1]); u > 0 ? (r.lShiftTo(u, a), s.lShiftTo(u, e)) : (r.copyTo(a), s.copyTo(e)); var l = a.t, f = a[l - 1]; if (f != 0) { var g = f * (1 << this.F1) + (l > 1 ? a[l - 2] >> this.F2 : 0), P = this.FV / g, m = (1 << this.F1) / g, b = 1 << this.F2, y = e.t, C = y - l, T = t ?? S(); for (a.dlShiftTo(C, T), e.compareTo(T) >= 0 && (e[e.t++] = 1, e.subTo(T, e)), n.ONE.dlShiftTo(l, T), T.subTo(a, a); a.t < l; ) a[a.t++] = 0; for (; --C >= 0; ) { var R = e[--y] == f ? this.DM : Math.floor(e[y] * P + (e[y - 1] + b) * m); if ((e[y] += a.am(0, R, e, C, 0, l)) < R) for (a.dlShiftTo(C, T), e.subTo(T, e); e[y] < --R; ) e.subTo(T, e); } t != null && (e.drShiftTo(l, t), o != c && n.ZERO.subTo(t, t)), e.t = l, e.clamp(), u > 0 && e.rShiftTo(u, e), o < 0 && n.ZERO.subTo(e, e); } } }, n.prototype.invDigit = function() { if (this.t < 1) return 0; var i = this[0]; if ((i & 1) == 0) return 0; var t = i & 3; return t = t * (2 - (i & 15) * t) & 15, t = t * (2 - (i & 255) * t) & 255, t = t * (2 - ((i & 65535) * t & 65535)) & 65535, t = t * (2 - i * t % this.DV) % this.DV, t > 0 ? this.DV - t : -t; }, n.prototype.isEven = function() { return (this.t > 0 ? this[0] & 1 : this.s) == 0; }, n.prototype.exp = function(i, t) { if (i > 4294967295 || i < 1) return n.ONE; var e = S(), r = S(), s = t.convert(this), a = St(i) - 1; for (s.copyTo(e); --a >= 0; ) if (t.sqrTo(e, r), (i & 1 << a) > 0) t.mulTo(r, s, e); else { var o = e; e = r, r = o; } return t.revert(e); }, n.prototype.chunkSize = function(i) { return Math.floor(Math.LN2 * this.DB / Math.log(i)); }, n.prototype.toRadix = function(i) { if (i == null && (i = 10), this.signum() == 0 || i < 2 || i > 36) return "0"; var t = this.chunkSize(i), e = Math.pow(i, t), r = J(e), s = S(), a = S(), o = ""; for (this.divRemTo(r, s, a); s.signum() > 0; ) o = (e + a.intValue()).toString(i).substr(1) + o, s.divRemTo(r, s, a); return a.intValue().toString(i) + o; }, n.prototype.fromRadix = function(i, t) { this.fromInt(0), t == null && (t = 10); for (var e = this.chunkSize(t), r = Math.pow(t, e), s = !1, a = 0, o = 0, c = 0; c < i.length; ++c) { var u = ke(i, c); if (u < 0) { i.charAt(c) == "-" && this.signum() == 0 && (s = !0); continue; } o = t * o + u, ++a >= e && (this.dMultiply(r), this.dAddOffset(o, 0), a = 0, o = 0); } a > 0 && (this.dMultiply(Math.pow(t, a)), this.dAddOffset(o, 0)), s && n.ZERO.subTo(this, this); }, n.prototype.fromNumber = function(i, t, e) { if (typeof t == "number") if (i < 2) this.fromInt(1); else for (this.fromNumber(i, e), this.testBit(i - 1) || this.bitwiseTo(n.ONE.shiftLeft(i - 1), Et, this), this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(t); ) this.dAddOffset(2, 0), this.bitLength() > i && this.subTo(n.ONE.shiftLeft(i - 1), this); else { var r = [], s = i & 7; r.length = (i >> 3) + 1, t.nextBytes(r), s > 0 ? r[0] &= (1 << s) - 1 : r[0] = 0, this.fromString(r, 256); } }, n.prototype.bitwiseTo = function(i, t, e) { var r, s, a = Math.min(i.t, this.t); for (r = 0; r < a; ++r) e[r] = t(this[r], i[r]); if (i.t < this.t) { for (s = i.s & this.DM, r = a; r < this.t; ++r) e[r] = t(this[r], s); e.t = this.t; } else { for (s = this.s & this.DM, r = a; r < i.t; ++r) e[r] = t(s, i[r]); e.t = i.t; } e.s = t(this.s, i.s), e.clamp(); }, n.prototype.changeBit = function(i, t) { var e = n.ONE.shiftLeft(i); return this.bitwiseTo(e, t, e), e; }, n.prototype.addTo = function(i, t) { for (var e = 0, r = 0, s = Math.min(i.t, this.t); e < s; ) r += this[e] + i[e], t[e++] = r & this.DM, r >>= this.DB; if (i.t < this.t) { for (r += i.s; e < this.t; ) r += this[e], t[e++] = r & this.DM, r >>= this.DB; r += this.s; } else { for (r += this.s; e < i.t; ) r += i[e], t[e++] = r & this.DM, r >>= this.DB; r += i.s; } t.s = r < 0 ? -1 : 0, r > 0 ? t[e++] = r : r < -1 && (t[e++] = this.DV + r), t.t = e, t.clamp(); }, n.prototype.dMultiply = function(i) { this[this.t] = this.am(0, i - 1, this, 0, 0, this.t), ++this.t, this.clamp(); }, n.prototype.dAddOffset = function(i, t) { if (i != 0) { for (; this.t <= t; ) this[this.t++] = 0; for (this[t] += i; this[t] >= this.DV; ) this[t] -= this.DV, ++t >= this.t && (this[this.t++] = 0), ++this[t]; } }, n.prototype.multiplyLowerTo = function(i, t, e) { var r = Math.min(this.t + i.t, t); for (e.s = 0, e.t = r; r > 0; ) e[--r] = 0; for (var s = e.t - this.t; r < s; ++r) e[r + this.t] = this.am(0, i[r], e, r, 0, this.t); for (var s = Math.min(i.t, t); r < s; ++r) this.am(0, i[r], e, r, 0, t - r); e.clamp(); }, n.prototype.multiplyUpperTo = function(i, t, e) { --t; var r = e.t = this.t + i.t - t; for (e.s = 0; --r >= 0; ) e[r] = 0; for (r = Math.max(t - this.t, 0); r < i.t; ++r) e[this.t + r - t] = this.am(t - r, i[r], e, 0, 0, this.t + r - t); e.clamp(), e.drShiftTo(1, e); }, n.prototype.modInt = function(i) { if (i <= 0) return 0; var t = this.DV % i, e = this.s < 0 ? i - 1 : 0; if (this.t > 0) if (t == 0) e = this[0] % i; else for (var r = this.t - 1; r >= 0; --r) e = (t * e + this[r]) % i; return e; }, n.prototype.millerRabin = function(i) { var t = this.subtract(n.ONE), e = t.getLowestSetBit(); if (e <= 0) return !1; var r = t.shiftRight(e); i = i + 1 >> 1, i > N.length && (i = N.length); for (var s = S(), a = 0; a < i; ++a) { s.fromInt(N[Math.floor(Math.random() * N.length)]); var o = s.modPow(r, this); if (o.compareTo(n.ONE) != 0 && o.compareTo(t) != 0) { for (var c = 1; c++ < e && o.compareTo(t) != 0; ) if (o = o.modPowInt(2, this), o.compareTo(n.ONE) == 0) return !1; if (o.compareTo(t) != 0) return !1; } } return !0; }, n.prototype.square = function() { var i = S(); return this.squareTo(i), i; }, n.prototype.gcda = function(i, t) { var e = this.s < 0 ? this.negate() : this.clone(), r = i.s < 0 ? i.negate() : i.clone(); if (e.compareTo(r) < 0) { var s = e; e = r, r = s; } var a = e.getLowestSetBit(), o = r.getLowestSetBit(); if (o < 0) { t(e); return; } a < o && (o = a), o > 0 && (e.rShiftTo(o, e), r.rShiftTo(o, r)); var c = function() { (a = e.getLowestSetBit()) > 0 && e.rShiftTo(a, e), (a = r.getLowestSetBit()) > 0 && r.rShiftTo(a, r), e.compareTo(r) >= 0 ? (e.subTo(r, e), e.rShiftTo(1, e)) : (r.subTo(e, r), r.rShiftTo(1, r)), e.signum() > 0 ? setTimeout(c, 0) : (o > 0 && r.lShiftTo(o, r), setTimeout(function() { t(r); }, 0)); }; setTimeout(c, 10); }, n.prototype.fromNumberAsync = function(i, t, e, r) { if (typeof t == "number") if (i < 2) this.fromInt(1); else { this.fromNumber(i, e), this.testBit(i - 1) || this.bitwiseTo(n.ONE.shiftLeft(i - 1), Et, this), this.isEven() && this.dAddOffset(1, 0); var s = this, a = function() { s.dAddOffset(2, 0), s.bitLength() > i && s.subTo(n.ONE.shiftLeft(i - 1), s), s.isProbablePrime(t) ? setTimeout(function() { r(); }, 0) : setTimeout(a, 0); }; setTimeout(a, 0); } else { var o = [], c = i & 7; o.length = (i >> 3) + 1, t.nextBytes(o), c > 0 ? o[0] &= (1 << c) - 1 : o[0] = 0, this.fromString(o, 256); } }, n; }() ), Bn = ( /** @class */ function() { function n() { } return n.prototype.convert = function(i) { return i; }, n.prototype.revert = function(i) { return i; }, n.prototype.mulTo = function(i, t, e) { i.multiplyTo(t, e); }, n.prototype.sqrTo = function(i, t) { i.squareTo(t); }, n; }() ), Ue = ( /** @class */ function() { function n(i) { this.m = i; } return n.prototype.convert = function(i) { return i.s < 0 || i.compareTo(this.m) >= 0 ? i.mod(this.m) : i; }, n.prototype.revert = function(i) { return i; }, n.prototype.reduce = function(i) { i.divRemTo(this.m, null, i); }, n.prototype.mulTo = function(i, t, e) { i.multiplyTo(t, e), this.reduce(e); }, n.prototype.sqrTo = function(i, t) { i.squareTo(t), this.reduce(t); }, n; }() ), Le = ( /** @class */ function() { function n(i) { this.m = i, this.mp = i.invDigit(), this.mpl = this.mp & 32767, this.mph = this.mp >> 15, this.um = (1 << i.DB - 15) - 1, this.mt2 = 2 * i.t; } return n.prototype.convert = function(i) { var t = S(); return i.abs().dlShiftTo(this.m.t, t), t.divRemTo(this.m, null, t), i.s < 0 && t.compareTo(E.ZERO) > 0 && this.m.subTo(t, t), t; }, n.prototype.revert = function(i) { var t = S(); return i.copyTo(t), this.reduce(t), t; }, n.prototype.reduce = function(i) { for (; i.t <= this.mt2; ) i[i.t++] = 0; for (var t = 0; t < this.m.t; ++t) { var e = i[t] & 32767, r = e * this.mpl + ((e * this.mph + (i[t] >> 15) * this.mpl & this.um) << 15) & i.DM; for (e = t + this.m.t, i[e] += this.m.am(0, r, i, t, 0, this.m.t); i[e] >= i.DV; ) i[e] -= i.DV, i[++e]++; } i.clamp(), i.drShiftTo(this.m.t, i), i.compareTo(this.m) >= 0 && i.subTo(this.m, i); }, n.prototype.mulTo = function(i, t, e) { i.multiplyTo(t, e), this.reduce(e); }, n.prototype.sqrTo = function(i, t) { i.squareTo(t), this.reduce(t); }, n; }() ), Nn = ( /** @class */ function() { function n(i) { this.m = i, this.r2 = S(), this.q3 = S(), E.ONE.dlShiftTo(2 * i.t, this.r2), this.mu = this.r2.divide(i); } return n.prototype.convert = function(i) { if (i.s < 0 || i.t > 2 * this.m.t) return i.mod(this.m); if (i.compareTo(this.m) < 0) return i; var t = S(); return i.copyTo(t), this.reduce(t), t; }, n.prototype.revert = function(i) { return i; }, n.prototype.reduce = function(i) { for (i.drShiftTo(this.m.t - 1, this.r2), i.t > this.m.t + 1 && (i.t = this.m.t + 1, i.clamp()), this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3), this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); i.compareTo(this.r2) < 0; ) i.dAddOffset(1, this.m.t + 1); for (i.subTo(this.r2, i); i.compareTo(this.m) >= 0; ) i.subTo(this.m, i); }, n.prototype.mulTo = function(i, t, e) { i.multiplyTo(t, e), this.reduce(e); }, n.prototype.sqrTo = function(i, t) { i.squareTo(t), this.reduce(t); }, n; }() ); function S() { return new E(null); } function O(n, i) { return new E(n, i); } var Me = typeof navigator < "u"; Me && Ve && navigator.appName == "Microsoft Internet Explorer" ? (E.prototype.am = function(i, t, e, r, s, a) { for (var o = t & 32767, c = t >> 15; --a >= 0; ) { var u = this[i] & 32767, l = this[i++] >> 15, f = c * u + l * o; u = o * u + ((f & 32767) << 15) + e[r] + (s & 1073741823), s = (u >>> 30) + (f >>> 15) + c * l + (s >>> 30), e[r++] = u & 1073741823; } return s; }, Z = 30) : Me && Ve && navigator.appName != "Netscape" ? (E.prototype.am = function(i, t, e, r, s, a) { for (; --a >= 0; ) { var o = t * this[i++] + e[r] + s; s = Math.floor(o / 67108864), e[r++] = o & 67108863; } return s; }, Z = 26) : (E.prototype.am = function(i, t, e, r, s, a) { for (var o = t & 16383, c = t >> 14; --a >= 0; ) { var u = this[i] & 16383, l = this[i++] >> 14, f = c * u + l * o; u = o * u + ((f & 16383) << 14) + e[r] + s, s = (u >> 28) + (f >> 14) + c * l, e[r++] = u & 268435455; } return s; }, Z = 28); E.prototype.DB = Z; E.prototype.DM = (1 << Z) - 1; E.prototype.DV = 1 << Z; var ve = 52; E.prototype.FV = Math.pow(2, ve); E.prototype.F1 = ve - Z; E.prototype.F2 = 2 * Z - ve; var Mt = [], ut, k; ut = 48; for (k = 0; k <= 9; ++k) Mt[ut++] = k; ut = 97; for (k = 10; k < 36; ++k) Mt[ut++] = k; ut = 65; for (k = 10; k < 36; ++k) Mt[ut++] = k; function ke(n, i) { var t = Mt[n.charCodeAt(i)]; return t ?? -1; } function J(n) { var i = S(); return i.fromInt(n), i; } function St(n) { var i = 1, t; return (t = n >>> 16) != 0 && (n = t, i += 16), (t = n >> 8) != 0 && (n = t, i += 8), (t = n >> 4) != 0 && (n = t, i += 4), (t = n >> 2) != 0 && (n = t, i += 2), (t = n >> 1) != 0 && (n = t, i += 1), i; } E.ZERO = J(0); E.ONE = J(1); var Vn = ( /** @class */ function() { function n() { this.i = 0, this.j = 0, this.S = []; } return n.prototype.init = function(i) { var t, e, r; for (t = 0; t < 256; ++t) this.S[t] = t; for (e = 0, t = 0; t < 256; ++t) e = e + this.S[t] + i[t % i.length] & 255, r = this.S[t], this.S[t] = this.S[e], this.S[e] = r; this.i = 0, this.j = 0; }, n.prototype.next = function() { var i; return this.i = this.i + 1 & 255, this.j = this.j + this.S[this.i] & 255, i = this.S[this.i], this.S[this.i] = this.S[this.j], this.S[this.j] = i, this.S[i + this.S[this.i] & 255]; }, n; }() ); function Un() { return new Vn(); } var ii = 256, Tt, Q = null, K; if (Q == null) { Q = [], K = 0; var Ct = void 0; if (typeof window < "u" && window.crypto && window.crypto.getRandomValues) { var Gt = new Uint32Array(256); for (window.crypto.getRandomValues(Gt), Ct = 0; Ct < Gt.length; ++Ct) Q[K++] = Gt[Ct] & 255; } var At = 0, Rt = function(n) { if (At = At || 0, At >= 256 || K >= ii) { window.removeEventListener ? window.removeEventListener("mousemove", Rt, !1) : window.detachEvent && window.detachEvent("onmousemove", Rt); return; } try { var i = n.x + n.y; Q[K++] = i & 255, At += 1; } catch { } }; typeof window < "u" && (window.addEventListener ? window.addEventListener("mousemove", Rt, !1) : window.attachEvent && window.attachEvent("onmousemove", Rt)); } function Ln() { if (Tt == null) { for (Tt = Un(); K < ii; ) { var n = Math.floor(65536 * Math.random()); Q[K++] = n & 255; } for (Tt.init(Q), K = 0; K < Q.length; ++K) Q[K] = 0; K = 0; } return Tt.next(); } var te = ( /** @class */ function() { function n() { } return n.prototype.nextBytes = function(i) { for (var t = 0; t < i.length; ++t) i[t] = Ln(); }, n; }() ); function Mn(n, i) { if (i < n.length + 22) return console.error("Message too long for RSA"), null; for (var t = i - n.length - 6, e = "", r = 0; r < t; r += 2) e += "ff"; var s = "0001" + e + "00" + n; return O(s, 16); } function kn(n, i) { if (i < n.length + 11) return console.error("Message too long for RSA"), null; for (var t = [], e = n.length - 1; e >= 0 && i > 0; ) { var r = n.charCodeAt(e--); r < 128 ? t[--i] = r : r > 127 && r < 2048 ? (t[--i] = r & 63 | 128, t[--i] = r >> 6 | 192) : (t[--i] = r & 63 | 128, t[--i] = r >> 6 & 63 | 128, t[--i] = r >> 12 | 224); } t[--i] = 0; for (var s = new te(), a = []; i > 2; ) { for (a[0] = 0; a[0] == 0; ) s.nextBytes(a); t[--i] = a[0]; } return t[--i] = 2, t[--i] = 0, new E(t); } var Fn = ( /** @class */ function() { function n() { this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null; } return n.prototype.doPublic = function(i) { return i.modPowInt(this.e, this.n); }, n.prototype.doPrivate = function(i) { if (this.p == null || this.q == null) return i.modPow(this.d, this.n); for (var t = i.mod(this.p).modPow(this.dmp1, this.p), e = i.mod(this.q).modPow(this.dmq1, this.q); t.compareTo(e) < 0; ) t = t.add(this.p); return t.subtract(e).multiply(this.coeff).mod(this.p).multiply(this.q).add(e); }, n.prototype.setPublic = function(i, t) { i != null && t != null && i.length > 0 && t.length > 0 ? (this.n = O(i, 16), this.e = parseInt(t, 16)) : console.error("Invalid RSA public key"); }, n.prototype.encrypt = function(i) { var t = this.n.bitLength() + 7 >> 3, e = kn(i, t); if (e == null) return null; var r = this.doPublic(e); if (r == null) return null; for (var s = r.toString(16), a = s.length, o = 0; o < t * 2 - a; o++) s = "0" + s; return s; }, n.prototype.setPrivate = function(i, t, e) { i != null && t != null && i.length > 0 && t.length > 0 ? (this.n = O(i, 16), this.e = parseInt(t, 16), this.d = O(e, 16)) : console.error("Invalid RSA private key"); }, n.prototype.setPrivateEx = function(i, t, e, r, s, a, o, c) { i != null && t != null && i.length > 0 && t.length > 0 ? (this.n = O(i, 16), this.e = parseInt(t, 16), this.d = O(e, 16), this.p = O(r, 16), this.