class A extends Error {}
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */ function t(A) {
    let t = A.length;
    for (; --t >= 0; ) A[t] = 0;
}
const e = 256,
    i = 286,
    s = 30,
    a = 15,
    n = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]),
    h = new Uint8Array([
        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
    ]),
    r = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]),
    E = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]),
    g = new Array(576);
t(g);
const o = new Array(60);
t(o);
const B = new Array(512);
t(B);
const w = new Array(256);
t(w);
const c = new Array(29);
t(c);
const I = new Array(s);
function C(A, t, e, i, s) {
    ((this.static_tree = A),
        (this.extra_bits = t),
        (this.extra_base = e),
        (this.elems = i),
        (this.max_length = s),
        (this.has_stree = A && A.length));
}
let l, _, d;
function D(A, t) {
    ((this.dyn_tree = A), (this.max_code = 0), (this.stat_desc = t));
}
t(I);
const M = (A) => (A < 256 ? B[A] : B[256 + (A >>> 7)]),
    Q = (A, t) => {
        ((A.pending_buf[A.pending++] = 255 & t), (A.pending_buf[A.pending++] = (t >>> 8) & 255));
    },
    S = (A, t, e) => {
        A.bi_valid > 16 - e
            ? ((A.bi_buf |= (t << A.bi_valid) & 65535),
              Q(A, A.bi_buf),
              (A.bi_buf = t >> (16 - A.bi_valid)),
              (A.bi_valid += e - 16))
            : ((A.bi_buf |= (t << A.bi_valid) & 65535), (A.bi_valid += e));
    },
    R = (A, t, e) => {
        S(A, e[2 * t], e[2 * t + 1]);
    },
    f = (A, t) => {
        let e = 0;
        do {
            ((e |= 1 & A), (A >>>= 1), (e <<= 1));
        } while (--t > 0);
        return e >>> 1;
    },
    F = (A, t, e) => {
        const i = new Array(16);
        let s,
            n,
            h = 0;
        for (s = 1; s <= a; s++) ((h = (h + e[s - 1]) << 1), (i[s] = h));
        for (n = 0; n <= t; n++) {
            let t = A[2 * n + 1];
            0 !== t && (A[2 * n] = f(i[t]++, t));
        }
    },
    u = (A) => {
        let t;
        for (t = 0; t < i; t++) A.dyn_ltree[2 * t] = 0;
        for (t = 0; t < s; t++) A.dyn_dtree[2 * t] = 0;
        for (t = 0; t < 19; t++) A.bl_tree[2 * t] = 0;
        ((A.dyn_ltree[512] = 1), (A.opt_len = A.static_len = 0), (A.sym_next = A.matches = 0));
    },
    T = (A) => {
        (A.bi_valid > 8 ? Q(A, A.bi_buf) : A.bi_valid > 0 && (A.pending_buf[A.pending++] = A.bi_buf),
            (A.bi_buf = 0),
            (A.bi_valid = 0));
    },
    y = (A, t, e, i) => {
        const s = 2 * t,
            a = 2 * e;
        return A[s] < A[a] || (A[s] === A[a] && i[t] <= i[e]);
    },
    p = (A, t, e) => {
        const i = A.heap[e];
        let s = e << 1;
        for (
            ;
            s <= A.heap_len &&
            (s < A.heap_len && y(t, A.heap[s + 1], A.heap[s], A.depth) && s++, !y(t, i, A.heap[s], A.depth));
        )
            ((A.heap[e] = A.heap[s]), (e = s), (s <<= 1));
        A.heap[e] = i;
    },
    k = (A, t, i) => {
        let s,
            a,
            r,
            E,
            g = 0;
        if (0 !== A.sym_next)
            do {
                ((s = 255 & A.pending_buf[A.sym_buf + g++]),
                    (s += (255 & A.pending_buf[A.sym_buf + g++]) << 8),
                    (a = A.pending_buf[A.sym_buf + g++]),
                    0 === s
                        ? R(A, a, t)
                        : ((r = w[a]),
                          R(A, r + e + 1, t),
                          (E = n[r]),
                          0 !== E && ((a -= c[r]), S(A, a, E)),
                          s--,
                          (r = M(s)),
                          R(A, r, i),
                          (E = h[r]),
                          0 !== E && ((s -= I[r]), S(A, s, E))));
            } while (g < A.sym_next);
        R(A, 256, t);
    },
    H = (A, t) => {
        const e = t.dyn_tree,
            i = t.stat_desc.static_tree,
            s = t.stat_desc.has_stree,
            n = t.stat_desc.elems;
        let h,
            r,
            E,
            g = -1;
        for (A.heap_len = 0, A.heap_max = 573, h = 0; h < n; h++)
            0 !== e[2 * h] ? ((A.heap[++A.heap_len] = g = h), (A.depth[h] = 0)) : (e[2 * h + 1] = 0);
        for (; A.heap_len < 2; )
            ((E = A.heap[++A.heap_len] = g < 2 ? ++g : 0),
                (e[2 * E] = 1),
                (A.depth[E] = 0),
                A.opt_len--,
                s && (A.static_len -= i[2 * E + 1]));
        for (t.max_code = g, h = A.heap_len >> 1; h >= 1; h--) p(A, e, h);
        E = n;
        do {
            ((h = A.heap[1]),
                (A.heap[1] = A.heap[A.heap_len--]),
                p(A, e, 1),
                (r = A.heap[1]),
                (A.heap[--A.heap_max] = h),
                (A.heap[--A.heap_max] = r),
                (e[2 * E] = e[2 * h] + e[2 * r]),
                (A.depth[E] = (A.depth[h] >= A.depth[r] ? A.depth[h] : A.depth[r]) + 1),
                (e[2 * h + 1] = e[2 * r + 1] = E),
                (A.heap[1] = E++),
                p(A, e, 1));
        } while (A.heap_len >= 2);
        ((A.heap[--A.heap_max] = A.heap[1]),
            ((A, t) => {
                const e = t.dyn_tree,
                    i = t.max_code,
                    s = t.stat_desc.static_tree,
                    n = t.stat_desc.has_stree,
                    h = t.stat_desc.extra_bits,
                    r = t.stat_desc.extra_base,
                    E = t.stat_desc.max_length;
                let g,
                    o,
                    B,
                    w,
                    c,
                    I,
                    C = 0;
                for (w = 0; w <= a; w++) A.bl_count[w] = 0;
                for (e[2 * A.heap[A.heap_max] + 1] = 0, g = A.heap_max + 1; g < 573; g++)
                    ((o = A.heap[g]),
                        (w = e[2 * e[2 * o + 1] + 1] + 1),
                        w > E && ((w = E), C++),
                        (e[2 * o + 1] = w),
                        o > i ||
                            (A.bl_count[w]++,
                            (c = 0),
                            o >= r && (c = h[o - r]),
                            (I = e[2 * o]),
                            (A.opt_len += I * (w + c)),
                            n && (A.static_len += I * (s[2 * o + 1] + c))));
                if (0 !== C) {
                    do {
                        for (w = E - 1; 0 === A.bl_count[w]; ) w--;
                        (A.bl_count[w]--, (A.bl_count[w + 1] += 2), A.bl_count[E]--, (C -= 2));
                    } while (C > 0);
                    for (w = E; 0 !== w; w--)
                        for (o = A.bl_count[w]; 0 !== o; )
                            ((B = A.heap[--g]),
                                B > i ||
                                    (e[2 * B + 1] !== w &&
                                        ((A.opt_len += (w - e[2 * B + 1]) * e[2 * B]), (e[2 * B + 1] = w)),
                                    o--));
                }
            })(A, t),
            F(e, g, A.bl_count));
    },
    P = (A, t, e) => {
        let i,
            s,
            a = -1,
            n = t[1],
            h = 0,
            r = 7,
            E = 4;
        for (0 === n && ((r = 138), (E = 3)), t[2 * (e + 1) + 1] = 65535, i = 0; i <= e; i++)
            ((s = n),
                (n = t[2 * (i + 1) + 1]),
                (++h < r && s === n) ||
                    (h < E
                        ? (A.bl_tree[2 * s] += h)
                        : 0 !== s
                          ? (s !== a && A.bl_tree[2 * s]++, A.bl_tree[32]++)
                          : h <= 10
                            ? A.bl_tree[34]++
                            : A.bl_tree[36]++,
                    (h = 0),
                    (a = s),
                    0 === n ? ((r = 138), (E = 3)) : s === n ? ((r = 6), (E = 3)) : ((r = 7), (E = 4))));
    },
    m = (A, t, e) => {
        let i,
            s,
            a = -1,
            n = t[1],
            h = 0,
            r = 7,
            E = 4;
        for (0 === n && ((r = 138), (E = 3)), i = 0; i <= e; i++)
            if (((s = n), (n = t[2 * (i + 1) + 1]), !(++h < r && s === n))) {
                if (h < E)
                    do {
                        R(A, s, A.bl_tree);
                    } while (0 != --h);
                else
                    0 !== s
                        ? (s !== a && (R(A, s, A.bl_tree), h--), R(A, 16, A.bl_tree), S(A, h - 3, 2))
                        : h <= 10
                          ? (R(A, 17, A.bl_tree), S(A, h - 3, 3))
                          : (R(A, 18, A.bl_tree), S(A, h - 11, 7));
                ((h = 0), (a = s), 0 === n ? ((r = 138), (E = 3)) : s === n ? ((r = 6), (E = 3)) : ((r = 7), (E = 4)));
            }
    };
let O = !1;
const G = (A, t, e, i) => {
    (S(A, 0 + (i ? 1 : 0), 3),
        T(A),
        Q(A, e),
        Q(A, ~e),
        e && A.pending_buf.set(A.window.subarray(t, t + e), A.pending),
        (A.pending += e));
};
var U = (A, t, i, s) => {
        let a,
            n,
            h = 0;
        (A.level > 0
            ? (2 === A.strm.data_type &&
                  (A.strm.data_type = ((A) => {
                      let t,
                          i = 4093624447;
                      for (t = 0; t <= 31; t++, i >>>= 1) if (1 & i && 0 !== A.dyn_ltree[2 * t]) return 0;
                      if (0 !== A.dyn_ltree[18] || 0 !== A.dyn_ltree[20] || 0 !== A.dyn_ltree[26]) return 1;
                      for (t = 32; t < e; t++) if (0 !== A.dyn_ltree[2 * t]) return 1;
                      return 0;
                  })(A)),
              H(A, A.l_desc),
              H(A, A.d_desc),
              (h = ((A) => {
                  let t;
                  for (
                      P(A, A.dyn_ltree, A.l_desc.max_code),
                          P(A, A.dyn_dtree, A.d_desc.max_code),
                          H(A, A.bl_desc),
                          t = 18;
                      t >= 3 && 0 === A.bl_tree[2 * E[t] + 1];
                      t--
                  );
                  return ((A.opt_len += 3 * (t + 1) + 5 + 5 + 4), t);
              })(A)),
              (a = (A.opt_len + 3 + 7) >>> 3),
              (n = (A.static_len + 3 + 7) >>> 3),
              n <= a && (a = n))
            : (a = n = i + 5),
            i + 4 <= a && -1 !== t
                ? G(A, t, i, s)
                : 4 === A.strategy || n === a
                  ? (S(A, 2 + (s ? 1 : 0), 3), k(A, g, o))
                  : (S(A, 4 + (s ? 1 : 0), 3),
                    ((A, t, e, i) => {
                        let s;
                        for (S(A, t - 257, 5), S(A, e - 1, 5), S(A, i - 4, 4), s = 0; s < i; s++)
                            S(A, A.bl_tree[2 * E[s] + 1], 3);
                        (m(A, A.dyn_ltree, t - 1), m(A, A.dyn_dtree, e - 1));
                    })(A, A.l_desc.max_code + 1, A.d_desc.max_code + 1, h + 1),
                    k(A, A.dyn_ltree, A.dyn_dtree)),
            u(A),
            s && T(A));
    },
    b = {
        _tr_init: (A) => {
            (O ||
                ((() => {
                    let A, t, e, E, D;
                    const M = new Array(16);
                    for (e = 0, E = 0; E < 28; E++) for (c[E] = e, A = 0; A < 1 << n[E]; A++) w[e++] = E;
                    for (w[e - 1] = E, D = 0, E = 0; E < 16; E++) for (I[E] = D, A = 0; A < 1 << h[E]; A++) B[D++] = E;
                    for (D >>= 7; E < s; E++) for (I[E] = D << 7, A = 0; A < 1 << (h[E] - 7); A++) B[256 + D++] = E;
                    for (t = 0; t <= a; t++) M[t] = 0;
                    for (A = 0; A <= 143; ) ((g[2 * A + 1] = 8), A++, M[8]++);
                    for (; A <= 255; ) ((g[2 * A + 1] = 9), A++, M[9]++);
                    for (; A <= 279; ) ((g[2 * A + 1] = 7), A++, M[7]++);
                    for (; A <= 287; ) ((g[2 * A + 1] = 8), A++, M[8]++);
                    for (F(g, 287, M), A = 0; A < s; A++) ((o[2 * A + 1] = 5), (o[2 * A] = f(A, 5)));
                    ((l = new C(g, n, 257, i, a)), (_ = new C(o, h, 0, s, a)), (d = new C(new Array(0), r, 0, 19, 7)));
                })(),
                (O = !0)),
                (A.l_desc = new D(A.dyn_ltree, l)),
                (A.d_desc = new D(A.dyn_dtree, _)),
                (A.bl_desc = new D(A.bl_tree, d)),
                (A.bi_buf = 0),
                (A.bi_valid = 0),
                u(A));
        },
        _tr_stored_block: G,
        _tr_flush_block: U,
        _tr_tally: (A, t, i) => (
            (A.pending_buf[A.sym_buf + A.sym_next++] = t),
            (A.pending_buf[A.sym_buf + A.sym_next++] = t >> 8),
            (A.pending_buf[A.sym_buf + A.sym_next++] = i),
            0 === t
                ? A.dyn_ltree[2 * i]++
                : (A.matches++, t--, A.dyn_ltree[2 * (w[i] + e + 1)]++, A.dyn_dtree[2 * M(t)]++),
            A.sym_next === A.sym_end
        ),
        _tr_align: (A) => {
            (S(A, 2, 3),
                R(A, 256, g),
                ((A) => {
                    16 === A.bi_valid
                        ? (Q(A, A.bi_buf), (A.bi_buf = 0), (A.bi_valid = 0))
                        : A.bi_valid >= 8 &&
                          ((A.pending_buf[A.pending++] = 255 & A.bi_buf), (A.bi_buf >>= 8), (A.bi_valid -= 8));
                })(A));
        },
    };
var Y = (A, t, e, i) => {
    let s = (65535 & A) | 0,
        a = ((A >>> 16) & 65535) | 0,
        n = 0;
    for (; 0 !== e; ) {
        ((n = e > 2e3 ? 2e3 : e), (e -= n));
        do {
            ((s = (s + t[i++]) | 0), (a = (a + s) | 0));
        } while (--n);
        ((s %= 65521), (a %= 65521));
    }
    return s | (a << 16) | 0;
};
const K = new Uint32Array(
    (() => {
        let A,
            t = [];
        for (var e = 0; e < 256; e++) {
            A = e;
            for (var i = 0; i < 8; i++) A = 1 & A ? 3988292384 ^ (A >>> 1) : A >>> 1;
            t[e] = A;
        }
        return t;
    })()
);
var x = (A, t, e, i) => {
        const s = K,
            a = i + e;
        A ^= -1;
        for (let e = i; e < a; e++) A = (A >>> 8) ^ s[255 & (A ^ t[e])];
        return -1 ^ A;
    },
    L = {
        2: "need dictionary",
        1: "stream end",
        0: "",
        "-1": "file error",
        "-2": "stream error",
        "-3": "data error",
        "-4": "insufficient memory",
        "-5": "buffer error",
        "-6": "incompatible version",
    },
    J = {
        Z_NO_FLUSH: 0,
        Z_PARTIAL_FLUSH: 1,
        Z_SYNC_FLUSH: 2,
        Z_FULL_FLUSH: 3,
        Z_FINISH: 4,
        Z_BLOCK: 5,
        Z_TREES: 6,
        Z_OK: 0,
        Z_STREAM_END: 1,
        Z_NEED_DICT: 2,
        Z_ERRNO: -1,
        Z_STREAM_ERROR: -2,
        Z_DATA_ERROR: -3,
        Z_MEM_ERROR: -4,
        Z_BUF_ERROR: -5,
        Z_NO_COMPRESSION: 0,
        Z_BEST_SPEED: 1,
        Z_BEST_COMPRESSION: 9,
        Z_DEFAULT_COMPRESSION: -1,
        Z_FILTERED: 1,
        Z_HUFFMAN_ONLY: 2,
        Z_RLE: 3,
        Z_FIXED: 4,
        Z_DEFAULT_STRATEGY: 0,
        Z_BINARY: 0,
        Z_TEXT: 1,
        Z_UNKNOWN: 2,
        Z_DEFLATED: 8,
    };
const { _tr_init: z, _tr_stored_block: v, _tr_flush_block: N, _tr_tally: Z, _tr_align: j } = b,
    {
        Z_NO_FLUSH: W,
        Z_PARTIAL_FLUSH: q,
        Z_FULL_FLUSH: X,
        Z_FINISH: V,
        Z_BLOCK: $,
        Z_OK: AA,
        Z_STREAM_END: tA,
        Z_STREAM_ERROR: eA,
        Z_DATA_ERROR: iA,
        Z_BUF_ERROR: sA,
        Z_DEFAULT_COMPRESSION: aA,
        Z_FILTERED: nA,
        Z_HUFFMAN_ONLY: hA,
        Z_RLE: rA,
        Z_FIXED: EA,
        Z_DEFAULT_STRATEGY: gA,
        Z_UNKNOWN: oA,
        Z_DEFLATED: BA,
    } = J,
    wA = 258,
    cA = 262,
    IA = 42,
    CA = 113,
    lA = 666,
    _A = (A, t) => ((A.msg = L[t]), t),
    dA = (A) => 2 * A - (A > 4 ? 9 : 0),
    DA = (A) => {
        let t = A.length;
        for (; --t >= 0; ) A[t] = 0;
    },
    MA = (A) => {
        let t,
            e,
            i,
            s = A.w_size;
        ((t = A.hash_size), (i = t));
        do {
            ((e = A.head[--i]), (A.head[i] = e >= s ? e - s : 0));
        } while (--t);
        ((t = s), (i = t));
        do {
            ((e = A.prev[--i]), (A.prev[i] = e >= s ? e - s : 0));
        } while (--t);
    };
