UNPKG

@vue-pdf-viewer/viewer

Version:

A vue-pdf-viewer component for Vue and Nuxt. Suitable for vue-pdf document.

12,598 lines 433 kB
import { p as kt } from "./index-Dz7QxyDX.js";
function En(e, t) {
  for (var a = 0; a < t.length; a++) {
    const r = t[a];
    if (typeof r != "string" && !Array.isArray(r)) {
      for (const i in r)
        if (i !== "default" && !(i in e)) {
          const n = Object.getOwnPropertyDescriptor(r, i);
          n && Object.defineProperty(e, i, n.get ? n : { enumerable: !0, get: () => r[i] });
        }
    }
  }
  return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
var xn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Sn(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function Tn(e) {
  if (e.__esModule) return e;
  var t = e.default;
  if (typeof t == "function") {
    var a = function r() {
      return this instanceof r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
    };
    a.prototype = t.prototype;
  } else a = {};
  return Object.defineProperty(a, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
    var i = Object.getOwnPropertyDescriptor(e, r);
    Object.defineProperty(a, r, i.get ? i : {
      enumerable: !0,
      get: function() {
        return e[r];
      }
    });
  }), a;
}
var ee = {
  // default options
  options: {
    usePureJavaScript: !1
  }
}, Ei = {}, Hr = {};
Hr.byteLength = An;
Hr.toByteArray = wn;
Hr.fromByteArray = Rn;
var xt = [], ot = [], In = typeof Uint8Array < "u" ? Uint8Array : Array, ta = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (var Jt = 0, Bn = ta.length; Jt < Bn; ++Jt)
  xt[Jt] = ta[Jt], ot[ta.charCodeAt(Jt)] = Jt;
ot[45] = 62;
ot[95] = 63;
function xi(e) {
  var t = e.length;
  if (t % 4 > 0)
    throw new Error("Invalid string. Length must be a multiple of 4");
  var a = e.indexOf("=");
  a === -1 && (a = t);
  var r = a === t ? 0 : 4 - a % 4;
  return [a, r];
}
function An(e) {
  var t = xi(e), a = t[0], r = t[1];
  return (a + r) * 3 / 4 - r;
}
function bn(e, t, a) {
  return (t + a) * 3 / 4 - a;
}
function wn(e) {
  var t, a = xi(e), r = a[0], i = a[1], n = new In(bn(e, r, i)), s = 0, o = i > 0 ? r - 4 : r, l;
  for (l = 0; l < o; l += 4)
    t = ot[e.charCodeAt(l)] << 18 | ot[e.charCodeAt(l + 1)] << 12 | ot[e.charCodeAt(l + 2)] << 6 | ot[e.charCodeAt(l + 3)], n[s++] = t >> 16 & 255, n[s++] = t >> 8 & 255, n[s++] = t & 255;
  return i === 2 && (t = ot[e.charCodeAt(l)] << 2 | ot[e.charCodeAt(l + 1)] >> 4, n[s++] = t & 255), i === 1 && (t = ot[e.charCodeAt(l)] << 10 | ot[e.charCodeAt(l + 1)] << 4 | ot[e.charCodeAt(l + 2)] >> 2, n[s++] = t >> 8 & 255, n[s++] = t & 255), n;
}
function _n(e) {
  return xt[e >> 18 & 63] + xt[e >> 12 & 63] + xt[e >> 6 & 63] + xt[e & 63];
}
function Nn(e, t, a) {
  for (var r, i = [], n = t; n < a; n += 3)
    r = (e[n] << 16 & 16711680) + (e[n + 1] << 8 & 65280) + (e[n + 2] & 255), i.push(_n(r));
  return i.join("");
}
function Rn(e) {
  for (var t, a = e.length, r = a % 3, i = [], n = 16383, s = 0, o = a - r; s < o; s += n)
    i.push(Nn(e, s, s + n > o ? o : s + n));
  return r === 1 ? (t = e[a - 1], i.push(
    xt[t >> 2] + xt[t << 4 & 63] + "=="
  )) : r === 2 && (t = (e[a - 2] << 8) + e[a - 1], i.push(
    xt[t >> 10] + xt[t >> 4 & 63] + xt[t << 2 & 63] + "="
  )), i.join("");
}
var Aa = {};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
Aa.read = function(e, t, a, r, i) {
  var n, s, o = i * 8 - r - 1, l = (1 << o) - 1, f = l >> 1, u = -7, p = a ? i - 1 : 0, m = a ? -1 : 1, S = e[t + p];
  for (p += m, n = S & (1 << -u) - 1, S >>= -u, u += o; u > 0; n = n * 256 + e[t + p], p += m, u -= 8)
    ;
  for (s = n & (1 << -u) - 1, n >>= -u, u += r; u > 0; s = s * 256 + e[t + p], p += m, u -= 8)
    ;
  if (n === 0)
    n = 1 - f;
  else {
    if (n === l)
      return s ? NaN : (S ? -1 : 1) * (1 / 0);
    s = s + Math.pow(2, r), n = n - f;
  }
  return (S ? -1 : 1) * s * Math.pow(2, n - r);
};
Aa.write = function(e, t, a, r, i, n) {
  var s, o, l, f = n * 8 - i - 1, u = (1 << f) - 1, p = u >> 1, m = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, S = r ? 0 : n - 1, C = r ? 1 : -1, A = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0;
  for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (o = isNaN(t) ? 1 : 0, s = u) : (s = Math.floor(Math.log(t) / Math.LN2), t * (l = Math.pow(2, -s)) < 1 && (s--, l *= 2), s + p >= 1 ? t += m / l : t += m * Math.pow(2, 1 - p), t * l >= 2 && (s++, l /= 2), s + p >= u ? (o = 0, s = u) : s + p >= 1 ? (o = (t * l - 1) * Math.pow(2, i), s = s + p) : (o = t * Math.pow(2, p - 1) * Math.pow(2, i), s = 0)); i >= 8; e[a + S] = o & 255, S += C, o /= 256, i -= 8)
    ;
  for (s = s << i | o, f += i; f > 0; e[a + S] = s & 255, S += C, s /= 256, f -= 8)
    ;
  e[a + S - C] |= A * 128;
};
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
(function(e) {
  const t = Hr, a = Aa, r = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
  e.Buffer = u, e.SlowBuffer = O, e.INSPECT_MAX_BYTES = 50;
  const i = 2147483647;
  e.kMaxLength = i;
  const { Uint8Array: n, ArrayBuffer: s, SharedArrayBuffer: o } = globalThis;
  u.TYPED_ARRAY_SUPPORT = l(), !u.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
    "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
  );
  function l() {
    try {
      const v = new n(1), c = { foo: function() {
        return 42;
      } };
      return Object.setPrototypeOf(c, n.prototype), Object.setPrototypeOf(v, c), v.foo() === 42;
    } catch {
      return !1;
    }
  }
  Object.defineProperty(u.prototype, "parent", {
    enumerable: !0,
    get: function() {
      if (u.isBuffer(this))
        return this.buffer;
    }
  }), Object.defineProperty(u.prototype, "offset", {
    enumerable: !0,
    get: function() {
      if (u.isBuffer(this))
        return this.byteOffset;
    }
  });
  function f(v) {
    if (v > i)
      throw new RangeError('The value "' + v + '" is invalid for option "size"');
    const c = new n(v);
    return Object.setPrototypeOf(c, u.prototype), c;
  }
  function u(v, c, h) {
    if (typeof v == "number") {
      if (typeof c == "string")
        throw new TypeError(
          'The "string" argument must be of type string. Received type number'
        );
      return C(v);
    }
    return p(v, c, h);
  }
  u.poolSize = 8192;
  function p(v, c, h) {
    if (typeof v == "string")
      return A(v, c);
    if (s.isView(v))
      return _(v);
    if (v == null)
      throw new TypeError(
        "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof v
      );
    if (vt(v, s) || v && vt(v.buffer, s) || typeof o < "u" && (vt(v, o) || v && vt(v.buffer, o)))
      return U(v, c, h);
    if (typeof v == "number")
      throw new TypeError(
        'The "value" argument must not be of type number. Received type number'
      );
    const E = v.valueOf && v.valueOf();
    if (E != null && E !== v)
      return u.from(E, c, h);
    const B = D(v);
    if (B) return B;
    if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof v[Symbol.toPrimitive] == "function")
      return u.from(v[Symbol.toPrimitive]("string"), c, h);
    throw new TypeError(
      "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof v
    );
  }
  u.from = function(v, c, h) {
    return p(v, c, h);
  }, Object.setPrototypeOf(u.prototype, n.prototype), Object.setPrototypeOf(u, n);
  function m(v) {
    if (typeof v != "number")
      throw new TypeError('"size" argument must be of type number');
    if (v < 0)
      throw new RangeError('The value "' + v + '" is invalid for option "size"');
  }
  function S(v, c, h) {
    return m(v), v <= 0 ? f(v) : c !== void 0 ? typeof h == "string" ? f(v).fill(c, h) : f(v).fill(c) : f(v);
  }
  u.alloc = function(v, c, h) {
    return S(v, c, h);
  };
  function C(v) {
    return m(v), f(v < 0 ? 0 : G(v) | 0);
  }
  u.allocUnsafe = function(v) {
    return C(v);
  }, u.allocUnsafeSlow = function(v) {
    return C(v);
  };
  function A(v, c) {
    if ((typeof c != "string" || c === "") && (c = "utf8"), !u.isEncoding(c))
      throw new TypeError("Unknown encoding: " + c);
    const h = F(v, c) | 0;
    let E = f(h);
    const B = E.write(v, c);
    return B !== h && (E = E.slice(0, B)), E;
  }
  function b(v) {
    const c = v.length < 0 ? 0 : G(v.length) | 0, h = f(c);
    for (let E = 0; E < c; E += 1)
      h[E] = v[E] & 255;
    return h;
  }
  function _(v) {
    if (vt(v, n)) {
      const c = new n(v);
      return U(c.buffer, c.byteOffset, c.byteLength);
    }
    return b(v);
  }
  function U(v, c, h) {
    if (c < 0 || v.byteLength < c)
      throw new RangeError('"offset" is outside of buffer bounds');
    if (v.byteLength < c + (h || 0))
      throw new RangeError('"length" is outside of buffer bounds');
    let E;
    return c === void 0 && h === void 0 ? E = new n(v) : h === void 0 ? E = new n(v, c) : E = new n(v, c, h), Object.setPrototypeOf(E, u.prototype), E;
  }
  function D(v) {
    if (u.isBuffer(v)) {
      const c = G(v.length) | 0, h = f(c);
      return h.length === 0 || v.copy(h, 0, 0, c), h;
    }
    if (v.length !== void 0)
      return typeof v.length != "number" || ea(v.length) ? f(0) : b(v);
    if (v.type === "Buffer" && Array.isArray(v.data))
      return b(v.data);
  }
  function G(v) {
    if (v >= i)
      throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + i.toString(16) + " bytes");
    return v | 0;
  }
  function O(v) {
    return +v != v && (v = 0), u.alloc(+v);
  }
  u.isBuffer = function(c) {
    return c != null && c._isBuffer === !0 && c !== u.prototype;
  }, u.compare = function(c, h) {
    if (vt(c, n) && (c = u.from(c, c.offset, c.byteLength)), vt(h, n) && (h = u.from(h, h.offset, h.byteLength)), !u.isBuffer(c) || !u.isBuffer(h))
      throw new TypeError(
        'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
      );
    if (c === h) return 0;
    let E = c.length, B = h.length;
    for (let N = 0, L = Math.min(E, B); N < L; ++N)
      if (c[N] !== h[N]) {
        E = c[N], B = h[N];
        break;
      }
    return E < B ? -1 : B < E ? 1 : 0;
  }, u.isEncoding = function(c) {
    switch (String(c).toLowerCase()) {
      case "hex":
      case "utf8":
      case "utf-8":
      case "ascii":
      case "latin1":
      case "binary":
      case "base64":
      case "ucs2":
      case "ucs-2":
      case "utf16le":
      case "utf-16le":
        return !0;
      default:
        return !1;
    }
  }, u.concat = function(c, h) {
    if (!Array.isArray(c))
      throw new TypeError('"list" argument must be an Array of Buffers');
    if (c.length === 0)
      return u.alloc(0);
    let E;
    if (h === void 0)
      for (h = 0, E = 0; E < c.length; ++E)
        h += c[E].length;
    const B = u.allocUnsafe(h);
    let N = 0;
    for (E = 0; E < c.length; ++E) {
      let L = c[E];
      if (vt(L, n))
        N + L.length > B.length ? (u.isBuffer(L) || (L = u.from(L)), L.copy(B, N)) : n.prototype.set.call(
          B,
          L,
          N
        );
      else if (u.isBuffer(L))
        L.copy(B, N);
      else
        throw new TypeError('"list" argument must be an Array of Buffers');
      N += L.length;
    }
    return B;
  };
  function F(v, c) {
    if (u.isBuffer(v))
      return v.length;
    if (s.isView(v) || vt(v, s))
      return v.byteLength;
    if (typeof v != "string")
      throw new TypeError(
        'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof v
      );
    const h = v.length, E = arguments.length > 2 && arguments[2] === !0;
    if (!E && h === 0) return 0;
    let B = !1;
    for (; ; )
      switch (c) {
        case "ascii":
        case "latin1":
        case "binary":
          return h;
        case "utf8":
        case "utf-8":
          return Jr(v).length;
        case "ucs2":
        case "ucs-2":
        case "utf16le":
        case "utf-16le":
          return h * 2;
        case "hex":
          return h >>> 1;
        case "base64":
          return za(v).length;
        default:
          if (B)
            return E ? -1 : Jr(v).length;
          c = ("" + c).toLowerCase(), B = !0;
      }
  }
  u.byteLength = F;
  function $(v, c, h) {
    let E = !1;
    if ((c === void 0 || c < 0) && (c = 0), c > this.length || ((h === void 0 || h > this.length) && (h = this.length), h <= 0) || (h >>>= 0, c >>>= 0, h <= c))
      return "";
    for (v || (v = "utf8"); ; )
      switch (v) {
        case "hex":
          return Le(this, c, h);
        case "utf8":
        case "utf-8":
          return z(this, c, h);
        case "ascii":
          return be(this, c, h);
        case "latin1":
        case "binary":
          return we(this, c, h);
        case "base64":
          return Ae(this, c, h);
        case "ucs2":
        case "ucs-2":
        case "utf16le":
        case "utf-16le":
          return He(this, c, h);
        default:
          if (E) throw new TypeError("Unknown encoding: " + v);
          v = (v + "").toLowerCase(), E = !0;
      }
  }
  u.prototype._isBuffer = !0;
  function j(v, c, h) {
    const E = v[c];
    v[c] = v[h], v[h] = E;
  }
  u.prototype.swap16 = function() {
    const c = this.length;
    if (c % 2 !== 0)
      throw new RangeError("Buffer size must be a multiple of 16-bits");
    for (let h = 0; h < c; h += 2)
      j(this, h, h + 1);
    return this;
  }, u.prototype.swap32 = function() {
    const c = this.length;
    if (c % 4 !== 0)
      throw new RangeError("Buffer size must be a multiple of 32-bits");
    for (let h = 0; h < c; h += 4)
      j(this, h, h + 3), j(this, h + 1, h + 2);
    return this;
  }, u.prototype.swap64 = function() {
    const c = this.length;
    if (c % 8 !== 0)
      throw new RangeError("Buffer size must be a multiple of 64-bits");
    for (let h = 0; h < c; h += 8)
      j(this, h, h + 7), j(this, h + 1, h + 6), j(this, h + 2, h + 5), j(this, h + 3, h + 4);
    return this;
  }, u.prototype.toString = function() {
    const c = this.length;
    return c === 0 ? "" : arguments.length === 0 ? z(this, 0, c) : $.apply(this, arguments);
  }, u.prototype.toLocaleString = u.prototype.toString, u.prototype.equals = function(c) {
    if (!u.isBuffer(c)) throw new TypeError("Argument must be a Buffer");
    return this === c ? !0 : u.compare(this, c) === 0;
  }, u.prototype.inspect = function() {
    let c = "";
    const h = e.INSPECT_MAX_BYTES;
    return c = this.toString("hex", 0, h).replace(/(.{2})/g, "$1 ").trim(), this.length > h && (c += " ... "), "<Buffer " + c + ">";
  }, r && (u.prototype[r] = u.prototype.inspect), u.prototype.compare = function(c, h, E, B, N) {
    if (vt(c, n) && (c = u.from(c, c.offset, c.byteLength)), !u.isBuffer(c))
      throw new TypeError(
        'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof c
      );
    if (h === void 0 && (h = 0), E === void 0 && (E = c ? c.length : 0), B === void 0 && (B = 0), N === void 0 && (N = this.length), h < 0 || E > c.length || B < 0 || N > this.length)
      throw new RangeError("out of range index");
    if (B >= N && h >= E)
      return 0;
    if (B >= N)
      return -1;
    if (h >= E)
      return 1;
    if (h >>>= 0, E >>>= 0, B >>>= 0, N >>>= 0, this === c) return 0;
    let L = N - B, te = E - h;
    const _e = Math.min(L, te), Te = this.slice(B, N), Ne = c.slice(h, E);
    for (let ge = 0; ge < _e; ++ge)
      if (Te[ge] !== Ne[ge]) {
        L = Te[ge], te = Ne[ge];
        break;
      }
    return L < te ? -1 : te < L ? 1 : 0;
  };
  function le(v, c, h, E, B) {
    if (v.length === 0) return -1;
    if (typeof h == "string" ? (E = h, h = 0) : h > 2147483647 ? h = 2147483647 : h < -2147483648 && (h = -2147483648), h = +h, ea(h) && (h = B ? 0 : v.length - 1), h < 0 && (h = v.length + h), h >= v.length) {
      if (B) return -1;
      h = v.length - 1;
    } else if (h < 0)
      if (B) h = 0;
      else return -1;
    if (typeof c == "string" && (c = u.from(c, E)), u.isBuffer(c))
      return c.length === 0 ? -1 : he(v, c, h, E, B);
    if (typeof c == "number")
      return c = c & 255, typeof n.prototype.indexOf == "function" ? B ? n.prototype.indexOf.call(v, c, h) : n.prototype.lastIndexOf.call(v, c, h) : he(v, [c], h, E, B);
    throw new TypeError("val must be string, number or Buffer");
  }
  function he(v, c, h, E, B) {
    let N = 1, L = v.length, te = c.length;
    if (E !== void 0 && (E = String(E).toLowerCase(), E === "ucs2" || E === "ucs-2" || E === "utf16le" || E === "utf-16le")) {
      if (v.length < 2 || c.length < 2)
        return -1;
      N = 2, L /= 2, te /= 2, h /= 2;
    }
    function _e(Ne, ge) {
      return N === 1 ? Ne[ge] : Ne.readUInt16BE(ge * N);
    }
    let Te;
    if (B) {
      let Ne = -1;
      for (Te = h; Te < L; Te++)
        if (_e(v, Te) === _e(c, Ne === -1 ? 0 : Te - Ne)) {
          if (Ne === -1 && (Ne = Te), Te - Ne + 1 === te) return Ne * N;
        } else
          Ne !== -1 && (Te -= Te - Ne), Ne = -1;
    } else
      for (h + te > L && (h = L - te), Te = h; Te >= 0; Te--) {
        let Ne = !0;
        for (let ge = 0; ge < te; ge++)
          if (_e(v, Te + ge) !== _e(c, ge)) {
            Ne = !1;
            break;
          }
        if (Ne) return Te;
      }
    return -1;
  }
  u.prototype.includes = function(c, h, E) {
    return this.indexOf(c, h, E) !== -1;
  }, u.prototype.indexOf = function(c, h, E) {
    return le(this, c, h, E, !0);
  }, u.prototype.lastIndexOf = function(c, h, E) {
    return le(this, c, h, E, !1);
  };
  function de(v, c, h, E) {
    h = Number(h) || 0;
    const B = v.length - h;
    E ? (E = Number(E), E > B && (E = B)) : E = B;
    const N = c.length;
    E > N / 2 && (E = N / 2);
    let L;
    for (L = 0; L < E; ++L) {
      const te = parseInt(c.substr(L * 2, 2), 16);
      if (ea(te)) return L;
      v[h + L] = te;
    }
    return L;
  }
  function Ee(v, c, h, E) {
    return Ir(Jr(c, v.length - h), v, h, E);
  }
  function je(v, c, h, E) {
    return Ir(gn(c), v, h, E);
  }
  function rt(v, c, h, E) {
    return Ir(za(c), v, h, E);
  }
  function ye(v, c, h, E) {
    return Ir(vn(c, v.length - h), v, h, E);
  }
  u.prototype.write = function(c, h, E, B) {
    if (h === void 0)
      B = "utf8", E = this.length, h = 0;
    else if (E === void 0 && typeof h == "string")
      B = h, E = this.length, h = 0;
    else if (isFinite(h))
      h = h >>> 0, isFinite(E) ? (E = E >>> 0, B === void 0 && (B = "utf8")) : (B = E, E = void 0);
    else
      throw new Error(
        "Buffer.write(string, encoding, offset[, length]) is no longer supported"
      );
    const N = this.length - h;
    if ((E === void 0 || E > N) && (E = N), c.length > 0 && (E < 0 || h < 0) || h > this.length)
      throw new RangeError("Attempt to write outside buffer bounds");
    B || (B = "utf8");
    let L = !1;
    for (; ; )
      switch (B) {
        case "hex":
          return de(this, c, h, E);
        case "utf8":
        case "utf-8":
          return Ee(this, c, h, E);
        case "ascii":
        case "latin1":
        case "binary":
          return je(this, c, h, E);
        case "base64":
          return rt(this, c, h, E);
        case "ucs2":
        case "ucs-2":
        case "utf16le":
        case "utf-16le":
          return ye(this, c, h, E);
        default:
          if (L) throw new TypeError("Unknown encoding: " + B);
          B = ("" + B).toLowerCase(), L = !0;
      }
  }, u.prototype.toJSON = function() {
    return {
      type: "Buffer",
      data: Array.prototype.slice.call(this._arr || this, 0)
    };
  };
  function Ae(v, c, h) {
    return c === 0 && h === v.length ? t.fromByteArray(v) : t.fromByteArray(v.slice(c, h));
  }
  function z(v, c, h) {
    h = Math.min(v.length, h);
    const E = [];
    let B = c;
    for (; B < h; ) {
      const N = v[B];
      let L = null, te = N > 239 ? 4 : N > 223 ? 3 : N > 191 ? 2 : 1;
      if (B + te <= h) {
        let _e, Te, Ne, ge;
        switch (te) {
          case 1:
            N < 128 && (L = N);
            break;
          case 2:
            _e = v[B + 1], (_e & 192) === 128 && (ge = (N & 31) << 6 | _e & 63, ge > 127 && (L = ge));
            break;
          case 3:
            _e = v[B + 1], Te = v[B + 2], (_e & 192) === 128 && (Te & 192) === 128 && (ge = (N & 15) << 12 | (_e & 63) << 6 | Te & 63, ge > 2047 && (ge < 55296 || ge > 57343) && (L = ge));
            break;
          case 4:
            _e = v[B + 1], Te = v[B + 2], Ne = v[B + 3], (_e & 192) === 128 && (Te & 192) === 128 && (Ne & 192) === 128 && (ge = (N & 15) << 18 | (_e & 63) << 12 | (Te & 63) << 6 | Ne & 63, ge > 65535 && ge < 1114112 && (L = ge));
        }
      }
      L === null ? (L = 65533, te = 1) : L > 65535 && (L -= 65536, E.push(L >>> 10 & 1023 | 55296), L = 56320 | L & 1023), E.push(L), B += te;
    }
    return Rt(E);
  }
  const gt = 4096;
  function Rt(v) {
    const c = v.length;
    if (c <= gt)
      return String.fromCharCode.apply(String, v);
    let h = "", E = 0;
    for (; E < c; )
      h += String.fromCharCode.apply(
        String,
        v.slice(E, E += gt)
      );
    return h;
  }
  function be(v, c, h) {
    let E = "";
    h = Math.min(v.length, h);
    for (let B = c; B < h; ++B)
      E += String.fromCharCode(v[B] & 127);
    return E;
  }
  function we(v, c, h) {
    let E = "";
    h = Math.min(v.length, h);
    for (let B = c; B < h; ++B)
      E += String.fromCharCode(v[B]);
    return E;
  }
  function Le(v, c, h) {
    const E = v.length;
    (!c || c < 0) && (c = 0), (!h || h < 0 || h > E) && (h = E);
    let B = "";
    for (let N = c; N < h; ++N)
      B += mn[v[N]];
    return B;
  }
  function He(v, c, h) {
    const E = v.slice(c, h);
    let B = "";
    for (let N = 0; N < E.length - 1; N += 2)
      B += String.fromCharCode(E[N] + E[N + 1] * 256);
    return B;
  }
  u.prototype.slice = function(c, h) {
    const E = this.length;
    c = ~~c, h = h === void 0 ? E : ~~h, c < 0 ? (c += E, c < 0 && (c = 0)) : c > E && (c = E), h < 0 ? (h += E, h < 0 && (h = 0)) : h > E && (h = E), h < c && (h = c);
    const B = this.subarray(c, h);
    return Object.setPrototypeOf(B, u.prototype), B;
  };
  function se(v, c, h) {
    if (v % 1 !== 0 || v < 0) throw new RangeError("offset is not uint");
    if (v + c > h) throw new RangeError("Trying to access beyond buffer length");
  }
  u.prototype.readUintLE = u.prototype.readUIntLE = function(c, h, E) {
    c = c >>> 0, h = h >>> 0, E || se(c, h, this.length);
    let B = this[c], N = 1, L = 0;
    for (; ++L < h && (N *= 256); )
      B += this[c + L] * N;
    return B;
  }, u.prototype.readUintBE = u.prototype.readUIntBE = function(c, h, E) {
    c = c >>> 0, h = h >>> 0, E || se(c, h, this.length);
    let B = this[c + --h], N = 1;
    for (; h > 0 && (N *= 256); )
      B += this[c + --h] * N;
    return B;
  }, u.prototype.readUint8 = u.prototype.readUInt8 = function(c, h) {
    return c = c >>> 0, h || se(c, 1, this.length), this[c];
  }, u.prototype.readUint16LE = u.prototype.readUInt16LE = function(c, h) {
    return c = c >>> 0, h || se(c, 2, this.length), this[c] | this[c + 1] << 8;
  }, u.prototype.readUint16BE = u.prototype.readUInt16BE = function(c, h) {
    return c = c >>> 0, h || se(c, 2, this.length), this[c] << 8 | this[c + 1];
  }, u.prototype.readUint32LE = u.prototype.readUInt32LE = function(c, h) {
    return c = c >>> 0, h || se(c, 4, this.length), (this[c] | this[c + 1] << 8 | this[c + 2] << 16) + this[c + 3] * 16777216;
  }, u.prototype.readUint32BE = u.prototype.readUInt32BE = function(c, h) {
    return c = c >>> 0, h || se(c, 4, this.length), this[c] * 16777216 + (this[c + 1] << 16 | this[c + 2] << 8 | this[c + 3]);
  }, u.prototype.readBigUInt64LE = Lt(function(c) {
    c = c >>> 0, Zt(c, "offset");
    const h = this[c], E = this[c + 7];
    (h === void 0 || E === void 0) && hr(c, this.length - 8);
    const B = h + this[++c] * 2 ** 8 + this[++c] * 2 ** 16 + this[++c] * 2 ** 24, N = this[++c] + this[++c] * 2 ** 8 + this[++c] * 2 ** 16 + E * 2 ** 24;
    return BigInt(B) + (BigInt(N) << BigInt(32));
  }), u.prototype.readBigUInt64BE = Lt(function(c) {
    c = c >>> 0, Zt(c, "offset");
    const h = this[c], E = this[c + 7];
    (h === void 0 || E === void 0) && hr(c, this.length - 8);
    const B = h * 2 ** 24 + this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + this[++c], N = this[++c] * 2 ** 24 + this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + E;
    return (BigInt(B) << BigInt(32)) + BigInt(N);
  }), u.prototype.readIntLE = function(c, h, E) {
    c = c >>> 0, h = h >>> 0, E || se(c, h, this.length);
    let B = this[c], N = 1, L = 0;
    for (; ++L < h && (N *= 256); )
      B += this[c + L] * N;
    return N *= 128, B >= N && (B -= Math.pow(2, 8 * h)), B;
  }, u.prototype.readIntBE = function(c, h, E) {
    c = c >>> 0, h = h >>> 0, E || se(c, h, this.length);
    let B = h, N = 1, L = this[c + --B];
    for (; B > 0 && (N *= 256); )
      L += this[c + --B] * N;
    return N *= 128, L >= N && (L -= Math.pow(2, 8 * h)), L;
  }, u.prototype.readInt8 = function(c, h) {
    return c = c >>> 0, h || se(c, 1, this.length), this[c] & 128 ? (255 - this[c] + 1) * -1 : this[c];
  }, u.prototype.readInt16LE = function(c, h) {
    c = c >>> 0, h || se(c, 2, this.length);
    const E = this[c] | this[c + 1] << 8;
    return E & 32768 ? E | 4294901760 : E;
  }, u.prototype.readInt16BE = function(c, h) {
    c = c >>> 0, h || se(c, 2, this.length);
    const E = this[c + 1] | this[c] << 8;
    return E & 32768 ? E | 4294901760 : E;
  }, u.prototype.readInt32LE = function(c, h) {
    return c = c >>> 0, h || se(c, 4, this.length), this[c] | this[c + 1] << 8 | this[c + 2] << 16 | this[c + 3] << 24;
  }, u.prototype.readInt32BE = function(c, h) {
    return c = c >>> 0, h || se(c, 4, this.length), this[c] << 24 | this[c + 1] << 16 | this[c + 2] << 8 | this[c + 3];
  }, u.prototype.readBigInt64LE = Lt(function(c) {
    c = c >>> 0, Zt(c, "offset");
    const h = this[c], E = this[c + 7];
    (h === void 0 || E === void 0) && hr(c, this.length - 8);
    const B = this[c + 4] + this[c + 5] * 2 ** 8 + this[c + 6] * 2 ** 16 + (E << 24);
    return (BigInt(B) << BigInt(32)) + BigInt(h + this[++c] * 2 ** 8 + this[++c] * 2 ** 16 + this[++c] * 2 ** 24);
  }), u.prototype.readBigInt64BE = Lt(function(c) {
    c = c >>> 0, Zt(c, "offset");
    const h = this[c], E = this[c + 7];
    (h === void 0 || E === void 0) && hr(c, this.length - 8);
    const B = (h << 24) + // Overflow
    this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + this[++c];
    return (BigInt(B) << BigInt(32)) + BigInt(this[++c] * 2 ** 24 + this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + E);
  }), u.prototype.readFloatLE = function(c, h) {
    return c = c >>> 0, h || se(c, 4, this.length), a.read(this, c, !0, 23, 4);
  }, u.prototype.readFloatBE = function(c, h) {
    return c = c >>> 0, h || se(c, 4, this.length), a.read(this, c, !1, 23, 4);
  }, u.prototype.readDoubleLE = function(c, h) {
    return c = c >>> 0, h || se(c, 8, this.length), a.read(this, c, !0, 52, 8);
  }, u.prototype.readDoubleBE = function(c, h) {
    return c = c >>> 0, h || se(c, 8, this.length), a.read(this, c, !1, 52, 8);
  };
  function ce(v, c, h, E, B, N) {
    if (!u.isBuffer(v)) throw new TypeError('"buffer" argument must be a Buffer instance');
    if (c > B || c < N) throw new RangeError('"value" argument is out of bounds');
    if (h + E > v.length) throw new RangeError("Index out of range");
  }
  u.prototype.writeUintLE = u.prototype.writeUIntLE = function(c, h, E, B) {
    if (c = +c, h = h >>> 0, E = E >>> 0, !B) {
      const te = Math.pow(2, 8 * E) - 1;
      ce(this, c, h, E, te, 0);
    }
    let N = 1, L = 0;
    for (this[h] = c & 255; ++L < E && (N *= 256); )
      this[h + L] = c / N & 255;
    return h + E;
  }, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(c, h, E, B) {
    if (c = +c, h = h >>> 0, E = E >>> 0, !B) {
      const te = Math.pow(2, 8 * E) - 1;
      ce(this, c, h, E, te, 0);
    }
    let N = E - 1, L = 1;
    for (this[h + N] = c & 255; --N >= 0 && (L *= 256); )
      this[h + N] = c / L & 255;
    return h + E;
  }, u.prototype.writeUint8 = u.prototype.writeUInt8 = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 1, 255, 0), this[h] = c & 255, h + 1;
  }, u.prototype.writeUint16LE = u.prototype.writeUInt16LE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 2, 65535, 0), this[h] = c & 255, this[h + 1] = c >>> 8, h + 2;
  }, u.prototype.writeUint16BE = u.prototype.writeUInt16BE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 2, 65535, 0), this[h] = c >>> 8, this[h + 1] = c & 255, h + 2;
  }, u.prototype.writeUint32LE = u.prototype.writeUInt32LE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 4, 4294967295, 0), this[h + 3] = c >>> 24, this[h + 2] = c >>> 16, this[h + 1] = c >>> 8, this[h] = c & 255, h + 4;
  }, u.prototype.writeUint32BE = u.prototype.writeUInt32BE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 4, 4294967295, 0), this[h] = c >>> 24, this[h + 1] = c >>> 16, this[h + 2] = c >>> 8, this[h + 3] = c & 255, h + 4;
  };
  function ke(v, c, h, E, B) {
    Me(c, E, B, v, h, 7);
    let N = Number(c & BigInt(4294967295));
    v[h++] = N, N = N >> 8, v[h++] = N, N = N >> 8, v[h++] = N, N = N >> 8, v[h++] = N;
    let L = Number(c >> BigInt(32) & BigInt(4294967295));
    return v[h++] = L, L = L >> 8, v[h++] = L, L = L >> 8, v[h++] = L, L = L >> 8, v[h++] = L, h;
  }
  function Pe(v, c, h, E, B) {
    Me(c, E, B, v, h, 7);
    let N = Number(c & BigInt(4294967295));
    v[h + 7] = N, N = N >> 8, v[h + 6] = N, N = N >> 8, v[h + 5] = N, N = N >> 8, v[h + 4] = N;
    let L = Number(c >> BigInt(32) & BigInt(4294967295));
    return v[h + 3] = L, L = L >> 8, v[h + 2] = L, L = L >> 8, v[h + 1] = L, L = L >> 8, v[h] = L, h + 8;
  }
  u.prototype.writeBigUInt64LE = Lt(function(c, h = 0) {
    return ke(this, c, h, BigInt(0), BigInt("0xffffffffffffffff"));
  }), u.prototype.writeBigUInt64BE = Lt(function(c, h = 0) {
    return Pe(this, c, h, BigInt(0), BigInt("0xffffffffffffffff"));
  }), u.prototype.writeIntLE = function(c, h, E, B) {
    if (c = +c, h = h >>> 0, !B) {
      const _e = Math.pow(2, 8 * E - 1);
      ce(this, c, h, E, _e - 1, -_e);
    }
    let N = 0, L = 1, te = 0;
    for (this[h] = c & 255; ++N < E && (L *= 256); )
      c < 0 && te === 0 && this[h + N - 1] !== 0 && (te = 1), this[h + N] = (c / L >> 0) - te & 255;
    return h + E;
  }, u.prototype.writeIntBE = function(c, h, E, B) {
    if (c = +c, h = h >>> 0, !B) {
      const _e = Math.pow(2, 8 * E - 1);
      ce(this, c, h, E, _e - 1, -_e);
    }
    let N = E - 1, L = 1, te = 0;
    for (this[h + N] = c & 255; --N >= 0 && (L *= 256); )
      c < 0 && te === 0 && this[h + N + 1] !== 0 && (te = 1), this[h + N] = (c / L >> 0) - te & 255;
    return h + E;
  }, u.prototype.writeInt8 = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 1, 127, -128), c < 0 && (c = 255 + c + 1), this[h] = c & 255, h + 1;
  }, u.prototype.writeInt16LE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 2, 32767, -32768), this[h] = c & 255, this[h + 1] = c >>> 8, h + 2;
  }, u.prototype.writeInt16BE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 2, 32767, -32768), this[h] = c >>> 8, this[h + 1] = c & 255, h + 2;
  }, u.prototype.writeInt32LE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 4, 2147483647, -2147483648), this[h] = c & 255, this[h + 1] = c >>> 8, this[h + 2] = c >>> 16, this[h + 3] = c >>> 24, h + 4;
  }, u.prototype.writeInt32BE = function(c, h, E) {
    return c = +c, h = h >>> 0, E || ce(this, c, h, 4, 2147483647, -2147483648), c < 0 && (c = 4294967295 + c + 1), this[h] = c >>> 24, this[h + 1] = c >>> 16, this[h + 2] = c >>> 8, this[h + 3] = c & 255, h + 4;
  }, u.prototype.writeBigInt64LE = Lt(function(c, h = 0) {
    return ke(this, c, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
  }), u.prototype.writeBigInt64BE = Lt(function(c, h = 0) {
    return Pe(this, c, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
  });
  function Ve(v, c, h, E, B, N) {
    if (h + E > v.length) throw new RangeError("Index out of range");
    if (h < 0) throw new RangeError("Index out of range");
  }
  function Fe(v, c, h, E, B) {
    return c = +c, h = h >>> 0, B || Ve(v, c, h, 4), a.write(v, c, h, E, 23, 4), h + 4;
  }
  u.prototype.writeFloatLE = function(c, h, E) {
    return Fe(this, c, h, !0, E);
  }, u.prototype.writeFloatBE = function(c, h, E) {
    return Fe(this, c, h, !1, E);
  };
  function Oe(v, c, h, E, B) {
    return c = +c, h = h >>> 0, B || Ve(v, c, h, 8), a.write(v, c, h, E, 52, 8), h + 8;
  }
  u.prototype.writeDoubleLE = function(c, h, E) {
    return Oe(this, c, h, !0, E);
  }, u.prototype.writeDoubleBE = function(c, h, E) {
    return Oe(this, c, h, !1, E);
  }, u.prototype.copy = function(c, h, E, B) {
    if (!u.isBuffer(c)) throw new TypeError("argument should be a Buffer");
    if (E || (E = 0), !B && B !== 0 && (B = this.length), h >= c.length && (h = c.length), h || (h = 0), B > 0 && B < E && (B = E), B === E || c.length === 0 || this.length === 0) return 0;
    if (h < 0)
      throw new RangeError("targetStart out of bounds");
    if (E < 0 || E >= this.length) throw new RangeError("Index out of range");
    if (B < 0) throw new RangeError("sourceEnd out of bounds");
    B > this.length && (B = this.length), c.length - h < B - E && (B = c.length - h + E);
    const N = B - E;
    return this === c && typeof n.prototype.copyWithin == "function" ? this.copyWithin(h, E, B) : n.prototype.set.call(
      c,
      this.subarray(E, B),
      h
    ), N;
  }, u.prototype.fill = function(c, h, E, B) {
    if (typeof c == "string") {
      if (typeof h == "string" ? (B = h, h = 0, E = this.length) : typeof E == "string" && (B = E, E = this.length), B !== void 0 && typeof B != "string")
        throw new TypeError("encoding must be a string");
      if (typeof B == "string" && !u.isEncoding(B))
        throw new TypeError("Unknown encoding: " + B);
      if (c.length === 1) {
        const L = c.charCodeAt(0);
        (B === "utf8" && L < 128 || B === "latin1") && (c = L);
      }
    } else typeof c == "number" ? c = c & 255 : typeof c == "boolean" && (c = Number(c));
    if (h < 0 || this.length < h || this.length < E)
      throw new RangeError("Out of range index");
    if (E <= h)
      return this;
    h = h >>> 0, E = E === void 0 ? this.length : E >>> 0, c || (c = 0);
    let N;
    if (typeof c == "number")
      for (N = h; N < E; ++N)
        this[N] = c;
    else {
      const L = u.isBuffer(c) ? c : u.from(c, B), te = L.length;
      if (te === 0)
        throw new TypeError('The value "' + c + '" is invalid for argument "value"');
      for (N = 0; N < E - h; ++N)
        this[N + h] = L[N % te];
    }
    return this;
  };
  const Be = {};
  function Ue(v, c, h) {
    Be[v] = class extends h {
      constructor() {
        super(), Object.defineProperty(this, "message", {
          value: c.apply(this, arguments),
          writable: !0,
          configurable: !0
        }), this.name = `${this.name} [${v}]`, this.stack, delete this.name;
      }
      get code() {
        return v;
      }
      set code(B) {
        Object.defineProperty(this, "code", {
          configurable: !0,
          enumerable: !0,
          value: B,
          writable: !0
        });
      }
      toString() {
        return `${this.name} [${v}]: ${this.message}`;
      }
    };
  }
  Ue(
    "ERR_BUFFER_OUT_OF_BOUNDS",
    function(v) {
      return v ? `${v} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
    },
    RangeError
  ), Ue(
    "ERR_INVALID_ARG_TYPE",
    function(v, c) {
      return `The "${v}" argument must be of type number. Received type ${typeof c}`;
    },
    TypeError
  ), Ue(
    "ERR_OUT_OF_RANGE",
    function(v, c, h) {
      let E = `The value of "${v}" is out of range.`, B = h;
      return Number.isInteger(h) && Math.abs(h) > 2 ** 32 ? B = Ke(String(h)) : typeof h == "bigint" && (B = String(h), (h > BigInt(2) ** BigInt(32) || h < -(BigInt(2) ** BigInt(32))) && (B = Ke(B)), B += "n"), E += ` It must be ${c}. Received ${B}`, E;
    },
    RangeError
  );
  function Ke(v) {
    let c = "", h = v.length;
    const E = v[0] === "-" ? 1 : 0;
    for (; h >= E + 4; h -= 3)
      c = `_${v.slice(h - 3, h)}${c}`;
    return `${v.slice(0, h)}${c}`;
  }
  function Ge(v, c, h) {
    Zt(c, "offset"), (v[c] === void 0 || v[c + h] === void 0) && hr(c, v.length - (h + 1));
  }
  function Me(v, c, h, E, B, N) {
    if (v > h || v < c) {
      const L = typeof c == "bigint" ? "n" : "";
      let te;
      throw c === 0 || c === BigInt(0) ? te = `>= 0${L} and < 2${L} ** ${(N + 1) * 8}${L}` : te = `>= -(2${L} ** ${(N + 1) * 8 - 1}${L}) and < 2 ** ${(N + 1) * 8 - 1}${L}`, new Be.ERR_OUT_OF_RANGE("value", te, v);
    }
    Ge(E, B, N);
  }
  function Zt(v, c) {
    if (typeof v != "number")
      throw new Be.ERR_INVALID_ARG_TYPE(c, "number", v);
  }
  function hr(v, c, h) {
    throw Math.floor(v) !== v ? (Zt(v, h), new Be.ERR_OUT_OF_RANGE("offset", "an integer", v)) : c < 0 ? new Be.ERR_BUFFER_OUT_OF_BOUNDS() : new Be.ERR_OUT_OF_RANGE(
      "offset",
      `>= 0 and <= ${c}`,
      v
    );
  }
  const dn = /[^+/0-9A-Za-z-_]/g;
  function yn(v) {
    if (v = v.split("=")[0], v = v.trim().replace(dn, ""), v.length < 2) return "";
    for (; v.length % 4 !== 0; )
      v = v + "=";
    return v;
  }
  function Jr(v, c) {
    c = c || 1 / 0;
    let h;
    const E = v.length;
    let B = null;
    const N = [];
    for (let L = 0; L < E; ++L) {
      if (h = v.charCodeAt(L), h > 55295 && h < 57344) {
        if (!B) {
          if (h > 56319) {
            (c -= 3) > -1 && N.push(239, 191, 189);
            continue;
          } else if (L + 1 === E) {
            (c -= 3) > -1 && N.push(239, 191, 189);
            continue;
          }
          B = h;
          continue;
        }
        if (h < 56320) {
          (c -= 3) > -1 && N.push(239, 191, 189), B = h;
          continue;
        }
        h = (B - 55296 << 10 | h - 56320) + 65536;
      } else B && (c -= 3) > -1 && N.push(239, 191, 189);
      if (B = null, h < 128) {
        if ((c -= 1) < 0) break;
        N.push(h);
      } else if (h < 2048) {
        if ((c -= 2) < 0) break;
        N.push(
          h >> 6 | 192,
          h & 63 | 128
        );
      } else if (h < 65536) {
        if ((c -= 3) < 0) break;
        N.push(
          h >> 12 | 224,
          h >> 6 & 63 | 128,
          h & 63 | 128
        );
      } else if (h < 1114112) {
        if ((c -= 4) < 0) break;
        N.push(
          h >> 18 | 240,
          h >> 12 & 63 | 128,
          h >> 6 & 63 | 128,
          h & 63 | 128
        );
      } else
        throw new Error("Invalid code point");
    }
    return N;
  }
  function gn(v) {
    const c = [];
    for (let h = 0; h < v.length; ++h)
      c.push(v.charCodeAt(h) & 255);
    return c;
  }
  function vn(v, c) {
    let h, E, B;
    const N = [];
    for (let L = 0; L < v.length && !((c -= 2) < 0); ++L)
      h = v.charCodeAt(L), E = h >> 8, B = h % 256, N.push(B), N.push(E);
    return N;
  }
  function za(v) {
    return t.toByteArray(yn(v));
  }
  function Ir(v, c, h, E) {
    let B;
    for (B = 0; B < E && !(B + h >= c.length || B >= v.length); ++B)
      c[B + h] = v[B];
    return B;
  }
  function vt(v, c) {
    return v instanceof c || v != null && v.constructor != null && v.constructor.name != null && v.constructor.name === c.name;
  }
  function ea(v) {
    return v !== v;
  }
  const mn = function() {
    const v = "0123456789abcdef", c = new Array(256);
    for (let h = 0; h < 16; ++h) {
      const E = h * 16;
      for (let B = 0; B < 16; ++B)
        c[E + B] = v[h] + v[B];
    }
    return c;
  }();
  function Lt(v) {
    return typeof BigInt > "u" ? Cn : v;
  }
  function Cn() {
    throw new Error("BigInt not supported");
  }
})(Ei);
const pt = Ei.Buffer;
var ba = {}, Ln = ba, Ya = {};
ba.encode = function(e, t, a) {
  if (typeof t != "string")
    throw new TypeError('"alphabet" must be a string.');
  if (a !== void 0 && typeof a != "number")
    throw new TypeError('"maxline" must be a number.');
  var r = "";
  if (!(e instanceof Uint8Array))
    r = Un(e, t);
  else {
    var i = 0, n = t.length, s = t.charAt(0), o = [0];
    for (i = 0; i < e.length; ++i) {
      for (var l = 0, f = e[i]; l < o.length; ++l)
        f += o[l] << 8, o[l] = f % n, f = f / n | 0;
      for (; f > 0; )
        o.push(f % n), f = f / n | 0;
    }
    for (i = 0; e[i] === 0 && i < e.length - 1; ++i)
      r += s;
    for (i = o.length - 1; i >= 0; --i)
      r += t[o[i]];
  }
  if (a) {
    var u = new RegExp(".{1," + a + "}", "g");
    r = r.match(u).join(`\r
`);
  }
  return r;
};
ba.decode = function(e, t) {
  if (typeof e != "string")
    throw new TypeError('"input" must be a string.');
  if (typeof t != "string")
    throw new TypeError('"alphabet" must be a string.');
  var a = Ya[t];
  if (!a) {
    a = Ya[t] = [];
    for (var r = 0; r < t.length; ++r)
      a[t.charCodeAt(r)] = r;
  }
  e = e.replace(/\s/g, "");
  for (var i = t.length, n = t.charAt(0), s = [0], r = 0; r < e.length; r++) {
    var o = a[e.charCodeAt(r)];
    if (o === void 0)
      return;
    for (var l = 0, f = o; l < s.length; ++l)
      f += s[l] * i, s[l] = f & 255, f >>= 8;
    for (; f > 0; )
      s.push(f & 255), f >>= 8;
  }
  for (var u = 0; e[u] === n && u < e.length - 1; ++u)
    s.push(0);
  return typeof pt < "u" ? pt.from(s.reverse()) : new Uint8Array(s.reverse());
};
function Un(e, t) {
  var a = 0, r = t.length, i = t.charAt(0), n = [0];
  for (a = 0; a < e.length(); ++a) {
    for (var s = 0, o = e.at(a); s < n.length; ++s)
      o += n[s] << 8, n[s] = o % r, o = o / r | 0;
    for (; o > 0; )
      n.push(o % r), o = o / r | 0;
  }
  var l = "";
  for (a = 0; e.at(a) === 0 && a < e.length() - 1; ++a)
    l += i;
  for (a = n.length - 1; a >= 0; --a)
    l += t[n[a]];
  return l;
}
var Xa = ee, Wa = Ln, I = Xa.util = Xa.util || {};
(function() {
  if (typeof kt < "u" && kt.nextTick && !kt.browser) {
    I.nextTick = kt.nextTick, typeof setImmediate == "function" ? I.setImmediate = setImmediate : I.setImmediate = I.nextTick;
    return;
  }
  if (typeof setImmediate == "function") {
    I.setImmediate = function() {
      return setImmediate.apply(void 0, arguments);
    }, I.nextTick = function(s) {
      return setImmediate(s);
    };
    return;
  }
  if (I.setImmediate = function(s) {
    setTimeout(s, 0);
  }, typeof window < "u" && typeof window.postMessage == "function") {
    let s = function(o) {
      if (o.source === window && o.data === e) {
        o.stopPropagation();
        var l = t.slice();
        t.length = 0, l.forEach(function(f) {
          f();
        });
      }
    };
    var e = "forge.setImmediate", t = [];
    I.setImmediate = function(o) {
      t.push(o), t.length === 1 && window.postMessage(e, "*");
    }, window.addEventListener("message", s, !0);
  }
  if (typeof MutationObserver < "u") {
    var a = Date.now(), r = !0, i = document.createElement("div"), t = [];
    new MutationObserver(function() {
      var o = t.slice();
      t.length = 0, o.forEach(function(l) {
        l();
      });
    }).observe(i, { attributes: !0 });
    var n = I.setImmediate;
    I.setImmediate = function(o) {
      Date.now() - a > 15 ? (a = Date.now(), n(o)) : (t.push(o), t.length === 1 && i.setAttribute("a", r = !r));
    };
  }
  I.nextTick = I.setImmediate;
})();
I.isNodejs = typeof kt < "u" && kt.versions && kt.versions.node;
I.globalScope = function() {
  return I.isNodejs ? xn : typeof self > "u" ? window : self;
}();
I.isArray = Array.isArray || function(e) {
  return Object.prototype.toString.call(e) === "[object Array]";
};
I.isArrayBuffer = function(e) {
  return typeof ArrayBuffer < "u" && e instanceof ArrayBuffer;
};
I.isArrayBufferView = function(e) {
  return e && I.isArrayBuffer(e.buffer) && e.byteLength !== void 0;
};
function xr(e) {
  if (!(e === 8 || e === 16 || e === 24 || e === 32))
    throw new Error("Only 8, 16, 24, or 32 bits supported: " + e);
}
I.ByteBuffer = wa;
function wa(e) {
  if (this.data = "", this.read = 0, typeof e == "string")
    this.data = e;
  else if (I.isArrayBuffer(e) || I.isArrayBufferView(e))
    if (typeof pt < "u" && e instanceof pt)
      this.data = e.toString("binary");
    else {
      var t = new Uint8Array(e);
      try {
        this.data = String.fromCharCode.apply(null, t);
      } catch {
        for (var a = 0; a < t.length; ++a)
          this.putByte(t[a]);
      }
    }
  else (e instanceof wa || typeof e == "object" && typeof e.data == "string" && typeof e.read == "number") && (this.data = e.data, this.read = e.read);
  this._constructedStringLength = 0;
}
I.ByteStringBuffer = wa;
var Dn = 4096;
I.ByteStringBuffer.prototype._optimizeConstructedString = function(e) {
  this._constructedStringLength += e, this._constructedStringLength > Dn && (this.data.substr(0, 1), this._constructedStringLength = 0);
};
I.ByteStringBuffer.prototype.length = function() {
  return this.data.length - this.read;
};
I.ByteStringBuffer.prototype.isEmpty = function() {
  return this.length() <= 0;
};
I.ByteStringBuffer.prototype.putByte = function(e) {
  return this.putBytes(String.fromCharCode(e));
};
I.ByteStringBuffer.prototype.fillWithByte = function(e, t) {
  e = String.fromCharCode(e);
  for (var a = this.data; t > 0; )
    t & 1 && (a += e), t >>>= 1, t > 0 && (e += e);
  return this.data = a, this._optimizeConstructedString(t), this;
};
I.ByteStringBuffer.prototype.putBytes = function(e) {
  return this.data += e, this._optimizeConstructedString(e.length), this;
};
I.ByteStringBuffer.prototype.putString = function(e) {
  return this.putBytes(I.encodeUtf8(e));
};
I.ByteStringBuffer.prototype.putInt16 = function(e) {
  return this.putBytes(
    String.fromCharCode(e >> 8 & 255) + String.fromCharCode(e & 255)
  );
};
I.ByteStringBuffer.prototype.putInt24 = function(e) {
  return this.putBytes(
    String.fromCharCode(e >> 16 & 255) + String.fromCharCode(e >> 8 & 255) + String.fromCharCode(e & 255)
  );
};
I.ByteStringBuffer.prototype.putInt32 = function(e) {
  return this.putBytes(
    String.fromCharCode(e >> 24 & 255) + String.fromCharCode(e >> 16 & 255) + String.fromCharCode(e >> 8 & 255) + String.fromCharCode(e & 255)
  );
};
I.ByteStringBuffer.prototype.putInt16Le = function(e) {
  return this.putBytes(
    String.fromCharCode(e & 255) + String.fromCharCode(e >> 8 & 255)
  );
};
I.ByteStringBuffer.prototype.putInt24Le = function(e) {
  return this.putBytes(
    String.fromCharCode(e & 255) + String.fromCharCode(e >> 8 & 255) + String.fromCharCode(e >> 16 & 255)
  );
};
I.ByteStringBuffer.prototype.putInt32Le = function(e) {
  return this.putBytes(
    String.fromCharCode(e & 255) + String.fromCharCode(e >> 8 & 255) + String.fromCharCode(e >> 16 & 255) + String.fromCharCode(e >> 24 & 255)
  );
};
I.ByteStringBuffer.prototype.putInt = function(e, t) {
  xr(t);
  var a = "";
  do
    t -= 8, a += String.fromCharCode(e >> t & 255);
  while (t > 0);
  return this.putBytes(a);
};
I.ByteStringBuffer.prototype.putSignedInt = function(e, t) {
  return e < 0 && (e += 2 << t - 1), this.putInt(e, t);
};
I.ByteStringBuffer.prototype.putBuffer = function(e) {
  return this.putBytes(e.getBytes());
};
I.ByteStringBuffer.prototype.getByte = function() {
  return this.data.charCodeAt(this.read++);
};
I.ByteStringBuffer.prototype.getInt16 = function() {
  var e = this.data.charCodeAt(this.read) << 8 ^ this.data.charCodeAt(this.read + 1);
  return this.read += 2, e;
};
I.ByteStringBuffer.prototype.getInt24 = function() {
  var e = this.data.charCodeAt(this.read) << 16 ^ this.data.charCodeAt(this.read + 1) << 8 ^ this.data.charCodeAt(this.read + 2);
  return this.read += 3, e;
};
I.ByteStringBuffer.prototype.getInt32 = function() {
  var e = this.data.charCodeAt(this.read) << 24 ^ this.data.charCodeAt(this.read + 1) << 16 ^ this.data.charCodeAt(this.read + 2) << 8 ^ this.data.charCodeAt(this.read + 3);
  return this.read += 4, e;
};
I.ByteStringBuffer.prototype.getInt16Le = function() {
  var e = this.data.charCodeAt(this.read) ^ this.data.charCodeAt(this.read + 1) << 8;
  return this.read += 2, e;
};
I.ByteStringBuffer.prototype.getInt24Le = function() {
  var e = this.data.charCodeAt(this.read) ^ this.data.charCodeAt(this.read + 1) << 8 ^ this.data.charCodeAt(this.read + 2) << 16;
  return this.read += 3, e;
};
I.ByteStringBuffer.prototype.getInt32Le = function() {
  var e = this.data.charCodeAt(this.read) ^ this.data.charCodeAt(this.read + 1) << 8 ^ this.data.charCodeAt(this.read + 2) << 16 ^ this.data.charCodeAt(this.read + 3) << 24;
  return this.read += 4, e;
};
I.ByteStringBuffer.prototype.getInt = function(e) {
  xr(e);
  var t = 0;
  do
    t = (t << 8) + this.data.charCodeAt(this.read++), e -= 8;
  while (e > 0);
  return t;
};
I.ByteStringBuffer.prototype.getSignedInt = function(e) {
  var t = this.getInt(e), a = 2 << e - 2;
  return t >= a && (t -= a << 1), t;
};
I.ByteStringBuffer.prototype.getBytes = function(e) {
  var t;
  return e ? (e = Math.min(this.length(), e), t = this.data.slice(this.read, this.read + e), this.read += e) : e === 0 ? t = "" : (t = this.read === 0 ? this.data : this.data.slice(this.read), this.clear()), t;
};
I.ByteStringBuffer.prototype.bytes = function(e) {
  return typeof e > "u" ? this.data.slice(this.read) : this.data.slice(this.read, this.read + e);
};
I.ByteStringBuffer.prototype.at = function(e) {
  return this.data.charCodeAt(this.read + e);
};
I.ByteStringBuffer.prototype.setAt = function(e, t) {
  return this.data = this.data.substr(0, this.read + e) + String.fromCharCode(t) + this.data.substr(this.read + e + 1), this;
};
I.ByteStringBuffer.prototype.last = function() {
  return this.data.charCodeAt(this.data.length - 1);
};
I.ByteStringBuffer.prototype.copy = function() {
  var e = I.createBuffer(this.data);
  return e.read = this.read, e;
};
I.ByteStringBuffer.prototype.compact = function() {
  return this.read > 0 && (this.data = this.data.slice(this.read), this.read = 0), this;
};
I.ByteStringBuffer.prototype.clear = function() {
  return this.data = "", this.read = 0, this;
};
I.ByteStringBuffer.prototype.truncate = function(e) {
  var t = Math.max(0, this.length() - e);
  return this.data = this.data.substr(this.read, t), this.read = 0, this;
};
I.ByteStringBuffer.prototype.toHex = function() {
  for (var e = "", t = this.read; t < this.data.length; ++t) {
    var a = this.data.charCodeAt(t);
    a < 16 && (e += "0"), e += a.toString(16);
  }
  return e;
};
I.ByteStringBuffer.prototype.toString = function() {
  return I.decodeUtf8(this.bytes());
};
function kn(e, t) {
  t = t || {}, this.read = t.readOffset || 0, this.growSize = t.growSize || 1024;
  var a = I.isArrayBuffer(e), r = I.isArrayBufferView(e);
  if (a || r) {
    a ? this.data = new DataView(e) : this.data = new DataView(e.buffer, e.byteOffset, e.byteLength), this.write = "writeOffset" in t ? t.writeOffset : this.data.byteLength;
    return;
  }
  this.data = new DataView(new ArrayBuffer(0)), this.write = 0, e != null && this.putBytes(e), "writeOffset" in t && (this.write = t.writeOffset);
}
I.DataBuffer = kn;
I.DataBuffer.prototype.length = function() {
  return this.write - this.read;
};
I.DataBuffer.prototype.isEmpty = function() {
  return this.length() <= 0;
};
I.DataBuffer.prototype.accommodate = function(e, t) {
  if (this.length() >= e)
    return this;
  t = Math.max(t || this.growSize, e);
  var a = new Uint8Array(
    this.data.buffer,
    this.data.byteOffset,
    this.data.byteLength
  ), r = new Uint8Array(this.length() + t);
  return r.set(a), this.data = new DataView(r.buffer), this;
};
I.DataBuffer.prototype.putByte = function(e) {
  return this.accommodate(1), this.data.setUint8(this.write++, e), this;
};
I.DataBuffer.prototype.fillWithByte = function(e, t) {
  this.accommodate(t);
  for (var a = 0; a < t; ++a)
    this.data.setUint8(e);
  return this;
};
I.DataBuffer.prototype.putBytes = function(e, t) {
  if (I.isArrayBufferView(e)) {
    var a = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), r = a.byteLength - a.byteOffset;
    this.accommodate(r);
    var i = new Uint8Array(this.data.buffer, this.write);
    return i.set(a), this.write += r, this;
  }
  if (I.isArrayBuffer(e)) {
    var a = new Uint8Array(e);
    this.accommodate(a.byteLength);
    var i = new Uint8Array(this.data.buffer);
    return i.set(a, this.write), this.write += a.byteLength, this;
  }
  if (e instanceof I.DataBuffer || typeof e == "object" && typeof e.read == "number" && typeof e.write == "number" && I.isArrayBufferView(e.data)) {
    var a = new Uint8Array(e.data.byteLength, e.read, e.length());
    this.accommodate(a.byteLength);
    var i = new Uint8Array(e.data.byteLength, this.write);
    return i.set(a), this.write += a.byteLength, this;
  }
  if (e instanceof I.ByteStringBuffer && (e = e.data, t = "binary"), t = t || "binary", typeof e == "string") {
    var n;
    if (t === "hex")
      return this.accommodate(Math.ceil(e.length / 2)), n = new Uint8Array(this.data.buffer, this.write), this.write += I.binary.hex.decode(e, n, this.write), this;
    if (t === "base64")
      return this.accommodate(Math.ceil(e.length / 4) * 3), n = new Uint8Array(this.data.buffer, this.write), this.write += I.binary.base64.decode(e, n, this.write), this;
    if (t === "utf8" && (e = I.encodeUtf8(e), t = "binary"), t === "binary" || t === "raw")
      return this.accommodate(e.length), n = new Uint8Array(this.data.buffer, this.write), this.write += I.binary.raw.decode(n), this;
    if (t === "utf16")
      return this.accommodate(e.length * 2), n = new Uint16Array(this.data.buffer, this.write), this.write += I.text.utf16.encode(n), this;
    throw new Error("Invalid encoding: " + t);
  }
  throw Error("Invalid parameter: " + e);
};
I.DataBuffer.prototype.putBuffer = function(e) {
  return this.putBytes(e), e.clear(), this;
};
I.DataBuffer.prototype.putString = function(e) {
  return this.putBytes(e, "utf16");
};
I.DataBuffer.prototype.putInt16 = function(e) {
  return this.accommodate(2), this.data.setInt16(this.write, e), this.write += 2, this;
};
I.DataBuffer.prototype.putInt24 = function(e) {
  return this.accommodate(3), this.data.setInt16(this.write, e >> 8 & 65535), this.data.setInt8(this.write, e >> 16 & 255), this.write += 3, this;
};
I.DataBuffer.prototype.putInt32 = function(e) {
  return this.accommodate(4), this.data.setInt32(this.write, e), this.write += 4, this;
};
I.DataBuffer.prototype.putInt16Le = function(e) {
  return this.accommodate(2), this.data.setInt16(this.write, e, !0), this.write += 2, this;
};
I.DataBuffer.prototype.putInt24Le = function(e) {
  return this.accommodate(3), this.data.setInt8(this.write, e >> 16 & 255), this.data.setInt16(this.write, e >> 8 & 65535, !0), this.write += 3, this;
};
I.DataBuffer.prototype.putInt32Le = function(e) {
  return this.accommodate(4), this.data.setInt32(this.write, e, !0), this.write += 4, this;
};
I.DataBuffer.prototype.putInt = function(e, t) {
  xr(t), this.accommodate(t / 8);
  do
    t -= 8, this.data.setInt8(this.write++, e >> t & 255);
  while (t > 0);
  return this;
};
I.DataBuffer.prototype.putSignedInt = function(e, t) {
  return xr(t), this.accommodate(t / 8), e < 0 && (e += 2 << t - 1), this.putInt(e, t);
};
I.DataBuffer.prototype.getByte = function() {
  return this.data.getInt8(this.read++);
};
I.DataBuffer.prototype.getInt16 = function() {
  var e = this.data.getInt16(this.read);
  return this.read += 2, e;
};
I.DataBuffer.prototype.getInt24 = function() {
  var e = this.data.getInt16(this.read) << 8 ^ this.data.getInt8(this.read + 2);
  return this.read += 3, e;
};
I.DataBuffer.prototype.getInt32 = function() {
  var e = this.data.getInt32(this.read);
  return this.read += 4, e;
};
I.DataBuffer.prototype.getInt16Le = function() {
  var e = this.data.getInt16(this.read, !0);
  return this.read += 2, e;
};
I.DataBuffer.prototype.getInt24Le = function() {
  var e = this.data.getInt8(this.read) ^ this.data.getInt16(this.read + 1, !0) << 8;
  return this.read += 3, e;
};
I.DataBuffer.prototype.getInt32Le = function() {
  var e = this.data.getInt32(this.read, !0);
  return this.read += 4, e;
};
I.DataBuffer.prototype.getInt = function(e) {
  xr(e);
  var t = 0;
  do
    t = (t << 8) + this.data.getInt8(this.read++), e -= 8;
  while (e > 0);
  return t;
};
I.DataBuffer.prototype.getSignedInt = function(e) {
  var t = this.getInt(e), a = 2 << e - 2;
  return t >= a && (t -= a << 1), t;
};
I.DataBuffer.prototype.getBytes = function(e) {
  var t;
  return e ? (e = Math.min(this.length(), e), t = this.data.slice(this.read, this.read + e), this.read += e) : e === 0 ? t = "" : (t = this.read === 0 ? this.data : this.data.slice(this.read), this.clear()), t;
};
I.DataBuffer.prototype.bytes = function(e) {
  return typeof e > "u" ? this.data.slice(this.read) : this.data.slice(this.read, this.read + e);
};
I.DataBuffer.prototype.at = function(e) {
  return this.data.getUint8(this.read + e);
};
I.DataBuffer.prototype.setAt = function(e, t) {
  return this.data.setUint8(e, t), this;
};
I.DataBuffer.prototype.last = function() {
  return this.data.getUint8(this.write - 1);
};
I.DataBuffer.prototype.copy = function() {
  return new I.DataBuffer(this);
};
I.DataBuffer.prototype.compact = function() {
  if (this.read > 0) {
    var e = new Uint8Array(this.data.buffer, this.read), t = new Uint8Array(e.byteLength);
    t.set(e), this.data = new DataView(t), this.write -= this.read, this.read = 0;
  }
  return this;
};
I.DataBuffer.prototype.clear = function() {
  return this.data = new DataView(new ArrayBuffer(0)), this.read = this.write = 0, this;
};
I.DataBuffer.prototype.truncate = function(e) {
  return this.write = Math.max(0, this.length() - e), this.read = Math.min(this.read, this.write), this;
};
I.DataBuffer.prototype.toHex = function() {
  for (var e = "", t = this.read; t < this.data.byteLength; ++t) {
    var a = this.data.getUint8(t);
    a < 16 && (e += "0"), e += a.toString(16);
  }
  return e;
};
I.DataBuffer.prototype.toString = function(e) {
  var t = new Uint8Array(this.data, this.read, this.length());
  if (e = e || "utf8", e === "binary" || e === "raw")
    return I.binary.raw.encode(t);
  if (e === "hex")
    return I.binary.hex.encode(t);
  if (e === "base64")
    return I.binary.base64.encode(t);
  if (e === "utf8")
    return I.text.utf8.decode(t);
  if (e === "utf16")
    return I.text.utf16.decode(t);
  throw new Error("Invalid encoding: " + e);
};
I.createBuffer = function(e, t) {
  return t = t || "raw", e !== void 0 && t === "utf8" && (e = I.encodeUtf8(e)), new I.ByteBuffer(e);
};
I.fillString = function(e, t) {
  for (var a = ""; t > 0; )
    t & 1 && (a += e), t >>>= 1, t > 0 && (e += e);
  return a;
};
I.xorBytes = function(e, t, a) {
  for (var r = "", i = "", n = "", s = 0, o = 0; a > 0; --a, ++s)
    i = e.charCodeAt(s) ^ t.charCodeAt(s), o >= 10 && (r += n, n = "", o = 0), n += String.fromCharCode(i), ++o;
  return r += n, r;
};
I.hexToBytes = function(e) {
  var t = "", a = 0;
  for (e.length & !0 && (a = 1, t += String.fromCharCode(parseInt(e[0], 16))); a < e.length; a += 2)
    t += String.fromCharCode(parseInt(e.substr(a, 2), 16));
  return t;
};
I.bytesToHex = function(e) {
  return I.createBuffer(e).toHex();
};
I.int32ToBytes = function(e) {
  return String.fromCharCode(e >> 24 & 255) + String.fromCharCode(e >> 16 & 255) + String.fromCharCode(e >> 8 & 255) + String.fromCharCode(e & 255);
};
var Pt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", Vt = [
  /*43 -43 = 0*/
  /*'+',  1,  2,  3,'/' */
  62,
  -1,
  -1,
  -1,
  63,
  /*'0','1','2','3','4','5','6','7','8','9' */
  52,
  53,
  54,
  55,
  56,
  57,
  58,
  59,
  60,
  61,
  /*15, 16, 17,'=', 19, 20, 21 */
  -1,
  -1,
  -1,
  64,
  -1,
  -1,
  -1,
  /*65 - 43 = 22*/
  /*'A','B','C','D','E','F','G','H','I','J','K','L','M', */
  0,
  1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  10,
  11,
  12,
  /*'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' */
  13,
  14,
  15,
  16,
  17,
  18,
  19,
  20,
  21,
  22,
  23,
  24,
  25,
  /*91 - 43 = 48 */
  /*48, 49, 50, 51, 52, 53 */
  -1,
  -1,
  -1,
  -1,
  -1,
  -1,
  /*97 - 43 = 54*/
  /*'a','b','c','d','e','f','g','h','i','j','k','l','m' */
  26,
  27,
  28,
  29,
  30,
  31,
  32,
  33,
  34,
  35,
  36,
  37,
  38,
  /*'n','o','p','q','r','s','t','u','v','w','x','y','z' */
  39,
  40,
  41,
  42,
  43,
  44,
  45,
  46,
  47,
  48,
  49,
  50,
  51
], Si = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
I.encode64 = function(e, t) {
  for (var a = "", r = "", i, n, s, o = 0; o < e.length; )
    i = e.charCodeAt(o++), n = e.charCodeAt(o++), s = e.charCodeAt(o++), a += Pt.charAt(i >> 2), a += Pt.charAt((i & 3) << 4 | n >> 4), isNaN(n) ? a += "==" : (a += Pt.charAt((n & 15) << 2 | s >> 6), a += isNaN(s) ? "=" : Pt.charAt(s & 63)), t && a.length > t && (r += a.substr(0, t) + `\r
`, a = a.substr(t));
  return r += a, r;
};
I.decode64 = function(e) {
  e = e.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  for (var t = "", a, r, i, n, s = 0; s < e.length; )
    a = Vt[e.charCodeAt(s++) - 43], r = Vt[e.charCodeAt(s++) - 43], i = Vt[e.charCodeAt(s++) - 43], n = Vt[e.charCodeAt(s++) - 43], t += String.fromCharCode(a << 2 | r >> 4), i !== 64 && (t += String.fromCharCode((r & 15) << 4 | i >> 2), n !== 64 && (t += String.fromCharCode((i & 3) << 6 | n)));
  return t;
};
I.encodeUtf8 = function(e) {
  return unescape(encodeURIComponent(e));
};
I.decodeUtf8 = function(e) {
  return decodeURIComponent(escape(e));
};
I.binary = {
  raw: {},
  hex: {},
  base64: {},
  base58: {},
  baseN: {
    encode: Wa.encode,
    decode: Wa.decode
  }
};
I.binary.raw.encode = function(e) {
  return String.fromCharCode.apply(null, e);
};
I.binary.raw.decode = function(e, t, a) {
  var r = t;
  r || (r = new Uint8Array(e.length)), a = a || 0;
  for (var i = a, n = 0; n < e.length; ++n)
    r[i++] = e.charCodeAt(n);
  return t ? i - a : r;
};
I.binary.hex.encode = I.bytesToHex;
I.binary.hex.decode = function(e, t, a) {
  var r = t;
  r || (r = new Uint8Array(Math.ceil(e.length / 2))), a = a || 0;
  var i = 0, n = a;
  for (e.length & 1 && (i = 1, r[n++] = parseInt(e[0], 16)); i < e.length; i += 2)
    r[n++] = parseInt(e.substr(i, 2), 16);
  return t ? n - a : r;
};
I.binary.base64.encode = function(e, t) {
  for (var a = "", r = "", i, n, s, o = 0; o < e.byteLength; )
    i = e[o++], n = e[o++], s = e[o++], a += Pt.charAt(i >> 2), a += Pt.charAt((i & 3) << 4 | n >> 4), isNaN(n) ? a += "==" : (a += Pt.charAt((n & 15) << 2 | s >> 6), a += isNaN(s) ? "=" : Pt.charAt(s & 63)), t && a.length > t && (r += a.substr(0, t) + `\r
`, a = a.substr(t));
  return r += a, r;
};
I.binary.base64.decode = function(e, t, a) {
  var r = t;
  r || (r = new Uint8Array(Math.ceil(e.length / 4) * 3)), e = e.replace(/[^A-Za-z0-9\+\/\=]/g, ""), a = a || 0;
  for (var i, n, s, o, l = 0, f = a; l < e.length; )
    i = Vt[e.charCodeAt(l++) - 43], n = Vt[e.charCodeAt(l++) - 43], s = Vt[e.charCodeAt(l++) - 43], o = Vt[e.charCodeAt(l++) - 43], r[f++] = i << 2 | n >> 4, s !== 64 && (r[f++] = (n & 15) << 4 | s >> 2, o !== 64 && (r[f++] = (s & 3) << 6 | o));
  return t ? f - a : r.subarray(0, f);
};
I.binary.base58.encode = function(e, t) {
  return I.binary.baseN.encode(e, Si, t);
};
I.binary.base58.decode = function(e, t) {
  return I.binary.baseN.decode(e, Si, t);
};
I.text = {
  utf8: {},
  utf16: {}
};
I.text.utf8.encode = function(e, t, a) {
  e = I.encodeUtf8(e);
  var r = t;
  r || (r = new Uint8Array(e.length)), a = a || 0;
  for (var i = a, n = 0; n < e.length; ++n)
    r[i++] = e.charCodeAt(n);
  return t ? i - a : r;
};
I.text.utf8.decode = function(e) {
  return I.decodeUtf8(String.fromCharCode.apply(null, e));
};
I.text.utf16.encode = function(e, t, a) {
  var r = t;
  r || (r = new Uint8Array(e.length * 2));
  var i = new Uint16Array(r.buffer);
  a = a || 0;
  for (var n = a, s = a, o = 0; o < e.length; ++o)
    i[s++] = e.charCodeAt(o), n += 2;
  return t ? n - a : r;
};
I.text.utf16.decode = function(e) {
  return String.fromCharCode.apply(null, new Uint16Array(e.buffer));
};
I.deflate = function(e, t, a) {
  if (t = I.decode64(e.deflate(I.encode64(t)).rval), a) {
    var r = 2, i = t.charCodeAt(1);
    i & 32 && (r = 6), t = t.substring(r, t.length - 4);
  }
  return t;
};
I.inflate = function(e, t, a) {
  var r = e.inflate(I.encode64(t)).rval;
  return r === null ? null : I.decode64(r);
};
var _a = function(e, t, a) {
  if (!e)
    throw new Error("WebStorage not available.");
  var r;
  if (a === null ? r = e.removeItem(t) : (a = I.encode64(JSON.stringify(a)), r = e.setItem(t, a)), typeof r < "u" && r.rval !== !0) {
    var i = new Error(r.error.message);
    throw i.id = r.error.id, i.name = r.error.name, i;
  }
}, Na = function(e, t) {
  if (!e)
    throw new Error("WebStorage not available.");
  var a = e.getItem(t);
  if (e.init)
    if (a.rval === null) {
      if (a.error) {
        var r = new Error(a.error.message);
        throw r.id = a.error.id, r.name = a.error.name, r;
      }
      a = null;
    } else
      a = a.rval;
  return a !== null && (a = JSON.parse(I.decode64(a))), a;
}, Pn = function(e, t, a, r) {
  var i = Na(e, t);
  i === null && (i = {}), i[a] = r, _a(e, t, i);
}, Vn = function(e, t, a) {
  var r = Na(e, t);
  return r !== null && (r = a in r ? r[a] : null), r;
}, Fn = function(e, t, a) {
  var r = Na(e, t);
  if (r !== null && a in r) {
    delete r[a];
    var i = !0;
    for (var n in r) {
      i = !1;
      break;
    }
    i && (r = null), _a(e, t, r);
  }
}, On = function(e, t) {
  _a(e, t, null);
}, Gr = function(e, t, a) {
  var r = null;
  typeof a > "u" && (a = ["web", "flash"]);
  var i, n = !1, s = null;
  for (var o in a) {
    i = a[o];
    try {
      if (i === "flash" || i === "both") {
        if (t[0] === null)
          throw new Error("Flash local storage not available.");
        r = e.apply(this, t), n = i === "flash";
      }
      (i === "web" || i === "both") && (t[0] = localStorage, r = e.apply(this, t), n = !0);
    } catch (l) {
      s = l;
    }
    if (n)
      break;
  }
  if (!n)
    throw s;
  return r;
};
I.setItem = function(e, t, a, r, i) {
  Gr(Pn, arguments, i);
};
I.getItem = function(e, t, a, r) {
  return Gr(Vn, arguments, r);
};
I.removeItem = function(e, t, a, r) {
  Gr(Fn, arguments, r);
};
I.clearItems = function(e, t, a) {
  Gr(On, arguments, a);
};
I.isEmpty = function(e) {
  for (var t in e)
    if (e.hasOwnProperty(t))
      return !1;
  return !0;
};
I.format = function(e) {
  for (var t = /%./g, a, r, i = 0, n = [], s = 0; a = t.exec(e); ) {
    r = e.substring(s, t.lastIndex - 2), r.length > 0 && n.push(r), s = t.lastIndex;
    var o = a[0][1];
    switch (o) {
      case "s":
      case "o":
        i < arguments.length ? n.push(arguments[i++ + 1]) : n.push("<?>");
        break;
      case "%":
        n.push("%");
        break;
      default:
        n.push("<%" + o + "?>");
    }
  }
  return n.push(e.substring(s)), n.join("");
};
I.formatNumber = function(e, t, a, r) {
  var i = e, n = isNaN(t = Math.abs(t)) ? 2 : t, s = a === void 0 ? "," : a, o = r === void 0 ? "." : r, l = i < 0 ? "-" : "", f = parseInt(i = Math.abs(+i || 0).toFixed(n), 10) + "", u = f.length > 3 ? f.length % 3 : 0;
  return l + (u ? f.substr(0, u) + o : "") + f.substr(u).replace(/(\d{3})(?=\d)/g, "$1" + o) + (n ? s + Math.abs(i - f).toFixed(n).slice(2) : "");
};
I.formatSize = function(e) {
  return e >= 1073741824 ? e = I.formatNumber(e / 1073741824, 2, ".", "") + " GiB" : e >= 1048576 ? e = I.formatNumber(e / 1048576, 2, ".", "") + " MiB" : e >= 1024 ? e = I.formatNumber(e / 1024, 0) + " KiB" : e = I.formatNumber(e, 0) + " bytes", e;
};
I.bytesFromIP = function(e) {
  return e.indexOf(".") !== -1 ? I.bytesFromIPv4(e) : e.indexOf(":") !== -1 ? I.bytesFromIPv6(e) : null;
};
I.bytesFromIPv4 = function(e) {
  if (e = e.split("."), e.length !== 4)
    return null;
  for (var t = I.createBuffer(), a = 0; a < e.length; ++a) {
    var r = parseInt(e[a], 10);
    if (isNaN(r))
      return null;
    t.putByte(r);
  }
  return t.getBytes();
};
I.bytesFromIPv6 = function(e) {
  var t = 0;
  e = e.split(":").filter(function(s) {
    return s.length === 0 && ++t, !0;
  });
  for (var a = (8 - e.length + t) * 2, r = I.createBuffer(), i = 0; i < 8; ++i) {
    if (!e[i] || e[i].length === 0) {
      r.fillWithByte(0, a), a = 0;
      continue;
    }
    var n = I.hexToBytes(e[i]);
    n.length < 2 && r.putByte(0), r.putBytes(n);
  }
  return r.getBytes();
};
I.bytesToIP = function(e) {
  return e.length === 4 ? I.bytesToIPv4(e) : e.length === 16 ? I.bytesToIPv6(e) : null;
};
I.bytesToIPv4 = function(e) {
  if (e.length !== 4)
    return null;
  for (var t = [], a = 0; a < e.length; ++a)
    t.push(e.charCodeAt(a));
  return t.join(".");
};
I.bytesToIPv6 = function(e) {
  if (e.length !== 16)
    return null;
  for (var t = [], a = [], r = 0, i = 0; i < e.length; i += 2) {
    for (var n = I.bytesToHex(e[i] + e[i + 1]); n[0] === "0" && n !== "0"; )
      n = n.substr(1);
    if (n === "0") {
      var s = a[a.length - 1], o = t.length;
      !s || o !== s.end + 1 ? a.push({ start: o, end: o }) : (s.end = o, s.end - s.start > a[r].end - a[r].start && (r = a.length - 1));
    }
    t.push(n);
  }
  if (a.length > 0) {
    var l = a[r];
    l.end - l.start > 0 && (t.splice(l.start, l.end - l.start + 1, ""), l.start === 0 && t.unshift(""), l.end === 7 && t.push(""));
  }
  return t.join(":");
};
I.estimateCores = function(e, t) {
  if (typeof e == "function" && (t = e, e = {}), e = e || {}, "cores" in I && !e.update)
    return t(null, I.cores);
  if (typeof navigator < "u" && "hardwareConcurrency" in navigator && navigator.hardwareConcurrency > 0)
    return I.cores = navigator.hardwareConcurrency, t(null, I.cores);
  if (typeof Worker > "u")
    return I.cores = 1, t(null, I.cores);
  if (typeof Blob > "u")
    return I.cores = 2, t(null, I.cores);
  var a = URL.createObjectURL(new Blob([
    "(",
    function() {
      self.addEventListener("message", function(s) {
        var o = Date.now(), l = o + 4;
        self.postMessage({ st: o, et: l });
      });
    }.toString(),
    ")()"
  ], { type: "application/javascript" }));
  r([], 5, 16);
  function r(s, o, l) {
    if (o === 0) {
      var f = Math.floor(s.reduce(function(u, p) {
        return u + p;
      }, 0) / s.length);
      return I.cores = Math.max(1, f), URL.revokeObjectURL(a), t(null, I.cores);
    }
    i(l, function(u, p) {
      s.push(n(l, p)), r(s, o - 1, l);
    });
  }
  function i(s, o) {
    for (var l = [], f = [], u = 0; u < s; ++u) {
      var p = new Worker(a);
      p.addEventListener("message", function(m) {
        if (f.push(m.data), f.length === s) {
          for (var S = 0; S < s; ++S)
            l[S].terminate();
          o(null, f);
        }
      }), l.push(p);
    }
    for (var u = 0; u < s; ++u)
      l[u].postMessage(u);
  }
  function n(s, o) {
    for (var l = [], f = 0; f < s; ++f)
      for (var u = o[f], p = l[f] = [], m = 0; m < s; ++m)
        if (f !== m) {
          var S = o[m];
          (u.st > S.st && u.st < S.et || S.st > u.st && S.st < u.et) && p.push(m);
        }
    return l.reduce(function(C, A) {
      return Math.max(C, A.length);
    }, 0);
  }
};
var Ye = ee;
Ye.cipher = Ye.cipher || {};
Ye.cipher.algorithms = Ye.cipher.algorithms || {};
Ye.cipher.createCipher = function(e, t) {
  var a = e;
  if (typeof a == "string" && (a = Ye.cipher.getAlgorithm(a), a && (a = a())), !a)
    throw new Error("Unsupported algorithm: " + e);
  return new Ye.cipher.BlockCipher({
    algorithm: a,
    key: t,
    decrypt: !1
  });
};
Ye.cipher.createDecipher = function(e, t) {
  var a = e;
  if (typeof a == "string" && (a = Ye.cipher.getAlgorithm(a), a && (a = a())), !a)
    throw new Error("Unsupported algorithm: " + e);
  return new Ye.cipher.BlockCipher({
    algorithm: a,
    key: t,
    decrypt: !0
  });
};
Ye.cipher.registerAlgorithm = function(e, t) {
  e = e.toUpperCase(), Ye.cipher.algorithms[e] = t;
};
Ye.cipher.getAlgorithm = function(e) {
  return e = e.toUpperCase(), e in Ye.cipher.algorithms ? Ye.cipher.algorithms[e] : null;
};
var Ra = Ye.cipher.BlockCipher = function(e) {
  this.algorithm = e.algorithm, this.mode = this.algorithm.mode, this.blockSize = this.mode.blockSize, this._finish = !1, this._input = null, this.output = null, this._op = e.decrypt ? this.mode.decrypt : this.mode.encrypt, this._decrypt = e.decrypt, this.algorithm.initialize(e);
};
Ra.prototype.start = function(e) {
  e = e || {};
  var t = {};
  for (var a in e)
    t[a] = e[a];
  t.decrypt = this._decrypt, this._finish = !1, this._input = Ye.util.createBuffer(), this.output = e.output || Ye.util.createBuffer(), this.mode.start(t);
};
Ra.prototype.update = function(e) {
  for (e && this._input.putBuffer(e); !this._op.call(this.mode, this._input, this.output, this._finish) && !this._finish; )
    ;
  this._input.compact();
};
Ra.prototype.finish = function(e) {
  e && (this.mode.name === "ECB" || this.mode.name === "CBC") && (this.mode.pad = function(a) {
    return e(this.blockSize, a, !1);
  }, this.mode.unpad = function(a) {
    return e(this.blockSize, a, !0);
  });
  var t = {};
  return t.decrypt = this._decrypt, t.overflow = this._input.length() % this.blockSize, !(!this._decrypt && this.mode.pad && !this.mode.pad(this._input, t) || (this._finish = !0, this.update(), this._decrypt && this.mode.unpad && !this.mode.unpad(this.output, t)) || this.mode.afterFinish && !this.mode.afterFinish(this.output, t));
};
var ze = ee;
ze.cipher = ze.cipher || {};
var ie = ze.cipher.modes = ze.cipher.modes || {};
ie.ecb = function(e) {
  e = e || {}, this.name = "ECB", this.cipher = e.cipher, this.blockSize = e.blockSize || 16, this._ints = this.blockSize / 4, this._inBlock = new Array(this._ints), this._outBlock = new Array(this._ints);
};
ie.ecb.prototype.start = function(e) {
};
ie.ecb.prototype.encrypt = function(e, t, a) {
  if (e.length() < this.blockSize && !(a && e.length() > 0))
    return !0;
  for (var r = 0; r < this._ints; ++r)
    this._inBlock[r] = e.getInt32();
  this.cipher.encrypt(this._inBlock, this._outBlock);
  for (var r = 0; r < this._ints; ++r)
    t.putInt32(this._outBlock[r]);
};
ie.ecb.prototype.decrypt = function(e, t, a) {
  if (e.length() < this.blockSize && !(a && e.length() > 0))
    return !0;
  for (var r = 0; r < this._ints; ++r)
    this._inBlock[r] = e.getInt32();
  this.cipher.decrypt(this._inBlock, this._outBlock);
  for (var r = 0; r < this._ints; ++r)
    t.putInt32(this._outBlock[r]);
};
ie.ecb.prototype.pad = function(e, t) {
  var a = e.length() === this.blockSize ? this.blockSize : this.blockSize - e.length();
  return e.fillWithByte(a, a), !0;
};
ie.ecb.prototype.unpad = function(e, t) {
  if (t.overflow > 0)
    return !1;
  var a = e.length(), r = e.at(a - 1);
  return r > this.blockSize << 2 ? !1 : (e.truncate(r), !0);
};
ie.cbc = function(e) {
  e = e || {}, this.name = "CBC", this.cipher = e.cipher, this.blockSize = e.blockSize || 16, this._ints = this.blockSize / 4, this._inBlock = new Array(this._ints), this._outBlock = new Array(this._ints);
};
ie.cbc.prototype.start = function(e) {
  if (e.iv === null) {
    if (!this._prev)
      throw new Error("Invalid IV parameter.");
    this._iv = this._prev.slice(0);
  } else if ("iv" in e)
    this._iv = qr(e.iv, this.blockSize), this._prev = this._iv.slice(0);
  else
    throw new Error("Invalid IV parameter.");
};
ie.cbc.prototype.encrypt = function(e, t, a) {
  if (e.length() < this.blockSize && !(a && e.length() > 0))
    return !0;
  for (var r = 0; r < this._ints; ++r)
    this._inBlock[r] = this._prev[r] ^ e.getInt32();
  this.cipher.encrypt(this._inBlock, this._outBlock);
  for (var r = 0; r < this._ints; ++r)
    t.putInt32(this._outBlock[r]);
  this._prev = this._outBlock;
};
ie.cbc.prototype.decrypt = function(e, t, a) {
  if (e.length() < this.blockSize && !(a && e.length() > 0))
    return !0;
  for (var r = 0; r < this._ints; ++r)
    this._inBlock[r] = e.getInt32();
  this.cipher.decrypt(this._inBlock, this._outBlock);
  for (var r = 0; r < this._ints; ++r)
    t.putInt32(this._prev[r] ^ this._outBlock[r]);
  this._prev = this._inBlock.slice(0);
};
ie.cbc.prototype.pad = function(e, t) {
  var a = e.length() === this.blockSize ? this.blockSize : this.blockSize - e.length();
  return e.fillWithByte(a, a), !0;
};
ie.cbc.prototype.unpad = function(e, t) {
  if (t.overflow > 0)
    return !1;
  var a = e.length(), r = e.at(a - 1);
  return r > this.blockSize << 2 ? !1 : (e.truncate(r), !0);
};
ie.cfb = function(e) {
  e = e || {}, this.name = "CFB", this.cipher = e.cipher, this.blockSize = e.blockSize || 16, this._ints = this.blockSize / 4, this._inBlock = null, this._outBlock = new Array(this._ints), this._partialBlock = new Array(this._ints), this._partialOutput = ze.util.createBuffer(), this._partialBytes = 0;
};
ie.cfb.prototype.start = function(e) {
  if (!("iv" in e))
    throw new Error("Invalid IV parameter.");
  this._iv = qr(e.iv, this.blockSize), this._inBlock = this._iv.slice(0), this._partialBytes = 0;
};
ie.cfb.prototype.encrypt = function(e, t, a) {
  var r = e.length();
  if (r === 0)
    return !0;
  if (this.cipher.encrypt(this._inBlock, this._outBlock), this._partialBytes === 0 && r >= this.blockSize) {
    for (var i = 0; i < this._ints; ++i)
      this._inBlock[i] = e.getInt32() ^ this._outBlock[i], t.putInt32(this._inBlock[i]);
    return;
  }
  var n = (this.blockSize - r) % this.blockSize;
  n > 0 && (n = this.blockSize - n), this._partialOutput.clear();
  for (var i = 0; i < this._ints; ++i)
    this._partialBlock[i] = e.getInt32() ^ this._outBlock[i], this._partialOutput.putInt32(this._partialBlock[i]);
  if (n > 0)
    e.read -= this.blockSize;
  else
    for (var i = 0; i < this._ints; ++i)
      this._inBlock[i] = this._partialBlock[i];
  if (this._partialBytes > 0 && this._partialOutput.getBytes(this._partialBytes), n > 0 && !a)
    return t.putBytes(this._partialOutput.getBytes(
      n - this._partialBytes
    )), this._partialBytes = n, !0;
  t.putBytes(this._partialOutput.getBytes(
    r - this._partialBytes
  )), this._partialBytes = 0;
};
ie.cfb.prototype.decrypt = function(e, t, a) {
  var r = e.length();
  if (r === 0)
    return !0;
  if (this.cipher.encrypt(this._inBlock, this._outBlock), this._partialBytes === 0 && r >= this.blockSize) {
    for (var i = 0; i < this._ints; ++i)
      this._inBlock[i] = e.getInt32(), t.putInt32(this._inBlock[i] ^ this._outBlock[i]);
    return;
  }
  var n = (this.blockSize - r) % this.blockSize;
  n > 0 && (n = this.blockSize - n), this._partialOutput.clear();
  for (var i = 0; i < this._ints; ++i)
    this._partialBlock[i] = e.getInt32(), this._partialOutput.putInt32(this._partialBlock[i] ^ this._outBlock[i]);
  if (n > 0)
    e.read -= this.blockSize;
  else
    for (var i = 0; i < this._ints; ++i)
      this._inBlock[i] = this._partialBlock[i];
  if (this._partialBytes > 0 && this._partialOutput.getBytes(this._partialBytes), n > 0 && !a)
    return t.putBytes(this._partialOutput.getBytes(
      n - this._partialBytes
    )), this._partialBytes = n, !0;
  t.putBytes(this._partialOutput.getBytes(
    r - this._partialBytes
  )), this._partialBytes = 0;
};
ie.ofb = function(e) {
  e = e || {}, this.name = "OFB", this.cipher = e.cipher, this.blockSize = e.blockSize || 16, this._ints = this.blockSize / 4, this._inBlock = null, this._outBlock = new Array(this._ints), this._partialOutput = ze.util.createBuffer(), this._partialBytes = 0;
};
ie.ofb.prototype.start = function(e) {
  if (!("iv" in e))
    throw new Error("Invalid IV parameter.");
  this._iv = qr(e.iv, this.blockSize), this._inBlock = this._iv.slice(0), this._partialBytes = 0;
};
ie.ofb.prototype.encrypt = function(e, t, a) {
  var r = e.length();
  if (e.length() === 0)
    return !0;
  if (this.cipher.encrypt(this._inBlock, this._outBlock), this._partialBytes === 0 && r >= this.blockSize) {
    for (var i = 0; i < this._ints; ++i)
      t.putInt32(e.getInt32() ^ this._outBlock[i]), this._inBlock[i] = this._outBlock[i];
    return;
  }
  var n = (this.blockSize - r) % this.blockSize;
  n > 0 && (n = this.blockSize - n), this._partialOutput.clear();
  for (var i = 0; i < this._ints; ++i)
    this._partialOutput.putInt32(e.getInt32() ^ this._outBlock[i]);
  if (n > 0)
    e.read -= this.blockSize;
  else
    for (var i = 0; i < this._ints; ++i)
      this._inBlock[i] = this._outBlock[i];
  if (this._partialBytes > 0 && this._partialOutput.getBytes(this._partialBytes), n > 0 && !a)
    return t.putBytes(this._partialOutput.getBytes(
      n - this._partialBytes
    )), this._partialBytes = n, !0;
  t.putBytes(this._partialOutput.getBytes(
    r - this._partialBytes
  )), this._partialBytes = 0;
};
ie.ofb.prototype.decrypt = ie.ofb.prototype.encrypt;
ie.ctr = function(e) {
  e = e || {}, this.name = "CTR", this.cipher = e.cipher, this.blockSize = e.blockSize || 16, this._ints = this.blockSize / 4, this._inBlock = null, this._outBlock = new Array(this._ints), this._partialOutput = ze.util.createBuffer(), this._partialBytes = 0;
};
ie.ctr.prototype.start = function(e) {
  if (!("iv" in e))
    throw new Error("Invalid IV parameter.");
  this._iv = qr(e.iv, this.blockSize), this._inBlock = this._iv.slice(0), this._partialBytes = 0;
};
ie.ctr.prototype.encrypt = function(e, t, a) {
  var r = e.length();
  if (r === 0)
    return !0;
  if (this.cipher.encrypt(this._inBlock, this._outBlock), this._partialBytes === 0 && r >= this.blockSize)
    for (var i = 0; i < this._ints; ++i)
      t.putInt32(e.getInt32() ^ this._outBlock[i]);
  else {
    var n = (this.blockSize - r) % this.blockSize;
    n > 0 && (n = this.blockSize - n), this._partialOutput.clear();
    for (var i = 0; i < this._ints; ++i)
      this._partialOutput.putInt32(e.getInt32() ^ this._outBlock[i]);
    if (n > 0 && (e.read -= this.blockSize), this._partialBytes > 0 && this._partialOutput.getBytes(this._partialBytes), n > 0 && !a)
      return t.putBytes(this._partialOutput.getBytes(
        n - this._partialBytes
      )), this._partialBytes = n, !0;
    t.putBytes(this._partialOutput.getBytes(
      r - this._partialBytes
    )), this._partialBytes = 0;
  }
  Qr(this._inBlock);
};
ie.ctr.prototype.decrypt = ie.ctr.prototype.encrypt;
ie.gcm = function(e) {
  e = e || {}, this.name = "GCM", this.cipher = e.cipher, this.blockSize = e.blockSize || 16, this._ints = this.blockSize / 4, this._inBlock = new Array(this._ints), this._outBlock = new Array(this._ints), this._partialOutput = ze.util.createBuffer(), this._partialBytes = 0, this._R = 3774873600;
};
ie.gcm.prototype.start = function(e) {
  if (!("iv" in e))
    throw new Error("Invalid IV parameter.");
  var t = ze.util.createBuffer(e.iv);
  this._cipherLength = 0;
  var a;
  if ("additionalData" in e ? a = ze.util.createBuffer(e.additionalData) : a = ze.util.createBuffer(), "tagLength" in e ? this._tagLength = e.tagLength : this._tagLength = 128, this._tag = null, e.decrypt && (this._tag = ze.util.createBuffer(e.tag).getBytes(), this._tag.length !== this._tagLength / 8))
    throw new Error("Authentication tag does not match tag length.");
  this._hashBlock = new Array(this._ints), this.tag = null, this._hashSubkey = new Array(this._ints), this.cipher.encrypt([0, 0, 0, 0], this._hashSubkey), this.componentBits = 4, this._m = this.generateHashTable(this._hashSubkey, this.componentBits);
  var r = t.length();
  if (r === 12)
    this._j0 = [t.getInt32(), t.getInt32(), t.getInt32(), 1];
  else {
    for (this._j0 = [0, 0, 0, 0]; t.length() > 0; )
      this._j0 = this.ghash(
        this._hashSubkey,
        this._j0,
        [t.getInt32(), t.getInt32(), t.getInt32(), t.getInt32()]
      );
    this._j0 = this.ghash(
      this._hashSubkey,
      this._j0,
      [0, 0].concat(ua(r * 8))
    );
  }
  this._inBlock = this._j0.slice(0), Qr(this._inBlock), this._partialBytes = 0, a = ze.util.createBuffer(a), this._aDataLength = ua(a.length() * 8);
  var i = a.length() % this.blockSize;
  for (i && a.fillWithByte(0, this.blockSize - i), this._s = [0, 0, 0, 0]; a.length() > 0; )
    this._s = this.ghash(this._hashSubkey, this._s, [
      a.getInt32(),
      a.getInt32(),
      a.getInt32(),
      a.getInt32()
    ]);
};
ie.gcm.prototype.encrypt = function(e, t, a) {
  var r = e.length();
  if (r === 0)
    return !0;
  if (this.cipher.encrypt(this._inBlock, this._outBlock), this._partialBytes === 0 && r >= this.blockSize) {
    for (var i = 0; i < this._ints; ++i)
      t.putInt32(this._outBlock[i] ^= e.getInt32());
    this._cipherLength += this.blockSize;
  } else {
    var n = (this.blockSize - r) % this.blockSize;
    n > 0 && (n = this.blockSize - n), this._partialOutput.clear();
    for (var i = 0; i < this._ints; ++i)
      this._partialOutput.putInt32(e.getInt32() ^ this._outBlock[i]);
    if (n <= 0 || a) {
      if (a) {
        var s = r % this.blockSize;
        this._cipherLength += s, this._partialOutput.truncate(this.blockSize - s);
      } else
        this._cipherLength += this.blockSize;
      for (var i = 0; i < this._ints; ++i)
        this._outBlock[i] = this._partialOutput.getInt32();
      this._partialOutput.read -= this.blockSize;
    }
    if (this._partialBytes > 0 && this._partialOutput.getBytes(this._partialBytes), n > 0 && !a)
      return e.read -= this.blockSize, t.putBytes(this._partialOutput.getBytes(
        n - this._partialBytes
      )), this._partialBytes = n, !0;
    t.putBytes(this._partialOutput.getBytes(
      r - this._partialBytes
    )), this._partialBytes = 0;
  }
  this._s = this.ghash(this._hashSubkey, this._s, this._outBlock), Qr(this._inBlock);
};
ie.gcm.prototype.decrypt = function(e, t, a) {
  var r = e.length();
  if (r < this.blockSize && !(a && r > 0))
    return !0;
  this.cipher.encrypt(this._inBlock, this._outBlock), Qr(this._inBlock), this._hashBlock[0] = e.getInt32(), this._hashBlock[1] = e.getInt32(), this._hashBlock[2] = e.getInt32(), this._hashBlock[3] = e.getInt32(), this._s = this.ghash(this._hashSubkey, this._s, this._hashBlock);
  for (var i = 0; i < this._ints; ++i)
    t.putInt32(this._outBlock[i] ^ this._hashBlock[i]);
  r < this.blockSize ? this._cipherLength += r % this.blockSize : this._cipherLength += this.blockSize;
};
ie.gcm.prototype.afterFinish = function(e, t) {
  var a = !0;
  t.decrypt && t.overflow && e.truncate(this.blockSize - t.overflow), this.tag = ze.util.createBuffer();
  var r = this._aDataLength.concat(ua(this._cipherLength * 8));
  this._s = this.ghash(this._hashSubkey, this._s, r);
  var i = [];
  this.cipher.encrypt(this._j0, i);
  for (var n = 0; n < this._ints; ++n)
    this.tag.putInt32(this._s[n] ^ i[n]);
  return this.tag.truncate(this.tag.length() % (this._tagLength / 8)), t.decrypt && this.tag.bytes() !== this._tag && (a = !1), a;
};
ie.gcm.prototype.multiply = function(e, t) {
  for (var a = [0, 0, 0, 0], r = t.slice(0), i = 0; i < 128; ++i) {
    var n = e[i / 32 | 0] & 1 << 31 - i % 32;
    n && (a[0] ^= r[0], a[1] ^= r[1], a[2] ^= r[2], a[3] ^= r[3]), this.pow(r, r);
  }
  return a;
};
ie.gcm.prototype.pow = function(e, t) {
  for (var a = e[3] & 1, r = 3; r > 0; --r)
    t[r] = e[r] >>> 1 | (e[r - 1] & 1) << 31;
  t[0] = e[0] >>> 1, a && (t[0] ^= this._R);
};
ie.gcm.prototype.tableMultiply = function(e) {
  for (var t = [0, 0, 0, 0], a = 0; a < 32; ++a) {
    var r = a / 8 | 0, i = e[r] >>> (7 - a % 8) * 4 & 15, n = this._m[a][i];
    t[0] ^= n[0], t[1] ^= n[1], t[2] ^= n[2], t[3] ^= n[3];
  }
  return t;
};
ie.gcm.prototype.ghash = function(e, t, a) {
  return t[0] ^= a[0], t[1] ^= a[1], t[2] ^= a[2], t[3] ^= a[3], this.tableMultiply(t);
};
ie.gcm.prototype.generateHashTable = function(e, t) {
  for (var a = 8 / t, r = 4 * a, i = 16 * a, n = new Array(i), s = 0; s < i; ++s) {
    var o = [0, 0, 0, 0], l = s / r | 0, f = (r - 1 - s % r) * t;
    o[l] = 1 << t - 1 << f, n[s] = this.generateSubHashTable(this.multiply(o, e), t);
  }
  return n;
};
ie.gcm.prototype.generateSubHashTable = function(e, t) {
  var a = 1 << t, r = a >>> 1, i = new Array(a);
  i[r] = e.slice(0);
  for (var n = r >>> 1; n > 0; )
    this.pow(i[2 * n], i[n] = []), n >>= 1;
  for (n = 2; n < r; ) {
    for (var s = 1; s < n; ++s) {
      var o = i[n], l = i[s];
      i[n + s] = [
        o[0] ^ l[0],
        o[1] ^ l[1],
        o[2] ^ l[2],
        o[3] ^ l[3]
      ];
    }
    n *= 2;
  }
  for (i[0] = [0, 0, 0, 0], n = r + 1; n < a; ++n) {
    var f = i[n ^ r];
    i[n] = [e[0] ^ f[0], e[1] ^ f[1], e[2] ^ f[2], e[3] ^ f[3]];
  }
  return i;
};
function qr(e, t) {
  if (typeof e == "string" && (e = ze.util.createBuffer(e)), ze.util.isArray(e) && e.length > 4) {
    var a = e;
    e = ze.util.createBuffer();
    for (var r = 0; r < a.length; ++r)
      e.putByte(a[r]);
  }
  if (e.length() < t)
    throw new Error(
      "Invalid IV length; got " + e.length() + " bytes and expected " + t + " bytes."
    );
  if (!ze.util.isArray(e)) {
    for (var i = [], n = t / 4, r = 0; r < n; ++r)
      i.push(e.getInt32());
    e = i;
  }
  return e;
}
function Qr(e) {
  e[e.length - 1] = e[e.length - 1] + 1 & 4294967295;
}
function ua(e) {
  return [e / 4294967296 | 0, e & 4294967295];
}
var Ce = ee;
Ce.aes = Ce.aes || {};
Ce.aes.startEncrypting = function(e, t, a, r) {
  var i = zr({
    key: e,
    output: a,
    decrypt: !1,
    mode: r
  });
  return i.start(t), i;
};
Ce.aes.createEncryptionCipher = function(e, t) {
  return zr({
    key: e,
    output: null,
    decrypt: !1,
    mode: t
  });
};
Ce.aes.startDecrypting = function(e, t, a, r) {
  var i = zr({
    key: e,
    output: a,
    decrypt: !0,
    mode: r
  });
  return i.start(t), i;
};
Ce.aes.createDecryptionCipher = function(e, t) {
  return zr({
    key: e,
    output: null,
    decrypt: !0,
    mode: t
  });
};
Ce.aes.Algorithm = function(e, t) {
  La || Ii();
  var a = this;
  a.name = e, a.mode = new t({
    blockSize: 16,
    cipher: {
      encrypt: function(r, i) {
        return la(a._w, r, i, !1);
      },
      decrypt: function(r, i) {
        return la(a._w, r, i, !0);
      }
    }
  }), a._init = !1;
};
Ce.aes.Algorithm.prototype.initialize = function(e) {
  if (!this._init) {
    var t = e.key, a;
    if (typeof t == "string" && (t.length === 16 || t.length === 24 || t.length === 32))
      t = Ce.util.createBuffer(t);
    else if (Ce.util.isArray(t) && (t.length === 16 || t.length === 24 || t.length === 32)) {
      a = t, t = Ce.util.createBuffer();
      for (var r = 0; r < a.length; ++r)
        t.putByte(a[r]);
    }
    if (!Ce.util.isArray(t)) {
      a = t, t = [];
      var i = a.length();
      if (i === 16 || i === 24 || i === 32) {
        i = i >>> 2;
        for (var r = 0; r < i; ++r)
          t.push(a.getInt32());
      }
    }
    if (!Ce.util.isArray(t) || !(t.length === 4 || t.length === 6 || t.length === 8))
      throw new Error("Invalid key parameter.");
    var n = this.mode.name, s = ["CFB", "OFB", "CTR", "GCM"].indexOf(n) !== -1;
    this._w = Bi(t, e.decrypt && !s), this._init = !0;
  }
};
Ce.aes._expandKey = function(e, t) {
  return La || Ii(), Bi(e, t);
};
Ce.aes._updateBlock = la;
ur("AES-ECB", Ce.cipher.modes.ecb);
ur("AES-CBC", Ce.cipher.modes.cbc);
ur("AES-CFB", Ce.cipher.modes.cfb);
ur("AES-OFB", Ce.cipher.modes.ofb);
ur("AES-CTR", Ce.cipher.modes.ctr);
ur("AES-GCM", Ce.cipher.modes.gcm);
function ur(e, t) {
  var a = function() {
    return new Ce.aes.Algorithm(e, t);
  };
  Ce.cipher.registerAlgorithm(e, a);
}
var La = !1, er = 4, Ze, fa, Ti, Xt, yt;
function Ii() {
  La = !0, Ti = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54];
  for (var e = new Array(256), t = 0; t < 128; ++t)
    e[t] = t << 1, e[t + 128] = t + 128 << 1 ^ 283;
  Ze = new Array(256), fa = new Array(256), Xt = new Array(4), yt = new Array(4);
  for (var t = 0; t < 4; ++t)
    Xt[t] = new Array(256), yt[t] = new Array(256);
  for (var a = 0, r = 0, i, n, s, o, l, f, u, t = 0; t < 256; ++t) {
    o = r ^ r << 1 ^ r << 2 ^ r << 3 ^ r << 4, o = o >> 8 ^ o & 255 ^ 99, Ze[a] = o, fa[o] = a, l = e[o], i = e[a], n = e[i], s = e[n], f = l << 24 ^ // 2
    o << 16 ^ // 1
    o << 8 ^ // 1
    (o ^ l), u = (i ^ n ^ s) << 24 ^ // E (14)
    (a ^ s) << 16 ^ // 9
    (a ^ n ^ s) << 8 ^ // D (13)
    (a ^ i ^ s);
    for (var p = 0; p < 4; ++p)
      Xt[p][a] = f, yt[p][o] = u, f = f << 24 | f >>> 8, u = u << 24 | u >>> 8;
    a === 0 ? a = r = 1 : (a = i ^ e[e[e[i ^ s]]], r ^= e[e[r]]);
  }
}
function Bi(e, t) {
  for (var a = e.slice(0), r, i = 1, n = a.length, s = n + 6 + 1, o = er * s, l = n; l < o; ++l)
    r = a[l - 1], l % n === 0 ? (r = Ze[r >>> 16 & 255] << 24 ^ Ze[r >>> 8 & 255] << 16 ^ Ze[r & 255] << 8 ^ Ze[r >>> 24] ^ Ti[i] << 24, i++) : n > 6 && l % n === 4 && (r = Ze[r >>> 24] << 24 ^ Ze[r >>> 16 & 255] << 16 ^ Ze[r >>> 8 & 255] << 8 ^ Ze[r & 255]), a[l] = a[l - n] ^ r;
  if (t) {
    var f, u = yt[0], p = yt[1], m = yt[2], S = yt[3], C = a.slice(0);
    o = a.length;
    for (var l = 0, A = o - er; l < o; l += er, A -= er)
      if (l === 0 || l === o - er)
        C[l] = a[A], C[l + 1] = a[A + 3], C[l + 2] = a[A + 2], C[l + 3] = a[A + 1];
      else
        for (var b = 0; b < er; ++b)
          f = a[A + b], C[l + (3 & -b)] = u[Ze[f >>> 24]] ^ p[Ze[f >>> 16 & 255]] ^ m[Ze[f >>> 8 & 255]] ^ S[Ze[f & 255]];
    a = C;
  }
  return a;
}
function la(e, t, a, r) {
  var i = e.length / 4 - 1, n, s, o, l, f;
  r ? (n = yt[0], s = yt[1], o = yt[2], l = yt[3], f = fa) : (n = Xt[0], s = Xt[1], o = Xt[2], l = Xt[3], f = Ze);
  var u, p, m, S, C, A, b;
  u = t[0] ^ e[0], p = t[r ? 3 : 1] ^ e[1], m = t[2] ^ e[2], S = t[r ? 1 : 3] ^ e[3];
  for (var _ = 3, U = 1; U < i; ++U)
    C = n[u >>> 24] ^ s[p >>> 16 & 255] ^ o[m >>> 8 & 255] ^ l[S & 255] ^ e[++_], A = n[p >>> 24] ^ s[m >>> 16 & 255] ^ o[S >>> 8 & 255] ^ l[u & 255] ^ e[++_], b = n[m >>> 24] ^ s[S >>> 16 & 255] ^ o[u >>> 8 & 255] ^ l[p & 255] ^ e[++_], S = n[S >>> 24] ^ s[u >>> 16 & 255] ^ o[p >>> 8 & 255] ^ l[m & 255] ^ e[++_], u = C, p = A, m = b;
  a[0] = f[u >>> 24] << 24 ^ f[p >>> 16 & 255] << 16 ^ f[m >>> 8 & 255] << 8 ^ f[S & 255] ^ e[++_], a[r ? 3 : 1] = f[p >>> 24] << 24 ^ f[m >>> 16 & 255] << 16 ^ f[S >>> 8 & 255] << 8 ^ f[u & 255] ^ e[++_], a[2] = f[m >>> 24] << 24 ^ f[S >>> 16 & 255] << 16 ^ f[u >>> 8 & 255] << 8 ^ f[p & 255] ^ e[++_], a[r ? 1 : 3] = f[S >>> 24] << 24 ^ f[u >>> 16 & 255] << 16 ^ f[p >>> 8 & 255] << 8 ^ f[m & 255] ^ e[++_];
}
function zr(e) {
  e = e || {};
  var t = (e.mode || "CBC").toUpperCase(), a = "AES-" + t, r;
  e.decrypt ? r = Ce.cipher.createDecipher(a, e.key) : r = Ce.cipher.createCipher(a, e.key);
  var i = r.start;
  return r.start = function(n, s) {
    var o = null;
    s instanceof Ce.util.ByteBuffer && (o = s, s = {}), s = s || {}, s.output = o, s.iv = n, i.call(r, s);
  }, r;
}
var vr = ee;
vr.pki = vr.pki || {};
var ca = vr.pki.oids = vr.oids = vr.oids || {};
function V(e, t) {
  ca[e] = t, ca[t] = e;
}
function pe(e, t) {
  ca[e] = t;
}
V("1.2.840.113549.1.1.1", "rsaEncryption");
V("1.2.840.113549.1.1.4", "md5WithRSAEncryption");
V("1.2.840.113549.1.1.5", "sha1WithRSAEncryption");
V("1.2.840.113549.1.1.7", "RSAES-OAEP");
V("1.2.840.113549.1.1.8", "mgf1");
V("1.2.840.113549.1.1.9", "pSpecified");
V("1.2.840.113549.1.1.10", "RSASSA-PSS");
V("1.2.840.113549.1.1.11", "sha256WithRSAEncryption");
V("1.2.840.113549.1.1.12", "sha384WithRSAEncryption");
V("1.2.840.113549.1.1.13", "sha512WithRSAEncryption");
V("1.3.101.112", "EdDSA25519");
V("1.2.840.10040.4.3", "dsa-with-sha1");
V("1.3.14.3.2.7", "desCBC");
V("1.3.14.3.2.26", "sha1");
V("1.3.14.3.2.29", "sha1WithRSASignature");
V("2.16.840.1.101.3.4.2.1", "sha256");
V("2.16.840.1.101.3.4.2.2", "sha384");
V("2.16.840.1.101.3.4.2.3", "sha512");
V("2.16.840.1.101.3.4.2.4", "sha224");
V("2.16.840.1.101.3.4.2.5", "sha512-224");
V("2.16.840.1.101.3.4.2.6", "sha512-256");
V("1.2.840.113549.2.2", "md2");
V("1.2.840.113549.2.5", "md5");
V("1.2.840.113549.1.7.1", "data");
V("1.2.840.113549.1.7.2", "signedData");
V("1.2.840.113549.1.7.3", "envelopedData");
V("1.2.840.113549.1.7.4", "signedAndEnvelopedData");
V("1.2.840.113549.1.7.5", "digestedData");
V("1.2.840.113549.1.7.6", "encryptedData");
V("1.2.840.113549.1.9.1", "emailAddress");
V("1.2.840.113549.1.9.2", "unstructuredName");
V("1.2.840.113549.1.9.3", "contentType");
V("1.2.840.113549.1.9.4", "messageDigest");
V("1.2.840.113549.1.9.5", "signingTime");
V("1.2.840.113549.1.9.6", "counterSignature");
V("1.2.840.113549.1.9.7", "challengePassword");
V("1.2.840.113549.1.9.8", "unstructuredAddress");
V("1.2.840.113549.1.9.14", "extensionRequest");
V("1.2.840.113549.1.9.20", "friendlyName");
V("1.2.840.113549.1.9.21", "localKeyId");
V("1.2.840.113549.1.9.22.1", "x509Certificate");
V("1.2.840.113549.1.12.10.1.1", "keyBag");
V("1.2.840.113549.1.12.10.1.2", "pkcs8ShroudedKeyBag");
V("1.2.840.113549.1.12.10.1.3", "certBag");
V("1.2.840.113549.1.12.10.1.4", "crlBag");
V("1.2.840.113549.1.12.10.1.5", "secretBag");
V("1.2.840.113549.1.12.10.1.6", "safeContentsBag");
V("1.2.840.113549.1.5.13", "pkcs5PBES2");
V("1.2.840.113549.1.5.12", "pkcs5PBKDF2");
V("1.2.840.113549.1.12.1.1", "pbeWithSHAAnd128BitRC4");
V("1.2.840.113549.1.12.1.2", "pbeWithSHAAnd40BitRC4");
V("1.2.840.113549.1.12.1.3", "pbeWithSHAAnd3-KeyTripleDES-CBC");
V("1.2.840.113549.1.12.1.4", "pbeWithSHAAnd2-KeyTripleDES-CBC");
V("1.2.840.113549.1.12.1.5", "pbeWithSHAAnd128BitRC2-CBC");
V("1.2.840.113549.1.12.1.6", "pbewithSHAAnd40BitRC2-CBC");
V("1.2.840.113549.2.7", "hmacWithSHA1");
V("1.2.840.113549.2.8", "hmacWithSHA224");
V("1.2.840.113549.2.9", "hmacWithSHA256");
V("1.2.840.113549.2.10", "hmacWithSHA384");
V("1.2.840.113549.2.11", "hmacWithSHA512");
V("1.2.840.113549.3.7", "des-EDE3-CBC");
V("2.16.840.1.101.3.4.1.2", "aes128-CBC");
V("2.16.840.1.101.3.4.1.22", "aes192-CBC");
V("2.16.840.1.101.3.4.1.42", "aes256-CBC");
V("2.5.4.3", "commonName");
V("2.5.4.4", "surname");
V("2.5.4.5", "serialNumber");
V("2.5.4.6", "countryName");
V("2.5.4.7", "localityName");
V("2.5.4.8", "stateOrProvinceName");
V("2.5.4.9", "streetAddress");
V("2.5.4.10", "organizationName");
V("2.5.4.11", "organizationalUnitName");
V("2.5.4.12", "title");
V("2.5.4.13", "description");
V("2.5.4.15", "businessCategory");
V("2.5.4.17", "postalCode");
V("2.5.4.42", "givenName");
V("1.3.6.1.4.1.311.60.2.1.2", "jurisdictionOfIncorporationStateOrProvinceName");
V("1.3.6.1.4.1.311.60.2.1.3", "jurisdictionOfIncorporationCountryName");
V("2.16.840.1.113730.1.1", "nsCertType");
V("2.16.840.1.113730.1.13", "nsComment");
pe("2.5.29.1", "authorityKeyIdentifier");
pe("2.5.29.2", "keyAttributes");
pe("2.5.29.3", "certificatePolicies");
pe("2.5.29.4", "keyUsageRestriction");
pe("2.5.29.5", "policyMapping");
pe("2.5.29.6", "subtreesConstraint");
pe("2.5.29.7", "subjectAltName");
pe("2.5.29.8", "issuerAltName");
pe("2.5.29.9", "subjectDirectoryAttributes");
pe("2.5.29.10", "basicConstraints");
pe("2.5.29.11", "nameConstraints");
pe("2.5.29.12", "policyConstraints");
pe("2.5.29.13", "basicConstraints");
V("2.5.29.14", "subjectKeyIdentifier");
V("2.5.29.15", "keyUsage");
pe("2.5.29.16", "privateKeyUsagePeriod");
V("2.5.29.17", "subjectAltName");
V("2.5.29.18", "issuerAltName");
V("2.5.29.19", "basicConstraints");
pe("2.5.29.20", "cRLNumber");
pe("2.5.29.21", "cRLReason");
pe("2.5.29.22", "expirationDate");
pe("2.5.29.23", "instructionCode");
pe("2.5.29.24", "invalidityDate");
pe("2.5.29.25", "cRLDistributionPoints");
pe("2.5.29.26", "issuingDistributionPoint");
pe("2.5.29.27", "deltaCRLIndicator");
pe("2.5.29.28", "issuingDistributionPoint");
pe("2.5.29.29", "certificateIssuer");
pe("2.5.29.30", "nameConstraints");
V("2.5.29.31", "cRLDistributionPoints");
V("2.5.29.32", "certificatePolicies");
pe("2.5.29.33", "policyMappings");
pe("2.5.29.34", "policyConstraints");
V("2.5.29.35", "authorityKeyIdentifier");
pe("2.5.29.36", "policyConstraints");
V("2.5.29.37", "extKeyUsage");
pe("2.5.29.46", "freshestCRL");
pe("2.5.29.54", "inhibitAnyPolicy");
V("1.3.6.1.4.1.11129.2.4.2", "timestampList");
V("1.3.6.1.5.5.7.1.1", "authorityInfoAccess");
V("1.3.6.1.5.5.7.3.1", "serverAuth");
V("1.3.6.1.5.5.7.3.2", "clientAuth");
V("1.3.6.1.5.5.7.3.3", "codeSigning");
V("1.3.6.1.5.5.7.3.4", "emailProtection");
V("1.3.6.1.5.5.7.3.8", "timeStamping");
var xe = ee, H = xe.asn1 = xe.asn1 || {};
H.Class = {
  UNIVERSAL: 0,
  APPLICATION: 64,
  CONTEXT_SPECIFIC: 128,
  PRIVATE: 192
};
H.Type = {
  NONE: 0,
  BOOLEAN: 1,
  INTEGER: 2,
  BITSTRING: 3,
  OCTETSTRING: 4,
  NULL: 5,
  OID: 6,
  ODESC: 7,
  EXTERNAL: 8,
  REAL: 9,
  ENUMERATED: 10,
  EMBEDDED: 11,
  UTF8: 12,
  ROID: 13,
  SEQUENCE: 16,
  SET: 17,
  PRINTABLESTRING: 19,
  IA5STRING: 22,
  UTCTIME: 23,
  GENERALIZEDTIME: 24,
  BMPSTRING: 30
};
H.maxDepth = 256;
H.create = function(e, t, a, r, i) {
  if (xe.util.isArray(r)) {
    for (var n = [], s = 0; s < r.length; ++s)
      r[s] !== void 0 && n.push(r[s]);
    r = n;
  }
  var o = {
    tagClass: e,
    type: t,
    constructed: a,
    composed: a || xe.util.isArray(r),
    value: r
  };
  return i && "bitStringContents" in i && (o.bitStringContents = i.bitStringContents, o.original = H.copy(o)), o;
};
H.copy = function(e, t) {
  var a;
  if (xe.util.isArray(e)) {
    a = [];
    for (var r = 0; r < e.length; ++r)
      a.push(H.copy(e[r], t));
    return a;
  }
  return typeof e == "string" ? e : (a = {
    tagClass: e.tagClass,
    type: e.type,
    constructed: e.constructed,
    composed: e.composed,
    value: H.copy(e.value, t)
  }, t && !t.excludeBitStringContents && (a.bitStringContents = e.bitStringContents), a);
};
H.equals = function(e, t, a) {
  if (xe.util.isArray(e)) {
    if (!xe.util.isArray(t) || e.length !== t.length)
      return !1;
    for (var r = 0; r < e.length; ++r)
      if (!H.equals(e[r], t[r]))
        return !1;
    return !0;
  }
  if (typeof e != typeof t)
    return !1;
  if (typeof e == "string")
    return e === t;
  var i = e.tagClass === t.tagClass && e.type === t.type && e.constructed === t.constructed && e.composed === t.composed && H.equals(e.value, t.value);
  return a && a.includeBitStringContents && (i = i && e.bitStringContents === t.bitStringContents), i;
};
H.getBerValueLength = function(e) {
  var t = e.getByte();
  if (t !== 128) {
    var a, r = t & 128;
    return r ? a = e.getInt((t & 127) << 3) : a = t, a;
  }
};
function yr(e, t, a) {
  if (a > t) {
    var r = new Error("Too few bytes to parse DER.");
    throw r.available = e.length(), r.remaining = t, r.requested = a, r;
  }
}
var Kn = function(e, t) {
  var a = e.getByte();
  if (t--, a !== 128) {
    var r, i = a & 128;
    if (!i)
      r = a;
    else {
      var n = a & 127;
      yr(e, t, n), r = e.getInt(n << 3);
    }
    if (r < 0)
      throw new Error("Negative length: " + r);
    return r;
  }
};
H.fromDer = function(e, t) {
  t === void 0 && (t = {
    strict: !0,
    parseAllBytes: !0,
    decodeBitStrings: !0
  }), typeof t == "boolean" && (t = {
    strict: t,
    parseAllBytes: !0,
    decodeBitStrings: !0
  }), "strict" in t || (t.strict = !0), "parseAllBytes" in t || (t.parseAllBytes = !0), "decodeBitStrings" in t || (t.decodeBitStrings = !0), "maxDepth" in t || (t.maxDepth = H.maxDepth), typeof e == "string" && (e = xe.util.createBuffer(e));
  var a = e.length(), r = _r(e, e.length(), 0, t);
  if (t.parseAllBytes && e.length() !== 0) {
    var i = new Error("Unparsed DER bytes remain after ASN.1 parsing.");
    throw i.byteCount = a, i.remaining = e.length(), i;
  }
  return r;
};
function _r(e, t, a, r) {
  if (a >= r.maxDepth)
    throw new Error("ASN.1 parsing error: Max depth exceeded.");
  var i;
  yr(e, t, 2);
  var n = e.getByte();
  t--;
  var s = n & 192, o = n & 31;
  i = e.length();
  var l = Kn(e, t);
  if (t -= i - e.length(), l !== void 0 && l > t) {
    if (r.strict) {
      var f = new Error("Too few bytes to read ASN.1 value.");
      throw f.available = e.length(), f.remaining = t, f.requested = l, f;
    }
    l = t;
  }
  var u, p, m = (n & 32) === 32;
  if (m)
    if (u = [], l === void 0)
      for (; ; ) {
        if (yr(e, t, 2), e.bytes(2) === "\0\0") {
          e.getBytes(2), t -= 2;
          break;
        }
        i = e.length(), u.push(_r(e, t, a + 1, r)), t -= i - e.length();
      }
    else
      for (; l > 0; )
        i = e.length(), u.push(_r(e, l, a + 1, r)), t -= i - e.length(), l -= i - e.length();
  if (u === void 0 && s === H.Class.UNIVERSAL && o === H.Type.BITSTRING && (p = e.bytes(l)), u === void 0 && r.decodeBitStrings && s === H.Class.UNIVERSAL && // FIXME: OCTET STRINGs not yet supported here
  // .. other parts of forge expect to decode OCTET STRINGs manually
  o === H.Type.BITSTRING && l > 1) {
    var S = e.read, C = t, A = 0;
    if (o === H.Type.BITSTRING && (yr(e, t, 1), A = e.getByte(), t--), A === 0)
      try {
        i = e.length();
        var b = {
          // enforce strict mode to avoid parsing ASN.1 from plain data
          strict: !0,
          decodeBitStrings: !0
        }, _ = _r(e, t, a + 1, b), U = i - e.length();
        t -= U, o == H.Type.BITSTRING && U++;
        var D = _.tagClass;
        U === l && (D === H.Class.UNIVERSAL || D === H.Class.CONTEXT_SPECIFIC) && (u = [_]);
      } catch {
      }
    u === void 0 && (e.read = S, t = C);
  }
  if (u === void 0) {
    if (l === void 0) {
      if (r.strict)
        throw new Error("Non-constructed ASN.1 object of indefinite length.");
      l = t;
    }
    if (o === H.Type.BMPSTRING)
      for (u = ""; l > 0; l -= 2)
        yr(e, t, 2), u += String.fromCharCode(e.getInt16()), t -= 2;
    else
      u = e.getBytes(l), t -= l;
  }
  var G = p === void 0 ? null : {
    bitStringContents: p
  };
  return H.create(s, o, m, u, G);
}
H.toDer = function(e) {
  var t = xe.util.createBuffer(), a = e.tagClass | e.type, r = xe.util.createBuffer(), i = !1;
  if ("bitStringContents" in e && (i = !0, e.original && (i = H.equals(e, e.original))), i)
    r.putBytes(e.bitStringContents);
  else if (e.composed) {
    e.constructed ? a |= 32 : r.putByte(0);
    for (var n = 0; n < e.value.length; ++n)
      e.value[n] !== void 0 && r.putBuffer(H.toDer(e.value[n]));
  } else if (e.type === H.Type.BMPSTRING)
    for (var n = 0; n < e.value.length; ++n)
      r.putInt16(e.value.charCodeAt(n));
  else
    e.type === H.Type.INTEGER && e.value.length > 1 && // leading 0x00 for positive integer
    (e.value.charCodeAt(0) === 0 && !(e.value.charCodeAt(1) & 128) || // leading 0xFF for negative integer
    e.value.charCodeAt(0) === 255 && (e.value.charCodeAt(1) & 128) === 128) ? r.putBytes(e.value.substr(1)) : r.putBytes(e.value);
  if (t.putByte(a), r.length() <= 127)
    t.putByte(r.length() & 127);
  else {
    var s = r.length(), o = "";
    do
      o += String.fromCharCode(s & 255), s = s >>> 8;
    while (s > 0);
    t.putByte(o.length | 128);
    for (var n = o.length - 1; n >= 0; --n)
      t.putByte(o.charCodeAt(n));
  }
  return t.putBuffer(r), t;
};
H.oidToDer = function(e) {
  var t = e.split("."), a = xe.util.createBuffer();
  a.putByte(40 * parseInt(t[0], 10) + parseInt(t[1], 10));
  for (var r, i, n, s, o = 2; o < t.length; ++o) {
    if (r = !0, i = [], n = parseInt(t[o], 10), n > 4294967295)
      throw new Error("OID value too large; max is 32-bits.");
    do
      s = n & 127, n = n >>> 7, r || (s |= 128), i.push(s), r = !1;
    while (n > 0);
    for (var l = i.length - 1; l >= 0; --l)
      a.putByte(i[l]);
  }
  return a;
};
H.derToOid = function(e) {
  var t;
  typeof e == "string" && (e = xe.util.createBuffer(e));
  var a = e.getByte();
  t = Math.floor(a / 40) + "." + a % 40;
  for (var r = 0; e.length() > 0; ) {
    if (r > 70368744177663)
      throw new Error("OID value too large; max is 53-bits.");
    a = e.getByte(), r = r * 128, a & 128 ? r += a & 127 : (t += "." + (r + a), r = 0);
  }
  return t;
};
H.utcTimeToDate = function(e) {
  var t = /* @__PURE__ */ new Date(), a = parseInt(e.substr(0, 2), 10);
  a = a >= 50 ? 1900 + a : 2e3 + a;
  var r = parseInt(e.substr(2, 2), 10) - 1, i = parseInt(e.substr(4, 2), 10), n = parseInt(e.substr(6, 2), 10), s = parseInt(e.substr(8, 2), 10), o = 0;
  if (e.length > 11) {
    var l = e.charAt(10), f = 10;
    l !== "+" && l !== "-" && (o = parseInt(e.substr(10, 2), 10), f += 2);
  }
  if (t.setUTCFullYear(a, r, i), t.setUTCHours(n, s, o, 0), f && (l = e.charAt(f), l === "+" || l === "-")) {
    var u = parseInt(e.substr(f + 1, 2), 10), p = parseInt(e.substr(f + 4, 2), 10), m = u * 60 + p;
    m *= 6e4, l === "+" ? t.setTime(+t - m) : t.setTime(+t + m);
  }
  return t;
};
H.generalizedTimeToDate = function(e) {
  var t = /* @__PURE__ */ new Date(), a = parseInt(e.substr(0, 4), 10), r = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10), n = parseInt(e.substr(8, 2), 10), s = parseInt(e.substr(10, 2), 10), o = parseInt(e.substr(12, 2), 10), l = 0, f = 0, u = !1;
  e.charAt(e.length - 1) === "Z" && (u = !0);
  var p = e.length - 5, m = e.charAt(p);
  if (m === "+" || m === "-") {
    var S = parseInt(e.substr(p + 1, 2), 10), C = parseInt(e.substr(p + 4, 2), 10);
    f = S * 60 + C, f *= 6e4, m === "+" && (f *= -1), u = !0;
  }
  return e.charAt(14) === "." && (l = parseFloat(e.substr(14), 10) * 1e3), u ? (t.setUTCFullYear(a, r, i), t.setUTCHours(n, s, o, l), t.setTime(+t + f)) : (t.setFullYear(a, r, i), t.setHours(n, s, o, l)), t;
};
H.dateToUtcTime = function(e) {
  if (typeof e == "string")
    return e;
  var t = "", a = [];
  a.push(("" + e.getUTCFullYear()).substr(2)), a.push("" + (e.getUTCMonth() + 1)), a.push("" + e.getUTCDate()), a.push("" + e.getUTCHours()), a.push("" + e.getUTCMinutes()), a.push("" + e.getUTCSeconds());
  for (var r = 0; r < a.length; ++r)
    a[r].length < 2 && (t += "0"), t += a[r];
  return t += "Z", t;
};
H.dateToGeneralizedTime = function(e) {
  if (typeof e == "string")
    return e;
  var t = "", a = [];
  a.push("" + e.getUTCFullYear()), a.push("" + (e.getUTCMonth() + 1)), a.push("" + e.getUTCDate()), a.push("" + e.getUTCHours()), a.push("" + e.getUTCMinutes()), a.push("" + e.getUTCSeconds());
  for (var r = 0; r < a.length; ++r)
    a[r].length < 2 && (t += "0"), t += a[r];
  return t += "Z", t;
};
H.integerToDer = function(e) {
  var t = xe.util.createBuffer();
  if (e >= -128 && e < 128)
    return t.putSignedInt(e, 8);
  if (e >= -32768 && e < 32768)
    return t.putSignedInt(e, 16);
  if (e >= -8388608 && e < 8388608)
    return t.putSignedInt(e, 24);
  if (e >= -2147483648 && e < 2147483648)
    return t.putSignedInt(e, 32);
  var a = new Error("Integer too large; max is 32-bits.");
  throw a.integer = e, a;
};
H.derToInteger = function(e) {
  typeof e == "string" && (e = xe.util.createBuffer(e));
  var t = e.length() * 8;
  if (t > 32)
    throw new Error("Integer too large; max is 32-bits.");
  return e.getSignedInt(t);
};
H.validate = function(e, t, a, r) {
  var i = !1;
  if ((e.tagClass === t.tagClass || typeof t.tagClass > "u") && (e.type === t.type || typeof t.type > "u"))
    if (e.constructed === t.constructed || typeof t.constructed > "u") {
      if (i = !0, t.value && xe.util.isArray(t.value))
        for (var n = 0, s = 0; i && s < t.value.length; ++s) {
          var o = t.value[s];
          i = !!o.optional;
          var l = e.value[n];
          if (!l) {
            o.optional || (i = !1, r && r.push("[" + t.name + '] Missing required element. Expected tag class "' + o.tagClass + '", type "' + o.type + '"'));
            continue;
          }
          var f = typeof o.tagClass < "u" && typeof o.type < "u";
          if (f && (l.tagClass !== o.tagClass || l.type !== o.type))
            if (o.optional) {
              i = !0;
              continue;
            } else {
              i = !1, r && r.push("[" + t.name + "] Tag mismatch. Expected (" + o.tagClass + "," + o.type + "), got (" + l.tagClass + "," + l.type + ")");
              break;
            }
          var u = H.validate(l, o, a, r);
          if (u)
            ++n, i = !0;
          else if (o.optional)
            i = !0;
          else {
            i = !1;
            break;
          }
        }
      if (i && a && (t.capture && (a[t.capture] = e.value), t.captureAsn1 && (a[t.captureAsn1] = e), t.captureBitStringContents && "bitStringContents" in e && (a[t.captureBitStringContents] = e.bitStringContents), t.captureBitStringValue && "bitStringContents" in e))
        if (e.bitStringContents.length < 2)
          a[t.captureBitStringValue] = "";
        else {
          var p = e.bitStringContents.charCodeAt(0);
          if (p !== 0)
            throw new Error(
              "captureBitStringValue only supported for zero unused bits"
            );
          a[t.captureBitStringValue] = e.bitStringContents.slice(1);
        }
    } else r && r.push(
      "[" + t.name + '] Expected constructed "' + t.constructed + '", got "' + e.constructed + '"'
    );
  else r && (e.tagClass !== t.tagClass && r.push(
    "[" + t.name + '] Expected tag class "' + t.tagClass + '", got "' + e.tagClass + '"'
  ), e.type !== t.type && r.push(
    "[" + t.name + '] Expected type "' + t.type + '", got "' + e.type + '"'
  ));
  return i;
};
var $a = /[^\\u0000-\\u00ff]/;
H.prettyPrint = function(e, t, a) {
  var r = "";
  t = t || 0, a = a || 2, t > 0 && (r += `
`);
  for (var i = "", n = 0; n < t * a; ++n)
    i += " ";
  switch (r += i + "Tag: ", e.tagClass) {
    case H.Class.UNIVERSAL:
      r += "Universal:";
      break;
    case H.Class.APPLICATION:
      r += "Application:";
      break;
    case H.Class.CONTEXT_SPECIFIC:
      r += "Context-Specific:";
      break;
    case H.Class.PRIVATE:
      r += "Private:";
      break;
  }
  if (e.tagClass === H.Class.UNIVERSAL)
    switch (r += e.type, e.type) {
      case H.Type.NONE:
        r += " (None)";
        break;
      case H.Type.BOOLEAN:
        r += " (Boolean)";
        break;
      case H.Type.INTEGER:
        r += " (Integer)";
        break;
      case H.Type.BITSTRING:
        r += " (Bit string)";
        break;
      case H.Type.OCTETSTRING:
        r += " (Octet string)";
        break;
      case H.Type.NULL:
        r += " (Null)";
        break;
      case H.Type.OID:
        r += " (Object Identifier)";
        break;
      case H.Type.ODESC:
        r += " (Object Descriptor)";
        break;
      case H.Type.EXTERNAL:
        r += " (External or Instance of)";
        break;
      case H.Type.REAL:
        r += " (Real)";
        break;
      case H.Type.ENUMERATED:
        r += " (Enumerated)";
        break;
      case H.Type.EMBEDDED:
        r += " (Embedded PDV)";
        break;
      case H.Type.UTF8:
        r += " (UTF8)";
        break;
      case H.Type.ROID:
        r += " (Relative Object Identifier)";
        break;
      case H.Type.SEQUENCE:
        r += " (Sequence)";
        break;
      case H.Type.SET:
        r += " (Set)";
        break;
      case H.Type.PRINTABLESTRING:
        r += " (Printable String)";
        break;
      case H.Type.IA5String:
        r += " (IA5String (ASCII))";
        break;
      case H.Type.UTCTIME:
        r += " (UTC time)";
        break;
      case H.Type.GENERALIZEDTIME:
        r += " (Generalized time)";
        break;
      case H.Type.BMPSTRING:
        r += " (BMP String)";
        break;
    }
  else
    r += e.type;
  if (r += `
`, r += i + "Constructed: " + e.constructed + `
`, e.composed) {
    for (var s = 0, o = "", n = 0; n < e.value.length; ++n)
      e.value[n] !== void 0 && (s += 1, o += H.prettyPrint(e.value[n], t + 1, a), n + 1 < e.value.length && (o += ","));
    r += i + "Sub values: " + s + o;
  } else {
    if (r += i + "Value: ", e.type === H.Type.OID) {
      var l = H.derToOid(e.value);
      r += l, xe.pki && xe.pki.oids && l in xe.pki.oids && (r += " (" + xe.pki.oids[l] + ") ");
    }
    if (e.type === H.Type.INTEGER)
      try {
        r += H.derToInteger(e.value);
      } catch {
        r += "0x" + xe.util.bytesToHex(e.value);
      }
    else if (e.type === H.Type.BITSTRING) {
      if (e.value.length > 1 ? r += "0x" + xe.util.bytesToHex(e.value.slice(1)) : r += "(none)", e.value.length > 0) {
        var f = e.value.charCodeAt(0);
        f == 1 ? r += " (1 unused bit shown)" : f > 1 && (r += " (" + f + " unused bits shown)");
      }
    } else if (e.type === H.Type.OCTETSTRING)
      $a.test(e.value) || (r += "(" + e.value + ") "), r += "0x" + xe.util.bytesToHex(e.value);
    else if (e.type === H.Type.UTF8)
      try {
        r += xe.util.decodeUtf8(e.value);
      } catch (u) {
        if (u.message === "URI malformed")
          r += "0x" + xe.util.bytesToHex(e.value) + " (malformed UTF8)";
        else
          throw u;
      }
    else e.type === H.Type.PRINTABLESTRING || e.type === H.Type.IA5String ? r += e.value : $a.test(e.value) ? r += "0x" + xe.util.bytesToHex(e.value) : e.value.length === 0 ? r += "[null]" : r += e.value;
  }
  return r;
};
var Lr = ee;
Lr.md = Lr.md || {};
Lr.md.algorithms = Lr.md.algorithms || {};
var wt = ee, Mn = wt.hmac = wt.hmac || {};
Mn.create = function() {
  var e = null, t = null, a = null, r = null, i = {};
  return i.start = function(n, s) {
    if (n !== null)
      if (typeof n == "string")
        if (n = n.toLowerCase(), n in wt.md.algorithms)
          t = wt.md.algorithms[n].create();
        else
          throw new Error('Unknown hash algorithm "' + n + '"');
      else
        t = n;
    if (s === null)
      s = e;
    else {
      if (typeof s == "string")
        s = wt.util.createBuffer(s);
      else if (wt.util.isArray(s)) {
        var o = s;
        s = wt.util.createBuffer();
        for (var l = 0; l < o.length; ++l)
          s.putByte(o[l]);
      }
      var f = s.length();
      f > t.blockLength && (t.start(), t.update(s.bytes()), s = t.digest()), a = wt.util.createBuffer(), r = wt.util.createBuffer(), f = s.length();
      for (var l = 0; l < f; ++l) {
        var o = s.at(l);
        a.putByte(54 ^ o), r.putByte(92 ^ o);
      }
      if (f < t.blockLength)
        for (var o = t.blockLength - f, l = 0; l < o; ++l)
          a.putByte(54), r.putByte(92);
      e = s, a = a.bytes(), r = r.bytes();
    }
    t.start(), t.update(a);
  }, i.update = function(n) {
    t.update(n);
  }, i.getMac = function() {
    var n = t.digest().bytes();
    return t.start(), t.update(r), t.update(n), t.digest();
  }, i.digest = i.getMac, i;
};
var St = ee, Ai = St.md5 = St.md5 || {};
St.md.md5 = St.md.algorithms.md5 = Ai;
Ai.create = function() {
  bi || Hn();
  var e = null, t = St.util.createBuffer(), a = new Array(16), r = {
    algorithm: "md5",
    blockLength: 64,
    digestLength: 16,
    // 56-bit length of message so far (does not including padding)
    messageLength: 0,
    // true message length
    fullMessageLength: null,
    // size of message length in bytes
    messageLengthSize: 8
  };
  return r.start = function() {
    r.messageLength = 0, r.fullMessageLength = r.messageLength64 = [];
    for (var i = r.messageLengthSize / 4, n = 0; n < i; ++n)
      r.fullMessageLength.push(0);
    return t = St.util.createBuffer(), e = {
      h0: 1732584193,
      h1: 4023233417,
      h2: 2562383102,
      h3: 271733878
    }, r;
  }, r.start(), r.update = function(i, n) {
    n === "utf8" && (i = St.util.encodeUtf8(i));
    var s = i.length;
    r.messageLength += s, s = [s / 4294967296 >>> 0, s >>> 0];
    for (var o = r.fullMessageLength.length - 1; o >= 0; --o)
      r.fullMessageLength[o] += s[1], s[1] = s[0] + (r.fullMessageLength[o] / 4294967296 >>> 0), r.fullMessageLength[o] = r.fullMessageLength[o] >>> 0, s[0] = s[1] / 4294967296 >>> 0;
    return t.putBytes(i), ja(e, a, t), (t.read > 2048 || t.length() === 0) && t.compact(), r;
  }, r.digest = function() {
    var i = St.util.createBuffer();
    i.putBytes(t.bytes());
    var n = r.fullMessageLength[r.fullMessageLength.length - 1] + r.messageLengthSize, s = n & r.blockLength - 1;
    i.putBytes(ha.substr(0, r.blockLength - s));
    for (var o, l = 0, f = r.fullMessageLength.length - 1; f >= 0; --f)
      o = r.fullMessageLength[f] * 8 + l, l = o / 4294967296 >>> 0, i.putInt32Le(o >>> 0);
    var u = {
      h0: e.h0,
      h1: e.h1,
      h2: e.h2,
      h3: e.h3
    };
    ja(u, a, i);
    var p = St.util.createBuffer();
    return p.putInt32Le(u.h0), p.putInt32Le(u.h1), p.putInt32Le(u.h2), p.putInt32Le(u.h3), p;
  }, r;
};
var ha = null, Nr = null, gr = null, rr = null, bi = !1;
function Hn() {
  ha = "€", ha += St.util.fillString("\0", 64), Nr = [
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11,
    12,
    13,
    14,
    15,
    1,
    6,
    11,
    0,
    5,
    10,
    15,
    4,
    9,
    14,
    3,
    8,
    13,
    2,
    7,
    12,
    5,
    8,
    11,
    14,
    1,
    4,
    7,
    10,
    13,
    0,
    3,
    6,
    9,
    12,
    15,
    2,
    0,
    7,
    14,
    5,
    12,
    3,
    10,
    1,
    8,
    15,
    6,
    13,
    4,
    11,
    2,
    9
  ], gr = [
    7,
    12,
    17,
    22,
    7,
    12,
    17,
    22,
    7,
    12,
    17,
    22,
    7,
    12,
    17,
    22,
    5,
    9,
    14,
    20,
    5,
    9,
    14,
    20,
    5,
    9,
    14,
    20,
    5,
    9,
    14,
    20,
    4,
    11,
    16,
    23,
    4,
    11,
    16,
    23,
    4,
    11,
    16,
    23,
    4,
    11,
    16,
    23,
    6,
    10,
    15,
    21,
    6,
    10,
    15,
    21,
    6,
    10,
    15,
    21,
    6,
    10,
    15,
    21
  ], rr = new Array(64);
  for (var e = 0; e < 64; ++e)
    rr[e] = Math.floor(Math.abs(Math.sin(e + 1)) * 4294967296);
  bi = !0;
}
function ja(e, t, a) {
  for (var r, i, n, s, o, l, f, u, p = a.length(); p >= 64; ) {
    for (i = e.h0, n = e.h1, s = e.h2, o = e.h3, u = 0; u < 16; ++u)
      t[u] = a.getInt32Le(), l = o ^ n & (s ^ o), r = i + l + rr[u] + t[u], f = gr[u], i = o, o = s, s = n, n += r << f | r >>> 32 - f;
    for (; u < 32; ++u)
      l = s ^ o & (n ^ s), r = i + l + rr[u] + t[Nr[u]], f = gr[u], i = o, o = s, s = n, n += r << f | r >>> 32 - f;
    for (; u < 48; ++u)
      l = n ^ s ^ o, r = i + l + rr[u] + t[Nr[u]], f = gr[u], i = o, o = s, s = n, n += r << f | r >>> 32 - f;
    for (; u < 64; ++u)
      l = s ^ (n | ~o), r = i + l + rr[u] + t[Nr[u]], f = gr[u], i = o, o = s, s = n, n += r << f | r >>> 32 - f;
    e.h0 = e.h0 + i | 0, e.h1 = e.h1 + n | 0, e.h2 = e.h2 + s | 0, e.h3 = e.h3 + o | 0, p -= 64;
  }
}
var Ur = ee, wi = Ur.pem = Ur.pem || {};
wi.encode = function(e, t) {
  t = t || {};
  var a = "-----BEGIN " + e.type + `-----\r
`, r;
  if (e.procType && (r = {
    name: "Proc-Type",
    values: [String(e.procType.version), e.procType.type]
  }, a += Br(r)), e.contentDomain && (r = { name: "Content-Domain", values: [e.contentDomain] }, a += Br(r)), e.dekInfo && (r = { name: "DEK-Info", values: [e.dekInfo.algorithm] }, e.dekInfo.parameters && r.values.push(e.dekInfo.parameters), a += Br(r)), e.headers)
    for (var i = 0; i < e.headers.length; ++i)
      a += Br(e.headers[i]);
  return e.procType && (a += `\r
`), a += Ur.util.encode64(e.body, t.maxline || 64) + `\r
`, a += "-----END " + e.type + `-----\r
`, a;
};
wi.decode = function(e) {
  for (var t = [], a = /\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g, r = /([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/, i = /\r?\n/, n; n = a.exec(e), !!n; ) {
    var s = n[1];
    s === "NEW CERTIFICATE REQUEST" && (s = "CERTIFICATE REQUEST");
    var o = {
      type: s,
      procType: null,
      contentDomain: null,
      dekInfo: null,
      headers: [],
      body: Ur.util.decode64(n[3])
    };
    if (t.push(o), !!n[2]) {
      for (var l = n[2].split(i), f = 0; n && f < l.length; ) {
        for (var u = l[f].replace(/\s+$/, ""), p = f + 1; p < l.length; ++p) {
          var m = l[p];
          if (!/\s/.test(m[0]))
            break;
          u += m, f = p;
        }
        if (n = u.match(r), n) {
          for (var S = { name: n[1], values: [] }, C = n[2].split(","), A = 0; A < C.length; ++A)
            S.values.push(Gn(C[A]));
          if (o.procType)
            if (!o.contentDomain && S.name === "Content-Domain")
              o.contentDomain = C[0] || "";
            else if (!o.dekInfo && S.name === "DEK-Info") {
              if (S.values.length === 0)
                throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');
              o.dekInfo = { algorithm: C[0], parameters: C[1] || null };
            } else
              o.headers.push(S);
          else {
            if (S.name !== "Proc-Type")
              throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');
            if (S.values.length !== 2)
              throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');
            o.procType = { version: C[0], type: C[1] };
          }
        }
        ++f;
      }
      if (o.procType === "ENCRYPTED" && !o.dekInfo)
        throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".');
    }
  }
  if (t.length === 0)
    throw new Error("Invalid PEM formatted message.");
  return t;
};
function Br(e) {
  for (var t = e.name + ": ", a = [], r = function(l, f) {
    return " " + f;
  }, i = 0; i < e.values.length; ++i)
    a.push(e.values[i].replace(/^(\S+\r\n)/, r));
  t += a.join(",") + `\r
`;
  for (var n = 0, s = -1, i = 0; i < t.length; ++i, ++n)
    if (n > 65 && s !== -1) {
      var o = t[s];
      o === "," ? (++s, t = t.substr(0, s) + `\r
 ` + t.substr(s)) : t = t.substr(0, s) + `\r
` + o + t.substr(s + 1), n = i - s - 1, s = -1, ++i;
    } else (t[i] === " " || t[i] === "	" || t[i] === ",") && (s = i);
  return t;
}
function Gn(e) {
  return e.replace(/^\s+/, "");
}
var Ie = ee;
Ie.des = Ie.des || {};
Ie.des.startEncrypting = function(e, t, a, r) {
  var i = Yr({
    key: e,
    output: a,
    decrypt: !1,
    mode: r || (t === null ? "ECB" : "CBC")
  });
  return i.start(t), i;
};
Ie.des.createEncryptionCipher = function(e, t) {
  return Yr({
    key: e,
    output: null,
    decrypt: !1,
    mode: t
  });
};
Ie.des.startDecrypting = function(e, t, a, r) {
  var i = Yr({
    key: e,
    output: a,
    decrypt: !0,
    mode: r || (t === null ? "ECB" : "CBC")
  });
  return i.start(t), i;
};
Ie.des.createDecryptionCipher = function(e, t) {
  return Yr({
    key: e,
    output: null,
    decrypt: !0,
    mode: t
  });
};
Ie.des.Algorithm = function(e, t) {
  var a = this;
  a.name = e, a.mode = new t({
    blockSize: 8,
    cipher: {
      encrypt: function(r, i) {
        return Za(a._keys, r, i, !1);
      },
      decrypt: function(r, i) {
        return Za(a._keys, r, i, !0);
      }
    }
  }), a._init = !1;
};
Ie.des.Algorithm.prototype.initialize = function(e) {
  if (!this._init) {
    var t = Ie.util.createBuffer(e.key);
    if (this.name.indexOf("3DES") === 0 && t.length() !== 24)
      throw new Error("Invalid Triple-DES key size: " + t.length() * 8);
    this._keys = Zn(t), this._init = !0;
  }
};
At("DES-ECB", Ie.cipher.modes.ecb);
At("DES-CBC", Ie.cipher.modes.cbc);
At("DES-CFB", Ie.cipher.modes.cfb);
At("DES-OFB", Ie.cipher.modes.ofb);
At("DES-CTR", Ie.cipher.modes.ctr);
At("3DES-ECB", Ie.cipher.modes.ecb);
At("3DES-CBC", Ie.cipher.modes.cbc);
At("3DES-CFB", Ie.cipher.modes.cfb);
At("3DES-OFB", Ie.cipher.modes.ofb);
At("3DES-CTR", Ie.cipher.modes.ctr);
function At(e, t) {
  var a = function() {
    return new Ie.des.Algorithm(e, t);
  };
  Ie.cipher.registerAlgorithm(e, a);
}
var qn = [16843776, 0, 65536, 16843780, 16842756, 66564, 4, 65536, 1024, 16843776, 16843780, 1024, 16778244, 16842756, 16777216, 4, 1028, 16778240, 16778240, 66560, 66560, 16842752, 16842752, 16778244, 65540, 16777220, 16777220, 65540, 0, 1028, 66564, 16777216, 65536, 16843780, 4, 16842752, 16843776, 16777216, 16777216, 1024, 16842756, 65536, 66560, 16777220, 1024, 4, 16778244, 66564, 16843780, 65540, 16842752, 16778244, 16777220, 1028, 66564, 16843776, 1028, 16778240, 16778240, 0, 65540, 66560, 0, 16842756], Qn = [-2146402272, -2147450880, 32768, 1081376, 1048576, 32, -2146435040, -2147450848, -2147483616, -2146402272, -2146402304, -2147483648, -2147450880, 1048576, 32, -2146435040, 1081344, 1048608, -2147450848, 0, -2147483648, 32768, 1081376, -2146435072, 1048608, -2147483616, 0, 1081344, 32800, -2146402304, -2146435072, 32800, 0, 1081376, -2146435040, 1048576, -2147450848, -2146435072, -2146402304, 32768, -2146435072, -2147450880, 32, -2146402272, 1081376, 32, 32768, -2147483648, 32800, -2146402304, 1048576, -2147483616, 1048608, -2147450848, -2147483616, 1048608, 1081344, 0, -2147450880, 32800, -2147483648, -2146435040, -2146402272, 1081344], zn = [520, 134349312, 0, 134348808, 134218240, 0, 131592, 134218240, 131080, 134217736, 134217736, 131072, 134349320, 131080, 134348800, 520, 134217728, 8, 134349312, 512, 131584, 134348800, 134348808, 131592, 134218248, 131584, 131072, 134218248, 8, 134349320, 512, 134217728, 134349312, 134217728, 131080, 520, 131072, 134349312, 134218240, 0, 512, 131080, 134349320, 134218240, 134217736, 512, 0, 134348808, 134218248, 131072, 134217728, 134349320, 8, 131592, 131584, 134217736, 134348800, 134218248, 520, 134348800, 131592, 8, 134348808, 131584], Yn = [8396801, 8321, 8321, 128, 8396928, 8388737, 8388609, 8193, 0, 8396800, 8396800, 8396929, 129, 0, 8388736, 8388609, 1, 8192, 8388608, 8396801, 128, 8388608, 8193, 8320, 8388737, 1, 8320, 8388736, 8192, 8396928, 8396929, 129, 8388736, 8388609, 8396800, 8396929, 129, 0, 0, 8396800, 8320, 8388736, 8388737, 1, 8396801, 8321, 8321, 128, 8396929, 129, 1, 8192, 8388609, 8193, 8396928, 8388737, 8193, 8320, 8388608, 8396801, 128, 8388608, 8192, 8396928], Xn = [256, 34078976, 34078720, 1107296512, 524288, 256, 1073741824, 34078720, 1074266368, 524288, 33554688, 1074266368, 1107296512, 1107820544, 524544, 1073741824, 33554432, 1074266112, 1074266112, 0, 1073742080, 1107820800, 1107820800, 33554688, 1107820544, 1073742080, 0, 1107296256, 34078976, 33554432, 1107296256, 524544, 524288, 1107296512, 256, 33554432, 1073741824, 34078720, 1107296512, 1074266368, 33554688, 1073741824, 1107820544, 34078976, 1074266368, 256, 33554432, 1107820544, 1107820800, 524544, 1107296256, 1107820800, 34078720, 0, 1074266112, 1107296256, 524544, 33554688, 1073742080, 524288, 0, 1074266112, 34078976, 1073742080], Wn = [536870928, 541065216, 16384, 541081616, 541065216, 16, 541081616, 4194304, 536887296, 4210704, 4194304, 536870928, 4194320, 536887296, 536870912, 16400, 0, 4194320, 536887312, 16384, 4210688, 536887312, 16, 541065232, 541065232, 0, 4210704, 541081600, 16400, 4210688, 541081600, 536870912, 536887296, 16, 541065232, 4210688, 541081616, 4194304, 16400, 536870928, 4194304, 536887296, 536870912, 16400, 536870928, 541081616, 4210688, 541065216, 4210704, 541081600, 0, 541065232, 16, 16384, 541065216, 4210704, 16384, 4194320, 536887312, 0, 541081600, 536870912, 4194320, 536887312], $n = [2097152, 69206018, 67110914, 0, 2048, 67110914, 2099202, 69208064, 69208066, 2097152, 0, 67108866, 2, 67108864, 69206018, 2050, 67110912, 2099202, 2097154, 67110912, 67108866, 69206016, 69208064, 2097154, 69206016, 2048, 2050, 69208066, 2099200, 2, 67108864, 2099200, 67108864, 2099200, 2097152, 67110914, 67110914, 69206018, 69206018, 2, 2097154, 67108864, 67110912, 2097152, 69208064, 2050, 2099202, 69208064, 2050, 67108866, 69208066, 69206016, 2099200, 0, 2, 69208066, 0, 2099202, 69206016, 2048, 67108866, 67110912, 2048, 2097154], jn = [268439616, 4096, 262144, 268701760, 268435456, 268439616, 64, 268435456, 262208, 268697600, 268701760, 266240, 268701696, 266304, 4096, 64, 268697600, 268435520, 268439552, 4160, 266240, 262208, 268697664, 268701696, 4160, 0, 0, 268697664, 268435520, 268439552, 266304, 262144, 266304, 262144, 268701696, 4096, 64, 268697664, 4096, 266304, 268439552, 64, 268435520, 268697600, 268697664, 268435456, 262144, 268439616, 0, 268701760, 262208, 268435520, 268697600, 268439552, 268439616, 0, 268701760, 266240, 266240, 4160, 4160, 262208, 268435456, 268701696];
function Zn(e) {
  for (var t = [0, 4, 536870912, 536870916, 65536, 65540, 536936448, 536936452, 512, 516, 536871424, 536871428, 66048, 66052, 536936960, 536936964], a = [0, 1, 1048576, 1048577, 67108864, 67108865, 68157440, 68157441, 256, 257, 1048832, 1048833, 67109120, 67109121, 68157696, 68157697], r = [0, 8, 2048, 2056, 16777216, 16777224, 16779264, 16779272, 0, 8, 2048, 2056, 16777216, 16777224, 16779264, 16779272], i = [0, 2097152, 134217728, 136314880, 8192, 2105344, 134225920, 136323072, 131072, 2228224, 134348800, 136445952, 139264, 2236416, 134356992, 136454144], n = [0, 262144, 16, 262160, 0, 262144, 16, 262160, 4096, 266240, 4112, 266256, 4096, 266240, 4112, 266256], s = [0, 1024, 32, 1056, 0, 1024, 32, 1056, 33554432, 33555456, 33554464, 33555488, 33554432, 33555456, 33554464, 33555488], o = [0, 268435456, 524288, 268959744, 2, 268435458, 524290, 268959746, 0, 268435456, 524288, 268959744, 2, 268435458, 524290, 268959746], l = [0, 65536, 2048, 67584, 536870912, 536936448, 536872960, 536938496, 131072, 196608, 133120, 198656, 537001984, 537067520, 537004032, 537069568], f = [0, 262144, 0, 262144, 2, 262146, 2, 262146, 33554432, 33816576, 33554432, 33816576, 33554434, 33816578, 33554434, 33816578], u = [0, 268435456, 8, 268435464, 0, 268435456, 8, 268435464, 1024, 268436480, 1032, 268436488, 1024, 268436480, 1032, 268436488], p = [0, 32, 0, 32, 1048576, 1048608, 1048576, 1048608, 8192, 8224, 8192, 8224, 1056768, 1056800, 1056768, 1056800], m = [0, 16777216, 512, 16777728, 2097152, 18874368, 2097664, 18874880, 67108864, 83886080, 67109376, 83886592, 69206016, 85983232, 69206528, 85983744], S = [0, 4096, 134217728, 134221824, 524288, 528384, 134742016, 134746112, 16, 4112, 134217744, 134221840, 524304, 528400, 134742032, 134746128], C = [0, 4, 256, 260, 0, 4, 256, 260, 1, 5, 257, 261, 1, 5, 257, 261], A = e.length() > 8 ? 3 : 1, b = [], _ = [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0], U = 0, D, G = 0; G < A; G++) {
    var O = e.getInt32(), F = e.getInt32();
    D = (O >>> 4 ^ F) & 252645135, F ^= D, O ^= D << 4, D = (F >>> -16 ^ O) & 65535, O ^= D, F ^= D << -16, D = (O >>> 2 ^ F) & 858993459, F ^= D, O ^= D << 2, D = (F >>> -16 ^ O) & 65535, O ^= D, F ^= D << -16, D = (O >>> 1 ^ F) & 1431655765, F ^= D, O ^= D << 1, D = (F >>> 8 ^ O) & 16711935, O ^= D, F ^= D << 8, D = (O >>> 1 ^ F) & 1431655765, F ^= D, O ^= D << 1, D = O << 8 | F >>> 20 & 240, O = F << 24 | F << 8 & 16711680 | F >>> 8 & 65280 | F >>> 24 & 240, F = D;
    for (var $ = 0; $ < _.length; ++$) {
      _[$] ? (O = O << 2 | O >>> 26, F = F << 2 | F >>> 26) : (O = O << 1 | O >>> 27, F = F << 1 | F >>> 27), O &= -15, F &= -15;
      var j = t[O >>> 28] | a[O >>> 24 & 15] | r[O >>> 20 & 15] | i[O >>> 16 & 15] | n[O >>> 12 & 15] | s[O >>> 8 & 15] | o[O >>> 4 & 15], le = l[F >>> 28] | f[F >>> 24 & 15] | u[F >>> 20 & 15] | p[F >>> 16 & 15] | m[F >>> 12 & 15] | S[F >>> 8 & 15] | C[F >>> 4 & 15];
      D = (le >>> 16 ^ j) & 65535, b[U++] = j ^ D, b[U++] = le ^ D << 16;
    }
  }
  return b;
}
function Za(e, t, a, r) {
  var i = e.length === 32 ? 3 : 9, n;
  i === 3 ? n = r ? [30, -2, -2] : [0, 32, 2] : n = r ? [94, 62, -2, 32, 64, 2, 30, -2, -2] : [0, 32, 2, 62, 30, -2, 64, 96, 2];
  var s, o = t[0], l = t[1];
  s = (o >>> 4 ^ l) & 252645135, l ^= s, o ^= s << 4, s = (o >>> 16 ^ l) & 65535, l ^= s, o ^= s << 16, s = (l >>> 2 ^ o) & 858993459, o ^= s, l ^= s << 2, s = (l >>> 8 ^ o) & 16711935, o ^= s, l ^= s << 8, s = (o >>> 1 ^ l) & 1431655765, l ^= s, o ^= s << 1, o = o << 1 | o >>> 31, l = l << 1 | l >>> 31;
  for (var f = 0; f < i; f += 3) {
    for (var u = n[f + 1], p = n[f + 2], m = n[f]; m != u; m += p) {
      var S = l ^ e[m], C = (l >>> 4 | l << 28) ^ e[m + 1];
      s = o, o = l, l = s ^ (Qn[S >>> 24 & 63] | Yn[S >>> 16 & 63] | Wn[S >>> 8 & 63] | jn[S & 63] | qn[C >>> 24 & 63] | zn[C >>> 16 & 63] | Xn[C >>> 8 & 63] | $n[C & 63]);
    }
    s = o, o = l, l = s;
  }
  o = o >>> 1 | o << 31, l = l >>> 1 | l << 31, s = (o >>> 1 ^ l) & 1431655765, l ^= s, o ^= s << 1, s = (l >>> 8 ^ o) & 16711935, o ^= s, l ^= s << 8, s = (l >>> 2 ^ o) & 858993459, o ^= s, l ^= s << 2, s = (o >>> 16 ^ l) & 65535, l ^= s, o ^= s << 16, s = (o >>> 4 ^ l) & 252645135, l ^= s, o ^= s << 4, a[0] = o, a[1] = l;
}
function Yr(e) {
  e = e || {};
  var t = (e.mode || "CBC").toUpperCase(), a = "DES-" + t, r;
  e.decrypt ? r = Ie.cipher.createDecipher(a, e.key) : r = Ie.cipher.createCipher(a, e.key);
  var i = r.start;
  return r.start = function(n, s) {
    var o = null;
    s instanceof Ie.util.ByteBuffer && (o = s, s = {}), s = s || {}, s.output = o, s.iv = n, i.call(r, s);
  }, r;
}
const Jn = {}, es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Jn }, Symbol.toStringTag, { value: "Module" })), Ua = /* @__PURE__ */ Tn(es);
var Je = ee, ts = Je.pkcs5 = Je.pkcs5 || {}, bt;
Je.util.isNodejs && !Je.options.usePureJavaScript && (bt = Ua);
Je.pbkdf2 = ts.pbkdf2 = function(e, t, a, r, i, n) {
  if (typeof i == "function" && (n = i, i = null), Je.util.isNodejs && !Je.options.usePureJavaScript && bt.pbkdf2 && (i === null || typeof i != "object") && (bt.pbkdf2Sync.length > 4 || !i || i === "sha1"))
    return typeof i != "string" && (i = "sha1"), e = pt.from(e, "binary"), t = pt.from(t, "binary"), n ? bt.pbkdf2Sync.length === 4 ? bt.pbkdf2(e, t, a, r, function(D, G) {
      if (D)
        return n(D);
      n(null, G.toString("binary"));
    }) : bt.pbkdf2(e, t, a, r, i, function(D, G) {
      if (D)
        return n(D);
      n(null, G.toString("binary"));
    }) : bt.pbkdf2Sync.length === 4 ? bt.pbkdf2Sync(e, t, a, r).toString("binary") : bt.pbkdf2Sync(e, t, a, r, i).toString("binary");
  if ((typeof i > "u" || i === null) && (i = "sha1"), typeof i == "string") {
    if (!(i in Je.md.algorithms))
      throw new Error("Unknown hash algorithm: " + i);
    i = Je.md[i].create();
  }
  var s = i.digestLength;
  if (r > 4294967295 * s) {
    var o = new Error("Derived key is too long.");
    if (n)
      return n(o);
    throw o;
  }
  var l = Math.ceil(r / s), f = r - (l - 1) * s, u = Je.hmac.create();
  u.start(i, e);
  var p = "", m, S, C;
  if (!n) {
    for (var A = 1; A <= l; ++A) {
      u.start(null, null), u.update(t), u.update(Je.util.int32ToBytes(A)), m = C = u.digest().getBytes();
      for (var b = 2; b <= a; ++b)
        u.start(null, null), u.update(C), S = u.digest().getBytes(), m = Je.util.xorBytes(m, S, s), C = S;
      p += A < l ? m : m.substr(0, f);
    }
    return p;
  }
  var A = 1, b;
  function _() {
    if (A > l)
      return n(null, p);
    u.start(null, null), u.update(t), u.update(Je.util.int32ToBytes(A)), m = C = u.digest().getBytes(), b = 2, U();
  }
  function U() {
    if (b <= a)
      return u.start(null, null), u.update(C), S = u.digest().getBytes(), m = Je.util.xorBytes(m, S, s), C = S, ++b, Je.util.setImmediate(U);
    p += A < l ? m : m.substr(0, f), ++A, _();
  }
  _();
};
var Tt = ee, _i = Tt.sha256 = Tt.sha256 || {};
Tt.md.sha256 = Tt.md.algorithms.sha256 = _i;
_i.create = function() {
  Ni || rs();
  var e = null, t = Tt.util.createBuffer(), a = new Array(64), r = {
    algorithm: "sha256",
    blockLength: 64,
    digestLength: 32,
    // 56-bit length of message so far (does not including padding)
    messageLength: 0,
    // true message length
    fullMessageLength: null,
    // size of message length in bytes
    messageLengthSize: 8
  };
  return r.start = function() {
    r.messageLength = 0, r.fullMessageLength = r.messageLength64 = [];
    for (var i = r.messageLengthSize / 4, n = 0; n < i; ++n)
      r.fullMessageLength.push(0);
    return t = Tt.util.createBuffer(), e = {
      h0: 1779033703,
      h1: 3144134277,
      h2: 1013904242,
      h3: 2773480762,
      h4: 1359893119,
      h5: 2600822924,
      h6: 528734635,
      h7: 1541459225
    }, r;
  }, r.start(), r.update = function(i, n) {
    n === "utf8" && (i = Tt.util.encodeUtf8(i));
    var s = i.length;
    r.messageLength += s, s = [s / 4294967296 >>> 0, s >>> 0];
    for (var o = r.fullMessageLength.length - 1; o >= 0; --o)
      r.fullMessageLength[o] += s[1], s[1] = s[0] + (r.fullMessageLength[o] / 4294967296 >>> 0), r.fullMessageLength[o] = r.fullMessageLength[o] >>> 0, s[0] = s[1] / 4294967296 >>> 0;
    return t.putBytes(i), Ja(e, a, t), (t.read > 2048 || t.length() === 0) && t.compact(), r;
  }, r.digest = function() {
    var i = Tt.util.createBuffer();
    i.putBytes(t.bytes());
    var n = r.fullMessageLength[r.fullMessageLength.length - 1] + r.messageLengthSize, s = n & r.blockLength - 1;
    i.putBytes(pa.substr(0, r.blockLength - s));
    for (var o, l, f = r.fullMessageLength[0] * 8, u = 0; u < r.fullMessageLength.length - 1; ++u)
      o = r.fullMessageLength[u + 1] * 8, l = o / 4294967296 >>> 0, f += l, i.putInt32(f >>> 0), f = o >>> 0;
    i.putInt32(f);
    var p = {
      h0: e.h0,
      h1: e.h1,
      h2: e.h2,
      h3: e.h3,
      h4: e.h4,
      h5: e.h5,
      h6: e.h6,
      h7: e.h7
    };
    Ja(p, a, i);
    var m = Tt.util.createBuffer();
    return m.putInt32(p.h0), m.putInt32(p.h1), m.putInt32(p.h2), m.putInt32(p.h3), m.putInt32(p.h4), m.putInt32(p.h5), m.putInt32(p.h6), m.putInt32(p.h7), m;
  }, r;
};
var pa = null, Ni = !1, Ri = null;
function rs() {
  pa = "€", pa += Tt.util.fillString("\0", 64), Ri = [
    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
  ], Ni = !0;
}
function Ja(e, t, a) {
  for (var r, i, n, s, o, l, f, u, p, m, S, C, A, b, _, U = a.length(); U >= 64; ) {
    for (f = 0; f < 16; ++f)
      t[f] = a.getInt32();
    for (; f < 64; ++f)
      r = t[f - 2], r = (r >>> 17 | r << 15) ^ (r >>> 19 | r << 13) ^ r >>> 10, i = t[f - 15], i = (i >>> 7 | i << 25) ^ (i >>> 18 | i << 14) ^ i >>> 3, t[f] = r + t[f - 7] + i + t[f - 16] | 0;
    for (u = e.h0, p = e.h1, m = e.h2, S = e.h3, C = e.h4, A = e.h5, b = e.h6, _ = e.h7, f = 0; f < 64; ++f)
      s = (C >>> 6 | C << 26) ^ (C >>> 11 | C << 21) ^ (C >>> 25 | C << 7), o = b ^ C & (A ^ b), n = (u >>> 2 | u << 30) ^ (u >>> 13 | u << 19) ^ (u >>> 22 | u << 10), l = u & p | m & (u ^ p), r = _ + s + o + Ri[f] + t[f], i = n + l, _ = b, b = A, A = C, C = S + r >>> 0, S = m, m = p, p = u, u = r + i >>> 0;
    e.h0 = e.h0 + u | 0, e.h1 = e.h1 + p | 0, e.h2 = e.h2 + m | 0, e.h3 = e.h3 + S | 0, e.h4 = e.h4 + C | 0, e.h5 = e.h5 + A | 0, e.h6 = e.h6 + b | 0, e.h7 = e.h7 + _ | 0, U -= 64;
  }
}
var Ct = ee, Rr = null;
Ct.util.isNodejs && !Ct.options.usePureJavaScript && !kt.versions["node-webkit"] && (Rr = Ua);
var as = Ct.prng = Ct.prng || {};
as.create = function(e) {
  for (var t = {
    plugin: e,
    key: null,
    seed: null,
    time: null,
    // number of reseeds so far
    reseeds: 0,
    // amount of data generated so far
    generated: 0,
    // no initial key bytes
    keyBytes: ""
  }, a = e.md, r = new Array(32), i = 0; i < 32; ++i)
    r[i] = a.create();
  t.pools = r, t.pool = 0, t.generate = function(f, u) {
    if (!u)
      return t.generateSync(f);
    var p = t.plugin.cipher, m = t.plugin.increment, S = t.plugin.formatKey, C = t.plugin.formatSeed, A = Ct.util.createBuffer();
    t.key = null, b();
    function b(_) {
      if (_)
        return u(_);
      if (A.length() >= f)
        return u(null, A.getBytes(f));
      if (t.generated > 1048575 && (t.key = null), t.key === null)
        return Ct.util.nextTick(function() {
          n(b);
        });
      var U = p(t.key, t.seed);
      t.generated += U.length, A.putBytes(U), t.key = S(p(t.key, m(t.seed))), t.seed = C(p(t.key, t.seed)), Ct.util.setImmediate(b);
    }
  }, t.generateSync = function(f) {
    var u = t.plugin.cipher, p = t.plugin.increment, m = t.plugin.formatKey, S = t.plugin.formatSeed;
    t.key = null;
    for (var C = Ct.util.createBuffer(); C.length() < f; ) {
      t.generated > 1048575 && (t.key = null), t.key === null && s();
      var A = u(t.key, t.seed);
      t.generated += A.length, C.putBytes(A), t.key = m(u(t.key, p(t.seed))), t.seed = S(u(t.key, t.seed));
    }
    return C.getBytes(f);
  };
  function n(f) {
    if (t.pools[0].messageLength >= 32)
      return o(), f();
    var u = 32 - t.pools[0].messageLength << 5;
    t.seedFile(u, function(p, m) {
      if (p)
        return f(p);
      t.collect(m), o(), f();
    });
  }
  function s() {
    if (t.pools[0].messageLength >= 32)
      return o();
    var f = 32 - t.pools[0].messageLength << 5;
    t.collect(t.seedFileSync(f)), o();
  }
  function o() {
    t.reseeds = t.reseeds === 4294967295 ? 0 : t.reseeds + 1;
    var f = t.plugin.md.create();
    f.update(t.keyBytes);
    for (var u = 1, p = 0; p < 32; ++p)
      t.reseeds % u === 0 && (f.update(t.pools[p].digest().getBytes()), t.pools[p].start()), u = u << 1;
    t.keyBytes = f.digest().getBytes(), f.start(), f.update(t.keyBytes);
    var m = f.digest().getBytes();
    t.key = t.plugin.formatKey(t.keyBytes), t.seed = t.plugin.formatSeed(m), t.generated = 0;
  }
  function l(f) {
    var u = null, p = Ct.util.globalScope, m = p.crypto || p.msCrypto;
    m && m.getRandomValues && (u = function(O) {
      return m.getRandomValues(O);
    });
    var S = Ct.util.createBuffer();
    if (u)
      for (; S.length() < f; ) {
        var C = Math.max(1, Math.min(f - S.length(), 65536) / 4), A = new Uint32Array(Math.floor(C));
        try {
          u(A);
          for (var b = 0; b < A.length; ++b)
            S.putInt32(A[b]);
        } catch (O) {
          if (!(typeof QuotaExceededError < "u" && O instanceof QuotaExceededError))
            throw O;
        }
      }
    if (S.length() < f)
      for (var _, U, D, G = Math.floor(Math.random() * 65536); S.length() < f; ) {
        U = 16807 * (G & 65535), _ = 16807 * (G >> 16), U += (_ & 32767) << 16, U += _ >> 15, U = (U & 2147483647) + (U >> 31), G = U & 4294967295;
        for (var b = 0; b < 3; ++b)
          D = G >>> (b << 3), D ^= Math.floor(Math.random() * 256), S.putByte(D & 255);
      }
    return S.getBytes(f);
  }
  return Rr ? (t.seedFile = function(f, u) {
    Rr.randomBytes(f, function(p, m) {
      if (p)
        return u(p);
      u(null, m.toString());
    });
  }, t.seedFileSync = function(f) {
    return Rr.randomBytes(f).toString();
  }) : (t.seedFile = function(f, u) {
    try {
      u(null, l(f));
    } catch (p) {
      u(p);
    }
  }, t.seedFileSync = l), t.collect = function(f) {
    for (var u = f.length, p = 0; p < u; ++p)
      t.pools[t.pool].update(f.substr(p, 1)), t.pool = t.pool === 31 ? 0 : t.pool + 1;
  }, t.collectInt = function(f, u) {
    for (var p = "", m = 0; m < u; m += 8)
      p += String.fromCharCode(f >> m & 255);
    t.collect(p);
  }, t.registerWorker = function(f) {
    if (f === self)
      t.seedFile = function(p, m) {
        function S(C) {
          var A = C.data;
          A.forge && A.forge.prng && (self.removeEventListener("message", S), m(A.forge.prng.err, A.forge.prng.bytes));
        }
        self.addEventListener("message", S), self.postMessage({ forge: { prng: { needed: p } } });
      };
    else {
      var u = function(p) {
        var m = p.data;
        m.forge && m.forge.prng && t.seedFile(m.forge.prng.needed, function(S, C) {
          f.postMessage({ forge: { prng: { err: S, bytes: C } } });
        });
      };
      f.addEventListener("message", u);
    }
  }, t;
};
var qe = ee;
(function() {
  if (qe.random && qe.random.getBytes) {
    qe.random;
    return;
  }
  (function(e) {
    var t = {}, a = new Array(4), r = qe.util.createBuffer();
    t.formatKey = function(p) {
      var m = qe.util.createBuffer(p);
      return p = new Array(4), p[0] = m.getInt32(), p[1] = m.getInt32(), p[2] = m.getInt32(), p[3] = m.getInt32(), qe.aes._expandKey(p, !1);
    }, t.formatSeed = function(p) {
      var m = qe.util.createBuffer(p);
      return p = new Array(4), p[0] = m.getInt32(), p[1] = m.getInt32(), p[2] = m.getInt32(), p[3] = m.getInt32(), p;
    }, t.cipher = function(p, m) {
      return qe.aes._updateBlock(p, m, a, !1), r.putInt32(a[0]), r.putInt32(a[1]), r.putInt32(a[2]), r.putInt32(a[3]), r.getBytes();
    }, t.increment = function(p) {
      return ++p[3], p;
    }, t.md = qe.md.sha256;
    function i() {
      var p = qe.prng.create(t);
      return p.getBytes = function(m, S) {
        return p.generate(m, S);
      }, p.getBytesSync = function(m) {
        return p.generate(m);
      }, p;
    }
    var n = i(), s = null, o = qe.util.globalScope, l = o.crypto || o.msCrypto;
    if (l && l.getRandomValues && (s = function(p) {
      return l.getRandomValues(p);
    }), qe.options.usePureJavaScript || !qe.util.isNodejs && !s) {
      if (n.collectInt(+/* @__PURE__ */ new Date(), 32), typeof navigator < "u") {
        var f = "";
        for (var u in navigator)
          try {
            typeof navigator[u] == "string" && (f += navigator[u]);
          } catch {
          }
        n.collect(f), f = null;
      }
      e && (e().mousemove(function(p) {
        n.collectInt(p.clientX, 16), n.collectInt(p.clientY, 16);
      }), e().keypress(function(p) {
        n.collectInt(p.charCode, 8);
      }));
    }
    if (!qe.random)
      qe.random = n;
    else
      for (var u in n)
        qe.random[u] = n[u];
    qe.random.createInstance = i, qe.random;
  })(typeof jQuery < "u" ? jQuery : null);
})();
var at = ee, ra = [
  217,
  120,
  249,
  196,
  25,
  221,
  181,
  237,
  40,
  233,
  253,
  121,
  74,
  160,
  216,
  157,
  198,
  126,
  55,
  131,
  43,
  118,
  83,
  142,
  98,
  76,
  100,
  136,
  68,
  139,
  251,
  162,
  23,
  154,
  89,
  245,
  135,
  179,
  79,
  19,
  97,
  69,
  109,
  141,
  9,
  129,
  125,
  50,
  189,
  143,
  64,
  235,
  134,
  183,
  123,
  11,
  240,
  149,
  33,
  34,
  92,
  107,
  78,
  130,
  84,
  214,
  101,
  147,
  206,
  96,
  178,
  28,
  115,
  86,
  192,
  20,
  167,
  140,
  241,
  220,
  18,
  117,
  202,
  31,
  59,
  190,
  228,
  209,
  66,
  61,
  212,
  48,
  163,
  60,
  182,
  38,
  111,
  191,
  14,
  218,
  70,
  105,
  7,
  87,
  39,
  242,
  29,
  155,
  188,
  148,
  67,
  3,
  248,
  17,
  199,
  246,
  144,
  239,
  62,
  231,
  6,
  195,
  213,
  47,
  200,
  102,
  30,
  215,
  8,
  232,
  234,
  222,
  128,
  82,
  238,
  247,
  132,
  170,
  114,
  172,
  53,
  77,
  106,
  42,
  150,
  26,
  210,
  113,
  90,
  21,
  73,
  116,
  75,
  159,
  208,
  94,
  4,
  24,
  164,
  236,
  194,
  224,
  65,
  110,
  15,
  81,
  203,
  204,
  36,
  145,
  175,
  80,
  161,
  244,
  112,
  57,
  153,
  124,
  58,
  133,
  35,
  184,
  180,
  122,
  252,
  2,
  54,
  91,
  37,
  85,
  151,
  49,
  45,
  93,
  250,
  152,
  227,
  138,
  146,
  174,
  5,
  223,
  41,
  16,
  103,
  108,
  186,
  201,
  211,
  0,
  230,
  207,
  225,
  158,
  168,
  44,
  99,
  22,
  1,
  63,
  88,
  226,
  137,
  169,
  13,
  56,
  52,
  27,
  171,
  51,
  255,
  176,
  187,
  72,
  12,
  95,
  185,
  177,
  205,
  46,
  197,
  243,
  219,
  71,
  229,
  165,
  156,
  119,
  10,
  166,
  32,
  104,
  254,
  127,
  193,
  173
], ei = [1, 2, 3, 5], is = function(e, t) {
  return e << t & 65535 | (e & 65535) >> 16 - t;
}, ns = function(e, t) {
  return (e & 65535) >> t | e << 16 - t & 65535;
};
at.rc2 = at.rc2 || {};
at.rc2.expandKey = function(e, t) {
  typeof e == "string" && (e = at.util.createBuffer(e)), t = t || 128;
  var a = e, r = e.length(), i = t, n = Math.ceil(i / 8), s = 255 >> (i & 7), o;
  for (o = r; o < 128; o++)
    a.putByte(ra[a.at(o - 1) + a.at(o - r) & 255]);
  for (a.setAt(128 - n, ra[a.at(128 - n) & s]), o = 127 - n; o >= 0; o--)
    a.setAt(o, ra[a.at(o + 1) ^ a.at(o + n)]);
  return a;
};
var Li = function(e, t, a) {
  var r = !1, i = null, n = null, s = null, o, l, f, u, p = [];
  for (e = at.rc2.expandKey(e, t), f = 0; f < 64; f++)
    p.push(e.getInt16Le());
  a ? (o = function(C) {
    for (f = 0; f < 4; f++)
      C[f] += p[u] + (C[(f + 3) % 4] & C[(f + 2) % 4]) + (~C[(f + 3) % 4] & C[(f + 1) % 4]), C[f] = is(C[f], ei[f]), u++;
  }, l = function(C) {
    for (f = 0; f < 4; f++)
      C[f] += p[C[(f + 3) % 4] & 63];
  }) : (o = function(C) {
    for (f = 3; f >= 0; f--)
      C[f] = ns(C[f], ei[f]), C[f] -= p[u] + (C[(f + 3) % 4] & C[(f + 2) % 4]) + (~C[(f + 3) % 4] & C[(f + 1) % 4]), u--;
  }, l = function(C) {
    for (f = 3; f >= 0; f--)
      C[f] -= p[C[(f + 3) % 4] & 63];
  });
  var m = function(C) {
    var A = [];
    for (f = 0; f < 4; f++) {
      var b = i.getInt16Le();
      s !== null && (a ? b ^= s.getInt16Le() : s.putInt16Le(b)), A.push(b & 65535);
    }
    u = a ? 0 : 63;
    for (var _ = 0; _ < C.length; _++)
      for (var U = 0; U < C[_][0]; U++)
        C[_][1](A);
    for (f = 0; f < 4; f++)
      s !== null && (a ? s.putInt16Le(A[f]) : A[f] ^= s.getInt16Le()), n.putInt16Le(A[f]);
  }, S = null;
  return S = {
    /**
     * Starts or restarts the encryption or decryption process, whichever
     * was previously configured.
     *
     * To use the cipher in CBC mode, iv may be given either as a string
     * of bytes, or as a byte buffer.  For ECB mode, give null as iv.
     *
     * @param iv the initialization vector to use, null for ECB mode.
     * @param output the output the buffer to write to, null to create one.
     */
    start: function(C, A) {
      C && typeof C == "string" && (C = at.util.createBuffer(C)), r = !1, i = at.util.createBuffer(), n = A || new at.util.createBuffer(), s = C, S.output = n;
    },
    /**
     * Updates the next block.
     *
     * @param input the buffer to read from.
     */
    update: function(C) {
      for (r || i.putBuffer(C); i.length() >= 8; )
        m([
          [5, o],
          [1, l],
          [6, o],
          [1, l],
          [5, o]
        ]);
    },
    /**
     * Finishes encrypting or decrypting.
     *
     * @param pad a padding function to use, null for PKCS#7 padding,
     *           signature(blockSize, buffer, decrypt).
     *
     * @return true if successful, false on error.
     */
    finish: function(C) {
      var A = !0;
      if (a)
        if (C)
          A = C(8, i, !a);
        else {
          var b = i.length() === 8 ? 8 : 8 - i.length();
          i.fillWithByte(b, b);
        }
      if (A && (r = !0, S.update()), !a && (A = i.length() === 0, A))
        if (C)
          A = C(8, n, !a);
        else {
          var _ = n.length(), U = n.at(_ - 1);
          U > _ ? A = !1 : n.truncate(U);
        }
      return A;
    }
  }, S;
};
at.rc2.startEncrypting = function(e, t, a) {
  var r = at.rc2.createEncryptionCipher(e, 128);
  return r.start(t, a), r;
};
at.rc2.createEncryptionCipher = function(e, t) {
  return Li(e, t, !0);
};
at.rc2.startDecrypting = function(e, t, a) {
  var r = at.rc2.createDecryptionCipher(e, 128);
  return r.start(t, a), r;
};
at.rc2.createDecryptionCipher = function(e, t) {
  return Li(e, t, !1);
};
var da = ee;
da.jsbn = da.jsbn || {};
var _t;
function P(e, t, a) {
  this.data = [], e != null && (typeof e == "number" ? this.fromNumber(e, t, a) : t == null && typeof e != "string" ? this.fromString(e, 256) : this.fromString(e, t));
}
da.jsbn.BigInteger = P;
function fe() {
  return new P(null);
}
function ss(e, t, a, r, i, n) {
  for (; --n >= 0; ) {
    var s = t * this.data[e++] + a.data[r] + i;
    i = Math.floor(s / 67108864), a.data[r++] = s & 67108863;
  }
  return i;
}
function os(e, t, a, r, i, n) {
  for (var s = t & 32767, o = t >> 15; --n >= 0; ) {
    var l = this.data[e] & 32767, f = this.data[e++] >> 15, u = o * l + f * s;
    l = s * l + ((u & 32767) << 15) + a.data[r] + (i & 1073741823), i = (l >>> 30) + (u >>> 15) + o * f + (i >>> 30), a.data[r++] = l & 1073741823;
  }
  return i;
}
function ti(e, t, a, r, i, n) {
  for (var s = t & 16383, o = t >> 14; --n >= 0; ) {
    var l = this.data[e] & 16383, f = this.data[e++] >> 14, u = o * l + f * s;
    l = s * l + ((u & 16383) << 14) + a.data[r] + i, i = (l >> 28) + (u >> 14) + o * f, a.data[r++] = l & 268435455;
  }
  return i;
}
typeof navigator > "u" ? (P.prototype.am = ti, _t = 28) : navigator.appName == "Microsoft Internet Explorer" ? (P.prototype.am = os, _t = 30) : navigator.appName != "Netscape" ? (P.prototype.am = ss, _t = 26) : (P.prototype.am = ti, _t = 28);
P.prototype.DB = _t;
P.prototype.DM = (1 << _t) - 1;
P.prototype.DV = 1 << _t;
var Da = 52;
P.prototype.FV = Math.pow(2, Da);
P.prototype.F1 = Da - _t;
P.prototype.F2 = 2 * _t - Da;
var us = "0123456789abcdefghijklmnopqrstuvwxyz", Xr = new Array(), fr, ft;
fr = 48;
for (ft = 0; ft <= 9; ++ft) Xr[fr++] = ft;
fr = 97;
for (ft = 10; ft < 36; ++ft) Xr[fr++] = ft;
fr = 65;
for (ft = 10; ft < 36; ++ft) Xr[fr++] = ft;
function ri(e) {
  return us.charAt(e);
}
function Ui(e, t) {
  var a = Xr[e.charCodeAt(t)];
  return a ?? -1;
}
function fs(e) {
  for (var t = this.t - 1; t >= 0; --t) e.data[t] = this.data[t];
  e.t = this.t, e.s = this.s;
}
function ls(e) {
  this.t = 1, this.s = e < 0 ? -1 : 0, e > 0 ? this.data[0] = e : e < -1 ? this.data[0] = e + this.DV : this.t = 0;
}
function Ft(e) {
  var t = fe();
  return t.fromInt(e), t;
}
function cs(e, t) {
  var a;
  if (t == 16) a = 4;
  else if (t == 8) a = 3;
  else if (t == 256) a = 8;
  else if (t == 2) a = 1;
  else if (t == 32) a = 5;
  else if (t == 4) a = 2;
  else {
    this.fromRadix(e, t);
    return;
  }
  this.t = 0, this.s = 0;
  for (var r = e.length, i = !1, n = 0; --r >= 0; ) {
    var s = a == 8 ? e[r] & 255 : Ui(e, r);
    if (s < 0) {
      e.charAt(r) == "-" && (i = !0);
      continue;
    }
    i = !1, n == 0 ? this.data[this.t++] = s : n + a > this.DB ? (this.data[this.t - 1] |= (s & (1 << this.DB - n) - 1) << n, this.data[this.t++] = s >> this.DB - n) : this.data[this.t - 1] |= s << n, n += a, n >= this.DB && (n -= this.DB);
  }
  a == 8 && e[0] & 128 && (this.s = -1, n > 0 && (this.data[this.t - 1] |= (1 << this.DB - n) - 1 << n)), this.clamp(), i && P.ZERO.subTo(this, this);
}
function hs() {
  for (var e = this.s & this.DM; this.t > 0 && this.data[this.t - 1] == e; ) --this.t;
}
function ps(e) {
  if (this.s < 0) return "-" + this.negate().toString(e);
  var t;
  if (e == 16) t = 4;
  else if (e == 8) t = 3;
  else if (e == 2) t = 1;
  else if (e == 32) t = 5;
  else if (e == 4) t = 2;
  else return this.toRadix(e);
  var a = (1 << t) - 1, r, i = !1, n = "", s = this.t, o = this.DB - s * this.DB % t;
  if (s-- > 0)
    for (o < this.DB && (r = this.data[s] >> o) > 0 && (i = !0, n = ri(r)); s >= 0; )
      o < t ? (r = (this.data[s] & (1 << o) - 1) << t - o, r |= this.data[--s] >> (o += this.DB - t)) : (r = this.data[s] >> (o -= t) & a, o <= 0 && (o += this.DB, --s)), r > 0 && (i = !0), i && (n += ri(r));
  return i ? n : "0";
}
function ds() {
  var e = fe();
  return P.ZERO.subTo(this, e), e;
}
function ys() {
  return this.s < 0 ? this.negate() : this;
}
function gs(e) {
  var t = this.s - e.s;
  if (t != 0) return t;
  var a = this.t;
  if (t = a - e.t, t != 0) return this.s < 0 ? -t : t;
  for (; --a >= 0; ) if ((t = this.data[a] - e.data[a]) != 0) return t;
  return 0;
}
function Wr(e) {
  var t = 1, a;
  return (a = e >>> 16) != 0 && (e = a, t += 16), (a = e >> 8) != 0 && (e = a, t += 8), (a = e >> 4) != 0 && (e = a, t += 4), (a = e >> 2) != 0 && (e = a, t += 2), (a = e >> 1) != 0 && (e = a, t += 1), t;
}
function vs() {
  return this.t <= 0 ? 0 : this.DB * (this.t - 1) + Wr(this.data[this.t - 1] ^ this.s & this.DM);
}
function ms(e, t) {
  var a;
  for (a = this.t - 1; a >= 0; --a) t.data[a + e] = this.data[a];
  for (a = e - 1; a >= 0; --a) t.data[a] = 0;
  t.t = this.t + e, t.s = this.s;
}
function Cs(e, t) {
  for (var a = e; a < this.t; ++a) t.data[a - e] = this.data[a];
  t.t = Math.max(this.t - e, 0), t.s = this.s;
}
function Es(e, t) {
  var a = e % this.DB, r = this.DB - a, i = (1 << r) - 1, n = Math.floor(e / this.DB), s = this.s << a & this.DM, o;
  for (o = this.t - 1; o >= 0; --o)
    t.data[o + n + 1] = this.data[o] >> r | s, s = (this.data[o] & i) << a;
  for (o = n - 1; o >= 0; --o) t.data[o] = 0;
  t.data[n] = s, t.t = this.t + n + 1, t.s = this.s, t.clamp();
}
function xs(e, t) {
  t.s = this.s;
  var a = Math.floor(e / this.DB);
  if (a >= this.t) {
    t.t = 0;
    return;
  }
  var r = e % this.DB, i = this.DB - r, n = (1 << r) - 1;
  t.data[0] = this.data[a] >> r;
  for (var s = a + 1; s < this.t; ++s)
    t.data[s - a - 1] |= (this.data[s] & n) << i, t.data[s - a] = this.data[s] >> r;
  r > 0 && (t.data[this.t - a - 1] |= (this.s & n) << i), t.t = this.t - a, t.clamp();
}
function Ss(e, t) {
  for (var a = 0, r = 0, i = Math.min(e.t, this.t); a < i; )
    r += this.data[a] - e.data[a], t.data[a++] = r & this.DM, r >>= this.DB;
  if (e.t < this.t) {
    for (r -= e.s; a < this.t; )
      r += this.data[a], t.data[a++] = r & this.DM, r >>= this.DB;
    r += this.s;
  } else {
    for (r += this.s; a < e.t; )
      r -= e.data[a], t.data[a++] = r & this.DM, r >>= this.DB;
    r -= e.s;
  }
  t.s = r < 0 ? -1 : 0, r < -1 ? t.data[a++] = this.DV + r : r > 0 && (t.data[a++] = r), t.t = a, t.clamp();
}
function Ts(e, t) {
  var a = this.abs(), r = e.abs(), i = a.t;
  for (t.t = i + r.t; --i >= 0; ) t.data[i] = 0;
  for (i = 0; i < r.t; ++i) t.data[i + a.t] = a.am(0, r.data[i], t, i, 0, a.t);
  t.s = 0, t.clamp(), this.s != e.s && P.ZERO.subTo(t, t);
}
function Is(e) {
  for (var t = this.abs(), a = e.t = 2 * t.t; --a >= 0; ) e.data[a] = 0;
  for (a = 0; a < t.t - 1; ++a) {
    var r = t.am(a, t.data[a], e, 2 * a, 0, 1);
    (e.data[a + t.t] += t.am(a + 1, 2 * t.data[a], e, 2 * a + 1, r, t.t - a - 1)) >= t.DV && (e.data[a + t.t] -= t.DV, e.data[a + t.t + 1] = 1);
  }
  e.t > 0 && (e.data[e.t - 1] += t.am(a, t.data[a], e, 2 * a, 0, 1)), e.s = 0, e.clamp();
}
function Bs(e, t, a) {
  var r = e.abs();
  if (!(r.t <= 0)) {
    var i = this.abs();
    if (i.t < r.t) {
      t?.fromInt(0), a != null && this.copyTo(a);
      return;
    }
    a == null && (a = fe());
    var n = fe(), s = this.s, o = e.s, l = this.DB - Wr(r.data[r.t - 1]);
    l > 0 ? (r.lShiftTo(l, n), i.lShiftTo(l, a)) : (r.copyTo(n), i.copyTo(a));
    var f = n.t, u = n.data[f - 1];
    if (u != 0) {
      var p = u * (1 << this.F1) + (f > 1 ? n.data[f - 2] >> this.F2 : 0), m = this.FV / p, S = (1 << this.F1) / p, C = 1 << this.F2, A = a.t, b = A - f, _ = t ?? fe();
      for (n.dlShiftTo(b, _), a.compareTo(_) >= 0 && (a.data[a.t++] = 1, a.subTo(_, a)), P.ONE.dlShiftTo(f, _), _.subTo(n, n); n.t < f; ) n.data[n.t++] = 0;
      for (; --b >= 0; ) {
        var U = a.data[--A] == u ? this.DM : Math.floor(a.data[A] * m + (a.data[A - 1] + C) * S);
        if ((a.data[A] += n.am(0, U, a, b, 0, f)) < U)
          for (n.dlShiftTo(b, _), a.subTo(_, a); a.data[A] < --U; ) a.subTo(_, a);
      }
      t != null && (a.drShiftTo(f, t), s != o && P.ZERO.subTo(t, t)), a.t = f, a.clamp(), l > 0 && a.rShiftTo(l, a), s < 0 && P.ZERO.subTo(a, a);
    }
  }
}
function As(e) {
  var t = fe();
  return this.abs().divRemTo(e, null, t), this.s < 0 && t.compareTo(P.ZERO) > 0 && e.subTo(t, t), t;
}
function $t(e) {
  this.m = e;
}
function bs(e) {
  return e.s < 0 || e.compareTo(this.m) >= 0 ? e.mod(this.m) : e;
}
function ws(e) {
  return e;
}
function _s(e) {
  e.divRemTo(this.m, null, e);
}
function Ns(e, t, a) {
  e.multiplyTo(t, a), this.reduce(a);
}
function Rs(e, t) {
  e.squareTo(t), this.reduce(t);
}
$t.prototype.convert = bs;
$t.prototype.revert = ws;
$t.prototype.reduce = _s;
$t.prototype.mulTo = Ns;
$t.prototype.sqrTo = Rs;
function Ls() {
  if (this.t < 1) return 0;
  var e = this.data[0];
  if (!(e & 1)) return 0;
  var t = e & 3;
  return t = t * (2 - (e & 15) * t) & 15, t = t * (2 - (e & 255) * t) & 255, t = t * (2 - ((e & 65535) * t & 65535)) & 65535, t = t * (2 - e * t % this.DV) % this.DV, t > 0 ? this.DV - t : -t;
}
function jt(e) {
  this.m = e, this.mp = e.invDigit(), this.mpl = this.mp & 32767, this.mph = this.mp >> 15, this.um = (1 << e.DB - 15) - 1, this.mt2 = 2 * e.t;
}
function Us(e) {
  var t = fe();
  return e.abs().dlShiftTo(this.m.t, t), t.divRemTo(this.m, null, t), e.s < 0 && t.compareTo(P.ZERO) > 0 && this.m.subTo(t, t), t;
}
function Ds(e) {
  var t = fe();
  return e.copyTo(t), this.reduce(t), t;
}
function ks(e) {
  for (; e.t <= this.mt2; )
    e.data[e.t++] = 0;
  for (var t = 0; t < this.m.t; ++t) {
    var a = e.data[t] & 32767, r = a * this.mpl + ((a * this.mph + (e.data[t] >> 15) * this.mpl & this.um) << 15) & e.DM;
    for (a = t + this.m.t, e.data[a] += this.m.am(0, r, e, t, 0, this.m.t); e.data[a] >= e.DV; )
      e.data[a] -= e.DV, e.data[++a]++;
  }
  e.clamp(), e.drShiftTo(this.m.t, e), e.compareTo(this.m) >= 0 && e.subTo(this.m, e);
}
function Ps(e, t) {
  e.squareTo(t), this.reduce(t);
}
function Vs(e, t, a) {
  e.multiplyTo(t, a), this.reduce(a);
}
jt.prototype.convert = Us;
jt.prototype.revert = Ds;
jt.prototype.reduce = ks;
jt.prototype.mulTo = Vs;
jt.prototype.sqrTo = Ps;
function Fs() {
  return (this.t > 0 ? this.data[0] & 1 : this.s) == 0;
}
function Os(e, t) {
  if (e > 4294967295 || e < 1) return P.ONE;
  var a = fe(), r = fe(), i = t.convert(this), n = Wr(e) - 1;
  for (i.copyTo(a); --n >= 0; )
    if (t.sqrTo(a, r), (e & 1 << n) > 0) t.mulTo(r, i, a);
    else {
      var s = a;
      a = r, r = s;
    }
  return t.revert(a);
}
function Ks(e, t) {
  var a;
  return e < 256 || t.isEven() ? a = new $t(t) : a = new jt(t), this.exp(e, a);
}
P.prototype.copyTo = fs;
P.prototype.fromInt = ls;
P.prototype.fromString = cs;
P.prototype.clamp = hs;
P.prototype.dlShiftTo = ms;
P.prototype.drShiftTo = Cs;
P.prototype.lShiftTo = Es;
P.prototype.rShiftTo = xs;
P.prototype.subTo = Ss;
P.prototype.multiplyTo = Ts;
P.prototype.squareTo = Is;
P.prototype.divRemTo = Bs;
P.prototype.invDigit = Ls;
P.prototype.isEven = Fs;
P.prototype.exp = Os;
P.prototype.toString = ps;
P.prototype.negate = ds;
P.prototype.abs = ys;
P.prototype.compareTo = gs;
P.prototype.bitLength = vs;
P.prototype.mod = As;
P.prototype.modPowInt = Ks;
P.ZERO = Ft(0);
P.ONE = Ft(1);
function Ms() {
  var e = fe();
  return this.copyTo(e), e;
}
function Hs() {
  if (this.s < 0) {
    if (this.t == 1) return this.data[0] - this.DV;
    if (this.t == 0) return -1;
  } else {
    if (this.t == 1) return this.data[0];
    if (this.t == 0) return 0;
  }
  return (this.data[1] & (1 << 32 - this.DB) - 1) << this.DB | this.data[0];
}
function Gs() {
  return this.t == 0 ? this.s : this.data[0] << 24 >> 24;
}
function qs() {
  return this.t == 0 ? this.s : this.data[0] << 16 >> 16;
}
function Qs(e) {
  return Math.floor(Math.LN2 * this.DB / Math.log(e));
}
function zs() {
  return this.s < 0 ? -1 : this.t <= 0 || this.t == 1 && this.data[0] <= 0 ? 0 : 1;
}
function Ys(e) {
  if (e == null && (e = 10), this.signum() == 0 || e < 2 || e > 36) return "0";
  var t = this.chunkSize(e), a = Math.pow(e, t), r = Ft(a), i = fe(), n = fe(), s = "";
  for (this.divRemTo(r, i, n); i.signum() > 0; )
    s = (a + n.intValue()).toString(e).substr(1) + s, i.divRemTo(r, i, n);
  return n.intValue().toString(e) + s;
}
function Xs(e, t) {
  this.fromInt(0), t == null && (t = 10);
  for (var a = this.chunkSize(t), r = Math.pow(t, a), i = !1, n = 0, s = 0, o = 0; o < e.length; ++o) {
    var l = Ui(e, o);
    if (l < 0) {
      e.charAt(o) == "-" && this.signum() == 0 && (i = !0);
      continue;
    }
    s = t * s + l, ++n >= a && (this.dMultiply(r), this.dAddOffset(s, 0), n = 0, s = 0);
  }
  n > 0 && (this.dMultiply(Math.pow(t, n)), this.dAddOffset(s, 0)), i && P.ZERO.subTo(this, this);
}
function Ws(e, t, a) {
  if (typeof t == "number")
    if (e < 2) this.fromInt(1);
    else
      for (this.fromNumber(e, a), this.testBit(e - 1) || this.bitwiseTo(P.ONE.shiftLeft(e - 1), ka, this), this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(t); )
        this.dAddOffset(2, 0), this.bitLength() > e && this.subTo(P.ONE.shiftLeft(e - 1), this);
  else {
    var r = new Array(), i = e & 7;
    r.length = (e >> 3) + 1, t.nextBytes(r), i > 0 ? r[0] &= (1 << i) - 1 : r[0] = 0, this.fromString(r, 256);
  }
}
function $s() {
  var e = this.t, t = new Array();
  t[0] = this.s;
  var a = this.DB - e * this.DB % 8, r, i = 0;
  if (e-- > 0)
    for (a < this.DB && (r = this.data[e] >> a) != (this.s & this.DM) >> a && (t[i++] = r | this.s << this.DB - a); e >= 0; )
      a < 8 ? (r = (this.data[e] & (1 << a) - 1) << 8 - a, r |= this.data[--e] >> (a += this.DB - 8)) : (r = this.data[e] >> (a -= 8) & 255, a <= 0 && (a += this.DB, --e)), r & 128 && (r |= -256), i == 0 && (this.s & 128) != (r & 128) && ++i, (i > 0 || r != this.s) && (t[i++] = r);
  return t;
}
function js(e) {
  return this.compareTo(e) == 0;
}
function Zs(e) {
  return this.compareTo(e) < 0 ? this : e;
}
function Js(e) {
  return this.compareTo(e) > 0 ? this : e;
}
function eo(e, t, a) {
  var r, i, n = Math.min(e.t, this.t);
  for (r = 0; r < n; ++r) a.data[r] = t(this.data[r], e.data[r]);
  if (e.t < this.t) {
    for (i = e.s & this.DM, r = n; r < this.t; ++r) a.data[r] = t(this.data[r], i);
    a.t = this.t;
  } else {
    for (i = this.s & this.DM, r = n; r < e.t; ++r) a.data[r] = t(i, e.data[r]);
    a.t = e.t;
  }
  a.s = t(this.s, e.s), a.clamp();
}
function to(e, t) {
  return e & t;
}
function ro(e) {
  var t = fe();
  return this.bitwiseTo(e, to, t), t;
}
function ka(e, t) {
  return e | t;
}
function ao(e) {
  var t = fe();
  return this.bitwiseTo(e, ka, t), t;
}
function Di(e, t) {
  return e ^ t;
}
function io(e) {
  var t = fe();
  return this.bitwiseTo(e, Di, t), t;
}
function ki(e, t) {
  return e & ~t;
}
function no(e) {
  var t = fe();
  return this.bitwiseTo(e, ki, t), t;
}
function so() {
  for (var e = fe(), t = 0; t < this.t; ++t) e.data[t] = this.DM & ~this.data[t];
  return e.t = this.t, e.s = ~this.s, e;
}
function oo(e) {
  var t = fe();
  return e < 0 ? this.rShiftTo(-e, t) : this.lShiftTo(e, t), t;
}
function uo(e) {
  var t = fe();
  return e < 0 ? this.lShiftTo(-e, t) : this.rShiftTo(e, t), t;
}
function fo(e) {
  if (e == 0) return -1;
  var t = 0;
  return e & 65535 || (e >>= 16, t += 16), e & 255 || (e >>= 8, t += 8), e & 15 || (e >>= 4, t += 4), e & 3 || (e >>= 2, t += 2), e & 1 || ++t, t;
}
function lo() {
  for (var e = 0; e < this.t; ++e)
    if (this.data[e] != 0) return e * this.DB + fo(this.data[e]);
  return this.s < 0 ? this.t * this.DB : -1;
}
function co(e) {
  for (var t = 0; e != 0; )
    e &= e - 1, ++t;
  return t;
}
function ho() {
  for (var e = 0, t = this.s & this.DM, a = 0; a < this.t; ++a) e += co(this.data[a] ^ t);
  return e;
}
function po(e) {
  var t = Math.floor(e / this.DB);
  return t >= this.t ? this.s != 0 : (this.data[t] & 1 << e % this.DB) != 0;
}
function yo(e, t) {
  var a = P.ONE.shiftLeft(e);
  return this.bitwiseTo(a, t, a), a;
}
function go(e) {
  return this.changeBit(e, ka);
}
function vo(e) {
  return this.changeBit(e, ki);
}
function mo(e) {
  return this.changeBit(e, Di);
}
function Co(e, t) {
  for (var a = 0, r = 0, i = Math.min(e.t, this.t); a < i; )
    r += this.data[a] + e.data[a], t.data[a++] = r & this.DM, r >>= this.DB;
  if (e.t < this.t) {
    for (r += e.s; a < this.t; )
      r += this.data[a], t.data[a++] = r & this.DM, r >>= this.DB;
    r += this.s;
  } else {
    for (r += this.s; a < e.t; )
      r += e.data[a], t.data[a++] = r & this.DM, r >>= this.DB;
    r += e.s;
  }
  t.s = r < 0 ? -1 : 0, r > 0 ? t.data[a++] = r : r < -1 && (t.data[a++] = this.DV + r), t.t = a, t.clamp();
}
function Eo(e) {
  var t = fe();
  return this.addTo(e, t), t;
}
function xo(e) {
  var t = fe();
  return this.subTo(e, t), t;
}
function So(e) {
  var t = fe();
  return this.multiplyTo(e, t), t;
}
function To(e) {
  var t = fe();
  return this.divRemTo(e, t, null), t;
}
function Io(e) {
  var t = fe();
  return this.divRemTo(e, null, t), t;
}
function Bo(e) {
  var t = fe(), a = fe();
  return this.divRemTo(e, t, a), new Array(t, a);
}
function Ao(e) {
  this.data[this.t] = this.am(0, e - 1, this, 0, 0, this.t), ++this.t, this.clamp();
}
function bo(e, t) {
  if (e != 0) {
    for (; this.t <= t; ) this.data[this.t++] = 0;
    for (this.data[t] += e; this.data[t] >= this.DV; )
      this.data[t] -= this.DV, ++t >= this.t && (this.data[this.t++] = 0), ++this.data[t];
  }
}
function Sr() {
}
function Pi(e) {
  return e;
}
function wo(e, t, a) {
  e.multiplyTo(t, a);
}
function _o(e, t) {
  e.squareTo(t);
}
Sr.prototype.convert = Pi;
Sr.prototype.revert = Pi;
Sr.prototype.mulTo = wo;
Sr.prototype.sqrTo = _o;
function No(e) {
  return this.exp(e, new Sr());
}
function Ro(e, t, a) {
  var r = Math.min(this.t + e.t, t);
  for (a.s = 0, a.t = r; r > 0; ) a.data[--r] = 0;
  var i;
  for (i = a.t - this.t; r < i; ++r) a.data[r + this.t] = this.am(0, e.data[r], a, r, 0, this.t);
  for (i = Math.min(e.t, t); r < i; ++r) this.am(0, e.data[r], a, r, 0, t - r);
  a.clamp();
}
function Lo(e, t, a) {
  --t;
  var r = a.t = this.t + e.t - t;
  for (a.s = 0; --r >= 0; ) a.data[r] = 0;
  for (r = Math.max(t - this.t, 0); r < e.t; ++r)
    a.data[this.t + r - t] = this.am(t - r, e.data[r], a, 0, 0, this.t + r - t);
  a.clamp(), a.drShiftTo(1, a);
}
function lr(e) {
  this.r2 = fe(), this.q3 = fe(), P.ONE.dlShiftTo(2 * e.t, this.r2), this.mu = this.r2.divide(e), this.m = e;
}
function Uo(e) {
  if (e.s < 0 || e.t > 2 * this.m.t) return e.mod(this.m);
  if (e.compareTo(this.m) < 0) return e;
  var t = fe();
  return e.copyTo(t), this.reduce(t), t;
}
function Do(e) {
  return e;
}
function ko(e) {
  for (e.drShiftTo(this.m.t - 1, this.r2), e.t > this.m.t + 1 && (e.t = this.m.t + 1, e.clamp()), this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3), this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); e.compareTo(this.r2) < 0; ) e.dAddOffset(1, this.m.t + 1);
  for (e.subTo(this.r2, e); e.compareTo(this.m) >= 0; ) e.subTo(this.m, e);
}
function Po(e, t) {
  e.squareTo(t), this.reduce(t);
}
function Vo(e, t, a) {
  e.multiplyTo(t, a), this.reduce(a);
}
lr.prototype.convert = Uo;
lr.prototype.revert = Do;
lr.prototype.reduce = ko;
lr.prototype.mulTo = Vo;
lr.prototype.sqrTo = Po;
function Fo(e, t) {
  var a = e.bitLength(), r, i = Ft(1), n;
  if (a <= 0) return i;
  a < 18 ? r = 1 : a < 48 ? r = 3 : a < 144 ? r = 4 : a < 768 ? r = 5 : r = 6, a < 8 ? n = new $t(t) : t.isEven() ? n = new lr(t) : n = new jt(t);
  var s = new Array(), o = 3, l = r - 1, f = (1 << r) - 1;
  if (s[1] = n.convert(this), r > 1) {
    var u = fe();
    for (n.sqrTo(s[1], u); o <= f; )
      s[o] = fe(), n.mulTo(u, s[o - 2], s[o]), o += 2;
  }
  var p = e.t - 1, m, S = !0, C = fe(), A;
  for (a = Wr(e.data[p]) - 1; p >= 0; ) {
    for (a >= l ? m = e.data[p] >> a - l & f : (m = (e.data[p] & (1 << a + 1) - 1) << l - a, p > 0 && (m |= e.data[p - 1] >> this.DB + a - l)), o = r; !(m & 1); )
      m >>= 1, --o;
    if ((a -= o) < 0 && (a += this.DB, --p), S)
      s[m].copyTo(i), S = !1;
    else {
      for (; o > 1; )
        n.sqrTo(i, C), n.sqrTo(C, i), o -= 2;
      o > 0 ? n.sqrTo(i, C) : (A = i, i = C, C = A), n.mulTo(C, s[m], i);
    }
    for (; p >= 0 && !(e.data[p] & 1 << a); )
      n.sqrTo(i, C), A = i, i = C, C = A, --a < 0 && (a = this.DB - 1, --p);
  }
  return n.revert(i);
}
function Oo(e) {
  var t = this.s < 0 ? this.negate() : this.clone(), a = e.s < 0 ? e.negate() : e.clone();
  if (t.compareTo(a) < 0) {
    var r = t;
    t = a, a = r;
  }
  var i = t.getLowestSetBit(), n = a.getLowestSetBit();
  if (n < 0) return t;
  for (i < n && (n = i), n > 0 && (t.rShiftTo(n, t), a.rShiftTo(n, a)); t.signum() > 0; )
    (i = t.getLowestSetBit()) > 0 && t.rShiftTo(i, t), (i = a.getLowestSetBit()) > 0 && a.rShiftTo(i, a), t.compareTo(a) >= 0 ? (t.subTo(a, t), t.rShiftTo(1, t)) : (a.subTo(t, a), a.rShiftTo(1, a));
  return n > 0 && a.lShiftTo(n, a), a;
}
function Ko(e) {
  if (e <= 0) return 0;
  var t = this.DV % e, a = this.s < 0 ? e - 1 : 0;
  if (this.t > 0)
    if (t == 0) a = this.data[0] % e;
    else for (var r = this.t - 1; r >= 0; --r) a = (t * a + this.data[r]) % e;
  return a;
}
function Mo(e) {
  var t = e.isEven();
  if (this.isEven() && t || e.signum() == 0) return P.ZERO;
  for (var a = e.clone(), r = this.clone(), i = Ft(1), n = Ft(0), s = Ft(0), o = Ft(1); a.signum() != 0; ) {
    for (; a.isEven(); )
      a.rShiftTo(1, a), t ? ((!i.isEven() || !n.isEven()) && (i.addTo(this, i), n.subTo(e, n)), i.rShiftTo(1, i)) : n.isEven() || n.subTo(e, n), n.rShiftTo(1, n);
    for (; r.isEven(); )
      r.rShiftTo(1, r), t ? ((!s.isEven() || !o.isEven()) && (s.addTo(this, s), o.subTo(e, o)), s.rShiftTo(1, s)) : o.isEven() || o.subTo(e, o), o.rShiftTo(1, o);
    a.compareTo(r) >= 0 ? (a.subTo(r, a), t && i.subTo(s, i), n.subTo(o, n)) : (r.subTo(a, r), t && s.subTo(i, s), o.subTo(n, o));
  }
  if (r.compareTo(P.ONE) != 0) return P.ZERO;
  if (o.compareTo(e) >= 0) return o.subtract(e);
  if (o.signum() < 0) o.addTo(e, o);
  else return o;
  return o.signum() < 0 ? o.add(e) : o;
}
var dt = [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], Ho = (1 << 26) / dt[dt.length - 1];
function Go(e) {
  var t, a = this.abs();
  if (a.t == 1 && a.data[0] <= dt[dt.length - 1]) {
    for (t = 0; t < dt.length; ++t)
      if (a.data[0] == dt[t]) return !0;
    return !1;
  }
  if (a.isEven()) return !1;
  for (t = 1; t < dt.length; ) {
    for (var r = dt[t], i = t + 1; i < dt.length && r < Ho; ) r *= dt[i++];
    for (r = a.modInt(r); t < i; ) if (r % dt[t++] == 0) return !1;
  }
  return a.millerRabin(e);
}
function qo(e) {
  var t = this.subtract(P.ONE), a = t.getLowestSetBit();
  if (a <= 0) return !1;
  for (var r = t.shiftRight(a), i = Qo(), n, s = 0; s < e; ++s) {
    do
      n = new P(this.bitLength(), i);
    while (n.compareTo(P.ONE) <= 0 || n.compareTo(t) >= 0);
    var o = n.modPow(r, this);
    if (o.compareTo(P.ONE) != 0 && o.compareTo(t) != 0) {
      for (var l = 1; l++ < a && o.compareTo(t) != 0; )
        if (o = o.modPowInt(2, this), o.compareTo(P.ONE) == 0) return !1;
      if (o.compareTo(t) != 0) return !1;
    }
  }
  return !0;
}
function Qo() {
  return {
    // x is an array to fill with bytes
    nextBytes: function(e) {
      for (var t = 0; t < e.length; ++t)
        e[t] = Math.floor(Math.random() * 256);
    }
  };
}
P.prototype.chunkSize = Qs;
P.prototype.toRadix = Ys;
P.prototype.fromRadix = Xs;
P.prototype.fromNumber = Ws;
P.prototype.bitwiseTo = eo;
P.prototype.changeBit = yo;
P.prototype.addTo = Co;
P.prototype.dMultiply = Ao;
P.prototype.dAddOffset = bo;
P.prototype.multiplyLowerTo = Ro;
P.prototype.multiplyUpperTo = Lo;
P.prototype.modInt = Ko;
P.prototype.millerRabin = qo;
P.prototype.clone = Ms;
P.prototype.intValue = Hs;
P.prototype.byteValue = Gs;
P.prototype.shortValue = qs;
P.prototype.signum = zs;
P.prototype.toByteArray = $s;
P.prototype.equals = js;
P.prototype.min = Zs;
P.prototype.max = Js;
P.prototype.and = ro;
P.prototype.or = ao;
P.prototype.xor = io;
P.prototype.andNot = no;
P.prototype.not = so;
P.prototype.shiftLeft = oo;
P.prototype.shiftRight = uo;
P.prototype.getLowestSetBit = lo;
P.prototype.bitCount = ho;
P.prototype.testBit = po;
P.prototype.setBit = go;
P.prototype.clearBit = vo;
P.prototype.flipBit = mo;
P.prototype.add = Eo;
P.prototype.subtract = xo;
P.prototype.multiply = So;
P.prototype.divide = To;
P.prototype.remainder = Io;
P.prototype.divideAndRemainder = Bo;
P.prototype.modPow = Fo;
P.prototype.modInverse = Mo;
P.prototype.pow = No;
P.prototype.gcd = Oo;
P.prototype.isProbablePrime = Go;
var It = ee, Vi = It.sha1 = It.sha1 || {};
It.md.sha1 = It.md.algorithms.sha1 = Vi;
Vi.create = function() {
  Fi || zo();
  var e = null, t = It.util.createBuffer(), a = new Array(80), r = {
    algorithm: "sha1",
    blockLength: 64,
    digestLength: 20,
    // 56-bit length of message so far (does not including padding)
    messageLength: 0,
    // true message length
    fullMessageLength: null,
    // size of message length in bytes
    messageLengthSize: 8
  };
  return r.start = function() {
    r.messageLength = 0, r.fullMessageLength = r.messageLength64 = [];
    for (var i = r.messageLengthSize / 4, n = 0; n < i; ++n)
      r.fullMessageLength.push(0);
    return t = It.util.createBuffer(), e = {
      h0: 1732584193,
      h1: 4023233417,
      h2: 2562383102,
      h3: 271733878,
      h4: 3285377520
    }, r;
  }, r.start(), r.update = function(i, n) {
    n === "utf8" && (i = It.util.encodeUtf8(i));
    var s = i.length;
    r.messageLength += s, s = [s / 4294967296 >>> 0, s >>> 0];
    for (var o = r.fullMessageLength.length - 1; o >= 0; --o)
      r.fullMessageLength[o] += s[1], s[1] = s[0] + (r.fullMessageLength[o] / 4294967296 >>> 0), r.fullMessageLength[o] = r.fullMessageLength[o] >>> 0, s[0] = s[1] / 4294967296 >>> 0;
    return t.putBytes(i), ai(e, a, t), (t.read > 2048 || t.length() === 0) && t.compact(), r;
  }, r.digest = function() {
    var i = It.util.createBuffer();
    i.putBytes(t.bytes());
    var n = r.fullMessageLength[r.fullMessageLength.length - 1] + r.messageLengthSize, s = n & r.blockLength - 1;
    i.putBytes(ya.substr(0, r.blockLength - s));
    for (var o, l, f = r.fullMessageLength[0] * 8, u = 0; u < r.fullMessageLength.length - 1; ++u)
      o = r.fullMessageLength[u + 1] * 8, l = o / 4294967296 >>> 0, f += l, i.putInt32(f >>> 0), f = o >>> 0;
    i.putInt32(f);
    var p = {
      h0: e.h0,
      h1: e.h1,
      h2: e.h2,
      h3: e.h3,
      h4: e.h4
    };
    ai(p, a, i);
    var m = It.util.createBuffer();
    return m.putInt32(p.h0), m.putInt32(p.h1), m.putInt32(p.h2), m.putInt32(p.h3), m.putInt32(p.h4), m;
  }, r;
};
var ya = null, Fi = !1;
function zo() {
  ya = "€", ya += It.util.fillString("\0", 64), Fi = !0;
}
function ai(e, t, a) {
  for (var r, i, n, s, o, l, f, u, p = a.length(); p >= 64; ) {
    for (i = e.h0, n = e.h1, s = e.h2, o = e.h3, l = e.h4, u = 0; u < 16; ++u)
      r = a.getInt32(), t[u] = r, f = o ^ n & (s ^ o), r = (i << 5 | i >>> 27) + f + l + 1518500249 + r, l = o, o = s, s = (n << 30 | n >>> 2) >>> 0, n = i, i = r;
    for (; u < 20; ++u)
      r = t[u - 3] ^ t[u - 8] ^ t[u - 14] ^ t[u - 16], r = r << 1 | r >>> 31, t[u] = r, f = o ^ n & (s ^ o), r = (i << 5 | i >>> 27) + f + l + 1518500249 + r, l = o, o = s, s = (n << 30 | n >>> 2) >>> 0, n = i, i = r;
    for (; u < 32; ++u)
      r = t[u - 3] ^ t[u - 8] ^ t[u - 14] ^ t[u - 16], r = r << 1 | r >>> 31, t[u] = r, f = n ^ s ^ o, r = (i << 5 | i >>> 27) + f + l + 1859775393 + r, l = o, o = s, s = (n << 30 | n >>> 2) >>> 0, n = i, i = r;
    for (; u < 40; ++u)
      r = t[u - 6] ^ t[u - 16] ^ t[u - 28] ^ t[u - 32], r = r << 2 | r >>> 30, t[u] = r, f = n ^ s ^ o, r = (i << 5 | i >>> 27) + f + l + 1859775393 + r, l = o, o = s, s = (n << 30 | n >>> 2) >>> 0, n = i, i = r;
    for (; u < 60; ++u)
      r = t[u - 6] ^ t[u - 16] ^ t[u - 28] ^ t[u - 32], r = r << 2 | r >>> 30, t[u] = r, f = n & s | o & (n ^ s), r = (i << 5 | i >>> 27) + f + l + 2400959708 + r, l = o, o = s, s = (n << 30 | n >>> 2) >>> 0, n = i, i = r;
    for (; u < 80; ++u)
      r = t[u - 6] ^ t[u - 16] ^ t[u - 28] ^ t[u - 32], r = r << 2 | r >>> 30, t[u] = r, f = n ^ s ^ o, r = (i << 5 | i >>> 27) + f + l + 3395469782 + r, l = o, o = s, s = (n << 30 | n >>> 2) >>> 0, n = i, i = r;
    e.h0 = e.h0 + i | 0, e.h1 = e.h1 + n | 0, e.h2 = e.h2 + s | 0, e.h3 = e.h3 + o | 0, e.h4 = e.h4 + l | 0, p -= 64;
  }
}
var Bt = ee, Oi = Bt.pkcs1 = Bt.pkcs1 || {};
Oi.encode_rsa_oaep = function(e, t, a) {
  var r, i, n, s;
  typeof a == "string" ? (r = a, i = arguments[3] || void 0, n = arguments[4] || void 0) : a && (r = a.label || void 0, i = a.seed || void 0, n = a.md || void 0, a.mgf1 && a.mgf1.md && (s = a.mgf1.md)), n ? n.start() : n = Bt.md.sha1.create(), s || (s = n);
  var o = Math.ceil(e.n.bitLength() / 8), l = o - 2 * n.digestLength - 2;
  if (t.length > l) {
    var f = new Error("RSAES-OAEP input message length is too long.");
    throw f.length = t.length, f.maxLength = l, f;
  }
  r || (r = ""), n.update(r, "raw");
  for (var u = n.digest(), p = "", m = l - t.length, S = 0; S < m; S++)
    p += "\0";
  var C = u.getBytes() + p + "" + t;
  if (!i)
    i = Bt.random.getBytes(n.digestLength);
  else if (i.length !== n.digestLength) {
    var f = new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");
    throw f.seedLength = i.length, f.digestLength = n.digestLength, f;
  }
  var A = Dr(i, o - n.digestLength - 1, s), b = Bt.util.xorBytes(C, A, C.length), _ = Dr(b, n.digestLength, s), U = Bt.util.xorBytes(i, _, i.length);
  return "\0" + U + b;
};
Oi.decode_rsa_oaep = function(e, t, a) {
  var r, i, n;
  typeof a == "string" ? (r = a, i = arguments[3] || void 0) : a && (r = a.label || void 0, i = a.md || void 0, a.mgf1 && a.mgf1.md && (n = a.mgf1.md));
  var s = Math.ceil(e.n.bitLength() / 8);
  if (t.length !== s) {
    var b = new Error("RSAES-OAEP encoded message length is invalid.");
    throw b.length = t.length, b.expectedLength = s, b;
  }
  if (i === void 0 ? i = Bt.md.sha1.create() : i.start(), n || (n = i), s < 2 * i.digestLength + 2)
    throw new Error("RSAES-OAEP key is too short for the hash function.");
  r || (r = ""), i.update(r, "raw");
  for (var o = i.digest().getBytes(), l = t.charAt(0), f = t.substring(1, i.digestLength + 1), u = t.substring(1 + i.digestLength), p = Dr(u, i.digestLength, n), m = Bt.util.xorBytes(f, p, f.length), S = Dr(m, s - i.digestLength - 1, n), C = Bt.util.xorBytes(u, S, u.length), A = C.substring(0, i.digestLength), b = l !== "\0", _ = 0; _ < i.digestLength; ++_)
    b |= o.charAt(_) !== A.charAt(_);
  for (var U = 1, D = i.digestLength, G = i.digestLength; G < C.length; G++) {
    var O = C.charCodeAt(G), F = O & 1 ^ 1, $ = U ? 65534 : 0;
    b |= O & $, U = U & F, D += U;
  }
  if (b || C.charCodeAt(D) !== 1)
    throw new Error("Invalid RSAES-OAEP padding.");
  return C.substring(D + 1);
};
function Dr(e, t, a) {
  a || (a = Bt.md.sha1.create());
  for (var r = "", i = Math.ceil(t / a.digestLength), n = 0; n < i; ++n) {
    var s = String.fromCharCode(
      n >> 24 & 255,
      n >> 16 & 255,
      n >> 8 & 255,
      n & 255
    );
    a.start(), a.update(e + s), r += a.digest().getBytes();
  }
  return r.substring(0, t);
}
var Ut = ee;
(function() {
  if (Ut.prime) {
    Ut.prime;
    return;
  }
  var e = Ut.prime = Ut.prime || {}, t = Ut.jsbn.BigInteger, a = [6, 4, 2, 4, 2, 4, 6, 2], r = new t(null);
  r.fromInt(30);
  var i = function(p, m) {
    return p | m;
  };
  e.generateProbablePrime = function(p, m, S) {
    typeof m == "function" && (S = m, m = {}), m = m || {};
    var C = m.algorithm || "PRIMEINC";
    typeof C == "string" && (C = { name: C }), C.options = C.options || {};
    var A = m.prng || Ut.random, b = {
      // x is an array to fill with bytes
      nextBytes: function(_) {
        for (var U = A.getBytesSync(_.length), D = 0; D < _.length; ++D)
          _[D] = U.charCodeAt(D);
      }
    };
    if (C.name === "PRIMEINC")
      return n(p, b, C.options, S);
    throw new Error("Invalid prime generation algorithm: " + C.name);
  };
  function n(p, m, S, C) {
    return "workers" in S ? l(p, m, S, C) : s(p, m, S, C);
  }
  function s(p, m, S, C) {
    var A = f(p, m), b = 0, _ = u(A.bitLength());
    "millerRabinTests" in S && (_ = S.millerRabinTests);
    var U = 10;
    "maxBlockTime" in S && (U = S.maxBlockTime), o(A, p, m, b, _, U, C);
  }
  function o(p, m, S, C, A, b, _) {
    var U = +/* @__PURE__ */ new Date();
    do {
      if (p.bitLength() > m && (p = f(m, S)), p.isProbablePrime(A))
        return _(null, p);
      p.dAddOffset(a[C++ % 8], 0);
    } while (b < 0 || +/* @__PURE__ */ new Date() - U < b);
    Ut.util.setImmediate(function() {
      o(p, m, S, C, A, b, _);
    });
  }
  function l(p, m, S, C) {
    if (typeof Worker > "u")
      return s(p, m, S, C);
    var A = f(p, m), b = S.workers, _ = S.workLoad || 100, U = _ * 30 / 8, D = S.workerScript || "forge/prime.worker.js";
    if (b === -1)
      return Ut.util.estimateCores(function(O, F) {
        O && (F = 2), b = F - 1, G();
      });
    G();
    function G() {
      b = Math.max(1, b);
      for (var O = [], F = 0; F < b; ++F)
        O[F] = new Worker(D);
      for (var F = 0; F < b; ++F)
        O[F].addEventListener("message", j);
      var $ = !1;
      function j(le) {
        if (!$) {
          var he = le.data;
          if (he.found) {
            for (var de = 0; de < O.length; ++de)
              O[de].terminate();
            return $ = !0, C(null, new t(he.prime, 16));
          }
          A.bitLength() > p && (A = f(p, m));
          var Ee = A.toString(16);
          le.target.postMessage({
            hex: Ee,
            workLoad: _
          }), A.dAddOffset(U, 0);
        }
      }
    }
  }
  function f(p, m) {
    var S = new t(p, m), C = p - 1;
    return S.testBit(C) || S.bitwiseTo(t.ONE.shiftLeft(C), i, S), S.dAddOffset(31 - S.mod(r).byteValue(), 0), S;
  }
  function u(p) {
    return p <= 100 ? 27 : p <= 150 ? 18 : p <= 200 ? 15 : p <= 250 ? 12 : p <= 300 ? 9 : p <= 350 ? 8 : p <= 400 ? 7 : p <= 500 ? 6 : p <= 600 ? 5 : p <= 800 ? 4 : p <= 1250 ? 3 : 2;
  }
})();
var Y = ee;
if (typeof ue > "u")
  var ue = Y.jsbn.BigInteger;
var ga = Y.util.isNodejs ? Ua : null, w = Y.asn1, lt = Y.util;
Y.pki = Y.pki || {};
Y.pki.rsa = Y.rsa = Y.rsa || {};
var Z = Y.pki, Yo = [6, 4, 2, 4, 2, 4, 6, 2], Xo = {
  // PrivateKeyInfo
  name: "PrivateKeyInfo",
  tagClass: w.Class.UNIVERSAL,
  type: w.Type.SEQUENCE,
  constructed: !0,
  value: [{
    // Version (INTEGER)
    name: "PrivateKeyInfo.version",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyVersion"
  }, {
    // privateKeyAlgorithm
    name: "PrivateKeyInfo.privateKeyAlgorithm",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "AlgorithmIdentifier.algorithm",
      tagClass: w.Class.UNIVERSAL,
      type: w.Type.OID,
      constructed: !1,
      capture: "privateKeyOid"
    }]
  }, {
    // PrivateKey
    name: "PrivateKeyInfo",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.OCTETSTRING,
    constructed: !1,
    capture: "privateKey"
  }]
}, Wo = {
  // RSAPrivateKey
  name: "RSAPrivateKey",
  tagClass: w.Class.UNIVERSAL,
  type: w.Type.SEQUENCE,
  constructed: !0,
  value: [{
    // Version (INTEGER)
    name: "RSAPrivateKey.version",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyVersion"
  }, {
    // modulus (n)
    name: "RSAPrivateKey.modulus",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyModulus"
  }, {
    // publicExponent (e)
    name: "RSAPrivateKey.publicExponent",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyPublicExponent"
  }, {
    // privateExponent (d)
    name: "RSAPrivateKey.privateExponent",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyPrivateExponent"
  }, {
    // prime1 (p)
    name: "RSAPrivateKey.prime1",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyPrime1"
  }, {
    // prime2 (q)
    name: "RSAPrivateKey.prime2",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyPrime2"
  }, {
    // exponent1 (d mod (p-1))
    name: "RSAPrivateKey.exponent1",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyExponent1"
  }, {
    // exponent2 (d mod (q-1))
    name: "RSAPrivateKey.exponent2",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyExponent2"
  }, {
    // coefficient ((inverse of q) mod p)
    name: "RSAPrivateKey.coefficient",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyCoefficient"
  }]
}, $o = {
  // RSAPublicKey
  name: "RSAPublicKey",
  tagClass: w.Class.UNIVERSAL,
  type: w.Type.SEQUENCE,
  constructed: !0,
  value: [{
    // modulus (n)
    name: "RSAPublicKey.modulus",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "publicKeyModulus"
  }, {
    // publicExponent (e)
    name: "RSAPublicKey.exponent",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.INTEGER,
    constructed: !1,
    capture: "publicKeyExponent"
  }]
}, jo = Y.pki.rsa.publicKeyValidator = {
  name: "SubjectPublicKeyInfo",
  tagClass: w.Class.UNIVERSAL,
  type: w.Type.SEQUENCE,
  constructed: !0,
  captureAsn1: "subjectPublicKeyInfo",
  value: [{
    name: "SubjectPublicKeyInfo.AlgorithmIdentifier",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "AlgorithmIdentifier.algorithm",
      tagClass: w.Class.UNIVERSAL,
      type: w.Type.OID,
      constructed: !1,
      capture: "publicKeyOid"
    }]
  }, {
    // subjectPublicKey
    name: "SubjectPublicKeyInfo.subjectPublicKey",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.BITSTRING,
    constructed: !1,
    value: [{
      // RSAPublicKey
      name: "SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",
      tagClass: w.Class.UNIVERSAL,
      type: w.Type.SEQUENCE,
      constructed: !0,
      optional: !0,
      captureAsn1: "rsaPublicKey"
    }]
  }]
}, Zo = {
  name: "DigestInfo",
  tagClass: w.Class.UNIVERSAL,
  type: w.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "DigestInfo.DigestAlgorithm",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "DigestInfo.DigestAlgorithm.algorithmIdentifier",
      tagClass: w.Class.UNIVERSAL,
      type: w.Type.OID,
      constructed: !1,
      capture: "algorithmIdentifier"
    }, {
      // NULL parameters
      name: "DigestInfo.DigestAlgorithm.parameters",
      tagClass: w.Class.UNIVERSAL,
      type: w.Type.NULL,
      // captured only to check existence for md2 and md5
      capture: "parameters",
      optional: !0,
      constructed: !1
    }]
  }, {
    // digest
    name: "DigestInfo.digest",
    tagClass: w.Class.UNIVERSAL,
    type: w.Type.OCTETSTRING,
    constructed: !1,
    capture: "digest"
  }]
}, Jo = function(e) {
  var t;
  if (e.algorithm in Z.oids)
    t = Z.oids[e.algorithm];
  else {
    var a = new Error("Unknown message digest algorithm.");
    throw a.algorithm = e.algorithm, a;
  }
  var r = w.oidToDer(t).getBytes(), i = w.create(
    w.Class.UNIVERSAL,
    w.Type.SEQUENCE,
    !0,
    []
  ), n = w.create(
    w.Class.UNIVERSAL,
    w.Type.SEQUENCE,
    !0,
    []
  );
  n.value.push(w.create(
    w.Class.UNIVERSAL,
    w.Type.OID,
    !1,
    r
  )), n.value.push(w.create(
    w.Class.UNIVERSAL,
    w.Type.NULL,
    !1,
    ""
  ));
  var s = w.create(
    w.Class.UNIVERSAL,
    w.Type.OCTETSTRING,
    !1,
    e.digest().getBytes()
  );
  return i.value.push(n), i.value.push(s), w.toDer(i).getBytes();
}, Ki = function(e, t, a) {
  if (a)
    return e.modPow(t.e, t.n);
  if (!t.p || !t.q)
    return e.modPow(t.d, t.n);
  t.dP || (t.dP = t.d.mod(t.p.subtract(ue.ONE))), t.dQ || (t.dQ = t.d.mod(t.q.subtract(ue.ONE))), t.qInv || (t.qInv = t.q.modInverse(t.p));
  var r;
  do
    r = new ue(
      Y.util.bytesToHex(Y.random.getBytes(t.n.bitLength() / 8)),
      16
    );
  while (r.compareTo(t.n) >= 0 || !r.gcd(t.n).equals(ue.ONE));
  e = e.multiply(r.modPow(t.e, t.n)).mod(t.n);
  for (var i = e.mod(t.p).modPow(t.dP, t.p), n = e.mod(t.q).modPow(t.dQ, t.q); i.compareTo(n) < 0; )
    i = i.add(t.p);
  var s = i.subtract(n).multiply(t.qInv).mod(t.p).multiply(t.q).add(n);
  return s = s.multiply(r.modInverse(t.n)).mod(t.n), s;
};
Z.rsa.encrypt = function(e, t, a) {
  var r = a, i, n = Math.ceil(t.n.bitLength() / 8);
  a !== !1 && a !== !0 ? (r = a === 2, i = Mi(e, t, a)) : (i = Y.util.createBuffer(), i.putBytes(e));
  for (var s = new ue(i.toHex(), 16), o = Ki(s, t, r), l = o.toString(16), f = Y.util.createBuffer(), u = n - Math.ceil(l.length / 2); u > 0; )
    f.putByte(0), --u;
  return f.putBytes(Y.util.hexToBytes(l)), f.getBytes();
};
Z.rsa.decrypt = function(e, t, a, r) {
  var i = Math.ceil(t.n.bitLength() / 8);
  if (e.length !== i) {
    var n = new Error("Encrypted message length is invalid.");
    throw n.length = e.length, n.expected = i, n;
  }
  var s = new ue(Y.util.createBuffer(e).toHex(), 16);
  if (s.compareTo(t.n) >= 0)
    throw new Error("Encrypted message is invalid.");
  for (var o = Ki(s, t, a), l = o.toString(16), f = Y.util.createBuffer(), u = i - Math.ceil(l.length / 2); u > 0; )
    f.putByte(0), --u;
  return f.putBytes(Y.util.hexToBytes(l)), r !== !1 ? kr(f.getBytes(), t, a) : f.getBytes();
};
Z.rsa.createKeyPairGenerationState = function(e, t, a) {
  typeof e == "string" && (e = parseInt(e, 10)), e = e || 2048, a = a || {};
  var r = a.prng || Y.random, i = {
    // x is an array to fill with bytes
    nextBytes: function(o) {
      for (var l = r.getBytesSync(o.length), f = 0; f < o.length; ++f)
        o[f] = l.charCodeAt(f);
    }
  }, n = a.algorithm || "PRIMEINC", s;
  if (n === "PRIMEINC")
    s = {
      algorithm: n,
      state: 0,
      bits: e,
      rng: i,
      eInt: t || 65537,
      e: new ue(null),
      p: null,
      q: null,
      qBits: e >> 1,
      pBits: e - (e >> 1),
      pqState: 0,
      num: null,
      keys: null
    }, s.e.fromInt(s.eInt);
  else
    throw new Error("Invalid key generation algorithm: " + n);
  return s;
};
Z.rsa.stepKeyPairGenerationState = function(e, t) {
  "algorithm" in e || (e.algorithm = "PRIMEINC");
  var a = new ue(null);
  a.fromInt(30);
  for (var r = 0, i = function(p, m) {
    return p | m;
  }, n = +/* @__PURE__ */ new Date(), s, o = 0; e.keys === null && (t <= 0 || o < t); ) {
    if (e.state === 0) {
      var l = e.p === null ? e.pBits : e.qBits, f = l - 1;
      e.pqState === 0 ? (e.num = new ue(l, e.rng), e.num.testBit(f) || e.num.bitwiseTo(
        ue.ONE.shiftLeft(f),
        i,
        e.num
      ), e.num.dAddOffset(31 - e.num.mod(a).byteValue(), 0), r = 0, ++e.pqState) : e.pqState === 1 ? e.num.bitLength() > l ? e.pqState = 0 : e.num.isProbablePrime(
        t0(e.num.bitLength())
      ) ? ++e.pqState : e.num.dAddOffset(Yo[r++ % 8], 0) : e.pqState === 2 ? e.pqState = e.num.subtract(ue.ONE).gcd(e.e).compareTo(ue.ONE) === 0 ? 3 : 0 : e.pqState === 3 && (e.pqState = 0, e.p === null ? e.p = e.num : e.q = e.num, e.p !== null && e.q !== null && ++e.state, e.num = null);
    } else if (e.state === 1)
      e.p.compareTo(e.q) < 0 && (e.num = e.p, e.p = e.q, e.q = e.num), ++e.state;
    else if (e.state === 2)
      e.p1 = e.p.subtract(ue.ONE), e.q1 = e.q.subtract(ue.ONE), e.phi = e.p1.multiply(e.q1), ++e.state;
    else if (e.state === 3)
      e.phi.gcd(e.e).compareTo(ue.ONE) === 0 ? ++e.state : (e.p = null, e.q = null, e.state = 0);
    else if (e.state === 4)
      e.n = e.p.multiply(e.q), e.n.bitLength() === e.bits ? ++e.state : (e.q = null, e.state = 0);
    else if (e.state === 5) {
      var u = e.e.modInverse(e.phi);
      e.keys = {
        privateKey: Z.rsa.setPrivateKey(
          e.n,
          e.e,
          u,
          e.p,
          e.q,
          u.mod(e.p1),
          u.mod(e.q1),
          e.q.modInverse(e.p)
        ),
        publicKey: Z.rsa.setPublicKey(e.n, e.e)
      };
    }
    s = +/* @__PURE__ */ new Date(), o += s - n, n = s;
  }
  return e.keys !== null;
};
Z.rsa.generateKeyPair = function(e, t, a, r) {
  if (arguments.length === 1 ? typeof e == "object" ? (a = e, e = void 0) : typeof e == "function" && (r = e, e = void 0) : arguments.length === 2 ? typeof e == "number" ? typeof t == "function" ? (r = t, t = void 0) : typeof t != "number" && (a = t, t = void 0) : (a = e, r = t, e = void 0, t = void 0) : arguments.length === 3 && (typeof t == "number" ? typeof a == "function" && (r = a, a = void 0) : (r = a, a = t, t = void 0)), a = a || {}, e === void 0 && (e = a.bits || 2048), t === void 0 && (t = a.e || 65537), !Y.options.usePureJavaScript && !a.prng && e >= 256 && e <= 16384 && (t === 65537 || t === 3)) {
    if (r) {
      if (ii("generateKeyPair"))
        return ga.generateKeyPair("rsa", {
          modulusLength: e,
          publicExponent: t,
          publicKeyEncoding: {
            type: "spki",
            format: "pem"
          },
          privateKeyEncoding: {
            type: "pkcs8",
            format: "pem"
          }
        }, function(o, l, f) {
          if (o)
            return r(o);
          r(null, {
            privateKey: Z.privateKeyFromPem(f),
            publicKey: Z.publicKeyFromPem(l)
          });
        });
      if (ni("generateKey") && ni("exportKey"))
        return lt.globalScope.crypto.subtle.generateKey({
          name: "RSASSA-PKCS1-v1_5",
          modulusLength: e,
          publicExponent: oi(t),
          hash: { name: "SHA-256" }
        }, !0, ["sign", "verify"]).then(function(o) {
          return lt.globalScope.crypto.subtle.exportKey(
            "pkcs8",
            o.privateKey
          );
        }).then(void 0, function(o) {
          r(o);
        }).then(function(o) {
          if (o) {
            var l = Z.privateKeyFromAsn1(
              w.fromDer(Y.util.createBuffer(o))
            );
            r(null, {
              privateKey: l,
              publicKey: Z.setRsaPublicKey(l.n, l.e)
            });
          }
        });
      if (si("generateKey") && si("exportKey")) {
        var i = lt.globalScope.msCrypto.subtle.generateKey({
          name: "RSASSA-PKCS1-v1_5",
          modulusLength: e,
          publicExponent: oi(t),
          hash: { name: "SHA-256" }
        }, !0, ["sign", "verify"]);
        i.oncomplete = function(o) {
          var l = o.target.result, f = lt.globalScope.msCrypto.subtle.exportKey(
            "pkcs8",
            l.privateKey
          );
          f.oncomplete = function(u) {
            var p = u.target.result, m = Z.privateKeyFromAsn1(
              w.fromDer(Y.util.createBuffer(p))
            );
            r(null, {
              privateKey: m,
              publicKey: Z.setRsaPublicKey(m.n, m.e)
            });
          }, f.onerror = function(u) {
            r(u);
          };
        }, i.onerror = function(o) {
          r(o);
        };
        return;
      }
    } else if (ii("generateKeyPairSync")) {
      var n = ga.generateKeyPairSync("rsa", {
        modulusLength: e,
        publicExponent: t,
        publicKeyEncoding: {
          type: "spki",
          format: "pem"
        },
        privateKeyEncoding: {
          type: "pkcs8",
          format: "pem"
        }
      });
      return {
        privateKey: Z.privateKeyFromPem(n.privateKey),
        publicKey: Z.publicKeyFromPem(n.publicKey)
      };
    }
  }
  var s = Z.rsa.createKeyPairGenerationState(e, t, a);
  if (!r)
    return Z.rsa.stepKeyPairGenerationState(s, 0), s.keys;
  e0(s, a, r);
};
Z.setRsaPublicKey = Z.rsa.setPublicKey = function(e, t) {
  var a = {
    n: e,
    e: t
  };
  return a.encrypt = function(r, i, n) {
    if (typeof i == "string" ? i = i.toUpperCase() : i === void 0 && (i = "RSAES-PKCS1-V1_5"), i === "RSAES-PKCS1-V1_5")
      i = {
        encode: function(o, l, f) {
          return Mi(o, l, 2).getBytes();
        }
      };
    else if (i === "RSA-OAEP" || i === "RSAES-OAEP")
      i = {
        encode: function(o, l) {
          return Y.pkcs1.encode_rsa_oaep(l, o, n);
        }
      };
    else if (["RAW", "NONE", "NULL", null].indexOf(i) !== -1)
      i = { encode: function(o) {
        return o;
      } };
    else if (typeof i == "string")
      throw new Error('Unsupported encryption scheme: "' + i + '".');
    var s = i.encode(r, a, !0);
    return Z.rsa.encrypt(s, a, !0);
  }, a.verify = function(r, i, n, s) {
    typeof n == "string" ? n = n.toUpperCase() : n === void 0 && (n = "RSASSA-PKCS1-V1_5"), s === void 0 && (s = {
      _parseAllDigestBytes: !0
    }), "_parseAllDigestBytes" in s || (s._parseAllDigestBytes = !0), n === "RSASSA-PKCS1-V1_5" ? n = {
      verify: function(l, f) {
        f = kr(f, a, !0);
        var u = w.fromDer(f, {
          parseAllBytes: s._parseAllDigestBytes
        }), p = {}, m = [];
        if (!w.validate(u, Zo, p, m)) {
          var S = new Error(
            "ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value."
          );
          throw S.errors = m, S;
        }
        var C = w.derToOid(p.algorithmIdentifier);
        if (!(C === Y.oids.md2 || C === Y.oids.md5 || C === Y.oids.sha1 || C === Y.oids.sha224 || C === Y.oids.sha256 || C === Y.oids.sha384 || C === Y.oids.sha512 || C === Y.oids["sha512-224"] || C === Y.oids["sha512-256"])) {
          var S = new Error(
            "Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier."
          );
          throw S.oid = C, S;
        }
        if ((C === Y.oids.md2 || C === Y.oids.md5) && !("parameters" in p))
          throw new Error(
            "ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters."
          );
        return l === p.digest;
      }
    } : (n === "NONE" || n === "NULL" || n === null) && (n = {
      verify: function(l, f) {
        return f = kr(f, a, !0), l === f;
      }
    });
    var o = Z.rsa.decrypt(i, a, !0, !1);
    return n.verify(r, o, a.n.bitLength());
  }, a;
};
Z.setRsaPrivateKey = Z.rsa.setPrivateKey = function(e, t, a, r, i, n, s, o) {
  var l = {
    n: e,
    e: t,
    d: a,
    p: r,
    q: i,
    dP: n,
    dQ: s,
    qInv: o
  };
  return l.decrypt = function(f, u, p) {
    typeof u == "string" ? u = u.toUpperCase() : u === void 0 && (u = "RSAES-PKCS1-V1_5");
    var m = Z.rsa.decrypt(f, l, !1, !1);
    if (u === "RSAES-PKCS1-V1_5")
      u = { decode: kr };
    else if (u === "RSA-OAEP" || u === "RSAES-OAEP")
      u = {
        decode: function(S, C) {
          return Y.pkcs1.decode_rsa_oaep(C, S, p);
        }
      };
    else if (["RAW", "NONE", "NULL", null].indexOf(u) !== -1)
      u = { decode: function(S) {
        return S;
      } };
    else
      throw new Error('Unsupported encryption scheme: "' + u + '".');
    return u.decode(m, l, !1);
  }, l.sign = function(f, u) {
    var p = !1;
    typeof u == "string" && (u = u.toUpperCase()), u === void 0 || u === "RSASSA-PKCS1-V1_5" ? (u = { encode: Jo }, p = 1) : (u === "NONE" || u === "NULL" || u === null) && (u = { encode: function() {
      return f;
    } }, p = 1);
    var m = u.encode(f, l.n.bitLength());
    return Z.rsa.encrypt(m, l, p);
  }, l;
};
Z.wrapRsaPrivateKey = function(e) {
  return w.create(w.Class.UNIVERSAL, w.Type.SEQUENCE, !0, [
    // version (0)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      w.integerToDer(0).getBytes()
    ),
    // privateKeyAlgorithm
    w.create(w.Class.UNIVERSAL, w.Type.SEQUENCE, !0, [
      w.create(
        w.Class.UNIVERSAL,
        w.Type.OID,
        !1,
        w.oidToDer(Z.oids.rsaEncryption).getBytes()
      ),
      w.create(w.Class.UNIVERSAL, w.Type.NULL, !1, "")
    ]),
    // PrivateKey
    w.create(
      w.Class.UNIVERSAL,
      w.Type.OCTETSTRING,
      !1,
      w.toDer(e).getBytes()
    )
  ]);
};
Z.privateKeyFromAsn1 = function(e) {
  var t = {}, a = [];
  if (w.validate(e, Xo, t, a) && (e = w.fromDer(Y.util.createBuffer(t.privateKey))), t = {}, a = [], !w.validate(e, Wo, t, a)) {
    var r = new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");
    throw r.errors = a, r;
  }
  var i, n, s, o, l, f, u, p;
  return i = Y.util.createBuffer(t.privateKeyModulus).toHex(), n = Y.util.createBuffer(t.privateKeyPublicExponent).toHex(), s = Y.util.createBuffer(t.privateKeyPrivateExponent).toHex(), o = Y.util.createBuffer(t.privateKeyPrime1).toHex(), l = Y.util.createBuffer(t.privateKeyPrime2).toHex(), f = Y.util.createBuffer(t.privateKeyExponent1).toHex(), u = Y.util.createBuffer(t.privateKeyExponent2).toHex(), p = Y.util.createBuffer(t.privateKeyCoefficient).toHex(), Z.setRsaPrivateKey(
    new ue(i, 16),
    new ue(n, 16),
    new ue(s, 16),
    new ue(o, 16),
    new ue(l, 16),
    new ue(f, 16),
    new ue(u, 16),
    new ue(p, 16)
  );
};
Z.privateKeyToAsn1 = Z.privateKeyToRSAPrivateKey = function(e) {
  return w.create(w.Class.UNIVERSAL, w.Type.SEQUENCE, !0, [
    // version (0 = only 2 primes, 1 multiple primes)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      w.integerToDer(0).getBytes()
    ),
    // modulus (n)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.n)
    ),
    // publicExponent (e)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.e)
    ),
    // privateExponent (d)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.d)
    ),
    // privateKeyPrime1 (p)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.p)
    ),
    // privateKeyPrime2 (q)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.q)
    ),
    // privateKeyExponent1 (dP)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.dP)
    ),
    // privateKeyExponent2 (dQ)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.dQ)
    ),
    // coefficient (qInv)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.qInv)
    )
  ]);
};
Z.publicKeyFromAsn1 = function(e) {
  var t = {}, a = [];
  if (w.validate(e, jo, t, a)) {
    var r = w.derToOid(t.publicKeyOid);
    if (r !== Z.oids.rsaEncryption) {
      var i = new Error("Cannot read public key. Unknown OID.");
      throw i.oid = r, i;
    }
    e = t.rsaPublicKey;
  }
  if (a = [], !w.validate(e, $o, t, a)) {
    var i = new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");
    throw i.errors = a, i;
  }
  var n = Y.util.createBuffer(t.publicKeyModulus).toHex(), s = Y.util.createBuffer(t.publicKeyExponent).toHex();
  return Z.setRsaPublicKey(
    new ue(n, 16),
    new ue(s, 16)
  );
};
Z.publicKeyToAsn1 = Z.publicKeyToSubjectPublicKeyInfo = function(e) {
  return w.create(w.Class.UNIVERSAL, w.Type.SEQUENCE, !0, [
    // AlgorithmIdentifier
    w.create(w.Class.UNIVERSAL, w.Type.SEQUENCE, !0, [
      // algorithm
      w.create(
        w.Class.UNIVERSAL,
        w.Type.OID,
        !1,
        w.oidToDer(Z.oids.rsaEncryption).getBytes()
      ),
      // parameters (null)
      w.create(w.Class.UNIVERSAL, w.Type.NULL, !1, "")
    ]),
    // subjectPublicKey
    w.create(w.Class.UNIVERSAL, w.Type.BITSTRING, !1, [
      Z.publicKeyToRSAPublicKey(e)
    ])
  ]);
};
Z.publicKeyToRSAPublicKey = function(e) {
  return w.create(w.Class.UNIVERSAL, w.Type.SEQUENCE, !0, [
    // modulus (n)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.n)
    ),
    // publicExponent (e)
    w.create(
      w.Class.UNIVERSAL,
      w.Type.INTEGER,
      !1,
      mt(e.e)
    )
  ]);
};
function Mi(e, t, a) {
  var r = Y.util.createBuffer(), i = Math.ceil(t.n.bitLength() / 8);
  if (e.length > i - 11) {
    var n = new Error("Message is too long for PKCS#1 v1.5 padding.");
    throw n.length = e.length, n.max = i - 11, n;
  }
  r.putByte(0), r.putByte(a);
  var s = i - 3 - e.length, o;
  if (a === 0 || a === 1) {
    o = a === 0 ? 0 : 255;
    for (var l = 0; l < s; ++l)
      r.putByte(o);
  } else
    for (; s > 0; ) {
      for (var f = 0, u = Y.random.getBytes(s), l = 0; l < s; ++l)
        o = u.charCodeAt(l), o === 0 ? ++f : r.putByte(o);
      s = f;
    }
  return r.putByte(0), r.putBytes(e), r;
}
function kr(e, t, a, r) {
  var i = Math.ceil(t.n.bitLength() / 8), n = Y.util.createBuffer(e), s = n.getByte(), o = n.getByte();
  if (s !== 0 || a && o !== 0 && o !== 1 || !a && o != 2 || a && o === 0 && typeof r > "u")
    throw new Error("Encryption block is invalid.");
  var l = 0;
  if (o === 0) {
    l = i - 3 - r;
    for (var f = 0; f < l; ++f)
      if (n.getByte() !== 0)
        throw new Error("Encryption block is invalid.");
  } else if (o === 1)
    for (l = 0; n.length() > 1; ) {
      if (n.getByte() !== 255) {
        --n.read;
        break;
      }
      ++l;
    }
  else if (o === 2)
    for (l = 0; n.length() > 1; ) {
      if (n.getByte() === 0) {
        --n.read;
        break;
      }
      ++l;
    }
  var u = n.getByte();
  if (u !== 0 || l !== i - 3 - n.length())
    throw new Error("Encryption block is invalid.");
  return n.getBytes();
}
function e0(e, t, a) {
  typeof t == "function" && (a = t, t = {}), t = t || {};
  var r = {
    algorithm: {
      name: t.algorithm || "PRIMEINC",
      options: {
        workers: t.workers || 2,
        workLoad: t.workLoad || 100,
        workerScript: t.workerScript
      }
    }
  };
  "prng" in t && (r.prng = t.prng), i();
  function i() {
    n(e.pBits, function(o, l) {
      if (o)
        return a(o);
      if (e.p = l, e.q !== null)
        return s(o, e.q);
      n(e.qBits, s);
    });
  }
  function n(o, l) {
    Y.prime.generateProbablePrime(o, r, l);
  }
  function s(o, l) {
    if (o)
      return a(o);
    if (e.q = l, e.p.compareTo(e.q) < 0) {
      var f = e.p;
      e.p = e.q, e.q = f;
    }
    if (e.p.subtract(ue.ONE).gcd(e.e).compareTo(ue.ONE) !== 0) {
      e.p = null, i();
      return;
    }
    if (e.q.subtract(ue.ONE).gcd(e.e).compareTo(ue.ONE) !== 0) {
      e.q = null, n(e.qBits, s);
      return;
    }
    if (e.p1 = e.p.subtract(ue.ONE), e.q1 = e.q.subtract(ue.ONE), e.phi = e.p1.multiply(e.q1), e.phi.gcd(e.e).compareTo(ue.ONE) !== 0) {
      e.p = e.q = null, i();
      return;
    }
    if (e.n = e.p.multiply(e.q), e.n.bitLength() !== e.bits) {
      e.q = null, n(e.qBits, s);
      return;
    }
    var u = e.e.modInverse(e.phi);
    e.keys = {
      privateKey: Z.rsa.setPrivateKey(
        e.n,
        e.e,
        u,
        e.p,
        e.q,
        u.mod(e.p1),
        u.mod(e.q1),
        e.q.modInverse(e.p)
      ),
      publicKey: Z.rsa.setPublicKey(e.n, e.e)
    }, a(null, e.keys);
  }
}
function mt(e) {
  var t = e.toString(16);
  t[0] >= "8" && (t = "00" + t);
  var a = Y.util.hexToBytes(t);
  return a.length > 1 && // leading 0x00 for positive integer
  (a.charCodeAt(0) === 0 && !(a.charCodeAt(1) & 128) || // leading 0xFF for negative integer
  a.charCodeAt(0) === 255 && (a.charCodeAt(1) & 128) === 128) ? a.substr(1) : a;
}
function t0(e) {
  return e <= 100 ? 27 : e <= 150 ? 18 : e <= 200 ? 15 : e <= 250 ? 12 : e <= 300 ? 9 : e <= 350 ? 8 : e <= 400 ? 7 : e <= 500 ? 6 : e <= 600 ? 5 : e <= 800 ? 4 : e <= 1250 ? 3 : 2;
}
function ii(e) {
  return Y.util.isNodejs && typeof ga[e] == "function";
}
function ni(e) {
  return typeof lt.globalScope < "u" && typeof lt.globalScope.crypto == "object" && typeof lt.globalScope.crypto.subtle == "object" && typeof lt.globalScope.crypto.subtle[e] == "function";
}
function si(e) {
  return typeof lt.globalScope < "u" && typeof lt.globalScope.msCrypto == "object" && typeof lt.globalScope.msCrypto.subtle == "object" && typeof lt.globalScope.msCrypto.subtle[e] == "function";
}
function oi(e) {
  for (var t = Y.util.hexToBytes(e.toString(16)), a = new Uint8Array(t.length), r = 0; r < t.length; ++r)
    a[r] = t.charCodeAt(r);
  return a;
}
var Q = ee;
if (typeof r0 > "u")
  var r0 = Q.jsbn.BigInteger;
var R = Q.asn1, J = Q.pki = Q.pki || {};
J.pbe = Q.pbe = Q.pbe || {};
var qt = J.oids, a0 = {
  name: "EncryptedPrivateKeyInfo",
  tagClass: R.Class.UNIVERSAL,
  type: R.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "EncryptedPrivateKeyInfo.encryptionAlgorithm",
    tagClass: R.Class.UNIVERSAL,
    type: R.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "AlgorithmIdentifier.algorithm",
      tagClass: R.Class.UNIVERSAL,
      type: R.Type.OID,
      constructed: !1,
      capture: "encryptionOid"
    }, {
      name: "AlgorithmIdentifier.parameters",
      tagClass: R.Class.UNIVERSAL,
      type: R.Type.SEQUENCE,
      constructed: !0,
      captureAsn1: "encryptionParams"
    }]
  }, {
    // encryptedData
    name: "EncryptedPrivateKeyInfo.encryptedData",
    tagClass: R.Class.UNIVERSAL,
    type: R.Type.OCTETSTRING,
    constructed: !1,
    capture: "encryptedData"
  }]
}, i0 = {
  name: "PBES2Algorithms",
  tagClass: R.Class.UNIVERSAL,
  type: R.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "PBES2Algorithms.keyDerivationFunc",
    tagClass: R.Class.UNIVERSAL,
    type: R.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "PBES2Algorithms.keyDerivationFunc.oid",
      tagClass: R.Class.UNIVERSAL,
      type: R.Type.OID,
      constructed: !1,
      capture: "kdfOid"
    }, {
      name: "PBES2Algorithms.params",
      tagClass: R.Class.UNIVERSAL,
      type: R.Type.SEQUENCE,
      constructed: !0,
      value: [{
        name: "PBES2Algorithms.params.salt",
        tagClass: R.Class.UNIVERSAL,
        type: R.Type.OCTETSTRING,
        constructed: !1,
        capture: "kdfSalt"
      }, {
        name: "PBES2Algorithms.params.iterationCount",
        tagClass: R.Class.UNIVERSAL,
        type: R.Type.INTEGER,
        constructed: !1,
        capture: "kdfIterationCount"
      }, {
        name: "PBES2Algorithms.params.keyLength",
        tagClass: R.Class.UNIVERSAL,
        type: R.Type.INTEGER,
        constructed: !1,
        optional: !0,
        capture: "keyLength"
      }, {
        // prf
        name: "PBES2Algorithms.params.prf",
        tagClass: R.Class.UNIVERSAL,
        type: R.Type.SEQUENCE,
        constructed: !0,
        optional: !0,
        value: [{
          name: "PBES2Algorithms.params.prf.algorithm",
          tagClass: R.Class.UNIVERSAL,
          type: R.Type.OID,
          constructed: !1,
          capture: "prfOid"
        }]
      }]
    }]
  }, {
    name: "PBES2Algorithms.encryptionScheme",
    tagClass: R.Class.UNIVERSAL,
    type: R.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "PBES2Algorithms.encryptionScheme.oid",
      tagClass: R.Class.UNIVERSAL,
      type: R.Type.OID,
      constructed: !1,
      capture: "encOid"
    }, {
      name: "PBES2Algorithms.encryptionScheme.iv",
      tagClass: R.Class.UNIVERSAL,
      type: R.Type.OCTETSTRING,
      constructed: !1,
      capture: "encIv"
    }]
  }]
}, n0 = {
  name: "pkcs-12PbeParams",
  tagClass: R.Class.UNIVERSAL,
  type: R.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "pkcs-12PbeParams.salt",
    tagClass: R.Class.UNIVERSAL,
    type: R.Type.OCTETSTRING,
    constructed: !1,
    capture: "salt"
  }, {
    name: "pkcs-12PbeParams.iterations",
    tagClass: R.Class.UNIVERSAL,
    type: R.Type.INTEGER,
    constructed: !1,
    capture: "iterations"
  }]
};
J.encryptPrivateKeyInfo = function(e, t, a) {
  a = a || {}, a.saltSize = a.saltSize || 8, a.count = a.count || 2048, a.algorithm = a.algorithm || "aes128", a.prfAlgorithm = a.prfAlgorithm || "sha1";
  var r = Q.random.getBytesSync(a.saltSize), i = a.count, n = R.integerToDer(i), s, o, l;
  if (a.algorithm.indexOf("aes") === 0 || a.algorithm === "des") {
    var f, u, p;
    switch (a.algorithm) {
      case "aes128":
        s = 16, f = 16, u = qt["aes128-CBC"], p = Q.aes.createEncryptionCipher;
        break;
      case "aes192":
        s = 24, f = 16, u = qt["aes192-CBC"], p = Q.aes.createEncryptionCipher;
        break;
      case "aes256":
        s = 32, f = 16, u = qt["aes256-CBC"], p = Q.aes.createEncryptionCipher;
        break;
      case "des":
        s = 8, f = 8, u = qt.desCBC, p = Q.des.createEncryptionCipher;
        break;
      default:
        var m = new Error("Cannot encrypt private key. Unknown encryption algorithm.");
        throw m.algorithm = a.algorithm, m;
    }
    var S = "hmacWith" + a.prfAlgorithm.toUpperCase(), C = Gi(S), A = Q.pkcs5.pbkdf2(t, r, i, s, C), b = Q.random.getBytesSync(f), _ = p(A);
    _.start(b), _.update(R.toDer(e)), _.finish(), l = _.output.getBytes();
    var U = s0(r, n, s, S);
    o = R.create(
      R.Class.UNIVERSAL,
      R.Type.SEQUENCE,
      !0,
      [
        R.create(
          R.Class.UNIVERSAL,
          R.Type.OID,
          !1,
          R.oidToDer(qt.pkcs5PBES2).getBytes()
        ),
        R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
          // keyDerivationFunc
          R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
            R.create(
              R.Class.UNIVERSAL,
              R.Type.OID,
              !1,
              R.oidToDer(qt.pkcs5PBKDF2).getBytes()
            ),
            // PBKDF2-params
            U
          ]),
          // encryptionScheme
          R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
            R.create(
              R.Class.UNIVERSAL,
              R.Type.OID,
              !1,
              R.oidToDer(u).getBytes()
            ),
            // iv
            R.create(
              R.Class.UNIVERSAL,
              R.Type.OCTETSTRING,
              !1,
              b
            )
          ])
        ])
      ]
    );
  } else if (a.algorithm === "3des") {
    s = 24;
    var D = new Q.util.ByteBuffer(r), A = J.pbe.generatePkcs12Key(t, D, 1, i, s), b = J.pbe.generatePkcs12Key(t, D, 2, i, s), _ = Q.des.createEncryptionCipher(A);
    _.start(b), _.update(R.toDer(e)), _.finish(), l = _.output.getBytes(), o = R.create(
      R.Class.UNIVERSAL,
      R.Type.SEQUENCE,
      !0,
      [
        R.create(
          R.Class.UNIVERSAL,
          R.Type.OID,
          !1,
          R.oidToDer(qt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()
        ),
        // pkcs-12PbeParams
        R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
          // salt
          R.create(R.Class.UNIVERSAL, R.Type.OCTETSTRING, !1, r),
          // iteration count
          R.create(
            R.Class.UNIVERSAL,
            R.Type.INTEGER,
            !1,
            n.getBytes()
          )
        ])
      ]
    );
  } else {
    var m = new Error("Cannot encrypt private key. Unknown encryption algorithm.");
    throw m.algorithm = a.algorithm, m;
  }
  var G = R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
    // encryptionAlgorithm
    o,
    // encryptedData
    R.create(
      R.Class.UNIVERSAL,
      R.Type.OCTETSTRING,
      !1,
      l
    )
  ]);
  return G;
};
J.decryptPrivateKeyInfo = function(e, t) {
  var a = null, r = {}, i = [];
  if (!R.validate(e, a0, r, i)) {
    var n = new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");
    throw n.errors = i, n;
  }
  var s = R.derToOid(r.encryptionOid), o = J.pbe.getCipher(s, r.encryptionParams, t), l = Q.util.createBuffer(r.encryptedData);
  return o.update(l), o.finish() && (a = R.fromDer(o.output)), a;
};
J.encryptedPrivateKeyToPem = function(e, t) {
  var a = {
    type: "ENCRYPTED PRIVATE KEY",
    body: R.toDer(e).getBytes()
  };
  return Q.pem.encode(a, { maxline: t });
};
J.encryptedPrivateKeyFromPem = function(e) {
  var t = Q.pem.decode(e)[0];
  if (t.type !== "ENCRYPTED PRIVATE KEY") {
    var a = new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');
    throw a.headerType = t.type, a;
  }
  if (t.procType && t.procType.type === "ENCRYPTED")
    throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");
  return R.fromDer(t.body);
};
J.encryptRsaPrivateKey = function(e, t, a) {
  if (a = a || {}, !a.legacy) {
    var r = J.wrapRsaPrivateKey(J.privateKeyToAsn1(e));
    return r = J.encryptPrivateKeyInfo(r, t, a), J.encryptedPrivateKeyToPem(r);
  }
  var i, n, s, o;
  switch (a.algorithm) {
    case "aes128":
      i = "AES-128-CBC", s = 16, n = Q.random.getBytesSync(16), o = Q.aes.createEncryptionCipher;
      break;
    case "aes192":
      i = "AES-192-CBC", s = 24, n = Q.random.getBytesSync(16), o = Q.aes.createEncryptionCipher;
      break;
    case "aes256":
      i = "AES-256-CBC", s = 32, n = Q.random.getBytesSync(16), o = Q.aes.createEncryptionCipher;
      break;
    case "3des":
      i = "DES-EDE3-CBC", s = 24, n = Q.random.getBytesSync(8), o = Q.des.createEncryptionCipher;
      break;
    case "des":
      i = "DES-CBC", s = 8, n = Q.random.getBytesSync(8), o = Q.des.createEncryptionCipher;
      break;
    default:
      var l = new Error('Could not encrypt RSA private key; unsupported encryption algorithm "' + a.algorithm + '".');
      throw l.algorithm = a.algorithm, l;
  }
  var f = Q.pbe.opensslDeriveBytes(t, n.substr(0, 8), s), u = o(f);
  u.start(n), u.update(R.toDer(J.privateKeyToAsn1(e))), u.finish();
  var p = {
    type: "RSA PRIVATE KEY",
    procType: {
      version: "4",
      type: "ENCRYPTED"
    },
    dekInfo: {
      algorithm: i,
      parameters: Q.util.bytesToHex(n).toUpperCase()
    },
    body: u.output.getBytes()
  };
  return Q.pem.encode(p);
};
J.decryptRsaPrivateKey = function(e, t) {
  var a = null, r = Q.pem.decode(e)[0];
  if (r.type !== "ENCRYPTED PRIVATE KEY" && r.type !== "PRIVATE KEY" && r.type !== "RSA PRIVATE KEY") {
    var i = new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');
    throw i.headerType = i, i;
  }
  if (r.procType && r.procType.type === "ENCRYPTED") {
    var n, s;
    switch (r.dekInfo.algorithm) {
      case "DES-CBC":
        n = 8, s = Q.des.createDecryptionCipher;
        break;
      case "DES-EDE3-CBC":
        n = 24, s = Q.des.createDecryptionCipher;
        break;
      case "AES-128-CBC":
        n = 16, s = Q.aes.createDecryptionCipher;
        break;
      case "AES-192-CBC":
        n = 24, s = Q.aes.createDecryptionCipher;
        break;
      case "AES-256-CBC":
        n = 32, s = Q.aes.createDecryptionCipher;
        break;
      case "RC2-40-CBC":
        n = 5, s = function(p) {
          return Q.rc2.createDecryptionCipher(p, 40);
        };
        break;
      case "RC2-64-CBC":
        n = 8, s = function(p) {
          return Q.rc2.createDecryptionCipher(p, 64);
        };
        break;
      case "RC2-128-CBC":
        n = 16, s = function(p) {
          return Q.rc2.createDecryptionCipher(p, 128);
        };
        break;
      default:
        var i = new Error('Could not decrypt private key; unsupported encryption algorithm "' + r.dekInfo.algorithm + '".');
        throw i.algorithm = r.dekInfo.algorithm, i;
    }
    var o = Q.util.hexToBytes(r.dekInfo.parameters), l = Q.pbe.opensslDeriveBytes(t, o.substr(0, 8), n), f = s(l);
    if (f.start(o), f.update(Q.util.createBuffer(r.body)), f.finish())
      a = f.output.getBytes();
    else
      return a;
  } else
    a = r.body;
  return r.type === "ENCRYPTED PRIVATE KEY" ? a = J.decryptPrivateKeyInfo(R.fromDer(a), t) : a = R.fromDer(a), a !== null && (a = J.privateKeyFromAsn1(a)), a;
};
J.pbe.generatePkcs12Key = function(e, t, a, r, i, n) {
  var s, o;
  if (typeof n > "u" || n === null) {
    if (!("sha1" in Q.md))
      throw new Error('"sha1" hash algorithm unavailable.');
    n = Q.md.sha1.create();
  }
  var l = n.digestLength, f = n.blockLength, u = new Q.util.ByteBuffer(), p = new Q.util.ByteBuffer();
  if (e != null) {
    for (o = 0; o < e.length; o++)
      p.putInt16(e.charCodeAt(o));
    p.putInt16(0);
  }
  var m = p.length(), S = t.length(), C = new Q.util.ByteBuffer();
  C.fillWithByte(a, f);
  var A = f * Math.ceil(S / f), b = new Q.util.ByteBuffer();
  for (o = 0; o < A; o++)
    b.putByte(t.at(o % S));
  var _ = f * Math.ceil(m / f), U = new Q.util.ByteBuffer();
  for (o = 0; o < _; o++)
    U.putByte(p.at(o % m));
  var D = b;
  D.putBuffer(U);
  for (var G = Math.ceil(i / l), O = 1; O <= G; O++) {
    var F = new Q.util.ByteBuffer();
    F.putBytes(C.bytes()), F.putBytes(D.bytes());
    for (var $ = 0; $ < r; $++)
      n.start(), n.update(F.getBytes()), F = n.digest();
    var j = new Q.util.ByteBuffer();
    for (o = 0; o < f; o++)
      j.putByte(F.at(o % l));
    var le = Math.ceil(S / f) + Math.ceil(m / f), he = new Q.util.ByteBuffer();
    for (s = 0; s < le; s++) {
      var de = new Q.util.ByteBuffer(D.getBytes(f)), Ee = 511;
      for (o = j.length() - 1; o >= 0; o--)
        Ee = Ee >> 8, Ee += j.at(o) + de.at(o), de.setAt(o, Ee & 255);
      he.putBuffer(de);
    }
    D = he, u.putBuffer(F);
  }
  return u.truncate(u.length() - i), u;
};
J.pbe.getCipher = function(e, t, a) {
  switch (e) {
    case J.oids.pkcs5PBES2:
      return J.pbe.getCipherForPBES2(e, t, a);
    case J.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:
    case J.oids["pbewithSHAAnd40BitRC2-CBC"]:
      return J.pbe.getCipherForPKCS12PBE(e, t, a);
    default:
      var r = new Error("Cannot read encrypted PBE data block. Unsupported OID.");
      throw r.oid = e, r.supportedOids = [
        "pkcs5PBES2",
        "pbeWithSHAAnd3-KeyTripleDES-CBC",
        "pbewithSHAAnd40BitRC2-CBC"
      ], r;
  }
};
J.pbe.getCipherForPBES2 = function(e, t, a) {
  var r = {}, i = [];
  if (!R.validate(t, i0, r, i)) {
    var n = new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");
    throw n.errors = i, n;
  }
  if (e = R.derToOid(r.kdfOid), e !== J.oids.pkcs5PBKDF2) {
    var n = new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");
    throw n.oid = e, n.supportedOids = ["pkcs5PBKDF2"], n;
  }
  if (e = R.derToOid(r.encOid), e !== J.oids["aes128-CBC"] && e !== J.oids["aes192-CBC"] && e !== J.oids["aes256-CBC"] && e !== J.oids["des-EDE3-CBC"] && e !== J.oids.desCBC) {
    var n = new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");
    throw n.oid = e, n.supportedOids = [
      "aes128-CBC",
      "aes192-CBC",
      "aes256-CBC",
      "des-EDE3-CBC",
      "desCBC"
    ], n;
  }
  var s = r.kdfSalt, o = Q.util.createBuffer(r.kdfIterationCount);
  o = o.getInt(o.length() << 3);
  var l, f;
  switch (J.oids[e]) {
    case "aes128-CBC":
      l = 16, f = Q.aes.createDecryptionCipher;
      break;
    case "aes192-CBC":
      l = 24, f = Q.aes.createDecryptionCipher;
      break;
    case "aes256-CBC":
      l = 32, f = Q.aes.createDecryptionCipher;
      break;
    case "des-EDE3-CBC":
      l = 24, f = Q.des.createDecryptionCipher;
      break;
    case "desCBC":
      l = 8, f = Q.des.createDecryptionCipher;
      break;
  }
  var u = Hi(r.prfOid), p = Q.pkcs5.pbkdf2(a, s, o, l, u), m = r.encIv, S = f(p);
  return S.start(m), S;
};
J.pbe.getCipherForPKCS12PBE = function(e, t, a) {
  var r = {}, i = [];
  if (!R.validate(t, n0, r, i)) {
    var n = new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");
    throw n.errors = i, n;
  }
  var s = Q.util.createBuffer(r.salt), o = Q.util.createBuffer(r.iterations);
  o = o.getInt(o.length() << 3);
  var l, f, u;
  switch (e) {
    case J.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:
      l = 24, f = 8, u = Q.des.startDecrypting;
      break;
    case J.oids["pbewithSHAAnd40BitRC2-CBC"]:
      l = 5, f = 8, u = function(A, b) {
        var _ = Q.rc2.createDecryptionCipher(A, 40);
        return _.start(b, null), _;
      };
      break;
    default:
      var n = new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");
      throw n.oid = e, n;
  }
  var p = Hi(r.prfOid), m = J.pbe.generatePkcs12Key(a, s, 1, o, l, p);
  p.start();
  var S = J.pbe.generatePkcs12Key(a, s, 2, o, f, p);
  return u(m, S);
};
J.pbe.opensslDeriveBytes = function(e, t, a, r) {
  if (typeof r > "u" || r === null) {
    if (!("md5" in Q.md))
      throw new Error('"md5" hash algorithm unavailable.');
    r = Q.md.md5.create();
  }
  t === null && (t = "");
  for (var i = [ui(r, e + t)], n = 16, s = 1; n < a; ++s, n += 16)
    i.push(ui(r, i[s - 1] + e + t));
  return i.join("").substr(0, a);
};
function ui(e, t) {
  return e.start().update(t).digest().getBytes();
}
function Hi(e) {
  var t;
  if (!e)
    t = "hmacWithSHA1";
  else if (t = J.oids[R.derToOid(e)], !t) {
    var a = new Error("Unsupported PRF OID.");
    throw a.oid = e, a.supported = [
      "hmacWithSHA1",
      "hmacWithSHA224",
      "hmacWithSHA256",
      "hmacWithSHA384",
      "hmacWithSHA512"
    ], a;
  }
  return Gi(t);
}
function Gi(e) {
  var t = Q.md;
  switch (e) {
    case "hmacWithSHA224":
      t = Q.md.sha512;
    case "hmacWithSHA1":
    case "hmacWithSHA256":
    case "hmacWithSHA384":
    case "hmacWithSHA512":
      e = e.substr(8).toLowerCase();
      break;
    default:
      var a = new Error("Unsupported PRF algorithm.");
      throw a.algorithm = e, a.supported = [
        "hmacWithSHA1",
        "hmacWithSHA224",
        "hmacWithSHA256",
        "hmacWithSHA384",
        "hmacWithSHA512"
      ], a;
  }
  if (!t || !(e in t))
    throw new Error("Unknown hash algorithm: " + e);
  return t[e].create();
}
function s0(e, t, a, r) {
  var i = R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
    // salt
    R.create(
      R.Class.UNIVERSAL,
      R.Type.OCTETSTRING,
      !1,
      e
    ),
    // iteration count
    R.create(
      R.Class.UNIVERSAL,
      R.Type.INTEGER,
      !1,
      t.getBytes()
    )
  ]);
  return r !== "hmacWithSHA1" && i.value.push(
    // key length
    R.create(
      R.Class.UNIVERSAL,
      R.Type.INTEGER,
      !1,
      Q.util.hexToBytes(a.toString(16))
    ),
    // AlgorithmIdentifier
    R.create(R.Class.UNIVERSAL, R.Type.SEQUENCE, !0, [
      // algorithm
      R.create(
        R.Class.UNIVERSAL,
        R.Type.OID,
        !1,
        R.oidToDer(J.oids[r]).getBytes()
      ),
      // parameters (null)
      R.create(R.Class.UNIVERSAL, R.Type.NULL, !1, "")
    ])
  ), i;
}
var nr = ee, q = nr.asn1, cr = nr.pkcs7asn1 = nr.pkcs7asn1 || {};
nr.pkcs7 = nr.pkcs7 || {};
nr.pkcs7.asn1 = cr;
var qi = {
  name: "ContentInfo",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "ContentInfo.ContentType",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.OID,
    constructed: !1,
    capture: "contentType"
  }, {
    name: "ContentInfo.content",
    tagClass: q.Class.CONTEXT_SPECIFIC,
    type: 0,
    constructed: !0,
    optional: !0,
    captureAsn1: "content"
  }]
};
cr.contentInfoValidator = qi;
var Qi = {
  name: "EncryptedContentInfo",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "EncryptedContentInfo.contentType",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.OID,
    constructed: !1,
    capture: "contentType"
  }, {
    name: "EncryptedContentInfo.contentEncryptionAlgorithm",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.OID,
      constructed: !1,
      capture: "encAlgorithm"
    }, {
      name: "EncryptedContentInfo.contentEncryptionAlgorithm.parameter",
      tagClass: q.Class.UNIVERSAL,
      captureAsn1: "encParameter"
    }]
  }, {
    name: "EncryptedContentInfo.encryptedContent",
    tagClass: q.Class.CONTEXT_SPECIFIC,
    type: 0,
    /* The PKCS#7 structure output by OpenSSL somewhat differs from what
     * other implementations do generate.
     *
     * OpenSSL generates a structure like this:
     * SEQUENCE {
     *    ...
     *    [0]
     *       26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
     *       C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
     *       ...
     * }
     *
     * Whereas other implementations (and this PKCS#7 module) generate:
     * SEQUENCE {
     *    ...
     *    [0] {
     *       OCTET STRING
     *          26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
     *          C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
     *          ...
     *    }
     * }
     *
     * In order to support both, we just capture the context specific
     * field here.  The OCTET STRING bit is removed below.
     */
    capture: "encryptedContent",
    captureAsn1: "encryptedContentAsn1"
  }]
};
cr.envelopedDataValidator = {
  name: "EnvelopedData",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "EnvelopedData.Version",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.INTEGER,
    constructed: !1,
    capture: "version"
  }, {
    name: "EnvelopedData.RecipientInfos",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SET,
    constructed: !0,
    captureAsn1: "recipientInfos"
  }].concat(Qi)
};
cr.encryptedDataValidator = {
  name: "EncryptedData",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "EncryptedData.Version",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.INTEGER,
    constructed: !1,
    capture: "version"
  }].concat(Qi)
};
var o0 = {
  name: "SignerInfo",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "SignerInfo.version",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.INTEGER,
    constructed: !1
  }, {
    name: "SignerInfo.issuerAndSerialNumber",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "SignerInfo.issuerAndSerialNumber.issuer",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.SEQUENCE,
      constructed: !0,
      captureAsn1: "issuer"
    }, {
      name: "SignerInfo.issuerAndSerialNumber.serialNumber",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.INTEGER,
      constructed: !1,
      capture: "serial"
    }]
  }, {
    name: "SignerInfo.digestAlgorithm",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "SignerInfo.digestAlgorithm.algorithm",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.OID,
      constructed: !1,
      capture: "digestAlgorithm"
    }, {
      name: "SignerInfo.digestAlgorithm.parameter",
      tagClass: q.Class.UNIVERSAL,
      constructed: !1,
      captureAsn1: "digestParameter",
      optional: !0
    }]
  }, {
    name: "SignerInfo.authenticatedAttributes",
    tagClass: q.Class.CONTEXT_SPECIFIC,
    type: 0,
    constructed: !0,
    optional: !0,
    capture: "authenticatedAttributes"
  }, {
    name: "SignerInfo.digestEncryptionAlgorithm",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SEQUENCE,
    constructed: !0,
    capture: "signatureAlgorithm"
  }, {
    name: "SignerInfo.encryptedDigest",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.OCTETSTRING,
    constructed: !1,
    capture: "signature"
  }, {
    name: "SignerInfo.unauthenticatedAttributes",
    tagClass: q.Class.CONTEXT_SPECIFIC,
    type: 1,
    constructed: !0,
    optional: !0,
    capture: "unauthenticatedAttributes"
  }]
};
cr.signedDataValidator = {
  name: "SignedData",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [
    {
      name: "SignedData.Version",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.INTEGER,
      constructed: !1,
      capture: "version"
    },
    {
      name: "SignedData.DigestAlgorithms",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.SET,
      constructed: !0,
      captureAsn1: "digestAlgorithms"
    },
    qi,
    {
      name: "SignedData.Certificates",
      tagClass: q.Class.CONTEXT_SPECIFIC,
      type: 0,
      optional: !0,
      captureAsn1: "certificates"
    },
    {
      name: "SignedData.CertificateRevocationLists",
      tagClass: q.Class.CONTEXT_SPECIFIC,
      type: 1,
      optional: !0,
      captureAsn1: "crls"
    },
    {
      name: "SignedData.SignerInfos",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.SET,
      capture: "signerInfos",
      optional: !0,
      value: [o0]
    }
  ]
};
cr.recipientInfoValidator = {
  name: "RecipientInfo",
  tagClass: q.Class.UNIVERSAL,
  type: q.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "RecipientInfo.version",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.INTEGER,
    constructed: !1,
    capture: "version"
  }, {
    name: "RecipientInfo.issuerAndSerial",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "RecipientInfo.issuerAndSerial.issuer",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.SEQUENCE,
      constructed: !0,
      captureAsn1: "issuer"
    }, {
      name: "RecipientInfo.issuerAndSerial.serialNumber",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.INTEGER,
      constructed: !1,
      capture: "serial"
    }]
  }, {
    name: "RecipientInfo.keyEncryptionAlgorithm",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "RecipientInfo.keyEncryptionAlgorithm.algorithm",
      tagClass: q.Class.UNIVERSAL,
      type: q.Type.OID,
      constructed: !1,
      capture: "encAlgorithm"
    }, {
      name: "RecipientInfo.keyEncryptionAlgorithm.parameter",
      tagClass: q.Class.UNIVERSAL,
      constructed: !1,
      captureAsn1: "encParameter",
      optional: !0
    }]
  }, {
    name: "RecipientInfo.encryptedKey",
    tagClass: q.Class.UNIVERSAL,
    type: q.Type.OCTETSTRING,
    constructed: !1,
    capture: "encKey"
  }]
};
var Wt = ee;
Wt.mgf = Wt.mgf || {};
var u0 = Wt.mgf.mgf1 = Wt.mgf1 = Wt.mgf1 || {};
u0.create = function(e) {
  var t = {
    /**
     * Generate mask of specified length.
     *
     * @param {String} seed The seed for mask generation.
     * @param maskLen Number of bytes to generate.
     * @return {String} The generated mask.
     */
    generate: function(a, r) {
      for (var i = new Wt.util.ByteBuffer(), n = Math.ceil(r / e.digestLength), s = 0; s < n; s++) {
        var o = new Wt.util.ByteBuffer();
        o.putInt32(s), e.start(), e.update(a + o.getBytes()), i.putBuffer(e.digest());
      }
      return i.truncate(i.length() - r), i.getBytes();
    }
  };
  return t;
};
var Pr = ee;
Pr.mgf = Pr.mgf || {};
Pr.mgf.mgf1 = Pr.mgf1;
var Qt = ee, f0 = Qt.pss = Qt.pss || {};
f0.create = function(e) {
  arguments.length === 3 && (e = {
    md: arguments[0],
    mgf: arguments[1],
    saltLength: arguments[2]
  });
  var t = e.md, a = e.mgf, r = t.digestLength, i = e.salt || null;
  typeof i == "string" && (i = Qt.util.createBuffer(i));
  var n;
  if ("saltLength" in e)
    n = e.saltLength;
  else if (i !== null)
    n = i.length();
  else
    throw new Error("Salt length not specified or specific salt not given.");
  if (i !== null && i.length() !== n)
    throw new Error("Given salt length does not match length of given salt.");
  var s = e.prng || Qt.random, o = {};
  return o.encode = function(l, f) {
    var u, p = f - 1, m = Math.ceil(p / 8), S = l.digest().getBytes();
    if (m < r + n + 2)
      throw new Error("Message is too long to encrypt.");
    var C;
    i === null ? C = s.getBytesSync(n) : C = i.bytes();
    var A = new Qt.util.ByteBuffer();
    A.fillWithByte(0, 8), A.putBytes(S), A.putBytes(C), t.start(), t.update(A.getBytes());
    var b = t.digest().getBytes(), _ = new Qt.util.ByteBuffer();
    _.fillWithByte(0, m - n - r - 2), _.putByte(1), _.putBytes(C);
    var U = _.getBytes(), D = m - r - 1, G = a.generate(b, D), O = "";
    for (u = 0; u < D; u++)
      O += String.fromCharCode(U.charCodeAt(u) ^ G.charCodeAt(u));
    var F = 65280 >> 8 * m - p & 255;
    return O = String.fromCharCode(O.charCodeAt(0) & ~F) + O.substr(1), O + b + "¼";
  }, o.verify = function(l, f, u) {
    var p, m = u - 1, S = Math.ceil(m / 8);
    if (f = f.substr(-S), S < r + n + 2)
      throw new Error("Inconsistent parameters to PSS signature verification.");
    if (f.charCodeAt(S - 1) !== 188)
      throw new Error("Encoded message does not end in 0xBC.");
    var C = S - r - 1, A = f.substr(0, C), b = f.substr(C, r), _ = 65280 >> 8 * S - m & 255;
    if (A.charCodeAt(0) & _)
      throw new Error("Bits beyond keysize not zero as expected.");
    var U = a.generate(b, C), D = "";
    for (p = 0; p < C; p++)
      D += String.fromCharCode(A.charCodeAt(p) ^ U.charCodeAt(p));
    D = String.fromCharCode(D.charCodeAt(0) & ~_) + D.substr(1);
    var G = S - r - n - 2;
    for (p = 0; p < G; p++)
      if (D.charCodeAt(p) !== 0)
        throw new Error("Leftmost octets not zero as expected");
    if (D.charCodeAt(G) !== 1)
      throw new Error("Inconsistent PSS signature, 0x01 marker not found");
    var O = D.substr(-n), F = new Qt.util.ByteBuffer();
    F.fillWithByte(0, 8), F.putBytes(l), F.putBytes(O), t.start(), t.update(F.getBytes());
    var $ = t.digest().getBytes();
    return b === $;
  }, o;
};
var X = ee, d = X.asn1, K = X.pki = X.pki || {}, oe = K.oids, Re = {};
Re.CN = oe.commonName;
Re.commonName = "CN";
Re.C = oe.countryName;
Re.countryName = "C";
Re.L = oe.localityName;
Re.localityName = "L";
Re.ST = oe.stateOrProvinceName;
Re.stateOrProvinceName = "ST";
Re.O = oe.organizationName;
Re.organizationName = "O";
Re.OU = oe.organizationalUnitName;
Re.organizationalUnitName = "OU";
Re.E = oe.emailAddress;
Re.emailAddress = "E";
var zi = X.pki.rsa.publicKeyValidator, l0 = {
  name: "Certificate",
  tagClass: d.Class.UNIVERSAL,
  type: d.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "Certificate.TBSCertificate",
    tagClass: d.Class.UNIVERSAL,
    type: d.Type.SEQUENCE,
    constructed: !0,
    captureAsn1: "tbsCertificate",
    value: [
      {
        name: "Certificate.TBSCertificate.version",
        tagClass: d.Class.CONTEXT_SPECIFIC,
        type: 0,
        constructed: !0,
        optional: !0,
        value: [{
          name: "Certificate.TBSCertificate.version.integer",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.INTEGER,
          constructed: !1,
          capture: "certVersion"
        }]
      },
      {
        name: "Certificate.TBSCertificate.serialNumber",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.INTEGER,
        constructed: !1,
        capture: "certSerialNumber"
      },
      {
        name: "Certificate.TBSCertificate.signature",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.SEQUENCE,
        constructed: !0,
        value: [{
          name: "Certificate.TBSCertificate.signature.algorithm",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.OID,
          constructed: !1,
          capture: "certinfoSignatureOid"
        }, {
          name: "Certificate.TBSCertificate.signature.parameters",
          tagClass: d.Class.UNIVERSAL,
          optional: !0,
          captureAsn1: "certinfoSignatureParams"
        }]
      },
      {
        name: "Certificate.TBSCertificate.issuer",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.SEQUENCE,
        constructed: !0,
        captureAsn1: "certIssuer"
      },
      {
        name: "Certificate.TBSCertificate.validity",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.SEQUENCE,
        constructed: !0,
        // Note: UTC and generalized times may both appear so the capture
        // names are based on their detected order, the names used below
        // are only for the common case, which validity time really means
        // "notBefore" and which means "notAfter" will be determined by order
        value: [{
          // notBefore (Time) (UTC time case)
          name: "Certificate.TBSCertificate.validity.notBefore (utc)",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.UTCTIME,
          constructed: !1,
          optional: !0,
          capture: "certValidity1UTCTime"
        }, {
          // notBefore (Time) (generalized time case)
          name: "Certificate.TBSCertificate.validity.notBefore (generalized)",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.GENERALIZEDTIME,
          constructed: !1,
          optional: !0,
          capture: "certValidity2GeneralizedTime"
        }, {
          // notAfter (Time) (only UTC time is supported)
          name: "Certificate.TBSCertificate.validity.notAfter (utc)",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.UTCTIME,
          constructed: !1,
          optional: !0,
          capture: "certValidity3UTCTime"
        }, {
          // notAfter (Time) (only UTC time is supported)
          name: "Certificate.TBSCertificate.validity.notAfter (generalized)",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.GENERALIZEDTIME,
          constructed: !1,
          optional: !0,
          capture: "certValidity4GeneralizedTime"
        }]
      },
      {
        // Name (subject) (RDNSequence)
        name: "Certificate.TBSCertificate.subject",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.SEQUENCE,
        constructed: !0,
        captureAsn1: "certSubject"
      },
      // SubjectPublicKeyInfo
      zi,
      {
        // issuerUniqueID (optional)
        name: "Certificate.TBSCertificate.issuerUniqueID",
        tagClass: d.Class.CONTEXT_SPECIFIC,
        type: 1,
        constructed: !0,
        optional: !0,
        value: [{
          name: "Certificate.TBSCertificate.issuerUniqueID.id",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.BITSTRING,
          constructed: !1,
          // TODO: support arbitrary bit length ids
          captureBitStringValue: "certIssuerUniqueId"
        }]
      },
      {
        // subjectUniqueID (optional)
        name: "Certificate.TBSCertificate.subjectUniqueID",
        tagClass: d.Class.CONTEXT_SPECIFIC,
        type: 2,
        constructed: !0,
        optional: !0,
        value: [{
          name: "Certificate.TBSCertificate.subjectUniqueID.id",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.BITSTRING,
          constructed: !1,
          // TODO: support arbitrary bit length ids
          captureBitStringValue: "certSubjectUniqueId"
        }]
      },
      {
        // Extensions (optional)
        name: "Certificate.TBSCertificate.extensions",
        tagClass: d.Class.CONTEXT_SPECIFIC,
        type: 3,
        constructed: !0,
        captureAsn1: "certExtensions",
        optional: !0
      }
    ]
  }, {
    // AlgorithmIdentifier (signature algorithm)
    name: "Certificate.signatureAlgorithm",
    tagClass: d.Class.UNIVERSAL,
    type: d.Type.SEQUENCE,
    constructed: !0,
    value: [{
      // algorithm
      name: "Certificate.signatureAlgorithm.algorithm",
      tagClass: d.Class.UNIVERSAL,
      type: d.Type.OID,
      constructed: !1,
      capture: "certSignatureOid"
    }, {
      name: "Certificate.TBSCertificate.signature.parameters",
      tagClass: d.Class.UNIVERSAL,
      optional: !0,
      captureAsn1: "certSignatureParams"
    }]
  }, {
    // SignatureValue
    name: "Certificate.signatureValue",
    tagClass: d.Class.UNIVERSAL,
    type: d.Type.BITSTRING,
    constructed: !1,
    captureBitStringValue: "certSignature"
  }]
}, c0 = {
  name: "rsapss",
  tagClass: d.Class.UNIVERSAL,
  type: d.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "rsapss.hashAlgorithm",
    tagClass: d.Class.CONTEXT_SPECIFIC,
    type: 0,
    constructed: !0,
    value: [{
      name: "rsapss.hashAlgorithm.AlgorithmIdentifier",
      tagClass: d.Class.UNIVERSAL,
      type: d.Class.SEQUENCE,
      constructed: !0,
      optional: !0,
      value: [{
        name: "rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.OID,
        constructed: !1,
        capture: "hashOid"
        /* parameter block omitted, for SHA1 NULL anyhow. */
      }]
    }]
  }, {
    name: "rsapss.maskGenAlgorithm",
    tagClass: d.Class.CONTEXT_SPECIFIC,
    type: 1,
    constructed: !0,
    value: [{
      name: "rsapss.maskGenAlgorithm.AlgorithmIdentifier",
      tagClass: d.Class.UNIVERSAL,
      type: d.Class.SEQUENCE,
      constructed: !0,
      optional: !0,
      value: [{
        name: "rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.OID,
        constructed: !1,
        capture: "maskGenOid"
      }, {
        name: "rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.SEQUENCE,
        constructed: !0,
        value: [{
          name: "rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.OID,
          constructed: !1,
          capture: "maskGenHashOid"
          /* parameter block omitted, for SHA1 NULL anyhow. */
        }]
      }]
    }]
  }, {
    name: "rsapss.saltLength",
    tagClass: d.Class.CONTEXT_SPECIFIC,
    type: 2,
    optional: !0,
    value: [{
      name: "rsapss.saltLength.saltLength",
      tagClass: d.Class.UNIVERSAL,
      type: d.Class.INTEGER,
      constructed: !1,
      capture: "saltLength"
    }]
  }, {
    name: "rsapss.trailerField",
    tagClass: d.Class.CONTEXT_SPECIFIC,
    type: 3,
    optional: !0,
    value: [{
      name: "rsapss.trailer.trailer",
      tagClass: d.Class.UNIVERSAL,
      type: d.Class.INTEGER,
      constructed: !1,
      capture: "trailer"
    }]
  }]
}, h0 = {
  name: "CertificationRequestInfo",
  tagClass: d.Class.UNIVERSAL,
  type: d.Type.SEQUENCE,
  constructed: !0,
  captureAsn1: "certificationRequestInfo",
  value: [
    {
      name: "CertificationRequestInfo.integer",
      tagClass: d.Class.UNIVERSAL,
      type: d.Type.INTEGER,
      constructed: !1,
      capture: "certificationRequestInfoVersion"
    },
    {
      // Name (subject) (RDNSequence)
      name: "CertificationRequestInfo.subject",
      tagClass: d.Class.UNIVERSAL,
      type: d.Type.SEQUENCE,
      constructed: !0,
      captureAsn1: "certificationRequestInfoSubject"
    },
    // SubjectPublicKeyInfo
    zi,
    {
      name: "CertificationRequestInfo.attributes",
      tagClass: d.Class.CONTEXT_SPECIFIC,
      type: 0,
      constructed: !0,
      optional: !0,
      capture: "certificationRequestInfoAttributes",
      value: [{
        name: "CertificationRequestInfo.attributes",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.SEQUENCE,
        constructed: !0,
        value: [{
          name: "CertificationRequestInfo.attributes.type",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.OID,
          constructed: !1
        }, {
          name: "CertificationRequestInfo.attributes.value",
          tagClass: d.Class.UNIVERSAL,
          type: d.Type.SET,
          constructed: !0
        }]
      }]
    }
  ]
}, p0 = {
  name: "CertificationRequest",
  tagClass: d.Class.UNIVERSAL,
  type: d.Type.SEQUENCE,
  constructed: !0,
  captureAsn1: "csr",
  value: [
    h0,
    {
      // AlgorithmIdentifier (signature algorithm)
      name: "CertificationRequest.signatureAlgorithm",
      tagClass: d.Class.UNIVERSAL,
      type: d.Type.SEQUENCE,
      constructed: !0,
      value: [{
        // algorithm
        name: "CertificationRequest.signatureAlgorithm.algorithm",
        tagClass: d.Class.UNIVERSAL,
        type: d.Type.OID,
        constructed: !1,
        capture: "csrSignatureOid"
      }, {
        name: "CertificationRequest.signatureAlgorithm.parameters",
        tagClass: d.Class.UNIVERSAL,
        optional: !0,
        captureAsn1: "csrSignatureParams"
      }]
    },
    {
      // signature
      name: "CertificationRequest.signature",
      tagClass: d.Class.UNIVERSAL,
      type: d.Type.BITSTRING,
      constructed: !1,
      captureBitStringValue: "csrSignature"
    }
  ]
};
K.RDNAttributesAsArray = function(e, t) {
  for (var a = [], r, i, n, s = 0; s < e.value.length; ++s) {
    r = e.value[s];
    for (var o = 0; o < r.value.length; ++o)
      n = {}, i = r.value[o], n.type = d.derToOid(i.value[0].value), n.value = i.value[1].value, n.valueTagClass = i.value[1].type, n.type in oe && (n.name = oe[n.type], n.name in Re && (n.shortName = Re[n.name])), t && (t.update(n.type), t.update(n.value)), a.push(n);
  }
  return a;
};
K.CRIAttributesAsArray = function(e) {
  for (var t = [], a = 0; a < e.length; ++a)
    for (var r = e[a], i = d.derToOid(r.value[0].value), n = r.value[1].value, s = 0; s < n.length; ++s) {
      var o = {};
      if (o.type = i, o.value = n[s].value, o.valueTagClass = n[s].type, o.type in oe && (o.name = oe[o.type], o.name in Re && (o.shortName = Re[o.name])), o.type === oe.extensionRequest) {
        o.extensions = [];
        for (var l = 0; l < o.value.length; ++l)
          o.extensions.push(K.certificateExtensionFromAsn1(o.value[l]));
      }
      t.push(o);
    }
  return t;
};
function Ht(e, t) {
  typeof t == "string" && (t = { shortName: t });
  for (var a = null, r, i = 0; a === null && i < e.attributes.length; ++i)
    r = e.attributes[i], (t.type && t.type === r.type || t.name && t.name === r.name || t.shortName && t.shortName === r.shortName) && (a = r);
  return a;
}
var Vr = function(e, t, a) {
  var r = {};
  if (e !== oe["RSASSA-PSS"])
    return r;
  a && (r = {
    hash: {
      algorithmOid: oe.sha1
    },
    mgf: {
      algorithmOid: oe.mgf1,
      hash: {
        algorithmOid: oe.sha1
      }
    },
    saltLength: 20
  });
  var i = {}, n = [];
  if (!d.validate(t, c0, i, n)) {
    var s = new Error("Cannot read RSASSA-PSS parameter block.");
    throw s.errors = n, s;
  }
  return i.hashOid !== void 0 && (r.hash = r.hash || {}, r.hash.algorithmOid = d.derToOid(i.hashOid)), i.maskGenOid !== void 0 && (r.mgf = r.mgf || {}, r.mgf.algorithmOid = d.derToOid(i.maskGenOid), r.mgf.hash = r.mgf.hash || {}, r.mgf.hash.algorithmOid = d.derToOid(i.maskGenHashOid)), i.saltLength !== void 0 && (r.saltLength = i.saltLength.charCodeAt(0)), r;
}, $r = function(e) {
  switch (oe[e.signatureOid]) {
    case "sha1WithRSAEncryption":
    case "sha1WithRSASignature":
      return X.md.sha1.create();
    case "md5WithRSAEncryption":
      return X.md.md5.create();
    case "sha256WithRSAEncryption":
      return X.md.sha256.create();
    case "sha384WithRSAEncryption":
      return X.md.sha384.create();
    case "sha512WithRSAEncryption":
      return X.md.sha512.create();
    case "RSASSA-PSS":
      return X.md.sha256.create();
    default:
      var t = new Error(
        "Could not compute " + e.type + " digest. Unknown signature OID."
      );
      throw t.signatureOid = e.signatureOid, t;
  }
}, Yi = function(e) {
  var t = e.certificate, a;
  switch (t.signatureOid) {
    case oe.sha1WithRSAEncryption:
    case oe.sha1WithRSASignature:
      break;
    case oe["RSASSA-PSS"]:
      var r, i;
      if (r = oe[t.signatureParameters.mgf.hash.algorithmOid], r === void 0 || X.md[r] === void 0) {
        var n = new Error("Unsupported MGF hash function.");
        throw n.oid = t.signatureParameters.mgf.hash.algorithmOid, n.name = r, n;
      }
      if (i = oe[t.signatureParameters.mgf.algorithmOid], i === void 0 || X.mgf[i] === void 0) {
        var n = new Error("Unsupported MGF function.");
        throw n.oid = t.signatureParameters.mgf.algorithmOid, n.name = i, n;
      }
      if (i = X.mgf[i].create(X.md[r].create()), r = oe[t.signatureParameters.hash.algorithmOid], r === void 0 || X.md[r] === void 0) {
        var n = new Error("Unsupported RSASSA-PSS hash function.");
        throw n.oid = t.signatureParameters.hash.algorithmOid, n.name = r, n;
      }
      a = X.pss.create(
        X.md[r].create(),
        i,
        t.signatureParameters.saltLength
      );
      break;
  }
  return t.publicKey.verify(
    e.md.digest().getBytes(),
    e.signature,
    a
  );
};
K.certificateFromPem = function(e, t, a) {
  var r = X.pem.decode(e)[0];
  if (r.type !== "CERTIFICATE" && r.type !== "X509 CERTIFICATE" && r.type !== "TRUSTED CERTIFICATE") {
    var i = new Error(
      'Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".'
    );
    throw i.headerType = r.type, i;
  }
  if (r.procType && r.procType.type === "ENCRYPTED")
    throw new Error(
      "Could not convert certificate from PEM; PEM is encrypted."
    );
  var n = d.fromDer(r.body, a);
  return K.certificateFromAsn1(n, t);
};
K.certificateToPem = function(e, t) {
  var a = {
    type: "CERTIFICATE",
    body: d.toDer(K.certificateToAsn1(e)).getBytes()
  };
  return X.pem.encode(a, { maxline: t });
};
K.publicKeyFromPem = function(e) {
  var t = X.pem.decode(e)[0];
  if (t.type !== "PUBLIC KEY" && t.type !== "RSA PUBLIC KEY") {
    var a = new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');
    throw a.headerType = t.type, a;
  }
  if (t.procType && t.procType.type === "ENCRYPTED")
    throw new Error("Could not convert public key from PEM; PEM is encrypted.");
  var r = d.fromDer(t.body);
  return K.publicKeyFromAsn1(r);
};
K.publicKeyToPem = function(e, t) {
  var a = {
    type: "PUBLIC KEY",
    body: d.toDer(K.publicKeyToAsn1(e)).getBytes()
  };
  return X.pem.encode(a, { maxline: t });
};
K.publicKeyToRSAPublicKeyPem = function(e, t) {
  var a = {
    type: "RSA PUBLIC KEY",
    body: d.toDer(K.publicKeyToRSAPublicKey(e)).getBytes()
  };
  return X.pem.encode(a, { maxline: t });
};
K.getPublicKeyFingerprint = function(e, t) {
  t = t || {};
  var a = t.md || X.md.sha1.create(), r = t.type || "RSAPublicKey", i;
  switch (r) {
    case "RSAPublicKey":
      i = d.toDer(K.publicKeyToRSAPublicKey(e)).getBytes();
      break;
    case "SubjectPublicKeyInfo":
      i = d.toDer(K.publicKeyToAsn1(e)).getBytes();
      break;
    default:
      throw new Error('Unknown fingerprint type "' + t.type + '".');
  }
  a.start(), a.update(i);
  var n = a.digest();
  if (t.encoding === "hex") {
    var s = n.toHex();
    return t.delimiter ? s.match(/.{2}/g).join(t.delimiter) : s;
  } else {
    if (t.encoding === "binary")
      return n.getBytes();
    if (t.encoding)
      throw new Error('Unknown encoding "' + t.encoding + '".');
  }
  return n;
};
K.certificationRequestFromPem = function(e, t, a) {
  var r = X.pem.decode(e)[0];
  if (r.type !== "CERTIFICATE REQUEST") {
    var i = new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');
    throw i.headerType = r.type, i;
  }
  if (r.procType && r.procType.type === "ENCRYPTED")
    throw new Error("Could not convert certification request from PEM; PEM is encrypted.");
  var n = d.fromDer(r.body, a);
  return K.certificationRequestFromAsn1(n, t);
};
K.certificationRequestToPem = function(e, t) {
  var a = {
    type: "CERTIFICATE REQUEST",
    body: d.toDer(K.certificationRequestToAsn1(e)).getBytes()
  };
  return X.pem.encode(a, { maxline: t });
};
K.createCertificate = function() {
  var e = {};
  return e.version = 2, e.serialNumber = "00", e.signatureOid = null, e.signature = null, e.siginfo = {}, e.siginfo.algorithmOid = null, e.validity = {}, e.validity.notBefore = /* @__PURE__ */ new Date(), e.validity.notAfter = /* @__PURE__ */ new Date(), e.issuer = {}, e.issuer.getField = function(t) {
    return Ht(e.issuer, t);
  }, e.issuer.addField = function(t) {
    ct([t]), e.issuer.attributes.push(t);
  }, e.issuer.attributes = [], e.issuer.hash = null, e.subject = {}, e.subject.getField = function(t) {
    return Ht(e.subject, t);
  }, e.subject.addField = function(t) {
    ct([t]), e.subject.attributes.push(t);
  }, e.subject.attributes = [], e.subject.hash = null, e.extensions = [], e.publicKey = null, e.md = null, e.setSubject = function(t, a) {
    ct(t), e.subject.attributes = t, delete e.subject.uniqueId, a && (e.subject.uniqueId = a), e.subject.hash = null;
  }, e.setIssuer = function(t, a) {
    ct(t), e.issuer.attributes = t, delete e.issuer.uniqueId, a && (e.issuer.uniqueId = a), e.issuer.hash = null;
  }, e.setExtensions = function(t) {
    for (var a = 0; a < t.length; ++a)
      Xi(t[a], { cert: e });
    e.extensions = t;
  }, e.getExtension = function(t) {
    typeof t == "string" && (t = { name: t });
    for (var a = null, r, i = 0; a === null && i < e.extensions.length; ++i)
      r = e.extensions[i], (t.id && r.id === t.id || t.name && r.name === t.name) && (a = r);
    return a;
  }, e.sign = function(t, a) {
    e.md = a || X.md.sha1.create();
    var r = oe[e.md.algorithm + "WithRSAEncryption"];
    if (!r) {
      var i = new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");
      throw i.algorithm = e.md.algorithm, i;
    }
    e.signatureOid = e.siginfo.algorithmOid = r, e.tbsCertificate = K.getTBSCertificate(e);
    var n = d.toDer(e.tbsCertificate);
    e.md.update(n.getBytes()), e.signature = t.sign(e.md);
  }, e.verify = function(t) {
    var a = !1;
    if (!e.issued(t)) {
      var r = t.issuer, i = e.subject, n = new Error(
        "The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject."
      );
      throw n.expectedIssuer = i.attributes, n.actualIssuer = r.attributes, n;
    }
    var s = t.md;
    if (s === null) {
      s = $r({
        signatureOid: t.signatureOid,
        type: "certificate"
      });
      var o = t.tbsCertificate || K.getTBSCertificate(t), l = d.toDer(o);
      s.update(l.getBytes());
    }
    return s !== null && (a = Yi({
      certificate: e,
      md: s,
      signature: t.signature
    })), a;
  }, e.isIssuer = function(t) {
    var a = !1, r = e.issuer, i = t.subject;
    if (r.hash && i.hash)
      a = r.hash === i.hash;
    else if (r.attributes.length === i.attributes.length) {
      a = !0;
      for (var n, s, o = 0; a && o < r.attributes.length; ++o)
        n = r.attributes[o], s = i.attributes[o], (n.type !== s.type || n.value !== s.value) && (a = !1);
    }
    return a;
  }, e.issued = function(t) {
    return t.isIssuer(e);
  }, e.generateSubjectKeyIdentifier = function() {
    return K.getPublicKeyFingerprint(e.publicKey, { type: "RSAPublicKey" });
  }, e.verifySubjectKeyIdentifier = function() {
    for (var t = oe.subjectKeyIdentifier, a = 0; a < e.extensions.length; ++a) {
      var r = e.extensions[a];
      if (r.id === t) {
        var i = e.generateSubjectKeyIdentifier().getBytes();
        return X.util.hexToBytes(r.subjectKeyIdentifier) === i;
      }
    }
    return !1;
  }, e;
};
K.certificateFromAsn1 = function(e, t) {
  var a = {}, r = [];
  if (!d.validate(e, l0, a, r)) {
    var i = new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");
    throw i.errors = r, i;
  }
  var n = d.derToOid(a.publicKeyOid);
  if (n !== K.oids.rsaEncryption)
    throw new Error("Cannot read public key. OID is not RSA.");
  var s = K.createCertificate();
  s.version = a.certVersion ? a.certVersion.charCodeAt(0) : 0;
  var o = X.util.createBuffer(a.certSerialNumber);
  s.serialNumber = o.toHex(), s.signatureOid = X.asn1.derToOid(a.certSignatureOid), s.signatureParameters = Vr(
    s.signatureOid,
    a.certSignatureParams,
    !0
  ), s.siginfo.algorithmOid = X.asn1.derToOid(a.certinfoSignatureOid), s.siginfo.parameters = Vr(
    s.siginfo.algorithmOid,
    a.certinfoSignatureParams,
    !1
  ), s.signature = a.certSignature;
  var l = [];
  if (a.certValidity1UTCTime !== void 0 && l.push(d.utcTimeToDate(a.certValidity1UTCTime)), a.certValidity2GeneralizedTime !== void 0 && l.push(d.generalizedTimeToDate(
    a.certValidity2GeneralizedTime
  )), a.certValidity3UTCTime !== void 0 && l.push(d.utcTimeToDate(a.certValidity3UTCTime)), a.certValidity4GeneralizedTime !== void 0 && l.push(d.generalizedTimeToDate(
    a.certValidity4GeneralizedTime
  )), l.length > 2)
    throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");
  if (l.length < 2)
    throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");
  if (s.validity.notBefore = l[0], s.validity.notAfter = l[1], s.tbsCertificate = a.tbsCertificate, t) {
    s.md = $r({
      signatureOid: s.signatureOid,
      type: "certificate"
    });
    var f = d.toDer(s.tbsCertificate);
    s.md.update(f.getBytes());
  }
  var u = X.md.sha1.create(), p = d.toDer(a.certIssuer);
  u.update(p.getBytes()), s.issuer.getField = function(C) {
    return Ht(s.issuer, C);
  }, s.issuer.addField = function(C) {
    ct([C]), s.issuer.attributes.push(C);
  }, s.issuer.attributes = K.RDNAttributesAsArray(a.certIssuer), a.certIssuerUniqueId && (s.issuer.uniqueId = a.certIssuerUniqueId), s.issuer.hash = u.digest().toHex();
  var m = X.md.sha1.create(), S = d.toDer(a.certSubject);
  return m.update(S.getBytes()), s.subject.getField = function(C) {
    return Ht(s.subject, C);
  }, s.subject.addField = function(C) {
    ct([C]), s.subject.attributes.push(C);
  }, s.subject.attributes = K.RDNAttributesAsArray(a.certSubject), a.certSubjectUniqueId && (s.subject.uniqueId = a.certSubjectUniqueId), s.subject.hash = m.digest().toHex(), a.certExtensions ? s.extensions = K.certificateExtensionsFromAsn1(a.certExtensions) : s.extensions = [], s.publicKey = K.publicKeyFromAsn1(a.subjectPublicKeyInfo), s;
};
K.certificateExtensionsFromAsn1 = function(e) {
  for (var t = [], a = 0; a < e.value.length; ++a)
    for (var r = e.value[a], i = 0; i < r.value.length; ++i)
      t.push(K.certificateExtensionFromAsn1(r.value[i]));
  return t;
};
K.certificateExtensionFromAsn1 = function(e) {
  var t = {};
  if (t.id = d.derToOid(e.value[0].value), t.critical = !1, e.value[1].type === d.Type.BOOLEAN ? (t.critical = e.value[1].value.charCodeAt(0) !== 0, t.value = e.value[2].value) : t.value = e.value[1].value, t.id in oe) {
    if (t.name = oe[t.id], t.name === "keyUsage") {
      var a = d.fromDer(t.value), r = 0, i = 0;
      a.value.length > 1 && (r = a.value.charCodeAt(1), i = a.value.length > 2 ? a.value.charCodeAt(2) : 0), t.digitalSignature = (r & 128) === 128, t.nonRepudiation = (r & 64) === 64, t.keyEncipherment = (r & 32) === 32, t.dataEncipherment = (r & 16) === 16, t.keyAgreement = (r & 8) === 8, t.keyCertSign = (r & 4) === 4, t.cRLSign = (r & 2) === 2, t.encipherOnly = (r & 1) === 1, t.decipherOnly = (i & 128) === 128;
    } else if (t.name === "basicConstraints") {
      var a = d.fromDer(t.value);
      a.value.length > 0 && a.value[0].type === d.Type.BOOLEAN ? t.cA = a.value[0].value.charCodeAt(0) !== 0 : t.cA = !1;
      var n = null;
      a.value.length > 0 && a.value[0].type === d.Type.INTEGER ? n = a.value[0].value : a.value.length > 1 && (n = a.value[1].value), n !== null && (t.pathLenConstraint = d.derToInteger(n));
    } else if (t.name === "extKeyUsage")
      for (var a = d.fromDer(t.value), s = 0; s < a.value.length; ++s) {
        var o = d.derToOid(a.value[s].value);
        o in oe ? t[oe[o]] = !0 : t[o] = !0;
      }
    else if (t.name === "nsCertType") {
      var a = d.fromDer(t.value), r = 0;
      a.value.length > 1 && (r = a.value.charCodeAt(1)), t.client = (r & 128) === 128, t.server = (r & 64) === 64, t.email = (r & 32) === 32, t.objsign = (r & 16) === 16, t.reserved = (r & 8) === 8, t.sslCA = (r & 4) === 4, t.emailCA = (r & 2) === 2, t.objCA = (r & 1) === 1;
    } else if (t.name === "subjectAltName" || t.name === "issuerAltName") {
      t.altNames = [];
      for (var l, a = d.fromDer(t.value), f = 0; f < a.value.length; ++f) {
        l = a.value[f];
        var u = {
          type: l.type,
          value: l.value
        };
        switch (t.altNames.push(u), l.type) {
          case 1:
          case 2:
          case 6:
            break;
          case 7:
            u.ip = X.util.bytesToIP(l.value);
            break;
          case 8:
            u.oid = d.derToOid(l.value);
            break;
        }
      }
    } else if (t.name === "subjectKeyIdentifier") {
      var a = d.fromDer(t.value);
      t.subjectKeyIdentifier = X.util.bytesToHex(a.value);
    }
  }
  return t;
};
K.certificationRequestFromAsn1 = function(e, t) {
  var a = {}, r = [];
  if (!d.validate(e, p0, a, r)) {
    var i = new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");
    throw i.errors = r, i;
  }
  var n = d.derToOid(a.publicKeyOid);
  if (n !== K.oids.rsaEncryption)
    throw new Error("Cannot read public key. OID is not RSA.");
  var s = K.createCertificationRequest();
  if (s.version = a.csrVersion ? a.csrVersion.charCodeAt(0) : 0, s.signatureOid = X.asn1.derToOid(a.csrSignatureOid), s.signatureParameters = Vr(
    s.signatureOid,
    a.csrSignatureParams,
    !0
  ), s.siginfo.algorithmOid = X.asn1.derToOid(a.csrSignatureOid), s.siginfo.parameters = Vr(
    s.siginfo.algorithmOid,
    a.csrSignatureParams,
    !1
  ), s.signature = a.csrSignature, s.certificationRequestInfo = a.certificationRequestInfo, t) {
    s.md = $r({
      signatureOid: s.signatureOid,
      type: "certification request"
    });
    var o = d.toDer(s.certificationRequestInfo);
    s.md.update(o.getBytes());
  }
  var l = X.md.sha1.create();
  return s.subject.getField = function(f) {
    return Ht(s.subject, f);
  }, s.subject.addField = function(f) {
    ct([f]), s.subject.attributes.push(f);
  }, s.subject.attributes = K.RDNAttributesAsArray(
    a.certificationRequestInfoSubject,
    l
  ), s.subject.hash = l.digest().toHex(), s.publicKey = K.publicKeyFromAsn1(a.subjectPublicKeyInfo), s.getAttribute = function(f) {
    return Ht(s, f);
  }, s.addAttribute = function(f) {
    ct([f]), s.attributes.push(f);
  }, s.attributes = K.CRIAttributesAsArray(
    a.certificationRequestInfoAttributes || []
  ), s;
};
K.createCertificationRequest = function() {
  var e = {};
  return e.version = 0, e.signatureOid = null, e.signature = null, e.siginfo = {}, e.siginfo.algorithmOid = null, e.subject = {}, e.subject.getField = function(t) {
    return Ht(e.subject, t);
  }, e.subject.addField = function(t) {
    ct([t]), e.subject.attributes.push(t);
  }, e.subject.attributes = [], e.subject.hash = null, e.publicKey = null, e.attributes = [], e.getAttribute = function(t) {
    return Ht(e, t);
  }, e.addAttribute = function(t) {
    ct([t]), e.attributes.push(t);
  }, e.md = null, e.setSubject = function(t) {
    ct(t), e.subject.attributes = t, e.subject.hash = null;
  }, e.setAttributes = function(t) {
    ct(t), e.attributes = t;
  }, e.sign = function(t, a) {
    e.md = a || X.md.sha1.create();
    var r = oe[e.md.algorithm + "WithRSAEncryption"];
    if (!r) {
      var i = new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");
      throw i.algorithm = e.md.algorithm, i;
    }
    e.signatureOid = e.siginfo.algorithmOid = r, e.certificationRequestInfo = K.getCertificationRequestInfo(e);
    var n = d.toDer(e.certificationRequestInfo);
    e.md.update(n.getBytes()), e.signature = t.sign(e.md);
  }, e.verify = function() {
    var t = !1, a = e.md;
    if (a === null) {
      a = $r({
        signatureOid: e.signatureOid,
        type: "certification request"
      });
      var r = e.certificationRequestInfo || K.getCertificationRequestInfo(e), i = d.toDer(r);
      a.update(i.getBytes());
    }
    return a !== null && (t = Yi({
      certificate: e,
      md: a,
      signature: e.signature
    })), t;
  }, e;
};
function sr(e) {
  for (var t = d.create(
    d.Class.UNIVERSAL,
    d.Type.SEQUENCE,
    !0,
    []
  ), a, r, i = e.attributes, n = 0; n < i.length; ++n) {
    a = i[n];
    var s = a.value, o = d.Type.PRINTABLESTRING;
    "valueTagClass" in a && (o = a.valueTagClass, o === d.Type.UTF8 && (s = X.util.encodeUtf8(s))), r = d.create(d.Class.UNIVERSAL, d.Type.SET, !0, [
      d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
        // AttributeType
        d.create(
          d.Class.UNIVERSAL,
          d.Type.OID,
          !1,
          d.oidToDer(a.type).getBytes()
        ),
        // AttributeValue
        d.create(d.Class.UNIVERSAL, o, !1, s)
      ])
    ]), t.value.push(r);
  }
  return t;
}
function ct(e) {
  for (var t, a = 0; a < e.length; ++a) {
    if (t = e[a], typeof t.name > "u" && (t.type && t.type in K.oids ? t.name = K.oids[t.type] : t.shortName && t.shortName in Re && (t.name = K.oids[Re[t.shortName]])), typeof t.type > "u")
      if (t.name && t.name in K.oids)
        t.type = K.oids[t.name];
      else {
        var r = new Error("Attribute type not specified.");
        throw r.attribute = t, r;
      }
    if (typeof t.shortName > "u" && t.name && t.name in Re && (t.shortName = Re[t.name]), t.type === oe.extensionRequest && (t.valueConstructed = !0, t.valueTagClass = d.Type.SEQUENCE, !t.value && t.extensions)) {
      t.value = [];
      for (var i = 0; i < t.extensions.length; ++i)
        t.value.push(K.certificateExtensionToAsn1(
          Xi(t.extensions[i])
        ));
    }
    if (typeof t.value > "u") {
      var r = new Error("Attribute value not specified.");
      throw r.attribute = t, r;
    }
  }
}
function Xi(e, t) {
  if (t = t || {}, typeof e.name > "u" && e.id && e.id in K.oids && (e.name = K.oids[e.id]), typeof e.id > "u")
    if (e.name && e.name in K.oids)
      e.id = K.oids[e.name];
    else {
      var a = new Error("Extension ID not specified.");
      throw a.extension = e, a;
    }
  if (typeof e.value < "u")
    return e;
  if (e.name === "keyUsage") {
    var r = 0, i = 0, n = 0;
    e.digitalSignature && (i |= 128, r = 7), e.nonRepudiation && (i |= 64, r = 6), e.keyEncipherment && (i |= 32, r = 5), e.dataEncipherment && (i |= 16, r = 4), e.keyAgreement && (i |= 8, r = 3), e.keyCertSign && (i |= 4, r = 2), e.cRLSign && (i |= 2, r = 1), e.encipherOnly && (i |= 1, r = 0), e.decipherOnly && (n |= 128, r = 7);
    var s = String.fromCharCode(r);
    n !== 0 ? s += String.fromCharCode(i) + String.fromCharCode(n) : i !== 0 && (s += String.fromCharCode(i)), e.value = d.create(
      d.Class.UNIVERSAL,
      d.Type.BITSTRING,
      !1,
      s
    );
  } else if (e.name === "basicConstraints")
    e.value = d.create(
      d.Class.UNIVERSAL,
      d.Type.SEQUENCE,
      !0,
      []
    ), e.cA && e.value.value.push(d.create(
      d.Class.UNIVERSAL,
      d.Type.BOOLEAN,
      !1,
      "ÿ"
    )), "pathLenConstraint" in e && e.value.value.push(d.create(
      d.Class.UNIVERSAL,
      d.Type.INTEGER,
      !1,
      d.integerToDer(e.pathLenConstraint).getBytes()
    ));
  else if (e.name === "extKeyUsage") {
    e.value = d.create(
      d.Class.UNIVERSAL,
      d.Type.SEQUENCE,
      !0,
      []
    );
    var o = e.value.value;
    for (var l in e)
      e[l] === !0 && (l in oe ? o.push(d.create(
        d.Class.UNIVERSAL,
        d.Type.OID,
        !1,
        d.oidToDer(oe[l]).getBytes()
      )) : l.indexOf(".") !== -1 && o.push(d.create(
        d.Class.UNIVERSAL,
        d.Type.OID,
        !1,
        d.oidToDer(l).getBytes()
      )));
  } else if (e.name === "nsCertType") {
    var r = 0, i = 0;
    e.client && (i |= 128, r = 7), e.server && (i |= 64, r = 6), e.email && (i |= 32, r = 5), e.objsign && (i |= 16, r = 4), e.reserved && (i |= 8, r = 3), e.sslCA && (i |= 4, r = 2), e.emailCA && (i |= 2, r = 1), e.objCA && (i |= 1, r = 0);
    var s = String.fromCharCode(r);
    i !== 0 && (s += String.fromCharCode(i)), e.value = d.create(
      d.Class.UNIVERSAL,
      d.Type.BITSTRING,
      !1,
      s
    );
  } else if (e.name === "subjectAltName" || e.name === "issuerAltName") {
    e.value = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, []);
    for (var f, u = 0; u < e.altNames.length; ++u) {
      f = e.altNames[u];
      var s = f.value;
      if (f.type === 7 && f.ip) {
        if (s = X.util.bytesFromIP(f.ip), s === null) {
          var a = new Error(
            'Extension "ip" value is not a valid IPv4 or IPv6 address.'
          );
          throw a.extension = e, a;
        }
      } else f.type === 8 && (f.oid ? s = d.oidToDer(d.oidToDer(f.oid)) : s = d.oidToDer(s));
      e.value.value.push(d.create(
        d.Class.CONTEXT_SPECIFIC,
        f.type,
        !1,
        s
      ));
    }
  } else if (e.name === "nsComment" && t.cert) {
    if (!/^[\x00-\x7F]*$/.test(e.comment) || e.comment.length < 1 || e.comment.length > 128)
      throw new Error('Invalid "nsComment" content.');
    e.value = d.create(
      d.Class.UNIVERSAL,
      d.Type.IA5STRING,
      !1,
      e.comment
    );
  } else if (e.name === "subjectKeyIdentifier" && t.cert) {
    var p = t.cert.generateSubjectKeyIdentifier();
    e.subjectKeyIdentifier = p.toHex(), e.value = d.create(
      d.Class.UNIVERSAL,
      d.Type.OCTETSTRING,
      !1,
      p.getBytes()
    );
  } else if (e.name === "authorityKeyIdentifier" && t.cert) {
    e.value = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, []);
    var o = e.value.value;
    if (e.keyIdentifier) {
      var m = e.keyIdentifier === !0 ? t.cert.generateSubjectKeyIdentifier().getBytes() : e.keyIdentifier;
      o.push(
        d.create(d.Class.CONTEXT_SPECIFIC, 0, !1, m)
      );
    }
    if (e.authorityCertIssuer) {
      var S = [
        d.create(d.Class.CONTEXT_SPECIFIC, 4, !0, [
          sr(e.authorityCertIssuer === !0 ? t.cert.issuer : e.authorityCertIssuer)
        ])
      ];
      o.push(
        d.create(d.Class.CONTEXT_SPECIFIC, 1, !0, S)
      );
    }
    if (e.serialNumber) {
      var C = X.util.hexToBytes(e.serialNumber === !0 ? t.cert.serialNumber : e.serialNumber);
      o.push(
        d.create(d.Class.CONTEXT_SPECIFIC, 2, !1, C)
      );
    }
  } else if (e.name === "cRLDistributionPoints") {
    e.value = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, []);
    for (var o = e.value.value, A = d.create(
      d.Class.UNIVERSAL,
      d.Type.SEQUENCE,
      !0,
      []
    ), b = d.create(
      d.Class.CONTEXT_SPECIFIC,
      0,
      !0,
      []
    ), f, u = 0; u < e.altNames.length; ++u) {
      f = e.altNames[u];
      var s = f.value;
      if (f.type === 7 && f.ip) {
        if (s = X.util.bytesFromIP(f.ip), s === null) {
          var a = new Error(
            'Extension "ip" value is not a valid IPv4 or IPv6 address.'
          );
          throw a.extension = e, a;
        }
      } else f.type === 8 && (f.oid ? s = d.oidToDer(d.oidToDer(f.oid)) : s = d.oidToDer(s));
      b.value.push(d.create(
        d.Class.CONTEXT_SPECIFIC,
        f.type,
        !1,
        s
      ));
    }
    A.value.push(d.create(
      d.Class.CONTEXT_SPECIFIC,
      0,
      !0,
      [b]
    )), o.push(A);
  }
  if (typeof e.value > "u") {
    var a = new Error("Extension value not specified.");
    throw a.extension = e, a;
  }
  return e;
}
function Pa(e, t) {
  switch (e) {
    case oe["RSASSA-PSS"]:
      var a = [];
      return t.hash.algorithmOid !== void 0 && a.push(d.create(d.Class.CONTEXT_SPECIFIC, 0, !0, [
        d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
          d.create(
            d.Class.UNIVERSAL,
            d.Type.OID,
            !1,
            d.oidToDer(t.hash.algorithmOid).getBytes()
          ),
          d.create(d.Class.UNIVERSAL, d.Type.NULL, !1, "")
        ])
      ])), t.mgf.algorithmOid !== void 0 && a.push(d.create(d.Class.CONTEXT_SPECIFIC, 1, !0, [
        d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
          d.create(
            d.Class.UNIVERSAL,
            d.Type.OID,
            !1,
            d.oidToDer(t.mgf.algorithmOid).getBytes()
          ),
          d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
            d.create(
              d.Class.UNIVERSAL,
              d.Type.OID,
              !1,
              d.oidToDer(t.mgf.hash.algorithmOid).getBytes()
            ),
            d.create(d.Class.UNIVERSAL, d.Type.NULL, !1, "")
          ])
        ])
      ])), t.saltLength !== void 0 && a.push(d.create(d.Class.CONTEXT_SPECIFIC, 2, !0, [
        d.create(
          d.Class.UNIVERSAL,
          d.Type.INTEGER,
          !1,
          d.integerToDer(t.saltLength).getBytes()
        )
      ])), d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, a);
    default:
      return d.create(d.Class.UNIVERSAL, d.Type.NULL, !1, "");
  }
}
function d0(e) {
  var t = d.create(d.Class.CONTEXT_SPECIFIC, 0, !0, []);
  if (e.attributes.length === 0)
    return t;
  for (var a = e.attributes, r = 0; r < a.length; ++r) {
    var i = a[r], n = i.value, s = d.Type.UTF8;
    "valueTagClass" in i && (s = i.valueTagClass), s === d.Type.UTF8 && (n = X.util.encodeUtf8(n));
    var o = !1;
    "valueConstructed" in i && (o = i.valueConstructed);
    var l = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
      // AttributeType
      d.create(
        d.Class.UNIVERSAL,
        d.Type.OID,
        !1,
        d.oidToDer(i.type).getBytes()
      ),
      d.create(d.Class.UNIVERSAL, d.Type.SET, !0, [
        // AttributeValue
        d.create(
          d.Class.UNIVERSAL,
          s,
          o,
          n
        )
      ])
    ]);
    t.value.push(l);
  }
  return t;
}
var y0 = /* @__PURE__ */ new Date("1950-01-01T00:00:00Z"), g0 = /* @__PURE__ */ new Date("2050-01-01T00:00:00Z");
function fi(e) {
  return e >= y0 && e < g0 ? d.create(
    d.Class.UNIVERSAL,
    d.Type.UTCTIME,
    !1,
    d.dateToUtcTime(e)
  ) : d.create(
    d.Class.UNIVERSAL,
    d.Type.GENERALIZEDTIME,
    !1,
    d.dateToGeneralizedTime(e)
  );
}
K.getTBSCertificate = function(e) {
  var t = fi(e.validity.notBefore), a = fi(e.validity.notAfter), r = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
    // version
    d.create(d.Class.CONTEXT_SPECIFIC, 0, !0, [
      // integer
      d.create(
        d.Class.UNIVERSAL,
        d.Type.INTEGER,
        !1,
        d.integerToDer(e.version).getBytes()
      )
    ]),
    // serialNumber
    d.create(
      d.Class.UNIVERSAL,
      d.Type.INTEGER,
      !1,
      X.util.hexToBytes(e.serialNumber)
    ),
    // signature
    d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
      // algorithm
      d.create(
        d.Class.UNIVERSAL,
        d.Type.OID,
        !1,
        d.oidToDer(e.siginfo.algorithmOid).getBytes()
      ),
      // parameters
      Pa(
        e.siginfo.algorithmOid,
        e.siginfo.parameters
      )
    ]),
    // issuer
    sr(e.issuer),
    // validity
    d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
      t,
      a
    ]),
    // subject
    sr(e.subject),
    // SubjectPublicKeyInfo
    K.publicKeyToAsn1(e.publicKey)
  ]);
  return e.issuer.uniqueId && r.value.push(
    d.create(d.Class.CONTEXT_SPECIFIC, 1, !0, [
      d.create(
        d.Class.UNIVERSAL,
        d.Type.BITSTRING,
        !1,
        // TODO: support arbitrary bit length ids
        "\0" + e.issuer.uniqueId
      )
    ])
  ), e.subject.uniqueId && r.value.push(
    d.create(d.Class.CONTEXT_SPECIFIC, 2, !0, [
      d.create(
        d.Class.UNIVERSAL,
        d.Type.BITSTRING,
        !1,
        // TODO: support arbitrary bit length ids
        "\0" + e.subject.uniqueId
      )
    ])
  ), e.extensions.length > 0 && r.value.push(K.certificateExtensionsToAsn1(e.extensions)), r;
};
K.getCertificationRequestInfo = function(e) {
  var t = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
    // version
    d.create(
      d.Class.UNIVERSAL,
      d.Type.INTEGER,
      !1,
      d.integerToDer(e.version).getBytes()
    ),
    // subject
    sr(e.subject),
    // SubjectPublicKeyInfo
    K.publicKeyToAsn1(e.publicKey),
    // attributes
    d0(e)
  ]);
  return t;
};
K.distinguishedNameToAsn1 = function(e) {
  return sr(e);
};
K.certificateToAsn1 = function(e) {
  var t = e.tbsCertificate || K.getTBSCertificate(e);
  return d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
    // TBSCertificate
    t,
    // AlgorithmIdentifier (signature algorithm)
    d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
      // algorithm
      d.create(
        d.Class.UNIVERSAL,
        d.Type.OID,
        !1,
        d.oidToDer(e.signatureOid).getBytes()
      ),
      // parameters
      Pa(e.signatureOid, e.signatureParameters)
    ]),
    // SignatureValue
    d.create(
      d.Class.UNIVERSAL,
      d.Type.BITSTRING,
      !1,
      "\0" + e.signature
    )
  ]);
};
K.certificateExtensionsToAsn1 = function(e) {
  var t = d.create(d.Class.CONTEXT_SPECIFIC, 3, !0, []), a = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, []);
  t.value.push(a);
  for (var r = 0; r < e.length; ++r)
    a.value.push(K.certificateExtensionToAsn1(e[r]));
  return t;
};
K.certificateExtensionToAsn1 = function(e) {
  var t = d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, []);
  t.value.push(d.create(
    d.Class.UNIVERSAL,
    d.Type.OID,
    !1,
    d.oidToDer(e.id).getBytes()
  )), e.critical && t.value.push(d.create(
    d.Class.UNIVERSAL,
    d.Type.BOOLEAN,
    !1,
    "ÿ"
  ));
  var a = e.value;
  return typeof e.value != "string" && (a = d.toDer(a).getBytes()), t.value.push(d.create(
    d.Class.UNIVERSAL,
    d.Type.OCTETSTRING,
    !1,
    a
  )), t;
};
K.certificationRequestToAsn1 = function(e) {
  var t = e.certificationRequestInfo || K.getCertificationRequestInfo(e);
  return d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
    // CertificationRequestInfo
    t,
    // AlgorithmIdentifier (signature algorithm)
    d.create(d.Class.UNIVERSAL, d.Type.SEQUENCE, !0, [
      // algorithm
      d.create(
        d.Class.UNIVERSAL,
        d.Type.OID,
        !1,
        d.oidToDer(e.signatureOid).getBytes()
      ),
      // parameters
      Pa(e.signatureOid, e.signatureParameters)
    ]),
    // signature
    d.create(
      d.Class.UNIVERSAL,
      d.Type.BITSTRING,
      !1,
      "\0" + e.signature
    )
  ]);
};
K.createCaStore = function(e) {
  var t = {
    // stored certificates
    certs: {}
  };
  t.getIssuer = function(s) {
    var o = a(s.issuer);
    return o;
  }, t.addCertificate = function(s) {
    if (typeof s == "string" && (s = X.pki.certificateFromPem(s)), r(s.subject), !t.hasCertificate(s))
      if (s.subject.hash in t.certs) {
        var o = t.certs[s.subject.hash];
        X.util.isArray(o) || (o = [o]), o.push(s), t.certs[s.subject.hash] = o;
      } else
        t.certs[s.subject.hash] = s;
  }, t.hasCertificate = function(s) {
    typeof s == "string" && (s = X.pki.certificateFromPem(s));
    var o = a(s.subject);
    if (!o)
      return !1;
    X.util.isArray(o) || (o = [o]);
    for (var l = d.toDer(K.certificateToAsn1(s)).getBytes(), f = 0; f < o.length; ++f) {
      var u = d.toDer(K.certificateToAsn1(o[f])).getBytes();
      if (l === u)
        return !0;
    }
    return !1;
  }, t.listAllCertificates = function() {
    var s = [];
    for (var o in t.certs)
      if (t.certs.hasOwnProperty(o)) {
        var l = t.certs[o];
        if (!X.util.isArray(l))
          s.push(l);
        else
          for (var f = 0; f < l.length; ++f)
            s.push(l[f]);
      }
    return s;
  }, t.removeCertificate = function(s) {
    var o;
    if (typeof s == "string" && (s = X.pki.certificateFromPem(s)), r(s.subject), !t.hasCertificate(s))
      return null;
    var l = a(s.subject);
    if (!X.util.isArray(l))
      return o = t.certs[s.subject.hash], delete t.certs[s.subject.hash], o;
    for (var f = d.toDer(K.certificateToAsn1(s)).getBytes(), u = 0; u < l.length; ++u) {
      var p = d.toDer(K.certificateToAsn1(l[u])).getBytes();
      f === p && (o = l[u], l.splice(u, 1));
    }
    return l.length === 0 && delete t.certs[s.subject.hash], o;
  };
  function a(s) {
    return r(s), t.certs[s.hash] || null;
  }
  function r(s) {
    if (!s.hash) {
      var o = X.md.sha1.create();
      s.attributes = K.RDNAttributesAsArray(sr(s), o), s.hash = o.digest().toHex();
    }
  }
  if (e)
    for (var i = 0; i < e.length; ++i) {
      var n = e[i];
      t.addCertificate(n);
    }
  return t;
};
K.certificateError = {
  bad_certificate: "forge.pki.BadCertificate",
  unsupported_certificate: "forge.pki.UnsupportedCertificate",
  certificate_revoked: "forge.pki.CertificateRevoked",
  certificate_expired: "forge.pki.CertificateExpired",
  certificate_unknown: "forge.pki.CertificateUnknown",
  unknown_ca: "forge.pki.UnknownCertificateAuthority"
};
K.verifyCertificateChain = function(e, t, a) {
  typeof a == "function" && (a = { verify: a }), a = a || {}, t = t.slice(0);
  var r = t.slice(0), i = a.validityCheckDate;
  typeof i > "u" && (i = /* @__PURE__ */ new Date());
  var n = !0, s = null, o = 0;
  do {
    var l = t.shift(), f = null, u = !1;
    if (i && (i < l.validity.notBefore || i > l.validity.notAfter) && (s = {
      message: "Certificate is not valid yet or has expired.",
      error: K.certificateError.certificate_expired,
      notBefore: l.validity.notBefore,
      notAfter: l.validity.notAfter,
      // TODO: we might want to reconsider renaming 'now' to
      // 'validityCheckDate' should this API be changed in the future.
      now: i
    }), s === null) {
      if (f = t[0] || e.getIssuer(l), f === null && l.isIssuer(l) && (u = !0, f = l), f) {
        var p = f;
        X.util.isArray(p) || (p = [p]);
        for (var m = !1; !m && p.length > 0; ) {
          f = p.shift();
          try {
            m = f.verify(l);
          } catch {
          }
        }
        m || (s = {
          message: "Certificate signature is invalid.",
          error: K.certificateError.bad_certificate
        });
      }
      s === null && (!f || u) && !e.hasCertificate(l) && (s = {
        message: "Certificate is not trusted.",
        error: K.certificateError.unknown_ca
      });
    }
    if (s === null && f && !l.isIssuer(f) && (s = {
      message: "Certificate issuer is invalid.",
      error: K.certificateError.bad_certificate
    }), s === null)
      for (var S = {
        keyUsage: !0,
        basicConstraints: !0
      }, C = 0; s === null && C < l.extensions.length; ++C) {
        var A = l.extensions[C];
        A.critical && !(A.name in S) && (s = {
          message: "Certificate has an unsupported critical extension.",
          error: K.certificateError.unsupported_certificate
        });
      }
    if (s === null && (!n || t.length === 0 && (!f || u))) {
      var b = l.getExtension("basicConstraints"), _ = l.getExtension("keyUsage");
      if (_ !== null && (!_.keyCertSign || b === null) && (s = {
        message: "Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",
        error: K.certificateError.bad_certificate
      }), s === null && b !== null && !b.cA && (s = {
        message: "Certificate basicConstraints indicates the certificate is not a CA.",
        error: K.certificateError.bad_certificate
      }), s === null && _ !== null && "pathLenConstraint" in b) {
        var U = o - 1;
        U > b.pathLenConstraint && (s = {
          message: "Certificate basicConstraints pathLenConstraint violated.",
          error: K.certificateError.bad_certificate
        });
      }
    }
    var D = s === null ? !0 : s.error, G = a.verify ? a.verify(D, o, r) : D;
    if (G === !0)
      s = null;
    else
      throw D === !0 && (s = {
        message: "The application rejected the certificate.",
        error: K.certificateError.bad_certificate
      }), (G || G === 0) && (typeof G == "object" && !X.util.isArray(G) ? (G.message && (s.message = G.message), G.error && (s.error = G.error)) : typeof G == "string" && (s.error = G)), s;
    n = !1, ++o;
  } while (t.length > 0);
  return !0;
};
var me = ee, x = me.asn1, re = me.pki, Er = me.pkcs12 = me.pkcs12 || {}, Wi = {
  name: "ContentInfo",
  tagClass: x.Class.UNIVERSAL,
  type: x.Type.SEQUENCE,
  // a ContentInfo
  constructed: !0,
  value: [{
    name: "ContentInfo.contentType",
    tagClass: x.Class.UNIVERSAL,
    type: x.Type.OID,
    constructed: !1,
    capture: "contentType"
  }, {
    name: "ContentInfo.content",
    tagClass: x.Class.CONTEXT_SPECIFIC,
    constructed: !0,
    captureAsn1: "content"
  }]
}, v0 = {
  name: "PFX",
  tagClass: x.Class.UNIVERSAL,
  type: x.Type.SEQUENCE,
  constructed: !0,
  value: [
    {
      name: "PFX.version",
      tagClass: x.Class.UNIVERSAL,
      type: x.Type.INTEGER,
      constructed: !1,
      capture: "version"
    },
    Wi,
    {
      name: "PFX.macData",
      tagClass: x.Class.UNIVERSAL,
      type: x.Type.SEQUENCE,
      constructed: !0,
      optional: !0,
      captureAsn1: "mac",
      value: [{
        name: "PFX.macData.mac",
        tagClass: x.Class.UNIVERSAL,
        type: x.Type.SEQUENCE,
        // DigestInfo
        constructed: !0,
        value: [{
          name: "PFX.macData.mac.digestAlgorithm",
          tagClass: x.Class.UNIVERSAL,
          type: x.Type.SEQUENCE,
          // DigestAlgorithmIdentifier
          constructed: !0,
          value: [{
            name: "PFX.macData.mac.digestAlgorithm.algorithm",
            tagClass: x.Class.UNIVERSAL,
            type: x.Type.OID,
            constructed: !1,
            capture: "macAlgorithm"
          }, {
            name: "PFX.macData.mac.digestAlgorithm.parameters",
            tagClass: x.Class.UNIVERSAL,
            captureAsn1: "macAlgorithmParameters"
          }]
        }, {
          name: "PFX.macData.mac.digest",
          tagClass: x.Class.UNIVERSAL,
          type: x.Type.OCTETSTRING,
          constructed: !1,
          capture: "macDigest"
        }]
      }, {
        name: "PFX.macData.macSalt",
        tagClass: x.Class.UNIVERSAL,
        type: x.Type.OCTETSTRING,
        constructed: !1,
        capture: "macSalt"
      }, {
        name: "PFX.macData.iterations",
        tagClass: x.Class.UNIVERSAL,
        type: x.Type.INTEGER,
        constructed: !1,
        optional: !0,
        capture: "macIterations"
      }]
    }
  ]
}, m0 = {
  name: "SafeBag",
  tagClass: x.Class.UNIVERSAL,
  type: x.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "SafeBag.bagId",
    tagClass: x.Class.UNIVERSAL,
    type: x.Type.OID,
    constructed: !1,
    capture: "bagId"
  }, {
    name: "SafeBag.bagValue",
    tagClass: x.Class.CONTEXT_SPECIFIC,
    constructed: !0,
    captureAsn1: "bagValue"
  }, {
    name: "SafeBag.bagAttributes",
    tagClass: x.Class.UNIVERSAL,
    type: x.Type.SET,
    constructed: !0,
    optional: !0,
    capture: "bagAttributes"
  }]
}, C0 = {
  name: "Attribute",
  tagClass: x.Class.UNIVERSAL,
  type: x.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "Attribute.attrId",
    tagClass: x.Class.UNIVERSAL,
    type: x.Type.OID,
    constructed: !1,
    capture: "oid"
  }, {
    name: "Attribute.attrValues",
    tagClass: x.Class.UNIVERSAL,
    type: x.Type.SET,
    constructed: !0,
    capture: "values"
  }]
}, E0 = {
  name: "CertBag",
  tagClass: x.Class.UNIVERSAL,
  type: x.Type.SEQUENCE,
  constructed: !0,
  value: [{
    name: "CertBag.certId",
    tagClass: x.Class.UNIVERSAL,
    type: x.Type.OID,
    constructed: !1,
    capture: "certId"
  }, {
    name: "CertBag.certValue",
    tagClass: x.Class.CONTEXT_SPECIFIC,
    constructed: !0,
    /* So far we only support X.509 certificates (which are wrapped in
       an OCTET STRING, hence hard code that here). */
    value: [{
      name: "CertBag.certValue[0]",
      tagClass: x.Class.UNIVERSAL,
      type: x.Class.OCTETSTRING,
      constructed: !1,
      capture: "cert"
    }]
  }]
};
function pr(e, t, a, r) {
  for (var i = [], n = 0; n < e.length; n++)
    for (var s = 0; s < e[n].safeBags.length; s++) {
      var o = e[n].safeBags[s];
      if (!(r !== void 0 && o.type !== r)) {
        if (t === null) {
          i.push(o);
          continue;
        }
        o.attributes[t] !== void 0 && o.attributes[t].indexOf(a) >= 0 && i.push(o);
      }
    }
  return i;
}
Er.pkcs12FromAsn1 = function(e, t, a) {
  typeof t == "string" ? (a = t, t = !0) : t === void 0 && (t = !0);
  var r = {}, i = [];
  if (!x.validate(e, v0, r, i)) {
    var n = new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");
    throw n.errors = n, n;
  }
  var s = {
    version: r.version.charCodeAt(0),
    safeContents: [],
    /**
     * Gets bags with matching attributes.
     *
     * @param filter the attributes to filter by:
     *          [localKeyId] the localKeyId to search for.
     *          [localKeyIdHex] the localKeyId in hex to search for.
     *          [friendlyName] the friendly name to search for.
     *          [bagType] bag type to narrow each attribute search by.
     *
     * @return a map of attribute type to an array of matching bags or, if no
     *           attribute was given but a bag type, the map key will be the
     *           bag type.
     */
    getBags: function(b) {
      var _ = {}, U;
      return "localKeyId" in b ? U = b.localKeyId : "localKeyIdHex" in b && (U = me.util.hexToBytes(b.localKeyIdHex)), U === void 0 && !("friendlyName" in b) && "bagType" in b && (_[b.bagType] = pr(
        s.safeContents,
        null,
        null,
        b.bagType
      )), U !== void 0 && (_.localKeyId = pr(
        s.safeContents,
        "localKeyId",
        U,
        b.bagType
      )), "friendlyName" in b && (_.friendlyName = pr(
        s.safeContents,
        "friendlyName",
        b.friendlyName,
        b.bagType
      )), _;
    },
    /**
     * DEPRECATED: use getBags() instead.
     *
     * Get bags with matching friendlyName attribute.
     *
     * @param friendlyName the friendly name to search for.
     * @param [bagType] bag type to narrow search by.
     *
     * @return an array of bags with matching friendlyName attribute.
     */
    getBagsByFriendlyName: function(b, _) {
      return pr(
        s.safeContents,
        "friendlyName",
        b,
        _
      );
    },
    /**
     * DEPRECATED: use getBags() instead.
     *
     * Get bags with matching localKeyId attribute.
     *
     * @param localKeyId the localKeyId to search for.
     * @param [bagType] bag type to narrow search by.
     *
     * @return an array of bags with matching localKeyId attribute.
     */
    getBagsByLocalKeyId: function(b, _) {
      return pr(
        s.safeContents,
        "localKeyId",
        b,
        _
      );
    }
  };
  if (r.version.charCodeAt(0) !== 3) {
    var n = new Error("PKCS#12 PFX of version other than 3 not supported.");
    throw n.version = r.version.charCodeAt(0), n;
  }
  if (x.derToOid(r.contentType) !== re.oids.data) {
    var n = new Error("Only PKCS#12 PFX in password integrity mode supported.");
    throw n.oid = x.derToOid(r.contentType), n;
  }
  var o = r.content.value[0];
  if (o.tagClass !== x.Class.UNIVERSAL || o.type !== x.Type.OCTETSTRING)
    throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");
  if (o = Va(o), r.mac) {
    var l = null, f = 0, u = x.derToOid(r.macAlgorithm);
    switch (u) {
      case re.oids.sha1:
        l = me.md.sha1.create(), f = 20;
        break;
      case re.oids.sha256:
        l = me.md.sha256.create(), f = 32;
        break;
      case re.oids.sha384:
        l = me.md.sha384.create(), f = 48;
        break;
      case re.oids.sha512:
        l = me.md.sha512.create(), f = 64;
        break;
      case re.oids.md5:
        l = me.md.md5.create(), f = 16;
        break;
    }
    if (l === null)
      throw new Error("PKCS#12 uses unsupported MAC algorithm: " + u);
    var p = new me.util.ByteBuffer(r.macSalt), m = "macIterations" in r ? parseInt(me.util.bytesToHex(r.macIterations), 16) : 1, S = Er.generateKey(
      a,
      p,
      3,
      m,
      f,
      l
    ), C = me.hmac.create();
    C.start(l, S), C.update(o.value);
    var A = C.getMac();
    if (A.getBytes() !== r.macDigest)
      throw new Error("PKCS#12 MAC could not be verified. Invalid password?");
  } else if (Array.isArray(e.value) && e.value.length > 2)
    throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");
  return x0(s, o.value, t, a), s;
};
function Va(e) {
  if (e.composed || e.constructed) {
    for (var t = me.util.createBuffer(), a = 0; a < e.value.length; ++a)
      t.putBytes(e.value[a].value);
    e.composed = e.constructed = !1, e.value = t.getBytes();
  }
  return e;
}
function x0(e, t, a, r) {
  if (t = x.fromDer(t, a), t.tagClass !== x.Class.UNIVERSAL || t.type !== x.Type.SEQUENCE || t.constructed !== !0)
    throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");
  for (var i = 0; i < t.value.length; i++) {
    var n = t.value[i], s = {}, o = [];
    if (!x.validate(n, Wi, s, o)) {
      var l = new Error("Cannot read ContentInfo.");
      throw l.errors = o, l;
    }
    var f = {
      encrypted: !1
    }, u = null, p = s.content.value[0];
    switch (x.derToOid(s.contentType)) {
      case re.oids.data:
        if (p.tagClass !== x.Class.UNIVERSAL || p.type !== x.Type.OCTETSTRING)
          throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");
        u = Va(p).value;
        break;
      case re.oids.encryptedData:
        u = S0(p, r), f.encrypted = !0;
        break;
      default:
        var l = new Error("Unsupported PKCS#12 contentType.");
        throw l.contentType = x.derToOid(s.contentType), l;
    }
    f.safeBags = T0(u, a, r), e.safeContents.push(f);
  }
}
function S0(e, t) {
  var a = {}, r = [];
  if (!x.validate(
    e,
    me.pkcs7.asn1.encryptedDataValidator,
    a,
    r
  )) {
    var i = new Error("Cannot read EncryptedContentInfo.");
    throw i.errors = r, i;
  }
  var n = x.derToOid(a.contentType);
  if (n !== re.oids.data) {
    var i = new Error(
      "PKCS#12 EncryptedContentInfo ContentType is not Data."
    );
    throw i.oid = n, i;
  }
  n = x.derToOid(a.encAlgorithm);
  var s = re.pbe.getCipher(n, a.encParameter, t), o = Va(a.encryptedContentAsn1), l = me.util.createBuffer(o.value);
  if (s.update(l), !s.finish())
    throw new Error("Failed to decrypt PKCS#12 SafeContents.");
  return s.output.getBytes();
}
function T0(e, t, a) {
  if (!t && e.length === 0)
    return [];
  if (e = x.fromDer(e, t), e.tagClass !== x.Class.UNIVERSAL || e.type !== x.Type.SEQUENCE || e.constructed !== !0)
    throw new Error(
      "PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag."
    );
  for (var r = [], i = 0; i < e.value.length; i++) {
    var n = e.value[i], s = {}, o = [];
    if (!x.validate(n, m0, s, o)) {
      var l = new Error("Cannot read SafeBag.");
      throw l.errors = o, l;
    }
    var f = {
      type: x.derToOid(s.bagId),
      attributes: I0(s.bagAttributes)
    };
    r.push(f);
    var u, p, m = s.bagValue.value[0];
    switch (f.type) {
      case re.oids.pkcs8ShroudedKeyBag:
        if (m = re.decryptPrivateKeyInfo(m, a), m === null)
          throw new Error(
            "Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?"
          );
      case re.oids.keyBag:
        try {
          f.key = re.privateKeyFromAsn1(m);
        } catch {
          f.key = null, f.asn1 = m;
        }
        continue;
      case re.oids.certBag:
        u = E0, p = function() {
          if (x.derToOid(s.certId) !== re.oids.x509Certificate) {
            var C = new Error(
              "Unsupported certificate type, only X.509 supported."
            );
            throw C.oid = x.derToOid(s.certId), C;
          }
          var A = x.fromDer(s.cert, t);
          try {
            f.cert = re.certificateFromAsn1(A, !0);
          } catch {
            f.cert = null, f.asn1 = A;
          }
        };
        break;
      default:
        var l = new Error("Unsupported PKCS#12 SafeBag type.");
        throw l.oid = f.type, l;
    }
    if (u !== void 0 && !x.validate(m, u, s, o)) {
      var l = new Error("Cannot read PKCS#12 " + u.name);
      throw l.errors = o, l;
    }
    p();
  }
  return r;
}
function I0(e) {
  var t = {};
  if (e !== void 0)
    for (var a = 0; a < e.length; ++a) {
      var r = {}, i = [];
      if (!x.validate(e[a], C0, r, i)) {
        var n = new Error("Cannot read PKCS#12 BagAttribute.");
        throw n.errors = i, n;
      }
      var s = x.derToOid(r.oid);
      if (re.oids[s] !== void 0) {
        t[re.oids[s]] = [];
        for (var o = 0; o < r.values.length; ++o)
          t[re.oids[s]].push(r.values[o].value);
      }
    }
  return t;
}
Er.toPkcs12Asn1 = function(e, t, a, r) {
  r = r || {}, r.saltSize = r.saltSize || 8, r.count = r.count || 2048, r.algorithm = r.algorithm || r.encAlgorithm || "aes128", "useMac" in r || (r.useMac = !0), "localKeyId" in r || (r.localKeyId = null), "generateLocalKeyId" in r || (r.generateLocalKeyId = !0);
  var i = r.localKeyId, n;
  if (i !== null)
    i = me.util.hexToBytes(i);
  else if (r.generateLocalKeyId)
    if (t) {
      var s = me.util.isArray(t) ? t[0] : t;
      typeof s == "string" && (s = re.certificateFromPem(s));
      var o = me.md.sha1.create();
      o.update(x.toDer(re.certificateToAsn1(s)).getBytes()), i = o.digest().getBytes();
    } else
      i = me.random.getBytes(20);
  var l = [];
  i !== null && l.push(
    // localKeyID
    x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // attrId
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OID,
        !1,
        x.oidToDer(re.oids.localKeyId).getBytes()
      ),
      // attrValues
      x.create(x.Class.UNIVERSAL, x.Type.SET, !0, [
        x.create(
          x.Class.UNIVERSAL,
          x.Type.OCTETSTRING,
          !1,
          i
        )
      ])
    ])
  ), "friendlyName" in r && l.push(
    // friendlyName
    x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // attrId
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OID,
        !1,
        x.oidToDer(re.oids.friendlyName).getBytes()
      ),
      // attrValues
      x.create(x.Class.UNIVERSAL, x.Type.SET, !0, [
        x.create(
          x.Class.UNIVERSAL,
          x.Type.BMPSTRING,
          !1,
          r.friendlyName
        )
      ])
    ])
  ), l.length > 0 && (n = x.create(x.Class.UNIVERSAL, x.Type.SET, !0, l));
  var f = [], u = [];
  t !== null && (me.util.isArray(t) ? u = t : u = [t]);
  for (var p = [], m = 0; m < u.length; ++m) {
    t = u[m], typeof t == "string" && (t = re.certificateFromPem(t));
    var S = m === 0 ? n : void 0, C = re.certificateToAsn1(t), A = x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // bagId
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OID,
        !1,
        x.oidToDer(re.oids.certBag).getBytes()
      ),
      // bagValue
      x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
        // CertBag
        x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
          // certId
          x.create(
            x.Class.UNIVERSAL,
            x.Type.OID,
            !1,
            x.oidToDer(re.oids.x509Certificate).getBytes()
          ),
          // certValue (x509Certificate)
          x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
            x.create(
              x.Class.UNIVERSAL,
              x.Type.OCTETSTRING,
              !1,
              x.toDer(C).getBytes()
            )
          ])
        ])
      ]),
      // bagAttributes (OPTIONAL)
      S
    ]);
    p.push(A);
  }
  if (p.length > 0) {
    var b = x.create(
      x.Class.UNIVERSAL,
      x.Type.SEQUENCE,
      !0,
      p
    ), _ = (
      // PKCS#7 ContentInfo
      x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
        // contentType
        x.create(
          x.Class.UNIVERSAL,
          x.Type.OID,
          !1,
          // OID for the content type is 'data'
          x.oidToDer(re.oids.data).getBytes()
        ),
        // content
        x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
          x.create(
            x.Class.UNIVERSAL,
            x.Type.OCTETSTRING,
            !1,
            x.toDer(b).getBytes()
          )
        ])
      ])
    );
    f.push(_);
  }
  var U = null;
  if (e !== null) {
    var D = re.wrapRsaPrivateKey(re.privateKeyToAsn1(e));
    a === null ? U = x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // bagId
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OID,
        !1,
        x.oidToDer(re.oids.keyBag).getBytes()
      ),
      // bagValue
      x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
        // PrivateKeyInfo
        D
      ]),
      // bagAttributes (OPTIONAL)
      n
    ]) : U = x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // bagId
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OID,
        !1,
        x.oidToDer(re.oids.pkcs8ShroudedKeyBag).getBytes()
      ),
      // bagValue
      x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
        // EncryptedPrivateKeyInfo
        re.encryptPrivateKeyInfo(D, a, r)
      ]),
      // bagAttributes (OPTIONAL)
      n
    ]);
    var G = x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [U]), O = (
      // PKCS#7 ContentInfo
      x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
        // contentType
        x.create(
          x.Class.UNIVERSAL,
          x.Type.OID,
          !1,
          // OID for the content type is 'data'
          x.oidToDer(re.oids.data).getBytes()
        ),
        // content
        x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
          x.create(
            x.Class.UNIVERSAL,
            x.Type.OCTETSTRING,
            !1,
            x.toDer(G).getBytes()
          )
        ])
      ])
    );
    f.push(O);
  }
  var F = x.create(
    x.Class.UNIVERSAL,
    x.Type.SEQUENCE,
    !0,
    f
  ), $;
  if (r.useMac) {
    var o = me.md.sha1.create(), j = new me.util.ByteBuffer(
      me.random.getBytes(r.saltSize)
    ), le = r.count, e = Er.generateKey(a, j, 3, le, 20), he = me.hmac.create();
    he.start(o, e), he.update(x.toDer(F).getBytes());
    var de = he.getMac();
    $ = x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // mac DigestInfo
      x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
        // digestAlgorithm
        x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
          // algorithm = SHA-1
          x.create(
            x.Class.UNIVERSAL,
            x.Type.OID,
            !1,
            x.oidToDer(re.oids.sha1).getBytes()
          ),
          // parameters = Null
          x.create(x.Class.UNIVERSAL, x.Type.NULL, !1, "")
        ]),
        // digest
        x.create(
          x.Class.UNIVERSAL,
          x.Type.OCTETSTRING,
          !1,
          de.getBytes()
        )
      ]),
      // macSalt OCTET STRING
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OCTETSTRING,
        !1,
        j.getBytes()
      ),
      // iterations INTEGER (XXX: Only support count < 65536)
      x.create(
        x.Class.UNIVERSAL,
        x.Type.INTEGER,
        !1,
        x.integerToDer(le).getBytes()
      )
    ]);
  }
  return x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
    // version (3)
    x.create(
      x.Class.UNIVERSAL,
      x.Type.INTEGER,
      !1,
      x.integerToDer(3).getBytes()
    ),
    // PKCS#7 ContentInfo
    x.create(x.Class.UNIVERSAL, x.Type.SEQUENCE, !0, [
      // contentType
      x.create(
        x.Class.UNIVERSAL,
        x.Type.OID,
        !1,
        // OID for the content type is 'data'
        x.oidToDer(re.oids.data).getBytes()
      ),
      // content
      x.create(x.Class.CONTEXT_SPECIFIC, 0, !0, [
        x.create(
          x.Class.UNIVERSAL,
          x.Type.OCTETSTRING,
          !1,
          x.toDer(F).getBytes()
        )
      ])
    ]),
    $
  ]);
};
Er.generateKey = me.pbe.generatePkcs12Key;
var Gt = ee, Fa = Gt.asn1, or = Gt.pki = Gt.pki || {};
or.pemToDer = function(e) {
  var t = Gt.pem.decode(e)[0];
  if (t.procType && t.procType.type === "ENCRYPTED")
    throw new Error("Could not convert PEM to DER; PEM is encrypted.");
  return Gt.util.createBuffer(t.body);
};
or.privateKeyFromPem = function(e) {
  var t = Gt.pem.decode(e)[0];
  if (t.type !== "PRIVATE KEY" && t.type !== "RSA PRIVATE KEY") {
    var a = new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
    throw a.headerType = t.type, a;
  }
  if (t.procType && t.procType.type === "ENCRYPTED")
    throw new Error("Could not convert private key from PEM; PEM is encrypted.");
  var r = Fa.fromDer(t.body);
  return or.privateKeyFromAsn1(r);
};
or.privateKeyToPem = function(e, t) {
  var a = {
    type: "RSA PRIVATE KEY",
    body: Fa.toDer(or.privateKeyToAsn1(e)).getBytes()
  };
  return Gt.pem.encode(a, { maxline: t });
};
or.privateKeyInfoToPem = function(e, t) {
  var a = {
    type: "PRIVATE KEY",
    body: Fa.toDer(e).getBytes()
  };
  return Gt.pem.encode(a, { maxline: t });
};
var k = ee, jr = function(e, t, a, r) {
  var i = k.util.createBuffer(), n = e.length >> 1, s = n + (e.length & 1), o = e.substr(0, s), l = e.substr(n, s), f = k.util.createBuffer(), u = k.hmac.create();
  a = t + a;
  var p = Math.ceil(r / 16), m = Math.ceil(r / 20);
  u.start("MD5", o);
  var S = k.util.createBuffer();
  f.putBytes(a);
  for (var C = 0; C < p; ++C)
    u.start(null, null), u.update(f.getBytes()), f.putBuffer(u.digest()), u.start(null, null), u.update(f.bytes() + a), S.putBuffer(u.digest());
  u.start("SHA1", l);
  var A = k.util.createBuffer();
  f.clear(), f.putBytes(a);
  for (var C = 0; C < m; ++C)
    u.start(null, null), u.update(f.getBytes()), f.putBuffer(u.digest()), u.start(null, null), u.update(f.bytes() + a), A.putBuffer(u.digest());
  return i.putBytes(k.util.xorBytes(
    S.getBytes(),
    A.getBytes(),
    r
  )), i;
}, B0 = function(e, t, a) {
  var r = k.hmac.create();
  r.start("SHA1", e);
  var i = k.util.createBuffer();
  return i.putInt32(t[0]), i.putInt32(t[1]), i.putByte(a.type), i.putByte(a.version.major), i.putByte(a.version.minor), i.putInt16(a.length), i.putBytes(a.fragment.bytes()), r.update(i.getBytes()), r.digest().getBytes();
}, A0 = function(e, t, a) {
  var r = !1;
  try {
    var i = e.deflate(t.fragment.getBytes());
    t.fragment = k.util.createBuffer(i), t.length = i.length, r = !0;
  } catch {
  }
  return r;
}, b0 = function(e, t, a) {
  var r = !1;
  try {
    var i = e.inflate(t.fragment.getBytes());
    t.fragment = k.util.createBuffer(i), t.length = i.length, r = !0;
  } catch {
  }
  return r;
}, nt = function(e, t) {
  var a = 0;
  switch (t) {
    case 1:
      a = e.getByte();
      break;
    case 2:
      a = e.getInt16();
      break;
    case 3:
      a = e.getInt24();
      break;
    case 4:
      a = e.getInt32();
      break;
  }
  return k.util.createBuffer(e.getBytes(a));
}, ut = function(e, t, a) {
  e.putInt(a.length(), t << 3), e.putBuffer(a);
}, g = {};
g.Versions = {
  TLS_1_0: { major: 3, minor: 1 },
  TLS_1_1: { major: 3, minor: 2 },
  TLS_1_2: { major: 3, minor: 3 }
};
g.SupportedVersions = [
  g.Versions.TLS_1_1,
  g.Versions.TLS_1_0
];
g.Version = g.SupportedVersions[0];
g.MaxFragment = 15360;
g.ConnectionEnd = {
  server: 0,
  client: 1
};
g.PRFAlgorithm = {
  tls_prf_sha256: 0
};
g.BulkCipherAlgorithm = {
  none: null,
  rc4: 0,
  des3: 1,
  aes: 2
};
g.CipherType = {
  stream: 0,
  block: 1,
  aead: 2
};
g.MACAlgorithm = {
  none: null,
  hmac_md5: 0,
  hmac_sha1: 1,
  hmac_sha256: 2,
  hmac_sha384: 3,
  hmac_sha512: 4
};
g.CompressionMethod = {
  none: 0,
  deflate: 1
};
g.ContentType = {
  change_cipher_spec: 20,
  alert: 21,
  handshake: 22,
  application_data: 23,
  heartbeat: 24
};
g.HandshakeType = {
  hello_request: 0,
  client_hello: 1,
  server_hello: 2,
  certificate: 11,
  server_key_exchange: 12,
  certificate_request: 13,
  server_hello_done: 14,
  certificate_verify: 15,
  client_key_exchange: 16,
  finished: 20
};
g.Alert = {};
g.Alert.Level = {
  warning: 1,
  fatal: 2
};
g.Alert.Description = {
  close_notify: 0,
  unexpected_message: 10,
  bad_record_mac: 20,
  decryption_failed: 21,
  record_overflow: 22,
  decompression_failure: 30,
  handshake_failure: 40,
  bad_certificate: 42,
  unsupported_certificate: 43,
  certificate_revoked: 44,
  certificate_expired: 45,
  certificate_unknown: 46,
  illegal_parameter: 47,
  unknown_ca: 48,
  access_denied: 49,
  decode_error: 50,
  decrypt_error: 51,
  export_restriction: 60,
  protocol_version: 70,
  insufficient_security: 71,
  internal_error: 80,
  user_canceled: 90,
  no_renegotiation: 100
};
g.HeartbeatMessageType = {
  heartbeat_request: 1,
  heartbeat_response: 2
};
g.CipherSuites = {};
g.getCipherSuite = function(e) {
  var t = null;
  for (var a in g.CipherSuites) {
    var r = g.CipherSuites[a];
    if (r.id[0] === e.charCodeAt(0) && r.id[1] === e.charCodeAt(1)) {
      t = r;
      break;
    }
  }
  return t;
};
g.handleUnexpected = function(e, t) {
  var a = !e.open && e.entity === g.ConnectionEnd.client;
  a || e.error(e, {
    message: "Unexpected message. Received TLS record out of order.",
    send: !0,
    alert: {
      level: g.Alert.Level.fatal,
      description: g.Alert.Description.unexpected_message
    }
  });
};
g.handleHelloRequest = function(e, t, a) {
  !e.handshaking && e.handshakes > 0 && (g.queue(e, g.createAlert(e, {
    level: g.Alert.Level.warning,
    description: g.Alert.Description.no_renegotiation
  })), g.flush(e)), e.process();
};
g.parseHelloMessage = function(e, t, a) {
  var r = null, i = e.entity === g.ConnectionEnd.client;
  if (a < 38)
    e.error(e, {
      message: i ? "Invalid ServerHello message. Message too short." : "Invalid ClientHello message. Message too short.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.illegal_parameter
      }
    });
  else {
    var n = t.fragment, s = n.length();
    if (r = {
      version: {
        major: n.getByte(),
        minor: n.getByte()
      },
      random: k.util.createBuffer(n.getBytes(32)),
      session_id: nt(n, 1),
      extensions: []
    }, i ? (r.cipher_suite = n.getBytes(2), r.compression_method = n.getByte()) : (r.cipher_suites = nt(n, 2), r.compression_methods = nt(n, 1)), s = a - (s - n.length()), s > 0) {
      for (var o = nt(n, 2); o.length() > 0; )
        r.extensions.push({
          type: [o.getByte(), o.getByte()],
          data: nt(o, 2)
        });
      if (!i)
        for (var l = 0; l < r.extensions.length; ++l) {
          var f = r.extensions[l];
          if (f.type[0] === 0 && f.type[1] === 0)
            for (var u = nt(f.data, 2); u.length() > 0; ) {
              var p = u.getByte();
              if (p !== 0)
                break;
              e.session.extensions.server_name.serverNameList.push(
                nt(u, 2).getBytes()
              );
            }
        }
    }
    if (e.session.version && (r.version.major !== e.session.version.major || r.version.minor !== e.session.version.minor))
      return e.error(e, {
        message: "TLS version change is disallowed during renegotiation.",
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.protocol_version
        }
      });
    if (i)
      e.session.cipherSuite = g.getCipherSuite(r.cipher_suite);
    else
      for (var m = k.util.createBuffer(r.cipher_suites.bytes()); m.length() > 0 && (e.session.cipherSuite = g.getCipherSuite(m.getBytes(2)), e.session.cipherSuite === null); )
        ;
    if (e.session.cipherSuite === null)
      return e.error(e, {
        message: "No cipher suites in common.",
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.handshake_failure
        },
        cipherSuite: k.util.bytesToHex(r.cipher_suite)
      });
    i ? e.session.compressionMethod = r.compression_method : e.session.compressionMethod = g.CompressionMethod.none;
  }
  return r;
};
g.createSecurityParameters = function(e, t) {
  var a = e.entity === g.ConnectionEnd.client, r = t.random.bytes(), i = a ? e.session.sp.client_random : r, n = a ? r : g.createRandom().getBytes();
  e.session.sp = {
    entity: e.entity,
    prf_algorithm: g.PRFAlgorithm.tls_prf_sha256,
    bulk_cipher_algorithm: null,
    cipher_type: null,
    enc_key_length: null,
    block_length: null,
    fixed_iv_length: null,
    record_iv_length: null,
    mac_algorithm: null,
    mac_length: null,
    mac_key_length: null,
    compression_algorithm: e.session.compressionMethod,
    pre_master_secret: null,
    master_secret: null,
    client_random: i,
    server_random: n
  };
};
g.handleServerHello = function(e, t, a) {
  var r = g.parseHelloMessage(e, t, a);
  if (!e.fail) {
    if (r.version.minor <= e.version.minor)
      e.version.minor = r.version.minor;
    else
      return e.error(e, {
        message: "Incompatible TLS version.",
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.protocol_version
        }
      });
    e.session.version = e.version;
    var i = r.session_id.bytes();
    i.length > 0 && i === e.session.id ? (e.expect = $i, e.session.resuming = !0, e.session.sp.server_random = r.random.bytes()) : (e.expect = _0, e.session.resuming = !1, g.createSecurityParameters(e, r)), e.session.id = i, e.process();
  }
};
g.handleClientHello = function(e, t, a) {
  var r = g.parseHelloMessage(e, t, a);
  if (!e.fail) {
    var i = r.session_id.bytes(), n = null;
    if (e.sessionCache && (n = e.sessionCache.getSession(i), n === null ? i = "" : (n.version.major !== r.version.major || n.version.minor > r.version.minor) && (n = null, i = "")), i.length === 0 && (i = k.random.getBytes(32)), e.session.id = i, e.session.clientHelloVersion = r.version, e.session.sp = {}, n)
      e.version = e.session.version = n.version, e.session.sp = n.sp;
    else {
      for (var s, o = 1; o < g.SupportedVersions.length && (s = g.SupportedVersions[o], !(s.minor <= r.version.minor)); ++o)
        ;
      e.version = { major: s.major, minor: s.minor }, e.session.version = e.version;
    }
    n !== null ? (e.expect = Oa, e.session.resuming = !0, e.session.sp.client_random = r.random.bytes()) : (e.expect = e.verifyClient !== !1 ? P0 : va, e.session.resuming = !1, g.createSecurityParameters(e, r)), e.open = !0, g.queue(e, g.createRecord(e, {
      type: g.ContentType.handshake,
      data: g.createServerHello(e)
    })), e.session.resuming ? (g.queue(e, g.createRecord(e, {
      type: g.ContentType.change_cipher_spec,
      data: g.createChangeCipherSpec()
    })), e.state.pending = g.createConnectionState(e), e.state.current.write = e.state.pending.write, g.queue(e, g.createRecord(e, {
      type: g.ContentType.handshake,
      data: g.createFinished(e)
    }))) : (g.queue(e, g.createRecord(e, {
      type: g.ContentType.handshake,
      data: g.createCertificate(e)
    })), e.fail || (g.queue(e, g.createRecord(e, {
      type: g.ContentType.handshake,
      data: g.createServerKeyExchange(e)
    })), e.verifyClient !== !1 && g.queue(e, g.createRecord(e, {
      type: g.ContentType.handshake,
      data: g.createCertificateRequest(e)
    })), g.queue(e, g.createRecord(e, {
      type: g.ContentType.handshake,
      data: g.createServerHelloDone(e)
    })))), g.flush(e), e.process();
  }
};
g.handleCertificate = function(e, t, a) {
  if (a < 3)
    return e.error(e, {
      message: "Invalid Certificate message. Message too short.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.illegal_parameter
      }
    });
  var r = t.fragment, i = {
    certificate_list: nt(r, 3)
  }, n, s, o = [];
  try {
    for (; i.certificate_list.length() > 0; )
      n = nt(i.certificate_list, 3), s = k.asn1.fromDer(n), n = k.pki.certificateFromAsn1(s, !0), o.push(n);
  } catch (f) {
    return e.error(e, {
      message: "Could not parse certificate list.",
      cause: f,
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.bad_certificate
      }
    });
  }
  var l = e.entity === g.ConnectionEnd.client;
  (l || e.verifyClient === !0) && o.length === 0 ? e.error(e, {
    message: l ? "No server certificate provided." : "No client certificate provided.",
    send: !0,
    alert: {
      level: g.Alert.Level.fatal,
      description: g.Alert.Description.illegal_parameter
    }
  }) : o.length === 0 ? e.expect = l ? li : va : (l ? e.session.serverCertificate = o[0] : e.session.clientCertificate = o[0], g.verifyCertificateChain(e, o) && (e.expect = l ? li : va)), e.process();
};
g.handleServerKeyExchange = function(e, t, a) {
  if (a > 0)
    return e.error(e, {
      message: "Invalid key parameters. Only RSA is supported.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.unsupported_certificate
      }
    });
  e.expect = N0, e.process();
};
g.handleClientKeyExchange = function(e, t, a) {
  if (a < 48)
    return e.error(e, {
      message: "Invalid key parameters. Only RSA is supported.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.unsupported_certificate
      }
    });
  var r = t.fragment, i = {
    enc_pre_master_secret: nt(r, 2).getBytes()
  }, n = null;
  if (e.getPrivateKey)
    try {
      n = e.getPrivateKey(e, e.session.serverCertificate), n = k.pki.privateKeyFromPem(n);
    } catch (l) {
      e.error(e, {
        message: "Could not get private key.",
        cause: l,
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.internal_error
        }
      });
    }
  if (n === null)
    return e.error(e, {
      message: "No private key set.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.internal_error
      }
    });
  try {
    var s = e.session.sp;
    s.pre_master_secret = n.decrypt(i.enc_pre_master_secret);
    var o = e.session.clientHelloVersion;
    if (o.major !== s.pre_master_secret.charCodeAt(0) || o.minor !== s.pre_master_secret.charCodeAt(1))
      throw new Error("TLS version rollback attack detected.");
  } catch {
    s.pre_master_secret = k.random.getBytes(48);
  }
  e.expect = Oa, e.session.clientCertificate !== null && (e.expect = V0), e.process();
};
g.handleCertificateRequest = function(e, t, a) {
  if (a < 3)
    return e.error(e, {
      message: "Invalid CertificateRequest. Message too short.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.illegal_parameter
      }
    });
  var r = t.fragment, i = {
    certificate_types: nt(r, 1),
    certificate_authorities: nt(r, 2)
  };
  e.session.certificateRequest = i, e.expect = R0, e.process();
};
g.handleCertificateVerify = function(e, t, a) {
  if (a < 2)
    return e.error(e, {
      message: "Invalid CertificateVerify. Message too short.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.illegal_parameter
      }
    });
  var r = t.fragment;
  r.read -= 4;
  var i = r.bytes();
  r.read += 4;
  var n = {
    signature: nt(r, 2).getBytes()
  }, s = k.util.createBuffer();
  s.putBuffer(e.session.md5.digest()), s.putBuffer(e.session.sha1.digest()), s = s.getBytes();
  try {
    var o = e.session.clientCertificate;
    if (!o.publicKey.verify(s, n.signature, "NONE"))
      throw new Error("CertificateVerify signature does not match.");
    e.session.md5.update(i), e.session.sha1.update(i);
  } catch {
    return e.error(e, {
      message: "Bad signature in CertificateVerify.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.handshake_failure
      }
    });
  }
  e.expect = Oa, e.process();
};
g.handleServerHelloDone = function(e, t, a) {
  if (a > 0)
    return e.error(e, {
      message: "Invalid ServerHelloDone message. Invalid length.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.record_overflow
      }
    });
  if (e.serverCertificate === null) {
    var r = {
      message: "No server certificate provided. Not enough security.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.insufficient_security
      }
    }, i = 0, n = e.verify(e, r.alert.description, i, []);
    if (n !== !0)
      return (n || n === 0) && (typeof n == "object" && !k.util.isArray(n) ? (n.message && (r.message = n.message), n.alert && (r.alert.description = n.alert)) : typeof n == "number" && (r.alert.description = n)), e.error(e, r);
  }
  e.session.certificateRequest !== null && (t = g.createRecord(e, {
    type: g.ContentType.handshake,
    data: g.createCertificate(e)
  }), g.queue(e, t)), t = g.createRecord(e, {
    type: g.ContentType.handshake,
    data: g.createClientKeyExchange(e)
  }), g.queue(e, t), e.expect = D0;
  var s = function(o, l) {
    o.session.certificateRequest !== null && o.session.clientCertificate !== null && g.queue(o, g.createRecord(o, {
      type: g.ContentType.handshake,
      data: g.createCertificateVerify(o, l)
    })), g.queue(o, g.createRecord(o, {
      type: g.ContentType.change_cipher_spec,
      data: g.createChangeCipherSpec()
    })), o.state.pending = g.createConnectionState(o), o.state.current.write = o.state.pending.write, g.queue(o, g.createRecord(o, {
      type: g.ContentType.handshake,
      data: g.createFinished(o)
    })), o.expect = $i, g.flush(o), o.process();
  };
  if (e.session.certificateRequest === null || e.session.clientCertificate === null)
    return s(e, null);
  g.getClientSignature(e, s);
};
g.handleChangeCipherSpec = function(e, t) {
  if (t.fragment.getByte() !== 1)
    return e.error(e, {
      message: "Invalid ChangeCipherSpec message received.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.illegal_parameter
      }
    });
  var a = e.entity === g.ConnectionEnd.client;
  (e.session.resuming && a || !e.session.resuming && !a) && (e.state.pending = g.createConnectionState(e)), e.state.current.read = e.state.pending.read, (!e.session.resuming && a || e.session.resuming && !a) && (e.state.pending = null), e.expect = a ? L0 : F0, e.process();
};
g.handleFinished = function(e, t, a) {
  var r = t.fragment;
  r.read -= 4;
  var i = r.bytes();
  r.read += 4;
  var n = t.fragment.getBytes();
  r = k.util.createBuffer(), r.putBuffer(e.session.md5.digest()), r.putBuffer(e.session.sha1.digest());
  var s = e.entity === g.ConnectionEnd.client, o = s ? "server finished" : "client finished", l = e.session.sp, f = 12, u = jr;
  if (r = u(l.master_secret, o, r.getBytes(), f), r.getBytes() !== n)
    return e.error(e, {
      message: "Invalid verify_data in Finished message.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.decrypt_error
      }
    });
  e.session.md5.update(i), e.session.sha1.update(i), (e.session.resuming && s || !e.session.resuming && !s) && (g.queue(e, g.createRecord(e, {
    type: g.ContentType.change_cipher_spec,
    data: g.createChangeCipherSpec()
  })), e.state.current.write = e.state.pending.write, e.state.pending = null, g.queue(e, g.createRecord(e, {
    type: g.ContentType.handshake,
    data: g.createFinished(e)
  }))), e.expect = s ? U0 : O0, e.handshaking = !1, ++e.handshakes, e.peerCertificate = s ? e.session.serverCertificate : e.session.clientCertificate, g.flush(e), e.isConnected = !0, e.connected(e), e.process();
};
g.handleAlert = function(e, t) {
  var a = t.fragment, r = {
    level: a.getByte(),
    description: a.getByte()
  }, i;
  switch (r.description) {
    case g.Alert.Description.close_notify:
      i = "Connection closed.";
      break;
    case g.Alert.Description.unexpected_message:
      i = "Unexpected message.";
      break;
    case g.Alert.Description.bad_record_mac:
      i = "Bad record MAC.";
      break;
    case g.Alert.Description.decryption_failed:
      i = "Decryption failed.";
      break;
    case g.Alert.Description.record_overflow:
      i = "Record overflow.";
      break;
    case g.Alert.Description.decompression_failure:
      i = "Decompression failed.";
      break;
    case g.Alert.Description.handshake_failure:
      i = "Handshake failure.";
      break;
    case g.Alert.Description.bad_certificate:
      i = "Bad certificate.";
      break;
    case g.Alert.Description.unsupported_certificate:
      i = "Unsupported certificate.";
      break;
    case g.Alert.Description.certificate_revoked:
      i = "Certificate revoked.";
      break;
    case g.Alert.Description.certificate_expired:
      i = "Certificate expired.";
      break;
    case g.Alert.Description.certificate_unknown:
      i = "Certificate unknown.";
      break;
    case g.Alert.Description.illegal_parameter:
      i = "Illegal parameter.";
      break;
    case g.Alert.Description.unknown_ca:
      i = "Unknown certificate authority.";
      break;
    case g.Alert.Description.access_denied:
      i = "Access denied.";
      break;
    case g.Alert.Description.decode_error:
      i = "Decode error.";
      break;
    case g.Alert.Description.decrypt_error:
      i = "Decrypt error.";
      break;
    case g.Alert.Description.export_restriction:
      i = "Export restriction.";
      break;
    case g.Alert.Description.protocol_version:
      i = "Unsupported protocol version.";
      break;
    case g.Alert.Description.insufficient_security:
      i = "Insufficient security.";
      break;
    case g.Alert.Description.internal_error:
      i = "Internal error.";
      break;
    case g.Alert.Description.user_canceled:
      i = "User canceled.";
      break;
    case g.Alert.Description.no_renegotiation:
      i = "Renegotiation not supported.";
      break;
    default:
      i = "Unknown error.";
      break;
  }
  if (r.description === g.Alert.Description.close_notify)
    return e.close();
  e.error(e, {
    message: i,
    send: !1,
    // origin is the opposite end
    origin: e.entity === g.ConnectionEnd.client ? "server" : "client",
    alert: r
  }), e.process();
};
g.handleHandshake = function(e, t) {
  var a = t.fragment, r = a.getByte(), i = a.getInt24();
  if (i > a.length())
    return e.fragmented = t, t.fragment = k.util.createBuffer(), a.read -= 4, e.process();
  e.fragmented = null, a.read -= 4;
  var n = a.bytes(i + 4);
  a.read += 4, r in Fr[e.entity][e.expect] ? (e.entity === g.ConnectionEnd.server && !e.open && !e.fail && (e.handshaking = !0, e.session = {
    version: null,
    extensions: {
      server_name: {
        serverNameList: []
      }
    },
    cipherSuite: null,
    compressionMethod: null,
    serverCertificate: null,
    clientCertificate: null,
    md5: k.md.md5.create(),
    sha1: k.md.sha1.create()
  }), r !== g.HandshakeType.hello_request && r !== g.HandshakeType.certificate_verify && r !== g.HandshakeType.finished && (e.session.md5.update(n), e.session.sha1.update(n)), Fr[e.entity][e.expect][r](e, t, i)) : g.handleUnexpected(e, t);
};
g.handleApplicationData = function(e, t) {
  e.data.putBuffer(t.fragment), e.dataReady(e), e.process();
};
g.handleHeartbeat = function(e, t) {
  var a = t.fragment, r = a.getByte(), i = a.getInt16(), n = a.getBytes(i);
  if (r === g.HeartbeatMessageType.heartbeat_request) {
    if (e.handshaking || i > n.length)
      return e.process();
    g.queue(e, g.createRecord(e, {
      type: g.ContentType.heartbeat,
      data: g.createHeartbeat(
        g.HeartbeatMessageType.heartbeat_response,
        n
      )
    })), g.flush(e);
  } else if (r === g.HeartbeatMessageType.heartbeat_response) {
    if (n !== e.expectedHeartbeatPayload)
      return e.process();
    e.heartbeatReceived && e.heartbeatReceived(e, k.util.createBuffer(n));
  }
  e.process();
};
var w0 = 0, _0 = 1, li = 2, N0 = 3, R0 = 4, $i = 5, L0 = 6, U0 = 7, D0 = 8, k0 = 0, P0 = 1, va = 2, V0 = 3, Oa = 4, F0 = 5, O0 = 6, y = g.handleUnexpected, ji = g.handleChangeCipherSpec, Xe = g.handleAlert, et = g.handleHandshake, Zi = g.handleApplicationData, We = g.handleHeartbeat, Ka = [];
Ka[g.ConnectionEnd.client] = [
  //      CC,AL,HS,AD,HB
  /*SHE*/
  [y, Xe, et, y, We],
  /*SCE*/
  [y, Xe, et, y, We],
  /*SKE*/
  [y, Xe, et, y, We],
  /*SCR*/
  [y, Xe, et, y, We],
  /*SHD*/
  [y, Xe, et, y, We],
  /*SCC*/
  [ji, Xe, y, y, We],
  /*SFI*/
  [y, Xe, et, y, We],
  /*SAD*/
  [y, Xe, et, Zi, We],
  /*SER*/
  [y, Xe, et, y, We]
];
Ka[g.ConnectionEnd.server] = [
  //      CC,AL,HS,AD
  /*CHE*/
  [y, Xe, et, y, We],
  /*CCE*/
  [y, Xe, et, y, We],
  /*CKE*/
  [y, Xe, et, y, We],
  /*CCV*/
  [y, Xe, et, y, We],
  /*CCC*/
  [ji, Xe, y, y, We],
  /*CFI*/
  [y, Xe, et, y, We],
  /*CAD*/
  [y, Xe, et, Zi, We],
  /*CER*/
  [y, Xe, et, y, We]
];
var Dt = g.handleHelloRequest, K0 = g.handleServerHello, Ji = g.handleCertificate, ci = g.handleServerKeyExchange, aa = g.handleCertificateRequest, Ar = g.handleServerHelloDone, en = g.handleFinished, Fr = [];
Fr[g.ConnectionEnd.client] = [
  //      HR,01,SH,03,04,05,06,07,08,09,10,SC,SK,CR,HD,15,CK,17,18,19,FI
  /*SHE*/
  [y, y, K0, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y],
  /*SCE*/
  [Dt, y, y, y, y, y, y, y, y, y, y, Ji, ci, aa, Ar, y, y, y, y, y, y],
  /*SKE*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, ci, aa, Ar, y, y, y, y, y, y],
  /*SCR*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, y, aa, Ar, y, y, y, y, y, y],
  /*SHD*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, y, y, Ar, y, y, y, y, y, y],
  /*SCC*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y],
  /*SFI*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, en],
  /*SAD*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y],
  /*SER*/
  [Dt, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y]
];
var M0 = g.handleClientHello, H0 = g.handleClientKeyExchange, G0 = g.handleCertificateVerify;
Fr[g.ConnectionEnd.server] = [
  //      01,CH,02,03,04,05,06,07,08,09,10,CC,12,13,14,CV,CK,17,18,19,FI
  /*CHE*/
  [y, M0, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y],
  /*CCE*/
  [y, y, y, y, y, y, y, y, y, y, y, Ji, y, y, y, y, y, y, y, y, y],
  /*CKE*/
  [y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, H0, y, y, y, y],
  /*CCV*/
  [y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, G0, y, y, y, y, y],
  /*CCC*/
  [y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y],
  /*CFI*/
  [y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, en],
  /*CAD*/
  [y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y],
  /*CER*/
  [y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y]
];
g.generateKeys = function(e, t) {
  var a = jr, r = t.client_random + t.server_random;
  e.session.resuming || (t.master_secret = a(
    t.pre_master_secret,
    "master secret",
    r,
    48
  ).bytes(), t.pre_master_secret = null), r = t.server_random + t.client_random;
  var i = 2 * t.mac_key_length + 2 * t.enc_key_length, n = e.version.major === g.Versions.TLS_1_0.major && e.version.minor === g.Versions.TLS_1_0.minor;
  n && (i += 2 * t.fixed_iv_length);
  var s = a(t.master_secret, "key expansion", r, i), o = {
    client_write_MAC_key: s.getBytes(t.mac_key_length),
    server_write_MAC_key: s.getBytes(t.mac_key_length),
    client_write_key: s.getBytes(t.enc_key_length),
    server_write_key: s.getBytes(t.enc_key_length)
  };
  return n && (o.client_write_IV = s.getBytes(t.fixed_iv_length), o.server_write_IV = s.getBytes(t.fixed_iv_length)), o;
};
g.createConnectionState = function(e) {
  var t = e.entity === g.ConnectionEnd.client, a = function() {
    var n = {
      // two 32-bit numbers, first is most significant
      sequenceNumber: [0, 0],
      macKey: null,
      macLength: 0,
      macFunction: null,
      cipherState: null,
      cipherFunction: function(s) {
        return !0;
      },
      compressionState: null,
      compressFunction: function(s) {
        return !0;
      },
      updateSequenceNumber: function() {
        n.sequenceNumber[1] === 4294967295 ? (n.sequenceNumber[1] = 0, ++n.sequenceNumber[0]) : ++n.sequenceNumber[1];
      }
    };
    return n;
  }, r = {
    read: a(),
    write: a()
  };
  if (r.read.update = function(n, s) {
    return r.read.cipherFunction(s, r.read) ? r.read.compressFunction(n, s, r.read) || n.error(n, {
      message: "Could not decompress record.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.decompression_failure
      }
    }) : n.error(n, {
      message: "Could not decrypt record or bad MAC.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        // doesn't matter if decryption failed or MAC was
        // invalid, return the same error so as not to reveal
        // which one occurred
        description: g.Alert.Description.bad_record_mac
      }
    }), !n.fail;
  }, r.write.update = function(n, s) {
    return r.write.compressFunction(n, s, r.write) ? r.write.cipherFunction(s, r.write) || n.error(n, {
      message: "Could not encrypt record.",
      send: !1,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.internal_error
      }
    }) : n.error(n, {
      message: "Could not compress record.",
      send: !1,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.internal_error
      }
    }), !n.fail;
  }, e.session) {
    var i = e.session.sp;
    switch (e.session.cipherSuite.initSecurityParameters(i), i.keys = g.generateKeys(e, i), r.read.macKey = t ? i.keys.server_write_MAC_key : i.keys.client_write_MAC_key, r.write.macKey = t ? i.keys.client_write_MAC_key : i.keys.server_write_MAC_key, e.session.cipherSuite.initConnectionState(r, e, i), i.compression_algorithm) {
      case g.CompressionMethod.none:
        break;
      case g.CompressionMethod.deflate:
        r.read.compressFunction = b0, r.write.compressFunction = A0;
        break;
      default:
        throw new Error("Unsupported compression algorithm.");
    }
  }
  return r;
};
g.createRandom = function() {
  var e = /* @__PURE__ */ new Date(), t = +e + e.getTimezoneOffset() * 6e4, a = k.util.createBuffer();
  return a.putInt32(t), a.putBytes(k.random.getBytes(28)), a;
};
g.createRecord = function(e, t) {
  if (!t.data)
    return null;
  var a = {
    type: t.type,
    version: {
      major: e.version.major,
      minor: e.version.minor
    },
    length: t.data.length(),
    fragment: t.data
  };
  return a;
};
g.createAlert = function(e, t) {
  var a = k.util.createBuffer();
  return a.putByte(t.level), a.putByte(t.description), g.createRecord(e, {
    type: g.ContentType.alert,
    data: a
  });
};
g.createClientHello = function(e) {
  e.session.clientHelloVersion = {
    major: e.version.major,
    minor: e.version.minor
  };
  for (var t = k.util.createBuffer(), a = 0; a < e.cipherSuites.length; ++a) {
    var r = e.cipherSuites[a];
    t.putByte(r.id[0]), t.putByte(r.id[1]);
  }
  var i = t.length(), n = k.util.createBuffer();
  n.putByte(g.CompressionMethod.none);
  var s = n.length(), o = k.util.createBuffer();
  if (e.virtualHost) {
    var l = k.util.createBuffer();
    l.putByte(0), l.putByte(0);
    var f = k.util.createBuffer();
    f.putByte(0), ut(f, 2, k.util.createBuffer(e.virtualHost));
    var u = k.util.createBuffer();
    ut(u, 2, f), ut(l, 2, u), o.putBuffer(l);
  }
  var p = o.length();
  p > 0 && (p += 2);
  var m = e.session.id, S = m.length + 1 + // session ID vector
  2 + // version (major + minor)
  4 + 28 + // random time and random bytes
  2 + i + // cipher suites vector
  1 + s + // compression methods vector
  p, C = k.util.createBuffer();
  return C.putByte(g.HandshakeType.client_hello), C.putInt24(S), C.putByte(e.version.major), C.putByte(e.version.minor), C.putBytes(e.session.sp.client_random), ut(C, 1, k.util.createBuffer(m)), ut(C, 2, t), ut(C, 1, n), p > 0 && ut(C, 2, o), C;
};
g.createServerHello = function(e) {
  var t = e.session.id, a = t.length + 1 + // session ID vector
  2 + // version (major + minor)
  4 + 28 + // random time and random bytes
  2 + // chosen cipher suite
  1, r = k.util.createBuffer();
  return r.putByte(g.HandshakeType.server_hello), r.putInt24(a), r.putByte(e.version.major), r.putByte(e.version.minor), r.putBytes(e.session.sp.server_random), ut(r, 1, k.util.createBuffer(t)), r.putByte(e.session.cipherSuite.id[0]), r.putByte(e.session.cipherSuite.id[1]), r.putByte(e.session.compressionMethod), r;
};
g.createCertificate = function(e) {
  var t = e.entity === g.ConnectionEnd.client, a = null;
  if (e.getCertificate) {
    var r;
    t ? r = e.session.certificateRequest : r = e.session.extensions.server_name.serverNameList, a = e.getCertificate(e, r);
  }
  var i = k.util.createBuffer();
  if (a !== null)
    try {
      k.util.isArray(a) || (a = [a]);
      for (var n = null, s = 0; s < a.length; ++s) {
        var o = k.pem.decode(a[s])[0];
        if (o.type !== "CERTIFICATE" && o.type !== "X509 CERTIFICATE" && o.type !== "TRUSTED CERTIFICATE") {
          var l = new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');
          throw l.headerType = o.type, l;
        }
        if (o.procType && o.procType.type === "ENCRYPTED")
          throw new Error("Could not convert certificate from PEM; PEM is encrypted.");
        var f = k.util.createBuffer(o.body);
        n === null && (n = k.asn1.fromDer(f.bytes(), !1));
        var u = k.util.createBuffer();
        ut(u, 3, f), i.putBuffer(u);
      }
      a = k.pki.certificateFromAsn1(n), t ? e.session.clientCertificate = a : e.session.serverCertificate = a;
    } catch (S) {
      return e.error(e, {
        message: "Could not send certificate list.",
        cause: S,
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.bad_certificate
        }
      });
    }
  var p = 3 + i.length(), m = k.util.createBuffer();
  return m.putByte(g.HandshakeType.certificate), m.putInt24(p), ut(m, 3, i), m;
};
g.createClientKeyExchange = function(e) {
  var t = k.util.createBuffer();
  t.putByte(e.session.clientHelloVersion.major), t.putByte(e.session.clientHelloVersion.minor), t.putBytes(k.random.getBytes(46));
  var a = e.session.sp;
  a.pre_master_secret = t.getBytes();
  var r = e.session.serverCertificate.publicKey;
  t = r.encrypt(a.pre_master_secret);
  var i = t.length + 2, n = k.util.createBuffer();
  return n.putByte(g.HandshakeType.client_key_exchange), n.putInt24(i), n.putInt16(t.length), n.putBytes(t), n;
};
g.createServerKeyExchange = function(e) {
  var t = k.util.createBuffer();
  return t;
};
g.getClientSignature = function(e, t) {
  var a = k.util.createBuffer();
  a.putBuffer(e.session.md5.digest()), a.putBuffer(e.session.sha1.digest()), a = a.getBytes(), e.getSignature = e.getSignature || function(r, i, n) {
    var s = null;
    if (r.getPrivateKey)
      try {
        s = r.getPrivateKey(r, r.session.clientCertificate), s = k.pki.privateKeyFromPem(s);
      } catch (o) {
        r.error(r, {
          message: "Could not get private key.",
          cause: o,
          send: !0,
          alert: {
            level: g.Alert.Level.fatal,
            description: g.Alert.Description.internal_error
          }
        });
      }
    s === null ? r.error(r, {
      message: "No private key set.",
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: g.Alert.Description.internal_error
      }
    }) : i = s.sign(i, null), n(r, i);
  }, e.getSignature(e, a, t);
};
g.createCertificateVerify = function(e, t) {
  var a = t.length + 2, r = k.util.createBuffer();
  return r.putByte(g.HandshakeType.certificate_verify), r.putInt24(a), r.putInt16(t.length), r.putBytes(t), r;
};
g.createCertificateRequest = function(e) {
  var t = k.util.createBuffer();
  t.putByte(1);
  var a = k.util.createBuffer();
  for (var r in e.caStore.certs) {
    var i = e.caStore.certs[r], n = k.pki.distinguishedNameToAsn1(i.subject), s = k.asn1.toDer(n);
    a.putInt16(s.length()), a.putBuffer(s);
  }
  var o = 1 + t.length() + 2 + a.length(), l = k.util.createBuffer();
  return l.putByte(g.HandshakeType.certificate_request), l.putInt24(o), ut(l, 1, t), ut(l, 2, a), l;
};
g.createServerHelloDone = function(e) {
  var t = k.util.createBuffer();
  return t.putByte(g.HandshakeType.server_hello_done), t.putInt24(0), t;
};
g.createChangeCipherSpec = function() {
  var e = k.util.createBuffer();
  return e.putByte(1), e;
};
g.createFinished = function(e) {
  var t = k.util.createBuffer();
  t.putBuffer(e.session.md5.digest()), t.putBuffer(e.session.sha1.digest());
  var a = e.entity === g.ConnectionEnd.client, r = e.session.sp, i = 12, n = jr, s = a ? "client finished" : "server finished";
  t = n(r.master_secret, s, t.getBytes(), i);
  var o = k.util.createBuffer();
  return o.putByte(g.HandshakeType.finished), o.putInt24(t.length()), o.putBuffer(t), o;
};
g.createHeartbeat = function(e, t, a) {
  typeof a > "u" && (a = t.length);
  var r = k.util.createBuffer();
  r.putByte(e), r.putInt16(a), r.putBytes(t);
  var i = r.length(), n = Math.max(16, i - a - 3);
  return r.putBytes(k.random.getBytes(n)), r;
};
g.queue = function(e, t) {
  if (t && !(t.fragment.length() === 0 && (t.type === g.ContentType.handshake || t.type === g.ContentType.alert || t.type === g.ContentType.change_cipher_spec))) {
    if (t.type === g.ContentType.handshake) {
      var a = t.fragment.bytes();
      e.session.md5.update(a), e.session.sha1.update(a), a = null;
    }
    var r;
    if (t.fragment.length() <= g.MaxFragment)
      r = [t];
    else {
      r = [];
      for (var i = t.fragment.bytes(); i.length > g.MaxFragment; )
        r.push(g.createRecord(e, {
          type: t.type,
          data: k.util.createBuffer(i.slice(0, g.MaxFragment))
        })), i = i.slice(g.MaxFragment);
      i.length > 0 && r.push(g.createRecord(e, {
        type: t.type,
        data: k.util.createBuffer(i)
      }));
    }
    for (var n = 0; n < r.length && !e.fail; ++n) {
      var s = r[n], o = e.state.current.write;
      o.update(e, s) && e.records.push(s);
    }
  }
};
g.flush = function(e) {
  for (var t = 0; t < e.records.length; ++t) {
    var a = e.records[t];
    e.tlsData.putByte(a.type), e.tlsData.putByte(a.version.major), e.tlsData.putByte(a.version.minor), e.tlsData.putInt16(a.fragment.length()), e.tlsData.putBuffer(e.records[t].fragment);
  }
  return e.records = [], e.tlsDataReady(e);
};
var ia = function(e) {
  switch (e) {
    case !0:
      return !0;
    case k.pki.certificateError.bad_certificate:
      return g.Alert.Description.bad_certificate;
    case k.pki.certificateError.unsupported_certificate:
      return g.Alert.Description.unsupported_certificate;
    case k.pki.certificateError.certificate_revoked:
      return g.Alert.Description.certificate_revoked;
    case k.pki.certificateError.certificate_expired:
      return g.Alert.Description.certificate_expired;
    case k.pki.certificateError.certificate_unknown:
      return g.Alert.Description.certificate_unknown;
    case k.pki.certificateError.unknown_ca:
      return g.Alert.Description.unknown_ca;
    default:
      return g.Alert.Description.bad_certificate;
  }
}, q0 = function(e) {
  switch (e) {
    case !0:
      return !0;
    case g.Alert.Description.bad_certificate:
      return k.pki.certificateError.bad_certificate;
    case g.Alert.Description.unsupported_certificate:
      return k.pki.certificateError.unsupported_certificate;
    case g.Alert.Description.certificate_revoked:
      return k.pki.certificateError.certificate_revoked;
    case g.Alert.Description.certificate_expired:
      return k.pki.certificateError.certificate_expired;
    case g.Alert.Description.certificate_unknown:
      return k.pki.certificateError.certificate_unknown;
    case g.Alert.Description.unknown_ca:
      return k.pki.certificateError.unknown_ca;
    default:
      return k.pki.certificateError.bad_certificate;
  }
};
g.verifyCertificateChain = function(e, t) {
  try {
    var a = {};
    for (var r in e.verifyOptions)
      a[r] = e.verifyOptions[r];
    a.verify = function(n, s, o) {
      var l = ia(n), f = e.verify(e, n, s, o);
      if (f !== !0) {
        if (typeof f == "object" && !k.util.isArray(f)) {
          var u = new Error("The application rejected the certificate.");
          throw u.send = !0, u.alert = {
            level: g.Alert.Level.fatal,
            description: g.Alert.Description.bad_certificate
          }, f.message && (u.message = f.message), f.alert && (u.alert.description = f.alert), u;
        }
        f !== n && (f = q0(f));
      }
      return f;
    }, k.pki.verifyCertificateChain(e.caStore, t, a);
  } catch (n) {
    var i = n;
    (typeof i != "object" || k.util.isArray(i)) && (i = {
      send: !0,
      alert: {
        level: g.Alert.Level.fatal,
        description: ia(n)
      }
    }), "send" in i || (i.send = !0), "alert" in i || (i.alert = {
      level: g.Alert.Level.fatal,
      description: ia(i.error)
    }), e.error(e, i);
  }
  return !e.fail;
};
g.createSessionCache = function(e, t) {
  var a = null;
  if (e && e.getSession && e.setSession && e.order)
    a = e;
  else {
    a = {}, a.cache = e || {}, a.capacity = Math.max(t || 100, 1), a.order = [];
    for (var r in e)
      a.order.length <= t ? a.order.push(r) : delete e[r];
    a.getSession = function(i) {
      var n = null, s = null;
      if (i ? s = k.util.bytesToHex(i) : a.order.length > 0 && (s = a.order[0]), s !== null && s in a.cache) {
        n = a.cache[s], delete a.cache[s];
        for (var o in a.order)
          if (a.order[o] === s) {
            a.order.splice(o, 1);
            break;
          }
      }
      return n;
    }, a.setSession = function(i, n) {
      if (a.order.length === a.capacity) {
        var s = a.order.shift();
        delete a.cache[s];
      }
      var s = k.util.bytesToHex(i);
      a.order.push(s), a.cache[s] = n;
    };
  }
  return a;
};
g.createConnection = function(e) {
  var t = null;
  e.caStore ? k.util.isArray(e.caStore) ? t = k.pki.createCaStore(e.caStore) : t = e.caStore : t = k.pki.createCaStore();
  var a = e.cipherSuites || null;
  if (a === null) {
    a = [];
    for (var r in g.CipherSuites)
      a.push(g.CipherSuites[r]);
  }
  var i = e.server ? g.ConnectionEnd.server : g.ConnectionEnd.client, n = e.sessionCache ? g.createSessionCache(e.sessionCache) : null, s = {
    version: { major: g.Version.major, minor: g.Version.minor },
    entity: i,
    sessionId: e.sessionId,
    caStore: t,
    sessionCache: n,
    cipherSuites: a,
    connected: e.connected,
    virtualHost: e.virtualHost || null,
    verifyClient: e.verifyClient || !1,
    verify: e.verify || function(u, p, m, S) {
      return p;
    },
    verifyOptions: e.verifyOptions || {},
    getCertificate: e.getCertificate || null,
    getPrivateKey: e.getPrivateKey || null,
    getSignature: e.getSignature || null,
    input: k.util.createBuffer(),
    tlsData: k.util.createBuffer(),
    data: k.util.createBuffer(),
    tlsDataReady: e.tlsDataReady,
    dataReady: e.dataReady,
    heartbeatReceived: e.heartbeatReceived,
    closed: e.closed,
    error: function(u, p) {
      p.origin = p.origin || (u.entity === g.ConnectionEnd.client ? "client" : "server"), p.send && (g.queue(u, g.createAlert(u, p.alert)), g.flush(u));
      var m = p.fatal !== !1;
      m && (u.fail = !0), e.error(u, p), m && u.close(!1);
    },
    deflate: e.deflate || null,
    inflate: e.inflate || null
  };
  s.reset = function(u) {
    s.version = { major: g.Version.major, minor: g.Version.minor }, s.record = null, s.session = null, s.peerCertificate = null, s.state = {
      pending: null,
      current: null
    }, s.expect = s.entity === g.ConnectionEnd.client ? w0 : k0, s.fragmented = null, s.records = [], s.open = !1, s.handshakes = 0, s.handshaking = !1, s.isConnected = !1, s.fail = !(u || typeof u > "u"), s.input.clear(), s.tlsData.clear(), s.data.clear(), s.state.current = g.createConnectionState(s);
  }, s.reset();
  var o = function(u, p) {
    var m = p.type - g.ContentType.change_cipher_spec, S = Ka[u.entity][u.expect];
    m in S ? S[m](u, p) : g.handleUnexpected(u, p);
  }, l = function(u) {
    var p = 0, m = u.input, S = m.length();
    if (S < 5)
      p = 5 - S;
    else {
      u.record = {
        type: m.getByte(),
        version: {
          major: m.getByte(),
          minor: m.getByte()
        },
        length: m.getInt16(),
        fragment: k.util.createBuffer(),
        ready: !1
      };
      var C = u.record.version.major === u.version.major;
      C && u.session && u.session.version && (C = u.record.version.minor === u.version.minor), C || u.error(u, {
        message: "Incompatible TLS version.",
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.protocol_version
        }
      });
    }
    return p;
  }, f = function(u) {
    var p = 0, m = u.input, S = m.length();
    if (S < u.record.length)
      p = u.record.length - S;
    else {
      u.record.fragment.putBytes(m.getBytes(u.record.length)), m.compact();
      var C = u.state.current.read;
      C.update(u, u.record) && (u.fragmented !== null && (u.fragmented.type === u.record.type ? (u.fragmented.fragment.putBuffer(u.record.fragment), u.record = u.fragmented) : u.error(u, {
        message: "Invalid fragmented record.",
        send: !0,
        alert: {
          level: g.Alert.Level.fatal,
          description: g.Alert.Description.unexpected_message
        }
      })), u.record.ready = !0);
    }
    return p;
  };
  return s.handshake = function(u) {
    if (s.entity !== g.ConnectionEnd.client)
      s.error(s, {
        message: "Cannot initiate handshake as a server.",
        fatal: !1
      });
    else if (s.handshaking)
      s.error(s, {
        message: "Handshake already in progress.",
        fatal: !1
      });
    else {
      s.fail && !s.open && s.handshakes === 0 && (s.fail = !1), s.handshaking = !0, u = u || "";
      var p = null;
      u.length > 0 && (s.sessionCache && (p = s.sessionCache.getSession(u)), p === null && (u = "")), u.length === 0 && s.sessionCache && (p = s.sessionCache.getSession(), p !== null && (u = p.id)), s.session = {
        id: u,
        version: null,
        cipherSuite: null,
        compressionMethod: null,
        serverCertificate: null,
        certificateRequest: null,
        clientCertificate: null,
        sp: {},
        md5: k.md.md5.create(),
        sha1: k.md.sha1.create()
      }, p && (s.version = p.version, s.session.sp = p.sp), s.session.sp.client_random = g.createRandom().getBytes(), s.open = !0, g.queue(s, g.createRecord(s, {
        type: g.ContentType.handshake,
        data: g.createClientHello(s)
      })), g.flush(s);
    }
  }, s.process = function(u) {
    var p = 0;
    return u && s.input.putBytes(u), s.fail || (s.record !== null && s.record.ready && s.record.fragment.isEmpty() && (s.record = null), s.record === null && (p = l(s)), !s.fail && s.record !== null && !s.record.ready && (p = f(s)), !s.fail && s.record !== null && s.record.ready && o(s, s.record)), p;
  }, s.prepare = function(u) {
    return g.queue(s, g.createRecord(s, {
      type: g.ContentType.application_data,
      data: k.util.createBuffer(u)
    })), g.flush(s);
  }, s.prepareHeartbeatRequest = function(u, p) {
    return u instanceof k.util.ByteBuffer && (u = u.bytes()), typeof p > "u" && (p = u.length), s.expectedHeartbeatPayload = u, g.queue(s, g.createRecord(s, {
      type: g.ContentType.heartbeat,
      data: g.createHeartbeat(
        g.HeartbeatMessageType.heartbeat_request,
        u,
        p
      )
    })), g.flush(s);
  }, s.close = function(u) {
    if (!s.fail && s.sessionCache && s.session) {
      var p = {
        id: s.session.id,
        version: s.session.version,
        sp: s.session.sp
      };
      p.sp.keys = null, s.sessionCache.setSession(p.id, p);
    }
    s.open && (s.open = !1, s.input.clear(), (s.isConnected || s.handshaking) && (s.isConnected = s.handshaking = !1, g.queue(s, g.createAlert(s, {
      level: g.Alert.Level.warning,
      description: g.Alert.Description.close_notify
    })), g.flush(s)), s.closed(s)), s.reset(u);
  }, s;
};
k.tls = k.tls || {};
for (var na in g)
  typeof g[na] != "function" && (k.tls[na] = g[na]);
k.tls.prf_tls1 = jr;
k.tls.hmac_sha1 = B0;
k.tls.createSessionCache = g.createSessionCache;
k.tls.createConnection = g.createConnection;
var Mt = ee, ht = Mt.tls;
ht.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA = {
  id: [0, 47],
  name: "TLS_RSA_WITH_AES_128_CBC_SHA",
  initSecurityParameters: function(e) {
    e.bulk_cipher_algorithm = ht.BulkCipherAlgorithm.aes, e.cipher_type = ht.CipherType.block, e.enc_key_length = 16, e.block_length = 16, e.fixed_iv_length = 16, e.record_iv_length = 16, e.mac_algorithm = ht.MACAlgorithm.hmac_sha1, e.mac_length = 20, e.mac_key_length = 20;
  },
  initConnectionState: tn
};
ht.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA = {
  id: [0, 53],
  name: "TLS_RSA_WITH_AES_256_CBC_SHA",
  initSecurityParameters: function(e) {
    e.bulk_cipher_algorithm = ht.BulkCipherAlgorithm.aes, e.cipher_type = ht.CipherType.block, e.enc_key_length = 32, e.block_length = 16, e.fixed_iv_length = 16, e.record_iv_length = 16, e.mac_algorithm = ht.MACAlgorithm.hmac_sha1, e.mac_length = 20, e.mac_key_length = 20;
  },
  initConnectionState: tn
};
function tn(e, t, a) {
  var r = t.entity === Mt.tls.ConnectionEnd.client;
  e.read.cipherState = {
    init: !1,
    cipher: Mt.cipher.createDecipher("AES-CBC", r ? a.keys.server_write_key : a.keys.client_write_key),
    iv: r ? a.keys.server_write_IV : a.keys.client_write_IV
  }, e.write.cipherState = {
    init: !1,
    cipher: Mt.cipher.createCipher("AES-CBC", r ? a.keys.client_write_key : a.keys.server_write_key),
    iv: r ? a.keys.client_write_IV : a.keys.server_write_IV
  }, e.read.cipherFunction = X0, e.write.cipherFunction = Q0, e.read.macLength = e.write.macLength = a.mac_length, e.read.macFunction = e.write.macFunction = ht.hmac_sha1;
}
function Q0(e, t) {
  var a = !1, r = t.macFunction(t.macKey, t.sequenceNumber, e);
  e.fragment.putBytes(r), t.updateSequenceNumber();
  var i;
  e.version.minor === ht.Versions.TLS_1_0.minor ? i = t.cipherState.init ? null : t.cipherState.iv : i = Mt.random.getBytesSync(16), t.cipherState.init = !0;
  var n = t.cipherState.cipher;
  return n.start({ iv: i }), e.version.minor >= ht.Versions.TLS_1_1.minor && n.output.putBytes(i), n.update(e.fragment), n.finish(z0) && (e.fragment = n.output, e.length = e.fragment.length(), a = !0), a;
}
function z0(e, t, a) {
  if (!a) {
    var r = e - t.length() % e;
    t.fillWithByte(r - 1, r);
  }
  return !0;
}
function Y0(e, t, a) {
  var r = !0;
  if (a) {
    for (var i = t.length(), n = t.last(), s = i - 1 - n; s < i - 1; ++s)
      r = r && t.at(s) == n;
    r && t.truncate(n + 1);
  }
  return r;
}
function X0(e, t) {
  var a = !1, r;
  e.version.minor === ht.Versions.TLS_1_0.minor ? r = t.cipherState.init ? null : t.cipherState.iv : r = e.fragment.getBytes(16), t.cipherState.init = !0;
  var i = t.cipherState.cipher;
  i.start({ iv: r }), i.update(e.fragment), a = i.finish(Y0);
  var n = t.macLength, s = Mt.random.getBytesSync(n), o = i.output.length();
  o >= n ? (e.fragment = i.output.getBytes(o - n), s = i.output.getBytes(n)) : e.fragment = i.output.getBytes(), e.fragment = Mt.util.createBuffer(e.fragment), e.length = e.fragment.length();
  var l = t.macFunction(t.macKey, t.sequenceNumber, e);
  return t.updateSequenceNumber(), a = W0(t.macKey, s, l) && a, a;
}
function W0(e, t, a) {
  var r = Mt.hmac.create();
  return r.start("SHA1", e), r.update(t), t = r.digest().getBytes(), r.start(null, null), r.update(a), a = r.digest().getBytes(), t === a;
}
var Se = ee, Tr = Se.sha512 = Se.sha512 || {};
Se.md.sha512 = Se.md.algorithms.sha512 = Tr;
var rn = Se.sha384 = Se.sha512.sha384 = Se.sha512.sha384 || {};
rn.create = function() {
  return Tr.create("SHA-384");
};
Se.md.sha384 = Se.md.algorithms.sha384 = rn;
Se.sha512.sha256 = Se.sha512.sha256 || {
  create: function() {
    return Tr.create("SHA-512/256");
  }
};
Se.md["sha512/256"] = Se.md.algorithms["sha512/256"] = Se.sha512.sha256;
Se.sha512.sha224 = Se.sha512.sha224 || {
  create: function() {
    return Tr.create("SHA-512/224");
  }
};
Se.md["sha512/224"] = Se.md.algorithms["sha512/224"] = Se.sha512.sha224;
Tr.create = function(e) {
  if (an || $0(), typeof e > "u" && (e = "SHA-512"), !(e in zt))
    throw new Error("Invalid SHA-512 algorithm: " + e);
  for (var t = zt[e], a = null, r = Se.util.createBuffer(), i = new Array(80), n = 0; n < 80; ++n)
    i[n] = new Array(2);
  var s = 64;
  switch (e) {
    case "SHA-384":
      s = 48;
      break;
    case "SHA-512/256":
      s = 32;
      break;
    case "SHA-512/224":
      s = 28;
      break;
  }
  var o = {
    // SHA-512 => sha512
    algorithm: e.replace("-", "").toLowerCase(),
    blockLength: 128,
    digestLength: s,
    // 56-bit length of message so far (does not including padding)
    messageLength: 0,
    // true message length
    fullMessageLength: null,
    // size of message length in bytes
    messageLengthSize: 16
  };
  return o.start = function() {
    o.messageLength = 0, o.fullMessageLength = o.messageLength128 = [];
    for (var l = o.messageLengthSize / 4, f = 0; f < l; ++f)
      o.fullMessageLength.push(0);
    r = Se.util.createBuffer(), a = new Array(t.length);
    for (var f = 0; f < t.length; ++f)
      a[f] = t[f].slice(0);
    return o;
  }, o.start(), o.update = function(l, f) {
    f === "utf8" && (l = Se.util.encodeUtf8(l));
    var u = l.length;
    o.messageLength += u, u = [u / 4294967296 >>> 0, u >>> 0];
    for (var p = o.fullMessageLength.length - 1; p >= 0; --p)
      o.fullMessageLength[p] += u[1], u[1] = u[0] + (o.fullMessageLength[p] / 4294967296 >>> 0), o.fullMessageLength[p] = o.fullMessageLength[p] >>> 0, u[0] = u[1] / 4294967296 >>> 0;
    return r.putBytes(l), hi(a, i, r), (r.read > 2048 || r.length() === 0) && r.compact(), o;
  }, o.digest = function() {
    var l = Se.util.createBuffer();
    l.putBytes(r.bytes());
    var f = o.fullMessageLength[o.fullMessageLength.length - 1] + o.messageLengthSize, u = f & o.blockLength - 1;
    l.putBytes(ma.substr(0, o.blockLength - u));
    for (var p, m, S = o.fullMessageLength[0] * 8, C = 0; C < o.fullMessageLength.length - 1; ++C)
      p = o.fullMessageLength[C + 1] * 8, m = p / 4294967296 >>> 0, S += m, l.putInt32(S >>> 0), S = p >>> 0;
    l.putInt32(S);
    for (var A = new Array(a.length), C = 0; C < a.length; ++C)
      A[C] = a[C].slice(0);
    hi(A, i, l);
    var b = Se.util.createBuffer(), _;
    e === "SHA-512" ? _ = A.length : e === "SHA-384" ? _ = A.length - 2 : _ = A.length - 4;
    for (var C = 0; C < _; ++C)
      b.putInt32(A[C][0]), (C !== _ - 1 || e !== "SHA-512/224") && b.putInt32(A[C][1]);
    return b;
  }, o;
};
var ma = null, an = !1, Ca = null, zt = null;
function $0() {
  ma = "€", ma += Se.util.fillString("\0", 128), Ca = [
    [1116352408, 3609767458],
    [1899447441, 602891725],
    [3049323471, 3964484399],
    [3921009573, 2173295548],
    [961987163, 4081628472],
    [1508970993, 3053834265],
    [2453635748, 2937671579],
    [2870763221, 3664609560],
    [3624381080, 2734883394],
    [310598401, 1164996542],
    [607225278, 1323610764],
    [1426881987, 3590304994],
    [1925078388, 4068182383],
    [2162078206, 991336113],
    [2614888103, 633803317],
    [3248222580, 3479774868],
    [3835390401, 2666613458],
    [4022224774, 944711139],
    [264347078, 2341262773],
    [604807628, 2007800933],
    [770255983, 1495990901],
    [1249150122, 1856431235],
    [1555081692, 3175218132],
    [1996064986, 2198950837],
    [2554220882, 3999719339],
    [2821834349, 766784016],
    [2952996808, 2566594879],
    [3210313671, 3203337956],
    [3336571891, 1034457026],
    [3584528711, 2466948901],
    [113926993, 3758326383],
    [338241895, 168717936],
    [666307205, 1188179964],
    [773529912, 1546045734],
    [1294757372, 1522805485],
    [1396182291, 2643833823],
    [1695183700, 2343527390],
    [1986661051, 1014477480],
    [2177026350, 1206759142],
    [2456956037, 344077627],
    [2730485921, 1290863460],
    [2820302411, 3158454273],
    [3259730800, 3505952657],
    [3345764771, 106217008],
    [3516065817, 3606008344],
    [3600352804, 1432725776],
    [4094571909, 1467031594],
    [275423344, 851169720],
    [430227734, 3100823752],
    [506948616, 1363258195],
    [659060556, 3750685593],
    [883997877, 3785050280],
    [958139571, 3318307427],
    [1322822218, 3812723403],
    [1537002063, 2003034995],
    [1747873779, 3602036899],
    [1955562222, 1575990012],
    [2024104815, 1125592928],
    [2227730452, 2716904306],
    [2361852424, 442776044],
    [2428436474, 593698344],
    [2756734187, 3733110249],
    [3204031479, 2999351573],
    [3329325298, 3815920427],
    [3391569614, 3928383900],
    [3515267271, 566280711],
    [3940187606, 3454069534],
    [4118630271, 4000239992],
    [116418474, 1914138554],
    [174292421, 2731055270],
    [289380356, 3203993006],
    [460393269, 320620315],
    [685471733, 587496836],
    [852142971, 1086792851],
    [1017036298, 365543100],
    [1126000580, 2618297676],
    [1288033470, 3409855158],
    [1501505948, 4234509866],
    [1607167915, 987167468],
    [1816402316, 1246189591]
  ], zt = {}, zt["SHA-512"] = [
    [1779033703, 4089235720],
    [3144134277, 2227873595],
    [1013904242, 4271175723],
    [2773480762, 1595750129],
    [1359893119, 2917565137],
    [2600822924, 725511199],
    [528734635, 4215389547],
    [1541459225, 327033209]
  ], zt["SHA-384"] = [
    [3418070365, 3238371032],
    [1654270250, 914150663],
    [2438529370, 812702999],
    [355462360, 4144912697],
    [1731405415, 4290775857],
    [2394180231, 1750603025],
    [3675008525, 1694076839],
    [1203062813, 3204075428]
  ], zt["SHA-512/256"] = [
    [573645204, 4230739756],
    [2673172387, 3360449730],
    [596883563, 1867755857],
    [2520282905, 1497426621],
    [2519219938, 2827943907],
    [3193839141, 1401305490],
    [721525244, 746961066],
    [246885852, 2177182882]
  ], zt["SHA-512/224"] = [
    [2352822216, 424955298],
    [1944164710, 2312950998],
    [502970286, 855612546],
    [1738396948, 1479516111],
    [258812777, 2077511080],
    [2011393907, 79989058],
    [1067287976, 1780299464],
    [286451373, 2446758561]
  ], an = !0;
}
function hi(e, t, a) {
  for (var r, i, n, s, o, l, f, u, p, m, S, C, A, b, _, U, D, G, O, F, $, j, le, he, de, Ee, je, rt, ye, Ae, z, gt, Rt, be, we, Le = a.length(); Le >= 128; ) {
    for (ye = 0; ye < 16; ++ye)
      t[ye][0] = a.getInt32() >>> 0, t[ye][1] = a.getInt32() >>> 0;
    for (; ye < 80; ++ye)
      gt = t[ye - 2], Ae = gt[0], z = gt[1], r = ((Ae >>> 19 | z << 13) ^ // ROTR 19
      (z >>> 29 | Ae << 3) ^ // ROTR 61/(swap + ROTR 29)
      Ae >>> 6) >>> 0, i = ((Ae << 13 | z >>> 19) ^ // ROTR 19
      (z << 3 | Ae >>> 29) ^ // ROTR 61/(swap + ROTR 29)
      (Ae << 26 | z >>> 6)) >>> 0, be = t[ye - 15], Ae = be[0], z = be[1], n = ((Ae >>> 1 | z << 31) ^ // ROTR 1
      (Ae >>> 8 | z << 24) ^ // ROTR 8
      Ae >>> 7) >>> 0, s = ((Ae << 31 | z >>> 1) ^ // ROTR 1
      (Ae << 24 | z >>> 8) ^ // ROTR 8
      (Ae << 25 | z >>> 7)) >>> 0, Rt = t[ye - 7], we = t[ye - 16], z = i + Rt[1] + s + we[1], t[ye][0] = r + Rt[0] + n + we[0] + (z / 4294967296 >>> 0) >>> 0, t[ye][1] = z >>> 0;
    for (A = e[0][0], b = e[0][1], _ = e[1][0], U = e[1][1], D = e[2][0], G = e[2][1], O = e[3][0], F = e[3][1], $ = e[4][0], j = e[4][1], le = e[5][0], he = e[5][1], de = e[6][0], Ee = e[6][1], je = e[7][0], rt = e[7][1], ye = 0; ye < 80; ++ye)
      f = (($ >>> 14 | j << 18) ^ // ROTR 14
      ($ >>> 18 | j << 14) ^ // ROTR 18
      (j >>> 9 | $ << 23)) >>> 0, u = (($ << 18 | j >>> 14) ^ // ROTR 14
      ($ << 14 | j >>> 18) ^ // ROTR 18
      (j << 23 | $ >>> 9)) >>> 0, p = (de ^ $ & (le ^ de)) >>> 0, m = (Ee ^ j & (he ^ Ee)) >>> 0, o = ((A >>> 28 | b << 4) ^ // ROTR 28
      (b >>> 2 | A << 30) ^ // ROTR 34/(swap + ROTR 2)
      (b >>> 7 | A << 25)) >>> 0, l = ((A << 4 | b >>> 28) ^ // ROTR 28
      (b << 30 | A >>> 2) ^ // ROTR 34/(swap + ROTR 2)
      (b << 25 | A >>> 7)) >>> 0, S = (A & _ | D & (A ^ _)) >>> 0, C = (b & U | G & (b ^ U)) >>> 0, z = rt + u + m + Ca[ye][1] + t[ye][1], r = je + f + p + Ca[ye][0] + t[ye][0] + (z / 4294967296 >>> 0) >>> 0, i = z >>> 0, z = l + C, n = o + S + (z / 4294967296 >>> 0) >>> 0, s = z >>> 0, je = de, rt = Ee, de = le, Ee = he, le = $, he = j, z = F + i, $ = O + r + (z / 4294967296 >>> 0) >>> 0, j = z >>> 0, O = D, F = G, D = _, G = U, _ = A, U = b, z = i + s, A = r + n + (z / 4294967296 >>> 0) >>> 0, b = z >>> 0;
    z = e[0][1] + b, e[0][0] = e[0][0] + A + (z / 4294967296 >>> 0) >>> 0, e[0][1] = z >>> 0, z = e[1][1] + U, e[1][0] = e[1][0] + _ + (z / 4294967296 >>> 0) >>> 0, e[1][1] = z >>> 0, z = e[2][1] + G, e[2][0] = e[2][0] + D + (z / 4294967296 >>> 0) >>> 0, e[2][1] = z >>> 0, z = e[3][1] + F, e[3][0] = e[3][0] + O + (z / 4294967296 >>> 0) >>> 0, e[3][1] = z >>> 0, z = e[4][1] + j, e[4][0] = e[4][0] + $ + (z / 4294967296 >>> 0) >>> 0, e[4][1] = z >>> 0, z = e[5][1] + he, e[5][0] = e[5][0] + le + (z / 4294967296 >>> 0) >>> 0, e[5][1] = z >>> 0, z = e[6][1] + Ee, e[6][0] = e[6][0] + de + (z / 4294967296 >>> 0) >>> 0, e[6][1] = z >>> 0, z = e[7][1] + rt, e[7][0] = e[7][0] + je + (z / 4294967296 >>> 0) >>> 0, e[7][1] = z >>> 0, Le -= 128;
  }
}
var Ma = {}, j0 = ee, Qe = j0.asn1;
Ma.privateKeyValidator = {
  // PrivateKeyInfo
  name: "PrivateKeyInfo",
  tagClass: Qe.Class.UNIVERSAL,
  type: Qe.Type.SEQUENCE,
  constructed: !0,
  value: [{
    // Version (INTEGER)
    name: "PrivateKeyInfo.version",
    tagClass: Qe.Class.UNIVERSAL,
    type: Qe.Type.INTEGER,
    constructed: !1,
    capture: "privateKeyVersion"
  }, {
    // privateKeyAlgorithm
    name: "PrivateKeyInfo.privateKeyAlgorithm",
    tagClass: Qe.Class.UNIVERSAL,
    type: Qe.Type.SEQUENCE,
    constructed: !0,
    value: [{
      name: "AlgorithmIdentifier.algorithm",
      tagClass: Qe.Class.UNIVERSAL,
      type: Qe.Type.OID,
      constructed: !1,
      capture: "privateKeyOid"
    }]
  }, {
    // PrivateKey
    name: "PrivateKeyInfo",
    tagClass: Qe.Class.UNIVERSAL,
    type: Qe.Type.OCTETSTRING,
    constructed: !1,
    capture: "privateKey"
  }]
};
Ma.publicKeyValidator = {
  name: "SubjectPublicKeyInfo",
  tagClass: Qe.Class.UNIVERSAL,
  type: Qe.Type.SEQUENCE,
  constructed: !0,
  captureAsn1: "subjectPublicKeyInfo",
  value: [
    {
      name: "SubjectPublicKeyInfo.AlgorithmIdentifier",
      tagClass: Qe.Class.UNIVERSAL,
      type: Qe.Type.SEQUENCE,
      constructed: !0,
      value: [{
        name: "AlgorithmIdentifier.algorithm",
        tagClass: Qe.Class.UNIVERSAL,
        type: Qe.Type.OID,
        constructed: !1,
        capture: "publicKeyOid"
      }]
    },
    // capture group for ed25519PublicKey
    {
      tagClass: Qe.Class.UNIVERSAL,
      type: Qe.Type.BITSTRING,
      constructed: !1,
      composed: !0,
      captureBitStringValue: "ed25519PublicKey"
    }
    // FIXME: this is capture group for rsaPublicKey, use it in this API or
    // discard?
    /* {
      // subjectPublicKey
      name: 'SubjectPublicKeyInfo.subjectPublicKey',
      tagClass: asn1.Class.UNIVERSAL,
      type: asn1.Type.BITSTRING,
      constructed: false,
      value: [{
        // RSAPublicKey
        name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
        tagClass: asn1.Class.UNIVERSAL,
        type: asn1.Type.SEQUENCE,
        constructed: true,
        optional: true,
        captureAsn1: 'rsaPublicKey'
      }]
    } */
  ]
};
var $e = ee, nn = Ma, Z0 = nn.publicKeyValidator, J0 = nn.privateKeyValidator;
if (typeof eu > "u")
  var eu = $e.jsbn.BigInteger;
var Ea = $e.util.ByteBuffer, it = typeof pt > "u" ? Uint8Array : pt;
$e.pki = $e.pki || {};
$e.pki.ed25519 = $e.ed25519 = $e.ed25519 || {};
var ae = $e.ed25519;
ae.constants = {};
ae.constants.PUBLIC_KEY_BYTE_LENGTH = 32;
ae.constants.PRIVATE_KEY_BYTE_LENGTH = 64;
ae.constants.SEED_BYTE_LENGTH = 32;
ae.constants.SIGN_BYTE_LENGTH = 64;
ae.constants.HASH_BYTE_LENGTH = 64;
ae.generateKeyPair = function(e) {
  e = e || {};
  var t = e.seed;
  if (t === void 0)
    t = $e.random.getBytesSync(ae.constants.SEED_BYTE_LENGTH);
  else if (typeof t == "string") {
    if (t.length !== ae.constants.SEED_BYTE_LENGTH)
      throw new TypeError(
        '"seed" must be ' + ae.constants.SEED_BYTE_LENGTH + " bytes in length."
      );
  } else if (!(t instanceof Uint8Array))
    throw new TypeError(
      '"seed" must be a node.js Buffer, Uint8Array, or a binary string.'
    );
  t = Nt({ message: t, encoding: "binary" });
  for (var a = new it(ae.constants.PUBLIC_KEY_BYTE_LENGTH), r = new it(ae.constants.PRIVATE_KEY_BYTE_LENGTH), i = 0; i < 32; ++i)
    r[i] = t[i];
  return iu(a, r), { publicKey: a, privateKey: r };
};
ae.privateKeyFromAsn1 = function(e) {
  var t = {}, a = [], r = $e.asn1.validate(e, J0, t, a);
  if (!r) {
    var i = new Error("Invalid Key.");
    throw i.errors = a, i;
  }
  var n = $e.asn1.derToOid(t.privateKeyOid), s = $e.oids.EdDSA25519;
  if (n !== s)
    throw new Error('Invalid OID "' + n + '"; OID must be "' + s + '".');
  var o = t.privateKey, l = Nt({
    message: $e.asn1.fromDer(o).value,
    encoding: "binary"
  });
  return { privateKeyBytes: l };
};
ae.publicKeyFromAsn1 = function(e) {
  var t = {}, a = [], r = $e.asn1.validate(e, Z0, t, a);
  if (!r) {
    var i = new Error("Invalid Key.");
    throw i.errors = a, i;
  }
  var n = $e.asn1.derToOid(t.publicKeyOid), s = $e.oids.EdDSA25519;
  if (n !== s)
    throw new Error('Invalid OID "' + n + '"; OID must be "' + s + '".');
  var o = t.ed25519PublicKey;
  if (o.length !== ae.constants.PUBLIC_KEY_BYTE_LENGTH)
    throw new Error("Key length is invalid.");
  return Nt({
    message: o,
    encoding: "binary"
  });
};
ae.publicKeyFromPrivateKey = function(e) {
  e = e || {};
  var t = Nt({
    message: e.privateKey,
    encoding: "binary"
  });
  if (t.length !== ae.constants.PRIVATE_KEY_BYTE_LENGTH)
    throw new TypeError(
      '"options.privateKey" must have a byte length of ' + ae.constants.PRIVATE_KEY_BYTE_LENGTH
    );
  for (var a = new it(ae.constants.PUBLIC_KEY_BYTE_LENGTH), r = 0; r < a.length; ++r)
    a[r] = t[32 + r];
  return a;
};
ae.sign = function(e) {
  e = e || {};
  var t = Nt(e), a = Nt({
    message: e.privateKey,
    encoding: "binary"
  });
  if (a.length === ae.constants.SEED_BYTE_LENGTH) {
    var r = ae.generateKeyPair({ seed: a });
    a = r.privateKey;
  } else if (a.length !== ae.constants.PRIVATE_KEY_BYTE_LENGTH)
    throw new TypeError(
      '"options.privateKey" must have a byte length of ' + ae.constants.SEED_BYTE_LENGTH + " or " + ae.constants.PRIVATE_KEY_BYTE_LENGTH
    );
  var i = new it(
    ae.constants.SIGN_BYTE_LENGTH + t.length
  );
  nu(i, t, t.length, a);
  for (var n = new it(ae.constants.SIGN_BYTE_LENGTH), s = 0; s < n.length; ++s)
    n[s] = i[s];
  return n;
};
ae.verify = function(e) {
  e = e || {};
  var t = Nt(e);
  if (e.signature === void 0)
    throw new TypeError(
      '"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.'
    );
  var a = Nt({
    message: e.signature,
    encoding: "binary"
  });
  if (a.length !== ae.constants.SIGN_BYTE_LENGTH)
    throw new TypeError(
      '"options.signature" must have a byte length of ' + ae.constants.SIGN_BYTE_LENGTH
    );
  var r = Nt({
    message: e.publicKey,
    encoding: "binary"
  });
  if (r.length !== ae.constants.PUBLIC_KEY_BYTE_LENGTH)
    throw new TypeError(
      '"options.publicKey" must have a byte length of ' + ae.constants.PUBLIC_KEY_BYTE_LENGTH
    );
  var i = new it(ae.constants.SIGN_BYTE_LENGTH + t.length), n = new it(ae.constants.SIGN_BYTE_LENGTH + t.length), s;
  for (s = 0; s < ae.constants.SIGN_BYTE_LENGTH; ++s)
    i[s] = a[s];
  for (s = 0; s < t.length; ++s)
    i[s + ae.constants.SIGN_BYTE_LENGTH] = t[s];
  return su(n, i, i.length, r) >= 0;
};
function Nt(e) {
  var t = e.message;
  if (t instanceof Uint8Array || t instanceof it)
    return t;
  var a = e.encoding;
  if (t === void 0)
    if (e.md)
      t = e.md.digest().getBytes(), a = "binary";
    else
      throw new TypeError('"options.message" or "options.md" not specified.');
  if (typeof t == "string" && !a)
    throw new TypeError('"options.encoding" must be "binary" or "utf8".');
  if (typeof t == "string") {
    if (typeof pt < "u")
      return pt.from(t, a);
    t = new Ea(t, a);
  } else if (!(t instanceof Ea))
    throw new TypeError(
      '"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.'
    );
  for (var r = new it(t.length()), i = 0; i < r.length; ++i)
    r[i] = t.at(i);
  return r;
}
var xa = W(), Or = W([1]), tu = W([
  30883,
  4953,
  19914,
  30187,
  55467,
  16705,
  2637,
  112,
  59544,
  30585,
  16505,
  36039,
  65139,
  11119,
  27886,
  20995
]), ru = W([
  61785,
  9906,
  39828,
  60374,
  45398,
  33411,
  5274,
  224,
  53552,
  61171,
  33010,
  6542,
  64743,
  22239,
  55772,
  9222
]), pi = W([
  54554,
  36645,
  11616,
  51542,
  42930,
  38181,
  51040,
  26924,
  56412,
  64982,
  57905,
  49316,
  21502,
  52590,
  14035,
  8553
]), di = W([
  26200,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214,
  26214
]), sa = new Float64Array([
  237,
  211,
  245,
  92,
  26,
  99,
  18,
  88,
  214,
  156,
  247,
  162,
  222,
  249,
  222,
  20,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  16
]), au = W([
  41136,
  18958,
  6951,
  50414,
  58488,
  44335,
  6150,
  12099,
  55207,
  15867,
  153,
  11085,
  57099,
  20417,
  9344,
  11139
]);
function mr(e, t) {
  var a = $e.md.sha512.create(), r = new Ea(e);
  a.update(r.getBytes(t), "binary");
  var i = a.digest().getBytes();
  if (typeof pt < "u")
    return pt.from(i, "binary");
  for (var n = new it(ae.constants.HASH_BYTE_LENGTH), s = 0; s < 64; ++s)
    n[s] = i.charCodeAt(s);
  return n;
}
function iu(e, t) {
  var a = [W(), W(), W(), W()], r, i = mr(t, 32);
  for (i[0] &= 248, i[31] &= 127, i[31] |= 64, Ga(a, i), Ha(e, a), r = 0; r < 32; ++r)
    t[r + 32] = e[r];
  return 0;
}
function nu(e, t, a, r) {
  var i, n, s = new Float64Array(64), o = [W(), W(), W(), W()], l = mr(r, 32);
  l[0] &= 248, l[31] &= 127, l[31] |= 64;
  var f = a + 64;
  for (i = 0; i < a; ++i)
    e[64 + i] = t[i];
  for (i = 0; i < 32; ++i)
    e[32 + i] = l[32 + i];
  var u = mr(e.subarray(32), a + 32);
  for (Sa(u), Ga(o, u), Ha(e, o), i = 32; i < 64; ++i)
    e[i] = r[i];
  var p = mr(e, a + 64);
  for (Sa(p), i = 32; i < 64; ++i)
    s[i] = 0;
  for (i = 0; i < 32; ++i)
    s[i] = u[i];
  for (i = 0; i < 32; ++i)
    for (n = 0; n < 32; n++)
      s[i + n] += p[i] * l[n];
  return sn(e.subarray(32), s), f;
}
function su(e, t, a, r) {
  var i, n, s = new it(32), o = [W(), W(), W(), W()], l = [W(), W(), W(), W()];
  if (n = -1, a < 64 || ou(l, r))
    return -1;
  for (i = 0; i < a; ++i)
    e[i] = t[i];
  for (i = 0; i < 32; ++i)
    e[i + 32] = r[i];
  var f = mr(e, a);
  if (Sa(f), fn(o, l, f), Ga(l, t.subarray(32)), Ta(o, l), Ha(s, o), a -= 64, on(t, 0, s, 0)) {
    for (i = 0; i < a; ++i)
      e[i] = 0;
    return -1;
  }
  for (i = 0; i < a; ++i)
    e[i] = t[i + 64];
  return n = a, n;
}
function sn(e, t) {
  var a, r, i, n;
  for (r = 63; r >= 32; --r) {
    for (a = 0, i = r - 32, n = r - 12; i < n; ++i)
      t[i] += a - 16 * t[r] * sa[i - (r - 32)], a = t[i] + 128 >> 8, t[i] -= a * 256;
    t[i] += a, t[r] = 0;
  }
  for (a = 0, i = 0; i < 32; ++i)
    t[i] += a - (t[31] >> 4) * sa[i], a = t[i] >> 8, t[i] &= 255;
  for (i = 0; i < 32; ++i)
    t[i] -= a * sa[i];
  for (r = 0; r < 32; ++r)
    t[r + 1] += t[r] >> 8, e[r] = t[r] & 255;
}
function Sa(e) {
  for (var t = new Float64Array(64), a = 0; a < 64; ++a)
    t[a] = e[a], e[a] = 0;
  sn(e, t);
}
function Ta(e, t) {
  var a = W(), r = W(), i = W(), n = W(), s = W(), o = W(), l = W(), f = W(), u = W();
  ar(a, e[1], e[0]), ar(u, t[1], t[0]), ve(a, a, u), tr(r, e[0], e[1]), tr(u, t[0], t[1]), ve(r, r, u), ve(i, e[3], t[3]), ve(i, i, ru), ve(n, e[2], t[2]), tr(n, n, n), ar(s, r, a), ar(o, n, i), tr(l, n, i), tr(f, r, a), ve(e[0], s, o), ve(e[1], f, l), ve(e[2], l, o), ve(e[3], s, f);
}
function yi(e, t, a) {
  for (var r = 0; r < 4; ++r)
    ln(e[r], t[r], a);
}
function Ha(e, t) {
  var a = W(), r = W(), i = W();
  cu(i, t[2]), ve(a, t[0], i), ve(r, t[1], i), Kr(e, r), e[31] ^= un(a) << 7;
}
function Kr(e, t) {
  var a, r, i, n = W(), s = W();
  for (a = 0; a < 16; ++a)
    s[a] = t[a];
  for (oa(s), oa(s), oa(s), r = 0; r < 2; ++r) {
    for (n[0] = s[0] - 65517, a = 1; a < 15; ++a)
      n[a] = s[a] - 65535 - (n[a - 1] >> 16 & 1), n[a - 1] &= 65535;
    n[15] = s[15] - 32767 - (n[14] >> 16 & 1), i = n[15] >> 16 & 1, n[14] &= 65535, ln(s, n, 1 - i);
  }
  for (a = 0; a < 16; a++)
    e[2 * a] = s[a] & 255, e[2 * a + 1] = s[a] >> 8;
}
function ou(e, t) {
  var a = W(), r = W(), i = W(), n = W(), s = W(), o = W(), l = W();
  return Ot(e[2], Or), uu(e[1], t), Yt(i, e[1]), ve(n, i, tu), ar(i, i, e[2]), tr(n, e[2], n), Yt(s, n), Yt(o, s), ve(l, o, s), ve(a, l, i), ve(a, a, n), fu(a, a), ve(a, a, i), ve(a, a, n), ve(a, a, n), ve(e[0], a, n), Yt(r, e[0]), ve(r, r, n), gi(r, i) && ve(e[0], e[0], au), Yt(r, e[0]), ve(r, r, n), gi(r, i) ? -1 : (un(e[0]) === t[31] >> 7 && ar(e[0], xa, e[0]), ve(e[3], e[0], e[1]), 0);
}
function uu(e, t) {
  var a;
  for (a = 0; a < 16; ++a)
    e[a] = t[2 * a] + (t[2 * a + 1] << 8);
  e[15] &= 32767;
}
function fu(e, t) {
  var a = W(), r;
  for (r = 0; r < 16; ++r)
    a[r] = t[r];
  for (r = 250; r >= 0; --r)
    Yt(a, a), r !== 1 && ve(a, a, t);
  for (r = 0; r < 16; ++r)
    e[r] = a[r];
}
function gi(e, t) {
  var a = new it(32), r = new it(32);
  return Kr(a, e), Kr(r, t), on(a, 0, r, 0);
}
function on(e, t, a, r) {
  return lu(e, t, a, r, 32);
}
function lu(e, t, a, r, i) {
  var n, s = 0;
  for (n = 0; n < i; ++n)
    s |= e[t + n] ^ a[r + n];
  return (1 & s - 1 >>> 8) - 1;
}
function un(e) {
  var t = new it(32);
  return Kr(t, e), t[0] & 1;
}
function fn(e, t, a) {
  var r, i;
  for (Ot(e[0], xa), Ot(e[1], Or), Ot(e[2], Or), Ot(e[3], xa), i = 255; i >= 0; --i)
    r = a[i / 8 | 0] >> (i & 7) & 1, yi(e, t, r), Ta(t, e), Ta(e, e), yi(e, t, r);
}
function Ga(e, t) {
  var a = [W(), W(), W(), W()];
  Ot(a[0], pi), Ot(a[1], di), Ot(a[2], Or), ve(a[3], pi, di), fn(e, a, t);
}
function Ot(e, t) {
  var a;
  for (a = 0; a < 16; a++)
    e[a] = t[a] | 0;
}
function cu(e, t) {
  var a = W(), r;
  for (r = 0; r < 16; ++r)
    a[r] = t[r];
  for (r = 253; r >= 0; --r)
    Yt(a, a), r !== 2 && r !== 4 && ve(a, a, t);
  for (r = 0; r < 16; ++r)
    e[r] = a[r];
}
function oa(e) {
  var t, a, r = 1;
  for (t = 0; t < 16; ++t)
    a = e[t] + r + 65535, r = Math.floor(a / 65536), e[t] = a - r * 65536;
  e[0] += r - 1 + 37 * (r - 1);
}
function ln(e, t, a) {
  for (var r, i = ~(a - 1), n = 0; n < 16; ++n)
    r = i & (e[n] ^ t[n]), e[n] ^= r, t[n] ^= r;
}
function W(e) {
  var t, a = new Float64Array(16);
  if (e)
    for (t = 0; t < e.length; ++t)
      a[t] = e[t];
  return a;
}
function tr(e, t, a) {
  for (var r = 0; r < 16; ++r)
    e[r] = t[r] + a[r];
}
function ar(e, t, a) {
  for (var r = 0; r < 16; ++r)
    e[r] = t[r] - a[r];
}
function Yt(e, t) {
  ve(e, t, t);
}
function ve(e, t, a) {
  var r, i, n = 0, s = 0, o = 0, l = 0, f = 0, u = 0, p = 0, m = 0, S = 0, C = 0, A = 0, b = 0, _ = 0, U = 0, D = 0, G = 0, O = 0, F = 0, $ = 0, j = 0, le = 0, he = 0, de = 0, Ee = 0, je = 0, rt = 0, ye = 0, Ae = 0, z = 0, gt = 0, Rt = 0, be = a[0], we = a[1], Le = a[2], He = a[3], se = a[4], ce = a[5], ke = a[6], Pe = a[7], Ve = a[8], Fe = a[9], Oe = a[10], Be = a[11], Ue = a[12], Ke = a[13], Ge = a[14], Me = a[15];
  r = t[0], n += r * be, s += r * we, o += r * Le, l += r * He, f += r * se, u += r * ce, p += r * ke, m += r * Pe, S += r * Ve, C += r * Fe, A += r * Oe, b += r * Be, _ += r * Ue, U += r * Ke, D += r * Ge, G += r * Me, r = t[1], s += r * be, o += r * we, l += r * Le, f += r * He, u += r * se, p += r * ce, m += r * ke, S += r * Pe, C += r * Ve, A += r * Fe, b += r * Oe, _ += r * Be, U += r * Ue, D += r * Ke, G += r * Ge, O += r * Me, r = t[2], o += r * be, l += r * we, f += r * Le, u += r * He, p += r * se, m += r * ce, S += r * ke, C += r * Pe, A += r * Ve, b += r * Fe, _ += r * Oe, U += r * Be, D += r * Ue, G += r * Ke, O += r * Ge, F += r * Me, r = t[3], l += r * be, f += r * we, u += r * Le, p += r * He, m += r * se, S += r * ce, C += r * ke, A += r * Pe, b += r * Ve, _ += r * Fe, U += r * Oe, D += r * Be, G += r * Ue, O += r * Ke, F += r * Ge, $ += r * Me, r = t[4], f += r * be, u += r * we, p += r * Le, m += r * He, S += r * se, C += r * ce, A += r * ke, b += r * Pe, _ += r * Ve, U += r * Fe, D += r * Oe, G += r * Be, O += r * Ue, F += r * Ke, $ += r * Ge, j += r * Me, r = t[5], u += r * be, p += r * we, m += r * Le, S += r * He, C += r * se, A += r * ce, b += r * ke, _ += r * Pe, U += r * Ve, D += r * Fe, G += r * Oe, O += r * Be, F += r * Ue, $ += r * Ke, j += r * Ge, le += r * Me, r = t[6], p += r * be, m += r * we, S += r * Le, C += r * He, A += r * se, b += r * ce, _ += r * ke, U += r * Pe, D += r * Ve, G += r * Fe, O += r * Oe, F += r * Be, $ += r * Ue, j += r * Ke, le += r * Ge, he += r * Me, r = t[7], m += r * be, S += r * we, C += r * Le, A += r * He, b += r * se, _ += r * ce, U += r * ke, D += r * Pe, G += r * Ve, O += r * Fe, F += r * Oe, $ += r * Be, j += r * Ue, le += r * Ke, he += r * Ge, de += r * Me, r = t[8], S += r * be, C += r * we, A += r * Le, b += r * He, _ += r * se, U += r * ce, D += r * ke, G += r * Pe, O += r * Ve, F += r * Fe, $ += r * Oe, j += r * Be, le += r * Ue, he += r * Ke, de += r * Ge, Ee += r * Me, r = t[9], C += r * be, A += r * we, b += r * Le, _ += r * He, U += r * se, D += r * ce, G += r * ke, O += r * Pe, F += r * Ve, $ += r * Fe, j += r * Oe, le += r * Be, he += r * Ue, de += r * Ke, Ee += r * Ge, je += r * Me, r = t[10], A += r * be, b += r * we, _ += r * Le, U += r * He, D += r * se, G += r * ce, O += r * ke, F += r * Pe, $ += r * Ve, j += r * Fe, le += r * Oe, he += r * Be, de += r * Ue, Ee += r * Ke, je += r * Ge, rt += r * Me, r = t[11], b += r * be, _ += r * we, U += r * Le, D += r * He, G += r * se, O += r * ce, F += r * ke, $ += r * Pe, j += r * Ve, le += r * Fe, he += r * Oe, de += r * Be, Ee += r * Ue, je += r * Ke, rt += r * Ge, ye += r * Me, r = t[12], _ += r * be, U += r * we, D += r * Le, G += r * He, O += r * se, F += r * ce, $ += r * ke, j += r * Pe, le += r * Ve, he += r * Fe, de += r * Oe, Ee += r * Be, je += r * Ue, rt += r * Ke, ye += r * Ge, Ae += r * Me, r = t[13], U += r * be, D += r * we, G += r * Le, O += r * He, F += r * se, $ += r * ce, j += r * ke, le += r * Pe, he += r * Ve, de += r * Fe, Ee += r * Oe, je += r * Be, rt += r * Ue, ye += r * Ke, Ae += r * Ge, z += r * Me, r = t[14], D += r * be, G += r * we, O += r * Le, F += r * He, $ += r * se, j += r * ce, le += r * ke, he += r * Pe, de += r * Ve, Ee += r * Fe, je += r * Oe, rt += r * Be, ye += r * Ue, Ae += r * Ke, z += r * Ge, gt += r * Me, r = t[15], G += r * be, O += r * we, F += r * Le, $ += r * He, j += r * se, le += r * ce, he += r * ke, de += r * Pe, Ee += r * Ve, je += r * Fe, rt += r * Oe, ye += r * Be, Ae += r * Ue, z += r * Ke, gt += r * Ge, Rt += r * Me, n += 38 * O, s += 38 * F, o += 38 * $, l += 38 * j, f += 38 * le, u += 38 * he, p += 38 * de, m += 38 * Ee, S += 38 * je, C += 38 * rt, A += 38 * ye, b += 38 * Ae, _ += 38 * z, U += 38 * gt, D += 38 * Rt, i = 1, r = n + i + 65535, i = Math.floor(r / 65536), n = r - i * 65536, r = s + i + 65535, i = Math.floor(r / 65536), s = r - i * 65536, r = o + i + 65535, i = Math.floor(r / 65536), o = r - i * 65536, r = l + i + 65535, i = Math.floor(r / 65536), l = r - i * 65536, r = f + i + 65535, i = Math.floor(r / 65536), f = r - i * 65536, r = u + i + 65535, i = Math.floor(r / 65536), u = r - i * 65536, r = p + i + 65535, i = Math.floor(r / 65536), p = r - i * 65536, r = m + i + 65535, i = Math.floor(r / 65536), m = r - i * 65536, r = S + i + 65535, i = Math.floor(r / 65536), S = r - i * 65536, r = C + i + 65535, i = Math.floor(r / 65536), C = r - i * 65536, r = A + i + 65535, i = Math.floor(r / 65536), A = r - i * 65536, r = b + i + 65535, i = Math.floor(r / 65536), b = r - i * 65536, r = _ + i + 65535, i = Math.floor(r / 65536), _ = r - i * 65536, r = U + i + 65535, i = Math.floor(r / 65536), U = r - i * 65536, r = D + i + 65535, i = Math.floor(r / 65536), D = r - i * 65536, r = G + i + 65535, i = Math.floor(r / 65536), G = r - i * 65536, n += i - 1 + 37 * (i - 1), i = 1, r = n + i + 65535, i = Math.floor(r / 65536), n = r - i * 65536, r = s + i + 65535, i = Math.floor(r / 65536), s = r - i * 65536, r = o + i + 65535, i = Math.floor(r / 65536), o = r - i * 65536, r = l + i + 65535, i = Math.floor(r / 65536), l = r - i * 65536, r = f + i + 65535, i = Math.floor(r / 65536), f = r - i * 65536, r = u + i + 65535, i = Math.floor(r / 65536), u = r - i * 65536, r = p + i + 65535, i = Math.floor(r / 65536), p = r - i * 65536, r = m + i + 65535, i = Math.floor(r / 65536), m = r - i * 65536, r = S + i + 65535, i = Math.floor(r / 65536), S = r - i * 65536, r = C + i + 65535, i = Math.floor(r / 65536), C = r - i * 65536, r = A + i + 65535, i = Math.floor(r / 65536), A = r - i * 65536, r = b + i + 65535, i = Math.floor(r / 65536), b = r - i * 65536, r = _ + i + 65535, i = Math.floor(r / 65536), _ = r - i * 65536, r = U + i + 65535, i = Math.floor(r / 65536), U = r - i * 65536, r = D + i + 65535, i = Math.floor(r / 65536), D = r - i * 65536, r = G + i + 65535, i = Math.floor(r / 65536), G = r - i * 65536, n += i - 1 + 37 * (i - 1), e[0] = n, e[1] = s, e[2] = o, e[3] = l, e[4] = f, e[5] = u, e[6] = p, e[7] = m, e[8] = S, e[9] = C, e[10] = A, e[11] = b, e[12] = _, e[13] = U, e[14] = D, e[15] = G;
}
var st = ee;
st.kem = st.kem || {};
var vi = st.jsbn.BigInteger;
st.kem.rsa = {};
st.kem.rsa.create = function(e, t) {
  t = t || {};
  var a = t.prng || st.random, r = {};
  return r.encrypt = function(i, n) {
    var s = Math.ceil(i.n.bitLength() / 8), o;
    do
      o = new vi(
        st.util.bytesToHex(a.getBytesSync(s)),
        16
      ).mod(i.n);
    while (o.compareTo(vi.ONE) <= 0);
    o = st.util.hexToBytes(o.toString(16));
    var l = s - o.length;
    l > 0 && (o = st.util.fillString("\0", l) + o);
    var f = i.encrypt(o, "NONE"), u = e.generate(o, n);
    return { encapsulation: f, key: u };
  }, r.decrypt = function(i, n, s) {
    var o = i.decrypt(n, "NONE");
    return e.generate(o, s);
  }, r;
};
st.kem.kdf1 = function(e, t) {
  cn(this, e, 0, t || e.digestLength);
};
st.kem.kdf2 = function(e, t) {
  cn(this, e, 1, t || e.digestLength);
};
function cn(e, t, a, r) {
  e.generate = function(i, n) {
    for (var s = new st.util.ByteBuffer(), o = Math.ceil(n / r) + a, l = new st.util.ByteBuffer(), f = a; f < o; ++f) {
      l.putInt32(f), t.start(), t.update(i + l.getBytes());
      var u = t.digest();
      s.putBytes(u.getBytes(r));
    }
    return s.truncate(s.length() - n), s.getBytes();
  };
}
var ne = ee;
ne.log = ne.log || {};
ne.log.levels = [
  "none",
  "error",
  "warning",
  "info",
  "debug",
  "verbose",
  "max"
];
var Mr = {}, Ia = [], Cr = null;
ne.log.LEVEL_LOCKED = 2;
ne.log.NO_LEVEL_CHECK = 4;
ne.log.INTERPOLATE = 8;
for (var Kt = 0; Kt < ne.log.levels.length; ++Kt) {
  var mi = ne.log.levels[Kt];
  Mr[mi] = {
    index: Kt,
    name: mi.toUpperCase()
  };
}
ne.log.logMessage = function(e) {
  for (var t = Mr[e.level].index, a = 0; a < Ia.length; ++a) {
    var r = Ia[a];
    if (r.flags & ne.log.NO_LEVEL_CHECK)
      r.f(e);
    else {
      var i = Mr[r.level].index;
      t <= i && r.f(r, e);
    }
  }
};
ne.log.prepareStandard = function(e) {
  "standard" in e || (e.standard = Mr[e.level].name + //' ' + +message.timestamp +
  " [" + e.category + "] " + e.message);
};
ne.log.prepareFull = function(e) {
  if (!("full" in e)) {
    var t = [e.message];
    t = t.concat([]), e.full = ne.util.format.apply(this, t);
  }
};
ne.log.prepareStandardFull = function(e) {
  "standardFull" in e || (ne.log.prepareStandard(e), e.standardFull = e.standard);
};
for (var Ci = ["error", "warning", "info", "debug", "verbose"], Kt = 0; Kt < Ci.length; ++Kt)
  (function(t) {
    ne.log[t] = function(a, r) {
      var i = Array.prototype.slice.call(arguments).slice(2), n = {
        timestamp: /* @__PURE__ */ new Date(),
        level: t,
        category: a,
        message: r,
        arguments: i
        /*standard*/
        /*full*/
        /*fullMessage*/
      };
      ne.log.logMessage(n);
    };
  })(Ci[Kt]);
ne.log.makeLogger = function(e) {
  var t = {
    flags: 0,
    f: e
  };
  return ne.log.setLevel(t, "none"), t;
};
ne.log.setLevel = function(e, t) {
  var a = !1;
  if (e && !(e.flags & ne.log.LEVEL_LOCKED))
    for (var r = 0; r < ne.log.levels.length; ++r) {
      var i = ne.log.levels[r];
      if (t == i) {
        e.level = t, a = !0;
        break;
      }
    }
  return a;
};
ne.log.lock = function(e, t) {
  typeof t > "u" || t ? e.flags |= ne.log.LEVEL_LOCKED : e.flags &= ~ne.log.LEVEL_LOCKED;
};
ne.log.addLogger = function(e) {
  Ia.push(e);
};
if (typeof console < "u" && "log" in console) {
  var dr;
  if (console.error && console.warn && console.info && console.debug) {
    var hu = {
      error: console.error,
      warning: console.warn,
      info: console.info,
      debug: console.debug,
      verbose: console.debug
    }, qa = function(e, t) {
      ne.log.prepareStandard(t);
      var a = hu[t.level], r = [t.standard];
      r = r.concat(t.arguments.slice()), a.apply(console, r);
    };
    dr = ne.log.makeLogger(qa);
  } else {
    var qa = function(t, a) {
      ne.log.prepareStandardFull(a), console.log(a.standardFull);
    };
    dr = ne.log.makeLogger(qa);
  }
  ne.log.setLevel(dr, "debug"), ne.log.addLogger(dr), Cr = dr;
} else
  console = {
    log: function() {
    }
  };
if (Cr !== null && typeof window < "u" && window.location) {
  var br = new URL(window.location.href).searchParams;
  if (br.has("console.level") && ne.log.setLevel(
    Cr,
    br.get("console.level").slice(-1)[0]
  ), br.has("console.lock")) {
    var pu = br.get("console.lock").slice(-1)[0];
    pu == "true" && ne.log.lock(Cr);
  }
}
ne.log.consoleLogger = Cr;
var M = ee, T = M.asn1, tt = M.pkcs7 = M.pkcs7 || {};
tt.messageFromPem = function(e) {
  var t = M.pem.decode(e)[0];
  if (t.type !== "PKCS7") {
    var a = new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');
    throw a.headerType = t.type, a;
  }
  if (t.procType && t.procType.type === "ENCRYPTED")
    throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");
  var r = T.fromDer(t.body);
  return tt.messageFromAsn1(r);
};
tt.messageToPem = function(e, t) {
  var a = {
    type: "PKCS7",
    body: T.toDer(e.toAsn1()).getBytes()
  };
  return M.pem.encode(a, { maxline: t });
};
tt.messageFromAsn1 = function(e) {
  var t = {}, a = [];
  if (!T.validate(e, tt.asn1.contentInfoValidator, t, a)) {
    var r = new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");
    throw r.errors = a, r;
  }
  var i = T.derToOid(t.contentType), n;
  switch (i) {
    case M.pki.oids.envelopedData:
      n = tt.createEnvelopedData();
      break;
    case M.pki.oids.encryptedData:
      n = tt.createEncryptedData();
      break;
    case M.pki.oids.signedData:
      n = tt.createSignedData();
      break;
    default:
      throw new Error("Cannot read PKCS#7 message. ContentType with OID " + i + " is not (yet) supported.");
  }
  return n.fromAsn1(t.content.value[0]), n;
};
tt.createSignedData = function() {
  var e = null;
  return e = {
    type: M.pki.oids.signedData,
    version: 1,
    certificates: [],
    crls: [],
    // TODO: add json-formatted signer stuff here?
    signers: [],
    // populated during sign()
    digestAlgorithmIdentifiers: [],
    contentInfo: null,
    signerInfos: [],
    fromAsn1: function(r) {
      if (Qa(e, r, tt.asn1.signedDataValidator), e.certificates = [], e.crls = [], e.digestAlgorithmIdentifiers = [], e.contentInfo = null, e.signerInfos = [], e.rawCapture.certificates)
        for (var i = e.rawCapture.certificates.value, n = 0; n < i.length; ++n)
          e.certificates.push(M.pki.certificateFromAsn1(i[n]));
    },
    toAsn1: function() {
      e.contentInfo || e.sign();
      for (var r = [], i = 0; i < e.certificates.length; ++i)
        r.push(M.pki.certificateToAsn1(e.certificates[i]));
      var n = [], s = T.create(T.Class.CONTEXT_SPECIFIC, 0, !0, [
        T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
          // Version
          T.create(
            T.Class.UNIVERSAL,
            T.Type.INTEGER,
            !1,
            T.integerToDer(e.version).getBytes()
          ),
          // DigestAlgorithmIdentifiers
          T.create(
            T.Class.UNIVERSAL,
            T.Type.SET,
            !0,
            e.digestAlgorithmIdentifiers
          ),
          // ContentInfo
          e.contentInfo
        ])
      ]);
      return r.length > 0 && s.value[0].value.push(
        T.create(T.Class.CONTEXT_SPECIFIC, 0, !0, r)
      ), n.length > 0 && s.value[0].value.push(
        T.create(T.Class.CONTEXT_SPECIFIC, 1, !0, n)
      ), s.value[0].value.push(
        T.create(
          T.Class.UNIVERSAL,
          T.Type.SET,
          !0,
          e.signerInfos
        )
      ), T.create(
        T.Class.UNIVERSAL,
        T.Type.SEQUENCE,
        !0,
        [
          // ContentType
          T.create(
            T.Class.UNIVERSAL,
            T.Type.OID,
            !1,
            T.oidToDer(e.type).getBytes()
          ),
          // [0] SignedData
          s
        ]
      );
    },
    /**
     * Add (another) entity to list of signers.
     *
     * Note: If authenticatedAttributes are provided, then, per RFC 2315,
     * they must include at least two attributes: content type and
     * message digest. The message digest attribute value will be
     * auto-calculated during signing and will be ignored if provided.
     *
     * Here's an example of providing these two attributes:
     *
     * forge.pkcs7.createSignedData();
     * p7.addSigner({
     *   issuer: cert.issuer.attributes,
     *   serialNumber: cert.serialNumber,
     *   key: privateKey,
     *   digestAlgorithm: forge.pki.oids.sha1,
     *   authenticatedAttributes: [{
     *     type: forge.pki.oids.contentType,
     *     value: forge.pki.oids.data
     *   }, {
     *     type: forge.pki.oids.messageDigest
     *   }]
     * });
     *
     * TODO: Support [subjectKeyIdentifier] as signer's ID.
     *
     * @param signer the signer information:
     *          key the signer's private key.
     *          [certificate] a certificate containing the public key
     *            associated with the signer's private key; use this option as
     *            an alternative to specifying signer.issuer and
     *            signer.serialNumber.
     *          [issuer] the issuer attributes (eg: cert.issuer.attributes).
     *          [serialNumber] the signer's certificate's serial number in
     *           hexadecimal (eg: cert.serialNumber).
     *          [digestAlgorithm] the message digest OID, as a string, to use
     *            (eg: forge.pki.oids.sha1).
     *          [authenticatedAttributes] an optional array of attributes
     *            to also sign along with the content.
     */
    addSigner: function(r) {
      var i = r.issuer, n = r.serialNumber;
      if (r.certificate) {
        var s = r.certificate;
        typeof s == "string" && (s = M.pki.certificateFromPem(s)), i = s.issuer.attributes, n = s.serialNumber;
      }
      var o = r.key;
      if (!o)
        throw new Error(
          "Could not add PKCS#7 signer; no private key specified."
        );
      typeof o == "string" && (o = M.pki.privateKeyFromPem(o));
      var l = r.digestAlgorithm || M.pki.oids.sha1;
      switch (l) {
        case M.pki.oids.sha1:
        case M.pki.oids.sha256:
        case M.pki.oids.sha384:
        case M.pki.oids.sha512:
        case M.pki.oids.md5:
          break;
        default:
          throw new Error(
            "Could not add PKCS#7 signer; unknown message digest algorithm: " + l
          );
      }
      var f = r.authenticatedAttributes || [];
      if (f.length > 0) {
        for (var u = !1, p = !1, m = 0; m < f.length; ++m) {
          var S = f[m];
          if (!u && S.type === M.pki.oids.contentType) {
            if (u = !0, p)
              break;
            continue;
          }
          if (!p && S.type === M.pki.oids.messageDigest) {
            if (p = !0, u)
              break;
            continue;
          }
        }
        if (!u || !p)
          throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.");
      }
      e.signers.push({
        key: o,
        version: 1,
        issuer: i,
        serialNumber: n,
        digestAlgorithm: l,
        signatureAlgorithm: M.pki.oids.rsaEncryption,
        signature: null,
        authenticatedAttributes: f,
        unauthenticatedAttributes: []
      });
    },
    /**
     * Signs the content.
     * @param options Options to apply when signing:
     *    [detached] boolean. If signing should be done in detached mode. Defaults to false.
     */
    sign: function(r) {
      if (r = r || {}, (typeof e.content != "object" || e.contentInfo === null) && (e.contentInfo = T.create(
        T.Class.UNIVERSAL,
        T.Type.SEQUENCE,
        !0,
        [
          // ContentType
          T.create(
            T.Class.UNIVERSAL,
            T.Type.OID,
            !1,
            T.oidToDer(M.pki.oids.data).getBytes()
          )
        ]
      ), "content" in e)) {
        var i;
        e.content instanceof M.util.ByteBuffer ? i = e.content.bytes() : typeof e.content == "string" && (i = M.util.encodeUtf8(e.content)), r.detached ? e.detachedContent = T.create(T.Class.UNIVERSAL, T.Type.OCTETSTRING, !1, i) : e.contentInfo.value.push(
          // [0] EXPLICIT content
          T.create(T.Class.CONTEXT_SPECIFIC, 0, !0, [
            T.create(
              T.Class.UNIVERSAL,
              T.Type.OCTETSTRING,
              !1,
              i
            )
          ])
        );
      }
      if (e.signers.length !== 0) {
        var n = t();
        a(n);
      }
    },
    verify: function() {
      throw new Error("PKCS#7 signature verification not yet implemented.");
    },
    /**
     * Add a certificate.
     *
     * @param cert the certificate to add.
     */
    addCertificate: function(r) {
      typeof r == "string" && (r = M.pki.certificateFromPem(r)), e.certificates.push(r);
    },
    /**
     * Add a certificate revokation list.
     *
     * @param crl the certificate revokation list to add.
     */
    addCertificateRevokationList: function(r) {
      throw new Error("PKCS#7 CRL support not yet implemented.");
    }
  }, e;
  function t() {
    for (var r = {}, i = 0; i < e.signers.length; ++i) {
      var n = e.signers[i], s = n.digestAlgorithm;
      s in r || (r[s] = M.md[M.pki.oids[s]].create()), n.authenticatedAttributes.length === 0 ? n.md = r[s] : n.md = M.md[M.pki.oids[s]].create();
    }
    e.digestAlgorithmIdentifiers = [];
    for (var s in r)
      e.digestAlgorithmIdentifiers.push(
        // AlgorithmIdentifier
        T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
          // algorithm
          T.create(
            T.Class.UNIVERSAL,
            T.Type.OID,
            !1,
            T.oidToDer(s).getBytes()
          ),
          // parameters (null)
          T.create(T.Class.UNIVERSAL, T.Type.NULL, !1, "")
        ])
      );
    return r;
  }
  function a(r) {
    var i;
    if (e.detachedContent ? i = e.detachedContent : (i = e.contentInfo.value[1], i = i.value[0]), !i)
      throw new Error(
        "Could not sign PKCS#7 message; there is no content to sign."
      );
    var n = T.derToOid(e.contentInfo.value[0].value), s = T.toDer(i);
    s.getByte(), T.getBerValueLength(s), s = s.getBytes();
    for (var o in r)
      r[o].start().update(s);
    for (var l = /* @__PURE__ */ new Date(), f = 0; f < e.signers.length; ++f) {
      var u = e.signers[f];
      if (u.authenticatedAttributes.length === 0) {
        if (n !== M.pki.oids.data)
          throw new Error(
            "Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data."
          );
      } else {
        u.authenticatedAttributesAsn1 = T.create(
          T.Class.CONTEXT_SPECIFIC,
          0,
          !0,
          []
        );
        for (var p = T.create(
          T.Class.UNIVERSAL,
          T.Type.SET,
          !0,
          []
        ), m = 0; m < u.authenticatedAttributes.length; ++m) {
          var S = u.authenticatedAttributes[m];
          S.type === M.pki.oids.messageDigest ? S.value = r[u.digestAlgorithm].digest() : S.type === M.pki.oids.signingTime && (S.value || (S.value = l)), p.value.push(Ba(S)), u.authenticatedAttributesAsn1.value.push(Ba(S));
        }
        s = T.toDer(p).getBytes(), u.md.start().update(s);
      }
      u.signature = u.key.sign(u.md, "RSASSA-PKCS1-V1_5");
    }
    e.signerInfos = Cu(e.signers);
  }
};
tt.createEncryptedData = function() {
  var e = null;
  return e = {
    type: M.pki.oids.encryptedData,
    version: 0,
    encryptedContent: {
      algorithm: M.pki.oids["aes256-CBC"]
    },
    /**
     * Reads an EncryptedData content block (in ASN.1 format)
     *
     * @param obj The ASN.1 representation of the EncryptedData content block
     */
    fromAsn1: function(t) {
      Qa(e, t, tt.asn1.encryptedDataValidator);
    },
    /**
     * Decrypt encrypted content
     *
     * @param key The (symmetric) key as a byte buffer
     */
    decrypt: function(t) {
      t !== void 0 && (e.encryptedContent.key = t), hn(e);
    }
  }, e;
};
tt.createEnvelopedData = function() {
  var e = null;
  return e = {
    type: M.pki.oids.envelopedData,
    version: 0,
    recipients: [],
    encryptedContent: {
      algorithm: M.pki.oids["aes256-CBC"]
    },
    /**
     * Reads an EnvelopedData content block (in ASN.1 format)
     *
     * @param obj the ASN.1 representation of the EnvelopedData content block.
     */
    fromAsn1: function(t) {
      var a = Qa(e, t, tt.asn1.envelopedDataValidator);
      e.recipients = gu(a.recipientInfos.value);
    },
    toAsn1: function() {
      return T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
        // ContentType
        T.create(
          T.Class.UNIVERSAL,
          T.Type.OID,
          !1,
          T.oidToDer(e.type).getBytes()
        ),
        // [0] EnvelopedData
        T.create(T.Class.CONTEXT_SPECIFIC, 0, !0, [
          T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
            // Version
            T.create(
              T.Class.UNIVERSAL,
              T.Type.INTEGER,
              !1,
              T.integerToDer(e.version).getBytes()
            ),
            // RecipientInfos
            T.create(
              T.Class.UNIVERSAL,
              T.Type.SET,
              !0,
              vu(e.recipients)
            ),
            // EncryptedContentInfo
            T.create(
              T.Class.UNIVERSAL,
              T.Type.SEQUENCE,
              !0,
              Eu(e.encryptedContent)
            )
          ])
        ])
      ]);
    },
    /**
     * Find recipient by X.509 certificate's issuer.
     *
     * @param cert the certificate with the issuer to look for.
     *
     * @return the recipient object.
     */
    findRecipient: function(t) {
      for (var a = t.issuer.attributes, r = 0; r < e.recipients.length; ++r) {
        var i = e.recipients[r], n = i.issuer;
        if (i.serialNumber === t.serialNumber && n.length === a.length) {
          for (var s = !0, o = 0; o < a.length; ++o)
            if (n[o].type !== a[o].type || n[o].value !== a[o].value) {
              s = !1;
              break;
            }
          if (s)
            return i;
        }
      }
      return null;
    },
    /**
     * Decrypt enveloped content
     *
     * @param recipient The recipient object related to the private key
     * @param privKey The (RSA) private key object
     */
    decrypt: function(t, a) {
      if (e.encryptedContent.key === void 0 && t !== void 0 && a !== void 0)
        switch (t.encryptedContent.algorithm) {
          case M.pki.oids.rsaEncryption:
          case M.pki.oids.desCBC:
            var r = a.decrypt(t.encryptedContent.content);
            e.encryptedContent.key = M.util.createBuffer(r);
            break;
          default:
            throw new Error("Unsupported asymmetric cipher, OID " + t.encryptedContent.algorithm);
        }
      hn(e);
    },
    /**
     * Add (another) entity to list of recipients.
     *
     * @param cert The certificate of the entity to add.
     */
    addRecipient: function(t) {
      e.recipients.push({
        version: 0,
        issuer: t.issuer.attributes,
        serialNumber: t.serialNumber,
        encryptedContent: {
          // We simply assume rsaEncryption here, since forge.pki only
          // supports RSA so far.  If the PKI module supports other
          // ciphers one day, we need to modify this one as well.
          algorithm: M.pki.oids.rsaEncryption,
          key: t.publicKey
        }
      });
    },
    /**
     * Encrypt enveloped content.
     *
     * This function supports two optional arguments, cipher and key, which
     * can be used to influence symmetric encryption.  Unless cipher is
     * provided, the cipher specified in encryptedContent.algorithm is used
     * (defaults to AES-256-CBC).  If no key is provided, encryptedContent.key
     * is (re-)used.  If that one's not set, a random key will be generated
     * automatically.
     *
     * @param [key] The key to be used for symmetric encryption.
     * @param [cipher] The OID of the symmetric cipher to use.
     */
    encrypt: function(t, a) {
      if (e.encryptedContent.content === void 0) {
        a = a || e.encryptedContent.algorithm, t = t || e.encryptedContent.key;
        var r, i, n;
        switch (a) {
          case M.pki.oids["aes128-CBC"]:
            r = 16, i = 16, n = M.aes.createEncryptionCipher;
            break;
          case M.pki.oids["aes192-CBC"]:
            r = 24, i = 16, n = M.aes.createEncryptionCipher;
            break;
          case M.pki.oids["aes256-CBC"]:
            r = 32, i = 16, n = M.aes.createEncryptionCipher;
            break;
          case M.pki.oids["des-EDE3-CBC"]:
            r = 24, i = 8, n = M.des.createEncryptionCipher;
            break;
          default:
            throw new Error("Unsupported symmetric cipher, OID " + a);
        }
        if (t === void 0)
          t = M.util.createBuffer(M.random.getBytes(r));
        else if (t.length() != r)
          throw new Error("Symmetric key has wrong length; got " + t.length() + " bytes, expected " + r + ".");
        e.encryptedContent.algorithm = a, e.encryptedContent.key = t, e.encryptedContent.parameter = M.util.createBuffer(
          M.random.getBytes(i)
        );
        var s = n(t);
        if (s.start(e.encryptedContent.parameter.copy()), s.update(e.content), !s.finish())
          throw new Error("Symmetric encryption failed.");
        e.encryptedContent.content = s.output;
      }
      for (var o = 0; o < e.recipients.length; ++o) {
        var l = e.recipients[o];
        if (l.encryptedContent.content === void 0)
          switch (l.encryptedContent.algorithm) {
            case M.pki.oids.rsaEncryption:
              l.encryptedContent.content = l.encryptedContent.key.encrypt(
                e.encryptedContent.key.data
              );
              break;
            default:
              throw new Error("Unsupported asymmetric cipher, OID " + l.encryptedContent.algorithm);
          }
      }
    }
  }, e;
};
function du(e) {
  var t = {}, a = [];
  if (!T.validate(e, tt.asn1.recipientInfoValidator, t, a)) {
    var r = new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");
    throw r.errors = a, r;
  }
  return {
    version: t.version.charCodeAt(0),
    issuer: M.pki.RDNAttributesAsArray(t.issuer),
    serialNumber: M.util.createBuffer(t.serial).toHex(),
    encryptedContent: {
      algorithm: T.derToOid(t.encAlgorithm),
      parameter: t.encParameter ? t.encParameter.value : void 0,
      content: t.encKey
    }
  };
}
function yu(e) {
  return T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
    // Version
    T.create(
      T.Class.UNIVERSAL,
      T.Type.INTEGER,
      !1,
      T.integerToDer(e.version).getBytes()
    ),
    // IssuerAndSerialNumber
    T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
      // Name
      M.pki.distinguishedNameToAsn1({ attributes: e.issuer }),
      // Serial
      T.create(
        T.Class.UNIVERSAL,
        T.Type.INTEGER,
        !1,
        M.util.hexToBytes(e.serialNumber)
      )
    ]),
    // KeyEncryptionAlgorithmIdentifier
    T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
      // Algorithm
      T.create(
        T.Class.UNIVERSAL,
        T.Type.OID,
        !1,
        T.oidToDer(e.encryptedContent.algorithm).getBytes()
      ),
      // Parameter, force NULL, only RSA supported for now.
      T.create(T.Class.UNIVERSAL, T.Type.NULL, !1, "")
    ]),
    // EncryptedKey
    T.create(
      T.Class.UNIVERSAL,
      T.Type.OCTETSTRING,
      !1,
      e.encryptedContent.content
    )
  ]);
}
function gu(e) {
  for (var t = [], a = 0; a < e.length; ++a)
    t.push(du(e[a]));
  return t;
}
function vu(e) {
  for (var t = [], a = 0; a < e.length; ++a)
    t.push(yu(e[a]));
  return t;
}
function mu(e) {
  var t = T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
    // version
    T.create(
      T.Class.UNIVERSAL,
      T.Type.INTEGER,
      !1,
      T.integerToDer(e.version).getBytes()
    ),
    // issuerAndSerialNumber
    T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
      // name
      M.pki.distinguishedNameToAsn1({ attributes: e.issuer }),
      // serial
      T.create(
        T.Class.UNIVERSAL,
        T.Type.INTEGER,
        !1,
        M.util.hexToBytes(e.serialNumber)
      )
    ]),
    // digestAlgorithm
    T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
      // algorithm
      T.create(
        T.Class.UNIVERSAL,
        T.Type.OID,
        !1,
        T.oidToDer(e.digestAlgorithm).getBytes()
      ),
      // parameters (null)
      T.create(T.Class.UNIVERSAL, T.Type.NULL, !1, "")
    ])
  ]);
  if (e.authenticatedAttributesAsn1 && t.value.push(e.authenticatedAttributesAsn1), t.value.push(T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
    // algorithm
    T.create(
      T.Class.UNIVERSAL,
      T.Type.OID,
      !1,
      T.oidToDer(e.signatureAlgorithm).getBytes()
    ),
    // parameters (null)
    T.create(T.Class.UNIVERSAL, T.Type.NULL, !1, "")
  ])), t.value.push(T.create(
    T.Class.UNIVERSAL,
    T.Type.OCTETSTRING,
    !1,
    e.signature
  )), e.unauthenticatedAttributes.length > 0) {
    for (var a = T.create(T.Class.CONTEXT_SPECIFIC, 1, !0, []), r = 0; r < e.unauthenticatedAttributes.length; ++r) {
      var i = e.unauthenticatedAttributes[r];
      a.values.push(Ba(i));
    }
    t.value.push(a);
  }
  return t;
}
function Cu(e) {
  for (var t = [], a = 0; a < e.length; ++a)
    t.push(mu(e[a]));
  return t;
}
function Ba(e) {
  var t;
  if (e.type === M.pki.oids.contentType)
    t = T.create(
      T.Class.UNIVERSAL,
      T.Type.OID,
      !1,
      T.oidToDer(e.value).getBytes()
    );
  else if (e.type === M.pki.oids.messageDigest)
    t = T.create(
      T.Class.UNIVERSAL,
      T.Type.OCTETSTRING,
      !1,
      e.value.bytes()
    );
  else if (e.type === M.pki.oids.signingTime) {
    var a = /* @__PURE__ */ new Date("1950-01-01T00:00:00Z"), r = /* @__PURE__ */ new Date("2050-01-01T00:00:00Z"), i = e.value;
    if (typeof i == "string") {
      var n = Date.parse(i);
      isNaN(n) ? i.length === 13 ? i = T.utcTimeToDate(i) : i = T.generalizedTimeToDate(i) : i = new Date(n);
    }
    i >= a && i < r ? t = T.create(
      T.Class.UNIVERSAL,
      T.Type.UTCTIME,
      !1,
      T.dateToUtcTime(i)
    ) : t = T.create(
      T.Class.UNIVERSAL,
      T.Type.GENERALIZEDTIME,
      !1,
      T.dateToGeneralizedTime(i)
    );
  }
  return T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
    // AttributeType
    T.create(
      T.Class.UNIVERSAL,
      T.Type.OID,
      !1,
      T.oidToDer(e.type).getBytes()
    ),
    T.create(T.Class.UNIVERSAL, T.Type.SET, !0, [
      // AttributeValue
      t
    ])
  ]);
}
function Eu(e) {
  return [
    // ContentType, always Data for the moment
    T.create(
      T.Class.UNIVERSAL,
      T.Type.OID,
      !1,
      T.oidToDer(M.pki.oids.data).getBytes()
    ),
    // ContentEncryptionAlgorithmIdentifier
    T.create(T.Class.UNIVERSAL, T.Type.SEQUENCE, !0, [
      // Algorithm
      T.create(
        T.Class.UNIVERSAL,
        T.Type.OID,
        !1,
        T.oidToDer(e.algorithm).getBytes()
      ),
      // Parameters (IV)
      e.parameter ? T.create(
        T.Class.UNIVERSAL,
        T.Type.OCTETSTRING,
        !1,
        e.parameter.getBytes()
      ) : void 0
    ]),
    // [0] EncryptedContent
    T.create(T.Class.CONTEXT_SPECIFIC, 0, !0, [
      T.create(
        T.Class.UNIVERSAL,
        T.Type.OCTETSTRING,
        !1,
        e.content.getBytes()
      )
    ])
  ];
}
function Qa(e, t, a) {
  var r = {}, i = [];
  if (!T.validate(t, a, r, i)) {
    var n = new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");
    throw n.errors = n, n;
  }
  var s = T.derToOid(r.contentType);
  if (s !== M.pki.oids.data)
    throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");
  if (r.encryptedContent) {
    var o = "";
    if (M.util.isArray(r.encryptedContent))
      for (var l = 0; l < r.encryptedContent.length; ++l) {
        if (r.encryptedContent[l].type !== T.Type.OCTETSTRING)
          throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");
        o += r.encryptedContent[l].value;
      }
    else
      o = r.encryptedContent;
    e.encryptedContent = {
      algorithm: T.derToOid(r.encAlgorithm),
      parameter: M.util.createBuffer(r.encParameter.value),
      content: M.util.createBuffer(o)
    };
  }
  if (r.content) {
    var o = "";
    if (M.util.isArray(r.content))
      for (var l = 0; l < r.content.length; ++l) {
        if (r.content[l].type !== T.Type.OCTETSTRING)
          throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");
        o += r.content[l].value;
      }
    else
      o = r.content;
    e.content = M.util.createBuffer(o);
  }
  return e.version = r.version.charCodeAt(0), e.rawCapture = r, r;
}
function hn(e) {
  if (e.encryptedContent.key === void 0)
    throw new Error("Symmetric key not available.");
  if (e.content === void 0) {
    var t;
    switch (e.encryptedContent.algorithm) {
      case M.pki.oids["aes128-CBC"]:
      case M.pki.oids["aes192-CBC"]:
      case M.pki.oids["aes256-CBC"]:
        t = M.aes.createDecryptionCipher(e.encryptedContent.key);
        break;
      case M.pki.oids.desCBC:
      case M.pki.oids["des-EDE3-CBC"]:
        t = M.des.createDecryptionCipher(e.encryptedContent.key);
        break;
      default:
        throw new Error("Unsupported symmetric cipher, OID " + e.encryptedContent.algorithm);
    }
    if (t.start(e.encryptedContent.parameter), t.update(e.encryptedContent.content), !t.finish())
      throw new Error("Symmetric decryption failed.");
    e.content = t.output;
  }
}
var De = ee, Zr = De.ssh = De.ssh || {};
Zr.privateKeyToPutty = function(e, t, a) {
  a = a || "", t = t || "";
  var r = "ssh-rsa", i = t === "" ? "none" : "aes256-cbc", n = "PuTTY-User-Key-File-2: " + r + `\r
`;
  n += "Encryption: " + i + `\r
`, n += "Comment: " + a + `\r
`;
  var s = De.util.createBuffer();
  ir(s, r), Et(s, e.e), Et(s, e.n);
  var o = De.util.encode64(s.bytes(), 64), l = Math.floor(o.length / 66) + 1;
  n += "Public-Lines: " + l + `\r
`, n += o;
  var f = De.util.createBuffer();
  Et(f, e.d), Et(f, e.p), Et(f, e.q), Et(f, e.qInv);
  var u;
  if (!t)
    u = De.util.encode64(f.bytes(), 64);
  else {
    var p = f.length() + 16 - 1;
    p -= p % 16;
    var m = wr(f.bytes());
    m.truncate(m.length() - p + f.length()), f.putBuffer(m);
    var S = De.util.createBuffer();
    S.putBuffer(wr("\0\0\0\0", t)), S.putBuffer(wr("\0\0\0", t));
    var C = De.aes.createEncryptionCipher(S.truncate(8), "CBC");
    C.start(De.util.createBuffer().fillWithByte(0, 16)), C.update(f.copy()), C.finish();
    var A = C.output;
    A.truncate(16), u = De.util.encode64(A.bytes(), 64);
  }
  l = Math.floor(u.length / 66) + 1, n += `\r
Private-Lines: ` + l + `\r
`, n += u;
  var b = wr("putty-private-key-file-mac-key", t), _ = De.util.createBuffer();
  ir(_, r), ir(_, i), ir(_, a), _.putInt32(s.length()), _.putBuffer(s), _.putInt32(f.length()), _.putBuffer(f);
  var U = De.hmac.create();
  return U.start("sha1", b), U.update(_.bytes()), n += `\r
Private-MAC: ` + U.digest().toHex() + `\r
`, n;
};
Zr.publicKeyToOpenSSH = function(e, t) {
  var a = "ssh-rsa";
  t = t || "";
  var r = De.util.createBuffer();
  return ir(r, a), Et(r, e.e), Et(r, e.n), a + " " + De.util.encode64(r.bytes()) + " " + t;
};
Zr.privateKeyToOpenSSH = function(e, t) {
  return t ? De.pki.encryptRsaPrivateKey(
    e,
    t,
    { legacy: !0, algorithm: "aes128" }
  ) : De.pki.privateKeyToPem(e);
};
Zr.getPublicKeyFingerprint = function(e, t) {
  t = t || {};
  var a = t.md || De.md.md5.create(), r = "ssh-rsa", i = De.util.createBuffer();
  ir(i, r), Et(i, e.e), Et(i, e.n), a.start(), a.update(i.getBytes());
  var n = a.digest();
  if (t.encoding === "hex") {
    var s = n.toHex();
    return t.delimiter ? s.match(/.{2}/g).join(t.delimiter) : s;
  } else {
    if (t.encoding === "binary")
      return n.getBytes();
    if (t.encoding)
      throw new Error('Unknown encoding "' + t.encoding + '".');
  }
  return n;
};
function Et(e, t) {
  var a = t.toString(16);
  a[0] >= "8" && (a = "00" + a);
  var r = De.util.hexToBytes(a);
  e.putInt32(r.length), e.putBytes(r);
}
function ir(e, t) {
  e.putInt32(t.length), e.putString(t);
}
function wr() {
  for (var e = De.md.sha1.create(), t = arguments.length, a = 0; a < t; ++a)
    e.update(arguments[a]);
  return e.digest();
}
var pn = ee;
const xu = /* @__PURE__ */ Sn(pn), Iu = /* @__PURE__ */ En({ __proto__: null, default: xu }, [pn]);
export {
  Iu as i
};