import { f as mi } from "./dist-6d707927.js";
if (typeof window < "u") {
  var De, Le;
  ((De = (Le = window).__svelte ?? (Le.__svelte = {})).v ?? (De.v = /* @__PURE__ */ new Set())).add("5");
}
var Qt = {}, R = /* @__PURE__ */ Symbol("uninitialized"), $i = Array.isArray, bi = Array.prototype.indexOf, Dn = Array.prototype.includes, _i = Array.from, Ln = Object.keys, Fn = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ki = Object.getOwnPropertyDescriptors, Mi = Object.prototype, Ti = Array.prototype, ar = Object.getPrototypeOf, Fe = Object.isExtensible, Si = () => {
};
function Ci(t) {
  for (var n = 0; n < t.length; n++) t[n]();
}
function ur() {
  var t, n;
  return {
    promise: new Promise((e, r) => {
      t = e, n = r;
    }),
    resolve: t,
    reject: n
  };
}
function fn(t) {
  "@babel/helpers - typeof";
  return fn = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
    return typeof n;
  } : function(n) {
    return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
  }, fn(t);
}
function xi(t, n) {
  if (fn(t) != "object" || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (e !== void 0) {
    var r = e.call(t, n || "default");
    if (fn(r) != "object") return r;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (n === "string" ? String : Number)(t);
}
function Wi(t) {
  var n = xi(t, "string");
  return fn(n) == "symbol" ? n : n + "";
}
function x(t, n, e) {
  return (n = Wi(n)) in t ? Object.defineProperty(t, n, {
    value: e,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[n] = e, t;
}
var Q = 1024, Z = 2048, qt = 4096, _e = 8192, Ei = 16384, ke = 32768, Ie = 1 << 25, Me = 65536, nn = 1 << 19, Pi = 1 << 20, gn = 65536, Be = 1 << 21, ji = 1 << 22, In = 1 << 23, an = /* @__PURE__ */ Symbol("$state"), cr = /* @__PURE__ */ Symbol("legacy props"), Ai = /* @__PURE__ */ Symbol(""), he = /* @__PURE__ */ Symbol("attributes"), Ni = /* @__PURE__ */ Symbol("class"), Oi = /* @__PURE__ */ Symbol("style"), Nn = /* @__PURE__ */ Symbol("text"), Xn = new class extends Error {
  constructor(...t) {
    super(...t), x(this, "name", "StaleReactionError"), x(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed");
  }
}(), Ri = !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml");
function zi(t) {
  throw new Error("https://svelte.dev/e/lifecycle_outside_component");
}
function qi() {
  throw new Error("https://svelte.dev/e/async_derived_orphan");
}
function Di(t) {
  throw new Error("https://svelte.dev/e/effect_in_teardown");
}
function Li() {
  throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
}
function Fi(t) {
  throw new Error("https://svelte.dev/e/effect_orphan");
}
function Ii() {
  throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
}
function Bi() {
  throw new Error("https://svelte.dev/e/hydration_failed");
}
function Hi(t) {
  throw new Error("https://svelte.dev/e/props_invalid_value");
}
function Vi() {
  throw new Error("https://svelte.dev/e/state_descriptors_fixed");
}
function Ki() {
  throw new Error("https://svelte.dev/e/state_prototype_fixed");
}
function Gi() {
  throw new Error("https://svelte.dev/e/state_unsafe_mutation");
}
function Ji() {
  throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
}
function Ui() {
  console.warn("https://svelte.dev/e/derived_inert");
}
function te(t) {
  console.warn("https://svelte.dev/e/hydration_mismatch");
}
function Qi() {
  console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
}
var q = !1;
function Ut(t) {
  q = t;
}
var P;
function ut(t) {
  if (t === null) throw te(), Qt;
  return P = t;
}
function Te() {
  return ut(/* @__PURE__ */ bt(P));
}
function Tn(t) {
  if (q) {
    if (/* @__PURE__ */ bt(P) !== null) throw te(), Qt;
    P = t;
  }
}
function Yi(t = 1) {
  if (q) {
    for (var n = t, e = P; n--; ) e = /* @__PURE__ */ bt(e);
    P = e;
  }
}
function fr(t = !0) {
  for (var n = 0, e = P; ; ) {
    if (e.nodeType === 8) {
      var r = e.data;
      if (r === "]") {
        if (n === 0) return e;
        n -= 1;
      } else (r === "[" || r === "[!" || r[0] === "[" && !isNaN(Number(r.slice(1)))) && (n += 1);
    }
    var i = /* @__PURE__ */ bt(e);
    t && e.remove(), e = i;
  }
}
function Zi(t) {
  if (!t || t.nodeType !== 8) throw te(), Qt;
  return t.data;
}
function hr(t) {
  return t === this.v;
}
function Xi(t, n) {
  return t != t ? n == n : t !== n || t !== null && typeof t == "object" || typeof t == "function";
}
function dr(t) {
  return !Xi(t, this.v);
}
var pt = !1, wn = !1, E = null;
function Yt(t) {
  E = t;
}
function vr(t, n = !1, e) {
  E = {
    p: E,
    i: !1,
    c: null,
    e: null,
    s: t,
    x: null,
    r: $,
    l: wn && !n ? {
      s: null,
      u: null,
      $: []
    } : null
  };
}
function pr(t) {
  var n = E, e = n.e;
  if (e !== null) {
    n.e = null;
    for (var r of e) Fr(r);
  }
  return t !== void 0 && (n.x = t), n.i = !0, E = n.p, t ?? {};
}
function yn() {
  return !wn || E !== null && E.l === null;
}
var St = [];
function gr() {
  var t = St;
  St = [], Ci(t);
}
function Zt(t) {
  if (St.length === 0 && !un) {
    var n = St;
    queueMicrotask(() => {
      n === St && gr();
    });
  }
  St.push(t);
}
function to() {
  for (; St.length > 0; ) gr();
}
function wr(t) {
  var n = $;
  if (n === null) return M.f |= In, t;
  if ((n.f & 32768) === 0 && (n.f & 4) === 0) throw t;
  $t(t, n);
}
function $t(t, n) {
  for (; n !== null; ) {
    if ((n.f & 128) !== 0) {
      if ((n.f & 32768) === 0) throw t;
      try {
        n.b.error(t);
        return;
      } catch (e) {
        t = e;
      }
    }
    n = n.parent;
  }
  throw t;
}
var no = ~(Z | qt | Q);
function j(t, n) {
  t.f = t.f & no | n;
}
function Se(t) {
  (t.f & 512) !== 0 || t.deps === null ? j(t, Q) : j(t, qt);
}
function yr(t) {
  if (t !== null) for (const n of t) !(n.f & 2) || !(n.f & 65536) || (n.f ^= gn, yr(n.deps));
}
function mr(t, n, e) {
  (t.f & 2048) !== 0 ? n.add(t) : t.f & 4096 && e.add(t), yr(t.deps), j(t, Q);
}
var eo = !1, Sn = !1;
function ro(t) {
  var n = Sn;
  try {
    return Sn = !1, [t(), Sn];
  } finally {
    Sn = n;
  }
}
function $r(t, n) {
  if (n.has(t)) throw new TypeError("Cannot initialize the same private elements twice on an object");
}
function Ce(t, n) {
  $r(t, n), n.add(t);
}
function m(t, n, e) {
  $r(t, n), n.set(t, e);
}
function b(t, n, e) {
  if (typeof t == "function" ? t === n : t.has(n)) return arguments.length < 3 ? n : e;
  throw new TypeError("Private element is not present on this object");
}
function y(t, n, e) {
  return t.set(b(t, n), e), e;
}
function s(t, n) {
  return t.get(b(t, n));
}
var br, Bn = null, It = null, k = null, de = null, F = null, ve = null, un = !1, se = !1, Xt = null, Hn = null, _r = 0, io = 1, Vn = /* @__PURE__ */ new WeakMap(), Pt = /* @__PURE__ */ new WeakMap(), Ct = /* @__PURE__ */ new WeakMap(), Kn = /* @__PURE__ */ new WeakMap(), Cn = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ new WeakMap(), Tt = /* @__PURE__ */ new WeakMap(), on = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), Rt = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap(), On = /* @__PURE__ */ new WeakMap(), sn = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakSet(), Dt = class kr {
  constructor() {
    Ce(this, A), x(this, "id", io++), m(this, Vn, !1), x(this, "linked", !0), m(this, Pt, null), m(this, Ct, null), x(this, "async_deriveds", /* @__PURE__ */ new Map()), x(this, "current", /* @__PURE__ */ new Map()), x(this, "previous", /* @__PURE__ */ new Map()), m(this, Kn, /* @__PURE__ */ new Set()), m(this, Cn, /* @__PURE__ */ new Set()), m(this, Bt, 0), m(this, Tt, /* @__PURE__ */ new Map()), m(this, on, null), m(this, J, []), m(this, pe, []), m(this, Rt, /* @__PURE__ */ new Set()), m(this, vt, /* @__PURE__ */ new Set()), m(this, mt, /* @__PURE__ */ new Map()), m(this, On, /* @__PURE__ */ new Set()), x(this, "is_fork", !1), m(this, sn, !1), It === null ? Bn = It = this : (y(Ct, It, this), y(Pt, this, It)), It = this;
  }
  skip_effect(n) {
    s(mt, this).has(n) || s(mt, this).set(n, {
      d: [],
      m: []
    }), s(On, this).delete(n);
  }
  unskip_effect(n, e = (r) => this.schedule(r)) {
    var r = s(mt, this).get(n);
    if (r) {
      s(mt, this).delete(n);
      for (var i of r.d) j(i, Z), e(i);
      for (i of r.m) j(i, qt), e(i);
    }
    s(On, this).add(n);
  }
  capture(n, e, r = !1) {
    n.v !== R && !this.previous.has(n) && this.previous.set(n, n.v), !(n.f & 8388608) && (this.current.set(n, [e, r]), F?.set(n, e)), this.is_fork || (n.v = e);
  }
  activate() {
    k = this;
  }
  deactivate() {
    k = null, F = null;
  }
  flush() {
    try {
      se = !0, k = this, b(A, this, Gn).call(this);
    } finally {
      _r = 0, ve = null, Xt = null, Hn = null, se = !1, k = null, F = null, Nt.clear();
    }
  }
  discard() {
    for (const n of s(Cn, this)) n(this);
    s(Cn, this).clear(), b(A, this, Jn).call(this), s(on, this)?.resolve();
  }
  register_created_effect(n) {
    s(pe, this).push(n);
  }
  increment(n, e) {
    if (y(Bt, this, s(Bt, this) + 1), n) {
      let r = s(Tt, this).get(e) ?? 0;
      s(Tt, this).set(e, r + 1);
    }
  }
  decrement(n, e) {
    if (y(Bt, this, s(Bt, this) - 1), n) {
      let r = s(Tt, this).get(e) ?? 0;
      r === 1 ? s(Tt, this).delete(e) : s(Tt, this).set(e, r - 1);
    }
    s(sn, this) || (y(sn, this, !0), Zt(() => {
      y(sn, this, !1), this.linked && this.flush();
    }));
  }
  transfer_effects(n, e) {
    for (const r of n) s(Rt, this).add(r);
    for (const r of e) s(vt, this).add(r);
    n.clear(), e.clear();
  }
  oncommit(n) {
    s(Kn, this).add(n);
  }
  ondiscard(n) {
    s(Cn, this).add(n);
  }
  settled() {
    return (s(on, this) ?? y(on, this, ur())).promise;
  }
  static ensure() {
    if (k === null) {
      const n = k = new kr();
      !se && !un && Zt(() => {
        s(Vn, n) || n.flush();
      });
    }
    return k;
  }
  apply() {
    if (!pt || !this.is_fork && s(Pt, this) === null && s(Ct, this) === null) {
      F = null;
      return;
    }
    F = /* @__PURE__ */ new Map();
    for (const [e, [r]] of this.current) F.set(e, r);
    for (let e = Bn; e !== null; e = s(Ct, e)) if (!(e === this || e.is_fork)) {
      var n = !1;
      if (e.id < this.id) {
        for (const [r, [, i]] of e.current) if (!i && this.current.has(r)) {
          n = !0;
          break;
        }
      }
      if (!n) for (const [r, i] of e.previous) F.has(r) || F.set(r, i);
    }
  }
  schedule(n) {
    if (ve = n, n.b?.is_pending && (n.f & 16777228) !== 0 && (n.f & 32768) === 0) {
      n.b.defer_effect(n);
      return;
    }
    for (var e = n; e.parent !== null; ) {
      e = e.parent;
      var r = e.f;
      if (Xt !== null && e === $ && (pt || (M === null || (M.f & 2) === 0) && !eo)) return;
      if ((r & 96) !== 0) {
        if ((r & 1024) === 0) return;
        e.f ^= Q;
      }
    }
    s(J, this).push(e);
  }
};
br = Dt;
function He() {
  if (this.is_fork) return !0;
  for (const e of s(Tt, this).keys()) {
    for (var t = e, n = !1; t.parent !== null; ) {
      if (s(mt, this).has(t)) {
        n = !0;
        break;
      }
      t = t.parent;
    }
    if (!n) return !0;
  }
  return !1;
}
function Gn() {
  y(Vn, this, !0), _r++ > 1e3 && (b(A, this, Jn).call(this), ao());
  for (const l of s(Rt, this)) s(vt, this).delete(l), j(l, Z), this.schedule(l);
  for (const l of s(vt, this)) j(l, qt), this.schedule(l);
  const t = s(J, this);
  y(J, this, []), this.apply();
  var n = Xt = [], e = [], r = Hn = [];
  for (const l of t) try {
    b(A, this, Mr).call(this, l, n, e);
  } catch (c) {
    throw Cr(l), b(A, this, He).call(this) || this.discard(), c;
  }
  if (k = null, r.length > 0) {
    var i = br.ensure();
    for (const l of r) i.schedule(l);
  }
  if (Xt = null, Hn = null, b(A, this, He).call(this)) {
    b(A, this, ln).call(this, e), b(A, this, ln).call(this, n);
    for (const [l, c] of s(mt, this)) Sr(l, c);
    r.length > 0 && b(A, k, Gn).call(k);
    return;
  }
  const o = b(A, this, oo).call(this);
  if (o) {
    b(A, this, ln).call(this, e), b(A, this, ln).call(this, n), b(A, o, so).call(o, this);
    return;
  }
  s(Rt, this).clear(), s(vt, this).clear();
  for (const l of s(Kn, this)) l(this);
  s(Kn, this).clear(), de = this, Ve(e), Ve(n), de = null, s(on, this)?.resolve();
  var a = k;
  if (s(Bt, this) === 0 && (s(J, this).length === 0 || a !== null) && (b(A, this, Jn).call(this), pt && (b(A, this, lo).call(this), k = a)), s(J, this).length > 0) if (a !== null) {
    const l = a;
    s(J, l).push(...s(J, this).filter((c) => !s(J, l).includes(c)));
  } else a = this;
  a !== null && b(A, a, Gn).call(a);
}
function Mr(t, n, e) {
  t.f ^= Q;
  for (var r = t.first; r !== null; ) {
    var i = r.f, o = (i & 96) !== 0;
    if (!(o && (i & 1024) !== 0 || (i & 8192) !== 0 || s(mt, this).has(r)) && r.fn !== null) {
      o ? r.f ^= Q : (i & 4) !== 0 ? n.push(r) : pt && (i & 16777224) !== 0 ? e.push(r) : bn(r) && (i & 16 && s(vt, this).add(r), tn(r));
      var a = r.first;
      if (a !== null) {
        r = a;
        continue;
      }
    }
    for (; r !== null; ) {
      var l = r.next;
      if (l !== null) {
        r = l;
        break;
      }
      r = r.parent;
    }
  }
}
function oo() {
  for (var t = s(Pt, this); t !== null; ) {
    if (!t.is_fork) {
      for (const [n, [, e]] of this.current) if (t.current.has(n) && !e) return t;
    }
    t = s(Pt, t);
  }
  return null;
}
function so(t) {
  for (const [e, r] of t.current) !this.previous.has(e) && t.previous.has(e) && this.previous.set(e, t.previous.get(e)), this.current.set(e, r);
  for (const [e, r] of t.async_deriveds) {
    const i = this.async_deriveds.get(e);
    i && r.promise.then(i.resolve).catch(i.reject);
  }
  this.transfer_effects(s(Rt, t), s(vt, t));
  const n = (e) => {
    var r = e.reactions;
    if (r !== null) for (const a of r) {
      var i = a.f;
      if ((i & 2) !== 0) n(a);
      else {
        var o = a;
        i & 4194320 && !this.async_deriveds.has(o) && (s(vt, this).delete(o), j(o, Z), this.schedule(o));
      }
    }
  };
  for (const e of this.current.keys()) n(e);
  this.oncommit(() => t.discard()), b(A, t, Jn).call(t), k = this, b(A, this, Gn).call(this);
}
function ln(t) {
  for (var n = 0; n < t.length; n += 1) mr(t[n], s(Rt, this), s(vt, this));
}
function lo() {
  for (let u = Bn; u !== null; u = s(Ct, u)) {
    var t = u.id < this.id, n = [];
    for (const [h, [v, d]] of this.current) {
      if (u.current.has(h)) {
        var e = u.current.get(h)[0];
        if (t && v !== e) u.current.set(h, [v, d]);
        else continue;
      }
      n.push(h);
    }
    if (t) for (const [h, v] of this.async_deriveds) {
      const d = u.async_deriveds.get(h);
      d && v.promise.then(d.resolve).catch(d.reject);
    }
    if (s(Vn, u)) {
      var r = [...u.current.keys()].filter((h) => !u.current.get(h)[1] && !this.current.has(h));
      if (r.length === 0) t && u.discard();
      else if (n.length > 0) {
        if (t) for (const h of s(On, this)) u.unskip_effect(h, (v) => {
          (v.f & 4194320) !== 0 ? u.schedule(v) : b(A, u, ln).call(u, [v]);
        });
        u.activate();
        var i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
        for (var a of n) Tr(a, r, i, o);
        o = /* @__PURE__ */ new Map();
        var l = [...u.current].filter(([h, v]) => {
          const d = this.current.get(h);
          return d ? d[0] !== v[0] || d[1] !== v[1] : !0;
        }).map(([h]) => h);
        if (l.length > 0) for (const h of s(pe, this)) !(h.f & 155648) && xe(h, l, o) && ((h.f & 4194320) !== 0 ? (j(h, Z), u.schedule(h)) : s(Rt, u).add(h));
        if (s(J, u).length > 0 && !s(sn, u)) {
          u.apply();
          for (var c of s(J, u)) b(A, u, Mr).call(u, c, [], []);
          y(J, u, []);
        }
        u.deactivate();
      }
    }
  }
}
function Jn() {
  if (this.linked) {
    var t = s(Pt, this), n = s(Ct, this);
    t === null ? Bn = n : y(Ct, t, n), n === null ? It = t : y(Pt, n, t), this.linked = !1;
  }
}
function Ht(t) {
  var n = un;
  un = !0;
  try {
    var e;
    for (t && (k !== null && !k.is_fork && k.flush(), e = t()); ; ) {
      if (to(), k === null) return e;
      k.flush();
    }
  } finally {
    un = n;
  }
}
function ao() {
  try {
    Ii();
  } catch (t) {
    $t(t, ve);
  }
}
var st = null;
function Ve(t) {
  var n = t.length;
  if (n !== 0) {
    for (var e = 0; e < n; ) {
      var r = t[e++];
      if ((r.f & 24576) === 0 && bn(r) && (st = /* @__PURE__ */ new Set(), tn(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Vr(r), st?.size > 0)) {
        Nt.clear();
        for (const i of st) {
          if ((i.f & 24576) !== 0) continue;
          const o = [i];
          let a = i.parent;
          for (; a !== null; ) st.has(a) && (st.delete(a), o.push(a)), a = a.parent;
          for (let l = o.length - 1; l >= 0; l--) {
            const c = o[l];
            !(c.f & 24576) && tn(c);
          }
        }
        st.clear();
      }
    }
    st = null;
  }
}
function Tr(t, n, e, r) {
  if (!e.has(t) && (e.add(t), t.reactions !== null)) for (const i of t.reactions) {
    const o = i.f;
    (o & 2) !== 0 ? Tr(i, n, e, r) : o & 4194320 && !(o & 2048) && xe(i, n, r) && (j(i, Z), We(i));
  }
}
function xe(t, n, e) {
  const r = e.get(t);
  if (r !== void 0) return r;
  if (t.deps !== null) for (const i of t.deps) {
    if (Dn.call(n, i)) return !0;
    if ((i.f & 2) !== 0 && xe(i, n, e)) return e.set(i, !0), !0;
  }
  return e.set(t, !1), !1;
}
function We(t) {
  k.schedule(t);
}
function Sr(t, n) {
  if (!((t.f & 32) !== 0 && (t.f & 1024) !== 0)) {
    (t.f & 2048) !== 0 ? n.d.push(t) : t.f & 4096 && n.m.push(t), j(t, Q);
    for (var e = t.first; e !== null; ) Sr(e, n), e = e.next;
  }
}
function Cr(t) {
  j(t, Q);
  for (var n = t.first; n !== null; ) Cr(n), n = n.next;
}
function uo(t) {
  let n = 0, e = mn(0), r;
  return () => {
    Ae() && (f(e), Ne(() => (n === 0 && (r = ne(() => t(() => cn(e)))), n += 1, () => {
      Zt(() => {
        n -= 1, n === 0 && (r?.(), r = void 0, cn(e));
      });
    })));
  };
}
var co = Me | nn;
function fo(t, n, e, r) {
  new ho(t, n, e, r);
}
var rt = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), hn = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), at = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), jt = /* @__PURE__ */ new WeakMap(), Vt = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(), xn = /* @__PURE__ */ new WeakMap(), we = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakSet(), ho = class {
  constructor(t, n, e, r) {
    Ce(this, L), x(this, "parent", void 0), x(this, "is_pending", !1), x(this, "transform_error", void 0), m(this, rt, void 0), m(this, ge, q ? P : null), m(this, lt, void 0), m(this, hn, void 0), m(this, U, void 0), m(this, at, null), m(this, K, null), m(this, nt, null), m(this, jt, null), m(this, Vt, 0), m(this, At, 0), m(this, xn, !1), m(this, we, /* @__PURE__ */ new Set()), m(this, ye, /* @__PURE__ */ new Set()), m(this, kt, null), m(this, Ke, uo(() => (y(kt, this, mn(s(Vt, this))), () => {
      y(kt, this, null);
    }))), y(rt, this, t), y(lt, this, n), y(hn, this, (i) => {
      var o = $;
      o.b = this, o.f |= 128, e(i);
    }), this.parent = $.b, this.transform_error = r ?? this.parent?.transform_error ?? ((i) => i), y(U, this, Br(() => {
      if (q) {
        const i = s(ge, this);
        Te();
        const o = i.data === "[!";
        if (i.data.startsWith("[?")) {
          const a = JSON.parse(i.data.slice(2));
          b(L, this, po).call(this, a);
        } else o ? b(L, this, go).call(this) : b(L, this, vo).call(this);
      } else b(L, this, xr).call(this);
    }, co)), q && y(rt, this, P);
  }
  defer_effect(t) {
    mr(t, s(we, this), s(ye, this));
  }
  is_rendered() {
    return !this.is_pending && (!this.parent || this.parent.is_rendered());
  }
  has_pending_snippet() {
    return !!s(lt, this).pending;
  }
  update_pending_count(t, n) {
    b(L, this, Wr).call(this, t, n), y(Vt, this, s(Vt, this) + t), !(!s(kt, this) || s(xn, this)) && (y(xn, this, !0), Zt(() => {
      y(xn, this, !1), s(kt, this) && Yn(s(kt, this), s(Vt, this));
    }));
  }
  get_effect_pending() {
    return s(Ke, this).call(this), f(s(kt, this));
  }
  error(t) {
    if (!s(lt, this).onerror && !s(lt, this).failed) throw t;
    k?.is_fork ? (s(at, this) && k.skip_effect(s(at, this)), s(K, this) && k.skip_effect(s(K, this)), s(nt, this) && k.skip_effect(s(nt, this)), k.oncommit(() => {
      b(L, this, Ge).call(this, t);
    })) : b(L, this, Ge).call(this, t);
  }
};
function vo() {
  try {
    y(at, this, gt(() => s(hn, this).call(this, s(rt, this))));
  } catch (t) {
    this.error(t);
  }
}
function po(t) {
  const n = s(lt, this).failed;
  n && y(nt, this, gt(() => {
    n(s(rt, this), () => t, () => () => {
    });
  }));
}
function go() {
  const t = s(lt, this).pending;
  t && (this.is_pending = !0, y(K, this, gt(() => t(s(rt, this)))), Zt(() => {
    var n = y(jt, this, document.createDocumentFragment()), e = zt();
    n.append(e), y(at, this, b(L, this, me).call(this, () => gt(() => s(hn, this).call(this, e)))), s(At, this) === 0 && (s(rt, this).before(n), y(jt, this, null), $n(s(K, this), () => {
      y(K, this, null);
    }), b(L, this, Ee).call(this, k));
  }));
}
function xr() {
  try {
    if (this.is_pending = this.has_pending_snippet(), y(At, this, 0), y(Vt, this, 0), y(at, this, gt(() => {
      s(hn, this).call(this, s(rt, this));
    })), s(At, this) > 0) {
      var t = y(jt, this, document.createDocumentFragment());
      Jr(s(at, this), t);
      const n = s(lt, this).pending;
      y(K, this, gt(() => n(s(rt, this))));
    } else b(L, this, Ee).call(this, k);
  } catch (n) {
    this.error(n);
  }
}
function Ee(t) {
  this.is_pending = !1, t.transfer_effects(s(we, this), s(ye, this));
}
function me(t) {
  var n = $, e = M, r = E;
  ct(s(U, this)), Y(s(U, this)), Yt(s(U, this).ctx);
  try {
    return Dt.ensure(), t();
  } catch (i) {
    return wr(i), null;
  } finally {
    ct(n), Y(e), Yt(r);
  }
}
function Wr(t, n) {
  if (!this.has_pending_snippet()) {
    if (this.parent) {
      var e;
      b(L, e = this.parent, Wr).call(e, t, n);
    }
    return;
  }
  y(At, this, s(At, this) + t), s(At, this) === 0 && (b(L, this, Ee).call(this, n), s(K, this) && $n(s(K, this), () => {
    y(K, this, null);
  }), s(jt, this) && (s(rt, this).before(s(jt, this)), y(jt, this, null)));
}
function Ge(t) {
  s(at, this) && (H(s(at, this)), y(at, this, null)), s(K, this) && (H(s(K, this)), y(K, this, null)), s(nt, this) && (H(s(nt, this)), y(nt, this, null)), q && (ut(s(ge, this)), Yi(), ut(fr()));
  var n = s(lt, this).onerror;
  let e = s(lt, this).failed;
  var r = !1, i = !1;
  const o = () => {
    if (r) {
      Qi();
      return;
    }
    r = !0, i && Ji(), s(nt, this) !== null && $n(s(nt, this), () => {
      y(nt, this, null);
    }), b(L, this, me).call(this, () => {
      b(L, this, xr).call(this);
    });
  }, a = (l) => {
    try {
      i = !0, n?.(l, o), i = !1;
    } catch (c) {
      $t(c, s(U, this) && s(U, this).parent);
    }
    e && y(nt, this, b(L, this, me).call(this, () => {
      try {
        return gt(() => {
          var c = $;
          c.b = this, c.f |= 128, e(s(rt, this), () => l, () => o);
        });
      } catch (c) {
        return $t(c, s(U, this).parent), null;
      }
    }));
  };
  Zt(() => {
    var l;
    try {
      l = this.transform_error(t);
    } catch (c) {
      $t(c, s(U, this) && s(U, this).parent);
      return;
    }
    l !== null && typeof l == "object" && typeof l.then == "function" ? l.then(a, (c) => $t(c, s(U, this) && s(U, this).parent)) : a(l);
  });
}
function wo(t, n, e, r) {
  const i = yn() ? dn : Pr;
  var o = t.filter((d) => !d.settled);
  if (e.length === 0 && o.length === 0) {
    r(n.map(i));
    return;
  }
  var a = $, l = yo(), c = o.length === 1 ? o[0].promise : o.length > 1 ? Promise.all(o.map((d) => d.promise)) : null;
  function u(d) {
    if ((a.f & 16384) === 0) {
      l();
      try {
        r(d);
      } catch (p) {
        $t(p, a);
      }
      Un();
    }
  }
  var h = Er();
  if (e.length === 0) {
    c.then(() => u(n.map(i))).finally(h);
    return;
  }
  function v() {
    Promise.all(e.map((d) => /* @__PURE__ */ mo(d))).then((d) => u([...n.map(i), ...d])).catch((d) => $t(d, a)).finally(h);
  }
  c ? c.then(() => {
    l(), v(), Un();
  }) : v();
}
function yo() {
  var t = $, n = M, e = E, r = k;
  return function(i = !0) {
    ct(t), Y(n), Yt(e), i && !(t.f & 16384) && (r?.activate(), r?.apply());
  };
}
function Un(t = !0) {
  ct(null), Y(null), Yt(null), t && k?.deactivate();
}
function Er() {
  var t = $, n = t.b, e = k, r = !!n?.is_rendered();
  return n?.update_pending_count(1, e), e.increment(r, t), () => {
    n?.update_pending_count(-1, e), e.decrement(r, t);
  };
}
// @__NO_SIDE_EFFECTS__
function dn(t) {
  var n = 2 | Z;
  return $ !== null && ($.f |= nn), {
    ctx: E,
    deps: null,
    effects: null,
    equals: hr,
    f: n,
    fn: t,
    reactions: null,
    rv: 0,
    v: R,
    wv: 0,
    parent: $,
    ac: null
  };
}
var Wn = /* @__PURE__ */ Symbol("obsolete");
// @__NO_SIDE_EFFECTS__
function mo(t, n, e) {
  let r = $;
  r === null && qi();
  var i = void 0, o = mn(R), a = !M, l = /* @__PURE__ */ new Set();
  return Po(() => {
    var c = $, u = ur();
    i = u.promise;
    try {
      Promise.resolve(t()).then(u.resolve, (p) => {
        p !== Xn && u.reject(p);
      }).finally(Un);
    } catch (p) {
      u.reject(p), Un();
    }
    var h = k;
    if (a) {
      if ((c.f & 32768) !== 0) var v = Er();
      if (r.b?.is_rendered()) h.async_deriveds.get(c)?.reject(Wn);
      else for (const p of l.values()) p.reject(Wn);
      l.add(u), h.async_deriveds.set(c, u);
    }
    const d = (p, w = void 0) => {
      v?.(), l.delete(u), w !== Wn && (h.activate(), w ? (o.f |= In, Yn(o, w)) : (o.f & 8388608 && (o.f ^= In), Yn(o, p)), h.deactivate());
    };
    u.promise.then(d, (p) => d(null, p || "unknown"));
  }), xo(() => {
    for (const c of l) c.reject(Wn);
  }), new Promise((c) => {
    function u(h) {
      function v() {
        h === i ? c(o) : u(i);
      }
      h.then(v, v);
    }
    u(i);
  });
}
// @__NO_SIDE_EFFECTS__
function Je(t) {
  const n = /* @__PURE__ */ dn(t);
  return pt || Ur(n), n;
}
// @__NO_SIDE_EFFECTS__
function Pr(t) {
  const n = /* @__PURE__ */ dn(t);
  return n.equals = dr, n;
}
function $o(t) {
  var n = t.effects;
  if (n !== null) {
    t.effects = null;
    for (var e = 0; e < n.length; e += 1) H(n[e]);
  }
}
function Pe(t) {
  var n, e = $, r = t.parent;
  if (!wt && r !== null && t.v !== R && (r.f & 24576) !== 0) return Ui(), t.v;
  ct(r);
  try {
    t.f &= ~gn, $o(t), n = Xr(t);
  } finally {
    ct(e);
  }
  return n;
}
function jr(t) {
  var n = Pe(t);
  if (!t.equals(n) && (t.wv = Yr(), (!k?.is_fork || t.deps === null) && (k !== null ? (k.capture(t, n, !0), de?.capture(t, n, !0)) : t.v = n, t.deps === null))) {
    j(t, Q);
    return;
  }
  wt || (F !== null ? (Ae() || k?.is_fork) && F.set(t, n) : Se(t));
}
function bo(t) {
  if (t.effects !== null) for (const n of t.effects) (n.teardown || n.ac) && (n.teardown?.(), n.ac?.abort(Xn), n.fn !== null && (n.teardown = Si), n.ac = null, pn(n, 0), Oe(n));
}
function Ar(t) {
  if (t.effects !== null) for (const n of t.effects) n.teardown && n.fn !== null && tn(n);
}
var Qn = /* @__PURE__ */ new Set(), Nt = /* @__PURE__ */ new Map(), Nr = !1;
function mn(t, n) {
  return {
    f: 0,
    v: t,
    reactions: null,
    equals: hr,
    rv: 0,
    wv: 0
  };
}
// @__NO_SIDE_EFFECTS__
function z(t, n) {
  const e = mn(t, n);
  return Ur(e), e;
}
// @__NO_SIDE_EFFECTS__
function _o(t, n = !1, e = !0) {
  const r = mn(t);
  if (n || (r.equals = dr), wn && e && E !== null && E.l !== null) {
    var i;
    ((i = E.l).s ?? (i.s = [])).push(r);
  }
  return r;
}
function S(t, n, e = !1) {
  return M !== null && (!et || M.f & 131072) && yn() && M.f & 4325394 && (it === null || !it.has(t)) && Gi(), Yn(t, e ? xt(n) : n, Hn);
}
function Yn(t, n, e = null) {
  if (!t.equals(n)) {
    Nt.set(t, wt ? n : t.v);
    var r = Dt.ensure();
    if (r.capture(t, n), (t.f & 2) !== 0) {
      const i = t;
      t.f & 2048 && Pe(i), F === null && Se(i);
    }
    t.wv = Yr(), Or(t, Z, e), yn() && $ !== null && $.f & 1024 && !($.f & 96) && (G === null ? Oo([t]) : G.push(t)), !r.is_fork && Qn.size > 0 && !Nr && ko();
  }
  return n;
}
function ko() {
  Nr = !1;
  for (const t of Qn) {
    t.f & 1024 && j(t, qt);
    let n;
    try {
      n = bn(t);
    } catch {
      n = !0;
    }
    n && tn(t);
  }
  Qn.clear();
}
function cn(t) {
  S(t, t.v + 1);
}
function Or(t, n, e) {
  var r = t.reactions;
  if (r !== null) for (var i = yn(), o = r.length, a = 0; a < o; a++) {
    var l = r[a], c = l.f;
    if (!(!i && l === $)) {
      var u = (c & Z) === 0;
      if (u && j(l, n), (c & 131072) !== 0) Qn.add(l);
      else if ((c & 2) !== 0) {
        var h = l;
        F?.delete(h), !(c & 65536) && (c & 512 && ($ === null || !($.f & 2097152)) && (l.f |= gn), Or(h, qt, e));
      } else if (u) {
        var v = l;
        c & 16 && st !== null && st.add(v), e !== null ? e.push(v) : We(v);
      }
    }
  }
}
function xt(t) {
  if (typeof t != "object" || t === null || an in t) return t;
  const n = ar(t);
  if (n !== Mi && n !== Ti) return t;
  var e = /* @__PURE__ */ new Map(), r = $i(t), i = /* @__PURE__ */ z(0), o = null, a = Ot, l = (c) => {
    if (Ot === a) return c();
    var u = M, h = Ot;
    Y(null), Xe(a);
    var v = c();
    return Y(u), Xe(h), v;
  };
  return r && e.set("length", /* @__PURE__ */ z(t.length, o)), new Proxy(t, {
    defineProperty(c, u, h) {
      (!("value" in h) || h.configurable === !1 || h.enumerable === !1 || h.writable === !1) && Vi();
      var v = e.get(u);
      return v === void 0 ? l(() => {
        var d = /* @__PURE__ */ z(h.value, o);
        return e.set(u, d), d;
      }) : S(v, h.value, !0), !0;
    },
    deleteProperty(c, u) {
      var h = e.get(u);
      if (h === void 0) {
        if (u in c) {
          const v = l(() => /* @__PURE__ */ z(R, o));
          e.set(u, v), cn(i);
        }
      } else S(h, R), cn(i);
      return !0;
    },
    get(c, u, h) {
      if (u === an) return t;
      var v = e.get(u), d = u in c;
      if (v === void 0 && (!d || Et(c, u)?.writable) && (v = l(() => /* @__PURE__ */ z(xt(d ? c[u] : R), o)), e.set(u, v)), v !== void 0) {
        var p = f(v);
        return p === R ? void 0 : p;
      }
      return Reflect.get(c, u, h);
    },
    getOwnPropertyDescriptor(c, u) {
      var h = Reflect.getOwnPropertyDescriptor(c, u);
      if (h && "value" in h) {
        var v = e.get(u);
        v && (h.value = f(v));
      } else if (h === void 0) {
        var d = e.get(u), p = d?.v;
        if (d !== void 0 && p !== R) return {
          enumerable: !0,
          configurable: !0,
          value: p,
          writable: !0
        };
      }
      return h;
    },
    has(c, u) {
      if (u === an) return !0;
      var h = e.get(u), v = h !== void 0 && h.v !== R || Reflect.has(c, u);
      return (h !== void 0 || $ !== null && (!v || Et(c, u)?.writable)) && (h === void 0 && (h = l(() => /* @__PURE__ */ z(v ? xt(c[u]) : R, o)), e.set(u, h)), f(h) === R) ? !1 : v;
    },
    set(c, u, h, v) {
      var d = e.get(u), p = u in c;
      if (r && u === "length") for (var w = h; w < d.v; w += 1) {
        var _ = e.get(w + "");
        _ !== void 0 ? S(_, R) : w in c && (_ = l(() => /* @__PURE__ */ z(R, o)), e.set(w + "", _));
      }
      if (d === void 0) (!p || Et(c, u)?.writable) && (d = l(() => /* @__PURE__ */ z(void 0, o)), S(d, xt(h)), e.set(u, d));
      else {
        p = d.v !== R;
        var C = l(() => xt(h));
        S(d, C);
      }
      var O = Reflect.getOwnPropertyDescriptor(c, u);
      if (O?.set && O.set.call(v, h), !p) {
        if (r && typeof u == "string") {
          var N = e.get("length"), X = Number(u);
          Number.isInteger(X) && X >= N.v && S(N, X + 1);
        }
        cn(i);
      }
      return !0;
    },
    ownKeys(c) {
      f(i);
      var u = Reflect.ownKeys(c).filter((d) => {
        var p = e.get(d);
        return p === void 0 || p.v !== R;
      });
      for (var [h, v] of e) v.v !== R && !(h in c) && u.push(h);
      return u;
    },
    setPrototypeOf() {
      Ki();
    }
  });
}
var Ue, Rr, zr, qr;
function $e() {
  if (Ue === void 0) {
    Ue = window, Rr = /Firefox/.test(navigator.userAgent);
    var t = Element.prototype, n = Node.prototype, e = Text.prototype;
    zr = Et(n, "firstChild").get, qr = Et(n, "nextSibling").get, Fe(t) && (t[Ni] = void 0, t[he] = null, t[Oi] = void 0, t.__e = void 0), Fe(e) && (e[Nn] = void 0);
  }
}
function zt(t = "") {
  return document.createTextNode(t);
}
// @__NO_SIDE_EFFECTS__
function vn(t) {
  return zr.call(t);
}
// @__NO_SIDE_EFFECTS__
function bt(t) {
  return qr.call(t);
}
function En(t, n) {
  if (!q) return /* @__PURE__ */ vn(t);
  var e = /* @__PURE__ */ vn(P);
  if (e === null) e = P.appendChild(zt());
  else if (n && e.nodeType !== 3) {
    var r = zt();
    return e?.before(r), ut(r), r;
  }
  return n && Dr(e), ut(e), e;
}
function le(t, n = 1, e = !1) {
  let r = q ? P : t;
  for (var i; n--; ) i = r, r = /* @__PURE__ */ bt(r);
  if (!q) return r;
  if (e) {
    if (r?.nodeType !== 3) {
      var o = zt();
      return r === null ? i?.after(o) : r.before(o), ut(o), o;
    }
    Dr(r);
  }
  return ut(r), r;
}
function Mo(t) {
  t.textContent = "";
}
function To() {
  return !pt || st !== null ? !1 : ($.f & ke) !== 0;
}
function je(t, n, e) {
  return n == null || n === "http://www.w3.org/1999/xhtml" ? e ? document.createElement(t, { is: e }) : document.createElement(t) : e ? document.createElementNS(n, t, { is: e }) : document.createElementNS(n, t);
}
function Dr(t) {
  if (t.nodeValue.length < 65536) return;
  let n = t.nextSibling;
  for (; n !== null && n.nodeType === 3; ) n.remove(), t.nodeValue += n.nodeValue, n = t.nextSibling;
}
function Lr(t) {
  var n = M, e = $;
  Y(null), ct(null);
  try {
    return t();
  } finally {
    Y(n), ct(e);
  }
}
function So(t) {
  $ === null && (M === null && Fi(t), Li()), wt && Di(t);
}
function Co(t, n) {
  var e = n.last;
  e === null ? n.last = n.first = t : (e.next = t, t.prev = e, n.last = t);
}
function ft(t, n) {
  var e = $;
  e !== null && e.f & 8192 && (t |= _e);
  var r = {
    ctx: E,
    deps: null,
    nodes: null,
    f: t | Z | 512,
    first: null,
    fn: n,
    last: null,
    next: null,
    parent: e,
    b: e && e.b,
    prev: null,
    teardown: null,
    wv: 0,
    ac: null
  };
  k?.register_created_effect(r);
  var i = r;
  if ((t & 4) !== 0) Xt !== null ? Xt.push(r) : Dt.ensure().schedule(r);
  else if (n !== null) {
    try {
      tn(r);
    } catch (a) {
      throw H(r), a;
    }
    i.deps === null && i.teardown === null && i.nodes === null && i.first === i.last && !(i.f & 524288) && (i = i.first, t & 16 && t & 65536 && i !== null && (i.f |= Me));
  }
  if (i !== null && (i.parent = e, e !== null && Co(i, e), M !== null && (M.f & 2) !== 0 && (t & 64) === 0)) {
    var o = M;
    (o.effects ?? (o.effects = [])).push(i);
  }
  return r;
}
function Ae() {
  return M !== null && !et;
}
function xo(t) {
  const n = ft(8, null);
  return j(n, Q), n.teardown = t, n;
}
function Kt(t) {
  So("$effect");
  var n = $.f;
  if (!M && (n & 32) !== 0 && E !== null && !E.i) {
    var e = E;
    (e.e ?? (e.e = [])).push(t);
  } else return Fr(t);
}
function Fr(t) {
  return ft(4 | Pi, t);
}
function Wo(t) {
  Dt.ensure();
  const n = ft(64 | nn, t);
  return () => {
    H(n);
  };
}
function Eo(t) {
  Dt.ensure();
  const n = ft(64 | nn, t);
  return (e = {}) => new Promise((r) => {
    e.outro ? $n(n, () => {
      H(n), r(void 0);
    }) : (H(n), r(void 0));
  });
}
function Ir(t) {
  return ft(4, t);
}
function Po(t) {
  return ft(ji | nn, t);
}
function Ne(t, n = 0) {
  return ft(8 | n, t);
}
function Qe(t, n = [], e = [], r = []) {
  wo(r, n, e, (i) => {
    ft(8, () => t(...i.map(f)));
  });
}
function Br(t, n = 0) {
  return ft(16 | n, t);
}
function gt(t) {
  return ft(32 | nn, t);
}
function Hr(t) {
  var n = t.teardown;
  if (n !== null) {
    const e = wt, r = M;
    Ze(!0), Y(null);
    try {
      n.call(null);
    } finally {
      Ze(e), Y(r);
    }
  }
}
function Oe(t, n = !1) {
  var e = t.first;
  for (t.first = t.last = null; e !== null; ) {
    const i = e.ac;
    i !== null && Lr(() => {
      i.abort(Xn);
    });
    var r = e.next;
    (e.f & 64) !== 0 ? e.parent = null : H(e, n), e = r;
  }
}
function jo(t) {
  for (var n = t.first; n !== null; ) {
    var e = n.next;
    !(n.f & 32) && H(n), n = e;
  }
}
function H(t, n = !0) {
  var e = !1;
  (n || t.f & 262144) && t.nodes !== null && t.nodes.end !== null && (Ao(t.nodes.start, t.nodes.end), e = !0), j(t, Ie), Oe(t, n && !e), pn(t, 0);
  var r = t.nodes && t.nodes.t;
  if (r !== null) for (const o of r) o.stop();
  Hr(t), t.f ^= Ie, t.f |= Ei;
  var i = t.parent;
  i !== null && i.first !== null && Vr(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes = t.ac = t.b = null;
}
function Ao(t, n) {
  for (; t !== null; ) {
    var e = t === n ? null : /* @__PURE__ */ bt(t);
    t.remove(), t = e;
  }
}
function Vr(t) {
  var n = t.parent, e = t.prev, r = t.next;
  e !== null && (e.next = r), r !== null && (r.prev = e), n !== null && (n.first === t && (n.first = r), n.last === t && (n.last = e));
}
function $n(t, n, e = !0) {
  var r = [];
  Kr(t, r, !0);
  var i = () => {
    e && H(t), n && n();
  }, o = r.length;
  if (o > 0) {
    var a = () => --o || i();
    for (var l of r) l.out(a);
  } else i();
}
function Kr(t, n, e) {
  if ((t.f & 8192) === 0) {
    t.f ^= _e;
    var r = t.nodes && t.nodes.t;
    if (r !== null) for (const l of r) (l.is_global || e) && n.push(l);
    for (var i = t.first; i !== null; ) {
      var o = i.next;
      if ((i.f & 64) === 0) {
        var a = (i.f & 65536) !== 0 || (i.f & 32) !== 0 && (t.f & 16) !== 0;
        Kr(i, n, a ? e : !1);
      }
      i = o;
    }
  }
}
function Ye(t) {
  Gr(t, !0);
}
function Gr(t, n) {
  if ((t.f & 8192) !== 0) {
    t.f ^= _e, !(t.f & 1024) && (j(t, Z), Dt.ensure().schedule(t));
    for (var e = t.first; e !== null; ) {
      var r = e.next, i = (e.f & 65536) !== 0 || (e.f & 32) !== 0;
      Gr(e, i ? n : !1), e = r;
    }
    var o = t.nodes && t.nodes.t;
    if (o !== null) for (const a of o) (a.is_global || n) && a.in();
  }
}
function Jr(t, n) {
  if (t.nodes) for (var e = t.nodes.start, r = t.nodes.end; e !== null; ) {
    var i = e === r ? null : /* @__PURE__ */ bt(e);
    n.append(e), e = i;
  }
}
var No = null, Rn = !1, wt = !1;
function Ze(t) {
  wt = t;
}
var M = null, et = !1;
function Y(t) {
  M = t;
}
var $ = null;
function ct(t) {
  $ = t;
}
var it = null;
function Ur(t) {
  M !== null && (!pt || M.f & 2) && (it ?? (it = /* @__PURE__ */ new Set())).add(t);
}
var B = null, V = 0, G = null;
function Oo(t) {
  G = t;
}
var Qr = 1, Wt = 0, Ot = Wt;
function Xe(t) {
  Ot = t;
}
function Yr() {
  return ++Qr;
}
function bn(t) {
  var n = t.f;
  if ((n & 2048) !== 0) return !0;
  if (n & 2 && (t.f &= ~gn), (n & 4096) !== 0) {
    for (var e = t.deps, r = e.length, i = 0; i < r; i++) {
      var o = e[i];
      if (bn(o) && jr(o), o.wv > t.wv) return !0;
    }
    n & 512 && F === null && j(t, Q);
  }
  return !1;
}
function Zr(t, n, e = !0) {
  var r = t.reactions;
  if (r !== null && !(!pt && it !== null && it.has(t))) for (var i = 0; i < r.length; i++) {
    var o = r[i];
    (o.f & 2) !== 0 ? Zr(o, n, !1) : n === o && (e ? j(o, Z) : o.f & 1024 && j(o, qt), We(o));
  }
}
function Xr(t) {
  var n = B, e = V, r = G, i = M, o = it, a = E, l = et, c = Ot, u = t.f;
  B = null, V = 0, G = null, M = (u & 96) === 0 ? t : null, it = null, Yt(t.ctx), et = !1, Ot = ++Wt, t.ac !== null && (Lr(() => {
    t.ac.abort(Xn);
  }), t.ac = null);
  try {
    t.f |= Be;
    var h = t.fn, v = h();
    t.f |= ke;
    var d = t.deps, p = k?.is_fork;
    if (B !== null) {
      var w;
      if (p || pn(t, V), d !== null && V > 0) for (d.length = V + B.length, w = 0; w < B.length; w++) d[V + w] = B[w];
      else t.deps = d = B;
      if (Ae() && (t.f & 512) !== 0) for (w = V; w < d.length; w++) {
        var _;
        ((_ = d[w]).reactions ?? (_.reactions = [])).push(t);
      }
    } else !p && d !== null && V < d.length && (pn(t, V), d.length = V);
    if (yn() && G !== null && !et && d !== null && (t.f & 6146) === 0) for (w = 0; w < G.length; w++) Zr(G[w], t);
    if (i !== null && i !== t) {
      if (Wt++, i.deps !== null) for (let C = 0; C < e; C += 1) i.deps[C].rv = Wt;
      if (n !== null) for (const C of n) C.rv = Wt;
      G !== null && (r === null ? r = G : r.push(...G));
    }
    return t.f & 8388608 && (t.f ^= In), v;
  } catch (C) {
    return wr(C);
  } finally {
    t.f ^= Be, B = n, V = e, G = r, M = i, it = o, Yt(a), et = l, Ot = c;
  }
}
function Ro(t, n) {
  let e = n.reactions;
  if (e !== null) {
    var r = bi.call(e, t);
    if (r !== -1) {
      var i = e.length - 1;
      i === 0 ? e = n.reactions = null : (e[r] = e[i], e.pop());
    }
  }
  if (e === null && (n.f & 2) !== 0 && (B === null || !Dn.call(B, n))) {
    var o = n;
    o.f & 512 && (o.f ^= 512, o.f &= ~gn), o.v !== R && Se(o), bo(o), pn(o, 0);
  }
}
function pn(t, n) {
  var e = t.deps;
  if (e !== null) for (var r = n; r < e.length; r++) Ro(t, e[r]);
}
function tn(t) {
  var n = t.f;
  if ((n & 16384) === 0) {
    j(t, Q);
    var e = $, r = Rn;
    $ = t, Rn = !0;
    try {
      (n & 16777232) !== 0 ? jo(t) : Oe(t), Hr(t);
      var i = Xr(t);
      t.teardown = typeof i == "function" ? i : null, t.wv = Qr;
    } finally {
      Rn = r, $ = e;
    }
  }
}
function f(t) {
  var n = (t.f & 2) !== 0;
  if (No?.add(t), M !== null && !et && !($ !== null && ($.f & 16384) !== 0) && (it === null || !it.has(t))) {
    var e = M.deps;
    if ((M.f & 2097152) !== 0) t.rv < Wt && (t.rv = Wt, B === null && e !== null && e[V] === t ? V++ : B === null ? B = [t] : B.push(t));
    else {
      var r;
      (r = M).deps ?? (r.deps = []), Dn.call(M.deps, t) || M.deps.push(t);
      var i = t.reactions;
      i === null ? t.reactions = [M] : Dn.call(i, M) || i.push(M);
    }
  }
  if (wt && Nt.has(t)) return Nt.get(t);
  if (n) {
    var o = t;
    if (wt) {
      var a = o.v;
      return (!(o.f & 1024) && o.reactions !== null || ni(o)) && (a = Pe(o)), Nt.set(o, a), a;
    }
    var l = (o.f & 512) === 0 && !et && M !== null && (Rn || (M.f & 512) !== 0), c = (o.f & ke) === 0;
    bn(o) && (l && (o.f |= 512), jr(o)), l && !c && (Ar(o), ti(o));
  }
  if (F?.has(t)) return F.get(t);
  if ((t.f & 8388608) !== 0) throw t.v;
  return t.v;
}
function ti(t) {
  if (t.f |= 512, t.deps !== null) for (const n of t.deps) (n.reactions ?? (n.reactions = [])).push(t), n.f & 2 && !(n.f & 512) && (Ar(n), ti(n));
}
function ni(t) {
  if (t.v === R) return !0;
  if (t.deps === null) return !1;
  for (const n of t.deps) if (Nt.has(n) || (n.f & 2) !== 0 && ni(n)) return !0;
  return !1;
}
function ne(t) {
  var n = et;
  try {
    return et = !0, t();
  } finally {
    et = n;
  }
}
var Pn = /* @__PURE__ */ Symbol("events"), zo = /* @__PURE__ */ new Set(), tr = /* @__PURE__ */ new Set(), nr = null;
function er(t) {
  var n = this, e = n.ownerDocument, r = t.type, i = t.composedPath?.() || [], o = i[0] || t.target;
  nr = t;
  var a = 0, l = nr === t && t[Pn];
  if (l) {
    var c = i.indexOf(l);
    if (c !== -1 && (n === document || n === window)) {
      t[Pn] = n;
      return;
    }
    var u = i.indexOf(n);
    if (u === -1) return;
    c <= u && (a = c);
  }
  if (o = i[a] || t.target, o !== n) {
    Fn(t, "currentTarget", {
      configurable: !0,
      get() {
        return o || e;
      }
    });
    var h = M, v = $;
    Y(null), ct(null);
    try {
      for (var d, p = []; o !== null && o !== n; ) {
        try {
          var w = o[Pn]?.[r];
          w != null && (!o.disabled || t.target === o) && w.call(o, t);
        } catch (_) {
          d ? p.push(_) : d = _;
        }
        if (t.cancelBubble) break;
        a++, o = a < i.length ? i[a] : null;
      }
      if (d) {
        for (let _ of p) queueMicrotask(() => {
          throw _;
        });
        throw d;
      }
    } finally {
      t[Pn] = n, delete t.currentTarget, Y(h), ct(v);
    }
  }
}
var qo = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", { createHTML: (t) => t });
function Do(t) {
  return qo?.createHTML(t) ?? t;
}
function Lo(t) {
  var n = je("template");
  return n.innerHTML = Do(t.replaceAll("<!>", "<!---->")), n.content;
}
function zn(t, n) {
  var e = $;
  e.nodes === null && (e.nodes = {
    start: t,
    end: n,
    a: null,
    t: null
  });
}
// @__NO_SIDE_EFFECTS__
function _n(t, n) {
  var e = (n & 1) !== 0, r = (n & 2) !== 0, i, o = !t.startsWith("<!>");
  return () => {
    if (q) return zn(P, null), P;
    i === void 0 && (i = Lo(o ? t : "<!>" + t), e || (i = /* @__PURE__ */ vn(i)));
    var a = r || Rr ? document.importNode(i, !0) : i.cloneNode(!0);
    if (e) {
      var l = /* @__PURE__ */ vn(a), c = a.lastChild;
      zn(l, c);
    } else zn(a, a);
    return a;
  };
}
function Gt(t, n) {
  if (q) {
    var e = $;
    (!(e.f & 32768) || e.nodes.end === null) && (e.nodes.end = P), Te();
    return;
  }
  t !== null && t.before(n);
}
var Fo = ["touchstart", "touchmove"];
function Io(t) {
  return Fo.includes(t);
}
function Bo(t, n) {
  var e, r = n == null ? "" : typeof n == "object" ? `${n}` : n;
  r !== ((e = t)[Nn] ?? (e[Nn] = t.nodeValue)) && (t[Nn] = r, t.nodeValue = `${r}`);
}
function ei(t, n) {
  return ri(t, n);
}
function Ho(t, n) {
  $e(), n.intro = n.intro ?? !1;
  const e = n.target, r = q, i = P;
  try {
    for (var o = /* @__PURE__ */ vn(e); o && (o.nodeType !== 8 || o.data !== "["); ) o = /* @__PURE__ */ bt(o);
    if (!o) throw Qt;
    Ut(!0), ut(o);
    const a = ri(t, {
      ...n,
      anchor: o
    });
    return Ut(!1), a;
  } catch (a) {
    if (a instanceof Error && a.message.split(`
`).some((l) => l.startsWith("https://svelte.dev/e/"))) throw a;
    return a !== Qt && console.warn("Failed to hydrate: ", a), n.recover === !1 && Bi(), $e(), Mo(e), Ut(!1), ei(t, n);
  } finally {
    Ut(r), ut(i);
  }
}
var jn = /* @__PURE__ */ new Map();
function ri(t, { target: n, anchor: e, props: r = {}, events: i, context: o, intro: a = !0, transformError: l }) {
  $e();
  var c = void 0, u = Eo(() => {
    var h = e ?? n.appendChild(zt());
    fo(h, { pending: () => {
    } }, (p) => {
      vr({});
      var w = E;
      if (o && (w.c = o), i && (r.$$events = i), q && zn(p, null), c = t(p, r) || {}, q && ($.nodes.end = P, P === null || P.nodeType !== 8 || P.data !== "]")) throw te(), Qt;
      pr();
    }, l);
    var v = /* @__PURE__ */ new Set(), d = (p) => {
      for (var w = 0; w < p.length; w++) {
        var _ = p[w];
        if (!v.has(_)) {
          v.add(_);
          var C = Io(_);
          for (const X of [n, document]) {
            var O = jn.get(X);
            O === void 0 && (O = /* @__PURE__ */ new Map(), jn.set(X, O));
            var N = O.get(_);
            N === void 0 ? (X.addEventListener(_, er, { passive: C }), O.set(_, 1)) : O.set(_, N + 1);
          }
        }
      }
    };
    return d(_i(zo)), tr.add(d), () => {
      for (var p of v) for (const C of [n, document]) {
        var w = jn.get(C), _ = w.get(p);
        --_ == 0 ? (C.removeEventListener(p, er), w.delete(p), w.size === 0 && jn.delete(C)) : w.set(p, _);
      }
      tr.delete(d), h !== e && h.parentNode?.removeChild(h);
    };
  });
  return be.set(c, u), c;
}
var be = /* @__PURE__ */ new WeakMap();
function Vo(t, n) {
  const e = be.get(t);
  return e ? (be.delete(t), e(n)) : Promise.resolve();
}
var dt = /* @__PURE__ */ new WeakMap(), yt = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), en = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), rr = /* @__PURE__ */ new WeakMap(), Ko = class {
  constructor(t, n = !0) {
    x(this, "anchor", void 0), m(this, dt, /* @__PURE__ */ new Map()), m(this, yt, /* @__PURE__ */ new Map()), m(this, tt, /* @__PURE__ */ new Map()), m(this, en, /* @__PURE__ */ new Set()), m(this, ae, !0), m(this, ue, (e) => {
      if (s(dt, this).has(e)) {
        var r = s(dt, this).get(e), i = s(yt, this).get(r);
        if (i) Ye(i), s(en, this).delete(r);
        else {
          var o = s(tt, this).get(r);
          o && (Ye(o.effect), s(yt, this).set(r, o.effect), s(tt, this).delete(r), o.fragment.lastChild.remove(), this.anchor.before(o.fragment), i = o.effect);
        }
        for (const [a, l] of s(dt, this)) {
          if (s(dt, this).delete(a), a === e) break;
          const c = s(tt, this).get(l);
          c && (H(c.effect), s(tt, this).delete(l));
        }
        for (const [a, l] of s(yt, this)) {
          if (a === r || s(en, this).has(a)) continue;
          const c = () => {
            if (Array.from(s(dt, this).values()).includes(a)) {
              var u = document.createDocumentFragment();
              Jr(l, u), u.append(zt()), s(tt, this).set(a, {
                effect: l,
                fragment: u
              });
            } else H(l);
            s(en, this).delete(a), s(yt, this).delete(a);
          };
          s(ae, this) || !i ? (s(en, this).add(a), $n(l, c, !1)) : c();
        }
      }
    }), m(this, rr, (e) => {
      s(dt, this).delete(e);
      const r = Array.from(s(dt, this).values());
      for (const [i, o] of s(tt, this)) r.includes(i) || (H(o.effect), s(tt, this).delete(i));
    }), this.anchor = t, y(ae, this, n);
  }
  ensure(t, n) {
    var e = k, r = To();
    if (n && !s(yt, this).has(t) && !s(tt, this).has(t)) if (r) {
      var i = document.createDocumentFragment(), o = zt();
      i.append(o), s(tt, this).set(t, {
        effect: gt(() => n(o)),
        fragment: i
      });
    } else s(yt, this).set(t, gt(() => n(this.anchor)));
    if (s(dt, this).set(e, t), r) {
      for (const [a, l] of s(yt, this)) a === t ? e.unskip_effect(l) : e.skip_effect(l);
      for (const [a, l] of s(tt, this)) a === t ? e.unskip_effect(l.effect) : e.skip_effect(l.effect);
      e.oncommit(s(ue, this)), e.ondiscard(s(rr, this));
    } else q && (this.anchor = P), s(ue, this).call(this, e);
  }
};
function Go(t) {
  E === null && zi("onMount"), wn && E.l !== null ? Jo(E).m.push(t) : Kt(() => {
    const n = ne(t);
    if (typeof n == "function") return n;
  });
}
function Jo(t) {
  var n = t.l;
  return n.u ?? (n.u = {
    a: [],
    b: [],
    m: []
  });
}
function An(t, n, e = !1) {
  var r;
  q && (r = P, Te());
  var i = new Ko(t), o = e ? Me : 0;
  function a(l, c) {
    if (q) {
      var u = Zi(r);
      if (l !== parseInt(u.substring(1))) {
        var h = fr();
        ut(h), i.anchor = h, Ut(!1), i.ensure(l, c), Ut(!0);
        return;
      }
    }
    i.ensure(l, c);
  }
  Br(() => {
    var l = !1;
    n((c, u = 0) => {
      l = !0, a(u, c);
    }), l || a(-1, null);
  }, o);
}
function Uo(t, n) {
  Ir(() => {
    var e = t.getRootNode(), r = e.host ? e : e.head ?? e.ownerDocument.head;
    if (!r.querySelector("#" + n.hash)) {
      const i = je("style");
      i.id = n.hash, i.textContent = n.code, r.appendChild(i);
    }
  });
}
var Qo = /* @__PURE__ */ Symbol("is custom element"), Yo = /* @__PURE__ */ Symbol("is html"), Zo = Ri ? "link" : "LINK";
function ir(t, n, e, r) {
  var i = Xo(t);
  q && (i[n] = t.getAttribute(n), n === "src" || n === "srcset" || n === "href" && t.nodeName === Zo) || i[n] !== (i[n] = e) && (n === "loading" && (t[Ai] = e), e == null ? t.removeAttribute(n) : typeof e != "string" && ts(t).includes(n) ? t[n] = e : t.setAttribute(n, e));
}
function Xo(t) {
  var n;
  return (n = t)[he] ?? (n[he] = {
    [Qo]: t.nodeName.includes("-"),
    [Yo]: t.namespaceURI === "http://www.w3.org/1999/xhtml"
  });
}
var or = /* @__PURE__ */ new Map();
function ts(t) {
  var n = t.getAttribute("is") || t.nodeName, e = or.get(n);
  if (e) return e;
  or.set(n, e = []);
  for (var r, i = t, o = Element.prototype; o !== i; ) {
    r = ki(i);
    for (var a in r) r[a].set && a !== "innerHTML" && a !== "textContent" && a !== "innerText" && e.push(a);
    i = ar(i);
  }
  return e;
}
var ii, Jt = /* @__PURE__ */ new WeakMap(), Zn = /* @__PURE__ */ new WeakMap(), ce = /* @__PURE__ */ new WeakMap(), sr = /* @__PURE__ */ new WeakSet(), oi = class {
  constructor(t) {
    Ce(this, sr), m(this, Jt, /* @__PURE__ */ new WeakMap()), m(this, Zn, void 0), m(this, ce, void 0), y(ce, this, t);
  }
  observe(t, n) {
    var e = s(Jt, this).get(t) || /* @__PURE__ */ new Set();
    return e.add(n), s(Jt, this).set(t, e), b(sr, this, ns).call(this).observe(t, s(ce, this)), () => {
      var r = s(Jt, this).get(t);
      r.delete(n), r.size === 0 && (s(Jt, this).delete(t), s(Zn, this).unobserve(t));
    };
  }
};
ii = oi;
function ns() {
  return s(Zn, this) ?? y(Zn, this, new ResizeObserver((t) => {
    for (var n of t) {
      ii.entries.set(n.target, n);
      for (var e of s(Jt, this).get(n.target) || []) e(n);
    }
  }));
}
x(oi, "entries", /* @__PURE__ */ new WeakMap());
function fe(t, n) {
  return t === n || t?.[an] === n;
}
function lr(t = {}, n, e, r) {
  var i = E.r, o = $;
  return Ir(() => {
    var a, l;
    return Ne(() => {
      a = l, l = r?.() || [], ne(() => {
        fe(e(...l), t) || (n(t, ...l), a && fe(e(...a), t) && n(null, ...a));
      });
    }), () => {
      let c = o;
      for (; c !== i && c.parent !== null && c.parent.f & 33554432; ) c = c.parent;
      const u = () => {
        l && fe(e(...l), t) && n(null, ...l);
      }, h = c.teardown;
      c.teardown = () => {
        u(), h?.();
      };
    };
  }), t;
}
function rn(t, n, e, r) {
  var i = !wn || (e & 2) !== 0, o = (e & 8) !== 0, a = (e & 16) !== 0, l = r, c = !0, u = void 0, h = () => a && i ? (u ?? (u = /* @__PURE__ */ dn(r)), f(u)) : (c && (c = !1, l = a ? ne(r) : r), l);
  let v;
  if (o) {
    var d = an in t || cr in t;
    v = Et(t, n)?.set ?? (d && n in t ? (D) => t[n] = D : void 0);
  }
  var p, w = !1;
  o ? [p, w] = ro(() => t[n]) : p = t[n], p === void 0 && r !== void 0 && (p = h(), v && (i && Hi(n), v(p)));
  var _;
  if (i ? _ = () => {
    var D = t[n];
    return D === void 0 ? h() : (c = !0, D);
  } : _ = () => {
    var D = t[n];
    return D !== void 0 && (l = void 0), D === void 0 ? l : D;
  }, i && (e & 4) === 0) return _;
  if (v) {
    var C = t.$$legacy;
    return (function(D, Lt) {
      return arguments.length > 0 ? ((!i || !Lt || C || w) && v(Lt ? _() : D), D) : _();
    });
  }
  var O = !1, N = ((e & 1) !== 0 ? dn : Pr)(() => (O = !1, _()));
  o && f(N);
  var X = $;
  return (function(D, Lt) {
    if (arguments.length > 0) {
      const Ft = Lt ? f(N) : i && o ? xt(D) : D;
      return S(N, Ft), O = !0, l !== void 0 && (l = Ft), D;
    }
    return wt && O || (X.f & 16384) !== 0 ? N.v : f(N);
  });
}
function es(t) {
  return new rs(t);
}
var Mt = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap(), rs = class {
  constructor(t) {
    m(this, Mt, void 0), m(this, ot, void 0);
    var n = /* @__PURE__ */ new Map(), e = (i, o) => {
      var a = /* @__PURE__ */ _o(o, !1, !1);
      return n.set(i, a), a;
    };
    const r = new Proxy({
      ...t.props || {},
      $$events: {}
    }, {
      get(i, o) {
        return f(n.get(o) ?? e(o, Reflect.get(i, o)));
      },
      has(i, o) {
        return o === cr ? !0 : (f(n.get(o) ?? e(o, Reflect.get(i, o))), Reflect.has(i, o));
      },
      set(i, o, a) {
        return S(n.get(o) ?? e(o, a), a), Reflect.set(i, o, a);
      }
    });
    y(ot, this, (t.hydrate ? Ho : ei)(t.component, {
      target: t.target,
      anchor: t.anchor,
      props: r,
      context: t.context,
      intro: t.intro ?? !1,
      recover: t.recover,
      transformError: t.transformError
    })), !pt && (!t?.props?.$$host || t.sync === !1) && Ht(), y(Mt, this, r.$$events);
    for (const i of Object.keys(s(ot, this))) i === "$set" || i === "$destroy" || i === "$on" || Fn(this, i, {
      get() {
        return s(ot, this)[i];
      },
      set(o) {
        s(ot, this)[i] = o;
      },
      enumerable: !0
    });
    s(ot, this).$set = (i) => {
      Object.assign(r, i);
    }, s(ot, this).$destroy = () => {
      Vo(s(ot, this));
    };
  }
  $set(t) {
    s(ot, this).$set(t);
  }
  $on(t, n) {
    s(Mt, this)[t] = s(Mt, this)[t] || [];
    const e = (...r) => n.call(this, ...r);
    return s(Mt, this)[t].push(e), () => {
      s(Mt, this)[t] = s(Mt, this)[t].filter((r) => r !== e);
    };
  }
  $destroy() {
    s(ot, this).$destroy();
  }
}, si;
typeof HTMLElement == "function" && (si = class extends HTMLElement {
  constructor(t, n, e) {
    super(), x(this, "$$ctor", void 0), x(this, "$$s", void 0), x(this, "$$c", void 0), x(this, "$$cn", !1), x(this, "$$d", {}), x(this, "$$r", !1), x(this, "$$p_d", {}), x(this, "$$l", {}), x(this, "$$l_u", /* @__PURE__ */ new Map()), x(this, "$$me", void 0), x(this, "$$shadowRoot", null), this.$$ctor = t, this.$$s = n, e && (this.$$shadowRoot = this.attachShadow(e));
  }
  addEventListener(t, n, e) {
    if (this.$$l[t] = this.$$l[t] || [], this.$$l[t].push(n), this.$$c) {
      const r = this.$$c.$on(t, n);
      this.$$l_u.set(n, r);
    }
    super.addEventListener(t, n, e);
  }
  removeEventListener(t, n, e) {
    if (super.removeEventListener(t, n, e), this.$$c) {
      const r = this.$$l_u.get(n);
      r && (r(), this.$$l_u.delete(n));
    }
  }
  async connectedCallback() {
    if (this.$$cn = !0, !this.$$c) {
      let t = function(r) {
        return (i) => {
          const o = je("slot");
          r !== "default" && (o.name = r), Gt(i, o);
        };
      };
      if (await Promise.resolve(), !this.$$cn || this.$$c) return;
      const n = {}, e = is(this);
      for (const r of this.$$s) r in e && (r === "default" && !this.$$d.children ? (this.$$d.children = t(r), n.default = !0) : n[r] = t(r));
      for (const r of this.attributes) {
        const i = this.$$g_p(r.name);
        i in this.$$d || (this.$$d[i] = qn(i, r.value, this.$$p_d, "toProp"));
      }
      for (const r in this.$$p_d) !(r in this.$$d) && this[r] !== void 0 && (this.$$d[r] = this[r], delete this[r]);
      this.$$c = es({
        component: this.$$ctor,
        target: this.$$shadowRoot || this,
        props: {
          ...this.$$d,
          $$slots: n,
          $$host: this
        }
      }), this.$$me = Wo(() => {
        Ne(() => {
          this.$$r = !0;
          for (const r of Ln(this.$$c)) {
            if (!this.$$p_d[r]?.reflect) continue;
            this.$$d[r] = this.$$c[r];
            const i = qn(r, this.$$d[r], this.$$p_d, "toAttribute");
            i == null ? this.removeAttribute(this.$$p_d[r].attribute || r) : this.setAttribute(this.$$p_d[r].attribute || r, i);
          }
          this.$$r = !1;
        });
      });
      for (const r in this.$$l) for (const i of this.$$l[r]) {
        const o = this.$$c.$on(r, i);
        this.$$l_u.set(i, o);
      }
      this.$$l = {};
    }
  }
  attributeChangedCallback(t, n, e) {
    this.$$r || (t = this.$$g_p(t), this.$$d[t] = qn(t, e, this.$$p_d, "toProp"), this.$$c?.$set({ [t]: this.$$d[t] }));
  }
  disconnectedCallback() {
    this.$$cn = !1, Promise.resolve().then(() => {
      !this.$$cn && this.$$c && (this.$$c.$destroy(), this.$$me(), this.$$c = void 0);
    });
  }
  $$g_p(t) {
    return Ln(this.$$p_d).find((n) => this.$$p_d[n].attribute === t || !this.$$p_d[n].attribute && n.toLowerCase() === t) || t;
  }
});
function qn(t, n, e, r) {
  const i = e[t]?.type;
  if (n = i === "Boolean" && typeof n != "boolean" ? n != null : n, !r || !e[t]) return n;
  if (r === "toAttribute") switch (i) {
    case "Object":
    case "Array":
      return n == null ? null : JSON.stringify(n);
    case "Boolean":
      return n ? "" : null;
    case "Number":
      return n ?? null;
    default:
      return n;
  }
  else switch (i) {
    case "Object":
    case "Array":
      return n && JSON.parse(n);
    case "Boolean":
      return n;
    case "Number":
      return n != null ? +n : n;
    default:
      return n;
  }
}
function is(t) {
  const n = {};
  return t.childNodes.forEach((e) => {
    n[e.slot || "default"] = !0;
  }), n;
}
function os(t, n, e, r, i, o) {
  let a = class extends si {
    constructor() {
      super(t, e, i), this.$$p_d = n;
    }
    static get observedAttributes() {
      return Ln(n).map((l) => (n[l].attribute || l).toLowerCase());
    }
  };
  return Ln(n).forEach((l) => {
    Fn(a.prototype, l, {
      get() {
        return this.$$c && l in this.$$c ? this.$$c[l] : this.$$d[l];
      },
      set(c) {
        c = qn(l, c, n), this.$$d[l] = c;
        var u = this.$$c;
        u && (Et(u, l)?.get ? u[l] = c : u.$set({ [l]: c }));
      }
    });
  }), r.forEach((l) => {
    Fn(a.prototype, l, { get() {
      return this.$$c?.[l];
    } });
  }), o && (a = o(a)), t.element = a, a;
}
var ss = /* @__PURE__ */ _n('<div class="pie-tool-calculator__loading svelte-sun9kf">Loading calculator...</div>'), ls = /* @__PURE__ */ _n('<div class="pie-tool-calculator__error-details svelte-sun9kf"> </div>'), as = /* @__PURE__ */ _n('<div class="pie-tool-calculator__loading pie-tool-calculator__loading--error svelte-sun9kf">Calculator failed to initialize. <!></div>'), us = /* @__PURE__ */ _n('<div class="pie-tool-calculator notranslate svelte-sun9kf" role="region" tabindex="-1" aria-label="Calculator tool" translate="no" style="width: 100%; height: 100%;"><div class="pie-tool-calculator__container svelte-sun9kf"></div> <!> <!></div>'), cs = /* @__PURE__ */ _n('<div class="pie-tool-calculator__context-host svelte-sun9kf"><!></div>'), fs = {
  hash: "svelte-sun9kf",
  code: ".pie-tool-calculator__context-host.svelte-sun9kf {width:100%;height:100%;display:flex;min-height:0;}.pie-tool-calculator.svelte-sun9kf {position:relative;background:white;overflow:hidden;min-width:100%;min-height:0;display:flex;flex-direction:column;flex:1 1 auto;}.pie-tool-calculator__container.svelte-sun9kf {background:white;width:100%;height:100%;min-width:100%;min-height:100%;position:relative;overflow:hidden;}.pie-tool-calculator__loading.svelte-sun9kf {position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(255, 255, 255, 0.9);color:#334155;font-size:0.9rem;z-index:2;}.pie-tool-calculator__loading--error.svelte-sun9kf {color:#b91c1c;flex-direction:column;gap:0.5rem;padding:0.75rem;text-align:center;}.pie-tool-calculator__error-details.svelte-sun9kf {font-size:0.8rem;line-height:1.2;color:#7f1d1d;max-width:95%;word-break:break-word;}.pie-tool-calculator__container .dcg-container {width:100% !important;height:100% !important;}"
};
function hs(t, n) {
  vr(n, !0), Uo(t, fs);
  let e = rn(n, "visible", 7, !1), r = rn(n, "toolId", 7, "calculator"), i = rn(n, "calculatorType", 7, "basic"), o = rn(n, "availableTypes", 23, () => [
    "basic",
    "scientific",
    "graphing"
  ]), a = rn(n, "toolkitCoordinator", 7, null), l = /* @__PURE__ */ z(null), c = /* @__PURE__ */ z(null);
  const u = /* @__PURE__ */ Je(() => a() ?? f(c)?.toolkitCoordinator);
  let h = /* @__PURE__ */ Je(() => typeof o() == "string" ? o().split(",").map((g) => g.trim()) : o()), v = /* @__PURE__ */ z(void 0), d = /* @__PURE__ */ z(null), p = /* @__PURE__ */ z("basic"), w = /* @__PURE__ */ z(!1), _ = /* @__PURE__ */ z(!1), C = /* @__PURE__ */ z(!1), O = /* @__PURE__ */ z(null), N = /* @__PURE__ */ z(!1);
  const X = ".dcg-container,.dcg-calculator-api-container,iframe,canvas";
  Kt(() => {
    if (f(l)) return mi(f(l), (g) => {
      S(c, g, !0);
    });
  });
  function D() {
    return "calculator-desmos";
  }
  async function Lt(g) {
    if (console.log("[ToolCalculator] getProvider called", {
      type: g,
      hasToolkitCoordinator: !!f(u),
      hasRegistry: !!f(u)?.toolProviderRegistry
    }), !f(u)?.toolProviderRegistry) return console.warn("[ToolCalculator] No toolkitCoordinator or registry available"), null;
    try {
      const T = D();
      console.log(`[ToolCalculator] Requesting ${T} provider from registry`);
      const W = await f(u).toolProviderRegistry.getProvider(T);
      return console.log("[ToolCalculator] Got provider from registry:", W), W;
    } catch (T) {
      return console.error("[ToolCalculator] Failed to get provider:", T), null;
    }
  }
  function Ft(g) {
    return g ? g.childElementCount > 0 || !!g.querySelector(X) : !1;
  }
  function li(g) {
    if (g) for (const T of [
      60,
      250,
      1e3,
      2500
    ]) setTimeout(() => {
      try {
        g.resize?.();
      } catch {
      }
    }, T);
  }
  async function Re(g, T, W = 8e3) {
    if (!g || !await ai(g, W)) return !1;
    S(N, !0);
    try {
      T?.resize?.();
    } catch {
    }
    return !0;
  }
  async function ai(g, T = 3e3) {
    if (!g) return !1;
    const W = Date.now();
    for (; Date.now() - W < T; ) {
      if (!g.isConnected) return !1;
      if (Ft(g)) return !0;
      await new Promise((_t) => setTimeout(_t, 100));
    }
    return Ft(g);
  }
  function ze() {
    requestAnimationFrame(() => {
      try {
        if (!e()) return;
        const g = f(d), T = f(v);
        if (!g || !T || !T.isConnected) return;
        const W = document.activeElement;
        if (W instanceof Node && T.contains(W)) return;
        g.focus?.();
      } catch {
      }
    });
  }
  function ui(g, T) {
    return new Promise((W) => {
      let _t = g;
      function Mn() {
        if (T?.aborted || _t <= 0) {
          W();
          return;
        }
        _t--, requestAnimationFrame(Mn);
      }
      Mn();
    });
  }
  function ci(g) {
    const T = g === "graphing";
    return {
      theme: "light",
      restrictedMode: !1,
      desmos: {
        degreeMode: !0,
        settingsMenu: T,
        qwertyKeyboard: !1,
        notes: T,
        folders: T,
        sliders: T,
        tables: T
      }
    };
  }
  let qe = /* @__PURE__ */ z(xt(ci("basic")));
  async function ee() {
    if (console.log("[ToolCalculator] initCalculator called", {
      isInitializing: f(w),
      isSwitching: f(_),
      hasCalculatorInstance: !!f(d),
      hasContainerEl: !!f(v),
      initializationFailed: f(C),
      hasToolkitCoordinator: !!f(u),
      hasRegistry: !!f(u)?.toolProviderRegistry
    }), f(w) || f(_) || f(d) || !f(v) || f(C)) {
      console.log("[ToolCalculator] Early return from initCalculator");
      return;
    }
    S(w, !0);
    try {
      f(h).includes(f(p)) || (console.log("[ToolCalculator] Calculator type not available, using fallback", {
        requested: f(p),
        availableTypes: f(h),
        fallback: f(h)[0] || "basic"
      }), S(p, f(h)[0] || "basic", !0)), console.log("[ToolCalculator] Getting provider for type:", f(p));
      const g = await Lt(f(p));
      if (console.log("[ToolCalculator] Got tool provider:", g), !g) throw new Error("Desmos calculator tool provider not available");
      console.log("[ToolCalculator] Creating calculator provider instance");
      const T = await g.createInstance();
      if (console.log("[ToolCalculator] Got calculator provider:", T), !f(v) || f(d) || f(_)) {
        console.log("[ToolCalculator] Aborting due to state change");
        return;
      }
      console.log("[ToolCalculator] Creating calculator with config:", {
        type: f(p),
        hasContainer: !!f(v),
        config: f(qe)
      });
      const W = f(v);
      if (!W || !W.isConnected) {
        console.warn("[ToolCalculator] Calculator container unavailable before mount");
        return;
      }
      if (!W.isConnected) {
        console.warn("[ToolCalculator] Calculator container disconnected before init");
        return;
      }
      S(d, await T.createCalculator(f(p), W, f(qe)), !0), await ui(2), f(d)?.resize?.(), li(f(d)), S(N, !1), await Re(W, f(d), 4e3) || (console.warn("[ToolCalculator] Calculator mount pending after init; keeping instance and monitoring"), Re(W, f(d), 12e3)), console.log("[ToolCalculator] Calculator instance created:", f(d)), S(C, !1), S(O, null), S(N, Ft(W), !0), console.log(`[ToolCalculator] ${f(p)} calculator initialized successfully`), f(N) && ze();
    } catch (g) {
      S(C, !0), S(O, g instanceof Error ? g.message : String(g), !0), console.error("[ToolCalculator] Failed to initialize calculator:", g), S(d, null), S(N, !1);
    } finally {
      S(w, !1);
    }
  }
  Kt(() => {
    !i() || !f(h).includes(i()) || S(p, i());
  }), Go(() => (e() && ee(), () => {
    f(d)?.destroy();
  })), Kt(() => {
    if (!e()) {
      if (f(d)) try {
        f(d).destroy();
      } catch (g) {
        console.warn("[ToolCalculator] Error destroying calculator on hide:", g);
      } finally {
        S(d, null);
      }
      S(C, !1), S(O, null), S(N, !1);
      return;
    }
    !f(d) && !f(w) && !f(_) && !f(C) && (f(v)?.isConnected ? ee() : queueMicrotask(() => {
      e() && f(v)?.isConnected && !f(d) && !f(w) && !f(_) && !f(C) && ee();
    }));
  }), Kt(() => {
    e() && f(d) && f(N) && ze();
  });
  let I = null;
  Kt(() => {
    if (e() && f(v) && f(d) && f(v).isConnected) return I || (I = new ResizeObserver((g) => {
      for (const T of g) if (!T.target.isConnected) {
        I?.unobserve(T.target);
        return;
      }
      if (f(d)?.resize && f(v)?.isConnected && e()) try {
        f(d).resize();
      } catch (T) {
        console.warn("[ToolCalculator] Error during resize:", T), I && f(v) && I.unobserve(f(v));
      }
    })), I.observe(f(v)), () => {
      I && f(v) && I.unobserve(f(v)), I?.disconnect(), I = null;
    };
    I && (f(v) && I.unobserve(f(v)), I.disconnect(), I = null);
  });
  var fi = {
    get visible() {
      return e();
    },
    set visible(g = !1) {
      e(g), Ht();
    },
    get toolId() {
      return r();
    },
    set toolId(g = "calculator") {
      r(g), Ht();
    },
    get calculatorType() {
      return i();
    },
    set calculatorType(g = "basic") {
      i(g), Ht();
    },
    get availableTypes() {
      return o();
    },
    set availableTypes(g = [
      "basic",
      "scientific",
      "graphing"
    ]) {
      o(g), Ht();
    },
    get toolkitCoordinator() {
      return a();
    },
    set toolkitCoordinator(g = null) {
      a(g), Ht();
    }
  }, kn = cs(), hi = En(kn), di = (g) => {
    var T = us(), W = En(T);
    lr(W, (ht) => S(v, ht), () => f(v));
    var _t = le(W, 2), Mn = (ht) => {
      Gt(ht, ss());
    };
    An(_t, (ht) => {
      (f(w) || f(_) || e() && !f(C) && !f(N)) && ht(Mn);
    });
    var vi = le(_t, 2), pi = (ht) => {
      var re = as(), gi = le(En(re)), wi = (ie) => {
        var oe = ls(), yi = En(oe, !0);
        Tn(oe), Qe(() => Bo(yi, f(O))), Gt(ie, oe);
      };
      An(gi, (ie) => {
        f(O) && ie(wi);
      }), Tn(re), Gt(ht, re);
    };
    An(vi, (ht) => {
      f(C) && ht(pi);
    }), Tn(T), Qe(() => {
      ir(T, "data-tool-id", r()), ir(W, "data-calculator-type", f(p));
    }), Gt(g, T);
  };
  return An(hi, (g) => {
    e() && g(di);
  }), Tn(kn), lr(kn, (g) => S(l, g), () => f(l)), Gt(t, kn), pr(fi);
}
customElements.define("pie-tool-calculator", os(hs, {
  visible: {
    attribute: "visible",
    type: "Boolean"
  },
  toolId: {
    attribute: "tool-id",
    type: "String"
  },
  calculatorType: {
    attribute: "calculator-type",
    type: "String"
  },
  availableTypes: {
    attribute: "available-types",
    type: "Array"
  },
  toolkitCoordinator: { type: "Object" }
}, [], []));
export {
  hs as default
};