let QA = (A, t, e) => ((t << A.hash_shift) ^ e) & A.hash_mask;
const SA = (A) => {
        const t = A.state;
        let e = t.pending;
        (e > A.avail_out && (e = A.avail_out),
            0 !== e &&
                (A.output.set(t.pending_buf.subarray(t.pending_out, t.pending_out + e), A.next_out),
                (A.next_out += e),
                (t.pending_out += e),
                (A.total_out += e),
                (A.avail_out -= e),
                (t.pending -= e),
                0 === t.pending && (t.pending_out = 0)));
    },
    RA = (A, t) => {
        (N(A, A.block_start >= 0 ? A.block_start : -1, A.strstart - A.block_start, t),
            (A.block_start = A.strstart),
            SA(A.strm));
    },
    fA = (A, t) => {
        A.pending_buf[A.pending++] = t;
    },
    FA = (A, t) => {
        ((A.pending_buf[A.pending++] = (t >>> 8) & 255), (A.pending_buf[A.pending++] = 255 & t));
    },
    uA = (A, t, e, i) => {
        let s = A.avail_in;
        return (
            s > i && (s = i),
            0 === s
                ? 0
                : ((A.avail_in -= s),
                  t.set(A.input.subarray(A.next_in, A.next_in + s), e),
                  1 === A.state.wrap
                      ? (A.adler = Y(A.adler, t, s, e))
                      : 2 === A.state.wrap && (A.adler = x(A.adler, t, s, e)),
                  (A.next_in += s),
                  (A.total_in += s),
                  s)
        );
    },
    TA = (A, t) => {
        let e,
            i,
            s = A.max_chain_length,
            a = A.strstart,
            n = A.prev_length,
            h = A.nice_match;
        const r = A.strstart > A.w_size - cA ? A.strstart - (A.w_size - cA) : 0,
            E = A.window,
            g = A.w_mask,
            o = A.prev,
            B = A.strstart + wA;
        let w = E[a + n - 1],
            c = E[a + n];
        (A.prev_length >= A.good_match && (s >>= 2), h > A.lookahead && (h = A.lookahead));
        do {
            if (((e = t), E[e + n] === c && E[e + n - 1] === w && E[e] === E[a] && E[++e] === E[a + 1])) {
                ((a += 2), e++);
                do {} while (
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    E[++a] === E[++e] &&
                    a < B
                );
                if (((i = wA - (B - a)), (a = B - wA), i > n)) {
                    if (((A.match_start = t), (n = i), i >= h)) break;
                    ((w = E[a + n - 1]), (c = E[a + n]));
                }
            }
        } while ((t = o[t & g]) > r && 0 != --s);
        return n <= A.lookahead ? n : A.lookahead;
    },
    yA = (A) => {
        const t = A.w_size;
        let e, i, s;
        do {
            if (
                ((i = A.window_size - A.lookahead - A.strstart),
                A.strstart >= t + (t - cA) &&
                    (A.window.set(A.window.subarray(t, t + t - i), 0),
                    (A.match_start -= t),
                    (A.strstart -= t),
                    (A.block_start -= t),
                    A.insert > A.strstart && (A.insert = A.strstart),
                    MA(A),
                    (i += t)),
                0 === A.strm.avail_in)
            )
                break;
            if (
                ((e = uA(A.strm, A.window, A.strstart + A.lookahead, i)),
                (A.lookahead += e),
                A.lookahead + A.insert >= 3)
            )
                for (
                    s = A.strstart - A.insert, A.ins_h = A.window[s], A.ins_h = QA(A, A.ins_h, A.window[s + 1]);
                    A.insert &&
                    ((A.ins_h = QA(A, A.ins_h, A.window[s + 3 - 1])),
                    (A.prev[s & A.w_mask] = A.head[A.ins_h]),
                    (A.head[A.ins_h] = s),
                    s++,
                    A.insert--,
                    !(A.lookahead + A.insert < 3));
                );
        } while (A.lookahead < cA && 0 !== A.strm.avail_in);
    },
    pA = (A, t) => {
        let e,
            i,
            s,
            a = A.pending_buf_size - 5 > A.w_size ? A.w_size : A.pending_buf_size - 5,
            n = 0,
            h = A.strm.avail_in;
        do {
            if (((e = 65535), (s = (A.bi_valid + 42) >> 3), A.strm.avail_out < s)) break;
            if (
                ((s = A.strm.avail_out - s),
                (i = A.strstart - A.block_start),
                e > i + A.strm.avail_in && (e = i + A.strm.avail_in),
                e > s && (e = s),
                e < a && ((0 === e && t !== V) || t === W || e !== i + A.strm.avail_in))
            )
                break;
            ((n = t === V && e === i + A.strm.avail_in ? 1 : 0),
                v(A, 0, 0, n),
                (A.pending_buf[A.pending - 4] = e),
                (A.pending_buf[A.pending - 3] = e >> 8),
                (A.pending_buf[A.pending - 2] = ~e),
                (A.pending_buf[A.pending - 1] = ~e >> 8),
                SA(A.strm),
                i &&
                    (i > e && (i = e),
                    A.strm.output.set(A.window.subarray(A.block_start, A.block_start + i), A.strm.next_out),
                    (A.strm.next_out += i),
                    (A.strm.avail_out -= i),
                    (A.strm.total_out += i),
                    (A.block_start += i),
                    (e -= i)),
                e &&
                    (uA(A.strm, A.strm.output, A.strm.next_out, e),
                    (A.strm.next_out += e),
                    (A.strm.avail_out -= e),
                    (A.strm.total_out += e)));
        } while (0 === n);
        return (
            (h -= A.strm.avail_in),
            h &&
                (h >= A.w_size
                    ? ((A.matches = 2),
                      A.window.set(A.strm.input.subarray(A.strm.next_in - A.w_size, A.strm.next_in), 0),
                      (A.strstart = A.w_size),
                      (A.insert = A.strstart))
                    : (A.window_size - A.strstart <= h &&
                          ((A.strstart -= A.w_size),
                          A.window.set(A.window.subarray(A.w_size, A.w_size + A.strstart), 0),
                          A.matches < 2 && A.matches++,
                          A.insert > A.strstart && (A.insert = A.strstart)),
                      A.window.set(A.strm.input.subarray(A.strm.next_in - h, A.strm.next_in), A.strstart),
                      (A.strstart += h),
                      (A.insert += h > A.w_size - A.insert ? A.w_size - A.insert : h)),
                (A.block_start = A.strstart)),
            A.high_water < A.strstart && (A.high_water = A.strstart),
            n
                ? 4
                : t !== W && t !== V && 0 === A.strm.avail_in && A.strstart === A.block_start
                  ? 2
                  : ((s = A.window_size - A.strstart),
                    A.strm.avail_in > s &&
                        A.block_start >= A.w_size &&
                        ((A.block_start -= A.w_size),
                        (A.strstart -= A.w_size),
                        A.window.set(A.window.subarray(A.w_size, A.w_size + A.strstart), 0),
                        A.matches < 2 && A.matches++,
                        (s += A.w_size),
                        A.insert > A.strstart && (A.insert = A.strstart)),
                    s > A.strm.avail_in && (s = A.strm.avail_in),
                    s &&
                        (uA(A.strm, A.window, A.strstart, s),
                        (A.strstart += s),
                        (A.insert += s > A.w_size - A.insert ? A.w_size - A.insert : s)),
                    A.high_water < A.strstart && (A.high_water = A.strstart),
                    (s = (A.bi_valid + 42) >> 3),
                    (s = A.pending_buf_size - s > 65535 ? 65535 : A.pending_buf_size - s),
                    (a = s > A.w_size ? A.w_size : s),
                    (i = A.strstart - A.block_start),
                    (i >= a || ((i || t === V) && t !== W && 0 === A.strm.avail_in && i <= s)) &&
                        ((e = i > s ? s : i),
                        (n = t === V && 0 === A.strm.avail_in && e === i ? 1 : 0),
                        v(A, A.block_start, e, n),
                        (A.block_start += e),
                        SA(A.strm)),
                    n ? 3 : 1)
        );
    },
    kA = (A, t) => {
        let e, i;
        for (;;) {
            if (A.lookahead < cA) {
                if ((yA(A), A.lookahead < cA && t === W)) return 1;
                if (0 === A.lookahead) break;
            }
            if (
                ((e = 0),
                A.lookahead >= 3 &&
                    ((A.ins_h = QA(A, A.ins_h, A.window[A.strstart + 3 - 1])),
                    (e = A.prev[A.strstart & A.w_mask] = A.head[A.ins_h]),
                    (A.head[A.ins_h] = A.strstart)),
                0 !== e && A.strstart - e <= A.w_size - cA && (A.match_length = TA(A, e)),
                A.match_length >= 3)
            )
                if (
                    ((i = Z(A, A.strstart - A.match_start, A.match_length - 3)),
                    (A.lookahead -= A.match_length),
                    A.match_length <= A.max_lazy_match && A.lookahead >= 3)
                ) {
                    A.match_length--;
                    do {
                        (A.strstart++,
                            (A.ins_h = QA(A, A.ins_h, A.window[A.strstart + 3 - 1])),
                            (e = A.prev[A.strstart & A.w_mask] = A.head[A.ins_h]),
                            (A.head[A.ins_h] = A.strstart));
                    } while (0 != --A.match_length);
                    A.strstart++;
                } else
                    ((A.strstart += A.match_length),
                        (A.match_length = 0),
                        (A.ins_h = A.window[A.strstart]),
                        (A.ins_h = QA(A, A.ins_h, A.window[A.strstart + 1])));
            else ((i = Z(A, 0, A.window[A.strstart])), A.lookahead--, A.strstart++);
            if (i && (RA(A, !1), 0 === A.strm.avail_out)) return 1;
        }
        return (
            (A.insert = A.strstart < 2 ? A.strstart : 2),
            t === V
                ? (RA(A, !0), 0 === A.strm.avail_out ? 3 : 4)
                : A.sym_next && (RA(A, !1), 0 === A.strm.avail_out)
                  ? 1
                  : 2
        );
    },
    HA = (A, t) => {
        let e, i, s;
        for (;;) {
            if (A.lookahead < cA) {
                if ((yA(A), A.lookahead < cA && t === W)) return 1;
                if (0 === A.lookahead) break;
            }
            if (
                ((e = 0),
                A.lookahead >= 3 &&
                    ((A.ins_h = QA(A, A.ins_h, A.window[A.strstart + 3 - 1])),
                    (e = A.prev[A.strstart & A.w_mask] = A.head[A.ins_h]),
                    (A.head[A.ins_h] = A.strstart)),
                (A.prev_length = A.match_length),
                (A.prev_match = A.match_start),
                (A.match_length = 2),
                0 !== e &&
                    A.prev_length < A.max_lazy_match &&
                    A.strstart - e <= A.w_size - cA &&
                    ((A.match_length = TA(A, e)),
                    A.match_length <= 5 &&
                        (A.strategy === nA || (3 === A.match_length && A.strstart - A.match_start > 4096)) &&
                        (A.match_length = 2)),
                A.prev_length >= 3 && A.match_length <= A.prev_length)
            ) {
                ((s = A.strstart + A.lookahead - 3),
                    (i = Z(A, A.strstart - 1 - A.prev_match, A.prev_length - 3)),
                    (A.lookahead -= A.prev_length - 1),
                    (A.prev_length -= 2));
                do {
                    ++A.strstart <= s &&
                        ((A.ins_h = QA(A, A.ins_h, A.window[A.strstart + 3 - 1])),
                        (e = A.prev[A.strstart & A.w_mask] = A.head[A.ins_h]),
                        (A.head[A.ins_h] = A.strstart));
                } while (0 != --A.prev_length);
                if (
                    ((A.match_available = 0),
                    (A.match_length = 2),
                    A.strstart++,
                    i && (RA(A, !1), 0 === A.strm.avail_out))
                )
                    return 1;
            } else if (A.match_available) {
                if (
                    ((i = Z(A, 0, A.window[A.strstart - 1])),
                    i && RA(A, !1),
                    A.strstart++,
                    A.lookahead--,
                    0 === A.strm.avail_out)
                )
                    return 1;
            } else ((A.match_available = 1), A.strstart++, A.lookahead--);
        }
        return (
            A.match_available && ((i = Z(A, 0, A.window[A.strstart - 1])), (A.match_available = 0)),
            (A.insert = A.strstart < 2 ? A.strstart : 2),
            t === V
                ? (RA(A, !0), 0 === A.strm.avail_out ? 3 : 4)
                : A.sym_next && (RA(A, !1), 0 === A.strm.avail_out)
                  ? 1
                  : 2
        );
    };
function PA(A, t, e, i, s) {
    ((this.good_length = A), (this.max_lazy = t), (this.nice_length = e), (this.max_chain = i), (this.func = s));
}
const mA = [
    new PA(0, 0, 0, 0, pA),
    new PA(4, 4, 8, 4, kA),
    new PA(4, 5, 16, 8, kA),
    new PA(4, 6, 32, 32, kA),
    new PA(4, 4, 16, 16, HA),
    new PA(8, 16, 32, 32, HA),
    new PA(8, 16, 128, 128, HA),
    new PA(8, 32, 128, 256, HA),
    new PA(32, 128, 258, 1024, HA),
    new PA(32, 258, 258, 4096, HA),
];
function OA() {
    ((this.strm = null),
        (this.status = 0),
        (this.pending_buf = null),
        (this.pending_buf_size = 0),
        (this.pending_out = 0),
        (this.pending = 0),
        (this.wrap = 0),
        (this.gzhead = null),
        (this.gzindex = 0),
        (this.method = BA),
        (this.last_flush = -1),
        (this.w_size = 0),
        (this.w_bits = 0),
        (this.w_mask = 0),
        (this.window = null),
        (this.window_size = 0),
        (this.prev = null),
        (this.head = null),
        (this.ins_h = 0),
        (this.hash_size = 0),
        (this.hash_bits = 0),
        (this.hash_mask = 0),
        (this.hash_shift = 0),
        (this.block_start = 0),
        (this.match_length = 0),
        (this.prev_match = 0),
        (this.match_available = 0),
        (this.strstart = 0),
        (this.match_start = 0),
        (this.lookahead = 0),
        (this.prev_length = 0),
        (this.max_chain_length = 0),
        (this.max_lazy_match = 0),
        (this.level = 0),
        (this.strategy = 0),
        (this.good_match = 0),
        (this.nice_match = 0),
        (this.dyn_ltree = new Uint16Array(1146)),
        (this.dyn_dtree = new Uint16Array(122)),
        (this.bl_tree = new Uint16Array(78)),
        DA(this.dyn_ltree),
        DA(this.dyn_dtree),
        DA(this.bl_tree),
        (this.l_desc = null),
        (this.d_desc = null),
        (this.bl_desc = null),
        (this.bl_count = new Uint16Array(16)),
        (this.heap = new Uint16Array(573)),
        DA(this.heap),
        (this.heap_len = 0),
        (this.heap_max = 0),
        (this.depth = new Uint16Array(573)),
        DA(this.depth),
        (this.sym_buf = 0),
        (this.lit_bufsize = 0),
        (this.sym_next = 0),
        (this.sym_end = 0),
        (this.opt_len = 0),
        (this.static_len = 0),
        (this.matches = 0),
        (this.insert = 0),
        (this.bi_buf = 0),
        (this.bi_valid = 0));
}
const GA = (A) => {
        if (!A) return 1;
        const t = A.state;
        return !t ||
            t.strm !== A ||
            (t.status !== IA &&
                57 !== t.status &&
                69 !== t.status &&
                73 !== t.status &&
                91 !== t.status &&
                103 !== t.status &&
                t.status !== CA &&
                t.status !== lA)
            ? 1
            : 0;
    },
    UA = (A) => {
        if (GA(A)) return _A(A, eA);
        ((A.total_in = A.total_out = 0), (A.data_type = oA));
        const t = A.state;
        return (
            (t.pending = 0),
            (t.pending_out = 0),
            t.wrap < 0 && (t.wrap = -t.wrap),
            (t.status = 2 === t.wrap ? 57 : t.wrap ? IA : CA),
            (A.adler = 2 === t.wrap ? 0 : 1),
            (t.last_flush = -2),
            z(t),
            AA
        );
    },
    bA = (A) => {
        const t = UA(A);
        var e;
        return (
            t === AA &&
                (((e = A.state).window_size = 2 * e.w_size),
                DA(e.head),
                (e.max_lazy_match = mA[e.level].max_lazy),
                (e.good_match = mA[e.level].good_length),
                (e.nice_match = mA[e.level].nice_length),
                (e.max_chain_length = mA[e.level].max_chain),
                (e.strstart = 0),
                (e.block_start = 0),
                (e.lookahead = 0),
                (e.insert = 0),
                (e.match_length = e.prev_length = 2),
                (e.match_available = 0),
                (e.ins_h = 0)),
            t
        );
    },
    YA = (A, t, e, i, s, a) => {
        if (!A) return eA;
        let n = 1;
        if (
            (t === aA && (t = 6),
            i < 0 ? ((n = 0), (i = -i)) : i > 15 && ((n = 2), (i -= 16)),
            s < 1 || s > 9 || e !== BA || i < 8 || i > 15 || t < 0 || t > 9 || a < 0 || a > EA || (8 === i && 1 !== n))
        )
            return _A(A, eA);
        8 === i && (i = 9);
        const h = new OA();
        return (
            (A.state = h),
            (h.strm = A),
            (h.status = IA),
            (h.wrap = n),
            (h.gzhead = null),
            (h.w_bits = i),
            (h.w_size = 1 << h.w_bits),
            (h.w_mask = h.w_size - 1),
            (h.hash_bits = s + 7),
            (h.hash_size = 1 << h.hash_bits),
            (h.hash_mask = h.hash_size - 1),
            (h.hash_shift = ~~((h.hash_bits + 3 - 1) / 3)),
            (h.window = new Uint8Array(2 * h.w_size)),
            (h.head = new Uint16Array(h.hash_size)),
            (h.prev = new Uint16Array(h.w_size)),
            (h.lit_bufsize = 1 << (s + 6)),
            (h.pending_buf_size = 4 * h.lit_bufsize),
            (h.pending_buf = new Uint8Array(h.pending_buf_size)),
            (h.sym_buf = h.lit_bufsize),
            (h.sym_end = 3 * (h.lit_bufsize - 1)),
            (h.level = t),
            (h.strategy = a),
            (h.method = e),
            bA(A)
        );
    };
