var Ft = Array.isArray, Ct = Array.prototype.indexOf, ue = Array.prototype.includes, It = Array.from, Mt = Object.defineProperty, de = Object.getOwnPropertyDescriptor, jt = Object.prototype, qt = Array.prototype, Lt = Object.getPrototypeOf, Ge = Object.isExtensible;
const Yt = () => {
};
function Ut(e) {
  for (var t = 0; t < e.length; t++)
    e[t]();
}
function rt() {
  var e, t, n = new Promise((r, i) => {
    e = r, t = i;
  });
  return { promise: n, resolve: e, reject: t };
}
const b = 2, ge = 4, Pe = 8, it = 1 << 24, K = 16, G = 32, ee = 64, Ce = 128, P = 512, m = 1024, T = 2048, j = 4096, B = 8192, I = 16384, he = 32768, Ke = 1 << 25, ke = 65536, He = 1 << 17, Vt = 1 << 18, _e = 1 << 19, Bt = 1 << 20, te = 65536, Ie = 1 << 21, Le = 1 << 22, $ = 1 << 23, De = /* @__PURE__ */ Symbol("$state"), Yn = /* @__PURE__ */ Symbol("legacy props"), Y = new class extends Error {
  name = "StaleReactionError";
  message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
}();
function $t() {
  throw new Error("https://svelte.dev/e/async_derived_orphan");
}
function zt() {
  throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
}
function Vn(e) {
  throw new Error("https://svelte.dev/e/props_invalid_value");
}
function Gt() {
  throw new Error("https://svelte.dev/e/state_descriptors_fixed");
}
function Kt() {
  throw new Error("https://svelte.dev/e/state_prototype_fixed");
}
function Ht() {
  throw new Error("https://svelte.dev/e/state_unsafe_mutation");
}
function Wt() {
  throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
}
const Bn = 2, $n = 4, zn = 8, Gn = 2, E = /* @__PURE__ */ Symbol(), Zt = "http://www.w3.org/1999/xhtml";
function Jt() {
  console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
}
function st(e) {
  return e === this.v;
}
function Qt(e, t) {
  return e != e ? t == t : e !== t || e !== null && typeof e == "object" || typeof e == "function";
}
function Xt(e) {
  return !Qt(e, this.v);
}
let Ye = !1;
function Kn() {
  Ye = !0;
}
let A = null;
function ae(e) {
  A = e;
}
function en(e, t = !1, n) {
  A = {
    p: A,
    i: !1,
    c: null,
    e: null,
    s: e,
    x: null,
    r: (
      /** @type {Effect} */
      p
    ),
    l: Ye && !t ? { s: null, u: null, $: [] } : null
  };
}
function tn(e) {
  var t = (
    /** @type {ComponentContext} */
    A
  ), n = t.e;
  if (n !== null) {
    t.e = null;
    for (var r of n)
      Sn(r);
  }
  return t.i = !0, A = t.p, /** @type {T} */
  {};
}
function ye() {
  return !Ye || A !== null && A.l === null;
}
let se = [];
function nn() {
  var e = se;
  se = [], Ut(e);
}
function fe(e) {
  if (se.length === 0) {
    var t = se;
    queueMicrotask(() => {
      t === se && nn();
    });
  }
  se.push(e);
}
function lt(e) {
  var t = p;
  if (t === null)
    return d.f |= $, e;
  if ((t.f & he) === 0 && (t.f & ge) === 0)
    throw e;
  V(e, t);
}
function V(e, t) {
  for (; t !== null; ) {
    if ((t.f & Ce) !== 0) {
      if ((t.f & he) === 0)
        throw e;
      try {
        t.b.error(e);
        return;
      } catch (n) {
        e = n;
      }
    }
    t = t.parent;
  }
  throw e;
}
const rn = -7169;
function y(e, t) {
  e.f = e.f & rn | t;
}
function Ue(e) {
  (e.f & P) !== 0 || e.deps === null ? y(e, m) : y(e, j);
}
function ft(e) {
  if (e !== null)
    for (const t of e)
      (t.f & b) === 0 || (t.f & te) === 0 || (t.f ^= te, ft(
        /** @type {Derived} */
        t.deps
      ));
}
function ut(e, t, n) {
  (e.f & T) !== 0 ? t.add(e) : (e.f & j) !== 0 && n.add(e), ft(e.deps), y(e, m);
}
const ie = /* @__PURE__ */ new Set();
let w = null, F = null, Me = null, Fe = !1, le = null, xe = null;
var We = 0;
let sn = 1;
class ne {
  // for debugging. TODO remove once async is stable
  id = sn++;
  /**
   * 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>}
   */
  #i = /* @__PURE__ */ new Set();
  /**
   * If a fork is discarded, we need to destroy any effects that are no longer needed
   * @type {Set<(batch: Batch) => void>}
   */
  #v = /* @__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
   */
  #f = 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[] }>}
   */
  #s = /* @__PURE__ */ new Map();
  is_fork = !1;
  #u = !1;
  #a() {
    return this.is_fork || this.#f > 0;
  }
  /**
   * Add an effect to the #skipped_branches map and reset its children
   * @param {Effect} effect
   */
  skip_effect(t) {
    this.#s.has(t) || this.#s.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.#s.get(t);
    if (n) {
      this.#s.delete(t);
      for (var r of n.d)
        y(r, T), this.schedule(r);
      for (r of n.m)
        y(r, j), this.schedule(r);
    }
  }
  #c() {
    if (We++ > 1e3 && (ie.delete(this), ln()), !this.#a()) {
      for (const f of this.#t)
        this.#n.delete(f), y(f, T), this.schedule(f);
      for (const f of this.#n)
        y(f, j), this.schedule(f);
    }
    const t = this.#e;
    this.#e = [], this.apply();
    var n = le = [], r = [], i = xe = [];
    for (const f of t)
      try {
        this.#h(f, n, r);
      } catch (s) {
        throw ht(f), s;
      }
    if (w = null, i.length > 0) {
      var l = ne.ensure();
      for (const f of i)
        l.schedule(f);
    }
    if (le = null, xe = null, this.#a()) {
      this.#_(r), this.#_(n);
      for (const [f, s] of this.#s)
        ct(f, s);
    } else {
      this.#l === 0 && ie.delete(this), this.#t.clear(), this.#n.clear();
      for (const f of this.#i) f(this);
      this.#i.clear(), Ze(r), Ze(n), this.#r?.resolve();
    }
    var a = (
      /** @type {Batch | null} */
      /** @type {unknown} */
      w
    );
    if (this.#e.length > 0) {
      const f = a ??= this;
      f.#e.push(...this.#e.filter((s) => !f.#e.includes(s)));
    }
    a !== null && (ie.add(a), a.#c()), ie.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
   */
  #h(t, n, r) {
    t.f ^= m;
    for (var i = t.first; i !== null; ) {
      var l = i.f, a = (l & (G | ee)) !== 0, f = a && (l & m) !== 0, s = f || (l & B) !== 0 || this.#s.has(i);
      if (!s && i.fn !== null) {
        a ? i.f ^= m : (l & ge) !== 0 ? n.push(i) : me(i) && ((l & K) !== 0 && this.#n.add(i), ce(i));
        var u = i.first;
        if (u !== null) {
          i = u;
          continue;
        }
      }
      for (; i !== null; ) {
        var o = i.next;
        if (o !== null) {
          i = o;
          break;
        }
        i = i.parent;
      }
    }
  }
  /**
   * @param {Effect[]} effects
   */
  #_(t) {
    for (var n = 0; n < t.length; n += 1)
      ut(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 !== E && !this.previous.has(t) && this.previous.set(t, n), (t.f & $) === 0 && (this.current.set(t, t.v), F?.set(t, t.v));
  }
  activate() {
    w = this;
  }
  deactivate() {
    w = null, F = null;
  }
  flush() {
    try {
      Fe = !0, w = this, this.#c();
    } finally {
      We = 0, Me = null, le = null, xe = null, Fe = !1, w = null, F = null, z.clear();
    }
  }
  discard() {
    for (const t of this.#v) t(this);
    this.#v.clear();
  }
  #o() {
    for (const s of ie) {
      var t = s.id < this.id, n = [];
      for (const [u, o] of this.current) {
        if (s.current.has(u))
          if (t && o !== s.current.get(u))
            s.current.set(u, o);
          else
            continue;
        n.push(u);
      }
      if (n.length !== 0) {
        var r = [...s.current.keys()].filter((u) => !this.current.has(u));
        if (r.length > 0) {
          s.activate();
          var i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
          for (var a of n)
            at(a, r, i, l);
          if (s.#e.length > 0) {
            s.apply();
            for (var f of s.#e)
              s.#h(f, [], []);
            s.#e = [];
          }
          s.deactivate();
        }
      }
    }
  }
  /**
   *
   * @param {boolean} blocking
   */
  increment(t) {
    this.#l += 1, t && (this.#f += 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.#f -= 1), !(this.#u || n) && (this.#u = !0, fe(() => {
      this.#u = !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.#i.add(t);
  }
  /** @param {(batch: Batch) => void} fn */
  ondiscard(t) {
    this.#v.add(t);
  }
  settled() {
    return (this.#r ??= rt()).promise;
  }
  static ensure() {
    if (w === null) {
      const t = w = new ne();
      Fe || (ie.add(w), fe(() => {
        w === t && t.flush();
      }));
    }
    return w;
  }
  apply() {
    {
      F = null;
      return;
    }
  }
  /**
   *
   * @param {Effect} effect
   */
  schedule(t) {
    if (Me = t, t.b?.is_pending && (t.f & (ge | Pe | it)) !== 0 && (t.f & he) === 0) {
      t.b.defer_effect(t);
      return;
    }
    for (var n = t; n.parent !== null; ) {
      n = n.parent;
      var r = n.f;
      if (le !== null && n === p && (d === null || (d.f & b) === 0))
        return;
      if ((r & (ee | G)) !== 0) {
        if ((r & m) === 0)
          return;
        n.f ^= m;
      }
    }
    this.#e.push(n);
  }
}
function ln() {
  try {
    zt();
  } catch (e) {
    V(e, Me);
  }
}
let L = null;
function Ze(e) {
  var t = e.length;
  if (t !== 0) {
    for (var n = 0; n < t; ) {
      var r = e[n++];
      if ((r.f & (I | B)) === 0 && me(r) && (L = /* @__PURE__ */ new Set(), ce(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Tt(r), L?.size > 0)) {
        z.clear();
        for (const i of L) {
          if ((i.f & (I | B)) !== 0) continue;
          const l = [i];
          let a = i.parent;
          for (; a !== null; )
            L.has(a) && (L.delete(a), l.push(a)), a = a.parent;
          for (let f = l.length - 1; f >= 0; f--) {
            const s = l[f];
            (s.f & (I | B)) === 0 && ce(s);
          }
        }
        L.clear();
      }
    }
    L = null;
  }
}
function at(e, t, n, r) {
  if (!n.has(e) && (n.add(e), e.reactions !== null))
    for (const i of e.reactions) {
      const l = i.f;
      (l & b) !== 0 ? at(
        /** @type {Derived} */
        i,
        t,
        n,
        r
      ) : (l & (Le | K)) !== 0 && (l & T) === 0 && ot(i, t, r) && (y(i, T), Ve(
        /** @type {Effect} */
        i
      ));
    }
}
function ot(e, t, n) {
  const r = n.get(e);
  if (r !== void 0) return r;
  if (e.deps !== null)
    for (const i of e.deps) {
      if (ue.call(t, i))
        return !0;
      if ((i.f & b) !== 0 && ot(
        /** @type {Derived} */
        i,
        t,
        n
      ))
        return n.set(
          /** @type {Derived} */
          i,
          !0
        ), !0;
    }
  return n.set(e, !1), !1;
}
function Ve(e) {
  w.schedule(e);
}
function ct(e, t) {
  if (!((e.f & G) !== 0 && (e.f & m) !== 0)) {
    (e.f & T) !== 0 ? t.d.push(e) : (e.f & j) !== 0 && t.m.push(e), y(e, m);
    for (var n = e.first; n !== null; )
      ct(n, t), n = n.next;
  }
}
function ht(e) {
  y(e, m);
  for (var t = e.first; t !== null; )
    ht(t), t = t.next;
}
function fn(e) {
  let t = 0, n = Ne(0), r;
  return () => {
    $e() && (Q(n), An(() => (t === 0 && (r = In(() => e(() => pe(n)))), t += 1, () => {
      fe(() => {
        t -= 1, t === 0 && (r?.(), r = void 0, pe(n));
      });
    })));
  };
}
var un = ke | _e;
function an(e, t, n, r) {
  new on(e, t, n, r);
}
class on {
  /** @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} */
  #i;
  /** @type {TemplateNode | null} */
  #v = null;
  /** @type {BoundaryProps} */
  #l;
  /** @type {((anchor: Node) => void)} */
  #f;
  /** @type {Effect} */
  #r;
  /** @type {Effect | null} */
  #e = null;
  /** @type {Effect | null} */
  #t = null;
  /** @type {Effect | null} */
  #n = null;
  /** @type {DocumentFragment | null} */
  #s = null;
  #u = 0;
  #a = 0;
  #c = !1;
  /** @type {Set<Effect>} */
  #h = /* @__PURE__ */ new Set();
  /** @type {Set<Effect>} */
  #_ = /* @__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 = fn(() => (this.#o = Ne(this.#u), () => {
    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, i) {
    this.#i = t, this.#l = n, this.#f = (l) => {
      var a = (
        /** @type {Effect} */
        p
      );
      a.b = this, a.f |= Ce, r(l);
    }, this.parent = /** @type {Effect} */
    p.b, this.transform_error = i ?? this.parent?.transform_error ?? ((l) => l), this.#r = Rn(() => {
      this.#g();
    }, un);
  }
  #m() {
    try {
      this.#e = W(() => this.#f(this.#i));
    } catch (t) {
      this.error(t);
    }
  }
  /**
   * @param {unknown} error The deserialized error from the server's hydration comment
   */
  #b(t) {
    const n = this.#l.failed;
    n && (this.#n = W(() => {
      n(
        this.#i,
        () => t,
        () => () => {
        }
      );
    }));
  }
  #E() {
    const t = this.#l.pending;
    t && (this.is_pending = !0, this.#t = W(() => t(this.#i)), fe(() => {
      var n = this.#s = document.createDocumentFragment(), r = bt();
      n.append(r), this.#e = this.#p(() => W(() => this.#f(r))), this.#a === 0 && (this.#i.before(n), this.#s = null, Se(
        /** @type {Effect} */
        this.#t,
        () => {
          this.#t = null;
        }
      ), this.#d(
        /** @type {Batch} */
        w
      ));
    }));
  }
  #g() {
    try {
      if (this.is_pending = this.has_pending_snippet(), this.#a = 0, this.#u = 0, this.#e = W(() => {
        this.#f(this.#i);
      }), this.#a > 0) {
        var t = this.#s = document.createDocumentFragment();
        On(this.#e, t);
        const n = (
          /** @type {(anchor: Node) => void} */
          this.#l.pending
        );
        this.#t = W(() => n(this.#i));
      } else
        this.#d(
          /** @type {Batch} */
          w
        );
    } catch (n) {
      this.error(n);
    }
  }
  /**
   * @param {Batch} batch
   */
  #d(t) {
    this.is_pending = !1, t.transfer_effects(this.#h, this.#_);
  }
  /**
   * Defer an effect inside a pending boundary until the boundary resolves
   * @param {Effect} effect
   */
  defer_effect(t) {
    ut(t, this.#h, this.#_);
  }
  /**
   * 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, i = A;
    q(this.#r), O(this.#r), ae(this.#r.ctx);
    try {
      return ne.ensure(), t();
    } catch (l) {
      return lt(l), null;
    } finally {
      q(n), O(r), ae(i);
    }
  }
  /**
   * 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.#a += t, this.#a === 0 && (this.#d(n), this.#t && Se(this.#t, () => {
      this.#t = null;
    }), this.#s && (this.#i.before(this.#s), this.#s = 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.#u += t, !(!this.#o || this.#c) && (this.#c = !0, fe(() => {
      this.#c = !1, this.#o && Re(this.#o, this.#u);
    }));
  }
  get_effect_pending() {
    return this.#y(), Q(
      /** @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 && (M(this.#e), this.#e = null), this.#t && (M(this.#t), this.#t = null), this.#n && (M(this.#n), this.#n = null);
    var i = !1, l = !1;
    const a = () => {
      if (i) {
        Jt();
        return;
      }
      i = !0, l && Wt(), this.#n !== null && Se(this.#n, () => {
        this.#n = null;
      }), this.#p(() => {
        this.#g();
      });
    }, f = (s) => {
      try {
        l = !0, n?.(s, a), l = !1;
      } catch (u) {
        V(u, this.#r && this.#r.parent);
      }
      r && (this.#n = this.#p(() => {
        try {
          return W(() => {
            var u = (
              /** @type {Effect} */
              p
            );
            u.b = this, u.f |= Ce, r(
              this.#i,
              () => s,
              () => a
            );
          });
        } catch (u) {
          return V(
            u,
            /** @type {Effect} */
            this.#r.parent
          ), null;
        }
      }));
    };
    fe(() => {
      var s;
      try {
        s = this.transform_error(t);
      } catch (u) {
        V(u, this.#r && this.#r.parent);
        return;
      }
      s !== null && typeof s == "object" && typeof /** @type {any} */
      s.then == "function" ? s.then(
        f,
        /** @param {unknown} e */
        (u) => V(u, this.#r && this.#r.parent)
      ) : f(s);
    });
  }
}
function cn(e, t, n, r) {
  const i = ye() ? vt : vn;
  var l = e.filter((c) => !c.settled);
  if (n.length === 0 && l.length === 0) {
    r(t.map(i));
    return;
  }
  var a = (
    /** @type {Effect} */
    p
  ), f = hn(), s = l.length === 1 ? l[0].promise : l.length > 1 ? Promise.all(l.map((c) => c.promise)) : null;
  function u(c) {
    f();
    try {
      r(c);
    } catch (v) {
      (a.f & I) === 0 && V(v, a);
    }
    Ae();
  }
  if (n.length === 0) {
    s.then(() => u(t.map(i)));
    return;
  }
  var o = _t();
  function h() {
    Promise.all(n.map((c) => /* @__PURE__ */ _n(c))).then((c) => u([...t.map(i), ...c])).catch((c) => V(c, a)).finally(() => o());
  }
  s ? s.then(() => {
    f(), h(), Ae();
  }) : h();
}
function hn() {
  var e = (
    /** @type {Effect} */
    p
  ), t = d, n = A, r = (
    /** @type {Batch} */
    w
  );
  return function(l = !0) {
    q(e), O(t), ae(n), l && (e.f & I) === 0 && (r?.activate(), r?.apply());
  };
}
function Ae(e = !0) {
  q(null), O(null), ae(null), e && w?.deactivate();
}
function _t() {
  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 vt(e) {
  var t = b | T, n = d !== null && (d.f & b) !== 0 ? (
    /** @type {Derived} */
    d
  ) : null;
  return p !== null && (p.f |= _e), {
    ctx: A,
    deps: null,
    effects: null,
    equals: st,
    f: t,
    fn: e,
    reactions: null,
    rv: 0,
    v: (
      /** @type {V} */
      E
    ),
    wv: 0,
    parent: n ?? p,
    ac: null
  };
}
// @__NO_SIDE_EFFECTS__
function _n(e, t, n) {
  let r = (
    /** @type {Effect | null} */
    p
  );
  r === null && $t();
  var i = (
    /** @type {Promise<V>} */
    /** @type {unknown} */
    void 0
  ), l = Ne(
    /** @type {V} */
    E
  ), a = !d, f = /* @__PURE__ */ new Map();
  return kn(() => {
    var s = (
      /** @type {Effect} */
      p
    ), u = rt();
    i = u.promise;
    try {
      Promise.resolve(e()).then(u.resolve, u.reject).finally(Ae);
    } catch (v) {
      u.reject(v), Ae();
    }
    var o = (
      /** @type {Batch} */
      w
    );
    if (a) {
      if ((s.f & he) !== 0)
        var h = _t();
      if (
        /** @type {Boundary} */
        r.b.is_rendered()
      )
        f.get(o)?.reject(Y), f.delete(o);
      else {
        for (const v of f.values())
          v.reject(Y);
        f.clear();
      }
      f.set(o, u);
    }
    const c = (v, _ = void 0) => {
      if (h) {
        var g = _ === Y;
        h(g);
      }
      if (!(_ === Y || (s.f & I) !== 0)) {
        if (o.activate(), _)
          l.f |= $, Re(l, _);
        else {
          (l.f & $) !== 0 && (l.f ^= $), Re(l, v);
          for (const [x, D] of f) {
            if (f.delete(x), x === o) break;
            D.reject(Y);
          }
        }
        o.deactivate();
      }
    };
    u.promise.then(c, (v) => c(null, v || "unknown"));
  }), xn(() => {
    for (const s of f.values())
      s.reject(Y);
  }), new Promise((s) => {
    function u(o) {
      function h() {
        o === i ? s(l) : u(i);
      }
      o.then(h, h);
    }
    u(i);
  });
}
// @__NO_SIDE_EFFECTS__
function vn(e) {
  const t = /* @__PURE__ */ vt(e);
  return t.equals = Xt, t;
}
function dn(e) {
  var t = e.effects;
  if (t !== null) {
    e.effects = null;
    for (var n = 0; n < t.length; n += 1)
      M(
        /** @type {Effect} */
        t[n]
      );
  }
}
function pn(e) {
  for (var t = e.parent; t !== null; ) {
    if ((t.f & b) === 0)
      return (t.f & I) === 0 ? (
        /** @type {Effect} */
        t
      ) : null;
    t = t.parent;
  }
  return null;
}
function Be(e) {
  var t, n = p;
  q(pn(e));
  try {
    e.f &= ~te, dn(e), t = Nt(e);
  } finally {
    q(n);
  }
  return t;
}
function dt(e) {
  var t = e.v, n = Be(e);
  if (!e.equals(n) && (e.wv = Rt(), (!w?.is_fork || e.deps === null) && (e.v = n, w?.capture(e, t), e.deps === null))) {
    y(e, m);
    return;
  }
  oe || (F !== null ? ($e() || w?.is_fork) && F.set(e, n) : Ue(e));
}
function gn(e) {
  if (e.effects !== null)
    for (const t of e.effects)
      (t.teardown || t.ac) && (t.teardown?.(), t.ac?.abort(Y), t.teardown = Yt, t.ac = null, we(t, 0), ze(t));
}
function pt(e) {
  if (e.effects !== null)
    for (const t of e.effects)
      t.teardown && ce(t);
}
let je = /* @__PURE__ */ new Set();
const z = /* @__PURE__ */ new Map();
let gt = !1;
function Ne(e, t) {
  var n = {
    f: 0,
    // TODO ideally we could skip this altogether, but it causes type errors
    v: e,
    reactions: null,
    equals: st,
    rv: 0,
    wv: 0
  };
  return n;
}
// @__NO_SIDE_EFFECTS__
function U(e, t) {
  const n = Ne(e);
  return Dn(n), n;
}
function Z(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
  (!C || (d.f & He) !== 0) && ye() && (d.f & (b | K | Le | He)) !== 0 && (N === null || !ue.call(N, e)) && Ht();
  let r = n ? ve(t) : t;
  return Re(e, r, xe);
}
function Re(e, t, n = null) {
  if (!e.equals(t)) {
    var r = e.v;
    oe ? z.set(e, t) : z.set(e, r), e.v = t;
    var i = ne.ensure();
    if (i.capture(e, r), (e.f & b) !== 0) {
      const l = (
        /** @type {Derived} */
        e
      );
      (e.f & T) !== 0 && Be(l), F === null && Ue(l);
    }
    e.wv = Rt(), wt(e, T, n), ye() && p !== null && (p.f & m) !== 0 && (p.f & (G | ee)) === 0 && (R === null ? Fn([e]) : R.push(e)), !i.is_fork && je.size > 0 && !gt && wn();
  }
  return t;
}
function wn() {
  gt = !1;
  for (const e of je)
    (e.f & m) !== 0 && y(e, j), me(e) && ce(e);
  je.clear();
}
function pe(e) {
  Z(e, e.v + 1);
}
function wt(e, t, n) {
  var r = e.reactions;
  if (r !== null)
    for (var i = ye(), l = r.length, a = 0; a < l; a++) {
      var f = r[a], s = f.f;
      if (!(!i && f === p)) {
        var u = (s & T) === 0;
        if (u && y(f, t), (s & b) !== 0) {
          var o = (
            /** @type {Derived} */
            f
          );
          F?.delete(o), (s & te) === 0 && (s & P && (f.f |= te), wt(o, j, n));
        } else if (u) {
          var h = (
            /** @type {Effect} */
            f
          );
          (s & K) !== 0 && L !== null && L.add(h), n !== null ? n.push(h) : Ve(h);
        }
      }
    }
}
function ve(e) {
  if (typeof e != "object" || e === null || De in e)
    return e;
  const t = Lt(e);
  if (t !== jt && t !== qt)
    return e;
  var n = /* @__PURE__ */ new Map(), r = Ft(e), i = /* @__PURE__ */ U(0), l = X, a = (f) => {
    if (X === l)
      return f();
    var s = d, u = X;
    O(null), Xe(l);
    var o = f();
    return O(s), Xe(u), o;
  };
  return r && n.set("length", /* @__PURE__ */ U(
    /** @type {any[]} */
    e.length
  )), new Proxy(
    /** @type {any} */
    e,
    {
      defineProperty(f, s, u) {
        (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Gt();
        var o = n.get(s);
        return o === void 0 ? a(() => {
          var h = /* @__PURE__ */ U(u.value);
          return n.set(s, h), h;
        }) : Z(o, u.value, !0), !0;
      },
      deleteProperty(f, s) {
        var u = n.get(s);
        if (u === void 0) {
          if (s in f) {
            const o = a(() => /* @__PURE__ */ U(E));
            n.set(s, o), pe(i);
          }
        } else
          Z(u, E), pe(i);
        return !0;
      },
      get(f, s, u) {
        if (s === De)
          return e;
        var o = n.get(s), h = s in f;
        if (o === void 0 && (!h || de(f, s)?.writable) && (o = a(() => {
          var v = ve(h ? f[s] : E), _ = /* @__PURE__ */ U(v);
          return _;
        }), n.set(s, o)), o !== void 0) {
          var c = Q(o);
          return c === E ? void 0 : c;
        }
        return Reflect.get(f, s, u);
      },
      getOwnPropertyDescriptor(f, s) {
        var u = Reflect.getOwnPropertyDescriptor(f, s);
        if (u && "value" in u) {
          var o = n.get(s);
          o && (u.value = Q(o));
        } else if (u === void 0) {
          var h = n.get(s), c = h?.v;
          if (h !== void 0 && c !== E)
            return {
              enumerable: !0,
              configurable: !0,
              value: c,
              writable: !0
            };
        }
        return u;
      },
      has(f, s) {
        if (s === De)
          return !0;
        var u = n.get(s), o = u !== void 0 && u.v !== E || Reflect.has(f, s);
        if (u !== void 0 || p !== null && (!o || de(f, s)?.writable)) {
          u === void 0 && (u = a(() => {
            var c = o ? ve(f[s]) : E, v = /* @__PURE__ */ U(c);
            return v;
          }), n.set(s, u));
          var h = Q(u);
          if (h === E)
            return !1;
        }
        return o;
      },
      set(f, s, u, o) {
        var h = n.get(s), c = s in f;
        if (r && s === "length")
          for (var v = u; v < /** @type {Source<number>} */
          h.v; v += 1) {
            var _ = n.get(v + "");
            _ !== void 0 ? Z(_, E) : v in f && (_ = a(() => /* @__PURE__ */ U(E)), n.set(v + "", _));
          }
        if (h === void 0)
          (!c || de(f, s)?.writable) && (h = a(() => /* @__PURE__ */ U(void 0)), Z(h, ve(u)), n.set(s, h));
        else {
          c = h.v !== E;
          var g = a(() => ve(u));
          Z(h, g);
        }
        var x = Reflect.getOwnPropertyDescriptor(f, s);
        if (x?.set && x.set.call(o, u), !c) {
          if (r && typeof s == "string") {
            var D = (
              /** @type {Source<number>} */
              n.get("length")
            ), re = Number(s);
            Number.isInteger(re) && re >= D.v && Z(D, re + 1);
          }
          pe(i);
        }
        return !0;
      },
      ownKeys(f) {
        Q(i);
        var s = Reflect.ownKeys(f).filter((h) => {
          var c = n.get(h);
          return c === void 0 || c.v !== E;
        });
        for (var [u, o] of n)
          o.v !== E && !(u in f) && s.push(u);
        return s;
      },
      setPrototypeOf() {
        Kt();
      }
    }
  );
}
var Je, yn, yt, mt;
function mn() {
  if (Je === void 0) {
    Je = window, yn = /Firefox/.test(navigator.userAgent);
    var e = Element.prototype, t = Node.prototype, n = Text.prototype;
    yt = de(t, "firstChild").get, mt = de(t, "nextSibling").get, Ge(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), Ge(n) && (n.__t = void 0);
  }
}
function bt(e = "") {
  return document.createTextNode(e);
}
// @__NO_SIDE_EFFECTS__
function bn(e) {
  return (
    /** @type {TemplateNode | null} */
    yt.call(e)
  );
}
// @__NO_SIDE_EFFECTS__
function Et(e) {
  return (
    /** @type {TemplateNode | null} */
    mt.call(e)
  );
}
function Hn(e, t) {
  return /* @__PURE__ */ bn(e);
}
function Wn(e, t, n) {
  return (
    /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */
    document.createElementNS(Zt, e, void 0)
  );
}
function xt(e) {
  var t = d, n = p;
  O(null), q(null);
  try {
    return e();
  } finally {
    O(t), q(n);
  }
}
function En(e, t) {
  var n = t.last;
  n === null ? t.last = t.first = e : (n.next = e, e.prev = n, t.last = e);
}
function H(e, t) {
  var n = p;
  n !== null && (n.f & B) !== 0 && (e |= B);
  var r = {
    ctx: A,
    deps: null,
    nodes: null,
    f: e | T | P,
    first: null,
    fn: t,
    last: null,
    next: null,
    parent: n,
    b: n && n.b,
    prev: null,
    teardown: null,
    wv: 0,
    ac: null
  }, i = r;
  if ((e & ge) !== 0)
    le !== null ? le.push(r) : ne.ensure().schedule(r);
  else if (t !== null) {
    try {
      ce(r);
    } catch (a) {
      throw M(r), a;
    }
    i.deps === null && i.teardown === null && i.nodes === null && i.first === i.last && // either `null`, or a singular child
    (i.f & _e) === 0 && (i = i.first, (e & K) !== 0 && (e & ke) !== 0 && i !== null && (i.f |= ke));
  }
  if (i !== null && (i.parent = n, n !== null && En(i, n), d !== null && (d.f & b) !== 0 && (e & ee) === 0)) {
    var l = (
      /** @type {Derived} */
      d
    );
    (l.effects ??= []).push(i);
  }
  return r;
}
function $e() {
  return d !== null && !C;
}
function xn(e) {
  const t = H(Pe, null);
  return y(t, m), t.teardown = e, t;
}
function Sn(e) {
  return H(ge | Bt, e);
}
function Tn(e) {
  ne.ensure();
  const t = H(ee | _e, e);
  return (n = {}) => new Promise((r) => {
    n.outro ? Se(t, () => {
      M(t), r(void 0);
    }) : (M(t), r(void 0));
  });
}
function kn(e) {
  return H(Le | _e, e);
}
function An(e, t = 0) {
  return H(Pe | t, e);
}
function Zn(e, t = [], n = [], r = []) {
  cn(r, t, n, (i) => {
    H(Pe, () => e(...i.map(Q)));
  });
}
function Rn(e, t = 0) {
  var n = H(K | t, e);
  return n;
}
function W(e) {
  return H(G | _e, e);
}
function St(e) {
  var t = e.teardown;
  if (t !== null) {
    const n = oe, r = d;
    Qe(!0), O(null);
    try {
      t.call(null);
    } finally {
      Qe(n), O(r);
    }
  }
}
function ze(e, t = !1) {
  var n = e.first;
  for (e.first = e.last = null; n !== null; ) {
    const i = n.ac;
    i !== null && xt(() => {
      i.abort(Y);
    });
    var r = n.next;
    (n.f & ee) !== 0 ? n.parent = null : M(n, t), n = r;
  }
}
function Pn(e) {
  for (var t = e.first; t !== null; ) {
    var n = t.next;
    (t.f & G) === 0 && M(t), t = n;
  }
}
function M(e, t = !0) {
  var n = !1;
  (t || (e.f & Vt) !== 0) && e.nodes !== null && e.nodes.end !== null && (Nn(
    e.nodes.start,
    /** @type {TemplateNode} */
    e.nodes.end
  ), n = !0), y(e, Ke), ze(e, t && !n), we(e, 0);
  var r = e.nodes && e.nodes.t;
  if (r !== null)
    for (const l of r)
      l.stop();
  St(e), e.f ^= Ke, e.f |= I;
  var i = e.parent;
  i !== null && i.first !== null && Tt(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null;
}
function Nn(e, t) {
  for (; e !== null; ) {
    var n = e === t ? null : /* @__PURE__ */ Et(e);
    e.remove(), e = n;
  }
}
function Tt(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 Se(e, t, n = !0) {
  var r = [];
  kt(e, r, !0);
  var i = () => {
    n && M(e), t && t();
  }, l = r.length;
  if (l > 0) {
    var a = () => --l || i();
    for (var f of r)
      f.out(a);
  } else
    i();
}
function kt(e, t, n) {
  if ((e.f & B) === 0) {
    e.f ^= B;
    var r = e.nodes && e.nodes.t;
    if (r !== null)
      for (const f of r)
        (f.is_global || n) && t.push(f);
    for (var i = e.first; i !== null; ) {
      var l = i.next, a = (i.f & ke) !== 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.
      (i.f & G) !== 0 && (e.f & K) !== 0;
      kt(i, t, a ? n : !1), i = l;
    }
  }
}
function On(e, t) {
  if (e.nodes)
    for (var n = e.nodes.start, r = e.nodes.end; n !== null; ) {
      var i = n === r ? null : /* @__PURE__ */ Et(n);
      t.append(n), n = i;
    }
}
let Te = !1, oe = !1;
function Qe(e) {
  oe = e;
}
let d = null, C = !1;
function O(e) {
  d = e;
}
let p = null;
function q(e) {
  p = e;
}
let N = null;
function Dn(e) {
  d !== null && (N === null ? N = [e] : N.push(e));
}
let S = null, k = 0, R = null;
function Fn(e) {
  R = e;
}
let At = 1, J = 0, X = J;
function Xe(e) {
  X = e;
}
function Rt() {
  return ++At;
}
function me(e) {
  var t = e.f;
  if ((t & T) !== 0)
    return !0;
  if (t & b && (e.f &= ~te), (t & j) !== 0) {
    for (var n = (
      /** @type {Value[]} */
      e.deps
    ), r = n.length, i = 0; i < r; i++) {
      var l = n[i];
      if (me(
        /** @type {Derived} */
        l
      ) && dt(
        /** @type {Derived} */
        l
      ), l.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
    F === null && y(e, m);
  }
  return !1;
}
function Pt(e, t, n = !0) {
  var r = e.reactions;
  if (r !== null && !(N !== null && ue.call(N, e)))
    for (var i = 0; i < r.length; i++) {
      var l = r[i];
      (l.f & b) !== 0 ? Pt(
        /** @type {Derived} */
        l,
        t,
        !1
      ) : t === l && (n ? y(l, T) : (l.f & m) !== 0 && y(l, j), Ve(
        /** @type {Effect} */
        l
      ));
    }
}
function Nt(e) {
  var t = S, n = k, r = R, i = d, l = N, a = A, f = C, s = X, u = e.f;
  S = /** @type {null | Value[]} */
  null, k = 0, R = null, d = (u & (G | ee)) === 0 ? e : null, N = null, ae(e.ctx), C = !1, X = ++J, e.ac !== null && (xt(() => {
    e.ac.abort(Y);
  }), e.ac = null);
  try {
    e.f |= Ie;
    var o = (
      /** @type {Function} */
      e.fn
    ), h = o();
    e.f |= he;
    var c = e.deps, v = w?.is_fork;
    if (S !== null) {
      var _;
      if (v || we(e, k), c !== null && k > 0)
        for (c.length = k + S.length, _ = 0; _ < S.length; _++)
          c[k + _] = S[_];
      else
        e.deps = c = S;
      if ($e() && (e.f & P) !== 0)
        for (_ = k; _ < c.length; _++)
          (c[_].reactions ??= []).push(e);
    } else !v && c !== null && k < c.length && (we(e, k), c.length = k);
    if (ye() && R !== null && !C && c !== null && (e.f & (b | j | T)) === 0)
      for (_ = 0; _ < /** @type {Source[]} */
      R.length; _++)
        Pt(
          R[_],
          /** @type {Effect} */
          e
        );
    if (i !== null && i !== e) {
      if (J++, i.deps !== null)
        for (let g = 0; g < n; g += 1)
          i.deps[g].rv = J;
      if (t !== null)
        for (const g of t)
          g.rv = J;
      R !== null && (r === null ? r = R : r.push(.../** @type {Source[]} */
      R));
    }
    return (e.f & $) !== 0 && (e.f ^= $), h;
  } catch (g) {
    return lt(g);
  } finally {
    e.f ^= Ie, S = t, k = n, R = r, d = i, N = l, ae(a), C = f, X = s;
  }
}
function Cn(e, t) {
  let n = t.reactions;
  if (n !== null) {
    var r = Ct.call(n, e);
    if (r !== -1) {
      var i = n.length - 1;
      i === 0 ? n = t.reactions = null : (n[r] = n[i], 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
  (S === null || !ue.call(S, t))) {
    var l = (
      /** @type {Derived} */
      t
    );
    (l.f & P) !== 0 && (l.f ^= P, l.f &= ~te), Ue(l), gn(l), we(l, 0);
  }
}
function we(e, t) {
  var n = e.deps;
  if (n !== null)
    for (var r = t; r < n.length; r++)
      Cn(e, n[r]);
}
function ce(e) {
  var t = e.f;
  if ((t & I) === 0) {
    y(e, m);
    var n = p, r = Te;
    p = e, Te = !0;
    try {
      (t & (K | it)) !== 0 ? Pn(e) : ze(e), St(e);
      var i = Nt(e);
      e.teardown = typeof i == "function" ? i : null, e.wv = At;
      var l;
    } finally {
      Te = r, p = n;
    }
  }
}
function Q(e) {
  var t = e.f, n = (t & b) !== 0;
  if (d !== null && !C) {
    var r = p !== null && (p.f & I) !== 0;
    if (!r && (N === null || !ue.call(N, e))) {
      var i = d.deps;
      if ((d.f & Ie) !== 0)
        e.rv < J && (e.rv = J, S === null && i !== null && i[k] === e ? k++ : S === null ? S = [e] : S.push(e));
      else {
        (d.deps ??= []).push(e);
        var l = e.reactions;
        l === null ? e.reactions = [d] : ue.call(l, d) || l.push(d);
      }
    }
  }
  if (oe && z.has(e))
    return z.get(e);
  if (n) {
    var a = (
      /** @type {Derived} */
      e
    );
    if (oe) {
      var f = a.v;
      return ((a.f & m) === 0 && a.reactions !== null || Dt(a)) && (f = Be(a)), z.set(a, f), f;
    }
    var s = (a.f & P) === 0 && !C && d !== null && (Te || (d.f & P) !== 0), u = (a.f & he) === 0;
    me(a) && (s && (a.f |= P), dt(a)), s && !u && (pt(a), Ot(a));
  }
  if (F?.has(e))
    return F.get(e);
  if ((e.f & $) !== 0)
    throw e.v;
  return e.v;
}
function Ot(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 && (pt(
        /** @type {Derived} */
        t
      ), Ot(
        /** @type {Derived} */
        t
      ));
}
function Dt(e) {
  if (e.v === E) return !0;
  if (e.deps === null) return !1;
  for (const t of e.deps)
    if (z.has(t) || (t.f & b) !== 0 && Dt(
      /** @type {Derived} */
      t
    ))
      return !0;
  return !1;
}
function In(e) {
  var t = C;
  try {
    return C = !0, e();
  } finally {
    C = t;
  }
}
const Mn = ["touchstart", "touchmove"];
function jn(e) {
  return Mn.includes(e);
}
const be = /* @__PURE__ */ Symbol("events"), qn = /* @__PURE__ */ new Set(), et = /* @__PURE__ */ new Set();
let tt = null;
function nt(e) {
  var t = this, n = (
    /** @type {Node} */
    t.ownerDocument
  ), r = e.type, i = e.composedPath?.() || [], l = (
    /** @type {null | Element} */
    i[0] || e.target
  );
  tt = e;
  var a = 0, f = tt === e && e[be];
  if (f) {
    var s = i.indexOf(f);
    if (s !== -1 && (t === document || t === /** @type {any} */
    window)) {
      e[be] = t;
      return;
    }
    var u = i.indexOf(t);
    if (u === -1)
      return;
    s <= u && (a = s);
  }
  if (l = /** @type {Element} */
  i[a] || e.target, l !== t) {
    Mt(e, "currentTarget", {
      configurable: !0,
      get() {
        return l || n;
      }
    });
    var o = d, h = p;
    O(null), q(null);
    try {
      for (var c, v = []; l !== null; ) {
        var _ = l.assignedSlot || l.parentNode || /** @type {any} */
        l.host || null;
        try {
          var g = l[be]?.[r];
          g != null && (!/** @type {any} */
          l.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 === l) && g.call(l, e);
        } catch (x) {
          c ? v.push(x) : c = x;
        }
        if (e.cancelBubble || _ === t || _ === null)
          break;
        l = _;
      }
      if (c) {
        for (let x of v)
          queueMicrotask(() => {
            throw x;
          });
        throw c;
      }
    } finally {
      e[be] = t, delete e.currentTarget, O(o), q(h);
    }
  }
}
function Jn(e, t) {
  var n = t == null ? "" : typeof t == "object" ? `${t}` : t;
  n !== (e.__t ??= e.nodeValue) && (e.__t = n, e.nodeValue = `${n}`);
}
function Qn(e, t) {
  return Ln(e, t);
}
const Ee = /* @__PURE__ */ new Map();
function Ln(e, { target: t, anchor: n, props: r = {}, events: i, context: l, intro: a = !0, transformError: f }) {
  mn();
  var s = void 0, u = Tn(() => {
    var o = n ?? t.appendChild(bt());
    an(
      /** @type {TemplateNode} */
      o,
      {
        pending: () => {
        }
      },
      (v) => {
        en({});
        var _ = (
          /** @type {ComponentContext} */
          A
        );
        l && (_.c = l), i && (r.$$events = i), s = e(v, r) || {}, tn();
      },
      f
    );
    var h = /* @__PURE__ */ new Set(), c = (v) => {
      for (var _ = 0; _ < v.length; _++) {
        var g = v[_];
        if (!h.has(g)) {
          h.add(g);
          var x = jn(g);
          for (const Oe of [t, document]) {
            var D = Ee.get(Oe);
            D === void 0 && (D = /* @__PURE__ */ new Map(), Ee.set(Oe, D));
            var re = D.get(g);
            re === void 0 ? (Oe.addEventListener(g, nt, { passive: x }), D.set(g, 1)) : D.set(g, re + 1);
          }
        }
      }
    };
    return c(It(qn)), et.add(c), () => {
      for (var v of h)
        for (const x of [t, document]) {
          var _ = (
            /** @type {Map<string, number>} */
            Ee.get(x)
          ), g = (
            /** @type {number} */
            _.get(v)
          );
          --g == 0 ? (x.removeEventListener(v, nt), _.delete(v), _.size === 0 && Ee.delete(x)) : _.set(v, g);
        }
      et.delete(c), o !== n && o.parentNode?.removeChild(o);
    };
  });
  return qe.set(s, u), s;
}
let qe = /* @__PURE__ */ new WeakMap();
function Xn(e, t) {
  const n = qe.get(e);
  return n ? (qe.delete(e), n(t)) : Promise.resolve();
}
export {
  I as D,
  Yn as L,
  $n as P,
  De as S,
  Gn as T,
  p as a,
  de as b,
  Wn as c,
  Q as d,
  ve as e,
  Bn as f,
  bn as g,
  zn as h,
  yn as i,
  vn as j,
  oe as k,
  Ye as l,
  Qn as m,
  Kn as n,
  Jn as o,
  Vn as p,
  Hn as q,
  Z as s,
  Zn as t,
  Xn as u
};
