var Xt = Array.isArray, Zt = Array.prototype.indexOf, _e = Array.prototype.includes, Jt = Array.from, Qt = Object.defineProperty, ye = Object.getOwnPropertyDescriptor, en = Object.getOwnPropertyDescriptors, tn = Object.prototype, nn = Array.prototype, ht = Object.getPrototypeOf, nt = Object.isExtensible;
function nr(e) {
  return typeof e == "function";
}
const rn = () => {
};
function rr(e) {
  return e();
}
function sn(e) {
  for (var t = 0; t < e.length; t++)
    e[t]();
}
function dt() {
  var e, t, n = new Promise((r, s) => {
    e = r, t = s;
  });
  return { promise: n, resolve: e, reject: t };
}
const b = 2, he = 4, Se = 8, $e = 1 << 24, J = 16, B = 32, se = 64, je = 128, P = 512, E = 1024, A = 2048, F = 4096, j = 8192, V = 16384, fe = 32768, rt = 1 << 25, be = 65536, st = 1 << 17, ln = 1 << 18, ve = 1 << 19, vt = 1 << 20, sr = 1 << 25, ie = 65536, Ve = 1 << 21, ze = 1 << 22, K = 1 << 23, ne = /* @__PURE__ */ Symbol("$state"), ir = /* @__PURE__ */ Symbol("legacy props"), lr = /* @__PURE__ */ Symbol(""), H = new class extends Error {
  name = "StaleReactionError";
  message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
}(), fr = (
  // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
  !!globalThis.document?.contentType && /* @__PURE__ */ globalThis.document.contentType.includes("xml")
);
function an() {
  throw new Error("https://svelte.dev/e/async_derived_orphan");
}
function ur(e, t, n) {
  throw new Error("https://svelte.dev/e/each_key_duplicate");
}
function fn(e) {
  throw new Error("https://svelte.dev/e/effect_in_teardown");
}
function un() {
  throw new Error("https://svelte.dev/e/effect_in_unowned_derived");
}
function on(e) {
  throw new Error("https://svelte.dev/e/effect_orphan");
}
function cn() {
  throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
}
function or(e) {
  throw new Error("https://svelte.dev/e/props_invalid_value");
}
function _n() {
  throw new Error("https://svelte.dev/e/state_descriptors_fixed");
}
function hn() {
  throw new Error("https://svelte.dev/e/state_prototype_fixed");
}
function dn() {
  throw new Error("https://svelte.dev/e/state_unsafe_mutation");
}
function vn() {
  throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
}
const cr = 1, _r = 2, hr = 4, dr = 8, vr = 16, pr = 1, gr = 2, wr = 4, yr = 8, Er = 16, mr = 1, br = 2, T = /* @__PURE__ */ Symbol(), pn = "http://www.w3.org/1999/xhtml", Tr = "http://www.w3.org/2000/svg", Sr = "@attach";
function Ar() {
  console.warn("https://svelte.dev/e/select_multiple_invalid_value");
}
function gn() {
  console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
}
function pt(e) {
  return e === this.v;
}
function wn(e, t) {
  return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
}
function gt(e) {
  return !wn(e, this.v);
}
let Ne = !1;
function xr() {
  Ne = !0;
}
let m = null;
function de(e) {
  m = e;
}
function yn(e, t = !1, n) {
  m = {
    p: m,
    i: !1,
    c: null,
    e: null,
    s: e,
    x: null,
    r: (
      /** @type {Effect} */
      p
    ),
    l: Ne && !t ? { s: null, u: null, $: [] } : null
  };
}
function En(e) {
  var t = (
    /** @type {ComponentContext} */
    m
  ), n = t.e;
  if (n !== null) {
    t.e = null;
    for (var r of n)
      Lt(r);
  }
  return t.i = !0, m = t.p, /** @type {T} */
  {};
}
function Ae() {
  return !Ne || m !== null && m.l === null;
}
let ee = [];
function wt() {
  var e = ee;
  ee = [], sn(e);
}
function W(e) {
  if (ee.length === 0 && !Ee) {
    var t = ee;
    queueMicrotask(() => {
      t === ee && wt();
    });
  }
  ee.push(e);
}
function mn() {
  for (; ee.length > 0; )
    wt();
}
function yt(e) {
  var t = p;
  if (t === null)
    return d.f |= K, e;
  if ((t.f & fe) === 0 && (t.f & he) === 0)
    throw e;
  $(e, t);
}
function $(e, t) {
  for (; t !== null; ) {
    if ((t.f & je) !== 0) {
      if ((t.f & fe) === 0)
        throw e;
      try {
        t.b.error(e);
        return;
      } catch (n) {
        e = n;
      }
    }
    t = t.parent;
  }
  throw e;
}
const bn = -7169;
function y(e, t) {
  e.f = e.f & bn | t;
}
function Ke(e) {
  (e.f & P) !== 0 || e.deps === null ? y(e, E) : y(e, F);
}
function Et(e) {
  if (e !== null)
    for (const t of e)
      (t.f & b) === 0 || (t.f & ie) === 0 || (t.f ^= ie, Et(
        /** @type {Derived} */
        t.deps
      ));
}
function mt(e, t, n) {
  (e.f & A) !== 0 ? t.add(e) : (e.f & F) !== 0 && n.add(e), Et(e.deps), y(e, E);
}
const oe = /* @__PURE__ */ new Set();
let w = null, D = null, qe = null, Ee = !1, Le = !1, ce = null, Re = null;
var it = 0;
let Tn = 1;
class Z {
  // for debugging. TODO remove once async is stable
  id = Tn++;
  /**
   * The current values of any sources that are updated in this batch
   * They keys of this map are identical to `this.#previous`
   * @type {Map<Source, any>}
   */
  current = /* @__PURE__ */ new Map();
  /**
   * The values of any sources that are updated in this batch _before_ those updates took place.
   * They keys of this map are identical to `this.#current`
   * @type {Map<Source, any>}
   */
  previous = /* @__PURE__ */ new Map();
  /**
   * When the batch is committed (and the DOM is updated), we need to remove old branches
   * and append new ones by calling the functions added inside (if/each/key/etc) blocks
   * @type {Set<(batch: Batch) => void>}
   */
  #s = /* @__PURE__ */ new Set();
  /**
   * If a fork is discarded, we need to destroy any effects that are no longer needed
   * @type {Set<(batch: Batch) => void>}
   */
  #d = /* @__PURE__ */ new Set();
  /**
   * The number of async effects that are currently in flight
   */
  #l = 0;
  /**
   * The number of async effects that are currently in flight, _not_ inside a pending boundary
   */
  #a = 0;
  /**
   * A deferred that resolves when the batch is committed, used with `settled()`
   * TODO replace with Promise.withResolvers once supported widely enough
   * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
   */
  #r = null;
  /**
   * The root effects that need to be flushed
   * @type {Effect[]}
   */
  #e = [];
  /**
   * Deferred effects (which run after async work has completed) that are DIRTY
   * @type {Set<Effect>}
   */
  #t = /* @__PURE__ */ new Set();
  /**
   * Deferred effects that are MAYBE_DIRTY
   * @type {Set<Effect>}
   */
  #n = /* @__PURE__ */ new Set();
  /**
   * A map of branches that still exist, but will be destroyed when this batch
   * is committed — we skip over these during `process`.
   * The value contains child effects that were dirty/maybe_dirty before being reset,
   * so they can be rescheduled if the branch survives.
   * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
   */
  #i = /* @__PURE__ */ new Map();
  is_fork = !1;
  #f = !1;
  #u() {
    return this.is_fork || this.#a > 0;
  }
  /**
   * Add an effect to the #skipped_branches map and reset its children
   * @param {Effect} effect
   */
  skip_effect(t) {
    this.#i.has(t) || this.#i.set(t, { d: [], m: [] });
  }
  /**
   * Remove an effect from the #skipped_branches map and reschedule
   * any tracked dirty/maybe_dirty child effects
   * @param {Effect} effect
   */
  unskip_effect(t) {
    var n = this.#i.get(t);
    if (n) {
      this.#i.delete(t);
      for (var r of n.d)
        y(r, A), this.schedule(r);
      for (r of n.m)
        y(r, F), this.schedule(r);
    }
  }
  #c() {
    if (it++ > 1e3 && (oe.delete(this), An()), !this.#u()) {
      for (const a of this.#t)
        this.#n.delete(a), y(a, A), this.schedule(a);
      for (const a of this.#n)
        y(a, F), this.schedule(a);
    }
    const t = this.#e;
    this.#e = [], this.apply();
    var n = ce = [], r = [], s = Re = [];
    for (const a of t)
      try {
        this.#_(a, n, r);
      } catch (l) {
        throw At(a), l;
      }
    if (w = null, s.length > 0) {
      var i = Z.ensure();
      for (const a of s)
        i.schedule(a);
    }
    if (ce = null, Re = null, this.#u()) {
      this.#h(r), this.#h(n);
      for (const [a, l] of this.#i)
        St(a, l);
    } else {
      this.#l === 0 && oe.delete(this), this.#t.clear(), this.#n.clear();
      for (const a of this.#s) a(this);
      this.#s.clear(), lt(r), lt(n), this.#r?.resolve();
    }
    var u = (
      /** @type {Batch | null} */
      /** @type {unknown} */
      w
    );
    if (this.#e.length > 0) {
      const a = u ??= this;
      a.#e.push(...this.#e.filter((l) => !a.#e.includes(l)));
    }
    u !== null && (oe.add(u), u.#c()), oe.has(this) || this.#o();
  }
  /**
   * Traverse the effect tree, executing effects or stashing
   * them for later execution as appropriate
   * @param {Effect} root
   * @param {Effect[]} effects
   * @param {Effect[]} render_effects
   */
  #_(t, n, r) {
    t.f ^= E;
    for (var s = t.first; s !== null; ) {
      var i = s.f, u = (i & (B | se)) !== 0, a = u && (i & E) !== 0, l = a || (i & j) !== 0 || this.#i.has(s);
      if (!l && s.fn !== null) {
        u ? s.f ^= E : (i & he) !== 0 ? n.push(s) : pe(s) && ((i & J) !== 0 && this.#n.add(s), ae(s));
        var f = s.first;
        if (f !== null) {
          s = f;
          continue;
        }
      }
      for (; s !== null; ) {
        var o = s.next;
        if (o !== null) {
          s = o;
          break;
        }
        s = s.parent;
      }
    }
  }
  /**
   * @param {Effect[]} effects
   */
  #h(t) {
    for (var n = 0; n < t.length; n += 1)
      mt(t[n], this.#t, this.#n);
  }
  /**
   * Associate a change to a given source with the current
   * batch, noting its previous and current values
   * @param {Source} source
   * @param {any} old_value
   */
  capture(t, n) {
    n !== T && !this.previous.has(t) && this.previous.set(t, n), (t.f & K) === 0 && (this.current.set(t, t.v), D?.set(t, t.v));
  }
  activate() {
    w = this;
  }
  deactivate() {
    w = null, D = null;
  }
  flush() {
    try {
      Le = !0, w = this, this.#c();
    } finally {
      it = 0, qe = null, ce = null, Re = null, Le = !1, w = null, D = null, X.clear();
    }
  }
  discard() {
    for (const t of this.#d) t(this);
    this.#d.clear();
  }
  #o() {
    for (const l of oe) {
      var t = l.id < this.id, n = [];
      for (const [f, o] of this.current) {
        if (l.current.has(f))
          if (t && o !== l.current.get(f))
            l.current.set(f, o);
          else
            continue;
        n.push(f);
      }
      if (n.length !== 0) {
        var r = [...l.current.keys()].filter((f) => !this.current.has(f));
        if (r.length > 0) {
          l.activate();
          var s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
          for (var u of n)
            bt(u, r, s, i);
          if (l.#e.length > 0) {
            l.apply();
            for (var a of l.#e)
              l.#_(a, [], []);
            l.#e = [];
          }
          l.deactivate();
        }
      }
    }
  }
  /**
   *
   * @param {boolean} blocking
   */
  increment(t) {
    this.#l += 1, t && (this.#a += 1);
  }
  /**
   * @param {boolean} blocking
   * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
   */
  decrement(t, n) {
    this.#l -= 1, t && (this.#a -= 1), !(this.#f || n) && (this.#f = !0, W(() => {
      this.#f = !1, this.flush();
    }));
  }
  /**
   * @param {Set<Effect>} dirty_effects
   * @param {Set<Effect>} maybe_dirty_effects
   */
  transfer_effects(t, n) {
    for (const r of t)
      this.#t.add(r);
    for (const r of n)
      this.#n.add(r);
    t.clear(), n.clear();
  }
  /** @param {(batch: Batch) => void} fn */
  oncommit(t) {
    this.#s.add(t);
  }
  /** @param {(batch: Batch) => void} fn */
  ondiscard(t) {
    this.#d.add(t);
  }
  settled() {
    return (this.#r ??= dt()).promise;
  }
  static ensure() {
    if (w === null) {
      const t = w = new Z();
      Le || (oe.add(w), Ee || W(() => {
        w === t && t.flush();
      }));
    }
    return w;
  }
  apply() {
    {
      D = null;
      return;
    }
  }
  /**
   *
   * @param {Effect} effect
   */
  schedule(t) {
    if (qe = t, t.b?.is_pending && (t.f & (he | Se | $e)) !== 0 && (t.f & fe) === 0) {
      t.b.defer_effect(t);
      return;
    }
    for (var n = t; n.parent !== null; ) {
      n = n.parent;
      var r = n.f;
      if (ce !== null && n === p && (d === null || (d.f & b) === 0))
        return;
      if ((r & (se | B)) !== 0) {
        if ((r & E) === 0)
          return;
        n.f ^= E;
      }
    }
    this.#e.push(n);
  }
}
function Sn(e) {
  var t = Ee;
  Ee = !0;
  try {
    for (var n; ; ) {
      if (mn(), w === null)
        return (
          /** @type {T} */
          n
        );
      w.flush();
    }
  } finally {
    Ee = t;
  }
}
function An() {
  try {
    cn();
  } catch (e) {
    $(e, qe);
  }
}
let Y = null;
function lt(e) {
  var t = e.length;
  if (t !== 0) {
    for (var n = 0; n < t; ) {
      var r = e[n++];
      if ((r.f & (V | j)) === 0 && pe(r) && (Y = /* @__PURE__ */ new Set(), ae(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Vt(r), Y?.size > 0)) {
        X.clear();
        for (const s of Y) {
          if ((s.f & (V | j)) !== 0) continue;
          const i = [s];
          let u = s.parent;
          for (; u !== null; )
            Y.has(u) && (Y.delete(u), i.push(u)), u = u.parent;
          for (let a = i.length - 1; a >= 0; a--) {
            const l = i[a];
            (l.f & (V | j)) === 0 && ae(l);
          }
        }
        Y.clear();
      }
    }
    Y = null;
  }
}
function bt(e, t, n, r) {
  if (!n.has(e) && (n.add(e), e.reactions !== null))
    for (const s of e.reactions) {
      const i = s.f;
      (i & b) !== 0 ? bt(
        /** @type {Derived} */
        s,
        t,
        n,
        r
      ) : (i & (ze | J)) !== 0 && (i & A) === 0 && Tt(s, t, r) && (y(s, A), We(
        /** @type {Effect} */
        s
      ));
    }
}
function Tt(e, t, n) {
  const r = n.get(e);
  if (r !== void 0) return r;
  if (e.deps !== null)
    for (const s of e.deps) {
      if (_e.call(t, s))
        return !0;
      if ((s.f & b) !== 0 && Tt(
        /** @type {Derived} */
        s,
        t,
        n
      ))
        return n.set(
          /** @type {Derived} */
          s,
          !0
        ), !0;
    }
  return n.set(e, !1), !1;
}
function We(e) {
  w.schedule(e);
}
function St(e, t) {
  if (!((e.f & B) !== 0 && (e.f & E) !== 0)) {
    (e.f & A) !== 0 ? t.d.push(e) : (e.f & F) !== 0 && t.m.push(e), y(e, E);
    for (var n = e.first; n !== null; )
      St(n, t), n = n.next;
  }
}
function At(e) {
  y(e, E);
  for (var t = e.first; t !== null; )
    At(t), t = t.next;
}
function xn(e) {
  let t = 0, n = xe(0), r;
  return () => {
    Je() && (z(n), Qe(() => (t === 0 && (r = tt(() => e(() => me(n)))), t += 1, () => {
      W(() => {
        t -= 1, t === 0 && (r?.(), r = void 0, me(n));
      });
    })));
  };
}
var kn = be | ve;
function Rn(e, t, n, r) {
  new Pn(e, t, n, r);
}
class Pn {
  /** @type {Boundary | null} */
  parent;
  is_pending = !1;
  /**
   * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
   * Inherited from parent boundary, or defaults to identity.
   * @type {(error: unknown) => unknown}
   */
  transform_error;
  /** @type {TemplateNode} */
  #s;
  /** @type {TemplateNode | null} */
  #d = null;
  /** @type {BoundaryProps} */
  #l;
  /** @type {((anchor: Node) => void)} */
  #a;
  /** @type {Effect} */
  #r;
  /** @type {Effect | null} */
  #e = null;
  /** @type {Effect | null} */
  #t = null;
  /** @type {Effect | null} */
  #n = null;
  /** @type {DocumentFragment | null} */
  #i = null;
  #f = 0;
  #u = 0;
  #c = !1;
  /** @type {Set<Effect>} */
  #_ = /* @__PURE__ */ new Set();
  /** @type {Set<Effect>} */
  #h = /* @__PURE__ */ new Set();
  /**
   * A source containing the number of pending async deriveds/expressions.
   * Only created if `$effect.pending()` is used inside the boundary,
   * otherwise updating the source results in needless `Batch.ensure()`
   * calls followed by no-op flushes
   * @type {Source<number> | null}
   */
  #o = null;
  #y = xn(() => (this.#o = xe(this.#f), () => {
    this.#o = null;
  }));
  /**
   * @param {TemplateNode} node
   * @param {BoundaryProps} props
   * @param {((anchor: Node) => void)} children
   * @param {((error: unknown) => unknown) | undefined} [transform_error]
   */
  constructor(t, n, r, s) {
    this.#s = t, this.#l = n, this.#a = (i) => {
      var u = (
        /** @type {Effect} */
        p
      );
      u.b = this, u.f |= je, r(i);
    }, this.parent = /** @type {Effect} */
    p.b, this.transform_error = s ?? this.parent?.transform_error ?? ((i) => i), this.#r = Un(() => {
      this.#g();
    }, kn);
  }
  #E() {
    try {
      this.#e = Q(() => this.#a(this.#s));
    } catch (t) {
      this.error(t);
    }
  }
  /**
   * @param {unknown} error The deserialized error from the server's hydration comment
   */
  #m(t) {
    const n = this.#l.failed;
    n && (this.#n = Q(() => {
      n(
        this.#s,
        () => t,
        () => () => {
        }
      );
    }));
  }
  #b() {
    const t = this.#l.pending;
    t && (this.is_pending = !0, this.#t = Q(() => t(this.#s)), W(() => {
      var n = this.#i = document.createDocumentFragment(), r = Nt();
      n.append(r), this.#e = this.#p(() => Q(() => this.#a(r))), this.#u === 0 && (this.#s.before(n), this.#i = null, Pe(
        /** @type {Effect} */
        this.#t,
        () => {
          this.#t = null;
        }
      ), this.#v(
        /** @type {Batch} */
        w
      ));
    }));
  }
  #g() {
    try {
      if (this.is_pending = this.has_pending_snippet(), this.#u = 0, this.#f = 0, this.#e = Q(() => {
        this.#a(this.#s);
      }), this.#u > 0) {
        var t = this.#i = document.createDocumentFragment();
        zn(this.#e, t);
        const n = (
          /** @type {(anchor: Node) => void} */
          this.#l.pending
        );
        this.#t = Q(() => n(this.#s));
      } else
        this.#v(
          /** @type {Batch} */
          w
        );
    } catch (n) {
      this.error(n);
    }
  }
  /**
   * @param {Batch} batch
   */
  #v(t) {
    this.is_pending = !1, t.transfer_effects(this.#_, this.#h);
  }
  /**
   * Defer an effect inside a pending boundary until the boundary resolves
   * @param {Effect} effect
   */
  defer_effect(t) {
    mt(t, this.#_, this.#h);
  }
  /**
   * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
   * @returns {boolean}
   */
  is_rendered() {
    return !this.is_pending && (!this.parent || this.parent.is_rendered());
  }
  has_pending_snippet() {
    return !!this.#l.pending;
  }
  /**
   * @template T
   * @param {() => T} fn
   */
  #p(t) {
    var n = p, r = d, s = m;
    C(this.#r), I(this.#r), de(this.#r.ctx);
    try {
      return Z.ensure(), t();
    } catch (i) {
      return yt(i), null;
    } finally {
      C(n), I(r), de(s);
    }
  }
  /**
   * Updates the pending count associated with the currently visible pending snippet,
   * if any, such that we can replace the snippet with content once work is done
   * @param {1 | -1} d
   * @param {Batch} batch
   */
  #w(t, n) {
    if (!this.has_pending_snippet()) {
      this.parent && this.parent.#w(t, n);
      return;
    }
    this.#u += t, this.#u === 0 && (this.#v(n), this.#t && Pe(this.#t, () => {
      this.#t = null;
    }), this.#i && (this.#s.before(this.#i), this.#i = null));
  }
  /**
   * Update the source that powers `$effect.pending()` inside this boundary,
   * and controls when the current `pending` snippet (if any) is removed.
   * Do not call from inside the class
   * @param {1 | -1} d
   * @param {Batch} batch
   */
  update_pending_count(t, n) {
    this.#w(t, n), this.#f += t, !(!this.#o || this.#c) && (this.#c = !0, W(() => {
      this.#c = !1, this.#o && Ce(this.#o, this.#f);
    }));
  }
  get_effect_pending() {
    return this.#y(), z(
      /** @type {Source<number>} */
      this.#o
    );
  }
  /** @param {unknown} error */
  error(t) {
    var n = this.#l.onerror;
    let r = this.#l.failed;
    if (!n && !r)
      throw t;
    this.#e && (q(this.#e), this.#e = null), this.#t && (q(this.#t), this.#t = null), this.#n && (q(this.#n), this.#n = null);
    var s = !1, i = !1;
    const u = () => {
      if (s) {
        gn();
        return;
      }
      s = !0, i && vn(), this.#n !== null && Pe(this.#n, () => {
        this.#n = null;
      }), this.#p(() => {
        this.#g();
      });
    }, a = (l) => {
      try {
        i = !0, n?.(l, u), i = !1;
      } catch (f) {
        $(f, this.#r && this.#r.parent);
      }
      r && (this.#n = this.#p(() => {
        try {
          return Q(() => {
            var f = (
              /** @type {Effect} */
              p
            );
            f.b = this, f.f |= je, r(
              this.#s,
              () => l,
              () => u
            );
          });
        } catch (f) {
          return $(
            f,
            /** @type {Effect} */
            this.#r.parent
          ), null;
        }
      }));
    };
    W(() => {
      var l;
      try {
        l = this.transform_error(t);
      } catch (f) {
        $(f, this.#r && this.#r.parent);
        return;
      }
      l !== null && typeof l == "object" && typeof /** @type {any} */
      l.then == "function" ? l.then(
        a,
        /** @param {unknown} e */
        (f) => $(f, this.#r && this.#r.parent)
      ) : a(l);
    });
  }
}
function On(e, t, n, r) {
  const s = Ae() ? Xe : Nn;
  var i = e.filter((c) => !c.settled);
  if (n.length === 0 && i.length === 0) {
    r(t.map(s));
    return;
  }
  var u = (
    /** @type {Effect} */
    p
  ), a = In(), l = i.length === 1 ? i[0].promise : i.length > 1 ? Promise.all(i.map((c) => c.promise)) : null;
  function f(c) {
    a();
    try {
      r(c);
    } catch (v) {
      (u.f & V) === 0 && $(v, u);
    }
    Ie();
  }
  if (n.length === 0) {
    l.then(() => f(t.map(s)));
    return;
  }
  var o = xt();
  function _() {
    Promise.all(n.map((c) => /* @__PURE__ */ Cn(c))).then((c) => f([...t.map(s), ...c])).catch((c) => $(c, u)).finally(() => o());
  }
  l ? l.then(() => {
    a(), _(), Ie();
  }) : _();
}
function In() {
  var e = (
    /** @type {Effect} */
    p
  ), t = d, n = m, r = (
    /** @type {Batch} */
    w
  );
  return function(i = !0) {
    C(e), I(t), de(n), i && (e.f & V) === 0 && (r?.activate(), r?.apply());
  };
}
function Ie(e = !0) {
  C(null), I(null), de(null), e && w?.deactivate();
}
function xt() {
  var e = (
    /** @type {Boundary} */
    /** @type {Effect} */
    p.b
  ), t = (
    /** @type {Batch} */
    w
  ), n = e.is_rendered();
  return e.update_pending_count(1, t), t.increment(n), (r = !1) => {
    e.update_pending_count(-1, t), t.decrement(n, r);
  };
}
// @__NO_SIDE_EFFECTS__
function Xe(e) {
  var t = b | A, n = d !== null && (d.f & b) !== 0 ? (
    /** @type {Derived} */
    d
  ) : null;
  return p !== null && (p.f |= ve), {
    ctx: m,
    deps: null,
    effects: null,
    equals: pt,
    f: t,
    fn: e,
    reactions: null,
    rv: 0,
    v: (
      /** @type {V} */
      T
    ),
    wv: 0,
    parent: n ?? p,
    ac: null
  };
}
// @__NO_SIDE_EFFECTS__
function Cn(e, t, n) {
  let r = (
    /** @type {Effect | null} */
    p
  );
  r === null && an();
  var s = (
    /** @type {Promise<V>} */
    /** @type {unknown} */
    void 0
  ), i = xe(
    /** @type {V} */
    T
  ), u = !d, a = /* @__PURE__ */ new Map();
  return Hn(() => {
    var l = (
      /** @type {Effect} */
      p
    ), f = dt();
    s = f.promise;
    try {
      Promise.resolve(e()).then(f.resolve, f.reject).finally(Ie);
    } catch (v) {
      f.reject(v), Ie();
    }
    var o = (
      /** @type {Batch} */
      w
    );
    if (u) {
      if ((l.f & fe) !== 0)
        var _ = xt();
      if (
        /** @type {Boundary} */
        r.b.is_rendered()
      )
        a.get(o)?.reject(H), a.delete(o);
      else {
        for (const v of a.values())
          v.reject(H);
        a.clear();
      }
      a.set(o, f);
    }
    const c = (v, h = void 0) => {
      if (_) {
        var g = h === H;
        _(g);
      }
      if (!(h === H || (l.f & V) !== 0)) {
        if (o.activate(), h)
          i.f |= K, Ce(i, h);
        else {
          (i.f & K) !== 0 && (i.f ^= K), Ce(i, v);
          for (const [S, N] of a) {
            if (a.delete(S), S === o) break;
            N.reject(H);
          }
        }
        o.deactivate();
      }
    };
    f.promise.then(c, (v) => c(null, v || "unknown"));
  }), Ft(() => {
    for (const l of a.values())
      l.reject(H);
  }), new Promise((l) => {
    function f(o) {
      function _() {
        o === s ? l(i) : f(s);
      }
      o.then(_, _);
    }
    f(s);
  });
}
// @__NO_SIDE_EFFECTS__
function kr(e) {
  const t = /* @__PURE__ */ Xe(e);
  return Yt(t), t;
}
// @__NO_SIDE_EFFECTS__
function Nn(e) {
  const t = /* @__PURE__ */ Xe(e);
  return t.equals = gt, t;
}
function Dn(e) {
  var t = e.effects;
  if (t !== null) {
    e.effects = null;
    for (var n = 0; n < t.length; n += 1)
      q(
        /** @type {Effect} */
        t[n]
      );
  }
}
function Mn(e) {
  for (var t = e.parent; t !== null; ) {
    if ((t.f & b) === 0)
      return (t.f & V) === 0 ? (
        /** @type {Effect} */
        t
      ) : null;
    t = t.parent;
  }
  return null;
}
function Ze(e) {
  var t, n = p;
  C(Mn(e));
  try {
    e.f &= ~ie, Dn(e), t = $t(e);
  } finally {
    C(n);
  }
  return t;
}
function kt(e) {
  var t = e.v, n = Ze(e);
  if (!e.equals(n) && (e.wv = Ut(), (!w?.is_fork || e.deps === null) && (e.v = n, w?.capture(e, t), e.deps === null))) {
    y(e, E);
    return;
  }
  le || (D !== null ? (Je() || w?.is_fork) && D.set(e, n) : Ke(e));
}
function Fn(e) {
  if (e.effects !== null)
    for (const t of e.effects)
      (t.teardown || t.ac) && (t.teardown?.(), t.ac?.abort(H), t.teardown = rn, t.ac = null, Te(t, 0), et(t));
}
function Rt(e) {
  if (e.effects !== null)
    for (const t of e.effects)
      t.teardown && ae(t);
}
let Be = /* @__PURE__ */ new Set();
const X = /* @__PURE__ */ new Map();
let Pt = !1;
function xe(e, t) {
  var n = {
    f: 0,
    // TODO ideally we could skip this altogether, but it causes type errors
    v: e,
    reactions: null,
    equals: pt,
    rv: 0,
    wv: 0
  };
  return n;
}
// @__NO_SIDE_EFFECTS__
function U(e, t) {
  const n = xe(e);
  return Yt(n), n;
}
// @__NO_SIDE_EFFECTS__
function Rr(e, t = !1, n = !0) {
  const r = xe(e);
  return t || (r.equals = gt), Ne && n && m !== null && m.l !== null && (m.l.s ??= []).push(r), r;
}
function Pr(e, t) {
  return G(
    e,
    tt(() => z(e))
  ), t;
}
function G(e, t, n = !1) {
  d !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
  // to ensure we error if state is set inside an inspect effect
  (!M || (d.f & st) !== 0) && Ae() && (d.f & (b | J | ze | st)) !== 0 && (O === null || !_e.call(O, e)) && dn();
  let r = n ? ge(t) : t;
  return Ce(e, r, Re);
}
function Ce(e, t, n = null) {
  if (!e.equals(t)) {
    var r = e.v;
    le ? X.set(e, t) : X.set(e, r), e.v = t;
    var s = Z.ensure();
    if (s.capture(e, r), (e.f & b) !== 0) {
      const i = (
        /** @type {Derived} */
        e
      );
      (e.f & A) !== 0 && Ze(i), D === null && Ke(i);
    }
    e.wv = Ut(), Ot(e, A, n), Ae() && p !== null && (p.f & E) !== 0 && (p.f & (B | se)) === 0 && (R === null ? Kn([e]) : R.push(e)), !s.is_fork && Be.size > 0 && !Pt && Ln();
  }
  return t;
}
function Ln() {
  Pt = !1;
  for (const e of Be)
    (e.f & E) !== 0 && y(e, F), pe(e) && ae(e);
  Be.clear();
}
function me(e) {
  G(e, e.v + 1);
}
function Ot(e, t, n) {
  var r = e.reactions;
  if (r !== null)
    for (var s = Ae(), i = r.length, u = 0; u < i; u++) {
      var a = r[u], l = a.f;
      if (!(!s && a === p)) {
        var f = (l & A) === 0;
        if (f && y(a, t), (l & b) !== 0) {
          var o = (
            /** @type {Derived} */
            a
          );
          D?.delete(o), (l & ie) === 0 && (l & P && (a.f |= ie), Ot(o, F, n));
        } else if (f) {
          var _ = (
            /** @type {Effect} */
            a
          );
          (l & J) !== 0 && Y !== null && Y.add(_), n !== null ? n.push(_) : We(_);
        }
      }
    }
}
function ge(e) {
  if (typeof e != "object" || e === null || ne in e)
    return e;
  const t = ht(e);
  if (t !== tn && t !== nn)
    return e;
  var n = /* @__PURE__ */ new Map(), r = Xt(e), s = /* @__PURE__ */ U(0), i = re, u = (a) => {
    if (re === i)
      return a();
    var l = d, f = re;
    I(null), ct(i);
    var o = a();
    return I(l), ct(f), o;
  };
  return r && n.set("length", /* @__PURE__ */ U(
    /** @type {any[]} */
    e.length
  )), new Proxy(
    /** @type {any} */
    e,
    {
      defineProperty(a, l, f) {
        (!("value" in f) || f.configurable === !1 || f.enumerable === !1 || f.writable === !1) && _n();
        var o = n.get(l);
        return o === void 0 ? u(() => {
          var _ = /* @__PURE__ */ U(f.value);
          return n.set(l, _), _;
        }) : G(o, f.value, !0), !0;
      },
      deleteProperty(a, l) {
        var f = n.get(l);
        if (f === void 0) {
          if (l in a) {
            const o = u(() => /* @__PURE__ */ U(T));
            n.set(l, o), me(s);
          }
        } else
          G(f, T), me(s);
        return !0;
      },
      get(a, l, f) {
        if (l === ne)
          return e;
        var o = n.get(l), _ = l in a;
        if (o === void 0 && (!_ || ye(a, l)?.writable) && (o = u(() => {
          var v = ge(_ ? a[l] : T), h = /* @__PURE__ */ U(v);
          return h;
        }), n.set(l, o)), o !== void 0) {
          var c = z(o);
          return c === T ? void 0 : c;
        }
        return Reflect.get(a, l, f);
      },
      getOwnPropertyDescriptor(a, l) {
        var f = Reflect.getOwnPropertyDescriptor(a, l);
        if (f && "value" in f) {
          var o = n.get(l);
          o && (f.value = z(o));
        } else if (f === void 0) {
          var _ = n.get(l), c = _?.v;
          if (_ !== void 0 && c !== T)
            return {
              enumerable: !0,
              configurable: !0,
              value: c,
              writable: !0
            };
        }
        return f;
      },
      has(a, l) {
        if (l === ne)
          return !0;
        var f = n.get(l), o = f !== void 0 && f.v !== T || Reflect.has(a, l);
        if (f !== void 0 || p !== null && (!o || ye(a, l)?.writable)) {
          f === void 0 && (f = u(() => {
            var c = o ? ge(a[l]) : T, v = /* @__PURE__ */ U(c);
            return v;
          }), n.set(l, f));
          var _ = z(f);
          if (_ === T)
            return !1;
        }
        return o;
      },
      set(a, l, f, o) {
        var _ = n.get(l), c = l in a;
        if (r && l === "length")
          for (var v = f; v < /** @type {Source<number>} */
          _.v; v += 1) {
            var h = n.get(v + "");
            h !== void 0 ? G(h, T) : v in a && (h = u(() => /* @__PURE__ */ U(T)), n.set(v + "", h));
          }
        if (_ === void 0)
          (!c || ye(a, l)?.writable) && (_ = u(() => /* @__PURE__ */ U(void 0)), G(_, ge(f)), n.set(l, _));
        else {
          c = _.v !== T;
          var g = u(() => ge(f));
          G(_, g);
        }
        var S = Reflect.getOwnPropertyDescriptor(a, l);
        if (S?.set && S.set.call(o, f), !c) {
          if (r && typeof l == "string") {
            var N = (
              /** @type {Source<number>} */
              n.get("length")
            ), ue = Number(l);
            Number.isInteger(ue) && ue >= N.v && G(N, ue + 1);
          }
          me(s);
        }
        return !0;
      },
      ownKeys(a) {
        z(s);
        var l = Reflect.ownKeys(a).filter((_) => {
          var c = n.get(_);
          return c === void 0 || c.v !== T;
        });
        for (var [f, o] of n)
          o.v !== T && !(f in a) && l.push(f);
        return l;
      },
      setPrototypeOf() {
        hn();
      }
    }
  );
}
function at(e) {
  try {
    if (e !== null && typeof e == "object" && ne in e)
      return e[ne];
  } catch {
  }
  return e;
}
function Or(e, t) {
  return Object.is(at(e), at(t));
}
var ft, jn, It, Ct;
function Vn() {
  if (ft === void 0) {
    ft = window, jn = /Firefox/.test(navigator.userAgent);
    var e = Element.prototype, t = Node.prototype, n = Text.prototype;
    It = ye(t, "firstChild").get, Ct = ye(t, "nextSibling").get, nt(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), nt(n) && (n.__t = void 0);
  }
}
function Nt(e = "") {
  return document.createTextNode(e);
}
// @__NO_SIDE_EFFECTS__
function Dt(e) {
  return (
    /** @type {TemplateNode | null} */
    It.call(e)
  );
}
// @__NO_SIDE_EFFECTS__
function De(e) {
  return (
    /** @type {TemplateNode | null} */
    Ct.call(e)
  );
}
function Ir(e, t) {
  return /* @__PURE__ */ Dt(e);
}
function Cr(e, t = !1) {
  {
    var n = /* @__PURE__ */ Dt(e);
    return n instanceof Comment && n.data === "" ? /* @__PURE__ */ De(n) : n;
  }
}
function Nr(e, t = 1, n = !1) {
  let r = e;
  for (; t--; )
    r = /** @type {TemplateNode} */
    /* @__PURE__ */ De(r);
  return r;
}
function Dr(e) {
  e.textContent = "";
}
function Mr() {
  return !1;
}
function Fr(e, t, n) {
  return (
    /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
    document.createElementNS(t ?? pn, e, void 0)
  );
}
function Lr(e, t) {
  if (t) {
    const n = document.body;
    e.autofocus = !0, W(() => {
      document.activeElement === n && e.focus();
    });
  }
}
let ut = !1;
function qn() {
  ut || (ut = !0, document.addEventListener(
    "reset",
    (e) => {
      Promise.resolve().then(() => {
        if (!e.defaultPrevented)
          for (
            const t of
            /**@type {HTMLFormElement} */
            e.target.elements
          )
            t.__on_r?.();
      });
    },
    // In the capture phase to guarantee we get noticed of it (no possibility of stopPropagation)
    { capture: !0 }
  ));
}
function Me(e) {
  var t = d, n = p;
  I(null), C(null);
  try {
    return e();
  } finally {
    I(t), C(n);
  }
}
function jr(e, t, n, r = n) {
  e.addEventListener(t, () => Me(n));
  const s = e.__on_r;
  s ? e.__on_r = () => {
    s(), r(!0);
  } : e.__on_r = () => r(!0), qn();
}
function Mt(e) {
  p === null && (d === null && on(), un()), le && fn();
}
function Bn(e, t) {
  var n = t.last;
  n === null ? t.last = t.first = e : (n.next = e, e.prev = n, t.last = e);
}
function L(e, t) {
  var n = p;
  n !== null && (n.f & j) !== 0 && (e |= j);
  var r = {
    ctx: m,
    deps: null,
    nodes: null,
    f: e | A | P,
    first: null,
    fn: t,
    last: null,
    next: null,
    parent: n,
    b: n && n.b,
    prev: null,
    teardown: null,
    wv: 0,
    ac: null
  }, s = r;
  if ((e & he) !== 0)
    ce !== null ? ce.push(r) : Z.ensure().schedule(r);
  else if (t !== null) {
    try {
      ae(r);
    } catch (u) {
      throw q(r), u;
    }
    s.deps === null && s.teardown === null && s.nodes === null && s.first === s.last && // either `null`, or a singular child
    (s.f & ve) === 0 && (s = s.first, (e & J) !== 0 && (e & be) !== 0 && s !== null && (s.f |= be));
  }
  if (s !== null && (s.parent = n, n !== null && Bn(s, n), d !== null && (d.f & b) !== 0 && (e & se) === 0)) {
    var i = (
      /** @type {Derived} */
      d
    );
    (i.effects ??= []).push(s);
  }
  return r;
}
function Je() {
  return d !== null && !M;
}
function Ft(e) {
  const t = L(Se, null);
  return y(t, E), t.teardown = e, t;
}
function Vr(e) {
  Mt();
  var t = (
    /** @type {Effect} */
    p.f
  ), n = !d && (t & B) !== 0 && (t & fe) === 0;
  if (n) {
    var r = (
      /** @type {ComponentContext} */
      m
    );
    (r.e ??= []).push(e);
  } else
    return Lt(e);
}
function Lt(e) {
  return L(he | vt, e);
}
function qr(e) {
  return Mt(), L(Se | vt, e);
}
function Yn(e) {
  Z.ensure();
  const t = L(se | ve, e);
  return (n = {}) => new Promise((r) => {
    n.outro ? Pe(t, () => {
      q(t), r(void 0);
    }) : (q(t), r(void 0));
  });
}
function Br(e) {
  return L(he, e);
}
function Yr(e, t) {
  var n = (
    /** @type {ComponentContextLegacy} */
    m
  ), r = { effect: null, ran: !1, deps: e };
  n.l.$.push(r), r.effect = Qe(() => {
    if (e(), !r.ran) {
      r.ran = !0;
      var s = (
        /** @type {Effect} */
        p
      );
      try {
        C(s.parent), tt(t);
      } finally {
        C(s);
      }
    }
  });
}
function Hr() {
  var e = (
    /** @type {ComponentContextLegacy} */
    m
  );
  Qe(() => {
    for (var t of e.l.$) {
      t.deps();
      var n = t.effect;
      (n.f & E) !== 0 && n.deps !== null && y(n, F), pe(n) && ae(n), t.ran = !1;
    }
  });
}
function Hn(e) {
  return L(ze | ve, e);
}
function Qe(e, t = 0) {
  return L(Se | t, e);
}
function Ur(e, t = [], n = [], r = []) {
  On(r, t, n, (s) => {
    L(Se, () => e(...s.map(z)));
  });
}
function Un(e, t = 0) {
  var n = L(J | t, e);
  return n;
}
function Gr(e, t = 0) {
  var n = L($e | t, e);
  return n;
}
function Q(e) {
  return L(B | ve, e);
}
function jt(e) {
  var t = e.teardown;
  if (t !== null) {
    const n = le, r = d;
    ot(!0), I(null);
    try {
      t.call(null);
    } finally {
      ot(n), I(r);
    }
  }
}
function et(e, t = !1) {
  var n = e.first;
  for (e.first = e.last = null; n !== null; ) {
    const s = n.ac;
    s !== null && Me(() => {
      s.abort(H);
    });
    var r = n.next;
    (n.f & se) !== 0 ? n.parent = null : q(n, t), n = r;
  }
}
function Gn(e) {
  for (var t = e.first; t !== null; ) {
    var n = t.next;
    (t.f & B) === 0 && q(t), t = n;
  }
}
function q(e, t = !0) {
  var n = !1;
  (t || (e.f & ln) !== 0) && e.nodes !== null && e.nodes.end !== null && ($n(
    e.nodes.start,
    /** @type {TemplateNode} */
    e.nodes.end
  ), n = !0), y(e, rt), et(e, t && !n), Te(e, 0);
  var r = e.nodes && e.nodes.t;
  if (r !== null)
    for (const i of r)
      i.stop();
  jt(e), e.f ^= rt, e.f |= V;
  var s = e.parent;
  s !== null && s.first !== null && Vt(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null;
}
function $n(e, t) {
  for (; e !== null; ) {
    var n = e === t ? null : /* @__PURE__ */ De(e);
    e.remove(), e = n;
  }
}
function Vt(e) {
  var t = e.parent, n = e.prev, r = e.next;
  n !== null && (n.next = r), r !== null && (r.prev = n), t !== null && (t.first === e && (t.first = r), t.last === e && (t.last = n));
}
function Pe(e, t, n = !0) {
  var r = [];
  qt(e, r, !0);
  var s = () => {
    n && q(e), t && t();
  }, i = r.length;
  if (i > 0) {
    var u = () => --i || s();
    for (var a of r)
      a.out(u);
  } else
    s();
}
function qt(e, t, n) {
  if ((e.f & j) === 0) {
    e.f ^= j;
    var r = e.nodes && e.nodes.t;
    if (r !== null)
      for (const a of r)
        (a.is_global || n) && t.push(a);
    for (var s = e.first; s !== null; ) {
      var i = s.next, u = (s.f & be) !== 0 || // If this is a branch effect without a block effect parent,
      // it means the parent block effect was pruned. In that case,
      // transparency information was transferred to the branch effect.
      (s.f & B) !== 0 && (e.f & J) !== 0;
      qt(s, t, u ? n : !1), s = i;
    }
  }
}
function $r(e) {
  Bt(e, !0);
}
function Bt(e, t) {
  if ((e.f & j) !== 0) {
    e.f ^= j, (e.f & E) === 0 && (y(e, A), Z.ensure().schedule(e));
    for (var n = e.first; n !== null; ) {
      var r = n.next, s = (n.f & be) !== 0 || (n.f & B) !== 0;
      Bt(n, s ? t : !1), n = r;
    }
    var i = e.nodes && e.nodes.t;
    if (i !== null)
      for (const u of i)
        (u.is_global || t) && u.in();
  }
}
function zn(e, t) {
  if (e.nodes)
    for (var n = e.nodes.start, r = e.nodes.end; n !== null; ) {
      var s = n === r ? null : /* @__PURE__ */ De(n);
      t.append(n), n = s;
    }
}
let Oe = !1, le = !1;
function ot(e) {
  le = e;
}
let d = null, M = !1;
function I(e) {
  d = e;
}
let p = null;
function C(e) {
  p = e;
}
let O = null;
function Yt(e) {
  d !== null && (O === null ? O = [e] : O.push(e));
}
let x = null, k = 0, R = null;
function Kn(e) {
  R = e;
}
let Ht = 1, te = 0, re = te;
function ct(e) {
  re = e;
}
function Ut() {
  return ++Ht;
}
function pe(e) {
  var t = e.f;
  if ((t & A) !== 0)
    return !0;
  if (t & b && (e.f &= ~ie), (t & F) !== 0) {
    for (var n = (
      /** @type {Value[]} */
      e.deps
    ), r = n.length, s = 0; s < r; s++) {
      var i = n[s];
      if (pe(
        /** @type {Derived} */
        i
      ) && kt(
        /** @type {Derived} */
        i
      ), i.wv > e.wv)
        return !0;
    }
    (t & P) !== 0 && // During time traveling we don't want to reset the status so that
    // traversal of the graph in the other batches still happens
    D === null && y(e, E);
  }
  return !1;
}
function Gt(e, t, n = !0) {
  var r = e.reactions;
  if (r !== null && !(O !== null && _e.call(O, e)))
    for (var s = 0; s < r.length; s++) {
      var i = r[s];
      (i.f & b) !== 0 ? Gt(
        /** @type {Derived} */
        i,
        t,
        !1
      ) : t === i && (n ? y(i, A) : (i.f & E) !== 0 && y(i, F), We(
        /** @type {Effect} */
        i
      ));
    }
}
function $t(e) {
  var t = x, n = k, r = R, s = d, i = O, u = m, a = M, l = re, f = e.f;
  x = /** @type {null | Value[]} */
  null, k = 0, R = null, d = (f & (B | se)) === 0 ? e : null, O = null, de(e.ctx), M = !1, re = ++te, e.ac !== null && (Me(() => {
    e.ac.abort(H);
  }), e.ac = null);
  try {
    e.f |= Ve;
    var o = (
      /** @type {Function} */
      e.fn
    ), _ = o();
    e.f |= fe;
    var c = e.deps, v = w?.is_fork;
    if (x !== null) {
      var h;
      if (v || Te(e, k), c !== null && k > 0)
        for (c.length = k + x.length, h = 0; h < x.length; h++)
          c[k + h] = x[h];
      else
        e.deps = c = x;
      if (Je() && (e.f & P) !== 0)
        for (h = k; h < c.length; h++)
          (c[h].reactions ??= []).push(e);
    } else !v && c !== null && k < c.length && (Te(e, k), c.length = k);
    if (Ae() && R !== null && !M && c !== null && (e.f & (b | F | A)) === 0)
      for (h = 0; h < /** @type {Source[]} */
      R.length; h++)
        Gt(
          R[h],
          /** @type {Effect} */
          e
        );
    if (s !== null && s !== e) {
      if (te++, s.deps !== null)
        for (let g = 0; g < n; g += 1)
          s.deps[g].rv = te;
      if (t !== null)
        for (const g of t)
          g.rv = te;
      R !== null && (r === null ? r = R : r.push(.../** @type {Source[]} */
      R));
    }
    return (e.f & K) !== 0 && (e.f ^= K), _;
  } catch (g) {
    return yt(g);
  } finally {
    e.f ^= Ve, x = t, k = n, R = r, d = s, O = i, de(u), M = a, re = l;
  }
}
function Wn(e, t) {
  let n = t.reactions;
  if (n !== null) {
    var r = Zt.call(n, e);
    if (r !== -1) {
      var s = n.length - 1;
      s === 0 ? n = t.reactions = null : (n[r] = n[s], n.pop());
    }
  }
  if (n === null && (t.f & b) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
  // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
  // allows us to skip the expensive work of disconnecting and immediately reconnecting it
  (x === null || !_e.call(x, t))) {
    var i = (
      /** @type {Derived} */
      t
    );
    (i.f & P) !== 0 && (i.f ^= P, i.f &= ~ie), Ke(i), Fn(i), Te(i, 0);
  }
}
function Te(e, t) {
  var n = e.deps;
  if (n !== null)
    for (var r = t; r < n.length; r++)
      Wn(e, n[r]);
}
function ae(e) {
  var t = e.f;
  if ((t & V) === 0) {
    y(e, E);
    var n = p, r = Oe;
    p = e, Oe = !0;
    try {
      (t & (J | $e)) !== 0 ? Gn(e) : et(e), jt(e);
      var s = $t(e);
      e.teardown = typeof s == "function" ? s : null, e.wv = Ht;
      var i;
    } finally {
      Oe = r, p = n;
    }
  }
}
async function zr() {
  await Promise.resolve(), Sn();
}
function z(e) {
  var t = e.f, n = (t & b) !== 0;
  if (d !== null && !M) {
    var r = p !== null && (p.f & V) !== 0;
    if (!r && (O === null || !_e.call(O, e))) {
      var s = d.deps;
      if ((d.f & Ve) !== 0)
        e.rv < te && (e.rv = te, x === null && s !== null && s[k] === e ? k++ : x === null ? x = [e] : x.push(e));
      else {
        (d.deps ??= []).push(e);
        var i = e.reactions;
        i === null ? e.reactions = [d] : _e.call(i, d) || i.push(d);
      }
    }
  }
  if (le && X.has(e))
    return X.get(e);
  if (n) {
    var u = (
      /** @type {Derived} */
      e
    );
    if (le) {
      var a = u.v;
      return ((u.f & E) === 0 && u.reactions !== null || Kt(u)) && (a = Ze(u)), X.set(u, a), a;
    }
    var l = (u.f & P) === 0 && !M && d !== null && (Oe || (d.f & P) !== 0), f = (u.f & fe) === 0;
    pe(u) && (l && (u.f |= P), kt(u)), l && !f && (Rt(u), zt(u));
  }
  if (D?.has(e))
    return D.get(e);
  if ((e.f & K) !== 0)
    throw e.v;
  return e.v;
}
function zt(e) {
  if (e.f |= P, e.deps !== null)
    for (const t of e.deps)
      (t.reactions ??= []).push(e), (t.f & b) !== 0 && (t.f & P) === 0 && (Rt(
        /** @type {Derived} */
        t
      ), zt(
        /** @type {Derived} */
        t
      ));
}
function Kt(e) {
  if (e.v === T) return !0;
  if (e.deps === null) return !1;
  for (const t of e.deps)
    if (X.has(t) || (t.f & b) !== 0 && Kt(
      /** @type {Derived} */
      t
    ))
      return !0;
  return !1;
}
function tt(e) {
  var t = M;
  try {
    return M = !0, e();
  } finally {
    M = t;
  }
}
function Kr(e) {
  if (!(typeof e != "object" || !e || e instanceof EventTarget)) {
    if (ne in e)
      Ye(e);
    else if (!Array.isArray(e))
      for (let t in e) {
        const n = e[t];
        typeof n == "object" && n && ne in n && Ye(n);
      }
  }
}
function Ye(e, t = /* @__PURE__ */ new Set()) {
  if (typeof e == "object" && e !== null && // We don't want to traverse DOM elements
  !(e instanceof EventTarget) && !t.has(e)) {
    t.add(e), e instanceof Date && e.getTime();
    for (let r in e)
      try {
        Ye(e[r], t);
      } catch {
      }
    const n = ht(e);
    if (n !== Object.prototype && n !== Array.prototype && n !== Map.prototype && n !== Set.prototype && n !== Date.prototype) {
      const r = en(n);
      for (let s in r) {
        const i = r[s].get;
        if (i)
          try {
            i.call(e);
          } catch {
          }
      }
    }
  }
}
function Wr(e) {
  return e.endsWith("capture") && e !== "gotpointercapture" && e !== "lostpointercapture";
}
const Xn = [
  "beforeinput",
  "click",
  "change",
  "dblclick",
  "contextmenu",
  "focusin",
  "focusout",
  "input",
  "keydown",
  "keyup",
  "mousedown",
  "mousemove",
  "mouseout",
  "mouseover",
  "mouseup",
  "pointerdown",
  "pointermove",
  "pointerout",
  "pointerover",
  "pointerup",
  "touchend",
  "touchmove",
  "touchstart"
];
function Xr(e) {
  return Xn.includes(e);
}
const Zn = {
  // no `class: 'className'` because we handle that separately
  formnovalidate: "formNoValidate",
  ismap: "isMap",
  nomodule: "noModule",
  playsinline: "playsInline",
  readonly: "readOnly",
  defaultvalue: "defaultValue",
  defaultchecked: "defaultChecked",
  srcobject: "srcObject",
  novalidate: "noValidate",
  allowfullscreen: "allowFullscreen",
  disablepictureinpicture: "disablePictureInPicture",
  disableremoteplayback: "disableRemotePlayback"
};
function Zr(e) {
  return e = e.toLowerCase(), Zn[e] ?? e;
}
const Jn = ["touchstart", "touchmove"];
function Qn(e) {
  return Jn.includes(e);
}
const we = /* @__PURE__ */ Symbol("events"), Wt = /* @__PURE__ */ new Set(), He = /* @__PURE__ */ new Set();
function er(e, t, n, r = {}) {
  function s(i) {
    if (r.capture || Ue.call(t, i), !i.cancelBubble)
      return Me(() => n?.call(this, i));
  }
  return e.startsWith("pointer") || e.startsWith("touch") || e === "wheel" ? W(() => {
    t.addEventListener(e, s, r);
  }) : t.addEventListener(e, s, r), s;
}
function Jr(e, t, n, r, s) {
  var i = { capture: r, passive: s }, u = er(e, t, n, i);
  (t === document.body || // @ts-ignore
  t === window || // @ts-ignore
  t === document || // Firefox has quirky behavior, it can happen that we still get "canplay" events when the element is already removed
  t instanceof HTMLMediaElement) && Ft(() => {
    t.removeEventListener(e, u, i);
  });
}
function Qr(e, t, n) {
  (t[we] ??= {})[e] = n;
}
function es(e) {
  for (var t = 0; t < e.length; t++)
    Wt.add(e[t]);
  for (var n of He)
    n(e);
}
let _t = null;
function Ue(e) {
  var t = this, n = (
    /** @type {Node} */
    t.ownerDocument
  ), r = e.type, s = e.composedPath?.() || [], i = (
    /** @type {null | Element} */
    s[0] || e.target
  );
  _t = e;
  var u = 0, a = _t === e && e[we];
  if (a) {
    var l = s.indexOf(a);
    if (l !== -1 && (t === document || t === /** @type {any} */
    window)) {
      e[we] = t;
      return;
    }
    var f = s.indexOf(t);
    if (f === -1)
      return;
    l <= f && (u = l);
  }
  if (i = /** @type {Element} */
  s[u] || e.target, i !== t) {
    Qt(e, "currentTarget", {
      configurable: !0,
      get() {
        return i || n;
      }
    });
    var o = d, _ = p;
    I(null), C(null);
    try {
      for (var c, v = []; i !== null; ) {
        var h = i.assignedSlot || i.parentNode || /** @type {any} */
        i.host || null;
        try {
          var g = i[we]?.[r];
          g != null && (!/** @type {any} */
          i.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
          // -> the target could not have been disabled because it emits the event in the first place
          e.target === i) && g.call(i, e);
        } catch (S) {
          c ? v.push(S) : c = S;
        }
        if (e.cancelBubble || h === t || h === null)
          break;
        i = h;
      }
      if (c) {
        for (let S of v)
          queueMicrotask(() => {
            throw S;
          });
        throw c;
      }
    } finally {
      e[we] = t, delete e.currentTarget, I(o), C(_);
    }
  }
}
function ts(e, t) {
  var n = t == null ? "" : typeof t == "object" ? `${t}` : t;
  n !== (e.__t ??= e.nodeValue) && (e.__t = n, e.nodeValue = `${n}`);
}
function ns(e, t) {
  return tr(e, t);
}
const ke = /* @__PURE__ */ new Map();
function tr(e, { target: t, anchor: n, props: r = {}, events: s, context: i, intro: u = !0, transformError: a }) {
  Vn();
  var l = void 0, f = Yn(() => {
    var o = n ?? t.appendChild(Nt());
    Rn(
      /** @type {TemplateNode} */
      o,
      {
        pending: () => {
        }
      },
      (v) => {
        yn({});
        var h = (
          /** @type {ComponentContext} */
          m
        );
        i && (h.c = i), s && (r.$$events = s), l = e(v, r) || {}, En();
      },
      a
    );
    var _ = /* @__PURE__ */ new Set(), c = (v) => {
      for (var h = 0; h < v.length; h++) {
        var g = v[h];
        if (!_.has(g)) {
          _.add(g);
          var S = Qn(g);
          for (const Fe of [t, document]) {
            var N = ke.get(Fe);
            N === void 0 && (N = /* @__PURE__ */ new Map(), ke.set(Fe, N));
            var ue = N.get(g);
            ue === void 0 ? (Fe.addEventListener(g, Ue, { passive: S }), N.set(g, 1)) : N.set(g, ue + 1);
          }
        }
      }
    };
    return c(Jt(Wt)), He.add(c), () => {
      for (var v of _)
        for (const S of [t, document]) {
          var h = (
            /** @type {Map<string, number>} */
            ke.get(S)
          ), g = (
            /** @type {number} */
            h.get(v)
          );
          --g == 0 ? (S.removeEventListener(v, Ue), h.delete(v), h.size === 0 && ke.delete(S)) : h.set(v, g);
        }
      He.delete(c), o !== n && o.parentNode?.removeChild(o);
    };
  });
  return Ge.set(l, f), l;
}
let Ge = /* @__PURE__ */ new WeakMap();
function rs(e, t) {
  const n = Ge.get(e);
  return n ? (Ge.delete(e), n(t)) : Promise.resolve();
}
export {
  pn as $,
  Mr as A,
  Un as B,
  Ce as C,
  ur as D,
  be as E,
  Nn as F,
  Jt as G,
  _r as H,
  xe as I,
  cr as J,
  vr as K,
  sr as L,
  V as M,
  j as N,
  B as O,
  Dr as P,
  W as Q,
  De as R,
  hr as S,
  mr as T,
  dr as U,
  Tr as V,
  Gr as W,
  Br as X,
  Ar as Y,
  Or as Z,
  lr as _,
  tt as a,
  en as a0,
  On as a1,
  Sr as a2,
  fr as a3,
  Wr as a4,
  Qr as a5,
  es as a6,
  er as a7,
  Lr as a8,
  Zr as a9,
  xr as aA,
  Yr as aB,
  Hr as aC,
  Cr as aD,
  En as aE,
  yn as aF,
  Nr as aG,
  Jr as aH,
  Ur as aI,
  Pr as aJ,
  Ir as aK,
  ts as aL,
  kr as aM,
  T as aa,
  Xr as ab,
  jr as ac,
  zr as ad,
  Qe as ae,
  m as af,
  rt as ag,
  ne as ah,
  qr as ai,
  Vr as aj,
  rr as ak,
  Kr as al,
  Xe as am,
  ye as an,
  or as ao,
  wr as ap,
  ge as aq,
  yr as ar,
  Ne as as,
  gr as at,
  pr as au,
  Er as av,
  le as aw,
  ir as ax,
  nr as ay,
  U as az,
  Rr as b,
  G as c,
  z as d,
  Qt as e,
  Fr as f,
  ht as g,
  Nt as h,
  Xt as i,
  p as j,
  Dt as k,
  jn as l,
  ns as m,
  rn as n,
  tn as o,
  br as p,
  $r as q,
  sn as r,
  wn as s,
  Ft as t,
  rs as u,
  q as v,
  Pe as w,
  Q as x,
  w as y,
  zn as z
};