var KA = {
    deflateInit: (A, t) => YA(A, t, BA, 15, 8, gA),
    deflateInit2: YA,
    deflateReset: bA,
    deflateResetKeep: UA,
    deflateSetHeader: (A, t) => (GA(A) || 2 !== A.state.wrap ? eA : ((A.state.gzhead = t), AA)),
    deflate: (A, t) => {
        if (GA(A) || t > $ || t < 0) return A ? _A(A, eA) : eA;
        const e = A.state;
        if (!A.output || (0 !== A.avail_in && !A.input) || (e.status === lA && t !== V))
            return _A(A, 0 === A.avail_out ? sA : eA);
        const i = e.last_flush;
        if (((e.last_flush = t), 0 !== e.pending)) {
            if ((SA(A), 0 === A.avail_out)) return ((e.last_flush = -1), AA);
        } else if (0 === A.avail_in && dA(t) <= dA(i) && t !== V) return _A(A, sA);
        if (e.status === lA && 0 !== A.avail_in) return _A(A, sA);
        if ((e.status === IA && 0 === e.wrap && (e.status = CA), e.status === IA)) {
            let t = (BA + ((e.w_bits - 8) << 4)) << 8,
                i = -1;
            if (
                ((i = e.strategy >= hA || e.level < 2 ? 0 : e.level < 6 ? 1 : 6 === e.level ? 2 : 3),
                (t |= i << 6),
                0 !== e.strstart && (t |= 32),
                (t += 31 - (t % 31)),
                FA(e, t),
                0 !== e.strstart && (FA(e, A.adler >>> 16), FA(e, 65535 & A.adler)),
                (A.adler = 1),
                (e.status = CA),
                SA(A),
                0 !== e.pending)
            )
                return ((e.last_flush = -1), AA);
        }
        if (57 === e.status)
            if (((A.adler = 0), fA(e, 31), fA(e, 139), fA(e, 8), e.gzhead))
                (fA(
                    e,
                    (e.gzhead.text ? 1 : 0) +
                        (e.gzhead.hcrc ? 2 : 0) +
                        (e.gzhead.extra ? 4 : 0) +
                        (e.gzhead.name ? 8 : 0) +
                        (e.gzhead.comment ? 16 : 0)
                ),
                    fA(e, 255 & e.gzhead.time),
                    fA(e, (e.gzhead.time >> 8) & 255),
                    fA(e, (e.gzhead.time >> 16) & 255),
                    fA(e, (e.gzhead.time >> 24) & 255),
                    fA(e, 9 === e.level ? 2 : e.strategy >= hA || e.level < 2 ? 4 : 0),
                    fA(e, 255 & e.gzhead.os),
                    e.gzhead.extra &&
                        e.gzhead.extra.length &&
                        (fA(e, 255 & e.gzhead.extra.length), fA(e, (e.gzhead.extra.length >> 8) & 255)),
                    e.gzhead.hcrc && (A.adler = x(A.adler, e.pending_buf, e.pending, 0)),
                    (e.gzindex = 0),
                    (e.status = 69));
            else if (
                (fA(e, 0),
                fA(e, 0),
                fA(e, 0),
                fA(e, 0),
                fA(e, 0),
                fA(e, 9 === e.level ? 2 : e.strategy >= hA || e.level < 2 ? 4 : 0),
                fA(e, 3),
                (e.status = CA),
                SA(A),
                0 !== e.pending)
            )
                return ((e.last_flush = -1), AA);
        if (69 === e.status) {
            if (e.gzhead.extra) {
                let t = e.pending,
                    i = (65535 & e.gzhead.extra.length) - e.gzindex;
                for (; e.pending + i > e.pending_buf_size; ) {
                    let s = e.pending_buf_size - e.pending;
                    if (
                        (e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex, e.gzindex + s), e.pending),
                        (e.pending = e.pending_buf_size),
                        e.gzhead.hcrc && e.pending > t && (A.adler = x(A.adler, e.pending_buf, e.pending - t, t)),
                        (e.gzindex += s),
                        SA(A),
                        0 !== e.pending)
                    )
                        return ((e.last_flush = -1), AA);
                    ((t = 0), (i -= s));
                }
                let s = new Uint8Array(e.gzhead.extra);
                (e.pending_buf.set(s.subarray(e.gzindex, e.gzindex + i), e.pending),
                    (e.pending += i),
                    e.gzhead.hcrc && e.pending > t && (A.adler = x(A.adler, e.pending_buf, e.pending - t, t)),
                    (e.gzindex = 0));
            }
            e.status = 73;
        }
        if (73 === e.status) {
            if (e.gzhead.name) {
                let t,
                    i = e.pending;
                do {
                    if (e.pending === e.pending_buf_size) {
                        if (
                            (e.gzhead.hcrc && e.pending > i && (A.adler = x(A.adler, e.pending_buf, e.pending - i, i)),
                            SA(A),
                            0 !== e.pending)
                        )
                            return ((e.last_flush = -1), AA);
                        i = 0;
                    }
                    ((t = e.gzindex < e.gzhead.name.length ? 255 & e.gzhead.name.charCodeAt(e.gzindex++) : 0),
                        fA(e, t));
                } while (0 !== t);
                (e.gzhead.hcrc && e.pending > i && (A.adler = x(A.adler, e.pending_buf, e.pending - i, i)),
                    (e.gzindex = 0));
            }
            e.status = 91;
        }
        if (91 === e.status) {
            if (e.gzhead.comment) {
                let t,
                    i = e.pending;
                do {
                    if (e.pending === e.pending_buf_size) {
                        if (
                            (e.gzhead.hcrc && e.pending > i && (A.adler = x(A.adler, e.pending_buf, e.pending - i, i)),
                            SA(A),
                            0 !== e.pending)
                        )
                            return ((e.last_flush = -1), AA);
                        i = 0;
                    }
                    ((t = e.gzindex < e.gzhead.comment.length ? 255 & e.gzhead.comment.charCodeAt(e.gzindex++) : 0),
                        fA(e, t));
                } while (0 !== t);
                e.gzhead.hcrc && e.pending > i && (A.adler = x(A.adler, e.pending_buf, e.pending - i, i));
            }
            e.status = 103;
        }
        if (103 === e.status) {
            if (e.gzhead.hcrc) {
                if (e.pending + 2 > e.pending_buf_size && (SA(A), 0 !== e.pending)) return ((e.last_flush = -1), AA);
                (fA(e, 255 & A.adler), fA(e, (A.adler >> 8) & 255), (A.adler = 0));
            }
            if (((e.status = CA), SA(A), 0 !== e.pending)) return ((e.last_flush = -1), AA);
        }
        if (0 !== A.avail_in || 0 !== e.lookahead || (t !== W && e.status !== lA)) {
            let i =
                0 === e.level
                    ? pA(e, t)
                    : e.strategy === hA
                      ? ((A, t) => {
                            let e;
                            for (;;) {
                                if (0 === A.lookahead && (yA(A), 0 === A.lookahead)) {
                                    if (t === W) return 1;
                                    break;
                                }
                                if (
                                    ((A.match_length = 0),
                                    (e = Z(A, 0, A.window[A.strstart])),
                                    A.lookahead--,
                                    A.strstart++,
                                    e && (RA(A, !1), 0 === A.strm.avail_out))
                                )
                                    return 1;
                            }
                            return (
                                (A.insert = 0),
                                t === V
                                    ? (RA(A, !0), 0 === A.strm.avail_out ? 3 : 4)
                                    : A.sym_next && (RA(A, !1), 0 === A.strm.avail_out)
                                      ? 1
                                      : 2
                            );
                        })(e, t)
                      : e.strategy === rA
                        ? ((A, t) => {
                              let e, i, s, a;
                              const n = A.window;
                              for (;;) {
                                  if (A.lookahead <= wA) {
                                      if ((yA(A), A.lookahead <= wA && t === W)) return 1;
                                      if (0 === A.lookahead) break;
                                  }
                                  if (
                                      ((A.match_length = 0),
                                      A.lookahead >= 3 &&
                                          A.strstart > 0 &&
                                          ((s = A.strstart - 1),
                                          (i = n[s]),
                                          i === n[++s] && i === n[++s] && i === n[++s]))
                                  ) {
                                      a = A.strstart + wA;
                                      do {} while (
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          i === n[++s] &&
                                          s < a
                                      );
                                      ((A.match_length = wA - (a - s)),
                                          A.match_length > A.lookahead && (A.match_length = A.lookahead));
                                  }
                                  if (
                                      (A.match_length >= 3
                                          ? ((e = Z(A, 1, A.match_length - 3)),
                                            (A.lookahead -= A.match_length),
                                            (A.strstart += A.match_length),
                                            (A.match_length = 0))
                                          : ((e = Z(A, 0, A.window[A.strstart])), A.lookahead--, A.strstart++),
                                      e && (RA(A, !1), 0 === A.strm.avail_out))
                                  )
                                      return 1;
                              }
                              return (
                                  (A.insert = 0),
                                  t === V
                                      ? (RA(A, !0), 0 === A.strm.avail_out ? 3 : 4)
                                      : A.sym_next && (RA(A, !1), 0 === A.strm.avail_out)
                                        ? 1
                                        : 2
                              );
                          })(e, t)
                        : mA[e.level].func(e, t);
            if (((3 !== i && 4 !== i) || (e.status = lA), 1 === i || 3 === i))
                return (0 === A.avail_out && (e.last_flush = -1), AA);
            if (
                2 === i &&
                (t === q
                    ? j(e)
                    : t !== $ &&
                      (v(e, 0, 0, !1),
                      t === X &&
                          (DA(e.head), 0 === e.lookahead && ((e.strstart = 0), (e.block_start = 0), (e.insert = 0)))),
                SA(A),
                0 === A.avail_out)
            )
                return ((e.last_flush = -1), AA);
        }
        return t !== V
            ? AA
            : e.wrap <= 0
              ? tA
              : (2 === e.wrap
                    ? (fA(e, 255 & A.adler),
                      fA(e, (A.adler >> 8) & 255),
                      fA(e, (A.adler >> 16) & 255),
                      fA(e, (A.adler >> 24) & 255),
                      fA(e, 255 & A.total_in),
                      fA(e, (A.total_in >> 8) & 255),
                      fA(e, (A.total_in >> 16) & 255),
                      fA(e, (A.total_in >> 24) & 255))
                    : (FA(e, A.adler >>> 16), FA(e, 65535 & A.adler)),
                SA(A),
                e.wrap > 0 && (e.wrap = -e.wrap),
                0 !== e.pending ? AA : tA);
    },
    deflateEnd: (A) => {
        if (GA(A)) return eA;
        const t = A.state.status;
        return ((A.state = null), t === CA ? _A(A, iA) : AA);
    },
    deflateSetDictionary: (A, t) => {
        let e = t.length;
        if (GA(A)) return eA;
        const i = A.state,
            s = i.wrap;
        if (2 === s || (1 === s && i.status !== IA) || i.lookahead) return eA;
        if ((1 === s && (A.adler = Y(A.adler, t, e, 0)), (i.wrap = 0), e >= i.w_size)) {
            0 === s && (DA(i.head), (i.strstart = 0), (i.block_start = 0), (i.insert = 0));
            let A = new Uint8Array(i.w_size);
            (A.set(t.subarray(e - i.w_size, e), 0), (t = A), (e = i.w_size));
        }
        const a = A.avail_in,
            n = A.next_in,
            h = A.input;
        for (A.avail_in = e, A.next_in = 0, A.input = t, yA(i); i.lookahead >= 3; ) {
            let A = i.strstart,
                t = i.lookahead - 2;
            do {
                ((i.ins_h = QA(i, i.ins_h, i.window[A + 3 - 1])),
                    (i.prev[A & i.w_mask] = i.head[i.ins_h]),
                    (i.head[i.ins_h] = A),
                    A++);
            } while (--t);
            ((i.strstart = A), (i.lookahead = 2), yA(i));
        }
        return (
            (i.strstart += i.lookahead),
            (i.block_start = i.strstart),
            (i.insert = i.lookahead),
            (i.lookahead = 0),
            (i.match_length = i.prev_length = 2),
            (i.match_available = 0),
            (A.next_in = n),
            (A.input = h),
            (A.avail_in = a),
            (i.wrap = s),
            AA
        );
    },
    deflateInfo: "pako deflate (from Nodeca project)",
};
const xA = (A, t) => Object.prototype.hasOwnProperty.call(A, t);
var LA = {
    assign: function (A) {
        const t = Array.prototype.slice.call(arguments, 1);
        for (; t.length; ) {
            const e = t.shift();
            if (e) {
                if ("object" != typeof e) throw new TypeError(e + "must be non-object");
                for (const t in e) xA(e, t) && (A[t] = e[t]);
            }
        }
        return A;
    },
    flattenChunks: (A) => {
        let t = 0;
        for (let e = 0, i = A.length; e < i; e++) t += A[e].length;
        const e = new Uint8Array(t);
        for (let t = 0, i = 0, s = A.length; t < s; t++) {
            let s = A[t];
            (e.set(s, i), (i += s.length));
        }
        return e;
    },
};
let JA = !0;
try {
    String.fromCharCode.apply(null, new Uint8Array(1));
} catch (A) {
    JA = !1;
}
const zA = new Uint8Array(256);
for (let A = 0; A < 256; A++) zA[A] = A >= 252 ? 6 : A >= 248 ? 5 : A >= 240 ? 4 : A >= 224 ? 3 : A >= 192 ? 2 : 1;
zA[254] = zA[254] = 1;
var vA = {
    string2buf: (A) => {
        if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(A);
        let t,
            e,
            i,
            s,
            a,
            n = A.length,
            h = 0;
        for (s = 0; s < n; s++)
            ((e = A.charCodeAt(s)),
                55296 == (64512 & e) &&
                    s + 1 < n &&
                    ((i = A.charCodeAt(s + 1)),
                    56320 == (64512 & i) && ((e = 65536 + ((e - 55296) << 10) + (i - 56320)), s++)),
                (h += e < 128 ? 1 : e < 2048 ? 2 : e < 65536 ? 3 : 4));
        for (t = new Uint8Array(h), a = 0, s = 0; a < h; s++)
            ((e = A.charCodeAt(s)),
                55296 == (64512 & e) &&
                    s + 1 < n &&
                    ((i = A.charCodeAt(s + 1)),
                    56320 == (64512 & i) && ((e = 65536 + ((e - 55296) << 10) + (i - 56320)), s++)),
                e < 128
                    ? (t[a++] = e)
                    : e < 2048
                      ? ((t[a++] = 192 | (e >>> 6)), (t[a++] = 128 | (63 & e)))
                      : e < 65536
                        ? ((t[a++] = 224 | (e >>> 12)), (t[a++] = 128 | ((e >>> 6) & 63)), (t[a++] = 128 | (63 & e)))
                        : ((t[a++] = 240 | (e >>> 18)),
                          (t[a++] = 128 | ((e >>> 12) & 63)),
                          (t[a++] = 128 | ((e >>> 6) & 63)),
                          (t[a++] = 128 | (63 & e))));
        return t;
    },
    buf2string: (A, t) => {
        const e = t || A.length;
        if ("function" == typeof TextDecoder && TextDecoder.prototype.decode)
            return new TextDecoder().decode(A.subarray(0, t));
        let i, s;
        const a = new Array(2 * e);
        for (s = 0, i = 0; i < e; ) {
            let t = A[i++];
            if (t < 128) {
                a[s++] = t;
                continue;
            }
            let n = zA[t];
            if (n > 4) ((a[s++] = 65533), (i += n - 1));
            else {
                for (t &= 2 === n ? 31 : 3 === n ? 15 : 7; n > 1 && i < e; ) ((t = (t << 6) | (63 & A[i++])), n--);
                n > 1
                    ? (a[s++] = 65533)
                    : t < 65536
                      ? (a[s++] = t)
                      : ((t -= 65536), (a[s++] = 55296 | ((t >> 10) & 1023)), (a[s++] = 56320 | (1023 & t)));
            }
        }
        return ((A, t) => {
            if (t < 65534 && A.subarray && JA)
                return String.fromCharCode.apply(null, A.length === t ? A : A.subarray(0, t));
            let e = "";
            for (let i = 0; i < t; i++) e += String.fromCharCode(A[i]);
            return e;
        })(a, s);
    },
    utf8border: (A, t) => {
        (t = t || A.length) > A.length && (t = A.length);
        let e = t - 1;
        for (; e >= 0 && 128 == (192 & A[e]); ) e--;
        return e < 0 || 0 === e ? t : e + zA[A[e]] > t ? e : t;
    },
};
var NA = function () {
    ((this.input = null),
        (this.next_in = 0),
        (this.avail_in = 0),
        (this.total_in = 0),
        (this.output = null),
        (this.next_out = 0),
        (this.avail_out = 0),
        (this.total_out = 0),
        (this.msg = ""),
        (this.state = null),
        (this.data_type = 2),
        (this.adler = 0));
};
const ZA = Object.prototype.toString,
    {
        Z_NO_FLUSH: jA,
        Z_SYNC_FLUSH: WA,
        Z_FULL_FLUSH: qA,
        Z_FINISH: XA,
        Z_OK: VA,
        Z_STREAM_END: $A,
        Z_DEFAULT_COMPRESSION: At,
        Z_DEFAULT_STRATEGY: tt,
        Z_DEFLATED: et,
    } = J;
function it(A) {
    this.options = LA.assign(
        { level: At, method: et, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: tt },
        A || {}
    );
    let t = this.options;
    (t.raw && t.windowBits > 0
        ? (t.windowBits = -t.windowBits)
        : t.gzip && t.windowBits > 0 && t.windowBits < 16 && (t.windowBits += 16),
        (this.err = 0),
        (this.msg = ""),
        (this.ended = !1),
        (this.chunks = []),
        (this.strm = new NA()),
        (this.strm.avail_out = 0));
    let e = KA.deflateInit2(this.strm, t.level, t.method, t.windowBits, t.memLevel, t.strategy);
    if (e !== VA) throw new Error(L[e]);
    if ((t.header && KA.deflateSetHeader(this.strm, t.header), t.dictionary)) {
        let A;
        if (
            ((A =
                "string" == typeof t.dictionary
                    ? vA.string2buf(t.dictionary)
                    : "[object ArrayBuffer]" === ZA.call(t.dictionary)
                      ? new Uint8Array(t.dictionary)
                      : t.dictionary),
            (e = KA.deflateSetDictionary(this.strm, A)),
            e !== VA)
        )
            throw new Error(L[e]);
        this._dict_set = !0;
    }
}
function st(A, t) {
    const e = new it(t);
    if ((e.push(A, !0), e.err)) throw e.msg || L[e.err];
    return e.result;
}
((it.prototype.push = function (A, t) {
    const e = this.strm,
        i = this.options.chunkSize;
    let s, a;
    if (this.ended) return !1;
    for (
        a = t === ~~t ? t : !0 === t ? XA : jA,
            "string" == typeof A
                ? (e.input = vA.string2buf(A))
                : "[object ArrayBuffer]" === ZA.call(A)
                  ? (e.input = new Uint8Array(A))
                  : (e.input = A),
            e.next_in = 0,
            e.avail_in = e.input.length;
        ;
    )
        if (
            (0 === e.avail_out && ((e.output = new Uint8Array(i)), (e.next_out = 0), (e.avail_out = i)),
            (a === WA || a === qA) && e.avail_out <= 6)
        )
            (this.onData(e.output.subarray(0, e.next_out)), (e.avail_out = 0));
        else {
            if (((s = KA.deflate(e, a)), s === $A))
                return (
                    e.next_out > 0 && this.onData(e.output.subarray(0, e.next_out)),
                    (s = KA.deflateEnd(this.strm)),
                    this.onEnd(s),
                    (this.ended = !0),
                    s === VA
                );
            if (0 !== e.avail_out) {
                if (a > 0 && e.next_out > 0) (this.onData(e.output.subarray(0, e.next_out)), (e.avail_out = 0));
                else if (0 === e.avail_in) break;
            } else this.onData(e.output);
        }
    return !0;
}),
    (it.prototype.onData = function (A) {
        this.chunks.push(A);
    }),
    (it.prototype.onEnd = function (A) {
        (A === VA && (this.result = LA.flattenChunks(this.chunks)),
            (this.chunks = []),
            (this.err = A),
            (this.msg = this.strm.msg));
    }));
var at = {
    Deflate: it,
    deflate: st,
    deflateRaw: function (A, t) {
        return (((t = t || {}).raw = !0), st(A, t));
    },
    gzip: function (A, t) {
        return (((t = t || {}).gzip = !0), st(A, t));
    },
    constants: J,
};
const nt = 16209;
var ht = function (A, t) {
    let e, i, s, a, n, h, r, E, g, o, B, w, c, I, C, l, _, d, D, M, Q, S, R, f;
    const F = A.state;
    ((e = A.next_in),
        (R = A.input),
        (i = e + (A.avail_in - 5)),
        (s = A.next_out),
        (f = A.output),
        (a = s - (t - A.avail_out)),
        (n = s + (A.avail_out - 257)),
        (h = F.dmax),
        (r = F.wsize),
        (E = F.whave),
        (g = F.wnext),
        (o = F.window),
        (B = F.hold),
        (w = F.bits),
        (c = F.lencode),
        (I = F.distcode),
        (C = (1 << F.lenbits) - 1),
        (l = (1 << F.distbits) - 1));
    A: do {
        (w < 15 && ((B += R[e++] << w), (w += 8), (B += R[e++] << w), (w += 8)), (_ = c[B & C]));
        t: for (;;) {
            if (((d = _ >>> 24), (B >>>= d), (w -= d), (d = (_ >>> 16) & 255), 0 === d)) f[s++] = 65535 & _;
            else {
                if (!(16 & d)) {
                    if (0 == (64 & d)) {
                        _ = c[(65535 & _) + (B & ((1 << d) - 1))];
                        continue t;
                    }
                    if (32 & d) {
                        F.mode = 16191;
                        break A;
                    }
                    ((A.msg = "invalid literal/length code"), (F.mode = nt));
                    break A;
                }
                ((D = 65535 & _),
                    (d &= 15),
                    d && (w < d && ((B += R[e++] << w), (w += 8)), (D += B & ((1 << d) - 1)), (B >>>= d), (w -= d)),
                    w < 15 && ((B += R[e++] << w), (w += 8), (B += R[e++] << w), (w += 8)),
                    (_ = I[B & l]));
                e: for (;;) {
                    if (((d = _ >>> 24), (B >>>= d), (w -= d), (d = (_ >>> 16) & 255), !(16 & d))) {
                        if (0 == (64 & d)) {
                            _ = I[(65535 & _) + (B & ((1 << d) - 1))];
                            continue e;
                        }
                        ((A.msg = "invalid distance code"), (F.mode = nt));
                        break A;
                    }
                    if (
                        ((M = 65535 & _),
                        (d &= 15),
                        w < d && ((B += R[e++] << w), (w += 8), w < d && ((B += R[e++] << w), (w += 8))),
                        (M += B & ((1 << d) - 1)),
                        M > h)
                    ) {
                        ((A.msg = "invalid distance too far back"), (F.mode = nt));
                        break A;
                    }
                    if (((B >>>= d), (w -= d), (d = s - a), M > d)) {
                        if (((d = M - d), d > E && F.sane)) {
                            ((A.msg = "invalid distance too far back"), (F.mode = nt));
                            break A;
                        }
                        if (((Q = 0), (S = o), 0 === g)) {
                            if (((Q += r - d), d < D)) {
                                D -= d;
                                do {
                                    f[s++] = o[Q++];
                                } while (--d);
                                ((Q = s - M), (S = f));
                            }
                        } else if (g < d) {
                            if (((Q += r + g - d), (d -= g), d < D)) {
                                D -= d;
                                do {
                                    f[s++] = o[Q++];
                                } while (--d);
                                if (((Q = 0), g < D)) {
                                    ((d = g), (D -= d));
                                    do {
                                        f[s++] = o[Q++];
                                    } while (--d);
                                    ((Q = s - M), (S = f));
                                }
                            }
                        } else if (((Q += g - d), d < D)) {
                            D -= d;
                            do {
                                f[s++] = o[Q++];
                            } while (--d);
                            ((Q = s - M), (S = f));
                        }
                        for (; D > 2; ) ((f[s++] = S[Q++]), (f[s++] = S[Q++]), (f[s++] = S[Q++]), (D -= 3));
                        D && ((f[s++] = S[Q++]), D > 1 && (f[s++] = S[Q++]));
                    } else {
                        Q = s - M;
                        do {
                            ((f[s++] = f[Q++]), (f[s++] = f[Q++]), (f[s++] = f[Q++]), (D -= 3));
                        } while (D > 2);
                        D && ((f[s++] = f[Q++]), D > 1 && (f[s++] = f[Q++]));
                    }
                    break;
                }
            }
            break;
        }
    } while (e < i && s < n);
    ((D = w >> 3),
        (e -= D),
        (w -= D << 3),
        (B &= (1 << w) - 1),
        (A.next_in = e),
        (A.next_out = s),
        (A.avail_in = e < i ? i - e + 5 : 5 - (e - i)),
        (A.avail_out = s < n ? n - s + 257 : 257 - (s - n)),
        (F.hold = B),
        (F.bits = w));
};
const rt = 15,
    Et = new Uint16Array([
        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227,
        258, 0, 0,
    ]),
    gt = new Uint8Array([
        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
        16, 72, 78,
    ]),
    ot = new Uint16Array([
        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097,
        6145, 8193, 12289, 16385, 24577, 0, 0,
    ]),
    Bt = new Uint8Array([
        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28,
        29, 29, 64, 64,
    ]);
var wt = (A, t, e, i, s, a, n, h) => {
    const r = h.bits;
    let E,
        g,
        o,
        B,
        w,
        c,
        I = 0,
        C = 0,
        l = 0,
        _ = 0,
        d = 0,
        D = 0,
        M = 0,
        Q = 0,
        S = 0,
        R = 0,
        f = null;
    const F = new Uint16Array(16),
        u = new Uint16Array(16);
    let T,
        y,
        p,
        k = null;
    for (I = 0; I <= rt; I++) F[I] = 0;
    for (C = 0; C < i; C++) F[t[e + C]]++;
    for (d = r, _ = rt; _ >= 1 && 0 === F[_]; _--);
    if ((d > _ && (d = _), 0 === _)) return ((s[a++] = 20971520), (s[a++] = 20971520), (h.bits = 1), 0);
    for (l = 1; l < _ && 0 === F[l]; l++);
    for (d < l && (d = l), Q = 1, I = 1; I <= rt; I++) if (((Q <<= 1), (Q -= F[I]), Q < 0)) return -1;
    if (Q > 0 && (0 === A || 1 !== _)) return -1;
    for (u[1] = 0, I = 1; I < rt; I++) u[I + 1] = u[I] + F[I];
    for (C = 0; C < i; C++) 0 !== t[e + C] && (n[u[t[e + C]]++] = C);
    if (
        (0 === A ? ((f = k = n), (c = 20)) : 1 === A ? ((f = Et), (k = gt), (c = 257)) : ((f = ot), (k = Bt), (c = 0)),
        (R = 0),
        (C = 0),
        (I = l),
        (w = a),
        (D = d),
        (M = 0),
        (o = -1),
        (S = 1 << d),
        (B = S - 1),
        (1 === A && S > 852) || (2 === A && S > 592))
    )
        return 1;
    for (;;) {
        ((T = I - M),
            n[C] + 1 < c
                ? ((y = 0), (p = n[C]))
                : n[C] >= c
                  ? ((y = k[n[C] - c]), (p = f[n[C] - c]))
                  : ((y = 96), (p = 0)),
            (E = 1 << (I - M)),
            (g = 1 << D),
            (l = g));
        do {
            ((g -= E), (s[w + (R >> M) + g] = (T << 24) | (y << 16) | p | 0));
        } while (0 !== g);
        for (E = 1 << (I - 1); R & E; ) E >>= 1;
        if ((0 !== E ? ((R &= E - 1), (R += E)) : (R = 0), C++, 0 == --F[I])) {
            if (I === _) break;
            I = t[e + n[C]];
        }
        if (I > d && (R & B) !== o) {
            for (0 === M && (M = d), w += l, D = I - M, Q = 1 << D; D + M < _ && ((Q -= F[D + M]), !(Q <= 0)); )
                (D++, (Q <<= 1));
            if (((S += 1 << D), (1 === A && S > 852) || (2 === A && S > 592))) return 1;
            ((o = R & B), (s[o] = (d << 24) | (D << 16) | (w - a) | 0));
        }
    }
    return (0 !== R && (s[w + R] = ((I - M) << 24) | (64 << 16) | 0), (h.bits = d), 0);
};
const {
        Z_FINISH: ct,
        Z_BLOCK: It,
        Z_TREES: Ct,
        Z_OK: lt,
        Z_STREAM_END: _t,
        Z_NEED_DICT: dt,
        Z_STREAM_ERROR: Dt,
        Z_DATA_ERROR: Mt,
        Z_MEM_ERROR: Qt,
        Z_BUF_ERROR: St,
        Z_DEFLATED: Rt,
    } = J,
    ft = 16180,
    Ft = 16190,
    ut = 16191,
    Tt = 16192,
    yt = 16194,
    pt = 16199,
    kt = 16200,
    Ht = 16206,
    Pt = 16209,
    mt = (A) => ((A >>> 24) & 255) + ((A >>> 8) & 65280) + ((65280 & A) << 8) + ((255 & A) << 24);
function Ot() {
    ((this.strm = null),
        (this.mode = 0),
        (this.last = !1),
        (this.wrap = 0),
        (this.havedict = !1),
        (this.flags = 0),
        (this.dmax = 0),
        (this.check = 0),
        (this.total = 0),
        (this.head = null),
        (this.wbits = 0),
        (this.wsize = 0),
        (this.whave = 0),
        (this.wnext = 0),
        (this.window = null),
        (this.hold = 0),
        (this.bits = 0),
        (this.length = 0),
        (this.offset = 0),
        (this.extra = 0),
        (this.lencode = null),
        (this.distcode = null),
        (this.lenbits = 0),
        (this.distbits = 0),
        (this.ncode = 0),
        (this.nlen = 0),
        (this.ndist = 0),
        (this.have = 0),
        (this.next = null),
        (this.lens = new Uint16Array(320)),
        (this.work = new Uint16Array(288)),
        (this.lendyn = null),
        (this.distdyn = null),
        (this.sane = 0),
        (this.back = 0),
        (this.was = 0));
}
const Gt = (A) => {
        if (!A) return 1;
        const t = A.state;
        return !t || t.strm !== A || t.mode < ft || t.mode > 16211 ? 1 : 0;
    },
    Ut = (A) => {
        if (Gt(A)) return Dt;
        const t = A.state;
        return (
            (A.total_in = A.total_out = t.total = 0),
            (A.msg = ""),
            t.wrap && (A.adler = 1 & t.wrap),
            (t.mode = ft),
            (t.last = 0),
            (t.havedict = 0),
            (t.flags = -1),
            (t.dmax = 32768),
            (t.head = null),
            (t.hold = 0),
            (t.bits = 0),
            (t.lencode = t.lendyn = new Int32Array(852)),
            (t.distcode = t.distdyn = new Int32Array(592)),
            (t.sane = 1),
            (t.back = -1),
            lt
        );
    },
    bt = (A) => {
        if (Gt(A)) return Dt;
        const t = A.state;
        return ((t.wsize = 0), (t.whave = 0), (t.wnext = 0), Ut(A));
    },
    Yt = (A, t) => {
        let e;
        if (Gt(A)) return Dt;
        const i = A.state;
        return (
            t < 0 ? ((e = 0), (t = -t)) : ((e = 5 + (t >> 4)), t < 48 && (t &= 15)),
            t && (t < 8 || t > 15)
                ? Dt
                : (null !== i.window && i.wbits !== t && (i.window = null), (i.wrap = e), (i.wbits = t), bt(A))
        );
    },
    Kt = (A, t) => {
        if (!A) return Dt;
        const e = new Ot();
        ((A.state = e), (e.strm = A), (e.window = null), (e.mode = ft));
        const i = Yt(A, t);
        return (i !== lt && (A.state = null), i);
    };
let xt,
    Lt,
    Jt = !0;
const zt = (A) => {
        if (Jt) {
            ((xt = new Int32Array(512)), (Lt = new Int32Array(32)));
            let t = 0;
            for (; t < 144; ) A.lens[t++] = 8;
            for (; t < 256; ) A.lens[t++] = 9;
            for (; t < 280; ) A.lens[t++] = 7;
            for (; t < 288; ) A.lens[t++] = 8;
            for (wt(1, A.lens, 0, 288, xt, 0, A.work, { bits: 9 }), t = 0; t < 32; ) A.lens[t++] = 5;
            (wt(2, A.lens, 0, 32, Lt, 0, A.work, { bits: 5 }), (Jt = !1));
        }
        ((A.lencode = xt), (A.lenbits = 9), (A.distcode = Lt), (A.distbits = 5));
    },
    vt = (A, t, e, i) => {
        let s;
        const a = A.state;
        return (
            null === a.window &&
                ((a.wsize = 1 << a.wbits), (a.wnext = 0), (a.whave = 0), (a.window = new Uint8Array(a.wsize))),
            i >= a.wsize
                ? (a.window.set(t.subarray(e - a.wsize, e), 0), (a.wnext = 0), (a.whave = a.wsize))
                : ((s = a.wsize - a.wnext),
                  s > i && (s = i),
                  a.window.set(t.subarray(e - i, e - i + s), a.wnext),
                  (i -= s)
                      ? (a.window.set(t.subarray(e - i, e), 0), (a.wnext = i), (a.whave = a.wsize))
                      : ((a.wnext += s), a.wnext === a.wsize && (a.wnext = 0), a.whave < a.wsize && (a.whave += s))),
            0
        );
    };
var Nt = {
    inflateReset: bt,
    inflateReset2: Yt,
    inflateResetKeep: Ut,
    inflateInit: (A) => Kt(A, 15),
    inflateInit2: Kt,
    inflate: (A, t) => {
        let e,
            i,
            s,
            a,
            n,
            h,
            r,
            E,
            g,
            o,
            B,
            w,
            c,
            I,
            C,
            l,
            _,
            d,
            D,
            M,
            Q,
            S,
            R = 0;
        const f = new Uint8Array(4);
        let F, u;
        const T = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
        if (Gt(A) || !A.output || (!A.input && 0 !== A.avail_in)) return Dt;
        ((e = A.state),
            e.mode === ut && (e.mode = Tt),
            (n = A.next_out),
            (s = A.output),
            (r = A.avail_out),
            (a = A.next_in),
            (i = A.input),
            (h = A.avail_in),
            (E = e.hold),
            (g = e.bits),
            (o = h),
            (B = r),
            (S = lt));
        A: for (;;)
            switch (e.mode) {
                case ft:
                    if (0 === e.wrap) {
                        e.mode = Tt;
                        break;
                    }
                    for (; g < 16; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    if (2 & e.wrap && 35615 === E) {
                        (0 === e.wbits && (e.wbits = 15),
                            (e.check = 0),
                            (f[0] = 255 & E),
                            (f[1] = (E >>> 8) & 255),
                            (e.check = x(e.check, f, 2, 0)),
                            (E = 0),
                            (g = 0),
                            (e.mode = 16181));
                        break;
                    }
                    if ((e.head && (e.head.done = !1), !(1 & e.wrap) || (((255 & E) << 8) + (E >> 8)) % 31)) {
                        ((A.msg = "incorrect header check"), (e.mode = Pt));
                        break;
                    }
                    if ((15 & E) !== Rt) {
                        ((A.msg = "unknown compression method"), (e.mode = Pt));
                        break;
                    }
                    if (
                        ((E >>>= 4),
                        (g -= 4),
                        (Q = 8 + (15 & E)),
                        0 === e.wbits && (e.wbits = Q),
                        Q > 15 || Q > e.wbits)
                    ) {
                        ((A.msg = "invalid window size"), (e.mode = Pt));
                        break;
                    }
                    ((e.dmax = 1 << e.wbits),
                        (e.flags = 0),
                        (A.adler = e.check = 1),
                        (e.mode = 512 & E ? 16189 : ut),
                        (E = 0),
                        (g = 0));
                    break;
                case 16181:
                    for (; g < 16; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    if (((e.flags = E), (255 & e.flags) !== Rt)) {
                        ((A.msg = "unknown compression method"), (e.mode = Pt));
                        break;
                    }
                    if (57344 & e.flags) {
                        ((A.msg = "unknown header flags set"), (e.mode = Pt));
                        break;
                    }
                    (e.head && (e.head.text = (E >> 8) & 1),
                        512 & e.flags &&
                            4 & e.wrap &&
                            ((f[0] = 255 & E), (f[1] = (E >>> 8) & 255), (e.check = x(e.check, f, 2, 0))),
                        (E = 0),
                        (g = 0),
                        (e.mode = 16182));
                case 16182:
                    for (; g < 32; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    (e.head && (e.head.time = E),
                        512 & e.flags &&
                            4 & e.wrap &&
                            ((f[0] = 255 & E),
                            (f[1] = (E >>> 8) & 255),
                            (f[2] = (E >>> 16) & 255),
                            (f[3] = (E >>> 24) & 255),
                            (e.check = x(e.check, f, 4, 0))),
                        (E = 0),
                        (g = 0),
                        (e.mode = 16183));
                case 16183:
                    for (; g < 16; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    (e.head && ((e.head.xflags = 255 & E), (e.head.os = E >> 8)),
                        512 & e.flags &&
                            4 & e.wrap &&
                            ((f[0] = 255 & E), (f[1] = (E >>> 8) & 255), (e.check = x(e.check, f, 2, 0))),
                        (E = 0),
                        (g = 0),
                        (e.mode = 16184));
                case 16184:
                    if (1024 & e.flags) {
                        for (; g < 16; ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        ((e.length = E),
                            e.head && (e.head.extra_len = E),
                            512 & e.flags &&
                                4 & e.wrap &&
                                ((f[0] = 255 & E), (f[1] = (E >>> 8) & 255), (e.check = x(e.check, f, 2, 0))),
                            (E = 0),
                            (g = 0));
                    } else e.head && (e.head.extra = null);
                    e.mode = 16185;
                case 16185:
                    if (
                        1024 & e.flags &&
                        ((w = e.length),
                        w > h && (w = h),
                        w &&
                            (e.head &&
                                ((Q = e.head.extra_len - e.length),
                                e.head.extra || (e.head.extra = new Uint8Array(e.head.extra_len)),
                                e.head.extra.set(i.subarray(a, a + w), Q)),
                            512 & e.flags && 4 & e.wrap && (e.check = x(e.check, i, w, a)),
                            (h -= w),
                            (a += w),
                            (e.length -= w)),
                        e.length)
                    )
                        break A;
                    ((e.length = 0), (e.mode = 16186));
                case 16186:
                    if (2048 & e.flags) {
                        if (0 === h) break A;
                        w = 0;
                        do {
                            ((Q = i[a + w++]),
                                e.head && Q && e.length < 65536 && (e.head.name += String.fromCharCode(Q)));
                        } while (Q && w < h);
                        if ((512 & e.flags && 4 & e.wrap && (e.check = x(e.check, i, w, a)), (h -= w), (a += w), Q))
                            break A;
                    } else e.head && (e.head.name = null);
                    ((e.length = 0), (e.mode = 16187));
                case 16187:
                    if (4096 & e.flags) {
                        if (0 === h) break A;
                        w = 0;
                        do {
                            ((Q = i[a + w++]),
                                e.head && Q && e.length < 65536 && (e.head.comment += String.fromCharCode(Q)));
                        } while (Q && w < h);
                        if ((512 & e.flags && 4 & e.wrap && (e.check = x(e.check, i, w, a)), (h -= w), (a += w), Q))
                            break A;
                    } else e.head && (e.head.comment = null);
                    e.mode = 16188;
                case 16188:
                    if (512 & e.flags) {
                        for (; g < 16; ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        if (4 & e.wrap && E !== (65535 & e.check)) {
                            ((A.msg = "header crc mismatch"), (e.mode = Pt));
                            break;
                        }
                        ((E = 0), (g = 0));
                    }
                    (e.head && ((e.head.hcrc = (e.flags >> 9) & 1), (e.head.done = !0)),
                        (A.adler = e.check = 0),
                        (e.mode = ut));
                    break;
                case 16189:
                    for (; g < 32; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    ((A.adler = e.check = mt(E)), (E = 0), (g = 0), (e.mode = Ft));
                case Ft:
                    if (0 === e.havedict)
                        return (
                            (A.next_out = n),
                            (A.avail_out = r),
                            (A.next_in = a),
                            (A.avail_in = h),
                            (e.hold = E),
                            (e.bits = g),
                            dt
                        );
                    ((A.adler = e.check = 1), (e.mode = ut));
                case ut:
                    if (t === It || t === Ct) break A;
                case Tt:
                    if (e.last) {
                        ((E >>>= 7 & g), (g -= 7 & g), (e.mode = Ht));
                        break;
                    }
                    for (; g < 3; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    switch (((e.last = 1 & E), (E >>>= 1), (g -= 1), 3 & E)) {
                        case 0:
                            e.mode = 16193;
                            break;
                        case 1:
                            if ((zt(e), (e.mode = pt), t === Ct)) {
                                ((E >>>= 2), (g -= 2));
                                break A;
                            }
                            break;
                        case 2:
                            e.mode = 16196;
                            break;
                        case 3:
                            ((A.msg = "invalid block type"), (e.mode = Pt));
                    }
                    ((E >>>= 2), (g -= 2));
                    break;
                case 16193:
                    for (E >>>= 7 & g, g -= 7 & g; g < 32; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    if ((65535 & E) != ((E >>> 16) ^ 65535)) {
                        ((A.msg = "invalid stored block lengths"), (e.mode = Pt));
                        break;
                    }
                    if (((e.length = 65535 & E), (E = 0), (g = 0), (e.mode = yt), t === Ct)) break A;
                case yt:
                    e.mode = 16195;
                case 16195:
                    if (((w = e.length), w)) {
                        if ((w > h && (w = h), w > r && (w = r), 0 === w)) break A;
                        (s.set(i.subarray(a, a + w), n), (h -= w), (a += w), (r -= w), (n += w), (e.length -= w));
                        break;
                    }
                    e.mode = ut;
                    break;
                case 16196:
                    for (; g < 14; ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    if (
                        ((e.nlen = 257 + (31 & E)),
                        (E >>>= 5),
                        (g -= 5),
                        (e.ndist = 1 + (31 & E)),
                        (E >>>= 5),
                        (g -= 5),
                        (e.ncode = 4 + (15 & E)),
                        (E >>>= 4),
                        (g -= 4),
                        e.nlen > 286 || e.ndist > 30)
                    ) {
                        ((A.msg = "too many length or distance symbols"), (e.mode = Pt));
                        break;
                    }
                    ((e.have = 0), (e.mode = 16197));
                case 16197:
                    for (; e.have < e.ncode; ) {
                        for (; g < 3; ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        ((e.lens[T[e.have++]] = 7 & E), (E >>>= 3), (g -= 3));
                    }
                    for (; e.have < 19; ) e.lens[T[e.have++]] = 0;
                    if (
                        ((e.lencode = e.lendyn),
                        (e.lenbits = 7),
                        (F = { bits: e.lenbits }),
                        (S = wt(0, e.lens, 0, 19, e.lencode, 0, e.work, F)),
                        (e.lenbits = F.bits),
                        S)
                    ) {
                        ((A.msg = "invalid code lengths set"), (e.mode = Pt));
                        break;
                    }
                    ((e.have = 0), (e.mode = 16198));
                case 16198:
                    for (; e.have < e.nlen + e.ndist; ) {
                        for (
                            ;
                            (R = e.lencode[E & ((1 << e.lenbits) - 1)]),
                                (C = R >>> 24),
                                (l = (R >>> 16) & 255),
                                (_ = 65535 & R),
                                !(C <= g);
                        ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        if (_ < 16) ((E >>>= C), (g -= C), (e.lens[e.have++] = _));
                        else {
                            if (16 === _) {
                                for (u = C + 2; g < u; ) {
                                    if (0 === h) break A;
                                    (h--, (E += i[a++] << g), (g += 8));
                                }
                                if (((E >>>= C), (g -= C), 0 === e.have)) {
                                    ((A.msg = "invalid bit length repeat"), (e.mode = Pt));
                                    break;
                                }
                                ((Q = e.lens[e.have - 1]), (w = 3 + (3 & E)), (E >>>= 2), (g -= 2));
                            } else if (17 === _) {
                                for (u = C + 3; g < u; ) {
                                    if (0 === h) break A;
                                    (h--, (E += i[a++] << g), (g += 8));
                                }
                                ((E >>>= C), (g -= C), (Q = 0), (w = 3 + (7 & E)), (E >>>= 3), (g -= 3));
                            } else {
                                for (u = C + 7; g < u; ) {
                                    if (0 === h) break A;
                                    (h--, (E += i[a++] << g), (g += 8));
                                }
                                ((E >>>= C), (g -= C), (Q = 0), (w = 11 + (127 & E)), (E >>>= 7), (g -= 7));
                            }
                            if (e.have + w > e.nlen + e.ndist) {
                                ((A.msg = "invalid bit length repeat"), (e.mode = Pt));
                                break;
                            }
                            for (; w--; ) e.lens[e.have++] = Q;
                        }
                    }
                    if (e.mode === Pt) break;
                    if (0 === e.lens[256]) {
                        ((A.msg = "invalid code -- missing end-of-block"), (e.mode = Pt));
                        break;
                    }
                    if (
                        ((e.lenbits = 9),
                        (F = { bits: e.lenbits }),
                        (S = wt(1, e.lens, 0, e.nlen, e.lencode, 0, e.work, F)),
                        (e.lenbits = F.bits),
                        S)
                    ) {
                        ((A.msg = "invalid literal/lengths set"), (e.mode = Pt));
                        break;
                    }
                    if (
                        ((e.distbits = 6),
                        (e.distcode = e.distdyn),
                        (F = { bits: e.distbits }),
                        (S = wt(2, e.lens, e.nlen, e.ndist, e.distcode, 0, e.work, F)),
                        (e.distbits = F.bits),
                        S)
                    ) {
                        ((A.msg = "invalid distances set"), (e.mode = Pt));
                        break;
                    }
                    if (((e.mode = pt), t === Ct)) break A;
                case pt:
                    e.mode = kt;
                case kt:
                    if (h >= 6 && r >= 258) {
                        ((A.next_out = n),
                            (A.avail_out = r),
                            (A.next_in = a),
                            (A.avail_in = h),
                            (e.hold = E),
                            (e.bits = g),
                            ht(A, B),
                            (n = A.next_out),
                            (s = A.output),
                            (r = A.avail_out),
                            (a = A.next_in),
                            (i = A.input),
                            (h = A.avail_in),
                            (E = e.hold),
                            (g = e.bits),
                            e.mode === ut && (e.back = -1));
                        break;
                    }
                    for (
                        e.back = 0;
                        (R = e.lencode[E & ((1 << e.lenbits) - 1)]),
                            (C = R >>> 24),
                            (l = (R >>> 16) & 255),
                            (_ = 65535 & R),
                            !(C <= g);
                    ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    if (l && 0 == (240 & l)) {
                        for (
                            d = C, D = l, M = _;
                            (R = e.lencode[M + ((E & ((1 << (d + D)) - 1)) >> d)]),
                                (C = R >>> 24),
                                (l = (R >>> 16) & 255),
                                (_ = 65535 & R),
                                !(d + C <= g);
                        ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        ((E >>>= d), (g -= d), (e.back += d));
                    }
                    if (((E >>>= C), (g -= C), (e.back += C), (e.length = _), 0 === l)) {
                        e.mode = 16205;
                        break;
                    }
                    if (32 & l) {
                        ((e.back = -1), (e.mode = ut));
                        break;
                    }
                    if (64 & l) {
                        ((A.msg = "invalid literal/length code"), (e.mode = Pt));
                        break;
                    }
                    ((e.extra = 15 & l), (e.mode = 16201));
                case 16201:
                    if (e.extra) {
                        for (u = e.extra; g < u; ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        ((e.length += E & ((1 << e.extra) - 1)), (E >>>= e.extra), (g -= e.extra), (e.back += e.extra));
                    }
                    ((e.was = e.length), (e.mode = 16202));
                case 16202:
                    for (
                        ;
                        (R = e.distcode[E & ((1 << e.distbits) - 1)]),
                            (C = R >>> 24),
                            (l = (R >>> 16) & 255),
                            (_ = 65535 & R),
                            !(C <= g);
                    ) {
                        if (0 === h) break A;
                        (h--, (E += i[a++] << g), (g += 8));
                    }
                    if (0 == (240 & l)) {
                        for (
                            d = C, D = l, M = _;
                            (R = e.distcode[M + ((E & ((1 << (d + D)) - 1)) >> d)]),
                                (C = R >>> 24),
                                (l = (R >>> 16) & 255),
                                (_ = 65535 & R),
                                !(d + C <= g);
                        ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        ((E >>>= d), (g -= d), (e.back += d));
                    }
                    if (((E >>>= C), (g -= C), (e.back += C), 64 & l)) {
                        ((A.msg = "invalid distance code"), (e.mode = Pt));
                        break;
                    }
                    ((e.offset = _), (e.extra = 15 & l), (e.mode = 16203));
                case 16203:
                    if (e.extra) {
                        for (u = e.extra; g < u; ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        ((e.offset += E & ((1 << e.extra) - 1)), (E >>>= e.extra), (g -= e.extra), (e.back += e.extra));
                    }
                    if (e.offset > e.dmax) {
                        ((A.msg = "invalid distance too far back"), (e.mode = Pt));
                        break;
                    }
                    e.mode = 16204;
                case 16204:
                    if (0 === r) break A;
                    if (((w = B - r), e.offset > w)) {
                        if (((w = e.offset - w), w > e.whave && e.sane)) {
                            ((A.msg = "invalid distance too far back"), (e.mode = Pt));
                            break;
                        }
                        (w > e.wnext ? ((w -= e.wnext), (c = e.wsize - w)) : (c = e.wnext - w),
                            w > e.length && (w = e.length),
                            (I = e.window));
                    } else ((I = s), (c = n - e.offset), (w = e.length));
                    (w > r && (w = r), (r -= w), (e.length -= w));
                    do {
                        s[n++] = I[c++];
                    } while (--w);
                    0 === e.length && (e.mode = kt);
                    break;
                case 16205:
                    if (0 === r) break A;
                    ((s[n++] = e.length), r--, (e.mode = kt));
                    break;
                case Ht:
                    if (e.wrap) {
                        for (; g < 32; ) {
                            if (0 === h) break A;
                            (h--, (E |= i[a++] << g), (g += 8));
                        }
                        if (
                            ((B -= r),
                            (A.total_out += B),
                            (e.total += B),
                            4 & e.wrap &&
                                B &&
                                (A.adler = e.check = e.flags ? x(e.check, s, B, n - B) : Y(e.check, s, B, n - B)),
                            (B = r),
                            4 & e.wrap && (e.flags ? E : mt(E)) !== e.check)
                        ) {
                            ((A.msg = "incorrect data check"), (e.mode = Pt));
                            break;
                        }
                        ((E = 0), (g = 0));
                    }
                    e.mode = 16207;
                case 16207:
                    if (e.wrap && e.flags) {
                        for (; g < 32; ) {
                            if (0 === h) break A;
                            (h--, (E += i[a++] << g), (g += 8));
                        }
                        if (4 & e.wrap && E !== (4294967295 & e.total)) {
                            ((A.msg = "incorrect length check"), (e.mode = Pt));
                            break;
                        }
                        ((E = 0), (g = 0));
                    }
                    e.mode = 16208;
                case 16208:
                    S = _t;
                    break A;
                case Pt:
                    S = Mt;
                    break A;
                case 16210:
                    return Qt;
                default:
                    return Dt;
            }
        return (
            (A.next_out = n),
            (A.avail_out = r),
            (A.next_in = a),
            (A.avail_in = h),
            (e.hold = E),
            (e.bits = g),
            (e.wsize || (B !== A.avail_out && e.mode < Pt && (e.mode < Ht || t !== ct))) &&
                vt(A, A.output, A.next_out, B - A.avail_out),
            (o -= A.avail_in),
            (B -= A.avail_out),
            (A.total_in += o),
            (A.total_out += B),
            (e.total += B),
            4 & e.wrap &&
                B &&
                (A.adler = e.check = e.flags ? x(e.check, s, B, A.next_out - B) : Y(e.check, s, B, A.next_out - B)),
            (A.data_type =
                e.bits + (e.last ? 64 : 0) + (e.mode === ut ? 128 : 0) + (e.mode === pt || e.mode === yt ? 256 : 0)),
            ((0 === o && 0 === B) || t === ct) && S === lt && (S = St),
            S
        );
    },
    inflateEnd: (A) => {
        if (Gt(A)) return Dt;
        let t = A.state;
        return (t.window && (t.window = null), (A.state = null), lt);
    },
    inflateGetHeader: (A, t) => {
        if (Gt(A)) return Dt;
        const e = A.state;
        return 0 == (2 & e.wrap) ? Dt : ((e.head = t), (t.done = !1), lt);
    },
    inflateSetDictionary: (A, t) => {
        const e = t.length;
        let i, s, a;
        return Gt(A)
            ? Dt
            : ((i = A.state),
              0 !== i.wrap && i.mode !== Ft
                  ? Dt
                  : i.mode === Ft && ((s = 1), (s = Y(s, t, e, 0)), s !== i.check)
                    ? Mt
                    : ((a = vt(A, t, e, e)), a ? ((i.mode = 16210), Qt) : ((i.havedict = 1), lt)));
    },
    inflateInfo: "pako inflate (from Nodeca project)",
};
var Zt = function () {
    ((this.text = 0),
        (this.time = 0),
        (this.xflags = 0),
        (this.os = 0),
        (this.extra = null),
        (this.extra_len = 0),
        (this.name = ""),
        (this.comment = ""),
        (this.hcrc = 0),
        (this.done = !1));
};
const jt = Object.prototype.toString,
    {
        Z_NO_FLUSH: Wt,
        Z_FINISH: qt,
        Z_OK: Xt,
        Z_STREAM_END: Vt,
        Z_NEED_DICT: $t,
        Z_STREAM_ERROR: Ae,
        Z_DATA_ERROR: te,
        Z_MEM_ERROR: ee,
    } = J;
function ie(A) {
    this.options = LA.assign({ chunkSize: 65536, windowBits: 15, to: "" }, A || {});
    const t = this.options;
    (t.raw &&
        t.windowBits >= 0 &&
        t.windowBits < 16 &&
        ((t.windowBits = -t.windowBits), 0 === t.windowBits && (t.windowBits = -15)),
        !(t.windowBits >= 0 && t.windowBits < 16) || (A && A.windowBits) || (t.windowBits += 32),
        t.windowBits > 15 && t.windowBits < 48 && 0 == (15 & t.windowBits) && (t.windowBits |= 15),
        (this.err = 0),
        (this.msg = ""),
        (this.ended = !1),
        (this.chunks = []),
        (this.strm = new NA()),
        (this.strm.avail_out = 0));
    let e = Nt.inflateInit2(this.strm, t.windowBits);
    if (e !== Xt) throw new Error(L[e]);
    if (
        ((this.header = new Zt()),
        Nt.inflateGetHeader(this.strm, this.header),
        t.dictionary &&
            ("string" == typeof t.dictionary
                ? (t.dictionary = vA.string2buf(t.dictionary))
                : "[object ArrayBuffer]" === jt.call(t.dictionary) && (t.dictionary = new Uint8Array(t.dictionary)),
            t.raw && ((e = Nt.inflateSetDictionary(this.strm, t.dictionary)), e !== Xt)))
    )
        throw new Error(L[e]);
}
function se(A, t) {
    const e = new ie(t);
    if ((e.push(A), e.err)) throw e.msg || L[e.err];
    return e.result;
}
((ie.prototype.push = function (A, t) {
    const e = this.strm,
        i = this.options.chunkSize,
        s = this.options.dictionary;
    let a, n, h;
    if (this.ended) return !1;
    for (
        n = t === ~~t ? t : !0 === t ? qt : Wt,
            "[object ArrayBuffer]" === jt.call(A) ? (e.input = new Uint8Array(A)) : (e.input = A),
            e.next_in = 0,
            e.avail_in = e.input.length;
        ;
    ) {
        for (
            0 === e.avail_out && ((e.output = new Uint8Array(i)), (e.next_out = 0), (e.avail_out = i)),
                a = Nt.inflate(e, n),
                a === $t &&
                    s &&
                    ((a = Nt.inflateSetDictionary(e, s)), a === Xt ? (a = Nt.inflate(e, n)) : a === te && (a = $t));
            e.avail_in > 0 && a === Vt && e.state.wrap > 0 && 0 !== A[e.next_in];
        )
            (Nt.inflateReset(e), (a = Nt.inflate(e, n)));
        switch (a) {
            case Ae:
            case te:
            case $t:
            case ee:
                return (this.onEnd(a), (this.ended = !0), !1);
        }
        if (((h = e.avail_out), e.next_out && (0 === e.avail_out || a === Vt)))
            if ("string" === this.options.to) {
                let A = vA.utf8border(e.output, e.next_out),
                    t = e.next_out - A,
                    s = vA.buf2string(e.output, A);
                ((e.next_out = t),
                    (e.avail_out = i - t),
                    t && e.output.set(e.output.subarray(A, A + t), 0),
                    this.onData(s));
            } else this.onData(e.output.length === e.next_out ? e.output : e.output.subarray(0, e.next_out));
        if (a !== Xt || 0 !== h) {
            if (a === Vt) return ((a = Nt.inflateEnd(this.strm)), this.onEnd(a), (this.ended = !0), !0);
            if (0 === e.avail_in) break;
        }
    }
    return !0;
}),
    (ie.prototype.onData = function (A) {
        this.chunks.push(A);
    }),
    (ie.prototype.onEnd = function (A) {
        (A === Xt &&
            ("string" === this.options.to
                ? (this.result = this.chunks.join(""))
                : (this.result = LA.flattenChunks(this.chunks))),
            (this.chunks = []),
            (this.err = A),
            (this.msg = this.strm.msg));
    }));
var ae = {
    Inflate: ie,
    inflate: se,
    inflateRaw: function (A, t) {
        return (((t = t || {}).raw = !0), se(A, t));
    },
    ungzip: se,
    constants: J,
};
const { Deflate: ne, deflate: he, deflateRaw: re, gzip: Ee } = at,
    { Inflate: ge, inflate: oe, inflateRaw: Be, ungzip: we } = ae;
var ce = he,
    Ie = ge;
class Ce {
    constructor(A, t = !1, e = !0) {
        ((this.device = A),
            (this.tracing = t),
            (this.slipReaderEnabled = !1),
            (this.leftOver = new Uint8Array(0)),
            (this.baudrate = 0),
            (this.traceLog = ""),
            (this.lastTraceTime = Date.now()),
            (this._DTR_state = !1),
            (this.slipReaderEnabled = e));
    }
    getInfo() {
        const A = this.device.getInfo();
        return A.usbVendorId && A.usbProductId
            ? `WebSerial VendorID 0x${A.usbVendorId.toString(16)} ProductID 0x${A.usbProductId.toString(16)}`
            : "";
    }
    getPid() {
        return this.device.getInfo().usbProductId;
    }
    trace(A) {
        const t = `${`TRACE ${(Date.now() - this.lastTraceTime).toFixed(3)}`} ${A}`;
        (console.log(t), (this.traceLog += t + "\n"));
    }
    async returnTrace() {
        try {
            (await navigator.clipboard.writeText(this.traceLog), console.log("Text copied to clipboard!"));
        } catch (A) {
            console.error("Failed to copy text:", A);
        }
    }
    hexify(A) {
        return Array.from(A)
            .map((A) => A.toString(16).padStart(2, "0"))
            .join("")
            .padEnd(16, " ");
    }
    hexConvert(A, t = !0) {
        if (t && A.length > 16) {
            let t = "",
                e = A;
            for (; e.length > 0; ) {
                const A = e.slice(0, 16),
                    i = String.fromCharCode(...A)
                        .split("")
                        .map((A) => (" " === A || (A >= " " && A <= "~" && "  " !== A) ? A : "."))
                        .join("");
                ((e = e.slice(16)), (t += `\n    ${this.hexify(A.slice(0, 8))} ${this.hexify(A.slice(8))} | ${i}`));
            }
            return t;
        }
        return this.hexify(A);
    }
    slipWriter(A) {
        const t = [];
        t.push(192);
        for (let e = 0; e < A.length; e++)
            219 === A[e] ? t.push(219, 221) : 192 === A[e] ? t.push(219, 220) : t.push(A[e]);
        return (t.push(192), new Uint8Array(t));
    }
    async write(A) {
        const t = this.slipWriter(A);
        if (this.device.writable) {
            const A = this.device.writable.getWriter();
            (this.tracing && (console.log("Write bytes"), this.trace(`Write ${t.length} bytes: ${this.hexConvert(t)}`)),
                await A.write(t),
                A.releaseLock());
        }
    }
    _appendBuffer(A, t) {
        const e = new Uint8Array(A.byteLength + t.byteLength);
        return (e.set(new Uint8Array(A), 0), e.set(new Uint8Array(t), A.byteLength), e.buffer);
    }
    slipReader(A) {
        let t = 0,
            e = 0,
            i = 0,
            s = "init";
        for (; t < A.length; )
            if ("init" !== s || 192 != A[t]) {
                if ("valid_data" === s && 192 == A[t]) {
                    ((i = t - 1), (s = "packet_complete"));
                    break;
                }
                t++;
            } else ((e = t + 1), (s = "valid_data"), t++);
        if ("packet_complete" !== s) return ((this.leftOver = A), new Uint8Array(0));
        this.leftOver = A.slice(i + 2);
        const a = new Uint8Array(i - e + 1);
        let n = 0;
        for (t = e; t <= i; t++, n++)
            219 !== A[t] || 220 !== A[t + 1]
                ? 219 !== A[t] || 221 !== A[t + 1]
                    ? (a[n] = A[t])
                    : ((a[n] = 219), t++)
                : ((a[n] = 192), t++);
        return a.slice(0, n);
    }
    async read(A = 0, t = 12) {
        let e,
            i = this.leftOver;
        if (((this.leftOver = new Uint8Array(0)), this.slipReaderEnabled)) {
            const A = this.slipReader(i);
            if (A.length > 0) return A;
            ((i = this.leftOver), (this.leftOver = new Uint8Array(0)));
        }
        if (null == this.device.readable) return this.leftOver;
        this.reader = this.device.readable.getReader();
        try {
            A > 0 &&
                (e = setTimeout(() => {
                    this.reader && this.reader.cancel();
                }, A));
            do {
                const { value: A, done: t } = await this.reader.read();
                if (t) throw ((this.leftOver = i), new Error("Timeout"));
                i = new Uint8Array(this._appendBuffer(i.buffer, A.buffer));
            } while (i.length < t);
        } finally {
            (A > 0 && clearTimeout(e), this.reader.releaseLock());
        }
        if (
            (this.tracing && (console.log("Read bytes"), this.trace(`Read ${i.length} bytes: ${this.hexConvert(i)}`)),
            this.slipReaderEnabled)
        ) {
            const A = this.slipReader(i);
            return (
                this.tracing &&
                    (console.log("Slip reader results"), this.trace(`Read ${A.length} bytes: ${this.hexConvert(A)}`)),
                A
            );
        }
        return i;
    }
    async rawRead(A = 0) {
        if (0 != this.leftOver.length) {
            const A = this.leftOver;
            return ((this.leftOver = new Uint8Array(0)), A);
        }
        if (!this.device.readable) return this.leftOver;
        let t;
        this.reader = this.device.readable.getReader();
        try {
            A > 0 &&
                (t = setTimeout(() => {
                    this.reader && this.reader.cancel();
                }, A));
            const { value: e, done: i } = await this.reader.read();
            return (
                i ||
                    (this.tracing &&
                        (console.log("Raw Read bytes"), this.trace(`Read ${e.length} bytes: ${this.hexConvert(e)}`))),
                e
            );
        } finally {
            (A > 0 && clearTimeout(t), this.reader.releaseLock());
        }
    }
    async setRTS(A) {
        (await this.device.setSignals({ requestToSend: A }), await this.setDTR(this._DTR_state));
    }
    async setDTR(A) {
        ((this._DTR_state = A), await this.device.setSignals({ dataTerminalReady: A }));
    }
    async connect(A = 115200, t = {}) {
        (await this.device.open({
            baudRate: A,
            dataBits: null == t ? void 0 : t.dataBits,
            stopBits: null == t ? void 0 : t.stopBits,
            bufferSize: null == t ? void 0 : t.bufferSize,
            parity: null == t ? void 0 : t.parity,
            flowControl: null == t ? void 0 : t.flowControl,
        }),
            (this.baudrate = A),
            (this.leftOver = new Uint8Array(0)));
    }
    async sleep(A) {
        return new Promise((t) => setTimeout(t, A));
    }
    async waitForUnlock(A) {
        for (
            ;
            (this.device.readable && this.device.readable.locked) ||
            (this.device.writable && this.device.writable.locked);
        )
            await this.sleep(A);
    }
    async disconnect() {
        var A, t;
        ((null === (A = this.device.readable) || void 0 === A ? void 0 : A.locked) &&
            (await (null === (t = this.reader) || void 0 === t ? void 0 : t.cancel())),
            await this.waitForUnlock(400),
            (this.reader = void 0),
            await this.device.close());
    }
}
function le(A) {
    return new Promise((t) => setTimeout(t, A));
}
async function _e(A, t = 50) {
    (await A.setDTR(!1),
        await A.setRTS(!0),
        await le(100),
        await A.setDTR(!0),
        await A.setRTS(!1),
        await le(t),
        await A.setDTR(!1));
}
async function de(A) {
    (await A.setRTS(!1),
        await A.setDTR(!1),
        await le(100),
        await A.setDTR(!0),
        await A.setRTS(!1),
        await le(100),
        await A.setRTS(!0),
        await A.setDTR(!1),
        await A.setRTS(!0),
        await le(100),
        await A.setRTS(!1),
        await A.setDTR(!1));
}
async function De(A, t = !1) {
    t ? (await le(200), await A.setRTS(!1), await le(200)) : (await le(100), await A.setRTS(!1));
}
function Me(A) {
    const t = ["D", "R", "W"],
        e = A.split("|");
    for (const A of e) {
        const e = A[0],
            i = A.slice(1);
        if (!t.includes(e)) return !1;
        if ("D" === e || "R" === e) {
            if ("0" !== i && "1" !== i) return !1;
        } else if ("W" === e) {
            const A = parseInt(i);
            if (isNaN(A) || A <= 0) return !1;
        }
    }
    return !0;
}
async function Qe(A, t) {
    const e = { D: async (t) => await A.setDTR(t), R: async (t) => await A.setRTS(t), W: async (A) => await le(A) };
    try {
        if (!Me(t)) return;
        const A = t.split("|");
        for (const t of A) {
            const A = t[0],
                i = t.slice(1);
            "W" === A ? await e.W(Number(i)) : ("D" !== A && "R" !== A) || (await e[A]("1" === i));
        }
    } catch (A) {
        throw new Error("Invalid custom reset sequence");
    }
}
var Se = function (A) {
    return atob(A);
};
class Re {
    constructor(A) {
        ((this.ESP_RAM_BLOCK = 6144),
            (this.ESP_FLASH_BEGIN = 2),
            (this.ESP_FLASH_DATA = 3),
            (this.ESP_FLASH_END = 4),
            (this.ESP_MEM_BEGIN = 5),
            (this.ESP_MEM_END = 6),
            (this.ESP_MEM_DATA = 7),
            (this.ESP_WRITE_REG = 9),
            (this.ESP_READ_REG = 10),
            (this.ESP_SPI_ATTACH = 13),
            (this.ESP_CHANGE_BAUDRATE = 15),
            (this.ESP_FLASH_DEFL_BEGIN = 16),
            (this.ESP_FLASH_DEFL_DATA = 17),
            (this.ESP_FLASH_DEFL_END = 18),
            (this.ESP_SPI_FLASH_MD5 = 19),
            (this.ESP_ERASE_FLASH = 208),
            (this.ESP_ERASE_REGION = 209),
            (this.ESP_READ_FLASH = 210),
            (this.ESP_RUN_USER_CODE = 211),
            (this.ESP_IMAGE_MAGIC = 233),
            (this.ESP_CHECKSUM_MAGIC = 239),
            (this.ROM_INVALID_RECV_MSG = 5),
            (this.ERASE_REGION_TIMEOUT_PER_MB = 3e4),
            (this.ERASE_WRITE_TIMEOUT_PER_MB = 4e4),
            (this.MD5_TIMEOUT_PER_MB = 8e3),
            (this.CHIP_ERASE_TIMEOUT = 12e4),
            (this.FLASH_READ_TIMEOUT = 1e5),
            (this.MAX_TIMEOUT = 2 * this.CHIP_ERASE_TIMEOUT),
            (this.CHIP_DETECT_MAGIC_REG_ADDR = 1073745920),
            (this.DETECTED_FLASH_SIZES = {
                18: "256KB",
                19: "512KB",
                20: "1MB",
                21: "2MB",
                22: "4MB",
                23: "8MB",
                24: "16MB",
            }),
            (this.DETECTED_FLASH_SIZES_NUM = { 18: 256, 19: 512, 20: 1024, 21: 2048, 22: 4096, 23: 8192, 24: 16384 }),
            (this.USB_JTAG_SERIAL_PID = 4097),
            (this.romBaudrate = 115200),
            (this.debugLogging = !1),
            (this.syncStubDetected = !1),
            (this.checksum = function (A) {
                let t,
                    e = 239;
                for (t = 0; t < A.length; t++) e ^= A[t];
                return e;
            }),
            (this.timeoutPerMb = function (A, t) {
                const e = A * (t / 1e6);
                return e < 3e3 ? 3e3 : e;
            }),
            (this.flashSizeBytes = function (A) {
                let t = -1;
                return (
                    -1 !== A.indexOf("KB")
                        ? (t = 1024 * parseInt(A.slice(0, A.indexOf("KB"))))
                        : -1 !== A.indexOf("MB") && (t = 1024 * parseInt(A.slice(0, A.indexOf("MB"))) * 1024),
                    t
                );
            }),
            (this.IS_STUB = !1),
            (this.FLASH_WRITE_SIZE = 16384),
            (this.transport = A.transport),
            (this.baudrate = A.baudrate),
            A.serialOptions && (this.serialOptions = A.serialOptions),
            A.romBaudrate && (this.romBaudrate = A.romBaudrate),
            A.terminal && ((this.terminal = A.terminal), this.terminal.clean()),
            void 0 !== A.debugLogging && (this.debugLogging = A.debugLogging),
            A.port && (this.transport = new Ce(A.port)),
            void 0 !== A.enableTracing && (this.transport.tracing = A.enableTracing),
            this.info("esptool.js"),
            this.info("Serial port " + this.transport.getInfo()));
    }
    _sleep(A) {
        return new Promise((t) => setTimeout(t, A));
    }
    write(A, t = !0) {
        this.terminal ? (t ? this.terminal.writeLine(A) : this.terminal.write(A)) : console.log(A);
    }
    error(A, t = !0) {
        this.write(`Error: ${A}`, t);
    }
    info(A, t = !0) {
        this.write(A, t);
    }
    debug(A, t = !0) {
        this.debugLogging && this.write(`Debug: ${A}`, t);
    }
    _shortToBytearray(A) {
        return new Uint8Array([255 & A, (A >> 8) & 255]);
    }
    _intToByteArray(A) {
        return new Uint8Array([255 & A, (A >> 8) & 255, (A >> 16) & 255, (A >> 24) & 255]);
    }
    _byteArrayToShort(A, t) {
        return A | (t >> 8);
    }
    _byteArrayToInt(A, t, e, i) {
        return A | (t << 8) | (e << 16) | (i << 24);
    }
    _appendBuffer(A, t) {
        const e = new Uint8Array(A.byteLength + t.byteLength);
        return (e.set(new Uint8Array(A), 0), e.set(new Uint8Array(t), A.byteLength), e.buffer);
    }
    _appendArray(A, t) {
        const e = new Uint8Array(A.length + t.length);
        return (e.set(A, 0), e.set(t, A.length), e);
    }
    ui8ToBstr(A) {
        let t = "";
        for (let e = 0; e < A.length; e++) t += String.fromCharCode(A[e]);
        return t;
    }
    bstrToUi8(A) {
        const t = new Uint8Array(A.length);
        for (let e = 0; e < A.length; e++) t[e] = A.charCodeAt(e);
        return t;
    }
    async flushInput() {
        try {
            await this.transport.rawRead(200);
        } catch (A) {
            this.error(A.message);
        }
    }
    async readPacket(t = null, e = 3e3) {
        for (let i = 0; i < 100; i++) {
            const i = await this.transport.read(e),
                s = i[0],
                a = i[1],
                n = this._byteArrayToInt(i[4], i[5], i[6], i[7]),
                h = i.slice(8);
            if (1 == s) {
                if (null == t || a == t) return [n, h];
                if (0 != h[0] && h[1] == this.ROM_INVALID_RECV_MSG)
                    throw (await this.flushInput(), new A("unsupported command error"));
            }
        }
        throw new A("invalid response");
    }
    async command(A = null, t = new Uint8Array(0), e = 0, i = !0, s = 3e3) {
        if (null != A) {
            this.transport.tracing &&
                this.transport.trace(
                    `command op:0x${A.toString(16).padStart(2, "0")} data len=${t.length} wait_response=${i ? 1 : 0} timeout=${(s / 1e3).toFixed(3)} data=${this.transport.hexConvert(t)}`
                );
            const a = new Uint8Array(8 + t.length);
            let n;
            for (
                a[0] = 0,
                    a[1] = A,
                    a[2] = this._shortToBytearray(t.length)[0],
                    a[3] = this._shortToBytearray(t.length)[1],
                    a[4] = this._intToByteArray(e)[0],
                    a[5] = this._intToByteArray(e)[1],
                    a[6] = this._intToByteArray(e)[2],
                    a[7] = this._intToByteArray(e)[3],
                    n = 0;
                n < t.length;
                n++
            )
                a[8 + n] = t[n];
            await this.transport.write(a);
        }
        return i ? this.readPacket(A, s) : [0, new Uint8Array(0)];
    }
    async readReg(A, t = 3e3) {
        const e = this._intToByteArray(A);
        return (await this.command(this.ESP_READ_REG, e, void 0, void 0, t))[0];
    }
    async writeReg(A, t, e = 4294967295, i = 0, s = 0) {
        let a = this._appendArray(this._intToByteArray(A), this._intToByteArray(t));
        ((a = this._appendArray(a, this._intToByteArray(e))),
            (a = this._appendArray(a, this._intToByteArray(i))),
            s > 0 &&
                ((a = this._appendArray(a, this._intToByteArray(this.chip.UART_DATE_REG_ADDR))),
                (a = this._appendArray(a, this._intToByteArray(0))),
                (a = this._appendArray(a, this._intToByteArray(0))),
                (a = this._appendArray(a, this._intToByteArray(s)))),
            await this.checkCommand("write target memory", this.ESP_WRITE_REG, a));
    }
    async sync() {
        this.debug("Sync");
        const A = new Uint8Array(36);
        let t;
        for (A[0] = 7, A[1] = 7, A[2] = 18, A[3] = 32, t = 0; t < 32; t++) A[4 + t] = 85;
        try {
            const t = await this.command(8, A, void 0, void 0, 100);
            return ((this.syncStubDetected = this.syncStubDetected && 0 === t[0]), t);
        } catch (A) {
            throw (this.debug("Sync err " + A), A);
        }
    }
    async _connectAttempt(A = "default_reset", t = !1) {
        if ((this.debug("_connect_attempt " + A + " " + t), "no_reset" !== A))
            if (this.transport.getPid() === this.USB_JTAG_SERIAL_PID) await de(this.transport);
            else {
                const A = t ? "D0|R1|W100|W2000|D1|R0|W50|D0" : "D0|R1|W100|D1|R0|W50|D0";
                await Qe(this.transport, A);
            }
        let e = 0,
            i = !0;
        for (; i; ) {
            try {
                e += (await this.transport.read(1e3)).length;
            } catch (A) {
                if ((this.debug(A.message), A instanceof Error)) {
                    i = !1;
                    break;
                }
            }
            await this._sleep(50);
        }
        for (this.transport.slipReaderEnabled = !0, this.syncStubDetected = !0, e = 7; e--; ) {
            try {
                const A = await this.sync();
                return (this.debug(A[0].toString()), "success");
            } catch (A) {
                A instanceof Error && (t ? this.info("_", !1) : this.info(".", !1));
            }
            await this._sleep(50);
        }
        return "error";
    }
    async connect(t = "default_reset", e = 7, i = !1) {
        let s, a;
        for (
            this.info("Connecting...", !1), await this.transport.connect(this.romBaudrate, this.serialOptions), s = 0;
            s < e &&
            ((a = await this._connectAttempt(t, !1)), "success" !== a) &&
            ((a = await this._connectAttempt(t, !0)), "success" !== a);
            s++
        );
        if ("success" !== a) throw new A("Failed to connect with the device");
        if ((this.info("\n\r", !1), !i)) {
            const t = (await this.readReg(1073745920)) >>> 0;
            this.debug("Chip Magic " + t.toString(16));
            const e = await (async function (A) {
                switch (A) {
                    case 15736195: {
                        const { ESP32ROM: A } = await Promise.resolve().then(function () {
                            return He;
                        });
                        return new A();
                    }
                    case 1867591791:
                    case 2084675695: {
                        const { ESP32C2ROM: A } = await Promise.resolve().then(function () {
                            return ve;
                        });
                        return new A();
                    }
                    case 1763790959:
                    case 456216687:
                    case 1216438383:
                    case 1130455151: {
                        const { ESP32C3ROM: A } = await Promise.resolve().then(function () {
                            return Ye;
                        });
                        return new A();
                    }
                    case 752910447: {
                        const { ESP32C6ROM: A } = await Promise.resolve().then(function () {
                            return Xe;
                        });
                        return new A();
                    }
                    case 3619110528: {
                        const { ESP32H2ROM: A } = await Promise.resolve().then(function () {
                            return ii;
                        });
                        return new A();
                    }
                    case 9: {
                        const { ESP32S3ROM: A } = await Promise.resolve().then(function () {
                            return Ei;
                        });
                        return new A();
                    }
                    case 1990: {
                        const { ESP32S2ROM: A } = await Promise.resolve().then(function () {
                            return Ii;
                        });
                        return new A();
                    }
                    case 4293968129: {
                        const { ESP8266ROM: A } = await Promise.resolve().then(function () {
                            return Mi;
                        });
                        return new A();
                    }
                    case 0:
                    case 182303440:
                    case 117676761: {
                        const { ESP32P4ROM: A } = await Promise.resolve().then(function () {
                            return ui;
                        });
                        return new A();
                    }
                    default:
                        return null;
                }
            })(t);
            if (null === this.chip) throw new A(`Unexpected CHIP magic value ${t}. Failed to autodetect chip type.`);
            this.chip = e;
        }
    }
    async detectChip(A = "default_reset") {
        (await this.connect(A),
            this.info("Detecting chip type... ", !1),
            null != this.chip ? this.info(this.chip.CHIP_NAME) : this.info("unknown!"));
    }
    async checkCommand(A = "", t = null, e = new Uint8Array(0), i = 0, s = 3e3) {
        this.debug("check_command " + A);
        const a = await this.command(t, e, i, void 0, s);
        return a[1].length > 4 ? a[1] : a[0];
    }
    async memBegin(A, t, e, i) {
        this.debug("mem_begin " + A + " " + t + " " + e + " " + i.toString(16));
        let s = this._appendArray(this._intToByteArray(A), this._intToByteArray(t));
        ((s = this._appendArray(s, this._intToByteArray(e))),
            (s = this._appendArray(s, this._intToByteArray(i))),
            await this.checkCommand("enter RAM download mode", this.ESP_MEM_BEGIN, s));
    }
    async memBlock(A, t) {
        let e = this._appendArray(this._intToByteArray(A.length), this._intToByteArray(t));
        ((e = this._appendArray(e, this._intToByteArray(0))),
            (e = this._appendArray(e, this._intToByteArray(0))),
            (e = this._appendArray(e, A)));
        const i = this.checksum(A);
        await this.checkCommand("write to target RAM", this.ESP_MEM_DATA, e, i);
    }
    async memFinish(A) {
        const t = 0 === A ? 1 : 0,
            e = this._appendArray(this._intToByteArray(t), this._intToByteArray(A));
        await this.checkCommand("leave RAM download mode", this.ESP_MEM_END, e, void 0, 50);
    }
    async flashSpiAttach(A) {
        const t = this._intToByteArray(A);
        await this.checkCommand("configure SPI flash pins", this.ESP_SPI_ATTACH, t);
    }
    async flashBegin(A, t) {
        const e = Math.floor((A + this.FLASH_WRITE_SIZE - 1) / this.FLASH_WRITE_SIZE),
            i = this.chip.getEraseSize(t, A),
            s = new Date(),
            a = s.getTime();
        let n = 3e3;
        (0 == this.IS_STUB && (n = this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB, A)),
            this.debug("flash begin " + i + " " + e + " " + this.FLASH_WRITE_SIZE + " " + t + " " + A));
        let h = this._appendArray(this._intToByteArray(i), this._intToByteArray(e));
        ((h = this._appendArray(h, this._intToByteArray(this.FLASH_WRITE_SIZE))),
            (h = this._appendArray(h, this._intToByteArray(t))),
            0 == this.IS_STUB && (h = this._appendArray(h, this._intToByteArray(0))),
            await this.checkCommand("enter Flash download mode", this.ESP_FLASH_BEGIN, h, void 0, n));
        const r = s.getTime();
        return (
            0 != A &&
                0 == this.IS_STUB &&
                this.info("Took " + (r - a) / 1e3 + "." + ((r - a) % 1e3) + "s to erase flash block"),
            e
        );
    }
    async flashDeflBegin(A, t, e) {
        const i = Math.floor((t + this.FLASH_WRITE_SIZE - 1) / this.FLASH_WRITE_SIZE),
            s = Math.floor((A + this.FLASH_WRITE_SIZE - 1) / this.FLASH_WRITE_SIZE),
            a = new Date(),
            n = a.getTime();
        let h, r;
        (this.IS_STUB
            ? ((h = A), (r = 3e3))
            : ((h = s * this.FLASH_WRITE_SIZE), (r = this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB, h))),
            this.info("Compressed " + A + " bytes to " + t + "..."));
        let E = this._appendArray(this._intToByteArray(h), this._intToByteArray(i));
        ((E = this._appendArray(E, this._intToByteArray(this.FLASH_WRITE_SIZE))),
            (E = this._appendArray(E, this._intToByteArray(e))),
            ("ESP32-S2" !== this.chip.CHIP_NAME &&
                "ESP32-S3" !== this.chip.CHIP_NAME &&
                "ESP32-C3" !== this.chip.CHIP_NAME &&
                "ESP32-C2" !== this.chip.CHIP_NAME) ||
                !1 !== this.IS_STUB ||
                (E = this._appendArray(E, this._intToByteArray(0))),
            await this.checkCommand("enter compressed flash mode", this.ESP_FLASH_DEFL_BEGIN, E, void 0, r));
        const g = a.getTime();
        return (
            0 != A &&
                !1 === this.IS_STUB &&
                this.info("Took " + (g - n) / 1e3 + "." + ((g - n) % 1e3) + "s to erase flash block"),
            i
        );
    }
    async flashBlock(A, t, e) {
        let i = this._appendArray(this._intToByteArray(A.length), this._intToByteArray(t));
        ((i = this._appendArray(i, this._intToByteArray(0))),
            (i = this._appendArray(i, this._intToByteArray(0))),
            (i = this._appendArray(i, A)));
        const s = this.checksum(A);
        await this.checkCommand("write to target Flash after seq " + t, this.ESP_FLASH_DATA, i, s, e);
    }
    async flashDeflBlock(A, t, e) {
        let i = this._appendArray(this._intToByteArray(A.length), this._intToByteArray(t));
        ((i = this._appendArray(i, this._intToByteArray(0))),
            (i = this._appendArray(i, this._intToByteArray(0))),
            (i = this._appendArray(i, A)));
        const s = this.checksum(A);
        (this.debug("flash_defl_block " + A[0].toString(16) + " " + A[1].toString(16)),
            await this.checkCommand(
                "write compressed data to flash after seq " + t,
                this.ESP_FLASH_DEFL_DATA,
                i,
                s,
                e
            ));
    }
    async flashFinish(A = !1) {
        const t = A ? 0 : 1,
            e = this._intToByteArray(t);
        await this.checkCommand("leave Flash mode", this.ESP_FLASH_END, e);
    }
    async flashDeflFinish(A = !1) {
        const t = A ? 0 : 1,
            e = this._intToByteArray(t);
        await this.checkCommand("leave compressed flash mode", this.ESP_FLASH_DEFL_END, e);
    }
    async runSpiflashCommand(t, e, i) {
        const s = this.chip.SPI_REG_BASE,
            a = s + 0,
            n = s + this.chip.SPI_USR_OFFS,
            h = s + this.chip.SPI_USR1_OFFS,
            r = s + this.chip.SPI_USR2_OFFS,
            E = s + this.chip.SPI_W0_OFFS;
        let g;
        g =
            null != this.chip.SPI_MOSI_DLEN_OFFS
                ? async (A, t) => {
                      const e = s + this.chip.SPI_MOSI_DLEN_OFFS,
                          i = s + this.chip.SPI_MISO_DLEN_OFFS;
                      (A > 0 && (await this.writeReg(e, A - 1)), t > 0 && (await this.writeReg(i, t - 1)));
                  }
                : async (A, t) => {
                      const e = h,
                          i = ((0 === t ? 0 : t - 1) << 8) | ((0 === A ? 0 : A - 1) << 17);
                      await this.writeReg(e, i);
                  };
        const o = 1 << 18;
        if (i > 32) throw new A("Reading more than 32 bits back from a SPI flash operation is unsupported");
        if (e.length > 64) throw new A("Writing more than 64 bytes of data with one SPI command is unsupported");
        const B = 8 * e.length,
            w = await this.readReg(n),
            c = await this.readReg(r);
        let I,
            C = 1 << 31;
        (i > 0 && (C |= 268435456), B > 0 && (C |= 134217728), await g(B, i), await this.writeReg(n, C));
        let l = (7 << 28) | t;
        if ((await this.writeReg(r, l), 0 == B)) await this.writeReg(E, 0);
        else {
            if (e.length % 4 != 0) {
                const A = new Uint8Array(e.length % 4);
                e = this._appendArray(e, A);
            }
            let A = E;
            for (I = 0; I < e.length - 4; I += 4)
                ((l = this._byteArrayToInt(e[I], e[I + 1], e[I + 2], e[I + 3])), await this.writeReg(A, l), (A += 4));
        }
        for (await this.writeReg(a, o), I = 0; I < 10 && ((l = (await this.readReg(a)) & o), 0 != l); I++);
        if (10 === I) throw new A("SPI command did not complete in time");
        const _ = await this.readReg(E);
        return (await this.writeReg(n, w), await this.writeReg(r, c), _);
    }
    async readFlashId() {
        const A = new Uint8Array(0);
        return await this.runSpiflashCommand(159, A, 24);
    }
    async eraseFlash() {
        this.info("Erasing flash (this may take a while)...");
        let A = new Date();
        const t = A.getTime(),
            e = await this.checkCommand("erase flash", this.ESP_ERASE_FLASH, void 0, void 0, this.CHIP_ERASE_TIMEOUT);
        A = new Date();
        const i = A.getTime();
        return (this.info("Chip erase completed successfully in " + (i - t) / 1e3 + "s"), e);
    }
    toHex(A) {
        return Array.prototype.map.call(A, (A) => ("00" + A.toString(16)).slice(-2)).join("");
    }
    async flashMd5sum(A, t) {
        const e = this.timeoutPerMb(this.MD5_TIMEOUT_PER_MB, t);
        let i = this._appendArray(this._intToByteArray(A), this._intToByteArray(t));
        ((i = this._appendArray(i, this._intToByteArray(0))), (i = this._appendArray(i, this._intToByteArray(0))));
        let s = await this.checkCommand("calculate md5sum", this.ESP_SPI_FLASH_MD5, i, void 0, e);
        s instanceof Uint8Array && s.length > 16 && (s = s.slice(0, 16));
        return this.toHex(s);
    }
    async readFlash(t, e, i = null) {
        let s = this._appendArray(this._intToByteArray(t), this._intToByteArray(e));
        ((s = this._appendArray(s, this._intToByteArray(4096))),
            (s = this._appendArray(s, this._intToByteArray(1024))));
        const a = await this.checkCommand("read flash", this.ESP_READ_FLASH, s);
        if (0 != a) throw new A("Failed to read memory: " + a);
        let n = new Uint8Array(0);
        for (; n.length < e; ) {
            const t = await this.transport.read(this.FLASH_READ_TIMEOUT);
            if (!(t instanceof Uint8Array)) throw new A("Failed to read memory: " + t);
            t.length > 0 &&
                ((n = this._appendArray(n, t)),
                await this.transport.write(this._intToByteArray(n.length)),
                i && i(t, n.length, e));
        }
        return n;
    }
    async runStub() {
        if (this.syncStubDetected) return (this.info("Stub is already running. No upload is necessary."), this.chip);
        this.info("Uploading stub...");
        let t = Se(this.chip.ROM_TEXT),
            e = t.split("").map(function (A) {
                return A.charCodeAt(0);
            });
        const i = new Uint8Array(e);
        ((t = Se(this.chip.ROM_DATA)),
            (e = t.split("").map(function (A) {
                return A.charCodeAt(0);
            })));
        const s = new Uint8Array(e);
        let a,
            n = Math.floor((i.length + this.ESP_RAM_BLOCK - 1) / this.ESP_RAM_BLOCK);
        for (await this.memBegin(i.length, n, this.ESP_RAM_BLOCK, this.chip.TEXT_START), a = 0; a < n; a++) {
            const A = a * this.ESP_RAM_BLOCK,
                t = A + this.ESP_RAM_BLOCK;
            await this.memBlock(i.slice(A, t), a);
        }
        for (
            n = Math.floor((s.length + this.ESP_RAM_BLOCK - 1) / this.ESP_RAM_BLOCK),
                await this.memBegin(s.length, n, this.ESP_RAM_BLOCK, this.chip.DATA_START),
                a = 0;
            a < n;
            a++
        ) {
            const A = a * this.ESP_RAM_BLOCK,
                t = A + this.ESP_RAM_BLOCK;
            await this.memBlock(s.slice(A, t), a);
        }
        (this.info("Running stub..."), await this.memFinish(this.chip.ENTRY));
        for (let A = 0; A < 100; A++) {
            const A = await this.transport.read(1e3, 6);
            if (79 === A[0] && 72 === A[1] && 65 === A[2] && 73 === A[3])
                return (this.info("Stub running..."), (this.IS_STUB = !0), (this.FLASH_WRITE_SIZE = 16384), this.chip);
        }
        throw new A("Failed to start stub. Unexpected response");
    }
    async changeBaud() {
        this.info("Changing baudrate to " + this.baudrate);
        const A = this.IS_STUB ? this.transport.baudrate : 0,
            t = this._appendArray(this._intToByteArray(this.baudrate), this._intToByteArray(A)),
            e = await this.command(this.ESP_CHANGE_BAUDRATE, t);
        (this.debug(e[0].toString()),
            this.info("Changed"),
            await this.transport.disconnect(),
            await this._sleep(50),
            await this.transport.connect(this.baudrate, this.serialOptions));
        try {
            let A = 64;
            for (; A--; ) {
                try {
                    await this.sync();
                    break;
                } catch (A) {
                    this.debug(A.message);
                }
                await this._sleep(10);
            }
        } catch (A) {
            this.debug(A.message);
        }
    }
    async main(A = "default_reset") {
        await this.detectChip(A);
        const t = await this.chip.getChipDescription(this);
        return (
            this.info("Chip is " + t),
            this.info("Features: " + (await this.chip.getChipFeatures(this))),
            this.info("Crystal is " + (await this.chip.getCrystalFreq(this)) + "MHz"),
            this.info("MAC: " + (await this.chip.readMac(this))),
            await this.chip.readMac(this),
            void 0 !== this.chip.postConnect && (await this.chip.postConnect(this)),
            await this.runStub(),
            this.romBaudrate !== this.baudrate && (await this.changeBaud()),
            t
        );
    }
    parseFlashSizeArg(t) {
        if (void 0 === this.chip.FLASH_SIZES[t])
            throw new A(
                "Flash size " + t + " is not supported by this chip type. Supported sizes: " + this.chip.FLASH_SIZES
            );
        return this.chip.FLASH_SIZES[t];
    }
    _updateImageFlashParams(A, t, e, i, s) {
        if ((this.debug("_update_image_flash_params " + e + " " + i + " " + s), A.length < 8)) return A;
        if (t != this.chip.BOOTLOADER_FLASH_OFFSET) return A;
        if ("keep" === e && "keep" === i && "keep" === s) return (this.info("Not changing the image"), A);
        const a = parseInt(A[0]);
        let n = parseInt(A[2]);
        const h = parseInt(A[3]);
        if (a !== this.ESP_IMAGE_MAGIC)
            return (
                this.info(
                    "Warning: Image file at 0x" +
                        t.toString(16) +
                        " doesn't look like an image file, so not changing any flash settings."
                ),
                A
            );
        if ("keep" !== i) {
            n = { qio: 0, qout: 1, dio: 2, dout: 3 }[i];
        }
        let r = 15 & h;
        if ("keep" !== s) {
            r = { "40m": 0, "26m": 1, "20m": 2, "80m": 15 }[s];
        }
        let E = 240 & h;
        "keep" !== e && (E = this.parseFlashSizeArg(e));
        const g = (n << 8) | (r + E);
        return (
            this.info("Flash params set to " + g.toString(16)),
            parseInt(A[2]) !== n << 8 && (A = A.substring(0, 2) + (n << 8).toString() + A.substring(3)),
            parseInt(A[3]) !== r + E && (A = A.substring(0, 3) + (r + E).toString() + A.substring(4)),
            A
        );
    }
    async writeFlash(t) {
        if ((this.debug("EspLoader program"), "keep" !== t.flashSize)) {
            const e = this.flashSizeBytes(t.flashSize);
            for (let i = 0; i < t.fileArray.length; i++)
                if (t.fileArray[i].data.length + t.fileArray[i].address > e)
                    throw new A(`File ${i + 1} doesn't fit in the available flash`);
        }
        let e, i;
        !0 === this.IS_STUB && !0 === t.eraseAll && (await this.eraseFlash());
        for (let s = 0; s < t.fileArray.length; s++) {
            (this.debug("Data Length " + t.fileArray[s].data.length), (e = t.fileArray[s].data));
            const a = t.fileArray[s].data.length % 4;
            if (
                (a > 0 && (e += "ÿÿÿÿ".substring(4 - a)),
                (i = t.fileArray[s].address),
                this.debug("Image Length " + e.length),
                0 === e.length)
            ) {
                this.debug("Warning: File is empty");
                continue;
            }
            e = this._updateImageFlashParams(e, i, t.flashSize, t.flashMode, t.flashFreq);
            let n = null;
            t.calculateMD5Hash && ((n = t.calculateMD5Hash(e)), this.debug("Image MD5 " + n));
            const h = e.length;
            let r;
            if (t.compress) {
                const A = this.bstrToUi8(e);
                ((e = this.ui8ToBstr(ce(A, { level: 9 }))), (r = await this.flashDeflBegin(h, e.length, i)));
            } else r = await this.flashBegin(h, i);
            let E = 0,
                g = 0;
            const o = e.length;
            t.reportProgress && t.reportProgress(s, 0, o);
            let B = new Date();
            const w = B.getTime();
            let c = 5e3;
            const I = new Ie({ chunkSize: 1 });
            let C = 0;
            for (
                I.onData = function (A) {
                    C += A.byteLength;
                };
                e.length > 0;
            ) {
                (this.debug("Write loop " + i + " " + E + " " + r),
                    this.info(
                        "Writing at 0x" + (i + C).toString(16) + "... (" + Math.floor((100 * (E + 1)) / r) + "%)"
                    ));
                const a = this.bstrToUi8(e.slice(0, this.FLASH_WRITE_SIZE));
                if (!t.compress) throw new A("Yet to handle Non Compressed writes");
                {
                    const A = C;
                    I.push(a, !1);
                    const t = C - A;
                    let e = 3e3;
                    (this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB, t) > 3e3 &&
                        (e = this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB, t)),
                        !1 === this.IS_STUB && (c = e),
                        await this.flashDeflBlock(a, E, c),
                        this.IS_STUB && (c = e));
                }
                ((g += a.length),
                    (e = e.slice(this.FLASH_WRITE_SIZE, e.length)),
                    E++,
                    t.reportProgress && t.reportProgress(s, g, o));
            }
            (this.IS_STUB && (await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR, c)), (B = new Date()));
            const l = B.getTime() - w;
            if (
                (t.compress &&
                    this.info(
                        "Wrote " +
                            h +
                            " bytes (" +
                            g +
                            " compressed) at 0x" +
                            i.toString(16) +
                            " in " +
                            l / 1e3 +
                            " seconds."
                    ),
                n)
            ) {
                const t = await this.flashMd5sum(i, h);
                if (new String(t).valueOf() != new String(n).valueOf())
                    throw (
                        this.info("File  md5: " + n),
                        this.info("Flash md5: " + t),
                        new A("MD5 of file does not match data in flash!")
                    );
                this.info("Hash of data verified.");
            }
        }
        (this.info("Leaving..."),
            this.IS_STUB &&
                (await this.flashBegin(0, 0), t.compress ? await this.flashDeflFinish() : await this.flashFinish()));
    }
    async flashId() {
        this.debug("flash_id");
        const A = await this.readFlashId();
        this.info("Manufacturer: " + (255 & A).toString(16));
        const t = (A >> 16) & 255;
        (this.info("Device: " + ((A >> 8) & 255).toString(16) + t.toString(16)),
            this.info("Detected flash size: " + this.DETECTED_FLASH_SIZES[t]));
    }
    async getFlashSize() {
        this.debug("flash_id");
        const A = ((await this.readFlashId()) >> 16) & 255;
        return this.DETECTED_FLASH_SIZES_NUM[A];
    }
    async hardReset() {
        (await this.transport.setRTS(!0), await this._sleep(100), await this.transport.setRTS(!1));
    }
    async softReset() {
        if (this.IS_STUB) {
            if ("ESP8266" != this.chip.CHIP_NAME) throw new A("Soft resetting is currently only supported on ESP8266");
            await this.command(this.ESP_RUN_USER_CODE, void 0, void 0, !1);
        } else (await this.flashBegin(0, 0), await this.flashFinish(!1));
    }
}
class fe {
    getEraseSize(A, t) {
        return t;
    }
}
var Fe = 1074521560,
    ue =
        "[encoded data, 4556 characters]",
    Te = 1074520064,
    ye =
        "GOv8P9jnC0Bx6AtA8+wLQO3oC0CP6AtA7egLQEnpC0AG6gtAeOoLQCHqC0CB5wtAo+kLQPjpC0Bn6QtAmuoLQI7pC0Ca6gtAXegLQLPoC0Dt6AtASekLQHfoC0BM6wtAs+wLQKXmC0DX7AtApeYLQKXmC0Cl5gtApeYLQKXmC0Cl5gtApeYLQKXmC0Dz6gtApeYLQM3rC0Cz7AtA",
    pe = 1073605544;
class ke extends fe {
    constructor() {
        (super(...arguments),
            (this.CHIP_NAME = "ESP32"),
            (this.IMAGE_CHIP_ID = 0),
            (this.EFUSE_RD_REG_BASE = 1073061888),
            (this.DR_REG_SYSCON_BASE = 1073111040),
            (this.UART_CLKDIV_REG = 1072955412),
            (this.UART_CLKDIV_MASK = 1048575),
            (this.UART_DATE_REG_ADDR = 1610612856),
            (this.XTAL_CLK_DIVIDER = 1),
            (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
            (this.FLASH_WRITE_SIZE = 1024),
            (this.BOOTLOADER_FLASH_OFFSET = 4096),
            (this.SPI_REG_BASE = 1072963584),
            (this.SPI_USR_OFFS = 28),
            (this.SPI_USR1_OFFS = 32),
            (this.SPI_USR2_OFFS = 36),
            (this.SPI_W0_OFFS = 128),
            (this.SPI_MOSI_DLEN_OFFS = 40),
            (this.SPI_MISO_DLEN_OFFS = 44),
            (this.TEXT_START = Te),
            (this.ENTRY = Fe),
            (this.DATA_START = pe),
            (this.ROM_DATA = ye),
            (this.ROM_TEXT = ue));
    }
    async readEfuse(A, t) {
        const e = this.EFUSE_RD_REG_BASE + 4 * t;
        return (A.debug("Read efuse " + e), await A.readReg(e));
    }
    async getPkgVersion(A) {
        const t = await this.readEfuse(A, 3);
        let e = (t >> 9) & 7;
        return ((e += ((t >> 2) & 1) << 3), e);
    }
    async getChipRevision(A) {
        const t = await this.readEfuse(A, 3),
            e = await this.readEfuse(A, 5),
            i = await A.readReg(this.DR_REG_SYSCON_BASE + 124);
        return 0 != ((t >> 15) & 1) ? (0 != ((e >> 20) & 1) ? (0 != ((i >> 31) & 1) ? 3 : 2) : 1) : 0;
    }
    async getChipDescription(A) {
        const t = ["ESP32-D0WDQ6", "ESP32-D0WD", "ESP32-D2WD", "", "ESP32-U4WDH", "ESP32-PICO-D4", "ESP32-PICO-V3-02"];
        let e = "";
        const i = await this.getPkgVersion(A),
            s = await this.getChipRevision(A),
            a = 3 == s;
        return (
            0 != (1 & (await this.readEfuse(A, 3))) && ((t[0] = "ESP32-S0WDQ6"), (t[1] = "ESP32-S0WD")),
            a && (t[5] = "ESP32-PICO-V3"),
            (e = i >= 0 && i <= 6 ? t[i] : "Unknown ESP32"),
            !a || (0 !== i && 1 !== i) || (e += "-V3"),
            e + " (revision " + s + ")"
        );
    }
    async getChipFeatures(A) {
        const t = ["Wi-Fi"],
            e = await this.readEfuse(A, 3);
        0 === (2 & e) && t.push(" BT");
        0 !== (1 & e) ? t.push(" Single Core") : t.push(" Dual Core");
        if (0 !== (8192 & e)) {
            0 !== (4096 & e) ? t.push(" 160MHz") : t.push(" 240MHz");
        }
        const i = await this.getPkgVersion(A);
        (-1 !== [2, 4, 5, 6].indexOf(i) && t.push(" Embedded Flash"), 6 === i && t.push(" Embedded PSRAM"));
        0 !== (((await this.readEfuse(A, 4)) >> 8) & 31) && t.push(" VRef calibration in efuse");
        0 !== ((e >> 14) & 1) && t.push(" BLK3 partially reserved");
        const s = 3 & (await this.readEfuse(A, 6));
        return (t.push(" Coding Scheme " + ["None", "3/4", "Repeat (UNSUPPORTED)", "Invalid"][s]), t);
    }
    async getCrystalFreq(A) {
        const t = (await A.readReg(this.UART_CLKDIV_REG)) & this.UART_CLKDIV_MASK,
            e = (A.transport.baudrate * t) / 1e6 / this.XTAL_CLK_DIVIDER;
        let i;
        return ((i = e > 33 ? 40 : 26), Math.abs(i - e) > 1 && A.info("WARNING: Unsupported crystal in use"), i);
    }
    _d2h(A) {
        const t = (+A).toString(16);
        return 1 === t.length ? "0" + t : t;
    }
    async readMac(A) {
        let t = await this.readEfuse(A, 1);
        t >>>= 0;
        let e = await this.readEfuse(A, 2);
        e >>>= 0;
        const i = new Uint8Array(6);
        return (
            (i[0] = (e >> 8) & 255),
            (i[1] = 255 & e),
            (i[2] = (t >> 24) & 255),
            (i[3] = (t >> 16) & 255),
            (i[4] = (t >> 8) & 255),
            (i[5] = 255 & t),
            this._d2h(i[0]) +
                ":" +
                this._d2h(i[1]) +
                ":" +
                this._d2h(i[2]) +
                ":" +
                this._d2h(i[3]) +
                ":" +
                this._d2h(i[4]) +
                ":" +
                this._d2h(i[5])
        );
    }
}
var He = Object.freeze({ __proto__: null, ESP32ROM: ke }),
    Pe = 1077413532,
    me =
        "[encoded data, 5000 characters]",
    Oe = 1077411840,
    Ge =
        "IGvIP3YKOEDGCjhAHgs4QMILOEAuDDhA3As4QEIJOEB+CzhAvgs4QDILOEDyCDhAZgs4QPIIOEBQCjhAlgo4QMYKOEAeCzhAYgo4QKYJOEDWCThAXgo4QIAOOEDGCjhARg04QDgOOEAyCDhAYA44QDIIOEAyCDhAMgg4QDIIOEAyCDhAMgg4QDIIOEAyCDhA4gw4QDIIOEBkDThAOA44QA==",
    Ue = 1070164912;
class be extends fe {
    constructor() {
        (super(...arguments),
            (this.CHIP_NAME = "ESP32-C3"),
            (this.IMAGE_CHIP_ID = 5),
            (this.EFUSE_BASE = 1610647552),
            (this.MAC_EFUSE_REG = this.EFUSE_BASE + 68),
            (this.UART_CLKDIV_REG = 1072955412),
            (this.UART_CLKDIV_MASK = 1048575),
            (this.UART_DATE_REG_ADDR = 1610612860),
            (this.FLASH_WRITE_SIZE = 1024),
            (this.BOOTLOADER_FLASH_OFFSET = 0),
            (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
            (this.SPI_REG_BASE = 1610620928),
            (this.SPI_USR_OFFS = 24),
            (this.SPI_USR1_OFFS = 28),
            (this.SPI_USR2_OFFS = 32),
            (this.SPI_MOSI_DLEN_OFFS = 36),
            (this.SPI_MISO_DLEN_OFFS = 40),
            (this.SPI_W0_OFFS = 88),
            (this.TEXT_START = Oe),
            (this.ENTRY = Pe),
            (this.DATA_START = Ue),
            (this.ROM_DATA = Ge),
            (this.ROM_TEXT = me));
    }
    async getPkgVersion(A) {
        const t = this.EFUSE_BASE + 68 + 12;
        return ((await A.readReg(t)) >> 21) & 7;
    }
    async getChipRevision(A) {
        const t = this.EFUSE_BASE + 68 + 12;
        return ((await A.readReg(t)) & (7 << 18)) >> 18;
    }
    async getChipDescription(A) {
        let t;
        t = 0 === (await this.getPkgVersion(A)) ? "ESP32-C3" : "unknown ESP32-C3";
        return ((t += " (revision " + (await this.getChipRevision(A)) + ")"), t);
    }
    async getChipFeatures(A) {
        return ["Wi-Fi"];
    }
    async getCrystalFreq(A) {
        return 40;
    }
    _d2h(A) {
        const t = (+A).toString(16);
        return 1 === t.length ? "0" + t : t;
    }
    async readMac(A) {
        let t = await A.readReg(this.MAC_EFUSE_REG);
        t >>>= 0;
        let e = await A.readReg(this.MAC_EFUSE_REG + 4);
        e = (e >>> 0) & 65535;
        const i = new Uint8Array(6);
        return (
            (i[0] = (e >> 8) & 255),
            (i[1] = 255 & e),
            (i[2] = (t >> 24) & 255),
            (i[3] = (t >> 16) & 255),
            (i[4] = (t >> 8) & 255),
            (i[5] = 255 & t),
            this._d2h(i[0]) +
                ":" +
                this._d2h(i[1]) +
                ":" +
                this._d2h(i[2]) +
                ":" +
                this._d2h(i[3]) +
                ":" +
                this._d2h(i[4]) +
                ":" +
                this._d2h(i[5])
        );
    }
    getEraseSize(A, t) {
        return t;
    }
}
var Ye = Object.freeze({ __proto__: null, ESP32C3ROM: be }),
    Ke = 1077413304,
    xe =
        "[encoded data, 4508 characters]",
    Le = 1077411840,
    Je =
        "DEDKP+AIOEAsCThAhAk4QFIKOEC+CjhAbAo4QKgHOEAOCjhATgo4QJgJOEBYBzhAzAk4QFgHOEC6CDhA/gg4QCwJOECECThAzAg4QBIIOEBCCDhAyAg4QBYNOEAsCThA1gs4QMoMOECkBjhA9Aw4QKQGOECkBjhApAY4QKQGOECkBjhApAY4QKQGOECkBjhAcgs4QKQGOEDyCzhAygw4QA==",
    ze = 1070295976;
var ve = Object.freeze({
        __proto__: null,
        ESP32C2ROM: class extends be {
            constructor() {
                (super(...arguments),
                    (this.CHIP_NAME = "ESP32-C2"),
                    (this.IMAGE_CHIP_ID = 12),
                    (this.EFUSE_BASE = 1610647552),
                    (this.MAC_EFUSE_REG = this.EFUSE_BASE + 64),
                    (this.UART_CLKDIV_REG = 1610612756),
                    (this.UART_CLKDIV_MASK = 1048575),
                    (this.UART_DATE_REG_ADDR = 1610612860),
                    (this.XTAL_CLK_DIVIDER = 1),
                    (this.FLASH_WRITE_SIZE = 1024),
                    (this.BOOTLOADER_FLASH_OFFSET = 0),
                    (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
                    (this.SPI_REG_BASE = 1610620928),
                    (this.SPI_USR_OFFS = 24),
                    (this.SPI_USR1_OFFS = 28),
                    (this.SPI_USR2_OFFS = 32),
                    (this.SPI_MOSI_DLEN_OFFS = 36),
                    (this.SPI_MISO_DLEN_OFFS = 40),
                    (this.SPI_W0_OFFS = 88),
                    (this.TEXT_START = Le),
                    (this.ENTRY = Ke),
                    (this.DATA_START = ze),
                    (this.ROM_DATA = Je),
                    (this.ROM_TEXT = xe));
            }
            async getPkgVersion(A) {
                const t = this.EFUSE_BASE + 64 + 4;
                return ((await A.readReg(t)) >> 22) & 7;
            }
            async getChipRevision(A) {
                const t = this.EFUSE_BASE + 64 + 4;
                return ((await A.readReg(t)) & (3 << 20)) >> 20;
            }
            async getChipDescription(A) {
                let t;
                const e = await this.getPkgVersion(A);
                t = 0 === e || 1 === e ? "ESP32-C2" : "unknown ESP32-C2";
                return ((t += " (revision " + (await this.getChipRevision(A)) + ")"), t);
            }
            async getChipFeatures(A) {
                return ["Wi-Fi", "BLE"];
            }
            async getCrystalFreq(A) {
                const t = (await A.readReg(this.UART_CLKDIV_REG)) & this.UART_CLKDIV_MASK,
                    e = (A.transport.baudrate * t) / 1e6 / this.XTAL_CLK_DIVIDER;
                let i;
                return (
                    (i = e > 33 ? 40 : 26),
                    Math.abs(i - e) > 1 && A.info("WARNING: Unsupported crystal in use"),
                    i
                );
            }
            async changeBaudRate(A) {
                26 === (await this.getCrystalFreq(A)) && A.changeBaud();
            }
            _d2h(A) {
                const t = (+A).toString(16);
                return 1 === t.length ? "0" + t : t;
            }
            async readMac(A) {
                let t = await A.readReg(this.MAC_EFUSE_REG);
                t >>>= 0;
                let e = await A.readReg(this.MAC_EFUSE_REG + 4);
                e = (e >>> 0) & 65535;
                const i = new Uint8Array(6);
                return (
                    (i[0] = (e >> 8) & 255),
                    (i[1] = 255 & e),
                    (i[2] = (t >> 24) & 255),
                    (i[3] = (t >> 16) & 255),
                    (i[4] = (t >> 8) & 255),
                    (i[5] = 255 & t),
                    this._d2h(i[0]) +
                        ":" +
                        this._d2h(i[1]) +
                        ":" +
                        this._d2h(i[2]) +
                        ":" +
                        this._d2h(i[3]) +
                        ":" +
                        this._d2h(i[4]) +
                        ":" +
                        this._d2h(i[5])
                );
            }
            getEraseSize(A, t) {
                return t;
            }
        },
    }),
    Ne = 1082132112,
    Ze =
        "[encoded data, 4928 characters]",
    je = 1082130432,
    We =
        "HCuEQEIKgECSCoBA6gqAQI4LgED6C4BAqAuAQA4JgEBKC4BAiguAQP4KgEC+CIBAMguAQL4IgEAcCoBAYgqAQJIKgEDqCoBALgqAQHIJgECiCYBAKgqAQEwOgECSCoBAEg2AQAQOgED+B4BALA6AQP4HgED+B4BA/geAQP4HgED+B4BA/geAQP4HgED+B4BArgyAQP4HgEAwDYBABA6AQA==",
    qe = 1082469292;
var Xe = Object.freeze({
        __proto__: null,
        ESP32C6ROM: class extends fe {
            constructor() {
                (super(...arguments),
                    (this.CHIP_NAME = "ESP32-C6"),
                    (this.IMAGE_CHIP_ID = 13),
                    (this.EFUSE_BASE = 1611335680),
                    (this.MAC_EFUSE_REG = this.EFUSE_BASE + 68),
                    (this.UART_CLKDIV_REG = 1072955412),
                    (this.UART_CLKDIV_MASK = 1048575),
                    (this.UART_DATE_REG_ADDR = 1610612860),
                    (this.FLASH_WRITE_SIZE = 1024),
                    (this.BOOTLOADER_FLASH_OFFSET = 0),
                    (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
                    (this.SPI_REG_BASE = 1610620928),
                    (this.SPI_USR_OFFS = 24),
                    (this.SPI_USR1_OFFS = 28),
                    (this.SPI_USR2_OFFS = 32),
                    (this.SPI_MOSI_DLEN_OFFS = 36),
                    (this.SPI_MISO_DLEN_OFFS = 40),
                    (this.SPI_W0_OFFS = 88),
                    (this.TEXT_START = je),
                    (this.ENTRY = Ne),
                    (this.DATA_START = qe),
                    (this.ROM_DATA = We),
                    (this.ROM_TEXT = Ze));
            }
            async getPkgVersion(A) {
                const t = this.EFUSE_BASE + 68 + 12;
                return ((await A.readReg(t)) >> 21) & 7;
            }
            async getChipRevision(A) {
                const t = this.EFUSE_BASE + 68 + 12;
                return ((await A.readReg(t)) & (7 << 18)) >> 18;
            }
            async getChipDescription(A) {
                let t;
                t = 0 === (await this.getPkgVersion(A)) ? "ESP32-C6" : "unknown ESP32-C6";
                return ((t += " (revision " + (await this.getChipRevision(A)) + ")"), t);
            }
            async getChipFeatures(A) {
                return ["Wi-Fi"];
            }
            async getCrystalFreq(A) {
                return 40;
            }
            _d2h(A) {
                const t = (+A).toString(16);
                return 1 === t.length ? "0" + t : t;
            }
            async readMac(A) {
                let t = await A.readReg(this.MAC_EFUSE_REG);
                t >>>= 0;
                let e = await A.readReg(this.MAC_EFUSE_REG + 4);
                e = (e >>> 0) & 65535;
                const i = new Uint8Array(6);
                return (
                    (i[0] = (e >> 8) & 255),
                    (i[1] = 255 & e),
                    (i[2] = (t >> 24) & 255),
                    (i[3] = (t >> 16) & 255),
                    (i[4] = (t >> 8) & 255),
                    (i[5] = 255 & t),
                    this._d2h(i[0]) +
                        ":" +
                        this._d2h(i[1]) +
                        ":" +
                        this._d2h(i[2]) +
                        ":" +
                        this._d2h(i[3]) +
                        ":" +
                        this._d2h(i[4]) +
                        ":" +
                        this._d2h(i[5])
                );
            }
            getEraseSize(A, t) {
                return t;
            }
        },
    }),
    Ve = 1082132112,
    $e =
        "[encoded data, 4936 characters]",
    Ai = 1082130432,
    ti =
        "EACDQEIKgECSCoBA6gqAQI4LgED6C4BAqAuAQA4JgEBKC4BAiguAQP4KgEC+CIBAMguAQL4IgEAcCoBAYgqAQJIKgEDqCoBALgqAQHIJgECiCYBAKgqAQFIOgECSCoBAEg2AQAoOgED+B4BAMg6AQP4HgED+B4BA/geAQP4HgED+B4BA/geAQP4HgED+B4BArgyAQP4HgEAwDYBACg6AQA==",
    ei = 1082403756;
var ii = Object.freeze({
        __proto__: null,
        ESP32H2ROM: class extends fe {
            constructor() {
                (super(...arguments),
                    (this.CHIP_NAME = "ESP32-H2"),
                    (this.IMAGE_CHIP_ID = 16),
                    (this.EFUSE_BASE = 1610647552),
                    (this.MAC_EFUSE_REG = this.EFUSE_BASE + 68),
                    (this.UART_CLKDIV_REG = 1072955412),
                    (this.UART_CLKDIV_MASK = 1048575),
                    (this.UART_DATE_REG_ADDR = 1610612860),
                    (this.FLASH_WRITE_SIZE = 1024),
                    (this.BOOTLOADER_FLASH_OFFSET = 0),
                    (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
                    (this.SPI_REG_BASE = 1610620928),
                    (this.SPI_USR_OFFS = 24),
                    (this.SPI_USR1_OFFS = 28),
                    (this.SPI_USR2_OFFS = 32),
                    (this.SPI_MOSI_DLEN_OFFS = 36),
                    (this.SPI_MISO_DLEN_OFFS = 40),
                    (this.SPI_W0_OFFS = 88),
                    (this.USB_RAM_BLOCK = 2048),
                    (this.UARTDEV_BUF_NO_USB = 3),
                    (this.UARTDEV_BUF_NO = 1070526796),
                    (this.TEXT_START = Ai),
                    (this.ENTRY = Ve),
                    (this.DATA_START = ei),
                    (this.ROM_DATA = ti),
                    (this.ROM_TEXT = $e));
            }
            async getChipDescription(A) {
                return this.CHIP_NAME;
            }
            async getChipFeatures(A) {
                return ["BLE", "IEEE802.15.4"];
            }
            async getCrystalFreq(A) {
                return 32;
            }
            _d2h(A) {
                const t = (+A).toString(16);
                return 1 === t.length ? "0" + t : t;
            }
            async postConnect(A) {
                const t = 255 & (await A.readReg(this.UARTDEV_BUF_NO));
                (A.debug("In _post_connect " + t),
                    t == this.UARTDEV_BUF_NO_USB && (A.ESP_RAM_BLOCK = this.USB_RAM_BLOCK));
            }
            async readMac(A) {
                let t = await A.readReg(this.MAC_EFUSE_REG);
                t >>>= 0;
                let e = await A.readReg(this.MAC_EFUSE_REG + 4);
                e = (e >>> 0) & 65535;
                const i = new Uint8Array(6);
                return (
                    (i[0] = (e >> 8) & 255),
                    (i[1] = 255 & e),
                    (i[2] = (t >> 24) & 255),
                    (i[3] = (t >> 16) & 255),
                    (i[4] = (t >> 8) & 255),
                    (i[5] = 255 & t),
                    this._d2h(i[0]) +
                        ":" +
                        this._d2h(i[1]) +
                        ":" +
                        this._d2h(i[2]) +
                        ":" +
                        this._d2h(i[3]) +
                        ":" +
                        this._d2h(i[4]) +
                        ":" +
                        this._d2h(i[5])
                );
            }
            getEraseSize(A, t) {
                return t;
            }
        },
    }),
    si = 1077381696,
    ai =
        "[encoded data, 6768 characters]",
    ni = 1077379072,
    hi =
        "ZCvKP8qNN0CvjjdAcJM3QDqPN0DPjjdAOo83QJmPN0BmkDdA2ZA3QIGQN0BVjTdA/I83QFiQN0C8jzdA+5A3QOaPN0D7kDdAnY43QPqON0A6jzdAmY83QLWON0CWjTdAvJE3QDaTN0ByjDdAVpM3QHKMN0ByjDdAcow3QHKMN0ByjDdAcow3QHKMN0ByjDdAVpE3QHKMN0BRkjdANpM3QAQInwAAAAAAAAAYAQQIBQAAAAAAAAAIAQQIBgAAAAAAAAAAAQQIIQAAAAAAIAAAEQQI3AAAAAAAIAAAEQQIDAAAAAAAIAAAAQQIEgAAAAAAIAAAESAoDAAQAQAA",
    ri = 1070279668;
var Ei = Object.freeze({
        __proto__: null,
        ESP32S3ROM: class extends fe {
            constructor() {
                (super(...arguments),
                    (this.CHIP_NAME = "ESP32-S3"),
                    (this.IMAGE_CHIP_ID = 9),
                    (this.EFUSE_BASE = 1610641408),
                    (this.MAC_EFUSE_REG = this.EFUSE_BASE + 68),
                    (this.UART_CLKDIV_REG = 1610612756),
                    (this.UART_CLKDIV_MASK = 1048575),
                    (this.UART_DATE_REG_ADDR = 1610612864),
                    (this.FLASH_WRITE_SIZE = 1024),
                    (this.BOOTLOADER_FLASH_OFFSET = 0),
                    (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
                    (this.SPI_REG_BASE = 1610620928),
                    (this.SPI_USR_OFFS = 24),
                    (this.SPI_USR1_OFFS = 28),
                    (this.SPI_USR2_OFFS = 32),
                    (this.SPI_MOSI_DLEN_OFFS = 36),
                    (this.SPI_MISO_DLEN_OFFS = 40),
                    (this.SPI_W0_OFFS = 88),
                    (this.USB_RAM_BLOCK = 2048),
                    (this.UARTDEV_BUF_NO_USB = 3),
                    (this.UARTDEV_BUF_NO = 1070526796),
                    (this.TEXT_START = ni),
                    (this.ENTRY = si),
                    (this.DATA_START = ri),
                    (this.ROM_DATA = hi),
                    (this.ROM_TEXT = ai));
            }
            async getChipDescription(A) {
                return "ESP32-S3";
            }
            async getChipFeatures(A) {
                return ["Wi-Fi", "BLE"];
            }
            async getCrystalFreq(A) {
                return 40;
            }
            _d2h(A) {
                const t = (+A).toString(16);
                return 1 === t.length ? "0" + t : t;
            }
            async postConnect(A) {
                const t = 255 & (await A.readReg(this.UARTDEV_BUF_NO));
                (A.debug("In _post_connect " + t),
                    t == this.UARTDEV_BUF_NO_USB && (A.ESP_RAM_BLOCK = this.USB_RAM_BLOCK));
            }
            async readMac(A) {
                let t = await A.readReg(this.MAC_EFUSE_REG);
                t >>>= 0;
                let e = await A.readReg(this.MAC_EFUSE_REG + 4);
                e = (e >>> 0) & 65535;
                const i = new Uint8Array(6);
                return (
                    (i[0] = (e >> 8) & 255),
                    (i[1] = 255 & e),
                    (i[2] = (t >> 24) & 255),
                    (i[3] = (t >> 16) & 255),
                    (i[4] = (t >> 8) & 255),
                    (i[5] = 255 & t),
                    this._d2h(i[0]) +
                        ":" +
                        this._d2h(i[1]) +
                        ":" +
                        this._d2h(i[2]) +
                        ":" +
                        this._d2h(i[3]) +
                        ":" +
                        this._d2h(i[4]) +
                        ":" +
                        this._d2h(i[5])
                );
            }
            getEraseSize(A, t) {
                return t;
            }
        },
    }),
    gi = 1073907696,
    oi =
        "[encoded data, 5784 characters]",
    Bi = 1073905664,
    wi =
        "ZCv9PzaLAkDBiwJAhpACQEqMAkDjiwJASowCQKmMAkByjQJA5Y0CQI2NAkDAigJAC40CQGSNAkDMjAJACI4CQPaMAkAIjgJAr4sCQA6MAkBKjAJAqYwCQMeLAkACiwJAx44CQD2QAkDYiQJAZZACQNiJAkDYiQJA2IkCQNiJAkDYiQJA2IkCQNiJAkDYiQJAZI4CQNiJAkBZjwJAPZACQA==",
    ci = 1073622012;
var Ii = Object.freeze({
        __proto__: null,
        ESP32S2ROM: class extends fe {
            constructor() {
                (super(...arguments),
                    (this.CHIP_NAME = "ESP32-S2"),
                    (this.IMAGE_CHIP_ID = 2),
                    (this.MAC_EFUSE_REG = 1061265476),
                    (this.EFUSE_BASE = 1061265408),
                    (this.UART_CLKDIV_REG = 1061158932),
                    (this.UART_CLKDIV_MASK = 1048575),
                    (this.UART_DATE_REG_ADDR = 1610612856),
                    (this.FLASH_WRITE_SIZE = 1024),
                    (this.BOOTLOADER_FLASH_OFFSET = 4096),
                    (this.FLASH_SIZES = { "1MB": 0, "2MB": 16, "4MB": 32, "8MB": 48, "16MB": 64 }),
                    (this.SPI_REG_BASE = 1061167104),
                    (this.SPI_USR_OFFS = 24),
                    (this.SPI_USR1_OFFS = 28),
                    (this.SPI_USR2_OFFS = 32),
                    (this.SPI_W0_OFFS = 88),
                    (this.SPI_MOSI_DLEN_OFFS = 36),
                    (this.SPI_MISO_DLEN_OFFS = 40),
                    (this.TEXT_START = Bi),
                    (this.ENTRY = gi),
                    (this.DATA_START = ci),
                    (this.ROM_DATA = wi),
                    (this.ROM_TEXT = oi));
            }
            async getPkgVersion(A) {
                const t = this.EFUSE_BASE + 68 + 12;
                return ((await A.readReg(t)) >> 21) & 15;
            }
            async getChipDescription(A) {
                const t = ["ESP32-S2", "ESP32-S2FH16", "ESP32-S2FH32"],
                    e = await this.getPkgVersion(A);
                return e >= 0 && e <= 2 ? t[e] : "unknown ESP32-S2";
            }
            async getChipFeatures(A) {
                const t = ["Wi-Fi"],
                    e = await this.getPkgVersion(A);
                1 == e ? t.push("Embedded 2MB Flash") : 2 == e && t.push("Embedded 4MB Flash");
                const i = this.EFUSE_BASE + 92 + 16;
                return (
                    1 == (((await A.readReg(i)) >> 4) & 7) &&
                        t.push("ADC and temperature sensor calibration in BLK2 of efuse"),
                    t
                );
            }
            async getCrystalFreq(A) {
                return 40;
            }
            _d2h(A) {
                const t = (+A).toString(16);
                return 1 === t.length ? "0" + t : t;
            }
            async readMac(A) {
                let t = await A.readReg(this.MAC_EFUSE_REG);
                t >>>= 0;
                let e = await A.readReg(this.MAC_EFUSE_REG + 4);
                e = (e >>> 0) & 65535;
                const i = new Uint8Array(6);
                return (
                    (i[0] = (e >> 8) & 255),
                    (i[1] = 255 & e),
                    (i[2] = (t >> 24) & 255),
                    (i[3] = (t >> 16) & 255),
                    (i[4] = (t >> 8) & 255),
                    (i[5] = 255 & t),
                    this._d2h(i[0]) +
                        ":" +
                        this._d2h(i[1]) +
                        ":" +
                        this._d2h(i[2]) +
                        ":" +
                        this._d2h(i[3]) +
                        ":" +
                        this._d2h(i[4]) +
                        ":" +
                        this._d2h(i[5])
                );
            }
            getEraseSize(A, t) {
                return t;
            }
        },
    }),
    Ci = 1074843652,
    li =
        "[encoded data, 10976 characters]",
    _i = 1074843648,
    di =
        "CIH+PwUFBAACAwcAAwMLALnXEEDv1xBAHdgQQLrYEEBo5xBAHtkQQHTZEEDA2RBAaOcQQILaEED/2hBAwNsQQGjnEEBo5xBAWNwQQGjnEEA33xBAAOAQQDvgEEBo5xBAaOcQQNfgEEBo5xBAv+EQQGXiEECj4xBAY+QQQDTlEEBo5xBAaOcQQGjnEEBo5xBAYuYQQGjnEEBX5xBAkN0QQI/YEECm5RBAq9oQQPzZEEBo5xBA7OYQQDHnEEBo5xBAaOcQQGjnEEBo5xBAaOcQQGjnEEBo5xBAaOcQQCLaEEBf2hBAvuUQQAEAAAACAAAAAwAAAAQAAAAFAAAABwAAAAkAAAANAAAAEQAAABkAAAAhAAAAMQAAAEEAAABhAAAAgQAAAMEAAAABAQAAgQEAAAECAAABAwAAAQQAAAEGAAABCAAAAQwAAAEQAAABGAAAASAAAAEwAAABQAAAAWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAUAAAAGAAAABgAAAAcAAAAHAAAACAAAAAgAAAAJAAAACQAAAAoAAAAKAAAACwAAAAsAAAAMAAAADAAAAA0AAAANAAAAAAAAAAAAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAANAAAADwAAABEAAAATAAAAFwAAABsAAAAfAAAAIwAAACsAAAAzAAAAOwAAAEMAAABTAAAAYwAAAHMAAACDAAAAowAAAMMAAADjAAAAAgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAgAAAAMAAAADAAAAAwAAAAMAAAAEAAAABAAAAAQAAAAEAAAABQAAAAUAAAAFAAAABQAAAAAAAAAAAAAAAAAAABAREgAIBwkGCgULBAwDDQIOAQ8AAQEAAAEAAAAEAAAA",
    Di = 1073720488;
var Mi = Object.freeze({
        __proto__: null,
        ESP8266ROM: class extends fe {
            constructor() {
                (super(...arguments),
                    (this.CHIP_NAME = "ESP8266"),
                    (this.CHIP_DETECT_MAGIC_VALUE = [4293968129]),
                    (this.EFUSE_RD_REG_BASE = 1072693328),
                    (this.UART_CLKDIV_REG = 1610612756),
                    (this.UART_CLKDIV_MASK = 1048575),
                    (this.XTAL_CLK_DIVIDER = 2),
                    (this.FLASH_WRITE_SIZE = 16384),
                    (this.BOOTLOADER_FLASH_OFFSET = 0),
                    (this.UART_DATE_REG_ADDR = 0),
                    (this.FLASH_SIZES = {
                        "512KB": 0,
                        "256KB": 16,
                        "1MB": 32,
                        "2MB": 48,
                        "4MB": 64,
                        "2MB-c1": 80,
                        "4MB-c1": 96,
                        "8MB": 128,
                        "16MB": 144,
                    }),
                    (this.SPI_REG_BASE = 1610613248),
                    (this.SPI_USR_OFFS = 28),
                    (this.SPI_USR1_OFFS = 32),
                    (this.SPI_USR2_OFFS = 36),
                    (this.SPI_MOSI_DLEN_OFFS = 0),
                    (this.SPI_MISO_DLEN_OFFS = 0),
                    (this.SPI_W0_OFFS = 64),
                    (this.TEXT_START = _i),
                    (this.ENTRY = Ci),
                    (this.DATA_START = Di),
                    (this.ROM_DATA = di),
                    (this.ROM_TEXT = li),
                    (this.getChipFeatures = async (A) => {
                        const t = ["WiFi"];
                        return ("ESP8285" == (await this.getChipDescription(A)) && t.push("Embedded Flash"), t);
                    }));
            }
            async readEfuse(A, t) {
                const e = this.EFUSE_RD_REG_BASE + 4 * t;
                return (A.debug("Read efuse " + e), await A.readReg(e));
            }
            async getChipDescription(A) {
                const t = await this.readEfuse(A, 2);
                return 0 != ((16 & (await this.readEfuse(A, 0))) | (65536 & t)) ? "ESP8285" : "ESP8266EX";
            }
            async getCrystalFreq(A) {
                const t = (await A.readReg(this.UART_CLKDIV_REG)) & this.UART_CLKDIV_MASK,
                    e = (A.transport.baudrate * t) / 1e6 / this.XTAL_CLK_DIVIDER;
                let i;
                return (
                    (i = e > 33 ? 40 : 26),
                    Math.abs(i - e) > 1 &&
                        A.info(
                            "WARNING: Detected crystal freq " +
                                e +
                                "MHz is quite different to normalized freq " +
                                i +
                                "MHz. Unsupported crystal in use?"
                        ),
                    i
                );
            }
            _d2h(A) {
                const t = (+A).toString(16);
                return 1 === t.length ? "0" + t : t;
            }
            async readMac(A) {
                let t = await this.readEfuse(A, 0);
                t >>>= 0;
                let e = await this.readEfuse(A, 1);
                e >>>= 0;
                let i = await this.readEfuse(A, 3);
                i >>>= 0;
                const s = new Uint8Array(6);
                return (
                    0 != i
                        ? ((s[0] = (i >> 16) & 255), (s[1] = (i >> 8) & 255), (s[2] = 255 & i))
                        : 0 == ((e >> 16) & 255)
                          ? ((s[0] = 24), (s[1] = 254), (s[2] = 52))
                          : 1 == ((e >> 16) & 255)
                            ? ((s[0] = 172), (s[1] = 208), (s[2] = 116))
                            : A.error("Unknown OUI"),
                    (s[3] = (e >> 8) & 255),
                    (s[4] = 255 & e),
                    (s[5] = (t >> 24) & 255),
                    this._d2h(s[0]) +
                        ":" +
                        this._d2h(s[1]) +
                        ":" +
                        this._d2h(s[2]) +
                        ":" +
                        this._d2h(s[3]) +
                        ":" +
                        this._d2h(s[4]) +
                        ":" +
                        this._d2h(s[5])
                );
            }
            getEraseSize(A, t) {
                return t;
            }
        },
    }),
    Qi = 1341195918,
    Si =
        "[encoded data, 4908 characters]",
    Ri = 1341194240,
    fi =
        "EAD1TwYK8U9WCvFPrgrxT4QL8U/wC/FPngvxT9QI8U9AC/FPgAvxT8IK8U+ECPFP9grxT4QI8U/gCfFPJgrxT1YK8U+uCvFP8gnxTzgJ8U9oCfFP7gnxT0AO8U9WCvFPCA3xTwAO8U/EB/FPJA7xT8QH8U/EB/FPxAfxT8QH8U/EB/FPxAfxT8QH8U/EB/FPpAzxT8QH8U8mDfFPAA7xTw==",
    Fi = 1341533100;
var ui = Object.freeze({
    __proto__: null,
    ESP32P4ROM: class extends ke {
        constructor() {
            (super(...arguments),
                (this.CHIP_NAME = "ESP32-P4"),
                (this.IMAGE_CHIP_ID = 18),
                (this.IROM_MAP_START = 1073741824),
                (this.IROM_MAP_END = 1275068416),
                (this.DROM_MAP_START = 1073741824),
                (this.DROM_MAP_END = 1275068416),
                (this.BOOTLOADER_FLASH_OFFSET = 8192),
                (this.CHIP_DETECT_MAGIC_VALUE = [0, 182303440]),
                (this.UART_DATE_REG_ADDR = 1343004812),
                (this.EFUSE_BASE = 1343410176),
                (this.EFUSE_BLOCK1_ADDR = this.EFUSE_BASE + 68),
                (this.MAC_EFUSE_REG = this.EFUSE_BASE + 68),
                (this.SPI_REG_BASE = 1342754816),
                (this.SPI_USR_OFFS = 24),
                (this.SPI_USR1_OFFS = 28),
                (this.SPI_USR2_OFFS = 32),
                (this.SPI_MOSI_DLEN_OFFS = 36),
                (this.SPI_MISO_DLEN_OFFS = 40),
                (this.SPI_W0_OFFS = 88),
                (this.EFUSE_RD_REG_BASE = this.EFUSE_BASE + 48),
                (this.EFUSE_PURPOSE_KEY0_REG = this.EFUSE_BASE + 52),
                (this.EFUSE_PURPOSE_KEY0_SHIFT = 24),
                (this.EFUSE_PURPOSE_KEY1_REG = this.EFUSE_BASE + 52),
                (this.EFUSE_PURPOSE_KEY1_SHIFT = 28),
                (this.EFUSE_PURPOSE_KEY2_REG = this.EFUSE_BASE + 56),
                (this.EFUSE_PURPOSE_KEY2_SHIFT = 0),
                (this.EFUSE_PURPOSE_KEY3_REG = this.EFUSE_BASE + 56),
                (this.EFUSE_PURPOSE_KEY3_SHIFT = 4),
                (this.EFUSE_PURPOSE_KEY4_REG = this.EFUSE_BASE + 56),
                (this.EFUSE_PURPOSE_KEY4_SHIFT = 8),
                (this.EFUSE_PURPOSE_KEY5_REG = this.EFUSE_BASE + 56),
                (this.EFUSE_PURPOSE_KEY5_SHIFT = 12),
                (this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG = this.EFUSE_RD_REG_BASE),
                (this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT = 1 << 20),
                (this.EFUSE_SPI_BOOT_CRYPT_CNT_REG = this.EFUSE_BASE + 52),
                (this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK = 7 << 18),
                (this.EFUSE_SECURE_BOOT_EN_REG = this.EFUSE_BASE + 56),
                (this.EFUSE_SECURE_BOOT_EN_MASK = 1 << 20),
                (this.PURPOSE_VAL_XTS_AES256_KEY_1 = 2),
                (this.PURPOSE_VAL_XTS_AES256_KEY_2 = 3),
                (this.PURPOSE_VAL_XTS_AES128_KEY = 4),
                (this.SUPPORTS_ENCRYPTED_FLASH = !0),
                (this.FLASH_ENCRYPTED_WRITE_ALIGN = 16),
                (this.MEMORY_MAP = [
                    [0, 65536, "PADDING"],
                    [1073741824, 1275068416, "DROM"],
                    [1341128704, 1341784064, "DRAM"],
                    [1341128704, 1341784064, "BYTE_ACCESSIBLE"],
                    [1337982976, 1338114048, "DROM_MASK"],
                    [1337982976, 1338114048, "IROM_MASK"],
                    [1073741824, 1275068416, "IROM"],
                    [1341128704, 1341784064, "IRAM"],
                    [1343258624, 1343291392, "RTC_IRAM"],
                    [1343258624, 1343291392, "RTC_DRAM"],
                    [1611653120, 1611661312, "MEM_INTERNAL2"],
                ]),
                (this.UF2_FAMILY_ID = 1026592404),
                (this.EFUSE_MAX_KEY = 5),
                (this.KEY_PURPOSES = {
                    0: "USER/EMPTY",
                    1: "ECDSA_KEY",
                    2: "XTS_AES_256_KEY_1",
                    3: "XTS_AES_256_KEY_2",
                    4: "XTS_AES_128_KEY",
                    5: "HMAC_DOWN_ALL",
                    6: "HMAC_DOWN_JTAG",
                    7: "HMAC_DOWN_DIGITAL_SIGNATURE",
                    8: "HMAC_UP",
                    9: "SECURE_BOOT_DIGEST0",
                    10: "SECURE_BOOT_DIGEST1",
                    11: "SECURE_BOOT_DIGEST2",
                    12: "KM_INIT_KEY",
                }),
                (this.TEXT_START = Ri),
                (this.ENTRY = Qi),
                (this.DATA_START = Fi),
                (this.ROM_DATA = fi),
                (this.ROM_TEXT = Si));
        }
        async getPkgVersion(A) {
            const t = this.EFUSE_BLOCK1_ADDR + 8;
            return ((await A.readReg(t)) >> 27) & 7;
        }
        async getMinorChipVersion(A) {
            const t = this.EFUSE_BLOCK1_ADDR + 8;
            return ((await A.readReg(t)) >> 0) & 15;
        }
        async getMajorChipVersion(A) {
            const t = this.EFUSE_BLOCK1_ADDR + 8;
            return ((await A.readReg(t)) >> 4) & 3;
        }
        async getChipDescription(A) {
            return `${0 === (await this.getPkgVersion(A)) ? "ESP32-P4" : "unknown ESP32-P4"} (revision v${await this.getMajorChipVersion(A)}.${await this.getMinorChipVersion(A)})`;
        }
        async getChipFeatures(A) {
            return ["High-Performance MCU"];
        }
        async getCrystalFreq(A) {
            return 40;
        }
        async getFlashVoltage(A) {}
        async overrideVddsdio(A) {
            A.debug("VDD_SDIO overrides are not supported for ESP32-P4");
        }
        async readMac(A) {
            let t = await A.readReg(this.MAC_EFUSE_REG);
            t >>>= 0;
            let e = await A.readReg(this.MAC_EFUSE_REG + 4);
            e = (e >>> 0) & 65535;
            const i = new Uint8Array(6);
            return (
                (i[0] = (e >> 8) & 255),
                (i[1] = 255 & e),
                (i[2] = (t >> 24) & 255),
                (i[3] = (t >> 16) & 255),
                (i[4] = (t >> 8) & 255),
                (i[5] = 255 & t),
                this._d2h(i[0]) +
                    ":" +
                    this._d2h(i[1]) +
                    ":" +
                    this._d2h(i[2]) +
                    ":" +
                    this._d2h(i[3]) +
                    ":" +
                    this._d2h(i[4]) +
                    ":" +
                    this._d2h(i[5])
            );
        }
        async getFlashCryptConfig(A) {}
        async getSecureBootEnabled(A) {
            return (await A.readReg(this.EFUSE_SECURE_BOOT_EN_REG)) & this.EFUSE_SECURE_BOOT_EN_MASK;
        }
        async getKeyBlockPurpose(A, t) {
            if (t < 0 || t > this.EFUSE_MAX_KEY)
                return void A.debug(`Valid key block numbers must be in range 0-${this.EFUSE_MAX_KEY}`);
            const e = [
                    [this.EFUSE_PURPOSE_KEY0_REG, this.EFUSE_PURPOSE_KEY0_SHIFT],
                    [this.EFUSE_PURPOSE_KEY1_REG, this.EFUSE_PURPOSE_KEY1_SHIFT],
                    [this.EFUSE_PURPOSE_KEY2_REG, this.EFUSE_PURPOSE_KEY2_SHIFT],
                    [this.EFUSE_PURPOSE_KEY3_REG, this.EFUSE_PURPOSE_KEY3_SHIFT],
                    [this.EFUSE_PURPOSE_KEY4_REG, this.EFUSE_PURPOSE_KEY4_SHIFT],
                    [this.EFUSE_PURPOSE_KEY5_REG, this.EFUSE_PURPOSE_KEY5_SHIFT],
                ],
                [i, s] = e[t];
            return ((await A.readReg(i)) >> s) & 15;
        }
        async isFlashEncryptionKeyValid(A) {
            const t = [];
            for (let e = 0; e <= this.EFUSE_MAX_KEY; e++) {
                const i = await this.getKeyBlockPurpose(A, e);
                t.push(i);
            }
            if (void 0 !== typeof t.find((A) => A === this.PURPOSE_VAL_XTS_AES128_KEY)) return !0;
            const e = t.find((A) => A === this.PURPOSE_VAL_XTS_AES256_KEY_1),
                i = t.find((A) => A === this.PURPOSE_VAL_XTS_AES256_KEY_2);
            return void 0 !== typeof e && void 0 !== typeof i;
        }
    },
});
export {
    Re as ESPLoader,
    fe as ROM,
    Ce as Transport,
    _e as classicReset,
    Qe as customReset,
    De as hardReset,
    de as usbJTAGSerialReset,
    Me as validateCustomResetStringSequence,
};
